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 diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
32 index e80785b..7653148 100644
33 --- a/arch/arm/cpu/armv7/sunxi/board.c
34 +++ b/arch/arm/cpu/armv7/sunxi/board.c
35 @@ -152,6 +152,7 @@ void s_init(void)
42 #ifdef CONFIG_SPL_BUILD
43 @@ -259,30 +260,3 @@ void enable_caches(void)
48 -#ifdef CONFIG_CMD_NET
50 - * Initializes on-chip ethernet controllers.
51 - * to override, implement board_eth_init()
53 -int cpu_eth_init(bd_t *bis)
55 - __maybe_unused int rc;
58 - gpio_request(CONFIG_MACPWR, "macpwr");
59 - gpio_direction_output(CONFIG_MACPWR, 1);
63 -#ifdef CONFIG_SUNXI_GMAC
64 - rc = sunxi_gmac_initialize(bis);
66 - printf("sunxi: failed to initialize gmac\n");
74 diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h
75 index 9df3744..a373319 100644
76 --- a/arch/arm/include/asm/arch-sunxi/sys_proto.h
77 +++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h
78 @@ -24,6 +24,10 @@ void sdelay(unsigned long);
79 void return_to_fel(uint32_t lr, uint32_t sp);
81 /* Board / SoC level designware gmac init */
82 -int sunxi_gmac_initialize(bd_t *bis);
83 +#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC
84 +void eth_init_board(void);
86 +static inline void eth_init_board(void) {}
90 diff --git a/board/sunxi/board.c b/board/sunxi/board.c
91 index 80eae9c..e16718f 100644
92 --- a/board/sunxi/board.c
93 +++ b/board/sunxi/board.c
94 @@ -90,6 +90,11 @@ int board_init(void)
99 + gpio_request(CONFIG_MACPWR, "macpwr");
100 + gpio_direction_output(CONFIG_MACPWR, 1);
103 /* Uses dm gpio code so do this here and not in i2c_init_board() */
104 return soft_i2c_board_init();
106 diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
107 index 4e222d8..69eb8ff 100644
108 --- a/board/sunxi/gmac.c
109 +++ b/board/sunxi/gmac.c
111 #include <asm/arch/clock.h>
112 #include <asm/arch/gpio.h>
114 -int sunxi_gmac_initialize(bd_t *bis)
115 +void eth_init_board(void)
118 struct sunxi_ccm_reg *const ccm =
119 @@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis)
120 for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++)
121 sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC);
124 -#ifdef CONFIG_DM_ETH
127 -# ifdef CONFIG_RGMII
128 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
129 -# elif defined CONFIG_GMII
130 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
132 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);