Nicolas Saenz Julienne | 057bbbd | 2020-06-29 18:37:23 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Raspberry Pi 4 firmware reset driver |
| 4 | * |
| 5 | * Copyright (C) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de> |
| 6 | */ |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <reset-uclass.h> |
| 10 | #include <asm/arch/msg.h> |
| 11 | #include <dt-bindings/reset/raspberrypi,firmware-reset.h> |
| 12 | |
| 13 | static int raspberrypi_reset_request(struct reset_ctl *reset_ctl) |
| 14 | { |
| 15 | if (reset_ctl->id >= RASPBERRYPI_FIRMWARE_RESET_NUM_IDS) |
| 16 | return -EINVAL; |
| 17 | |
| 18 | return 0; |
| 19 | } |
| 20 | |
Nicolas Saenz Julienne | 057bbbd | 2020-06-29 18:37:23 +0200 | [diff] [blame] | 21 | static int raspberrypi_reset_assert(struct reset_ctl *reset_ctl) |
| 22 | { |
| 23 | switch (reset_ctl->id) { |
| 24 | case RASPBERRYPI_FIRMWARE_RESET_ID_USB: |
| 25 | bcm2711_notify_vl805_reset(); |
| 26 | return 0; |
| 27 | default: |
| 28 | return -EINVAL; |
| 29 | } |
| 30 | } |
| 31 | |
Nicolas Saenz Julienne | 057bbbd | 2020-06-29 18:37:23 +0200 | [diff] [blame] | 32 | struct reset_ops raspberrypi_reset_ops = { |
| 33 | .request = raspberrypi_reset_request, |
Nicolas Saenz Julienne | 057bbbd | 2020-06-29 18:37:23 +0200 | [diff] [blame] | 34 | .rst_assert = raspberrypi_reset_assert, |
Nicolas Saenz Julienne | 057bbbd | 2020-06-29 18:37:23 +0200 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | static const struct udevice_id raspberrypi_reset_ids[] = { |
| 38 | { .compatible = "raspberrypi,firmware-reset" }, |
| 39 | { } |
| 40 | }; |
| 41 | |
| 42 | U_BOOT_DRIVER(raspberrypi_reset) = { |
| 43 | .name = "raspberrypi-reset", |
| 44 | .id = UCLASS_RESET, |
| 45 | .of_match = raspberrypi_reset_ids, |
| 46 | .ops = &raspberrypi_reset_ops, |
| 47 | }; |