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