1 From fc8991c61c393ce6a9d3dfc97cb56dbbd9e8cbba Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Thu, 17 Mar 2016 13:53:03 +0100
4 Subject: [PATCH] sunxi: Fix gmac not working due to cpu_eth_init no longer
7 cpu_eth_init is no longer called for dm enabled eth drivers, this
8 was causing the sunxi gmac eth controller to no longer work in u-boot.
10 This commit fixes this by calling the clock, reset and pinmux setup
11 function from s_init() and enabling the phy power pin (if any) from
14 The enabling of phy power cannot be done from s_init because it uses dm
15 and dm is not ready yet at this point.
17 Note that the mdelay is dropped as the phy gets enabled much earlier
18 now, so it is no longer needed.
20 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
21 Acked-by: Ian Campbell <ijc@hellion.org.uk>
22 Tested-by: Karsten Merker <merker@debian.org>
23 Tested-by: Michael Haas <haas@computerlinguist.org>
25 arch/arm/cpu/armv7/sunxi/board.c | 28 +---------------------------
26 arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++++-
27 board/sunxi/board.c | 5 +++++
28 board/sunxi/gmac.c | 14 +-------------
29 4 files changed, 12 insertions(+), 41 deletions(-)
31 --- a/arch/arm/cpu/armv7/sunxi/board.c
32 +++ b/arch/arm/cpu/armv7/sunxi/board.c
33 @@ -136,6 +136,7 @@ void s_init(void)
40 #ifdef CONFIG_SPL_BUILD
41 @@ -243,30 +244,3 @@ void enable_caches(void)
46 -#ifdef CONFIG_CMD_NET
48 - * Initializes on-chip ethernet controllers.
49 - * to override, implement board_eth_init()
51 -int cpu_eth_init(bd_t *bis)
53 - __maybe_unused int rc;
56 - gpio_request(CONFIG_MACPWR, "macpwr");
57 - gpio_direction_output(CONFIG_MACPWR, 1);
61 -#ifdef CONFIG_SUNXI_GMAC
62 - rc = sunxi_gmac_initialize(bis);
64 - printf("sunxi: failed to initialize gmac\n");
72 --- a/arch/arm/include/asm/arch-sunxi/sys_proto.h
73 +++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h
74 @@ -24,6 +24,10 @@ void sdelay(unsigned long);
75 void return_to_fel(uint32_t lr, uint32_t sp);
77 /* Board / SoC level designware gmac init */
78 -int sunxi_gmac_initialize(bd_t *bis);
79 +#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC
80 +void eth_init_board(void);
82 +static inline void eth_init_board(void) {}
86 --- a/board/sunxi/board.c
87 +++ b/board/sunxi/board.c
88 @@ -90,6 +90,11 @@ int board_init(void)
93 + gpio_request(CONFIG_MACPWR, "macpwr");
94 + gpio_direction_output(CONFIG_MACPWR, 1);
97 /* Uses dm gpio code so do this here and not in i2c_init_board() */
98 return soft_i2c_board_init();
100 --- a/board/sunxi/gmac.c
101 +++ b/board/sunxi/gmac.c
103 #include <asm/arch/clock.h>
104 #include <asm/arch/gpio.h>
106 -int sunxi_gmac_initialize(bd_t *bis)
107 +void eth_init_board(void)
110 struct sunxi_ccm_reg *const ccm =
111 @@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis)
112 for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++)
113 sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC);
116 -#ifdef CONFIG_DM_ETH
119 -# ifdef CONFIG_RGMII
120 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
121 -# elif defined CONFIG_GMII
122 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
124 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);