public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vincent Chen <vincent.chen@sifive.com>
To: green.wan@sifive.com, rick@andestech.com, bmeng.cn@gmail.com,
	ycliang@andestech.com, u-boot@lists.denx.de
Cc: vincent.chen@sifive.com
Subject: [PATCH 2/2] board: sifive: unmatched: reset USB hub, PCIe-USB bridge, and ULPI device in SPL
Date: Thu,  8 Jul 2021 09:08:21 +0800	[thread overview]
Message-ID: <1625706501-964-3-git-send-email-vincent.chen@sifive.com> (raw)
In-Reply-To: <1625706501-964-1-git-send-email-vincent.chen@sifive.com>

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(+)

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;
 }
-- 
2.7.4


  parent reply	other threads:[~2021-07-08  1:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  1:08 [PATCH 0/2] board: sifive: unmatched: reset multiple devices in SPL Vincent Chen
2021-07-08  1:08 ` [PATCH 1/2] board: sifive: unmatched: refine GEMGXL initialized function " Vincent Chen
2021-07-21 14:23   ` Leo Liang
2021-07-08  1:08 ` Vincent Chen [this message]
2021-07-21 14:24   ` [PATCH 2/2] board: sifive: unmatched: reset USB hub, PCIe-USB bridge, and ULPI device " Leo Liang
2021-07-20  7:57 ` [PATCH 0/2] board: sifive: unmatched: reset multiple devices " Vincent Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1625706501-964-3-git-send-email-vincent.chen@sifive.com \
    --to=vincent.chen@sifive.com \
    --cc=bmeng.cn@gmail.com \
    --cc=green.wan@sifive.com \
    --cc=rick@andestech.com \
    --cc=u-boot@lists.denx.de \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox