[ARM] pxa: move mach/i2c.h to plat/i2c.h
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / poodle.c
index 461af1c..74f4ce6 100644 (file)
 #include <linux/fb.h>
 #include <linux/pm.h>
 #include <linux/delay.h>
+#include <linux/mtd/physmap.h>
 #include <linux/gpio.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
+#include <linux/mtd/sharpsl.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 
-#include <mach/pxa-regs.h>
-#include <mach/pxa2xx-regs.h>
-#include <mach/mfp-pxa25x.h>
+#include <mach/pxa25x.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
-#include <mach/i2c.h>
+#include <plat/i2c.h>
 #include <mach/irda.h>
 #include <mach/poodle.h>
 #include <mach/pxafb.h>
 #include <mach/sharpsl.h>
 #include <mach/ssp.h>
+#include <mach/pxa2xx_spi.h>
 
 #include <asm/hardware/scoop.h>
 #include <asm/hardware/locomo.h>
@@ -63,9 +66,9 @@ static unsigned long poodle_pin_config[] __initdata = {
 
        /* SSP1 */
        GPIO23_SSP1_SCLK,
-       GPIO24_SSP1_SFRM,
        GPIO25_SSP1_TXD,
        GPIO26_SSP1_RXD,
+       GPIO24_GPIO,    /* POODLE_GPIO_TP_CS - SFRM as chip select */
 
        /* I2S */
        GPIO28_I2S_BITCLK_OUT,
@@ -106,7 +109,7 @@ static unsigned long poodle_pin_config[] __initdata = {
        GPIO74_LCD_FCLK,
        GPIO75_LCD_LCLK,
        GPIO76_LCD_PCLK,
-       GPIO77_LCD_ACBIAS,
+       GPIO77_LCD_BIAS,
 
        /* PC Card */
        GPIO48_nPOE,
@@ -145,6 +148,7 @@ static struct resource poodle_scoop_resources[] = {
 static struct scoop_config poodle_scoop_setup = {
        .io_dir         = POODLE_SCOOP_IO_DIR,
        .io_out         = POODLE_SCOOP_IO_OUT,
+       .gpio_base      = POODLE_SCOOP_GPIO_BASE,
 };
 
 struct platform_device poodle_scoop_device = {
@@ -197,62 +201,55 @@ struct platform_device poodle_locomo_device = {
 
 EXPORT_SYMBOL(poodle_locomo_device);
 
-/*
- * Poodle SSP Device
- */
-
-struct platform_device poodle_ssp_device = {
-       .name           = "corgi-ssp",
-       .id             = -1,
+#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
+static struct pxa2xx_spi_master poodle_spi_info = {
+       .num_chipselect = 1,
 };
 
-struct corgissp_machinfo poodle_ssp_machinfo = {
-       .port           = 1,
-       .cs_lcdcon      = -1,
-       .cs_ads7846     = -1,
-       .cs_max1111     = -1,
-       .clk_lcdcon     = 2,
-       .clk_ads7846    = 36,
-       .clk_max1111    = 2,
+static struct ads7846_platform_data poodle_ads7846_info = {
+       .model                  = 7846,
+       .vref_delay_usecs       = 100,
+       .x_plate_ohms           = 419,
+       .y_plate_ohms           = 486,
+       .gpio_pendown           = POODLE_GPIO_TP_INT,
 };
 
-
-/*
- * Poodle Touch Screen Device
- */
-static struct resource poodlets_resources[] = {
-       [0] = {
-               .start          = POODLE_IRQ_GPIO_TP_INT,
-               .end            = POODLE_IRQ_GPIO_TP_INT,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static unsigned long poodle_get_hsync_invperiod(void)
-{
-       return 0;
-}
-
-static void poodle_null_hsync(void)
+static void ads7846_cs(u32 command)
 {
+       gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
 }
 
-static struct corgits_machinfo  poodle_ts_machinfo = {
-       .get_hsync_invperiod    = poodle_get_hsync_invperiod,
-       .put_hsync              = poodle_null_hsync,
-       .wait_hsync             = poodle_null_hsync,
+static struct pxa2xx_spi_chip poodle_ads7846_chip = {
+       .cs_control             = ads7846_cs,
 };
 
-static struct platform_device poodle_ts_device = {
-       .name           = "corgi-ts",
-       .dev            = {
-               .platform_data  = &poodle_ts_machinfo,
+static struct spi_board_info poodle_spi_devices[] = {
+       {
+               .modalias       = "ads7846",
+               .max_speed_hz   = 10000,
+               .bus_num        = 1,
+               .platform_data  = &poodle_ads7846_info,
+               .controller_data= &poodle_ads7846_chip,
+               .irq            = gpio_to_irq(POODLE_GPIO_TP_INT),
        },
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(poodlets_resources),
-       .resource       = poodlets_resources,
 };
 
+static void __init poodle_init_spi(void)
+{
+       int err;
+
+       err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
+       if (err)
+               return;
+
+       gpio_direction_output(POODLE_GPIO_TP_CS, 1);
+
+       pxa2xx_set_spi_info(1, &poodle_spi_info);
+       spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
+}
+#else
+static inline void poodle_init_spi(void) {}
+#endif
 
 /*
  * MMC/SD Device
@@ -416,21 +413,100 @@ static struct pxafb_mach_info poodle_fb_info = {
        .lcd_conn       = LCD_COLOR_TFT_16BPP,
 };
 
+static struct mtd_partition sharpsl_nand_partitions[] = {
+       {
+               .name = "System Area",
+               .offset = 0,
+               .size = 7 * 1024 * 1024,
+       },
+       {
+               .name = "Root Filesystem",
+               .offset = 7 * 1024 * 1024,
+               .size = 22 * 1024 * 1024,
+       },
+       {
+               .name = "Home Filesystem",
+               .offset = MTDPART_OFS_APPEND,
+               .size = MTDPART_SIZ_FULL,
+       },
+};
+
+static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
+
+static struct nand_bbt_descr sharpsl_bbt = {
+       .options = 0,
+       .offs = 4,
+       .len = 2,
+       .pattern = scan_ff_pattern
+};
+
+static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
+       .badblock_pattern       = &sharpsl_bbt,
+       .partitions             = sharpsl_nand_partitions,
+       .nr_partitions          = ARRAY_SIZE(sharpsl_nand_partitions),
+};
+
+static struct resource sharpsl_nand_resources[] = {
+       {
+               .start  = 0x0C000000,
+               .end    = 0x0C000FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device sharpsl_nand_device = {
+       .name           = "sharpsl-nand",
+       .id             = -1,
+       .resource       = sharpsl_nand_resources,
+       .num_resources  = ARRAY_SIZE(sharpsl_nand_resources),
+       .dev.platform_data      = &sharpsl_nand_platform_data,
+};
+
+static struct mtd_partition sharpsl_rom_parts[] = {
+       {
+               .name   ="Boot PROM Filesystem",
+               .offset = 0x00120000,
+               .size   = MTDPART_SIZ_FULL,
+       },
+};
+
+static struct physmap_flash_data sharpsl_rom_data = {
+       .width          = 2,
+       .nr_parts       = ARRAY_SIZE(sharpsl_rom_parts),
+       .parts          = sharpsl_rom_parts,
+};
+
+static struct resource sharpsl_rom_resources[] = {
+       {
+               .start  = 0x00000000,
+               .end    = 0x007fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device sharpsl_rom_device = {
+       .name   = "physmap-flash",
+       .id     = -1,
+       .resource = sharpsl_rom_resources,
+       .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
+       .dev.platform_data = &sharpsl_rom_data,
+};
+
 static struct platform_device *devices[] __initdata = {
        &poodle_locomo_device,
        &poodle_scoop_device,
-       &poodle_ssp_device,
-       &poodle_ts_device,
+       &sharpsl_nand_device,
+       &sharpsl_rom_device,
 };
 
 static void poodle_poweroff(void)
 {
-       arm_machine_restart('h');
+       arm_machine_restart('h', NULL);
 }
 
-static void poodle_restart(char mode)
+static void poodle_restart(char mode, const char *cmd)
 {
-       arm_machine_restart('h');
+       arm_machine_restart('h', cmd);
 }
 
 static void __init poodle_init(void)
@@ -445,7 +521,6 @@ static void __init poodle_init(void)
        pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
 
        platform_scoop_config = &poodle_pcmcia_config;
-       corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
 
        ret = platform_add_devices(devices, ARRAY_SIZE(devices));
        if (ret)
@@ -457,6 +532,7 @@ static void __init poodle_init(void)
        pxa_set_mci_info(&poodle_mci_platform_data);
        pxa_set_ficp_info(&poodle_ficp_platform_data);
        pxa_set_i2c_info(NULL);
+       poodle_init_spi();
 }
 
 static void __init fixup_poodle(struct machine_desc *desc,