diff mbox series

[2/2] board: sifive: unmatched: reset USB hub, PCIe-USB bridge, and ULPI device in SPL

Message ID 1625706501-964-3-git-send-email-vincent.chen@sifive.com
State Accepted
Commit 219cb173114c9cfaf1dc7fed21281f2c43c88c9f
Delegated to: Andes
Headers show
Series board: sifive: unmatched: reset multiple devices in SPL | expand

Commit Message

Vincent Chen July 8, 2021, 1:08 a.m. UTC
Ensure USB hub, PCIe-USB bridge, and ULPI device to be reset
even if the rebooting is without power-cycling.

Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
---
 board/sifive/unmatched/spl.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Leo Liang July 21, 2021, 2:24 p.m. UTC | #1
On Thu, Jul 08, 2021 at 09:08:21AM +0800, Vincent Chen wrote:
> Ensure USB hub, PCIe-USB bridge, and ULPI device to be reset
> even if the rebooting is without power-cycling.
> 
> Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> ---
>  board/sifive/unmatched/spl.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
diff mbox series

Patch

diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c
index b598f9f..d566327 100644
--- a/board/sifive/unmatched/spl.c
+++ b/board/sifive/unmatched/spl.c
@@ -16,6 +16,9 @@ 
 #include <asm/arch/gpio.h>
 #include <asm/arch/spl.h>
 
+#define UBRDG_RESET	SIFIVE_GENERIC_GPIO_NR(0, 7)
+#define ULPI_RESET	SIFIVE_GENERIC_GPIO_NR(0, 9)
+#define UHUB_RESET	SIFIVE_GENERIC_GPIO_NR(0, 11)
 #define GEM_PHY_RESET	SIFIVE_GENERIC_GPIO_NR(0, 12)
 
 #define MODE_SELECT_REG		0x1000
@@ -61,6 +64,21 @@  static inline int spl_gemgxl_init(void)
 	return ret;
 }
 
+static inline int spl_usb_pcie_bridge_init(void)
+{
+	return spl_reset_device_by_gpio("usb_pcie_bridge_reset", UBRDG_RESET, 3000);
+}
+
+static inline int spl_usb_hub_init(void)
+{
+	return spl_reset_device_by_gpio("usb_hub_reset", UHUB_RESET, 100);
+}
+
+static inline int spl_ulpi_init(void)
+{
+	return spl_reset_device_by_gpio("ulpi_reset", ULPI_RESET, 1);
+}
+
 int spl_board_init_f(void)
 {
 	int ret;
@@ -77,6 +95,24 @@  int spl_board_init_f(void)
 		goto end;
 	}
 
+	ret = spl_usb_pcie_bridge_init();
+	if (ret) {
+		debug("USB Bridge (ASM1042A) init failed: %d\n", ret);
+		goto end;
+	}
+
+	ret = spl_usb_hub_init();
+	if (ret) {
+		debug("USB Hub (ASM1074) init failed: %d\n", ret);
+		goto end;
+	}
+
+	ret = spl_ulpi_init();
+	if (ret) {
+		debug("USB 2.0 PHY (USB3320C) init failed: %d\n", ret);
+		goto end;
+	}
+
 end:
 	return ret;
 }