Pull cpuidle into release branch
[pandora-kernel.git] / arch / arm / mach-omap1 / board-osk.c
index 7d0cf7a..5db182d 100644 (file)
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/i2c.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 
 #include <asm/hardware.h>
+#include <asm/gpio.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/flash.h>
 
-#include <asm/arch/gpio.h>
 #include <asm/arch/usb.h>
+#include <asm/arch/tps65010.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/tc.h>
 #include <asm/arch/common.h>
@@ -179,6 +183,19 @@ static struct platform_device *osk5912_devices[] __initdata = {
        &osk5912_mcbsp1_device,
 };
 
+static struct i2c_board_info __initdata osk_i2c_board_info[] = {
+       {
+               I2C_BOARD_INFO("tps65010", 0x48),
+               .type           = "tps65010",
+               .irq            = OMAP_GPIO_IRQ(OMAP_MPUIO(1)),
+       },
+       /* TODO when driver support is ready:
+        *  - aic23 audio chip at 0x1a
+        *  - on Mistral, 24c04 eeprom at 0x50
+        *  - optionally on Mistral, ov9640 camera sensor at 0x30
+        */
+};
+
 static void __init osk_init_smc91x(void)
 {
        if ((omap_request_gpio(0)) < 0) {
@@ -292,6 +309,18 @@ static struct platform_device osk5912_kp_device = {
        .resource       = osk5912_kp_resources,
 };
 
+static struct omap_backlight_config mistral_bl_data = {
+       .default_intensity      = 0xa0,
+};
+
+static struct platform_device mistral_bl_device = {
+       .name           = "omap-bl",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &mistral_bl_data,
+       },
+};
+
 static struct platform_device osk5912_lcd_device = {
        .name           = "lcd_osk",
        .id             = -1,
@@ -299,6 +328,7 @@ static struct platform_device osk5912_lcd_device = {
 
 static struct platform_device *mistral_devices[] __initdata = {
        &osk5912_kp_device,
+       &mistral_bl_device,
        &osk5912_lcd_device,
 };
 
@@ -342,6 +372,38 @@ static void __init osk_mistral_init(void)
         * can't talk to the ads or even the i2c eeprom.
         */
 
+       /* parallel camera interface */
+       omap_cfg_reg(J15_1610_CAM_LCLK);
+       omap_cfg_reg(J18_1610_CAM_D7);
+       omap_cfg_reg(J19_1610_CAM_D6);
+       omap_cfg_reg(J14_1610_CAM_D5);
+       omap_cfg_reg(K18_1610_CAM_D4);
+       omap_cfg_reg(K19_1610_CAM_D3);
+       omap_cfg_reg(K15_1610_CAM_D2);
+       omap_cfg_reg(K14_1610_CAM_D1);
+       omap_cfg_reg(L19_1610_CAM_D0);
+       omap_cfg_reg(L18_1610_CAM_VS);
+       omap_cfg_reg(L15_1610_CAM_HS);
+       omap_cfg_reg(M19_1610_CAM_RSTZ);
+       omap_cfg_reg(Y15_1610_CAM_OUTCLK);
+
+       /* serial camera interface */
+       omap_cfg_reg(H19_1610_CAM_EXCLK);
+       omap_cfg_reg(W13_1610_CCP_CLKM);
+       omap_cfg_reg(Y12_1610_CCP_CLKP);
+       /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
+       // omap_cfg_reg(Y14_1610_CCP_DATAM);
+       omap_cfg_reg(W14_1610_CCP_DATAP);
+
+       /* CAM_PWDN */
+       if (omap_request_gpio(11) == 0) {
+               omap_cfg_reg(N20_1610_GPIO11);
+               omap_set_gpio_direction(11, 0 /* out */);
+               omap_set_gpio_dataout(11, 0 /* off */);
+       } else
+               pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
+
+
        // omap_cfg_reg(P19_1610_GPIO6);        // BUSY
        omap_cfg_reg(P20_1610_GPIO4);   // PENIRQ
        set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING);
@@ -372,6 +434,15 @@ static void __init osk_mistral_init(void)
        } else
                printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
 
+       /* LCD:  backlight, and power; power controls other devices on the
+        * board, like the touchscreen, EEPROM, and wakeup (!) switch.
+        */
+       omap_cfg_reg(PWL);
+       if (omap_request_gpio(2) == 0) {
+               omap_set_gpio_direction(2, 0 /* out */);
+               omap_set_gpio_dataout(2, 1 /* on */);
+       }
+
        platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
 }
 #else
@@ -385,7 +456,7 @@ static void __init osk_init(void)
        /* Workaround for wrong CS3 (NOR flash) timing
         * There are some U-Boot versions out there which configure
         * wrong CS3 memory timings. This mainly leads to CRC
-        * or similiar errors if you use NOR flash (e.g. with JFFS2)
+        * or similar errors if you use NOR flash (e.g. with JFFS2)
         */
        if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
                EMIFS_CCS(3) = EMIFS_CS3_VAL;
@@ -397,6 +468,14 @@ static void __init osk_init(void)
        omap_board_config_size = ARRAY_SIZE(osk_config);
        USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
 
+       /* irq for tps65010 chip */
+       /* bootloader effectively does:  omap_cfg_reg(U19_1610_MPUIO1); */
+       if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
+               gpio_direction_input(OMAP_MPUIO(1));
+
+       i2c_register_board_info(1, osk_i2c_board_info,
+                       ARRAY_SIZE(osk_i2c_board_info));
+
        omap_serial_init();
        osk_mistral_init();
 }
@@ -406,6 +485,44 @@ static void __init osk_map_io(void)
        omap1_map_common_io();
 }
 
+#ifdef CONFIG_TPS65010
+static int __init osk_tps_init(void)
+{
+       if (!machine_is_omap_osk())
+               return 0;
+
+       /* Let LED1 (D9) blink */
+       tps65010_set_led(LED1, BLINK);
+
+       /* Disable LED 2 (D2) */
+       tps65010_set_led(LED2, OFF);
+
+       /* Set GPIO 1 HIGH to disable VBUS power supply;
+        * OHCI driver powers it up/down as needed.
+        */
+       tps65010_set_gpio_out_value(GPIO1, HIGH);
+
+       /* Set GPIO 2 low to turn on LED D3 */
+       tps65010_set_gpio_out_value(GPIO2, HIGH);
+
+       /* Set GPIO 3 low to take ethernet out of reset */
+       tps65010_set_gpio_out_value(GPIO3, LOW);
+
+       /* gpio4 for VDD_DSP */
+       /* FIXME send power to DSP iff it's configured */
+
+       /* Enable LOW_PWR */
+       tps65010_set_low_pwr(ON);
+
+       /* Switch VLDO2 to 3.0V for AIC23 */
+       tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
+                       | TPS_LDO1_ENABLE);
+
+       return 0;
+}
+fs_initcall(osk_tps_init);
+#endif
+
 MACHINE_START(OMAP_OSK, "TI-OSK")
        /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
        .phys_io        = 0xfff00000,