]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
reset: Add Raspberry Pi 4 firmware reset controller
authorNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Mon, 29 Jun 2020 16:37:23 +0000 (18:37 +0200)
committerMatthias Brugger <mbrugger@suse.com>
Fri, 10 Jul 2020 09:49:28 +0000 (11:49 +0200)
Raspberry Pi 4's co-processor controls some of the board's HW
initialization process, but it's up to Linux to trigger it when
relevant. Introduce a reset controller capable of interfacing with
RPi4's co-processor that models these firmware initialization routines as
reset lines.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
drivers/reset/Kconfig
drivers/reset/Makefile
drivers/reset/reset-raspberrypi.c [new file with mode: 0644]
include/dt-bindings/reset/raspberrypi,firmware-reset.h [new file with mode: 0644]

index 58ba0c686e000696fddde8c725b5c3b0c3f2ad48..6d5356122343b81d1d539a429e9084d7a3424cad 100644 (file)
@@ -153,4 +153,15 @@ config RESET_SYSCON
        depends on DM_RESET
        help
          Support generic syscon mapped register reset devices.
+
+config RESET_RASPBERRYPI
+       bool "Raspberry Pi 4 Firmware Reset Controller Driver"
+       depends on DM_RESET && ARCH_BCM283X
+       default USB_XHCI_PCI
+       help
+         Raspberry Pi 4's co-processor controls some of the board's HW
+         initialization process, but it's up to Linux to trigger it when
+         relevant. This driver provides a reset controller capable of
+         interfacing with RPi4's co-processor and model these firmware
+         initialization routines as reset lines.
 endmenu
index 433f1eca540c16d088b765dbab5c573fc5c9c51d..8e0124b8dee3af9c2be466dbe5fdd9080425b955 100644 (file)
@@ -24,3 +24,4 @@ obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o
 obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
 obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o
+obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
diff --git a/drivers/reset/reset-raspberrypi.c b/drivers/reset/reset-raspberrypi.c
new file mode 100644 (file)
index 0000000..e2d284e
--- /dev/null
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Raspberry Pi 4 firmware reset driver
+ *
+ * Copyright (C) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+ */
+#include <common.h>
+#include <dm.h>
+#include <reset-uclass.h>
+#include <asm/arch/msg.h>
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+
+static int raspberrypi_reset_request(struct reset_ctl *reset_ctl)
+{
+       if (reset_ctl->id >= RASPBERRYPI_FIRMWARE_RESET_NUM_IDS)
+               return -EINVAL;
+
+       return 0;
+}
+
+static int raspberrypi_reset_free(struct reset_ctl *reset_ctl)
+{
+       return 0;
+}
+
+static int raspberrypi_reset_assert(struct reset_ctl *reset_ctl)
+{
+       switch (reset_ctl->id) {
+       case RASPBERRYPI_FIRMWARE_RESET_ID_USB:
+               bcm2711_notify_vl805_reset();
+               return 0;
+       default:
+               return -EINVAL;
+       }
+}
+
+static int raspberrypi_reset_deassert(struct reset_ctl *reset_ctl)
+{
+       return 0;
+}
+
+struct reset_ops raspberrypi_reset_ops = {
+       .request = raspberrypi_reset_request,
+       .rfree = raspberrypi_reset_free,
+       .rst_assert = raspberrypi_reset_assert,
+       .rst_deassert = raspberrypi_reset_deassert,
+};
+
+static const struct udevice_id raspberrypi_reset_ids[] = {
+       { .compatible = "raspberrypi,firmware-reset" },
+       { }
+};
+
+U_BOOT_DRIVER(raspberrypi_reset) = {
+       .name = "raspberrypi-reset",
+       .id = UCLASS_RESET,
+       .of_match = raspberrypi_reset_ids,
+       .ops = &raspberrypi_reset_ops,
+};
+
diff --git a/include/dt-bindings/reset/raspberrypi,firmware-reset.h b/include/dt-bindings/reset/raspberrypi,firmware-reset.h
new file mode 100644 (file)
index 0000000..1a4f4c7
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2020 Nicolas Saenz Julienne
+ * Author: Nicolas Saenz Julienne <nsaenzjulienne@suse.com>
+ */
+
+#ifndef _DT_BINDINGS_RASPBERRYPI_FIRMWARE_RESET_H
+#define _DT_BINDINGS_RASPBERRYPI_FIRMWARE_RESET_H
+
+#define RASPBERRYPI_FIRMWARE_RESET_ID_USB      0
+#define RASPBERRYPI_FIRMWARE_RESET_NUM_IDS     1
+
+#endif