blob: e2d284e5aca5383a3f2ab12c02f1f59ffeb97457 [file] [log] [blame]
Nicolas Saenz Juliennef676eb22020-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
21static int raspberrypi_reset_free(struct reset_ctl *reset_ctl)
22{
23 return 0;
24}
25
26static int raspberrypi_reset_assert(struct reset_ctl *reset_ctl)
27{
28 switch (reset_ctl->id) {
29 case RASPBERRYPI_FIRMWARE_RESET_ID_USB:
30 bcm2711_notify_vl805_reset();
31 return 0;
32 default:
33 return -EINVAL;
34 }
35}
36
37static int raspberrypi_reset_deassert(struct reset_ctl *reset_ctl)
38{
39 return 0;
40}
41
42struct reset_ops raspberrypi_reset_ops = {
43 .request = raspberrypi_reset_request,
44 .rfree = raspberrypi_reset_free,
45 .rst_assert = raspberrypi_reset_assert,
46 .rst_deassert = raspberrypi_reset_deassert,
47};
48
49static const struct udevice_id raspberrypi_reset_ids[] = {
50 { .compatible = "raspberrypi,firmware-reset" },
51 { }
52};
53
54U_BOOT_DRIVER(raspberrypi_reset) = {
55 .name = "raspberrypi-reset",
56 .id = UCLASS_RESET,
57 .of_match = raspberrypi_reset_ids,
58 .ops = &raspberrypi_reset_ops,
59};
60