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
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
11 Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
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
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)
29 - ret = spl_soc_init();
30 + ret = gpio_request(pin, label);
32 - debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret);
33 + debug("%s gpio request failed: %d\n", label, ret);
37 + ret = gpio_direction_output(pin, 1);
39 + debug("%s gpio direction set failed: %d\n", label, ret);
45 + gpio_set_value(pin, 0);
47 + gpio_set_value(pin, 1);
52 +static inline int spl_gemgxl_init(void)
56 * GEMGXL init VSC8541 PHY reset sequence;
57 * leave pull-down active for 2ms
60 - ret = gpio_request(GEM_PHY_RESET, "gem_phy_reset");
61 + ret = spl_reset_device_by_gpio("gem_phy_reset", GEM_PHY_RESET, 1);
67 +int spl_board_init_f(void)
71 + ret = spl_soc_init();
73 - debug("gem_phy_reset gpio request failed: %d\n", ret);
75 + debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret);
79 - /* Set GPIO 12 (PHY NRESET) */
80 - ret = gpio_direction_output(GEM_PHY_RESET, 1);
81 + ret = spl_gemgxl_init();
83 - debug("gem_phy_reset gpio direction set failed: %d\n", ret);
85 + debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret);
91 - /* Reset PHY again to enter unmanaged mode */
92 - gpio_set_value(GEM_PHY_RESET, 0);
94 - gpio_set_value(GEM_PHY_RESET, 1);
102 u32 spl_boot_device(void)