sunxi: Fix gmac not working due to cpu_eth_init no longer being called
Subsystems (2)
PATCH 1/1 sunxi: Fix gmac not working due to cpu_eth_init no longer being called
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 moving the gpio setup to gpio_init() and by calling the clock, reset and pinmux setup function from s_init().
Note that the mdelay is dropped as the phy gets enabled much earlier now, so it is no longer needed.
--- arch/arm/cpu/armv7/sunxi/board.c | 32 +++++------------------------ arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++++- board/sunxi/gmac.c | 14 +------------ 3 files changed, 11 insertions(+), 41 deletions(-)
arch/arm/cpu/armv7/sunxi/board.c +5 -27
@@ -100,6 +100,10 @@ static int gpio_init(void)#error Unsupported console port number. Please fix pin mux settings in board.c#endif +#ifdef CONFIG_MACPWR +gpio_request (CONFIG_MACPWR ,"macpwr" ); +gpio_direction_output (CONFIG_MACPWR ,1 ); +#endif return 0 ; }
@@ -152,6 +156,7 @@ void s_init(void)timer_init ();gpio_init ();i2c_init_board (); +eth_init_board (); }#ifdef CONFIG_SPL_BUILD
@@ -259,30 +264,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
arch/arm/include/asm/arch-sunxi/sys_proto.h +5 -1
@@ -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 !definedCONFIG_SPL_BUILD && definedCONFIG_SUNXI_GMAC +void eth_init_board (void ); +#else +static inline void eth_init_board (void ) {} +#endif #endif
board/sunxi/gmac.c +1 -13
@@ -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 definedCONFIG_GMII -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_GMII ); -# else -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_MII ); -# endif -#endif }
Signature · 1 line
2.7.3
PATCH 1/1 sunxi: Fix gmac not working due to cpu_eth_init no longer being called
Quoted 9 lines · Hans de Goede
cpu_eth_initis 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 moving the gpio setup to
gpio_init()and by calling the clock, reset and pinmux setup function froms_init().Note that the mdelay is dropped as the phy gets enabled much earlier now, so it is no longer needed.
Everything is DM_ETH based now, right? Which is why this final hunk is OK?
Quoted 18 lines
[...]
(quoted diff) +0
-0@@ -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
board/sunxi/gmac.c +0
-12- -#ifdef CONFIG_DM_ETH -return 0 ; -#else -# ifdef CONFIG_RGMII -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_RGMII ); -# elif definedCONFIG_GMII -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_GMII ); -# else -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_MII ); -# endif -#endif ?}
PATCH 1/1 sunxi: Fix gmac not working due to cpu_eth_init no longer being called
Hi,
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
cpu_eth_initis no longer called for dm enabled eth drivers, this was causing the sunxi gmac eth controller to no longer work in u- boot.
Quoted 8 lines
Quoted 5 lines
This commit fixes this by moving the gpio setup to
gpio_init()and by calling the clock, reset and pinmux setup function froms_init().Note that the mdelay is dropped as the phy gets enabled much earlier now, so it is no longer needed.
Everything is
DM_ETHbased now, right? Which is why this final hunk is OK?
Correct, we only do DM for eth in sunxi now, we try to do only DM everywhere.
But we still have a bunch of things we need to convert, like i2c which has dm support in the core now I believe, patches welcome :)
Regards,
Hans
Quoted 19 lines
Quoted 19 lines
[...]
board/sunxi/gmac.c +0
-12@@ -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 definedCONFIG_GMII -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_GMII ); -# else -return designware_initialize (SUNXI_GMAC_BASE ,PHY_INTERFACE_MODE_MII ); -# endif -#endif }
PATCH 1/1 sunxi: Fix gmac not working due to cpu_eth_init no longer being called
Quoted 14 lines · Hans de Goede
Hi,
Quoted 11 lines · Ian Campbell
Quoted 9 lines · Hans de Goede
cpu_eth_initis 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 moving the gpio setup to
gpio_init()and by
calling the clock, reset and pinmux setup function froms_init().
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Note that the mdelay is dropped as the phy gets enabled much earlier
now, so it is no longer needed.Everything is
DM_ETHbased now, right? Which is why this final hunk is OK?Correct, we only do DM for eth in sunxi now,
Super. Acked-by: Ian Campbell <[email protected]>
Ian.