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