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.c322
1 files changed, 320 insertions, 2 deletions
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 826e62326d51..194aaca22d47 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -19,11 +19,18 @@
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>
23#include <linux/input/sh_keysc.h> 27#include <linux/input/sh_keysc.h>
24#include <linux/mfd/sh_mobile_sdhi.h> 28#include <linux/mfd/sh_mobile_sdhi.h>
25#include <video/sh_mobile_lcdc.h> 29#include <video/sh_mobile_lcdc.h>
30#include <sound/sh_fsi.h>
26#include <media/sh_mobile_ceu.h> 31#include <media/sh_mobile_ceu.h>
32#include <media/tw9910.h>
33#include <media/mt9t112.h>
27#include <asm/heartbeat.h> 34#include <asm/heartbeat.h>
28#include <asm/sh_eth.h> 35#include <asm/sh_eth.h>
29#include <asm/clock.h> 36#include <asm/clock.h>
@@ -338,6 +345,12 @@ static struct platform_device ceu1_device = {
338}; 345};
339 346
340/* I2C device */ 347/* I2C device */
348static struct i2c_board_info i2c0_devices[] = {
349 {
350 I2C_BOARD_INFO("da7210", 0x1a),
351 },
352};
353
341static struct i2c_board_info i2c1_devices[] = { 354static struct i2c_board_info i2c1_devices[] = {
342 { 355 {
343 I2C_BOARD_INFO("r2025sd", 0x32), 356 I2C_BOARD_INFO("r2025sd", 0x32),
@@ -421,6 +434,7 @@ static struct i2c_board_info ts_i2c_clients = {
421 .irq = IRQ0, 434 .irq = IRQ0,
422}; 435};
423 436
437#ifdef CONFIG_MFD_SH_MOBILE_SDHI
424/* SHDI0 */ 438/* SHDI0 */
425static void sdhi0_set_pwr(struct platform_device *pdev, int state) 439static void sdhi0_set_pwr(struct platform_device *pdev, int state)
426{ 440{
@@ -493,6 +507,248 @@ static struct platform_device sdhi1_device = {
493 }, 507 },
494}; 508};
495 509
510#else
511
512static int mmc_spi_get_ro(struct device *dev)
513{
514 return gpio_get_value(GPIO_PTY6);
515}
516
517static int mmc_spi_get_cd(struct device *dev)
518{
519 return !gpio_get_value(GPIO_PTY7);
520}
521
522static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
523{
524 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
525}
526
527static struct mmc_spi_platform_data mmc_spi_info = {
528 .get_ro = mmc_spi_get_ro,
529 .get_cd = mmc_spi_get_cd,
530 .caps = MMC_CAP_NEEDS_POLL,
531 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
532 .setpower = mmc_spi_setpower,
533};
534
535static struct spi_board_info spi_bus[] = {
536 {
537 .modalias = "mmc_spi",
538 .platform_data = &mmc_spi_info,
539 .max_speed_hz = 5000000,
540 .mode = SPI_MODE_0,
541 .controller_data = (void *) GPIO_PTM4,
542 },
543};
544
545static struct sh_msiof_spi_info msiof0_data = {
546 .num_chipselect = 1,
547};
548
549static struct resource msiof0_resources[] = {
550 [0] = {
551 .name = "MSIOF0",
552 .start = 0xa4c40000,
553 .end = 0xa4c40063,
554 .flags = IORESOURCE_MEM,
555 },
556 [1] = {
557 .start = 84,
558 .flags = IORESOURCE_IRQ,
559 },
560};
561
562static struct platform_device msiof0_device = {
563 .name = "spi_sh_msiof",
564 .id = 0, /* MSIOF0 */
565 .dev = {
566 .platform_data = &msiof0_data,
567 },
568 .num_resources = ARRAY_SIZE(msiof0_resources),
569 .resource = msiof0_resources,
570 .archdata = {
571 .hwblk_id = HWBLK_MSIOF0,
572 },
573};
574
575#endif
576
577/* I2C Video/Camera */
578static struct i2c_board_info i2c_camera[] = {
579 {
580 I2C_BOARD_INFO("tw9910", 0x45),
581 },
582 {
583 /* 1st camera */
584 I2C_BOARD_INFO("mt9t112", 0x3c),
585 },
586 {
587 /* 2nd camera */
588 I2C_BOARD_INFO("mt9t112", 0x3c),
589 },
590};
591
592/* tw9910 */
593static int tw9910_power(struct device *dev, int mode)
594{
595 int val = mode ? 0 : 1;
596
597 gpio_set_value(GPIO_PTU2, val);
598 if (mode)
599 mdelay(100);
600
601 return 0;
602}
603
604static struct tw9910_video_info tw9910_info = {
605 .buswidth = SOCAM_DATAWIDTH_8,
606 .mpout = TW9910_MPO_FIELD,
607};
608
609static struct soc_camera_link tw9910_link = {
610 .i2c_adapter_id = 0,
611 .bus_id = 1,
612 .power = tw9910_power,
613 .board_info = &i2c_camera[0],
614 .module_name = "tw9910",
615 .priv = &tw9910_info,
616};
617
618/* mt9t112 */
619static int mt9t112_power1(struct device *dev, int mode)
620{
621 gpio_set_value(GPIO_PTA3, mode);
622 if (mode)
623 mdelay(100);
624
625 return 0;
626}
627
628static struct mt9t112_camera_info mt9t112_info1 = {
629 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
630 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
631};
632
633static struct soc_camera_link mt9t112_link1 = {
634 .i2c_adapter_id = 0,
635 .power = mt9t112_power1,
636 .bus_id = 0,
637 .board_info = &i2c_camera[1],
638 .module_name = "mt9t112",
639 .priv = &mt9t112_info1,
640};
641
642static int mt9t112_power2(struct device *dev, int mode)
643{
644 gpio_set_value(GPIO_PTA4, mode);
645 if (mode)
646 mdelay(100);
647
648 return 0;
649}
650
651static struct mt9t112_camera_info mt9t112_info2 = {
652 .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
653 .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
654};
655
656static struct soc_camera_link mt9t112_link2 = {
657 .i2c_adapter_id = 1,
658 .power = mt9t112_power2,
659 .bus_id = 1,
660 .board_info = &i2c_camera[2],
661 .module_name = "mt9t112",
662 .priv = &mt9t112_info2,
663};
664
665static struct platform_device camera_devices[] = {
666 {
667 .name = "soc-camera-pdrv",
668 .id = 0,
669 .dev = {
670 .platform_data = &tw9910_link,
671 },
672 },
673 {
674 .name = "soc-camera-pdrv",
675 .id = 1,
676 .dev = {
677 .platform_data = &mt9t112_link1,
678 },
679 },
680 {
681 .name = "soc-camera-pdrv",
682 .id = 2,
683 .dev = {
684 .platform_data = &mt9t112_link2,
685 },
686 },
687};
688
689/* FSI */
690/*
691 * FSI-B use external clock which came from da7210.
692 * So, we should change parent of fsi
693 */
694#define FCLKBCR 0xa415000c
695static void fsimck_init(struct clk *clk)
696{
697 u32 status = ctrl_inl(clk->enable_reg);
698
699 /* use external clock */
700 status &= ~0x000000ff;
701 status |= 0x00000080;
702
703 ctrl_outl(status, clk->enable_reg);
704}
705
706static struct clk_ops fsimck_clk_ops = {
707 .init = fsimck_init,
708};
709
710static struct clk fsimckb_clk = {
711 .name = "fsimckb_clk",
712 .id = -1,
713 .ops = &fsimck_clk_ops,
714 .enable_reg = (void __iomem *)FCLKBCR,
715 .rate = 0, /* unknown */
716};
717
718struct sh_fsi_platform_info fsi_info = {
719 .portb_flags = SH_FSI_BRS_INV |
720 SH_FSI_OUT_SLAVE_MODE |
721 SH_FSI_IN_SLAVE_MODE |
722 SH_FSI_OFMT(I2S) |
723 SH_FSI_IFMT(I2S),
724};
725
726static struct resource fsi_resources[] = {
727 [0] = {
728 .name = "FSI",
729 .start = 0xFE3C0000,
730 .end = 0xFE3C021d,
731 .flags = IORESOURCE_MEM,
732 },
733 [1] = {
734 .start = 108,
735 .flags = IORESOURCE_IRQ,
736 },
737};
738
739static struct platform_device fsi_device = {
740 .name = "sh_fsi",
741 .id = 0,
742 .num_resources = ARRAY_SIZE(fsi_resources),
743 .resource = fsi_resources,
744 .dev = {
745 .platform_data = &fsi_info,
746 },
747 .archdata = {
748 .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
749 },
750};
751
496static struct platform_device *ecovec_devices[] __initdata = { 752static struct platform_device *ecovec_devices[] __initdata = {
497 &heartbeat_device, 753 &heartbeat_device,
498 &nor_flash_device, 754 &nor_flash_device,
@@ -503,8 +759,16 @@ static struct platform_device *ecovec_devices[] __initdata = {
503 &ceu0_device, 759 &ceu0_device,
504 &ceu1_device, 760 &ceu1_device,
505 &keysc_device, 761 &keysc_device,
762#ifdef CONFIG_MFD_SH_MOBILE_SDHI
506 &sdhi0_device, 763 &sdhi0_device,
507 &sdhi1_device, 764 &sdhi1_device,
765#else
766 &msiof0_device,
767#endif
768 &camera_devices[0],
769 &camera_devices[1],
770 &camera_devices[2],
771 &fsi_device,
508}; 772};
509 773
510#define EEPROM_ADDR 0x50 774#define EEPROM_ADDR 0x50
@@ -560,6 +824,8 @@ extern char ecovec24_sdram_leave_end;
560 824
561static int __init arch_setup(void) 825static int __init arch_setup(void)
562{ 826{
827 struct clk *clk;
828
563 /* register board specific self-refresh code */ 829 /* register board specific self-refresh code */
564 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF, 830 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
565 &ecovec24_sdram_enter_start, 831 &ecovec24_sdram_enter_start,
@@ -773,7 +1039,8 @@ static int __init arch_setup(void)
773 gpio_direction_input(GPIO_PTR5); 1039 gpio_direction_input(GPIO_PTR5);
774 gpio_direction_input(GPIO_PTR6); 1040 gpio_direction_input(GPIO_PTR6);
775 1041
776 /* enable SDHI0 (needs DS2.4 set to ON) */ 1042#ifdef CONFIG_MFD_SH_MOBILE_SDHI
1043 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
777 gpio_request(GPIO_FN_SDHI0CD, NULL); 1044 gpio_request(GPIO_FN_SDHI0CD, NULL);
778 gpio_request(GPIO_FN_SDHI0WP, NULL); 1045 gpio_request(GPIO_FN_SDHI0WP, NULL);
779 gpio_request(GPIO_FN_SDHI0CMD, NULL); 1046 gpio_request(GPIO_FN_SDHI0CMD, NULL);
@@ -785,7 +1052,7 @@ static int __init arch_setup(void)
785 gpio_request(GPIO_PTB6, NULL); 1052 gpio_request(GPIO_PTB6, NULL);
786 gpio_direction_output(GPIO_PTB6, 0); 1053 gpio_direction_output(GPIO_PTB6, 0);
787 1054
788 /* enable SDHI1 (needs DS2.6,7 set to ON,OFF) */ 1055 /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
789 gpio_request(GPIO_FN_SDHI1CD, NULL); 1056 gpio_request(GPIO_FN_SDHI1CD, NULL);
790 gpio_request(GPIO_FN_SDHI1WP, NULL); 1057 gpio_request(GPIO_FN_SDHI1WP, NULL);
791 gpio_request(GPIO_FN_SDHI1CMD, NULL); 1058 gpio_request(GPIO_FN_SDHI1CMD, NULL);
@@ -799,8 +1066,59 @@ static int __init arch_setup(void)
799 1066
800 /* I/O buffer drive ability is high for SDHI1 */ 1067 /* I/O buffer drive ability is high for SDHI1 */
801 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA); 1068 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
1069#else
1070 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
1071 gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
1072 gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
1073 gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
1074 gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
1075 gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
1076 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
1077 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
1078 gpio_request(GPIO_PTY6, NULL); /* write protect */
1079 gpio_direction_input(GPIO_PTY6);
1080 gpio_request(GPIO_PTY7, NULL); /* card detect */
1081 gpio_direction_input(GPIO_PTY7);
1082
1083 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
1084#endif
1085
1086 /* enable Video */
1087 gpio_request(GPIO_PTU2, NULL);
1088 gpio_direction_output(GPIO_PTU2, 1);
1089
1090 /* enable Camera */
1091 gpio_request(GPIO_PTA3, NULL);
1092 gpio_request(GPIO_PTA4, NULL);
1093 gpio_direction_output(GPIO_PTA3, 0);
1094 gpio_direction_output(GPIO_PTA4, 0);
1095
1096 /* enable FSI */
1097 gpio_request(GPIO_FN_FSIMCKB, NULL);
1098 gpio_request(GPIO_FN_FSIIBSD, NULL);
1099 gpio_request(GPIO_FN_FSIOBSD, NULL);
1100 gpio_request(GPIO_FN_FSIIBBCK, NULL);
1101 gpio_request(GPIO_FN_FSIIBLRCK, NULL);
1102 gpio_request(GPIO_FN_FSIOBBCK, NULL);
1103 gpio_request(GPIO_FN_FSIOBLRCK, NULL);
1104 gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
1105
1106 /* change parent of FSI B */
1107 clk = clk_get(NULL, "fsib_clk");
1108 clk_register(&fsimckb_clk);
1109 clk_set_parent(clk, &fsimckb_clk);
1110 clk_set_rate(clk, 11000);
1111 clk_set_rate(&fsimckb_clk, 11000);
1112 clk_put(clk);
1113
1114 gpio_request(GPIO_PTU0, NULL);
1115 gpio_direction_output(GPIO_PTU0, 0);
1116 mdelay(20);
802 1117
803 /* enable I2C device */ 1118 /* enable I2C device */
1119 i2c_register_board_info(0, i2c0_devices,
1120 ARRAY_SIZE(i2c0_devices));
1121
804 i2c_register_board_info(1, i2c1_devices, 1122 i2c_register_board_info(1, i2c1_devices,
805 ARRAY_SIZE(i2c1_devices)); 1123 ARRAY_SIZE(i2c1_devices));
806 1124