video: imxfb: remove cpu_is_xxx by using platform_device_id
authorShawn Guo <shawn.guo@linaro.org>
Sun, 16 Sep 2012 11:59:53 +0000 (19:59 +0800)
committerShawn Guo <shawn.guo@linaro.org>
Mon, 15 Oct 2012 02:05:42 +0000 (10:05 +0800)
It changes the driver to use platform_device_id rather than cpu_is_xxx
to determine the controller type, and updates the platform code
accordingly.

As the result, mach/hardware.h inclusion gets removed from the driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: linux-fbdev@vger.kernel.org
arch/arm/mach-imx/clk-imx1.c
arch/arm/mach-imx/clk-imx21.c
arch/arm/mach-imx/clk-imx25.c
arch/arm/mach-imx/clk-imx27.c
arch/arm/mach-imx/devices/devices-common.h
arch/arm/mach-imx/devices/platform-imx-fb.c
drivers/video/imxfb.c

index 49a74440bc4837edf63fccfa058a48705fb32f6c..796d8b86e8b675339d3a6e67556ab24f61088be7 100644 (file)
@@ -102,9 +102,9 @@ int __init mx1_clocks_init(unsigned long fref)
        clk_register_clkdev(clk[per2], "per", "imx1-cspi.1");
        clk_register_clkdev(clk[dummy], "ipg", "imx1-cspi.1");
        clk_register_clkdev(clk[per2], NULL, "imx-mmc.0");
-       clk_register_clkdev(clk[per2], "per", "imx-fb.0");
-       clk_register_clkdev(clk[dummy], "ipg", "imx-fb.0");
-       clk_register_clkdev(clk[dummy], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[per2], "per", "imx1-fb.0");
+       clk_register_clkdev(clk[dummy], "ipg", "imx1-fb.0");
+       clk_register_clkdev(clk[dummy], "ahb", "imx1-fb.0");
        clk_register_clkdev(clk[hclk], "mshc", NULL);
        clk_register_clkdev(clk[per3], "ssi", NULL);
        clk_register_clkdev(clk[clk32], NULL, "imx1-rtc.0");
index 8aec572f84feb6aa3b4e89cbd4babcb938bb5cdb..fcdaa9b9cec7425d67c1b21d078c63b85f501e4b 100644 (file)
@@ -157,9 +157,9 @@ int __init mx21_clocks_init(unsigned long lref, unsigned long href)
        clk_register_clkdev(clk[cspi2_ipg_gate], "ipg", "imx21-cspi.1");
        clk_register_clkdev(clk[per2], "per", "imx21-cspi.2");
        clk_register_clkdev(clk[cspi3_ipg_gate], "ipg", "imx21-cspi.2");
-       clk_register_clkdev(clk[per3], "per", "imx-fb.0");
-       clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0");
-       clk_register_clkdev(clk[lcdc_hclk_gate], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[per3], "per", "imx21-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx21-fb.0");
+       clk_register_clkdev(clk[lcdc_hclk_gate], "ahb", "imx21-fb.0");
        clk_register_clkdev(clk[usb_gate], "per", "imx21-hcd.0");
        clk_register_clkdev(clk[usb_hclk_gate], "ahb", "imx21-hcd.0");
        clk_register_clkdev(clk[nfc_gate], NULL, "imx21-nand.0");
index 2add1ea22d44ee4ffed01bbbcb5f1a7a1b5e109a..08d98030e02f10cd42413dadc177f9a742ea68d7 100644 (file)
@@ -219,9 +219,9 @@ int __init mx25_clocks_init(void)
        clk_register_clkdev(clk[fec_ipg], "ipg", "imx25-fec.0");
        clk_register_clkdev(clk[fec_ahb], "ahb", "imx25-fec.0");
        clk_register_clkdev(clk[dryice_ipg], NULL, "imxdi_rtc.0");
