aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/mach-ecovec24/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/mach-ecovec24/setup.c')
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c197
1 files changed, 143 insertions, 54 deletions
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 3b1ceb46fa54..826e62326d51 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -20,12 +20,14 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/i2c/tsc2007.h> 21#include <linux/i2c/tsc2007.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/input/sh_keysc.h>
24#include <linux/mfd/sh_mobile_sdhi.h>
23#include <video/sh_mobile_lcdc.h> 25#include <video/sh_mobile_lcdc.h>
24#include <media/sh_mobile_ceu.h> 26#include <media/sh_mobile_ceu.h>
25#include <asm/heartbeat.h> 27#include <asm/heartbeat.h>
26#include <asm/sh_eth.h> 28#include <asm/sh_eth.h>
27#include <asm/sh_keysc.h>
28#include <asm/clock.h> 29#include <asm/clock.h>
30#include <asm/suspend.h>
29#include <cpu/sh7724.h> 31#include <cpu/sh7724.h>
30 32
31/* 33/*
@@ -147,6 +149,9 @@ static struct platform_device sh_eth_device = {
147 }, 149 },
148 .num_resources = ARRAY_SIZE(sh_eth_resources), 150 .num_resources = ARRAY_SIZE(sh_eth_resources),
149 .resource = sh_eth_resources, 151 .resource = sh_eth_resources,
152 .archdata = {
153 .hwblk_id = HWBLK_ETHER,
154 },
150}; 155};
151 156
152/* USB0 host */ 157/* USB0 host */
@@ -185,30 +190,18 @@ static struct platform_device usb0_host_device = {
185 .resource = usb0_host_resources, 190 .resource = usb0_host_resources,
186}; 191};
187 192
188/* 193/* USB1 host/function */
189 * USB1
190 *
191 * CN5 can use both host/function,
192 * and we can determine it by checking PTB[3]
193 *
194 * This time only USB1 host is supported.
195 */
196void usb1_port_power(int port, int power) 194void usb1_port_power(int port, int power)
197{ 195{
198 if (!gpio_get_value(GPIO_PTB3)) {
199 printk(KERN_ERR "USB1 function is not supported\n");
200 return;
201 }
202
203 gpio_set_value(GPIO_PTB5, power); 196 gpio_set_value(GPIO_PTB5, power);
204} 197}
205 198
206static struct r8a66597_platdata usb1_host_data = { 199static struct r8a66597_platdata usb1_common_data = {
207 .on_chip = 1, 200 .on_chip = 1,
208 .port_power = usb1_port_power, 201 .port_power = usb1_port_power,
209}; 202};
210 203
211static struct resource usb1_host_resources[] = { 204static struct resource usb1_common_resources[] = {
212 [0] = { 205 [0] = {
213 .start = 0xa4d90000, 206 .start = 0xa4d90000,
214 .end = 0xa4d90124 - 1, 207 .end = 0xa4d90124 - 1,
@@ -221,16 +214,16 @@ static struct resource usb1_host_resources[] = {
221 }, 214 },
222}; 215};
223 216
224static struct platform_device usb1_host_device = { 217static struct platform_device usb1_common_device = {
225 .name = "r8a66597_hcd", 218 /* .name will be added in arch_setup */
226 .id = 1, 219 .id = 1,
227 .dev = { 220 .dev = {
228 .dma_mask = NULL, /* not use dma */ 221 .dma_mask = NULL, /* not use dma */
229 .coherent_dma_mask = 0xffffffff, 222 .coherent_dma_mask = 0xffffffff,
230 .platform_data = &usb1_host_data, 223 .platform_data = &usb1_common_data,
231 }, 224 },
232 .num_resources = ARRAY_SIZE(usb1_host_resources), 225 .num_resources = ARRAY_SIZE(usb1_common_resources),
233 .resource = usb1_host_resources, 226 .resource = usb1_common_resources,
234}; 227};
235 228
236/* LCDC */ 229/* LCDC */
@@ -428,16 +421,90 @@ static struct i2c_board_info ts_i2c_clients = {
428 .irq = IRQ0, 421 .irq = IRQ0,
429}; 422};
430 423
424/* SHDI0 */
425static void sdhi0_set_pwr(struct platform_device *pdev, int state)
426{
427 gpio_set_value(GPIO_PTB6, state);
428}
429
430static struct sh_mobile_sdhi_info sdhi0_info = {
431 .set_pwr = sdhi0_set_pwr,
432};
433
434static struct resource sdhi0_resources[] = {
435 [0] = {
436 .name = "SDHI0",
437 .start = 0x04ce0000,
438 .end = 0x04ce01ff,
439 .flags = IORESOURCE_MEM,
440 },
441 [1] = {
442 .start = 101,
443 .flags = IORESOURCE_IRQ,
444 },
445};
446
447static struct platform_device sdhi0_device = {
448 .name = "sh_mobile_sdhi",
449 .num_resources = ARRAY_SIZE(sdhi0_resources),
450 .resource = sdhi0_resources,
451 .id = 0,
452 .dev = {
453 .platform_data = &sdhi0_info,
454 },
455 .archdata = {
456 .hwblk_id = HWBLK_SDHI0,
457 },
458};
459
460/* SHDI1 */
461static void sdhi1_set_pwr(struct platform_device *pdev, int state)
462{
463 gpio_set_value(GPIO_PTB7, state);
464}
465
466static struct sh_mobile_sdhi_info sdhi1_info = {
467 .set_pwr = sdhi1_set_pwr,
468};
469
470static struct resource sdhi1_resources[] = {
471 [0] = {
472 .name = "SDHI1",
473 .start = 0x04cf0000,
474 .end = 0x04cf01ff,
475 .flags = IORESOURCE_MEM,
476 },
477 [1] = {
478 .start = 24,
479 .flags = IORESOURCE_IRQ,
480 },
481};
482
483static struct platform_device sdhi1_device = {
484 .name = "sh_mobile_sdhi",
485 .num_resources = ARRAY_SIZE(sdhi1_resources),
486 .resource = sdhi1_resources,
487 .id = 1,
488 .dev = {
489 .platform_data = &sdhi1_info,
490 },
491 .archdata = {
492 .hwblk_id = HWBLK_SDHI1,
493 },
494};
495
431static struct platform_device *ecovec_devices[] __initdata = { 496static struct platform_device *ecovec_devices[] __initdata = {
432 &heartbeat_device, 497 &heartbeat_device,
433 &nor_flash_device, 498 &nor_flash_device,
434 &sh_eth_device, 499 &sh_eth_device,
435 &usb0_host_device, 500 &usb0_host_device,
436 &usb1_host_device, /* USB1 host support */ 501 &usb1_common_device,
437 &lcdc_device, 502 &lcdc_device,
438 &ceu0_device, 503 &ceu0_device,
439 &ceu1_device, 504 &ceu1_device,
440 &keysc_device, 505 &keysc_device,
506 &sdhi0_device,
507 &sdhi1_device,
441}; 508};
442 509
443#define EEPROM_ADDR 0x50 510#define EEPROM_ADDR 0x50
@@ -466,12 +533,9 @@ static u8 mac_read(struct i2c_adapter *a, u8 command)
466 return buf; 533 return buf;
467} 534}
468 535
469#define MAC_LEN 6 536static void __init sh_eth_init(struct sh_eth_plat_data *pd)
470static void __init sh_eth_init(void)
471{ 537{
472 struct i2c_adapter *a = i2c_get_adapter(1); 538 struct i2c_adapter *a = i2c_get_adapter(1);
473 struct clk *eth_clk;
474 u8 mac[MAC_LEN];
475 int i; 539 int i;
476 540
477 if (!a) { 541 if (!a) {
@@ -479,39 +543,30 @@ static void __init sh_eth_init(void)
479 return; 543 return;
480 } 544 }
481 545
482 eth_clk = clk_get(NULL, "eth0");
483 if (!eth_clk) {
484 pr_err("can not get eth0 clk\n");
485 return;
486 }
487
488 /* read MAC address frome EEPROM */ 546 /* read MAC address frome EEPROM */
489 for (i = 0; i < MAC_LEN; i++) { 547 for (i = 0; i < sizeof(pd->mac_addr); i++) {
490 mac[i] = mac_read(a, 0x10 + i); 548 pd->mac_addr[i] = mac_read(a, 0x10 + i);
491 msleep(10); 549 msleep(10);
492 } 550 }
493
494 /* clock enable */
495 clk_enable(eth_clk);
496
497 /* reset sh-eth */
498 ctrl_outl(0x1, SH_ETH_ADDR + 0x0);
499
500 /* set MAC addr */
501 ctrl_outl((mac[0] << 24) |
502 (mac[1] << 16) |
503 (mac[2] << 8) |
504 (mac[3] << 0), SH_ETH_MAHR);
505 ctrl_outl((mac[4] << 8) |
506 (mac[5] << 0), SH_ETH_MALR);
507
508 clk_put(eth_clk);
509} 551}
510 552
511#define PORT_HIZA 0xA4050158 553#define PORT_HIZA 0xA4050158
512#define IODRIVEA 0xA405018A 554#define IODRIVEA 0xA405018A
555
556extern char ecovec24_sdram_enter_start;
557extern char ecovec24_sdram_enter_end;
558extern char ecovec24_sdram_leave_start;
559extern char ecovec24_sdram_leave_end;
560
513static int __init arch_setup(void) 561static int __init arch_setup(void)
514{ 562{
563 /* register board specific self-refresh code */
564 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
565 &ecovec24_sdram_enter_start,
566 &ecovec24_sdram_enter_end,
567 &ecovec24_sdram_leave_start,
568 &ecovec24_sdram_leave_end);
569
515 /* enable STATUS0, STATUS2 and PDSTATUS */ 570 /* enable STATUS0, STATUS2 and PDSTATUS */
516 gpio_request(GPIO_FN_STATUS0, NULL); 571 gpio_request(GPIO_FN_STATUS0, NULL);
517 gpio_request(GPIO_FN_STATUS2, NULL); 572 gpio_request(GPIO_FN_STATUS2, NULL);
@@ -561,6 +616,14 @@ static int __init arch_setup(void)
561 ctrl_outw(0x0600, 0xa40501d4); 616 ctrl_outw(0x0600, 0xa40501d4);
562 ctrl_outw(0x0600, 0xa4050192); 617 ctrl_outw(0x0600, 0xa4050192);
563 618
619 if (gpio_get_value(GPIO_PTB3)) {
620 printk(KERN_INFO "USB1 function is selected\n");
621 usb1_common_device.name = "r8a66597_udc";
622 } else {
623 printk(KERN_INFO "USB1 host is selected\n");
624 usb1_common_device.name = "r8a66597_hcd";
625 }
626
564 /* enable LCDC */ 627 /* enable LCDC */
565 gpio_request(GPIO_FN_LCDD23, NULL); 628 gpio_request(GPIO_FN_LCDD23, NULL);
566 gpio_request(GPIO_FN_LCDD22, NULL); 629 gpio_request(GPIO_FN_LCDD22, NULL);
@@ -603,8 +666,8 @@ static int __init arch_setup(void)
603 gpio_direction_output(GPIO_PTR1, 0); 666 gpio_direction_output(GPIO_PTR1, 0);
604 gpio_direction_output(GPIO_PTA2, 0); 667 gpio_direction_output(GPIO_PTA2, 0);
605 668
606 /* I/O buffer drive ability is low */ 669 /* I/O buffer drive ability is high */
607 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA); 670 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
608 671
609 if (gpio_get_value(GPIO_PTE6)) { 672 if (gpio_get_value(GPIO_PTE6)) {
610 /* DVI */ 673 /* DVI */
@@ -710,6 +773,33 @@ static int __init arch_setup(void)
710 gpio_direction_input(GPIO_PTR5); 773 gpio_direction_input(GPIO_PTR5);
711 gpio_direction_input(GPIO_PTR6); 774 gpio_direction_input(GPIO_PTR6);
712 775
776 /* enable SDHI0 (needs DS2.4 set to ON) */
777 gpio_request(GPIO_FN_SDHI0CD, NULL);
778 gpio_request(GPIO_FN_SDHI0WP, NULL);
779 gpio_request(GPIO_FN_SDHI0CMD, NULL);
780 gpio_request(GPIO_FN_SDHI0CLK, NULL);
781 gpio_request(GPIO_FN_SDHI0D3, NULL);
782 gpio_request(GPIO_FN_SDHI0D2, NULL);
783 gpio_request(GPIO_FN_SDHI0D1, NULL);
784 gpio_request(GPIO_FN_SDHI0D0, NULL);
785 gpio_request(GPIO_PTB6, NULL);
786 gpio_direction_output(GPIO_PTB6, 0);
787
788 /* enable SDHI1 (needs DS2.6,7 set to ON,OFF) */
789 gpio_request(GPIO_FN_SDHI1CD, NULL);
790 gpio_request(GPIO_FN_SDHI1WP, NULL);
791 gpio_request(GPIO_FN_SDHI1CMD, NULL);
792 gpio_request(GPIO_FN_SDHI1CLK, NULL);
793 gpio_request(GPIO_FN_SDHI1D3, NULL);
794 gpio_request(GPIO_FN_SDHI1D2, NULL);
795 gpio_request(GPIO_FN_SDHI1D1, NULL);
796 gpio_request(GPIO_FN_SDHI1D0, NULL);
797 gpio_request(GPIO_PTB7, NULL);
798 gpio_direction_output(GPIO_PTB7, 0);
799
800 /* I/O buffer drive ability is high for SDHI1 */
801 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
802
713 /* enable I2C device */ 803 /* enable I2C device */
714 i2c_register_board_info(1, i2c1_devices, 804 i2c_register_board_info(1, i2c1_devices,
715 ARRAY_SIZE(i2c1_devices)); 805 ARRAY_SIZE(i2c1_devices));
@@ -721,12 +811,11 @@ arch_initcall(arch_setup);
721 811
722static int __init devices_setup(void) 812static int __init devices_setup(void)
723{ 813{
724 sh_eth_init(); 814 sh_eth_init(&sh_eth_plat);
725 return 0; 815 return 0;
726} 816}
727device_initcall(devices_setup); 817device_initcall(devices_setup);
728 818
729
730static struct sh_machine_vector mv_ecovec __initmv = { 819static struct sh_machine_vector mv_ecovec __initmv = {
731 .mv_name = "R0P7724 (EcoVec)", 820 .mv_name = "R0P7724 (EcoVec)",
732}; 821};