Merge git://git.infradead.org/battery-2.6
[pandora-kernel.git] / arch / arm / mach-omap1 / board-h2.c
index 48c8c91..b092162 100644 (file)
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/i2c.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
-#include <linux/workqueue.h>
 
 #include <asm/hardware.h>
+#include <asm/gpio.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 
-#include <asm/arch/gpio.h>
+#include <asm/arch/tps65010.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/tc.h>
 #include <asm/arch/irda.h>
@@ -139,6 +140,66 @@ static struct platform_device h2_nor_device = {
        .resource       = &h2_nor_resource,
 };
 
+#if 0  /* REVISIT: Enable when nand_platform_data is applied */
+
+static struct mtd_partition h2_nand_partitions[] = {
+#if 0
+       /* REVISIT:  enable these partitions if you make NAND BOOT
+        * work on your H2 (rev C or newer); published versions of
+        * x-load only support P2 and H3.
+        */
+       {
+               .name           = "xloader",
+               .offset         = 0,
+               .size           = 64 * 1024,
+               .mask_flags     = MTD_WRITEABLE,        /* force read-only */
+       },
+       {
+               .name           = "bootloader",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 256 * 1024,
+               .mask_flags     = MTD_WRITEABLE,        /* force read-only */
+       },
+       {
+               .name           = "params",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 192 * 1024,
+       },
+       {
+               .name           = "kernel",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 2 * SZ_1M,
+       },
+#endif
+       {
+               .name           = "filesystem",
+               .size           = MTDPART_SIZ_FULL,
+               .offset         = MTDPART_OFS_APPEND,
+       },
+};
+
+/* dip switches control NAND chip access:  8 bit, 16 bit, or neither */
+static struct nand_platform_data h2_nand_data = {
+       .options        = NAND_SAMSUNG_LP_OPTIONS,
+       .parts          = h2_nand_partitions,
+       .nr_parts       = ARRAY_SIZE(h2_nand_partitions),
+};
+
+static struct resource h2_nand_resource = {
+       .flags          = IORESOURCE_MEM,
+};
+
+static struct platform_device h2_nand_device = {
+       .name           = "omapnand",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &h2_nand_data,
+       },
+       .num_resources  = 1,
+       .resource       = &h2_nand_resource,
+};
+#endif
+
 static struct resource h2_smc91x_resources[] = {
        [0] = {
                .start  = OMAP1610_ETHR_START,          /* Physical */
@@ -218,11 +279,15 @@ static struct resource h2_irda_resources[] = {
                .flags  = IORESOURCE_IRQ,
        },
 };
+
+static u64 irda_dmamask = 0xffffffff;
+
 static struct platform_device h2_irda_device = {
        .name           = "omapirda",
        .id             = 0,
        .dev            = {
                .platform_data  = &h2_irda_data,
+               .dma_mask       = &irda_dmamask,
        },
        .num_resources  = ARRAY_SIZE(h2_irda_resources),
        .resource       = h2_irda_resources,
@@ -270,6 +335,7 @@ static struct platform_device h2_mcbsp1_device = {
 
 static struct platform_device *h2_devices[] __initdata = {
        &h2_nor_device,
+       //&h2_nand_device,
        &h2_smc91x_device,
        &h2_irda_device,
        &h2_kp_device,
@@ -277,6 +343,20 @@ static struct platform_device *h2_devices[] __initdata = {
        &h2_mcbsp1_device,
 };
 
+static struct i2c_board_info __initdata h2_i2c_board_info[] = {
+       {
+               I2C_BOARD_INFO("tps65010", 0x48),
+               .type           = "tps65010",
+               .irq            = OMAP_GPIO_IRQ(58),
+       },
+       /* TODO when driver support is ready:
+        *  - isp1301 OTG transceiver
+        *  - optional ov9640 camera sensor at 0x30
+        *  - pcf9754 for aGPS control
+        *  - ... etc
+        */
+};
+
 static void __init h2_init_smc91x(void)
 {
        if ((omap_request_gpio(0)) < 0) {
@@ -333,6 +413,13 @@ static struct omap_board_config_kernel h2_config[] __initdata = {
        { OMAP_TAG_LCD,         &h2_lcd_config },
 };
 
+#define H2_NAND_RB_GPIO_PIN    62
+
+static int h2_nand_dev_ready(struct nand_platform_data *data)
+{
+       return omap_get_gpio_datain(H2_NAND_RB_GPIO_PIN);
+}
+
 static void __init h2_init(void)
 {
        /* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
@@ -347,6 +434,13 @@ static void __init h2_init(void)
        h2_nor_resource.end = h2_nor_resource.start = omap_cs3_phys();
        h2_nor_resource.end += SZ_32M - 1;
 
+#if 0  /* REVISIT: Enable when nand_platform_data is applied */
+       h2_nand_resource.end = h2_nand_resource.start = OMAP_CS2B_PHYS;
+       h2_nand_resource.end += SZ_4K - 1;
+       if (!(omap_request_gpio(H2_NAND_RB_GPIO_PIN)))
+               h2_nand_data.dev_ready = h2_nand_dev_ready;
+#endif
+
        omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
        omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
 
@@ -367,6 +461,14 @@ static void __init h2_init(void)
        omap_board_config = h2_config;
        omap_board_config_size = ARRAY_SIZE(h2_config);
        omap_serial_init();
+
+       /* irq for tps65010 chip */
+       omap_cfg_reg(W4_GPIO58);
+       if (gpio_request(58, "tps65010") == 0)
+               gpio_direction_input(58);
+
+       i2c_register_board_info(1, h2_i2c_board_info,
+                       ARRAY_SIZE(h2_i2c_board_info));
 }
 
 static void __init h2_map_io(void)
@@ -374,6 +476,22 @@ static void __init h2_map_io(void)
        omap1_map_common_io();
 }
 
+#ifdef CONFIG_TPS65010
+static int __init h2_tps_init(void)
+{
+       if (!machine_is_omap_h2())
+               return 0;
+
+       /* gpio3 for SD, gpio4 for VDD_DSP */
+       /* FIXME send power to DSP iff it's configured */
+
+       /* Enable LOW_PWR */
+       tps65010_set_low_pwr(ON);
+       return 0;
+}
+fs_initcall(h2_tps_init);
+#endif
+
 MACHINE_START(OMAP_H2, "TI-H2")
        /* Maintainer: Imre Deak <imre.deak@nokia.com> */
        .phys_io        = 0xfff00000,