uboot-sunxi: fix default config for OLIMEX A13 SOM (FS#239)
[openwrt/staging/florian.git] / package / boot / uboot-sunxi / patches / 014-fix-gmac-init.patch
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
5 being called
6
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.
9
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
12 board_init().
13
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.
16
17 Note that the mdelay is dropped as the phy gets enabled much earlier
18 now, so it is no longer needed.
19
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>
24 ---
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(-)
30
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)
34 timer_init();
35 gpio_init();
36 i2c_init_board();
37 + eth_init_board();
38 }
39
40 #ifdef CONFIG_SPL_BUILD
41 @@ -243,30 +244,3 @@ void enable_caches(void)
42 dcache_enable();
43 }
44 #endif
45 -
46 -#ifdef CONFIG_CMD_NET
47 -/*
48 - * Initializes on-chip ethernet controllers.
49 - * to override, implement board_eth_init()
50 - */
51 -int cpu_eth_init(bd_t *bis)
52 -{
53 - __maybe_unused int rc;
54 -
55 -#ifdef CONFIG_MACPWR
56 - gpio_request(CONFIG_MACPWR, "macpwr");
57 - gpio_direction_output(CONFIG_MACPWR, 1);
58 - mdelay(200);
59 -#endif
60 -
61 -#ifdef CONFIG_SUNXI_GMAC
62 - rc = sunxi_gmac_initialize(bis);
63 - if (rc < 0) {
64 - printf("sunxi: failed to initialize gmac\n");
65 - return rc;
66 - }
67 -#endif
68 -
69 - return 0;
70 -}
71 -#endif
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);
76
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);
81 +#else
82 +static inline void eth_init_board(void) {}
83 +#endif
84
85 #endif
86 --- a/board/sunxi/board.c
87 +++ b/board/sunxi/board.c
88 @@ -90,6 +90,11 @@ int board_init(void)
89 if (ret)
90 return ret;
91
92 +#ifdef CONFIG_MACPWR
93 + gpio_request(CONFIG_MACPWR, "macpwr");
94 + gpio_direction_output(CONFIG_MACPWR, 1);
95 +#endif
96 +
97 /* Uses dm gpio code so do this here and not in i2c_init_board() */
98 return soft_i2c_board_init();
99 }
100 --- a/board/sunxi/gmac.c
101 +++ b/board/sunxi/gmac.c
102 @@ -6,7 +6,7 @@
103 #include <asm/arch/clock.h>
104 #include <asm/arch/gpio.h>
105
106 -int sunxi_gmac_initialize(bd_t *bis)
107 +void eth_init_board(void)
108 {
109 int pin;
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);
114 #endif
115 -
116 -#ifdef CONFIG_DM_ETH
117 - return 0;
118 -#else
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);
123 -# else
124 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
125 -# endif
126 -#endif
127 }