-       clk_register_clkdev(clk[lcdc_ipg_per], "per", "imx-fb.0");
-       clk_register_clkdev(clk[lcdc_ipg], "ipg", "imx-fb.0");
-       clk_register_clkdev(clk[lcdc_ahb], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg_per], "per", "imx21-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg], "ipg", "imx21-fb.0");
+       clk_register_clkdev(clk[lcdc_ahb], "ahb", "imx21-fb.0");
        clk_register_clkdev(clk[wdt_ipg], NULL, "imx2-wdt.0");
        clk_register_clkdev(clk[ssi1_ipg], NULL, "imx-ssi.0");
        clk_register_clkdev(clk[ssi2_ipg], NULL, "imx-ssi.1");
index 46764d864232137ca70941d79ea648787c1ac312..4204092ab64ae024a7205e74efc0783e73249376 100644 (file)
@@ -221,9 +221,9 @@ int __init mx27_clocks_init(unsigned long fref)
        clk_register_clkdev(clk[cspi1_ipg_gate], NULL, "imx27-cspi.0");
        clk_register_clkdev(clk[cspi2_ipg_gate], NULL, "imx27-cspi.1");
        clk_register_clkdev(clk[cspi3_ipg_gate], NULL, "imx27-cspi.2");
-       clk_register_clkdev(clk[per3_gate], "per", "imx-fb.0");
-       clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0");
-       clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[per3_gate], "per", "imx21-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx21-fb.0");
+       clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx21-fb.0");
        clk_register_clkdev(clk[csi_ahb_gate], "ahb", "imx27-camera.0");
        clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc");
        clk_register_clkdev(clk[usb_ipg_gate], "ipg", "fsl-usb2-udc");
