From f91df70bc5d469e933afed723b90c90f33372bc3 Mon Sep 17 00:00:00 2001 From: speriaka Date: Tue, 30 Apr 2019 10:52:33 +0530 Subject: [PATCH] u-boot: ipq6018: eth: Add mdio gpio config from DTS Change-Id: I6d8288e2450415bb2a1616b0ecb63b2714ecfa47 Signed-off-by: speriaka --- board/qca/arm/ipq6018/ipq6018.c | 41 +++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/board/qca/arm/ipq6018/ipq6018.c b/board/qca/arm/ipq6018/ipq6018.c index 1d9ceae72e..f6e31bcfa5 100644 --- a/board/qca/arm/ipq6018/ipq6018.c +++ b/board/qca/arm/ipq6018/ipq6018.c @@ -845,10 +845,39 @@ void malibu_phy_reset_init_done(void) } } +int get_mdc_mdio_gpio(int mdc_mdio_gpio[2]) +{ + int mdc_mdio_gpio_cnt = 2, node; + int res = -1; + node = fdt_path_offset(gd->fdt_blob, "/ess-switch"); + if (node >= 0) { + res = fdtdec_get_int_array(gd->fdt_blob, node, "mdc_mdio_gpio", + (u32 *)mdc_mdio_gpio, mdc_mdio_gpio_cnt); + if (res >= 0) + return mdc_mdio_gpio_cnt; + } + + return res; +} + +void set_function_select_as_mdc_mdio(void) +{ + int mdc_mdio_gpio[2] = {0}, mdc_mdio_gpio_cnt, i; + unsigned int *mdc_mdio_gpio_base; + + mdc_mdio_gpio_cnt = get_mdc_mdio_gpio(mdc_mdio_gpio); + if (mdc_mdio_gpio_cnt >= 1) { + for (i = 0; i < mdc_mdio_gpio_cnt; i++) { + if (mdc_mdio_gpio[i] >=0) { + mdc_mdio_gpio_base = (unsigned int *)GPIO_CONFIG_ADDR(mdc_mdio_gpio[i]); + writel(0x7, mdc_mdio_gpio_base); + } + } + } +} + void eth_clock_enable(void) { - int tlmm_base = 0x1025000; - /* * ethernet clk rcgr block init -- start * these clk init will be moved to sbl later @@ -902,15 +931,13 @@ void eth_clock_enable(void) * these clk init will be moved to sbl later */ + /* set function select as mdio */ + set_function_select_as_mdc_mdio(); + /* bring phy out of reset */ - writel(7, tlmm_base + 0x1f000); - writel(7, tlmm_base + 0x20000); - writel(0x203, tlmm_base); - writel(0, tlmm_base + 0x4); malibu_phy_reset_init(); napa_phy_reset_init(); mdelay(500); - writel(2, tlmm_base + 0x4); malibu_phy_reset_init_done(); napa_phy_reset_init_done(); mdelay(500);