diff options
author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2009-06-26 03:05:39 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-06-26 03:24:02 -0400 |
commit | a80cad950f2a562e60db1869dd29bc007c5a4b66 (patch) | |
tree | 9bc1ae5ac9657cdfa27f21d6d87d39df0507065a /arch/sh | |
parent | dfc2f91ac29f5ef50e74bf15a1a6b6aa6b952e62 (diff) |
sh: ms7724se: Add sh_eth support
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/boards/mach-se/7724/setup.c | 106 | ||||
-rw-r--r-- | arch/sh/include/mach-se/mach/se7724.h | 5 |
2 files changed, 109 insertions, 2 deletions
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c index 9cd04bd558b8..21d18005fb4a 100644 --- a/arch/sh/boards/mach-se/7724/setup.c +++ b/arch/sh/boards/mach-se/7724/setup.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <media/sh_mobile_ceu.h> | 23 | #include <media/sh_mobile_ceu.h> |
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <asm/heartbeat.h> | 25 | #include <asm/heartbeat.h> |
26 | #include <asm/sh_eth.h> | ||
27 | #include <asm/clock.h> | ||
26 | #include <asm/sh_keysc.h> | 28 | #include <asm/sh_keysc.h> |
27 | #include <cpu/sh7724.h> | 29 | #include <cpu/sh7724.h> |
28 | #include <mach-se/mach/se7724.h> | 30 | #include <mach-se/mach/se7724.h> |
@@ -272,6 +274,34 @@ static struct platform_device keysc_device = { | |||
272 | }, | 274 | }, |
273 | }; | 275 | }; |
274 | 276 | ||
277 | /* SH Eth */ | ||
278 | static struct resource sh_eth_resources[] = { | ||
279 | [0] = { | ||
280 | .start = SH_ETH_ADDR, | ||
281 | .end = SH_ETH_ADDR + 0x1FC, | ||
282 | .flags = IORESOURCE_MEM, | ||
283 | }, | ||
284 | [1] = { | ||
285 | .start = 91, | ||
286 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, | ||
287 | }, | ||
288 | }; | ||
289 | |||
290 | struct sh_eth_plat_data sh_eth_plat = { | ||
291 | .phy = 0x1f, /* SMSC LAN8187 */ | ||
292 | .edmac_endian = EDMAC_LITTLE_ENDIAN, | ||
293 | }; | ||
294 | |||
295 | static struct platform_device sh_eth_device = { | ||
296 | .name = "sh-eth", | ||
297 | .id = 0, | ||
298 | .dev = { | ||
299 | .platform_data = &sh_eth_plat, | ||
300 | }, | ||
301 | .num_resources = ARRAY_SIZE(sh_eth_resources), | ||
302 | .resource = sh_eth_resources, | ||
303 | }; | ||
304 | |||
275 | static struct platform_device *ms7724se_devices[] __initdata = { | 305 | static struct platform_device *ms7724se_devices[] __initdata = { |
276 | &heartbeat_device, | 306 | &heartbeat_device, |
277 | &smc91x_eth_device, | 307 | &smc91x_eth_device, |
@@ -280,8 +310,57 @@ static struct platform_device *ms7724se_devices[] __initdata = { | |||
280 | &ceu0_device, | 310 | &ceu0_device, |
281 | &ceu1_device, | 311 | &ceu1_device, |
282 | &keysc_device, | 312 | &keysc_device, |
313 | &sh_eth_device, | ||
283 | }; | 314 | }; |
284 | 315 | ||
316 | #define EEPROM_OP 0xBA206000 | ||
317 | #define EEPROM_ADR 0xBA206004 | ||
318 | #define EEPROM_DATA 0xBA20600C | ||
319 | #define EEPROM_STAT 0xBA206010 | ||
320 | #define EEPROM_STRT 0xBA206014 | ||
321 | static int __init sh_eth_is_eeprom_ready(void) | ||
322 | { | ||
323 | int t = 10000; | ||
324 | |||
325 | while (t--) { | ||
326 | if (!ctrl_inw(EEPROM_STAT)) | ||
327 | return 1; | ||
328 | cpu_relax(); | ||
329 | } | ||
330 | |||
331 | printk(KERN_ERR "ms7724se can not access to eeprom\n"); | ||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static void __init sh_eth_init(void) | ||
336 | { | ||
337 | int i; | ||
338 | u16 mac[3]; | ||
339 | |||
340 | /* check EEPROM status */ | ||
341 | if (!sh_eth_is_eeprom_ready()) | ||
342 | return; | ||
343 | |||
344 | /* read MAC addr from EEPROM */ | ||
345 | for (i = 0 ; i < 3 ; i++) { | ||
346 | ctrl_outw(0x0, EEPROM_OP); /* read */ | ||
347 | ctrl_outw(i*2, EEPROM_ADR); | ||
348 | ctrl_outw(0x1, EEPROM_STRT); | ||
349 | if (!sh_eth_is_eeprom_ready()) | ||
350 | return; | ||
351 | |||
352 | mac[i] = ctrl_inw(EEPROM_DATA); | ||
353 | mac[i] = ((mac[i] & 0xFF) << 8) | (mac[i] >> 8); /* swap */ | ||
354 | } | ||
355 | |||
356 | /* reset sh-eth */ | ||
357 | ctrl_outl(0x1, SH_ETH_ADDR + 0x0); | ||
358 | |||
359 | /* set MAC addr */ | ||
360 | ctrl_outl(((mac[0] << 16) | (mac[1])), SH_ETH_MAHR); | ||
361 | ctrl_outl((mac[2]), SH_ETH_MALR); | ||
362 | } | ||
363 | |||
285 | #define SW4140 0xBA201000 | 364 | #define SW4140 0xBA201000 |
286 | #define FPGA_OUT 0xBA200400 | 365 | #define FPGA_OUT 0xBA200400 |
287 | #define PORT_HIZA 0xA4050158 | 366 | #define PORT_HIZA 0xA4050158 |
@@ -302,7 +381,8 @@ static int __init devices_setup(void) | |||
302 | ctrl_outw(ctrl_inw(FPGA_OUT) & | 381 | ctrl_outw(ctrl_inw(FPGA_OUT) & |
303 | ~((1 << 1) | /* LAN */ | 382 | ~((1 << 1) | /* LAN */ |
304 | (1 << 6) | /* VIDEO DAC */ | 383 | (1 << 6) | /* VIDEO DAC */ |
305 | (1 << 12)), /* USB0 */ | 384 | (1 << 12) | /* USB0 */ |
385 | (1 << 14)), /* RMII */ | ||
306 | FPGA_OUT); | 386 | FPGA_OUT); |
307 | 387 | ||
308 | /* enable IRQ 0,1,2 */ | 388 | /* enable IRQ 0,1,2 */ |
@@ -404,6 +484,28 @@ static int __init devices_setup(void) | |||
404 | gpio_request(GPIO_FN_KEYOUT1, NULL); | 484 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
405 | gpio_request(GPIO_FN_KEYOUT0, NULL); | 485 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
406 | 486 | ||
487 | /* | ||
488 | * enable SH-Eth | ||
489 | * | ||
490 | * please remove J33 pin from your board !! | ||
491 | * | ||
492 | * ms7724 board should not use GPIO_FN_LNKSTA pin | ||
493 | * So, This time PTX5 is set to input pin | ||
494 | */ | ||
495 | gpio_request(GPIO_FN_RMII_RXD0, NULL); | ||
496 | gpio_request(GPIO_FN_RMII_RXD1, NULL); | ||
497 | gpio_request(GPIO_FN_RMII_TXD0, NULL); | ||
498 | gpio_request(GPIO_FN_RMII_TXD1, NULL); | ||
499 | gpio_request(GPIO_FN_RMII_REF_CLK, NULL); | ||
500 | gpio_request(GPIO_FN_RMII_TX_EN, NULL); | ||
501 | gpio_request(GPIO_FN_RMII_RX_ER, NULL); | ||
502 | gpio_request(GPIO_FN_RMII_CRS_DV, NULL); | ||
503 | gpio_request(GPIO_FN_MDIO, NULL); | ||
504 | gpio_request(GPIO_FN_MDC, NULL); | ||
505 | gpio_request(GPIO_PTX5, NULL); | ||
506 | gpio_direction_input(GPIO_PTX5); | ||
507 | sh_eth_init(); | ||
508 | |||
407 | if (sw & SW41_B) { | 509 | if (sw & SW41_B) { |
408 | /* SVGA */ | 510 | /* SVGA */ |
409 | lcdc_info.ch[0].lcd_cfg.xres = 800; | 511 | lcdc_info.ch[0].lcd_cfg.xres = 800; |
@@ -437,7 +539,7 @@ static int __init devices_setup(void) | |||
437 | } | 539 | } |
438 | 540 | ||
439 | return platform_add_devices(ms7724se_devices, | 541 | return platform_add_devices(ms7724se_devices, |
440 | ARRAY_SIZE(ms7724se_devices)); | 542 | ARRAY_SIZE(ms7724se_devices)); |
441 | } | 543 | } |
442 | device_initcall(devices_setup); | 544 | device_initcall(devices_setup); |
443 | 545 | ||
diff --git a/arch/sh/include/mach-se/mach/se7724.h b/arch/sh/include/mach-se/mach/se7724.h index 74164b60d0db..29514a39d0f5 100644 --- a/arch/sh/include/mach-se/mach/se7724.h +++ b/arch/sh/include/mach-se/mach/se7724.h | |||
@@ -20,6 +20,11 @@ | |||
20 | */ | 20 | */ |
21 | #include <asm/addrspace.h> | 21 | #include <asm/addrspace.h> |
22 | 22 | ||
23 | /* SH Eth */ | ||
24 | #define SH_ETH_ADDR (0xA4600000) | ||
25 | #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0) | ||
26 | #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8) | ||
27 | |||
23 | #define PA_LED (0xba203000) /* 8bit LED */ | 28 | #define PA_LED (0xba203000) /* 8bit LED */ |
24 | #define IRQ_MODE (0xba200010) | 29 | #define IRQ_MODE (0xba200010) |
25 | #define IRQ0_SR (0xba200014) | 30 | #define IRQ0_SR (0xba200014) |