blob: 1792f0813f79d7d1ca92a2301bcb53e4c596df5c [file] [log] [blame]
Nicolas Saenz Julienne057bbbd2020-06-29 18:37:23 +02001// 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 Julienne057bbbd2020-06-29 18:37:23 +02007#include <dm.h>
8#include <reset-uclass.h>
9#include <asm/arch/msg.h>
10#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
11
12static 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 Julienne057bbbd2020-06-29 18:37:23 +020020static 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 Julienne057bbbd2020-06-29 18:37:23 +020031struct reset_ops raspberrypi_reset_ops = {
32 .request = raspberrypi_reset_request,
Nicolas Saenz Julienne057bbbd2020-06-29 18:37:23 +020033 .rst_assert = raspberrypi_reset_assert,
Nicolas Saenz Julienne057bbbd2020-06-29 18:37:23 +020034};
35
36static const struct udevice_id raspberrypi_reset_ids[] = {
37 { .compatible = "raspberrypi,firmware-reset" },
38 { }
39};
40
41U_BOOT_DRIVER(raspberrypi_reset) = {
42 .name = "raspberrypi-reset",
43 .id = UCLASS_RESET,
44 .of_match = raspberrypi_reset_ids,
45 .ops = &raspberrypi_reset_ops,
46};