aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/board-koelsch.c
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2013-12-08 15:52:44 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-12-19 05:08:24 -0500
commit974faba70550409049ee349939f4479ad98908ae (patch)
treefb2bd192165a11414f3942bec96ee2187407ce46 /arch/arm/mach-shmobile/board-koelsch.c
parent784c33a0c9b509f09cb69bc93f3863ed20338462 (diff)
ARM: shmobile: Koelsch: add Ether support
Register Ether platform device and pin data on the Koelsch board. Register platform fixup for Micrel KSZ8041 PHY, just like on the Lager board. Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'arch/arm/mach-shmobile/board-koelsch.c')
-rw-r--r--arch/arm/mach-shmobile/board-koelsch.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/arch/arm/mach-shmobile/board-koelsch.c b/arch/arm/mach-shmobile/board-koelsch.c
index 5d84fb6f3c5c..de7cc64b1f37 100644
--- a/arch/arm/mach-shmobile/board-koelsch.c
+++ b/arch/arm/mach-shmobile/board-koelsch.c
@@ -25,10 +25,12 @@
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/leds.h> 27#include <linux/leds.h>
28#include <linux/phy.h>
28#include <linux/pinctrl/machine.h> 29#include <linux/pinctrl/machine.h>
29#include <linux/platform_data/gpio-rcar.h> 30#include <linux/platform_data/gpio-rcar.h>
30#include <linux/platform_data/rcar-du.h> 31#include <linux/platform_data/rcar-du.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/sh_eth.h>
32#include <mach/common.h> 34#include <mach/common.h>
33#include <mach/irqs.h> 35#include <mach/irqs.h>
34#include <mach/r8a7791.h> 36#include <mach/r8a7791.h>
@@ -87,6 +89,19 @@ static void __init koelsch_add_du_device(void)
87 platform_device_register_full(&info); 89 platform_device_register_full(&info);
88} 90}
89 91
92/* Ether */
93static const struct sh_eth_plat_data ether_pdata __initconst = {
94 .phy = 0x1,
95 .edmac_endian = EDMAC_LITTLE_ENDIAN,
96 .phy_interface = PHY_INTERFACE_MODE_RMII,
97 .ether_link_active_low = 1,
98};
99
100static const struct resource ether_resources[] __initconst = {
101 DEFINE_RES_MEM(0xee700000, 0x400),
102 DEFINE_RES_IRQ(gic_spi(162)),
103};
104
90/* LEDS */ 105/* LEDS */
91static struct gpio_led koelsch_leds[] = { 106static struct gpio_led koelsch_leds[] = {
92 { 107 {
@@ -141,6 +156,15 @@ static const struct pinctrl_map koelsch_pinctrl_map[] = {
141 "du_sync", "du"), 156 "du_sync", "du"),
142 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791", 157 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791",
143 "du_clk_out_0", "du"), 158 "du_clk_out_0", "du"),
159 /* Ether */
160 PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
161 "eth_link", "eth"),
162 PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
163 "eth_mdio", "eth"),
164 PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
165 "eth_rmii", "eth"),
166 PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
167 "intc_irq0", "intc"),
144 /* SCIF0 (CN19: DEBUG SERIAL0) */ 168 /* SCIF0 (CN19: DEBUG SERIAL0) */
145 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791", 169 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791",
146 "scif0_data_d", "scif0"), 170 "scif0_data_d", "scif0"),
@@ -156,6 +180,10 @@ static void __init koelsch_add_standard_devices(void)
156 ARRAY_SIZE(koelsch_pinctrl_map)); 180 ARRAY_SIZE(koelsch_pinctrl_map));
157 r8a7791_pinmux_init(); 181 r8a7791_pinmux_init();
158 r8a7791_add_standard_devices(); 182 r8a7791_add_standard_devices();
183 platform_device_register_resndata(&platform_bus, "r8a7791-ether", -1,
184 ether_resources,
185 ARRAY_SIZE(ether_resources),
186 &ether_pdata, sizeof(ether_pdata));
159 platform_device_register_data(&platform_bus, "leds-gpio", -1, 187 platform_device_register_data(&platform_bus, "leds-gpio", -1,
160 &koelsch_leds_pdata, 188 &koelsch_leds_pdata,
161 sizeof(koelsch_leds_pdata)); 189 sizeof(koelsch_leds_pdata));
@@ -166,6 +194,32 @@ static void __init koelsch_add_standard_devices(void)
166 koelsch_add_du_device(); 194 koelsch_add_du_device();
167} 195}
168 196
197/*
198 * Ether LEDs on the Koelsch board are named LINK and ACTIVE which corresponds
199 * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
200 * 14-15. We have to set them back to 01 from the default 00 value each time
201 * the PHY is reset. It's also important because the PHY's LED0 signal is
202 * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
203 * bounce on and off after each packet, which we apparently want to avoid.
204 */
205static int koelsch_ksz8041_fixup(struct phy_device *phydev)
206{
207 u16 phyctrl1 = phy_read(phydev, 0x1e);
208
209 phyctrl1 &= ~0xc000;
210 phyctrl1 |= 0x4000;
211 return phy_write(phydev, 0x1e, phyctrl1);
212}
213
214static void __init koelsch_init(void)
215{
216 koelsch_add_standard_devices();
217
218 if (IS_ENABLED(CONFIG_PHYLIB))
219 phy_register_fixup_for_id("r8a7791-ether-ff:01",
220 koelsch_ksz8041_fixup);
221}
222
169static const char * const koelsch_boards_compat_dt[] __initconst = { 223static const char * const koelsch_boards_compat_dt[] __initconst = {
170 "renesas,koelsch", 224 "renesas,koelsch",
171 NULL, 225 NULL,
@@ -175,7 +229,7 @@ DT_MACHINE_START(KOELSCH_DT, "koelsch")
175 .smp = smp_ops(r8a7791_smp_ops), 229 .smp = smp_ops(r8a7791_smp_ops),
176 .init_early = r8a7791_init_early, 230 .init_early = r8a7791_init_early,
177 .init_time = rcar_gen2_timer_init, 231 .init_time = rcar_gen2_timer_init,
178 .init_machine = koelsch_add_standard_devices, 232 .init_machine = koelsch_init,
179 .init_late = shmobile_init_late, 233 .init_late = shmobile_init_late,
180 .dt_compat = koelsch_boards_compat_dt, 234 .dt_compat = koelsch_boards_compat_dt,
181MACHINE_END 235MACHINE_END