pandora: reserve CMA area for c64_tools
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap3pandora.c
index feed150..6f98ba0 100644 (file)
@@ -37,6 +37,8 @@
 #include <linux/mmc/card.h>
 #include <linux/regulator/fixed.h>
 #include <linux/i2c/vsense.h>
+#include <linux/dma-mapping.h>
+#include <linux/dma-contiguous.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -136,7 +138,7 @@ static struct led_pwm pandora_pwm_leds[] = {
                .pwm_id                 = 1, /* LEDB */
        }, {
                .name                   = "pandora::charger",
-               .default_trigger        = "bq27500-0-charging",
+               .default_trigger        = "twl4030_bci-charging",
                .pwm_id                 = 3, /* PWM1 */
        }
 };
@@ -348,7 +350,7 @@ static void pandora_wl1251_init_card(struct mmc_card *card)
        card->cis.vendor = 0x104c;
        card->cis.device = 0x9066;
        card->cis.blksize = 512;
-       card->cis.max_dtr = 20000000;
+       card->cis.max_dtr = 24000000;
 }
 
 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
@@ -695,10 +697,15 @@ static void __init pandora_usb_host_init(void)
 
 static DECLARE_COMPLETION(ts_completion);
 static struct timespec ts_last_framedone;
+static int pendown_state;
 
 static void vsync_irq_wait_handler(void *data, u32 mask)
 {
        getnstimeofday(&ts_last_framedone);
+
+       /* reliable to read here */
+       pendown_state = !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
+
        complete(&ts_completion);
 }
 
@@ -723,11 +730,34 @@ static void ads7846_wait_for_sync(void)
 static int pandora_pendown_state(void)
 {
        static int val_old;
+       struct timespec now, diff;
+       u32 diff_us;
        int val;
        int ret;
        
+       /* This line is a noisy mess. It doesn't trigger spuriously, i.e.
+        * there is no signal when pen is up, but when it's down we have
+        * white noise of sorts. */
        val = !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
-       if (!in_irq() && !in_atomic() && val != val_old) {
+       pendown_state |= val;
+
+       if (in_irq() || in_atomic())
+               /* no time to fight noise.. */
+               return val | pendown_state;
+
+       if (val == 0) {
+               getnstimeofday(&now);
+               diff = timespec_sub(now, ts_last_framedone);
+               diff_us = diff.tv_nsec / NSEC_PER_USEC + diff.tv_sec * USEC_PER_SEC;
+
+               if (diff_us < 40000)
+                       /* assume pendown_state is up-to-date */
+                       val = pendown_state;
+               else
+                       pendown_state = 0;
+       }
+
+       if (val != val_old) {
                init_completion(&ts_completion);
                dispc_runtime_get();
                if (val)
@@ -760,12 +790,26 @@ static struct ads7846_platform_data pandora_ads7846_cfg = {
        .get_pendown_state      = pandora_pendown_state,
 };
 
+static struct platform_device pandora_ram_console = {
+       .name   = "ram_console",
+       .id     = -1,
+};
+
+static struct platform_device pandora_c64_tools = {
+       .name   = "c64_tools",
+       .dev    = {
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+       },
+};
+
 static struct platform_device *omap3pandora_devices[] __initdata = {
        &pandora_leds_gpio,
        &pandora_leds_pwm,
        &pandora_bl,
        &pandora_keys_gpio,
        &pandora_vwlan_device,
+       &pandora_ram_console,
+       &pandora_c64_tools,
 };
 
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
@@ -861,7 +905,7 @@ static void __init omap3pandora_init(void)
 
        spi_register_board_info(omap3pandora_spi_board_info,
                        ARRAY_SIZE(omap3pandora_spi_board_info));
-       omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 4, &pandora_ads7846_cfg);
+       omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 31, &pandora_ads7846_cfg);
        usbhs_init(&usbhs_bdata);
        usb_musb_init(NULL);
        gpmc_nand_init(&pandora_nand_data);
@@ -887,9 +931,33 @@ static int __init proc_pandora_init(void)
 fs_initcall(proc_pandora_init);
 #endif
 
+/* for debug.. */
+#include <../drivers/staging/android/persistent_ram.h>
+
+struct persistent_ram_descriptor ram_console_desc = {
+       .name           = "ram_console",
+       .size           = 0x20000,
+};
+
+struct persistent_ram ram_console_ram = {
+       .start          = 0x80fe0000,
+       .size           = 0x20000,
+       .num_descs      = 1,
+       .descs          = &ram_console_desc,
+};
+
+void __init pandora_reserve(void)
+{
+       omap_reserve();
+       dma_declare_contiguous(&pandora_c64_tools.dev, 4 * SZ_1M, 0x86000000, 0);
+#ifdef CONFIG_ANDROID_PERSISTENT_RAM
+       persistent_ram_early_init(&ram_console_ram);
+#endif
+}
+
 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
        .atag_offset    = 0x100,
-       .reserve        = omap_reserve,
+       .reserve        = pandora_reserve,
        .map_io         = omap3_map_io,
        .init_early     = omap35xx_init_early,
        .init_irq       = omap3_init_irq,