ARM: at91/avr32/atmel_lcdfb: add platform device-id table
[sfrench/cifs-2.6.git] / drivers / video / atmel_lcdfb.c
index 2effd35da5893d8eb9ddffb19f6c355e385ab93a..c1a2914447e14c4aef834a9e23fc70d6ad49377b 100644 (file)
 #define ATMEL_LCDC_DMA_BURST_LEN       8       /* words */
 #define ATMEL_LCDC_FIFO_SIZE           512     /* words */
 
+struct atmel_lcdfb_config {
+       bool have_alt_pixclock;
+       bool have_hozval;
+       bool have_intensity_bit;
+};
+
+static struct atmel_lcdfb_config at91sam9261_config = {
+       .have_hozval            = true,
+       .have_intensity_bit     = true,
+};
+
+static struct atmel_lcdfb_config at91sam9263_config = {
+       .have_intensity_bit     = true,
+};
+
+static struct atmel_lcdfb_config at91sam9g10_config = {
+       .have_hozval            = true,
+};
+
+static struct atmel_lcdfb_config at91sam9g45_config = {
+       .have_alt_pixclock      = true,
+};
+
+static struct atmel_lcdfb_config at91sam9g45es_config = {
+};
+
+static struct atmel_lcdfb_config at91sam9rl_config = {
+       .have_intensity_bit     = true,
+};
+
+static struct atmel_lcdfb_config at32ap_config = {
+       .have_hozval            = true,
+};
+
+static const struct platform_device_id atmel_lcdfb_devtypes[] = {
+       {
+               .name = "at91sam9261-lcdfb",
+               .driver_data = (unsigned long)&at91sam9261_config,
+       }, {
+               .name = "at91sam9263-lcdfb",
+               .driver_data = (unsigned long)&at91sam9263_config,
+       }, {
+               .name = "at91sam9g10-lcdfb",
+               .driver_data = (unsigned long)&at91sam9g10_config,
+       }, {
+               .name = "at91sam9g45-lcdfb",
+               .driver_data = (unsigned long)&at91sam9g45_config,
+       }, {
+               .name = "at91sam9g45es-lcdfb",
+               .driver_data = (unsigned long)&at91sam9g45es_config,
+       }, {
+               .name = "at91sam9rl-lcdfb",
+               .driver_data = (unsigned long)&at91sam9rl_config,
+       }, {
+               .name = "at32ap-lcdfb",
+               .driver_data = (unsigned long)&at32ap_config,
+       }, {
+               /* terminator */
+       }
+};
+
+static struct atmel_lcdfb_config *
+atmel_lcdfb_get_config(struct platform_device *pdev)
+{
+       unsigned long data;
+
+       data = platform_get_device_id(pdev)->driver_data;
+
+       return (struct atmel_lcdfb_config *)data;
+}
+
 #if defined(CONFIG_ARCH_AT91)
 #define        ATMEL_LCDFB_FBINFO_DEFAULT      (FBINFO_DEFAULT \
                                         | FBINFO_PARTIAL_PAN_OK \
@@ -199,8 +270,7 @@ static unsigned long compute_hozval(struct atmel_lcdfb_info *sinfo,
        unsigned long lcdcon2;
        unsigned long value;
 
-       if (!(cpu_is_at91sam9261() || cpu_is_at91sam9g10()
-               || cpu_is_at32ap7000()))
+       if (!sinfo->config->have_hozval)
                return xres;
 
        lcdcon2 = lcdc_readl(sinfo, ATMEL_LCDC_LCDCON2);
@@ -426,7 +496,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
                break;
        case 16:
                /* Older SOCs use IBGR:555 rather than BGR:565. */
-               if (sinfo->have_intensity_bit)
+               if (sinfo->config->have_intensity_bit)
                        var->green.length = 5;
                else
                        var->green.length = 6;
@@ -534,7 +604,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
        /* Now, the LCDC core... */
 
        /* Set pixel clock */
-       if (cpu_is_at91sam9g45() && !cpu_is_at91sam9g45es())
+       if (sinfo->config->have_alt_pixclock)
                pix_factor = 1;
 
        clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
@@ -686,7 +756,7 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
 
        case FB_VISUAL_PSEUDOCOLOR:
                if (regno < 256) {
-                       if (sinfo->have_intensity_bit) {
+                       if (sinfo->config->have_intensity_bit) {
                                /* old style I+BGR:555 */
                                val  = ((red   >> 11) & 0x001f);
                                val |= ((green >>  6) & 0x03e0);
@@ -874,10 +944,9 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
        }
        sinfo->info = info;
        sinfo->pdev = pdev;
-       if (cpu_is_at91sam9261() || cpu_is_at91sam9263() ||
-                                                       cpu_is_at91sam9rl()) {
-               sinfo->have_intensity_bit = true;
-       }
+       sinfo->config = atmel_lcdfb_get_config(pdev);
+       if (!sinfo->config)
+               goto free_info;
 
        strcpy(info->fix.id, sinfo->pdev->name);
        info->flags = ATMEL_LCDFB_FBINFO_DEFAULT;
@@ -1146,7 +1215,7 @@ static struct platform_driver atmel_lcdfb_driver = {
        .remove         = __exit_p(atmel_lcdfb_remove),
        .suspend        = atmel_lcdfb_suspend,
        .resume         = atmel_lcdfb_resume,
-
+       .id_table       = atmel_lcdfb_devtypes,
        .driver         = {
                .name   = "atmel_lcdfb",
                .owner  = THIS_MODULE,