index 4caf1c61e3506a4d05a31c9d745cb9559990377b..e4b790b9e2aaaea5d708371354ec83d9adc28844 100644 (file)
@@ -108,6 +108,7 @@ struct platform_device *__init imx_add_imxdi_rtc(
 
 #include <linux/platform_data/video-imxfb.h>
 struct imx_imx_fb_data {
+       const char *devid;
        resource_size_t iobase;
        resource_size_t iosize;
        resource_size_t irq;
index 4e6f85703918630436492be05e95471f20417ada..abea28bea282bafa6493aae3fa733ad7a396dafa 100644 (file)
@@ -10,8 +10,9 @@
 #include <mach/hardware.h>
 #include "devices-common.h"
 
-#define imx_imx_fb_data_entry_single(soc, _size)                       \
+#define imx_imx_fb_data_entry_single(soc, _devid, _size)               \
        {                                                               \
+               .devid = _devid,                                        \
                .iobase = soc ## _LCDC_BASE_ADDR,                       \
                .iosize = _size,                                        \
                .irq = soc ## _INT_LCDC,                                \
 
 #ifdef CONFIG_SOC_IMX1
 const struct imx_imx_fb_data imx1_imx_fb_data __initconst =
-       imx_imx_fb_data_entry_single(MX1, SZ_4K);
+       imx_imx_fb_data_entry_single(MX1, "imx1-fb", SZ_4K);
 #endif /* ifdef CONFIG_SOC_IMX1 */
 
 #ifdef CONFIG_SOC_IMX21
 const struct imx_imx_fb_data imx21_imx_fb_data __initconst =
-       imx_imx_fb_data_entry_single(MX21, SZ_4K);
+       imx_imx_fb_data_entry_single(MX21, "imx21-fb", SZ_4K);
 #endif /* ifdef CONFIG_SOC_IMX21 */
 
 #ifdef CONFIG_SOC_IMX25
 const struct imx_imx_fb_data imx25_imx_fb_data __initconst =
-       imx_imx_fb_data_entry_single(MX25, SZ_16K);
+       imx_imx_fb_data_entry_single(MX25, "imx21-fb", SZ_16K);
 #endif /* ifdef CONFIG_SOC_IMX25 */
 
 #ifdef CONFIG_SOC_IMX27
 const struct imx_imx_fb_data imx27_imx_fb_data __initconst =
-       imx_imx_fb_data_entry_single(MX27, SZ_4K);
+       imx_imx_fb_data_entry_single(MX27, "imx21-fb", SZ_4K);
 #endif /* ifdef CONFIG_SOC_IMX27 */
 
 struct platform_device *__init imx_add_imx_fb(
index cf2688de083244c2ab25da05638c6edb2d7e3a47..e501dbc966b3b2a3976d17956fc9bd9f387cec29 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/math64.h>
 
 #include <linux/platform_data/video-imxfb.h>
-#include <mach/hardware.h>
 
 /*
  * Complain if VAR is out of range.
@@ -53,8 +52,8 @@
 #define LCDC_SIZE      0x04
 #define SIZE_XMAX(x)   ((((x) >> 4) & 0x3f) << 20)
 
-#define YMAX_MASK       (cpu_is_mx1() ? 0x1ff : 0x3ff)
-#define SIZE_YMAX(y)   ((y) & YMAX_MASK)
+#define YMAX_MASK_IMX1 0x1ff
+#define YMAX_MASK_IMX21        0x3ff
 
 #define LCDC_VPW       0x08
 #define VPW_VPW(x)     ((x) & 0x3ff)
@@ -128,12 +127,18 @@ struct imxfb_rgb {
        struct fb_bitfield      transp;
 };
 
+enum imxfb_type {
+       IMX1_FB,
+       IMX21_FB,
+};
+
 struct imxfb_info {
        struct platform_device  *pdev;
        void __iomem            *regs;
        struct clk              *clk_ipg;
        struct clk              *clk_ahb;
        struct clk              *clk_per;
+       enum imxfb_type         devtype;
 
        /*
         * These are the addresses we mapped
@@ -168,6 +173,24 @@ struct imxfb_info {
        void (*backlight_power)(int);
 };
 
+static struct platform_device_id imxfb_devtype[] = {
+       {
+               .name = "imx1-fb",
+               .driver_data = IMX1_FB,
+       }, {
+               .name = "imx21-fb",
+               .driver_data = IMX21_FB,
+       }, {
+               /* sentinel */
+       }
+};
+MODULE_DEVICE_TABLE(platform, imxfb_devtype);
+
+static inline int is_imx1_fb(struct imxfb_info *fbi)
+{
+       return fbi->devtype == IMX1_FB;
+}
+
 #define IMX_NAME       "IMX"
 
 /*
@@ -366,7 +389,7 @@ static int imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                break;
        case 16:
        default:
-               if (cpu_is_mx1())
+               if (is_imx1_fb(fbi))
                        pcr |= PCR_BPIX_12;
                else
                        pcr |= PCR_BPIX_16;
@@ -596,6 +619,7 @@ static struct fb_ops imxfb_ops = {
 static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
        struct imxfb_info *fbi = info->par;
+       u32 ymax_mask = is_imx1_fb(fbi) ? YMAX_MASK_IMX1 : YMAX_MASK_IMX21;
 
        pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n",
                var->xres, var->hsync_len,
@@ -617,7 +641,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf
        if (var->right_margin > 255)
                printk(KERN_ERR "%s: invalid right_margin %d\n",
                        info->fix.id, var->right_margin);
-       if (var->yres < 1 || var->yres > YMAX_MASK)
+       if (var->yres < 1 || var->yres > ymax_mask)
                printk(KERN_ERR "%s: invalid yres %d\n",
                        info->fix.id, var->yres);
        if (var->vsync_len > 100)
@@ -645,7 +669,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf
                VCR_V_WAIT_2(var->upper_margin),
                fbi->regs + LCDC_VCR);
 
-       writel(SIZE_XMAX(var->xres) | SIZE_YMAX(var->yres),
+       writel(SIZE_XMAX(var->xres) | (var->yres & ymax_mask),
                        fbi->regs + LCDC_SIZE);
 
        writel(fbi->pcr, fbi->regs + LCDC_PCR);
@@ -765,6 +789,7 @@ static int __init imxfb_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        fbi = info->par;
+       fbi->devtype = pdev->id_entry->driver_data;
 
        if (!fb_mode)
                fb_mode = pdata->mode[0].mode.name;
@@ -939,6 +964,7 @@ static struct platform_driver imxfb_driver = {
        .driver         = {
                .name   = DRIVER_NAME,
        },
+       .id_table       = imxfb_devtype,
 };
 
 static int imxfb_setup(void)