blob: 804e32b8dd140b21b18d1039e1a794984d9763b5 [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 */
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
13static 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 Julienne057bbbd2020-06-29 18:37:23 +020021static 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 Julienne057bbbd2020-06-29 18:37:23 +020032struct reset_ops raspberrypi_reset_ops = {
33 .request = raspberrypi_reset_request,
Nicolas Saenz Julienne057bbbd2020-06-29 18:37:23 +020034 .rst_assert = raspberrypi_reset_assert,
Nicolas Saenz Julienne057bbbd2020-06-29 18:37:23 +020035};
36
37static const struct udevice_id raspberrypi_reset_ids[] = {
38 { .compatible = "raspberrypi,firmware-reset" },
39 { }
40};
41
42U_BOOT_DRIVER(raspberrypi_reset) = {
43 .name = "raspberrypi-reset",
44 .id = UCLASS_RESET,
45 .of_match = raspberrypi_reset_ids,
46 .ops = &raspberrypi_reset_ops,
47};