* updated libkcddb (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / architecture / riscv64 / package / u-boot / 0008-board-sifive-unmatched-refine-GEMGXL-initialized-fun.patch
blob00a8a403dceacc14ae21205c3aef85e0ee4ba261
1 From 5f26d71202f37d77ecf74da2ce7e4c3a3f4d48d3 Mon Sep 17 00:00:00 2001
2 From: Vincent Chen <vincent.chen@sifive.com>
3 Date: Thu, 8 Jul 2021 09:08:20 +0800
4 Subject: [PATCH 08/16] board: sifive: unmatched: refine GEMGXL initialized
5 function in SPL
7 Create a new function spl_reset_device_by_gpio to reset the device
8 whose reset pin is connected to the GPIO. Then, using this function
9 to initialize GEMGXL.
11 Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
12 ---
13 board/sifive/unmatched/spl.c | 58 +++++++++++++++++++++++++++++---------------
14 1 file changed, 39 insertions(+), 19 deletions(-)
16 diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c
17 index 5e1333b..b598f9f 100644
18 --- a/board/sifive/unmatched/spl.c
19 +++ b/board/sifive/unmatched/spl.c
20 @@ -22,43 +22,63 @@
21 #define MODE_SELECT_SD 0xb
22 #define MODE_SELECT_MASK GENMASK(3, 0)
24 -int spl_board_init_f(void)
25 +static inline int spl_reset_device_by_gpio(const char *label, int pin, int low_width)
27 int ret;
29 - ret = spl_soc_init();
30 + ret = gpio_request(pin, label);
31 if (ret) {
32 - debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret);
33 + debug("%s gpio request failed: %d\n", label, ret);
34 + return ret;
35 + }
37 + ret = gpio_direction_output(pin, 1);
38 + if (ret) {
39 + debug("%s gpio direction set failed: %d\n", label, ret);
40 return ret;
43 + udelay(1);
45 + gpio_set_value(pin, 0);
46 + udelay(low_width);
47 + gpio_set_value(pin, 1);
49 + return ret;
52 +static inline int spl_gemgxl_init(void)
54 + int ret;
56 * GEMGXL init VSC8541 PHY reset sequence;
57 * leave pull-down active for 2ms
59 udelay(2000);
60 - ret = gpio_request(GEM_PHY_RESET, "gem_phy_reset");
61 + ret = spl_reset_device_by_gpio("gem_phy_reset", GEM_PHY_RESET, 1);
62 + mdelay(15);
64 + return ret;
67 +int spl_board_init_f(void)
69 + int ret;
71 + ret = spl_soc_init();
72 if (ret) {
73 - debug("gem_phy_reset gpio request failed: %d\n", ret);
74 - return ret;
75 + debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret);
76 + goto end;
79 - /* Set GPIO 12 (PHY NRESET) */
80 - ret = gpio_direction_output(GEM_PHY_RESET, 1);
81 + ret = spl_gemgxl_init();
82 if (ret) {
83 - debug("gem_phy_reset gpio direction set failed: %d\n", ret);
84 - return ret;
85 + debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret);
86 + goto end;
89 - udelay(1);
91 - /* Reset PHY again to enter unmanaged mode */
92 - gpio_set_value(GEM_PHY_RESET, 0);
93 - udelay(1);
94 - gpio_set_value(GEM_PHY_RESET, 1);
95 - mdelay(15);
97 - return 0;
98 +end:
99 + return ret;
102 u32 spl_boot_device(void)
104 2.7.4