a4e43869a679e9985c4127fb05103e1d7f1260a6
[openwrt/staging/yousong.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 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)
36 timer_init();
37 gpio_init();
38 i2c_init_board();
39 + eth_init_board();
40 }
41
42 #ifdef CONFIG_SPL_BUILD
43 @@ -259,30 +260,3 @@ void enable_caches(void)
44 dcache_enable();
45 }
46 #endif
47 -
48 -#ifdef CONFIG_CMD_NET
49 -/*
50 - * Initializes on-chip ethernet controllers.
51 - * to override, implement board_eth_init()
52 - */
53 -int cpu_eth_init(bd_t *bis)
54 -{
55 - __maybe_unused int rc;
56 -
57 -#ifdef CONFIG_MACPWR
58 - gpio_request(CONFIG_MACPWR, "macpwr");
59 - gpio_direction_output(CONFIG_MACPWR, 1);
60 - mdelay(200);
61 -#endif
62 -
63 -#ifdef CONFIG_SUNXI_GMAC
64 - rc = sunxi_gmac_initialize(bis);
65 - if (rc < 0) {
66 - printf("sunxi: failed to initialize gmac\n");
67 - return rc;
68 - }
69 -#endif
70 -
71 - return 0;
72 -}
73 -#endif
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);
80
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);
85 +#else
86 +static inline void eth_init_board(void) {}
87 +#endif
88
89 #endif
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)
95 if (ret)
96 return ret;
97
98 +#ifdef CONFIG_MACPWR
99 + gpio_request(CONFIG_MACPWR, "macpwr");
100 + gpio_direction_output(CONFIG_MACPWR, 1);
101 +#endif
102 +
103 /* Uses dm gpio code so do this here and not in i2c_init_board() */
104 return soft_i2c_board_init();
105 }
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
110 @@ -6,7 +6,7 @@
111 #include <asm/arch/clock.h>
112 #include <asm/arch/gpio.h>
113
114 -int sunxi_gmac_initialize(bd_t *bis)
115 +void eth_init_board(void)
116 {
117 int pin;
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);
122 #endif
123 -
124 -#ifdef CONFIG_DM_ETH
125 - return 0;
126 -#else
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);
131 -# else
132 - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
133 -# endif
134 -#endif
135 }