sh: mach-ecovec24: Document DS2 switch settings.
[pandora-kernel.git] / arch / sh / boards / mach-ecovec24 / setup.c
index 6cd1b78..bbc7859 100644 (file)
 #include <linux/delay.h>
 #include <linux/usb/r8a66597.h>
 #include <linux/i2c.h>
+#include <linux/i2c/tsc2007.h>
+#include <linux/input.h>
 #include <video/sh_mobile_lcdc.h>
 #include <media/sh_mobile_ceu.h>
 #include <asm/heartbeat.h>
 #include <asm/sh_eth.h>
+#include <asm/sh_keysc.h>
+#include <asm/clock.h>
 #include <cpu/sh7724.h>
 
 /*
  *  0x1800_0000  MFI              16bit
  */
 
+/* SWITCH
+ *------------------------------
+ * DS2[1] = FlashROM write protect  ON     : write protect
+ *                                  OFF    : No write protect
+ * DS2[2] = RMII / TS, SCIF         ON     : RMII
+ *                                  OFF    : TS, SCIF3
+ * DS2[3] = Camera / Video          ON     : Camera
+ *                                  OFF    : NTSC/PAL (IN)
+ * DS2[5] = NTSC_OUT Clock          ON     : On board OSC
+ *                                  OFF    : SH7724 DV_CLK
+ * DS2[6-7] = MMC / SD              ON-OFF : SD
+ *                                  OFF-ON : MMC
+ */
+
 /* Heartbeat */
 static unsigned char led_pos[] = { 0, 1, 2, 3 };
 static struct heartbeat_data heartbeat_data = {
@@ -67,7 +85,7 @@ static struct mtd_partition nor_flash_partitions[] = {
                .name = "boot loader",
                .offset = 0,
                .size = (5 * 1024 * 1024),
-               .mask_flags = MTD_CAP_ROM,
+               .mask_flags = MTD_WRITEABLE,  /* force read-only */
        }, {
                .name = "free-area",
                .offset = MTDPART_OFS_APPEND,
@@ -118,6 +136,7 @@ static struct resource sh_eth_resources[] = {
 struct sh_eth_plat_data sh_eth_plat = {
        .phy = 0x1f, /* SMSC LAN8700 */
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
+       .ether_link_active_low = 1
 };
 
 static struct platform_device sh_eth_device = {
@@ -236,7 +255,7 @@ static struct resource lcdc_resources[] = {
        [0] = {
                .name   = "LCDC",
                .start  = 0xfe940000,
-               .end    = 0xfe941fff,
+               .end    = 0xfe942fff,
                .flags  = IORESOURCE_MEM,
        },
        [1] = {
@@ -332,6 +351,83 @@ static struct i2c_board_info i2c1_devices[] = {
        },
 };
 
+/* KEYSC */
+static struct sh_keysc_info keysc_info = {
+       .mode           = SH_KEYSC_MODE_1,
+       .scan_timing    = 3,
+       .delay          = 50,
+       .kycr2_delay    = 100,
+       .keycodes       = { KEY_1, 0, 0, 0, 0,
+                           KEY_2, 0, 0, 0, 0,
+                           KEY_3, 0, 0, 0, 0,
+                           KEY_4, 0, 0, 0, 0,
+                           KEY_5, 0, 0, 0, 0,
+                           KEY_6, 0, 0, 0, 0, },
+};
+
+static struct resource keysc_resources[] = {
+       [0] = {
+               .name   = "KEYSC",
+               .start  = 0x044b0000,
+               .end    = 0x044b000f,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = 79,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device keysc_device = {
+       .name           = "sh_keysc",
+       .id             = 0, /* keysc0 clock */
+       .num_resources  = ARRAY_SIZE(keysc_resources),
+       .resource       = keysc_resources,
+       .dev    = {
+               .platform_data  = &keysc_info,
+       },
+       .archdata = {
+               .hwblk_id = HWBLK_KEYSC,
+       },
+};
+
+/* TouchScreen */
+#define IRQ0 32
+static int ts_get_pendown_state(void)
+{
+       int val = 0;
+       gpio_free(GPIO_FN_INTC_IRQ0);
+       gpio_request(GPIO_PTZ0, NULL);
+       gpio_direction_input(GPIO_PTZ0);
+
+       val = gpio_get_value(GPIO_PTZ0);
+
+       gpio_free(GPIO_PTZ0);
+       gpio_request(GPIO_FN_INTC_IRQ0, NULL);
+
+       return val ? 0 : 1;
+}
+
+static int ts_init(void)
+{
+       gpio_request(GPIO_FN_INTC_IRQ0, NULL);
+       return 0;
+}
+
+struct tsc2007_platform_data tsc2007_info = {
+       .model                  = 2007,
+       .x_plate_ohms           = 180,
+       .get_pendown_state      = ts_get_pendown_state,
+       .init_platform_hw       = ts_init,
+};
+
+static struct i2c_board_info ts_i2c_clients = {
+       I2C_BOARD_INFO("tsc2007", 0x48),
+       .type           = "tsc2007",
+       .platform_data  = &tsc2007_info,
+       .irq            = IRQ0,
+};
+
 static struct platform_device *ecovec_devices[] __initdata = {
        &heartbeat_device,
        &nor_flash_device,
@@ -341,6 +437,7 @@ static struct platform_device *ecovec_devices[] __initdata = {
        &lcdc_device,
        &ceu0_device,
        &ceu1_device,
+       &keysc_device,
 };
 
 #define EEPROM_ADDR 0x50
@@ -428,6 +525,7 @@ static int __init arch_setup(void)
        gpio_direction_output(GPIO_PTG1, 0);
        gpio_direction_output(GPIO_PTG2, 0);
        gpio_direction_output(GPIO_PTG3, 0);
+       ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
 
        /* enable SH-Eth */
        gpio_request(GPIO_PTA1, NULL);
@@ -448,6 +546,7 @@ static int __init arch_setup(void)
 
        /* enable USB */
        ctrl_outw(0x0000, 0xA4D80000);
+       ctrl_outw(0x0000, 0xA4D90000);
        gpio_request(GPIO_PTB3,  NULL);
        gpio_request(GPIO_PTB4,  NULL);
        gpio_request(GPIO_PTB5,  NULL);
@@ -543,6 +642,10 @@ static int __init arch_setup(void)
                 */
                gpio_request(GPIO_PTF4, NULL);
                gpio_direction_output(GPIO_PTF4, 1);
+
+               /* enable TouchScreen */
+               i2c_register_board_info(0, &ts_i2c_clients, 1);
+               set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
        }
 
        /* enable CEU0 */
@@ -583,6 +686,25 @@ static int __init arch_setup(void)
        gpio_request(GPIO_FN_VIO1_CLK, NULL);
        platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
 
+       /* enable KEYSC */
+       gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
+       gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
+       gpio_request(GPIO_FN_KEYOUT3,     NULL);
+       gpio_request(GPIO_FN_KEYOUT2,     NULL);
+       gpio_request(GPIO_FN_KEYOUT1,     NULL);
+       gpio_request(GPIO_FN_KEYOUT0,     NULL);
+       gpio_request(GPIO_FN_KEYIN0,      NULL);
+
+       /* enable user debug switch */
+       gpio_request(GPIO_PTR0, NULL);
+       gpio_request(GPIO_PTR4, NULL);
+       gpio_request(GPIO_PTR5, NULL);
+       gpio_request(GPIO_PTR6, NULL);
+       gpio_direction_input(GPIO_PTR0);
+       gpio_direction_input(GPIO_PTR4);
+       gpio_direction_input(GPIO_PTR5);
+       gpio_direction_input(GPIO_PTR6);
+
        /* enable I2C device */
        i2c_register_board_info(1, i2c1_devices,
                                ARRAY_SIZE(i2c1_devices));