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.c600
1 files changed, 530 insertions, 70 deletions
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 3b1ceb46fa54..6c13b92742e8 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -19,13 +19,22 @@
19#include <linux/usb/r8a66597.h> 19#include <linux/usb/r8a66597.h>
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/spi/spi.h>
23#include <linux/spi/sh_msiof.h>
24#include <linux/spi/mmc_spi.h>
25#include <linux/mmc/host.h>
22#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/input/sh_keysc.h>
28#include <linux/mfd/sh_mobile_sdhi.h>
23#include <video/sh_mobile_lcdc.h> 29#include <video/sh_mobile_lcdc.h>
30#include <sound/sh_fsi.h>
24#include <media/sh_mobile_ceu.h> 31#include <media/sh_mobile_ceu.h>
32#include <media/tw9910.h>
33#include <media/mt9t112.h>
25#include <asm/heartbeat.h> 34#include <asm/heartbeat.h>
26#include <asm/sh_eth.h> 35#include <asm/sh_eth.h>
27#include <asm/sh_keysc.h>
28#include <asm/clock.h> 36#include <asm/clock.h>
37#include <asm/suspend.h>
29#include <cpu/sh7724.h> 38#include <cpu/sh7724.h>
30 39
31/* 40/*
@@ -55,18 +64,16 @@
55 64
56/* Heartbeat */ 65/* Heartbeat */
57static unsigned char led_pos[] = { 0, 1, 2, 3 }; 66static unsigned char led_pos[] = { 0, 1, 2, 3 };
67
58static struct heartbeat_data heartbeat_data = { 68static struct heartbeat_data heartbeat_data = {
59 .regsize = 8,
60 .nr_bits = 4, 69 .nr_bits = 4,
61 .bit_pos = led_pos, 70 .bit_pos = led_pos,
62}; 71};
63 72
64static struct resource heartbeat_resources[] = { 73static struct resource heartbeat_resource = {
65 [0] = { 74 .start = 0xA405012C, /* PTG */
66 .start = 0xA405012C, /* PTG */ 75 .end = 0xA405012E - 1,
67 .end = 0xA405012E - 1, 76 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
68 .flags = IORESOURCE_MEM,
69 },
70}; 77};
71 78
72static struct platform_device heartbeat_device = { 79static struct platform_device heartbeat_device = {
@@ -75,8 +82,8 @@ static struct platform_device heartbeat_device = {
75 .dev = { 82 .dev = {
76 .platform_data = &heartbeat_data, 83 .platform_data = &heartbeat_data,
77 }, 84 },
78 .num_resources = ARRAY_SIZE(heartbeat_resources), 85 .num_resources = 1,
79 .resource = heartbeat_resources, 86 .resource = &heartbeat_resource,
80}; 87};
81 88
82/* MTD */ 89/* MTD */
@@ -119,8 +126,6 @@ static struct platform_device nor_flash_device = {
119 126
120/* SH Eth */ 127/* SH Eth */
121#define SH_ETH_ADDR (0xA4600000) 128#define SH_ETH_ADDR (0xA4600000)
122#define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
123#define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
124static struct resource sh_eth_resources[] = { 129static struct resource sh_eth_resources[] = {
125 [0] = { 130 [0] = {
126 .start = SH_ETH_ADDR, 131 .start = SH_ETH_ADDR,
@@ -147,6 +152,9 @@ static struct platform_device sh_eth_device = {
147 }, 152 },
148 .num_resources = ARRAY_SIZE(sh_eth_resources), 153 .num_resources = ARRAY_SIZE(sh_eth_resources),
149 .resource = sh_eth_resources, 154 .resource = sh_eth_resources,
155 .archdata = {
156 .hwblk_id = HWBLK_ETHER,
157 },
150}; 158};
151 159
152/* USB0 host */ 160/* USB0 host */
@@ -185,30 +193,18 @@ static struct platform_device usb0_host_device = {
185 .resource = usb0_host_resources, 193 .resource = usb0_host_resources,
186}; 194};
187 195
188/* 196/* 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) 197void usb1_port_power(int port, int power)
197{ 198{
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); 199 gpio_set_value(GPIO_PTB5, power);
204} 200}
205 201
206static struct r8a66597_platdata usb1_host_data = { 202static struct r8a66597_platdata usb1_common_data = {
207 .on_chip = 1, 203 .on_chip = 1,
208 .port_power = usb1_port_power, 204 .port_power = usb1_port_power,
209}; 205};
210 206
211static struct resource usb1_host_resources[] = { 207static struct resource usb1_common_resources[] = {
212 [0] = { 208 [0] = {
213 .start = 0xa4d90000, 209 .start = 0xa4d90000,
214 .end = 0xa4d90124 - 1, 210 .end = 0xa4d90124 - 1,
@@ -221,16 +217,16 @@ static struct resource usb1_host_resources[] = {
221 }, 217 },
222}; 218};
223 219
224static struct platform_device usb1_host_device = { 220static struct platform_device usb1_common_device = {
225 .name = "r8a66597_hcd", 221 /* .name will be added in arch_setup */
226 .id = 1, 222 .id = 1,
227 .dev = { 223 .dev = {
228 .dma_mask = NULL, /* not use dma */ 224 .dma_mask = NULL, /* not use dma */
229 .coherent_dma_mask = 0xffffffff, 225 .coherent_dma_mask = 0xffffffff,
230 .platform_data = &usb1_host_data, 226 .platform_data = &usb1_common_data,
231 }, 227 },
232 .num_resources = ARRAY_SIZE(usb1_host_resources), 228 .num_resources = ARRAY_SIZE(usb1_common_resources),
233 .resource = usb1_host_resources, 229 .resource = usb1_common_resources,
234}; 230};
235 231
236/* LCDC */ 232/* LCDC */
@@ -345,10 +341,20 @@ static struct platform_device ceu1_device = {
345}; 341};
346 342
347/* I2C device */ 343/* I2C device */
344static struct i2c_board_info i2c0_devices[] = {
345 {
346 I2C_BOARD_INFO("da7210", 0x1a),
347 },
348};
349
348static struct i2c_board_info i2c1_devices[] = { 350static struct i2c_board_info i2c1_devices[] = {
349 { 351 {
350 I2C_BOARD_INFO("r2025sd", 0x32), 352 I2C_BOARD_INFO("r2025sd", 0x32),
351 }, 353 },
354 {
355 I2C_BOARD_INFO("lis3lv02d", 0x1c),
356 .irq = 33,
357 }
352}; 358};
353 359
354/* KEYSC */ 360/* KEYSC */
@@ -428,18 +434,367 @@ static struct i2c_board_info ts_i2c_clients = {
428 .irq = IRQ0, 434 .irq = IRQ0,
429}; 435};
430 436
437#ifdef CONFIG_MFD_SH_MOBILE_SDHI
438/* SHDI0 */
439static void sdhi0_set_pwr(struct platform_device *pdev, int state)
440{
441 gpio_set_value(GPIO_PTB6, state);
442}
443
444static struct sh_mobile_sdhi_info sdhi0_info = {
445 .set_pwr = sdhi0_set_pwr,
446};
447
448static struct resource sdhi0_resources[] = {
449 [0] = {
450 .name = "SDHI0",
451 .start = 0x04ce0000,
452 .end = 0x04ce01ff,
453 .flags = IORESOURCE_MEM,
454 },
455 [1] = {
456 .start = 100,
457 .flags = IORESOURCE_IRQ,
458 },
459};
460
461static struct platform_device sdhi0_device = {
462 .name = "sh_mobile_sdhi",
463 .num_resources = ARRAY_SIZE(sdhi0_resources),
464 .resource = sdhi0_resources,
465 .id = 0,
466 .dev = {
467 .platform_data = &sdhi0_info,
468 },
469 .archdata = {
470 .hwblk_id = HWBLK_SDHI0,
471 },
472};
473
474/* SHDI1 */
475static void sdhi1_set_pwr(struct platform_device *pdev, int state)
476{
477 gpio_set_value(GPIO_PTB7, state);
478}
479
480static struct sh_mobile_sdhi_info sdhi1_info = {
481 .set_pwr = sdhi1_set_pwr,
482};
483
484static struct resource sdhi1_resources[] = {
485 [0] = {
486 .name = "SDHI1",
487 .start = 0x04cf0000,
488 .end = 0x04cf01ff,
489 .flags = IORESOURCE_MEM,
490 },
491 [1] = {
492 .start = 23,
493 .flags = IORESOURCE_IRQ,
494 },
495};
496
497static struct platform_device sdhi1_device = {
498 .name = "sh_mobile_sdhi",
499 .num_resources = ARRAY_SIZE(sdhi1_resources),
500 .resource = sdhi1_resources,
501 .id = 1,
502 .dev = {
503 .platform_data = &sdhi1_info,
504 },
505 .archdata = {
506 .hwblk_id = HWBLK_SDHI1,
507 },
508};
509
510#else
511
512/* MMC SPI */
513static int mmc_spi_get_ro(struct device *dev)
514{
515 return gpio_get_value(GPIO_PTY6);
516}
517
518static int mmc_spi_get_cd(struct device *dev)
519{
520 return !gpio_get_value(GPIO_PTY7);
521}
522
523static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
524{
525 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
526}
527
528static struct mmc_spi_platform_data mmc_spi_info = {
529 .get_ro = mmc_spi_get_ro,
530 .get_cd = mmc_spi_get_cd,
531 .caps = MMC_CAP_NEEDS_POLL,
532 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
533 .setpower = mmc_spi_setpower,
534};
535
536static struct spi_board_info spi_bus[] = {
537 {
538 .modalias = "mmc_spi",
539 .platform_data = &mmc_spi_info,
540 .max_speed_hz = 5000000,
541 .mode = SPI_MODE_0,
542 .controller_data = (void *) GPIO_PTM4,
543 },
544};
545
546/* MSIOF0 */
547static struct sh_msiof_spi_info msiof0_data = {
548 .num_chipselect = 1,
549};
550
551static struct resource msiof0_resources[] = {
552 [0] = {
553 .name = "MSIOF0",
554 .start = 0xa4c40000,
555 .end = 0xa4c40063,
556 .flags = IORESOURCE_MEM,
557 },
558 [1] = {
559 .start = 84,
560 .flags = IORESOURCE_IRQ,
561 },
562};
563
564static struct platform_device msiof0_device = {
565 .name = "spi_sh_msiof",
566 .id = 0, /* MSIOF0 */
567 .dev = {
568 .platform_data = &msiof0_data,
569 },
570 .num_resources = ARRAY_SIZE(msiof0_resources),
571 .resource = msiof0_resources,
572 .archdata = {
573 .hwblk_id = HWBLK_MSIOF0,
574 },
575};
576
577#endif
578
579/* I2C Video/Camera */
580static struct i2c_board_info i2c_camera[] = {
581 {
582 I2C_BOARD_INFO("tw9910", 0x45),
583 },
584 {
585 /* 1st camera */
586 I2C_BOARD_INFO("mt9t112", 0x3c),
587 },
588 {
589 /* 2nd camera */
590 I2C_BOARD_INFO("mt9t112", 0x3c),
591 },
592};
593
594/* tw9910 */
595static int tw9910_power(struct device *dev, int mode)
596{
597 int val = mode ? 0 : 1;
598
599 gpio_set_value(GPIO_PTU2, val);
600 if (mode)
601 mdelay(100);
602
603 return 0;
604}
605
606static struct tw9910_video_info tw9910_info = {
607 .buswidth = SOCAM_DATAWIDTH_8,
608 .mpout = TW9910_MPO_FIELD,
609};
610
611static struct soc_camera_link tw9910_link = {
612 .i2c_adapter_id = 0,
613 .bus_id = 1,
614 .power = tw9910_power,
615 .board_info = &i2c_camera[0],
616 .module_name = "tw9910",
617 .priv = &tw9910_info,
618};
619
620/* mt9t112 */
621static int mt9t112_power1(struct device *dev, int mode)
622{
623 gpio_set_value(GPIO_PTA3, mode);
624 if (mode)
625 mdelay(100);
626
627 return 0;
628}
629
630static struct mt9t112_camera_info mt9t112_info1 = {
631 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
632 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
633};
634
635static struct soc_camera_link mt9t112_link1 = {
636 .i2c_adapter_id = 0,
637 .power = mt9t112_power1,
638 .bus_id = 0,
639 .board_info = &i2c_camera[1],
640 .module_name = "mt9t112",
641 .priv = &mt9t112_info1,
642};
643
644static int mt9t112_power2(struct device *dev, int mode)
645{
646 gpio_set_value(GPIO_PTA4, mode);
647 if (mode)
648 mdelay(100);
649
650 return 0;
651}
652
653static struct mt9t112_camera_info mt9t112_info2 = {
654 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
655 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
656};
657
658static struct soc_camera_link mt9t112_link2 = {
659 .i2c_adapter_id = 1,
660 .power = mt9t112_power2,
661 .bus_id = 1,
662 .board_info = &i2c_camera[2],
663 .module_name = "mt9t112",
664 .priv = &mt9t112_info2,
665};
666
667static struct platform_device camera_devices[] = {
668 {
669 .name = "soc-camera-pdrv",
670 .id = 0,
671 .dev = {
672 .platform_data = &tw9910_link,
673 },
674 },
675 {
676 .name = "soc-camera-pdrv",
677 .id = 1,
678 .dev = {
679 .platform_data = &mt9t112_link1,
680 },
681 },
682 {
683 .name = "soc-camera-pdrv",
684 .id = 2,
685 .dev = {
686 .platform_data = &mt9t112_link2,
687 },
688 },
689};
690
691/* FSI */
692/*
693 * FSI-B use external clock which came from da7210.
694 * So, we should change parent of fsi
695 */
696#define FCLKBCR 0xa415000c
697static void fsimck_init(struct clk *clk)
698{
699 u32 status = __raw_readl(clk->enable_reg);
700
701 /* use external clock */
702 status &= ~0x000000ff;
703 status |= 0x00000080;
704
705 __raw_writel(status, clk->enable_reg);
706}
707
708static struct clk_ops fsimck_clk_ops = {
709 .init = fsimck_init,
710};
711
712static struct clk fsimckb_clk = {
713 .name = "fsimckb_clk",
714 .id = -1,
715 .ops = &fsimck_clk_ops,
716 .enable_reg = (void __iomem *)FCLKBCR,
717 .rate = 0, /* unknown */
718};
719
720struct sh_fsi_platform_info fsi_info = {
721 .portb_flags = SH_FSI_BRS_INV |
722 SH_FSI_OUT_SLAVE_MODE |
723 SH_FSI_IN_SLAVE_MODE |
724 SH_FSI_OFMT(I2S) |
725 SH_FSI_IFMT(I2S),
726};
727
728static struct resource fsi_resources[] = {
729 [0] = {
730 .name = "FSI",
731 .start = 0xFE3C0000,
732 .end = 0xFE3C021d,
733 .flags = IORESOURCE_MEM,
734 },
735 [1] = {
736 .start = 108,
737 .flags = IORESOURCE_IRQ,
738 },
739};
740
741static struct platform_device fsi_device = {
742 .name = "sh_fsi",
743 .id = 0,
744 .num_resources = ARRAY_SIZE(fsi_resources),
745 .resource = fsi_resources,
746 .dev = {
747 .platform_data = &fsi_info,
748 },
749 .archdata = {
750 .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
751 },
752};
753
754/* IrDA */
755static struct resource irda_resources[] = {
756 [0] = {
757 .name = "IrDA",
758 .start = 0xA45D0000,
759 .end = 0xA45D0049,
760 .flags = IORESOURCE_MEM,
761 },
762 [1] = {
763 .start = 20,
764 .flags = IORESOURCE_IRQ,
765 },
766};
767
768static struct platform_device irda_device = {
769 .name = "sh_sir",
770 .num_resources = ARRAY_SIZE(irda_resources),
771 .resource = irda_resources,
772};
773
431static struct platform_device *ecovec_devices[] __initdata = { 774static struct platform_device *ecovec_devices[] __initdata = {
432 &heartbeat_device, 775 &heartbeat_device,
433 &nor_flash_device, 776 &nor_flash_device,
434 &sh_eth_device, 777 &sh_eth_device,
435 &usb0_host_device, 778 &usb0_host_device,
436 &usb1_host_device, /* USB1 host support */ 779 &usb1_common_device,
437 &lcdc_device, 780 &lcdc_device,
438 &ceu0_device, 781 &ceu0_device,
439 &ceu1_device, 782 &ceu1_device,
440 &keysc_device, 783 &keysc_device,
784#ifdef CONFIG_MFD_SH_MOBILE_SDHI
785 &sdhi0_device,
786 &sdhi1_device,
787#else
788 &msiof0_device,
789#endif
790 &camera_devices[0],
791 &camera_devices[1],
792 &camera_devices[2],
793 &fsi_device,
794 &irda_device,
441}; 795};
442 796
797#ifdef CONFIG_I2C
443#define EEPROM_ADDR 0x50 798#define EEPROM_ADDR 0x50
444static u8 mac_read(struct i2c_adapter *a, u8 command) 799static u8 mac_read(struct i2c_adapter *a, u8 command)
445{ 800{
@@ -466,12 +821,9 @@ static u8 mac_read(struct i2c_adapter *a, u8 command)
466 return buf; 821 return buf;
467} 822}
468 823
469#define MAC_LEN 6 824static void __init sh_eth_init(struct sh_eth_plat_data *pd)
470static void __init sh_eth_init(void)
471{ 825{
472 struct i2c_adapter *a = i2c_get_adapter(1); 826 struct i2c_adapter *a = i2c_get_adapter(1);
473 struct clk *eth_clk;
474 u8 mac[MAC_LEN];
475 int i; 827 int i;
476 828
477 if (!a) { 829 if (!a) {
@@ -479,39 +831,41 @@ static void __init sh_eth_init(void)
479 return; 831 return;
480 } 832 }
481 833
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 */ 834 /* read MAC address frome EEPROM */
489 for (i = 0; i < MAC_LEN; i++) { 835 for (i = 0; i < sizeof(pd->mac_addr); i++) {
490 mac[i] = mac_read(a, 0x10 + i); 836 pd->mac_addr[i] = mac_read(a, 0x10 + i);
491 msleep(10); 837 msleep(10);
492 } 838 }
493 839
494 /* clock enable */ 840 i2c_put_adapter(a);
495 clk_enable(eth_clk); 841}
496 842#else
497 /* reset sh-eth */ 843static void __init sh_eth_init(struct sh_eth_plat_data *pd)
498 ctrl_outl(0x1, SH_ETH_ADDR + 0x0); 844{
499 845 pr_err("unable to read sh_eth MAC address\n");
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} 846}
847#endif
510 848
511#define PORT_HIZA 0xA4050158 849#define PORT_HIZA 0xA4050158
512#define IODRIVEA 0xA405018A 850#define IODRIVEA 0xA405018A
851
852extern char ecovec24_sdram_enter_start;
853extern char ecovec24_sdram_enter_end;
854extern char ecovec24_sdram_leave_start;
855extern char ecovec24_sdram_leave_end;
856
513static int __init arch_setup(void) 857static int __init arch_setup(void)
514{ 858{
859 struct clk *clk;
860
861 /* register board specific self-refresh code */
862 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
863 SUSP_SH_RSTANDBY,
864 &ecovec24_sdram_enter_start,
865 &ecovec24_sdram_enter_end,
866 &ecovec24_sdram_leave_start,
867 &ecovec24_sdram_leave_end);
868
515 /* enable STATUS0, STATUS2 and PDSTATUS */ 869 /* enable STATUS0, STATUS2 and PDSTATUS */
516 gpio_request(GPIO_FN_STATUS0, NULL); 870 gpio_request(GPIO_FN_STATUS0, NULL);
517 gpio_request(GPIO_FN_STATUS2, NULL); 871 gpio_request(GPIO_FN_STATUS2, NULL);
@@ -530,7 +884,7 @@ static int __init arch_setup(void)
530 gpio_direction_output(GPIO_PTG1, 0); 884 gpio_direction_output(GPIO_PTG1, 0);
531 gpio_direction_output(GPIO_PTG2, 0); 885 gpio_direction_output(GPIO_PTG2, 0);
532 gpio_direction_output(GPIO_PTG3, 0); 886 gpio_direction_output(GPIO_PTG3, 0);
533 ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA); 887 __raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
534 888
535 /* enable SH-Eth */ 889 /* enable SH-Eth */
536 gpio_request(GPIO_PTA1, NULL); 890 gpio_request(GPIO_PTA1, NULL);
@@ -550,16 +904,24 @@ static int __init arch_setup(void)
550 gpio_request(GPIO_FN_LNKSTA, NULL); 904 gpio_request(GPIO_FN_LNKSTA, NULL);
551 905
552 /* enable USB */ 906 /* enable USB */
553 ctrl_outw(0x0000, 0xA4D80000); 907 __raw_writew(0x0000, 0xA4D80000);
554 ctrl_outw(0x0000, 0xA4D90000); 908 __raw_writew(0x0000, 0xA4D90000);
555 gpio_request(GPIO_PTB3, NULL); 909 gpio_request(GPIO_PTB3, NULL);
556 gpio_request(GPIO_PTB4, NULL); 910 gpio_request(GPIO_PTB4, NULL);
557 gpio_request(GPIO_PTB5, NULL); 911 gpio_request(GPIO_PTB5, NULL);
558 gpio_direction_input(GPIO_PTB3); 912 gpio_direction_input(GPIO_PTB3);
559 gpio_direction_output(GPIO_PTB4, 0); 913 gpio_direction_output(GPIO_PTB4, 0);
560 gpio_direction_output(GPIO_PTB5, 0); 914 gpio_direction_output(GPIO_PTB5, 0);
561 ctrl_outw(0x0600, 0xa40501d4); 915 __raw_writew(0x0600, 0xa40501d4);
562 ctrl_outw(0x0600, 0xa4050192); 916 __raw_writew(0x0600, 0xa4050192);
917
918 if (gpio_get_value(GPIO_PTB3)) {
919 printk(KERN_INFO "USB1 function is selected\n");
920 usb1_common_device.name = "r8a66597_udc";
921 } else {
922 printk(KERN_INFO "USB1 host is selected\n");
923 usb1_common_device.name = "r8a66597_hcd";
924 }
563 925
564 /* enable LCDC */ 926 /* enable LCDC */
565 gpio_request(GPIO_FN_LCDD23, NULL); 927 gpio_request(GPIO_FN_LCDD23, NULL);
@@ -592,7 +954,7 @@ static int __init arch_setup(void)
592 gpio_request(GPIO_FN_LCDVSYN, NULL); 954 gpio_request(GPIO_FN_LCDVSYN, NULL);
593 gpio_request(GPIO_FN_LCDDON, NULL); 955 gpio_request(GPIO_FN_LCDDON, NULL);
594 gpio_request(GPIO_FN_LCDLCLK, NULL); 956 gpio_request(GPIO_FN_LCDLCLK, NULL);
595 ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA); 957 __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
596 958
597 gpio_request(GPIO_PTE6, NULL); 959 gpio_request(GPIO_PTE6, NULL);
598 gpio_request(GPIO_PTU1, NULL); 960 gpio_request(GPIO_PTU1, NULL);
@@ -603,8 +965,8 @@ static int __init arch_setup(void)
603 gpio_direction_output(GPIO_PTR1, 0); 965 gpio_direction_output(GPIO_PTR1, 0);
604 gpio_direction_output(GPIO_PTA2, 0); 966 gpio_direction_output(GPIO_PTA2, 0);
605 967
606 /* I/O buffer drive ability is low */ 968 /* I/O buffer drive ability is high */
607 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA); 969 __raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
608 970
609 if (gpio_get_value(GPIO_PTE6)) { 971 if (gpio_get_value(GPIO_PTE6)) {
610 /* DVI */ 972 /* DVI */
@@ -710,7 +1072,106 @@ static int __init arch_setup(void)
710 gpio_direction_input(GPIO_PTR5); 1072 gpio_direction_input(GPIO_PTR5);
711 gpio_direction_input(GPIO_PTR6); 1073 gpio_direction_input(GPIO_PTR6);
712 1074
1075#ifdef CONFIG_MFD_SH_MOBILE_SDHI
1076 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
1077 gpio_request(GPIO_FN_SDHI0CD, NULL);
1078 gpio_request(GPIO_FN_SDHI0WP, NULL);
1079 gpio_request(GPIO_FN_SDHI0CMD, NULL);
1080 gpio_request(GPIO_FN_SDHI0CLK, NULL);
1081 gpio_request(GPIO_FN_SDHI0D3, NULL);
1082 gpio_request(GPIO_FN_SDHI0D2, NULL);
1083 gpio_request(GPIO_FN_SDHI0D1, NULL);
1084 gpio_request(GPIO_FN_SDHI0D0, NULL);
1085 gpio_request(GPIO_PTB6, NULL);
1086 gpio_direction_output(GPIO_PTB6, 0);
1087
1088 /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
1089 gpio_request(GPIO_FN_SDHI1CD, NULL);
1090 gpio_request(GPIO_FN_SDHI1WP, NULL);
1091 gpio_request(GPIO_FN_SDHI1CMD, NULL);
1092 gpio_request(GPIO_FN_SDHI1CLK, NULL);
1093 gpio_request(GPIO_FN_SDHI1D3, NULL);
1094 gpio_request(GPIO_FN_SDHI1D2, NULL);
1095 gpio_request(GPIO_FN_SDHI1D1, NULL);
1096 gpio_request(GPIO_FN_SDHI1D0, NULL);
1097 gpio_request(GPIO_PTB7, NULL);
1098 gpio_direction_output(GPIO_PTB7, 0);
1099
1100 /* I/O buffer drive ability is high for SDHI1 */
1101 __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
1102#else
1103 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
1104 gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
1105 gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
1106 gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
1107 gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
1108 gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
1109 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
1110 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
1111 gpio_request(GPIO_PTY6, NULL); /* write protect */
1112 gpio_direction_input(GPIO_PTY6);
1113 gpio_request(GPIO_PTY7, NULL); /* card detect */
1114 gpio_direction_input(GPIO_PTY7);
1115
1116 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
1117#endif
1118
1119 /* enable Video */
1120 gpio_request(GPIO_PTU2, NULL);
1121 gpio_direction_output(GPIO_PTU2, 1);
1122
1123 /* enable Camera */
1124 gpio_request(GPIO_PTA3, NULL);
1125 gpio_request(GPIO_PTA4, NULL);
1126 gpio_direction_output(GPIO_PTA3, 0);
1127 gpio_direction_output(GPIO_PTA4, 0);
1128
1129 /* enable FSI */
1130 gpio_request(GPIO_FN_FSIMCKB, NULL);
1131 gpio_request(GPIO_FN_FSIIBSD, NULL);
1132 gpio_request(GPIO_FN_FSIOBSD, NULL);
1133 gpio_request(GPIO_FN_FSIIBBCK, NULL);
1134 gpio_request(GPIO_FN_FSIIBLRCK, NULL);
1135 gpio_request(GPIO_FN_FSIOBBCK, NULL);
1136 gpio_request(GPIO_FN_FSIOBLRCK, NULL);
1137 gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
1138
1139 /* set SPU2 clock to 83.4 MHz */
1140 clk = clk_get(NULL, "spu_clk");
1141 clk_set_rate(clk, clk_round_rate(clk, 83333333));
1142 clk_put(clk);
1143
1144 /* change parent of FSI B */
1145 clk = clk_get(NULL, "fsib_clk");
1146 clk_register(&fsimckb_clk);
1147 clk_set_parent(clk, &fsimckb_clk);
1148 clk_set_rate(clk, 11000);
1149 clk_set_rate(&fsimckb_clk, 11000);
1150 clk_put(clk);
1151
1152 gpio_request(GPIO_PTU0, NULL);
1153 gpio_direction_output(GPIO_PTU0, 0);
1154 mdelay(20);
1155
1156 /* enable motion sensor */
1157 gpio_request(GPIO_FN_INTC_IRQ1, NULL);
1158 gpio_direction_input(GPIO_FN_INTC_IRQ1);
1159
1160 /* set VPU clock to 166 MHz */
1161 clk = clk_get(NULL, "vpu_clk");
1162 clk_set_rate(clk, clk_round_rate(clk, 166000000));
1163 clk_put(clk);
1164
1165 /* enable IrDA */
1166 gpio_request(GPIO_FN_IRDA_OUT, NULL);
1167 gpio_request(GPIO_FN_IRDA_IN, NULL);
1168 gpio_request(GPIO_PTU5, NULL);
1169 gpio_direction_output(GPIO_PTU5, 0);
1170
713 /* enable I2C device */ 1171 /* enable I2C device */
1172 i2c_register_board_info(0, i2c0_devices,
1173 ARRAY_SIZE(i2c0_devices));
1174
714 i2c_register_board_info(1, i2c1_devices, 1175 i2c_register_board_info(1, i2c1_devices,
715 ARRAY_SIZE(i2c1_devices)); 1176 ARRAY_SIZE(i2c1_devices));
716 1177
@@ -721,12 +1182,11 @@ arch_initcall(arch_setup);
721 1182
722static int __init devices_setup(void) 1183static int __init devices_setup(void)
723{ 1184{
724 sh_eth_init(); 1185 sh_eth_init(&sh_eth_plat);
725 return 0; 1186 return 0;
726} 1187}
727device_initcall(devices_setup); 1188device_initcall(devices_setup);
728 1189
729
730static struct sh_machine_vector mv_ecovec __initmv = { 1190static struct sh_machine_vector mv_ecovec __initmv = {
731 .mv_name = "R0P7724 (EcoVec)", 1191 .mv_name = "R0P7724 (EcoVec)",
732}; 1192};