sunxi: Fix gmac not working due to cpu_eth_init no longer being called
authorHans de Goede <hdegoede@redhat.com>
Thu, 17 Mar 2016 12:53:03 +0000 (13:53 +0100)
committerVagrant Cascadian <vagrant@debian.org>
Tue, 28 Jun 2016 07:38:27 +0000 (07:38 +0000)
cpu_eth_init is no longer called for dm enabled eth drivers, this
was causing the sunxi gmac eth controller to no longer work in u-boot.

This commit fixes this by calling the clock, reset and pinmux setup
function from s_init() and enabling the phy power pin (if any) from
board_init().

The enabling of phy power cannot be done from s_init because it uses dm
and dm is not ready yet at this point.

Note that the mdelay is dropped as the phy gets enabled much earlier
now, so it is no longer needed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Tested-by: Karsten Merker <merker@debian.org>
Tested-by: Michael Haas <haas@computerlinguist.org>
Gbp-Pq: Topic upstream/sunxi
Gbp-Pq: Name 0001-sunxi-Fix-gmac-not-working-due-to-cpu_eth_init-no-lo.patch

arch/arm/cpu/armv7/sunxi/board.c
arch/arm/include/asm/arch-sunxi/sys_proto.h
board/sunxi/board.c
board/sunxi/gmac.c

index eb5f4b686ea7416f02cb9377d2e4d78413ad350e..bca573398a47a074eb5e17dce983d39a976b59cb 100644 (file)
@@ -136,6 +136,7 @@ void s_init(void)
        timer_init();
        gpio_init();
        i2c_init_board();
+       eth_init_board();
 }
 
 #ifdef CONFIG_SPL_BUILD
@@ -243,30 +244,3 @@ void enable_caches(void)
        dcache_enable();
 }
 #endif
-
-#ifdef CONFIG_CMD_NET
-/*
- * Initializes on-chip ethernet controllers.
- * to override, implement board_eth_init()
- */
-int cpu_eth_init(bd_t *bis)
-{
-       __maybe_unused int rc;
-
-#ifdef CONFIG_MACPWR
-       gpio_request(CONFIG_MACPWR, "macpwr");
-       gpio_direction_output(CONFIG_MACPWR, 1);
-       mdelay(200);
-#endif
-
-#ifdef CONFIG_SUNXI_GMAC
-       rc = sunxi_gmac_initialize(bis);
-       if (rc < 0) {
-               printf("sunxi: failed to initialize gmac\n");
-               return rc;
-       }
-#endif
-
-       return 0;
-}
-#endif
index 9df37445210aebc1d7304f822fa74ad61e9b5a23..a373319a2b4a14b503b1c5f0b6f5a56e83ff7b37 100644 (file)
@@ -24,6 +24,10 @@ void sdelay(unsigned long);
 void return_to_fel(uint32_t lr, uint32_t sp);
 
 /* Board / SoC level designware gmac init */
-int sunxi_gmac_initialize(bd_t *bis);
+#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC
+void eth_init_board(void);
+#else
+static inline void eth_init_board(void) {}
+#endif
 
 #endif
index 15b7af634cb275b48bd308e0b52c433407624bac..6a4b44f1bcc63ec4942884c3d162ad72e375491a 100644 (file)
@@ -90,6 +90,11 @@ int board_init(void)
        if (ret)
                return ret;
 
+#ifdef CONFIG_MACPWR
+       gpio_request(CONFIG_MACPWR, "macpwr");
+       gpio_direction_output(CONFIG_MACPWR, 1);
+#endif
+
        /* Uses dm gpio code so do this here and not in i2c_init_board() */
        return soft_i2c_board_init();
 }
index 4e222d88c0d3a9d543ace1f1c17665394f8f25cb..69eb8ff2d921170817b0e3d12c9ad9472c75045e 100644 (file)
@@ -6,7 +6,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
 
-int sunxi_gmac_initialize(bd_t *bis)
+void eth_init_board(void)
 {
        int pin;
        struct sunxi_ccm_reg *const ccm =
@@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis)
        for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++)
                sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC);
 #endif
-
-#ifdef CONFIG_DM_ETH
-       return 0;
-#else
-# ifdef CONFIG_RGMII
-       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
-# elif defined CONFIG_GMII
-       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
-# else
-       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
-# endif
-#endif
 }