[ARM] pxa/corgi: use SPI-based driver for ads7846, corgi-lcd and max1111
authorEric Miao <eric.miao@marvell.com>
Fri, 29 Aug 2008 00:09:48 +0000 (08:09 +0800)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 23 Sep 2008 21:04:36 +0000 (22:04 +0100)
Signed-off-by: Eric Miao <eric.miao@marvell.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-pxa/Makefile
arch/arm/mach-pxa/corgi.c

index b069dcbb764c889efcd533bcb3de1e37fdb1594d..ced2a679d08acd684ca5d913f47b9e6ab062625c 100644 (file)
@@ -28,7 +28,7 @@ obj-$(CONFIG_MACH_MAINSTONE)  += mainstone.o
 obj-$(CONFIG_ARCH_PXA_IDP)     += idp.o
 obj-$(CONFIG_MACH_TRIZEPS4)    += trizeps4.o
 obj-$(CONFIG_MACH_COLIBRI)     += colibri.o
-obj-$(CONFIG_PXA_SHARP_C7xx)   += corgi.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o corgi_pm.o
+obj-$(CONFIG_PXA_SHARP_C7xx)   += corgi.o sharpsl_pm.o corgi_pm.o
 obj-$(CONFIG_PXA_SHARP_Cxx00)  += spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o spitz_pm.o
 obj-$(CONFIG_MACH_AKITA)       += akita-ioexp.o
 obj-$(CONFIG_MACH_POODLE)      += poodle.o
index 14155fc49a1208d2c8b9fc7116719c73f8972b7c..68765636bfce1e5b3f7205db9b444f87d966dfaa 100644 (file)
@@ -22,6 +22,9 @@
 #include <linux/pm.h>
 #include <linux/gpio.h>
 #include <linux/backlight.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
+#include <linux/spi/corgi_lcd.h>
 #include <video/w100fb.h>
 
 #include <asm/setup.h>
@@ -43,6 +46,7 @@
 #include <mach/irda.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
+#include <mach/pxa2xx_spi.h>
 #include <mach/corgi.h>
 #include <mach/sharpsl.h>
 
