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 1/2] board: sifive: unmatched: refine GEMGXL initialized function in SPL
Date: Thu, 8 Jul 2021 09:08:20 +0800 [thread overview]
Message-ID: <1625706501-964-2-git-send-email-vincent.chen@sifive.com> (raw)
In-Reply-To: <1625706501-964-1-git-send-email-vincent.chen@sifive.com>
Create a new function spl_reset_device_by_gpio to reset the device
whose reset pin is connected to the GPIO. Then, using this function
to initialize GEMGXL.
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
---
board/sifive/unmatched/spl.c | 58 +++++++++++++++++++++++++++++---------------
1 file changed, 39 insertions(+), 19 deletions(-)
diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c
index 5e1333b..b598f9f 100644
--- a/board/sifive/unmatched/spl.c
+++ b/board/sifive/unmatched/spl.c
@@ -22,43 +22,63 @@
#define MODE_SELECT_SD 0xb
#define MODE_SELECT_MASK GENMASK(3, 0)
-int spl_board_init_f(void)
+static inline int spl_reset_device_by_gpio(const char *label, int pin, int low_width)
{
int ret;
- ret = spl_soc_init();
+ ret = gpio_request(pin, label);
if (ret) {
- debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret);
+ debug("%s gpio request failed: %d\n", label, ret);
+ return ret;
+ }
+
+ ret = gpio_direction_output(pin, 1);
+ if (ret) {
+ debug("%s gpio direction set failed: %d\n", label, ret);
return ret;
}
+ udelay(1);
+
+ gpio_set_value(pin, 0);
+ udelay(low_width);
+ gpio_set_value(pin, 1);
+
+ return ret;
+}
+
+static inline int spl_gemgxl_init(void)
+{
+ int ret;
/*
* GEMGXL init VSC8541 PHY reset sequence;
* leave pull-down active for 2ms
*/
udelay(2000);
- ret = gpio_request(GEM_PHY_RESET, "gem_phy_reset");
+ ret = spl_reset_device_by_gpio("gem_phy_reset", GEM_PHY_RESET, 1);
+ mdelay(15);
+
+ return ret;
+}
+
+int spl_board_init_f(void)
+{
+ int ret;
+
+ ret = spl_soc_init();
if (ret) {
- debug("gem_phy_reset gpio request failed: %d\n", ret);
- return ret;
+ debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret);
+ goto end;
}
- /* Set GPIO 12 (PHY NRESET) */
- ret = gpio_direction_output(GEM_PHY_RESET, 1);
+ ret = spl_gemgxl_init();
if (ret) {
- debug("gem_phy_reset gpio direction set failed: %d\n", ret);
- return ret;
+ debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret);
+ goto end;
}
- udelay(1);
-
- /* Reset PHY again to enter unmanaged mode */
- gpio_set_value(GEM_PHY_RESET, 0);
- udelay(1);
- gpio_set_value(GEM_PHY_RESET, 1);
- mdelay(15);
-
- return 0;
+end:
+ return ret;
}
u32 spl_boot_device(void)
--
2.7.4
next prev parent reply other threads:[~2021-07-08 1:08 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 ` Vincent Chen [this message]
2021-07-21 14:23 ` [PATCH 1/2] board: sifive: unmatched: refine GEMGXL initialized function " Leo Liang
2021-07-08 1:08 ` [PATCH 2/2] board: sifive: unmatched: reset USB hub, PCIe-USB bridge, and ULPI device " Vincent Chen
2021-07-21 14:24 ` 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-2-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