@@ -151,53 +155,6 @@ static struct scoop_pcmcia_config corgi_pcmcia_config = {
 
 EXPORT_SYMBOL(corgiscoop_device);
 
-
-/*
- * Corgi SSP Device
- *
- * Set the parent as the scoop device because a lot of SSP devices
- * also use scoop functions and this makes the power up/down order
- * work correctly.
- */
-struct platform_device corgissp_device = {
-       .name           = "corgi-ssp",
-       .dev            = {
-               .parent = &corgiscoop_device.dev,
-       },
-       .id             = -1,
-};
-
-struct corgissp_machinfo corgi_ssp_machinfo = {
-       .port           = 1,
-       .cs_lcdcon      = CORGI_GPIO_LCDCON_CS,
-       .cs_ads7846     = CORGI_GPIO_ADS7846_CS,
-       .cs_max1111     = CORGI_GPIO_MAX1111_CS,
-       .clk_lcdcon     = 76,
-       .clk_ads7846    = 2,
-       .clk_max1111    = 8,
-};
-
-
-/*
- * LCD/Framebuffer
- */
-static void w100_lcdtg_suspend(struct w100fb_par *par)
-{
-       corgi_lcdtg_suspend();
-}
-
-static void w100_lcdtg_init(struct w100fb_par *par)
-{
-       corgi_lcdtg_hw_init(par->xres);
-}
-
-
-static struct w100_tg_info corgi_lcdtg_info = {
-       .change  = w100_lcdtg_init,
-       .suspend = w100_lcdtg_suspend,
-       .resume  = w100_lcdtg_init,
-};
-
 static struct w100_mem_info corgi_fb_mem = {
        .ext_cntl          = 0x00040003,
        .sdram_mode_reg    = 0x00650021,
@@ -276,7 +233,6 @@ static struct w100_mode corgi_fb_modes[] = {
 };
 
 static struct w100fb_mach_info corgi_fb_info = {
-       .tg         = &corgi_lcdtg_info,
        .init_mode  = INIT_MODE_ROTATED,
        .mem        = &corgi_fb_mem,
        .regs       = &corgi_fb_regs,
@@ -302,60 +258,10 @@ static struct platform_device corgifb_device = {
        .resource       = corgi_fb_resources,
        .dev            = {
                .platform_data = &corgi_fb_info,
-               .parent = &corgissp_device.dev,
        },
 
 };
 
-
-/*
- * Corgi Backlight Device
- */
-static void corgi_bl_kick_battery(void)
-{
-       void (*kick_batt)(void);
-
-       kick_batt = symbol_get(sharpsl_battery_kick);
-       if (kick_batt) {
-               kick_batt();
-               symbol_put(sharpsl_battery_kick);
-       }
-}
-
-static void corgi_bl_set_intensity(int intensity)
-{
-       if (intensity > 0x10)
-               intensity += 0x10;
-
-       /* Bits 0-4 are accessed via the SSP interface */
-       corgi_ssp_blduty_set(intensity & 0x1f);
-
-       /* Bit 5 is via SCOOP */
-       if (intensity & 0x0020)
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
-       else
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
-}
-
-static struct generic_bl_info corgi_bl_machinfo = {
-       .name = "corgi-bl",
-       .max_intensity = 0x2f,
-       .default_intensity = 0x1f,
-       .limit_mask = 0x0b,
-       .set_bl_intensity = corgi_bl_set_intensity,
-       .kick_battery = corgi_bl_kick_battery,
-};
-
-static struct platform_device corgibl_device = {
-       .name           = "generic-bl",
-       .dev            = {
-               .parent = &corgifb_device.dev,
-               .platform_data  = &corgi_bl_machinfo,
-       },
-       .id             = -1,
-};
-
-
 /*
  * Corgi Keyboard Device
  */
@@ -373,66 +279,6 @@ static struct platform_device corgiled_device = {
        .id             = -1,
 };
 
-
-/*
- * Corgi Touch Screen Device
- */
-static unsigned long (*get_hsync_invperiod)(struct device *dev);
-
-static void inline sharpsl_wait_sync(int gpio)
-{
-       while((GPLR(gpio) & GPIO_bit(gpio)) == 0);
-       while((GPLR(gpio) & GPIO_bit(gpio)) != 0);
-}
-
-static unsigned long corgi_get_hsync_invperiod(void)
-{
-       if (!get_hsync_invperiod)
-               get_hsync_invperiod = symbol_get(w100fb_get_hsynclen);
-       if (!get_hsync_invperiod)
-               return 0;
-
-       return get_hsync_invperiod(&corgifb_device.dev);
-}
-
-static void corgi_put_hsync(void)
-{
-       if (get_hsync_invperiod)
-               symbol_put(w100fb_get_hsynclen);
-       get_hsync_invperiod = NULL;
-}
-
-static void corgi_wait_hsync(void)
-{
-       sharpsl_wait_sync(CORGI_GPIO_HSYNC);
-}
-
-static struct resource corgits_resources[] = {
-       [0] = {
-               .start          = CORGI_IRQ_GPIO_TP_INT,
-               .end            = CORGI_IRQ_GPIO_TP_INT,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct corgits_machinfo  corgi_ts_machinfo = {
-       .get_hsync_invperiod = corgi_get_hsync_invperiod,
-       .put_hsync           = corgi_put_hsync,
-       .wait_hsync          = corgi_wait_hsync,
-};
-
-static struct platform_device corgits_device = {
-       .name           = "corgi-ts",
-       .dev            = {
-               .parent = &corgissp_device.dev,
-               .platform_data  = &corgi_ts_machinfo,
-       },
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(corgits_resources),
-       .resource       = corgits_resources,
-};
-
-
 /*
  * MMC/SD Device
  *
@@ -555,14 +401,137 @@ static struct pxa2xx_udc_mach_info udc_info __initdata = {
        .gpio_pullup            = CORGI_GPIO_USB_PULLUP,
 };
 
+#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER)
+static struct pxa2xx_spi_master corgi_spi_info = {
+       .num_chipselect = 3,
+};
+
+static struct ads7846_platform_data corgi_ads7846_info = {
+       .model                  = 7846,
+       .vref_delay_usecs       = 100,
+       .x_plate_ohms           = 419,
+       .y_plate_ohms           = 486,
+       .gpio_pendown           = CORGI_GPIO_TP_INT,
+};
+
+static void corgi_ads7846_cs(u32 command)
+{
+       gpio_set_value(CORGI_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
+}
+
+static struct pxa2xx_spi_chip corgi_ads7846_chip = {
+       .cs_control     = corgi_ads7846_cs,
+};
+
+static void corgi_notify_intensity(int intensity)
+{
+       /* Bit 5 is via SCOOP */
+       if (intensity & 0x0020)
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
+       else
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
+}
+
+static void corgi_bl_kick_battery(void)
+{
+       void (*kick_batt)(void);
+
+       kick_batt = symbol_get(sharpsl_battery_kick);
+       if (kick_batt) {
+               kick_batt();
+               symbol_put(sharpsl_battery_kick);
+       }
+}
+
+static struct corgi_lcd_platform_data corgi_lcdcon_info = {
+       .init_mode              = CORGI_LCD_MODE_VGA,
+       .max_intensity          = 0x2f,
+       .default_intensity      = 0x1f,
+       .limit_mask             = 0x0b,
+       .notify                 = corgi_notify_intensity,
+       .kick_battery           = corgi_bl_kick_battery,
+};
+
+static void corgi_lcdcon_cs(u32 command)
+{
+       gpio_set_value(CORGI_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
+}
+
+static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
+       .cs_control     = corgi_lcdcon_cs,
+};
+
+static void corgi_max1111_cs(u32 command)
+{
+       gpio_set_value(CORGI_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
+}
+
+static struct pxa2xx_spi_chip corgi_max1111_chip = {
+       .cs_control     = corgi_max1111_cs,
+};
+
+static struct spi_board_info corgi_spi_devices[] = {
+       {
+               .modalias       = "ads7846",
+               .max_speed_hz   = 1200000,
+               .bus_num        = 1,
+               .chip_select    = 0,
+               .platform_data  = &corgi_ads7846_info,
+               .controller_data= &corgi_ads7846_chip,
+               .irq            = gpio_to_irq(CORGI_GPIO_TP_INT),
+       }, {
+               .modalias       = "corgi-lcd",
+               .max_speed_hz   = 50000,
+               .bus_num        = 1,
+               .chip_select    = 1,
+               .platform_data  = &corgi_lcdcon_info,
+               .controller_data= &corgi_lcdcon_chip,
+       }, {
+               .modalias       = "max1111",
+               .max_speed_hz   = 450000,
+               .bus_num        = 1,
+               .chip_select    = 2,
+               .controller_data= &corgi_max1111_chip,
+       },
+};
+
+static void __init corgi_init_spi(void)
+{
+       int err;
+
+       err = gpio_request(CORGI_GPIO_ADS7846_CS, "ADS7846_CS");
+       if (err)
+               return;
+
+       err = gpio_request(CORGI_GPIO_LCDCON_CS, "LCDCON_CS");
+       if (err)
+               goto err_free_1;
+
+       err = gpio_request(CORGI_GPIO_MAX1111_CS, "MAX1111_CS");
+       if (err)
+               goto err_free_2;
+
+       gpio_direction_output(CORGI_GPIO_ADS7846_CS, 1);
+       gpio_direction_output(CORGI_GPIO_LCDCON_CS, 1);
+       gpio_direction_output(CORGI_GPIO_MAX1111_CS, 1);
+
+       pxa2xx_set_spi_info(1, &corgi_spi_info);
+       spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));
+       return;
+
+err_free_2:
+       gpio_free(CORGI_GPIO_LCDCON_CS);
+err_free_1:
+       gpio_free(CORGI_GPIO_ADS7846_CS);
+}
+#else
+static inline void corgi_init_spi(void) {}
+#endif
 
 static struct platform_device *devices[] __initdata = {
        &corgiscoop_device,
-       &corgissp_device,
        &corgifb_device,
        &corgikbd_device,
-       &corgibl_device,
-       &corgits_device,
        &corgiled_device,
 };
 
@@ -592,7 +561,7 @@ static void __init corgi_init(void)
 
        pxa2xx_mfp_config(ARRAY_AND_SIZE(corgi_pin_config));
 
-       corgi_ssp_set_machinfo(&corgi_ssp_machinfo);
+       corgi_init_spi();
 
        pxa_set_udc_info(&udc_info);
        pxa_set_mci_info(&corgi_mci_platform_data);