diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-09-16 07:59:53 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2012-10-14 22:05:42 -0400 |
commit | e69dc9a91eeb0387e08d8e1d0e576c88b28902fc (patch) | |
tree | 4b4ef12b66ae33e79b77528f7e9568a62743f43a /drivers/video | |
parent | 7f917a8df68985aa38a90b7110b5f42bfa0d7cda (diff) |
video: imxfb: remove cpu_is_xxx by using platform_device_id
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
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/imxfb.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index cf2688de083..e501dbc966b 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/math64.h> | 33 | #include <linux/math64.h> |
34 | 34 | ||
35 | #include <linux/platform_data/video-imxfb.h> | 35 | #include <linux/platform_data/video-imxfb.h> |
36 | #include <mach/hardware.h> | ||
37 | 36 | ||
38 | /* | 37 | /* |
39 | * Complain if VAR is out of range. | 38 | * Complain if VAR is out of range. |
@@ -53,8 +52,8 @@ | |||
53 | #define LCDC_SIZE 0x04 | 52 | #define LCDC_SIZE 0x04 |
54 | #define SIZE_XMAX(x) ((((x) >> 4) & 0x3f) << 20) | 53 | #define SIZE_XMAX(x) ((((x) >> 4) & 0x3f) << 20) |
55 | 54 | ||
56 | #define YMAX_MASK (cpu_is_mx1() ? 0x1ff : 0x3ff) | 55 | #define YMAX_MASK_IMX1 0x1ff |
57 | #define SIZE_YMAX(y) ((y) & YMAX_MASK) | 56 | #define YMAX_MASK_IMX21 0x3ff |
58 | 57 | ||
59 | #define LCDC_VPW 0x08 | 58 | #define LCDC_VPW 0x08 |
60 | #define VPW_VPW(x) ((x) & 0x3ff) | 59 | #define VPW_VPW(x) ((x) & 0x3ff) |
@@ -128,12 +127,18 @@ struct imxfb_rgb { | |||
128 | struct fb_bitfield transp; | 127 | struct fb_bitfield transp; |
129 | }; | 128 | }; |
130 | 129 | ||
130 | enum imxfb_type { | ||
131 | IMX1_FB, | ||
132 | IMX21_FB, | ||
133 | }; | ||
134 | |||
131 | struct imxfb_info { | 135 | struct imxfb_info { |
132 | struct platform_device *pdev; | 136 | struct platform_device *pdev; |
133 | void __iomem *regs; | 137 | void __iomem *regs; |
134 | struct clk *clk_ipg; | 138 | struct clk *clk_ipg; |
135 | struct clk *clk_ahb; | 139 | struct clk *clk_ahb; |
136 | struct clk *clk_per; | 140 | struct clk *clk_per; |
141 | enum imxfb_type devtype; | ||
137 | 142 | ||
138 | /* | 143 | /* |
139 | * These are the addresses we mapped | 144 | * These are the addresses we mapped |
@@ -168,6 +173,24 @@ struct imxfb_info { | |||
168 | void (*backlight_power)(int); | 173 | void (*backlight_power)(int); |
169 | }; | 174 | }; |
170 | 175 | ||
176 | static struct platform_device_id imxfb_devtype[] = { | ||
177 | { | ||
178 | .name = "imx1-fb", | ||
179 | .driver_data = IMX1_FB, | ||
180 | }, { | ||
181 | .name = "imx21-fb", | ||
182 | .driver_data = IMX21_FB, | ||
183 | }, { | ||
184 | /* sentinel */ | ||
185 | } | ||
186 | }; | ||
187 | MODULE_DEVICE_TABLE(platform, imxfb_devtype); | ||
188 | |||
189 | static inline int is_imx1_fb(struct imxfb_info *fbi) | ||
190 | { | ||
191 | return fbi->devtype == IMX1_FB; | ||
192 | } | ||
193 | |||
171 | #define IMX_NAME "IMX" | 194 | #define IMX_NAME "IMX" |
172 | 195 | ||
173 | /* | 196 | /* |
@@ -366,7 +389,7 @@ static int imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
366 | break; | 389 | break; |
367 | case 16: | 390 | case 16: |
368 | default: | 391 | default: |
369 | if (cpu_is_mx1()) | 392 | if (is_imx1_fb(fbi)) |
370 | pcr |= PCR_BPIX_12; | 393 | pcr |= PCR_BPIX_12; |
371 | else | 394 | else |
372 | pcr |= PCR_BPIX_16; | 395 | pcr |= PCR_BPIX_16; |
@@ -596,6 +619,7 @@ static struct fb_ops imxfb_ops = { | |||
596 | static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info) | 619 | static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info) |
597 | { | 620 | { |
598 | struct imxfb_info *fbi = info->par; | 621 | struct imxfb_info *fbi = info->par; |
622 | u32 ymax_mask = is_imx1_fb(fbi) ? YMAX_MASK_IMX1 : YMAX_MASK_IMX21; | ||
599 | 623 | ||
600 | pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n", | 624 | pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n", |
601 | var->xres, var->hsync_len, | 625 | var->xres, var->hsync_len, |
@@ -617,7 +641,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf | |||
617 | if (var->right_margin > 255) | 641 | if (var->right_margin > 255) |
618 | printk(KERN_ERR "%s: invalid right_margin %d\n", | 642 | printk(KERN_ERR "%s: invalid right_margin %d\n", |
619 | info->fix.id, var->right_margin); | 643 | info->fix.id, var->right_margin); |
620 | if (var->yres < 1 || var->yres > YMAX_MASK) | 644 | if (var->yres < 1 || var->yres > ymax_mask) |
621 | printk(KERN_ERR "%s: invalid yres %d\n", | 645 | printk(KERN_ERR "%s: invalid yres %d\n", |
622 | info->fix.id, var->yres); | 646 | info->fix.id, var->yres); |
623 | if (var->vsync_len > 100) | 647 | if (var->vsync_len > 100) |
@@ -645,7 +669,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf | |||
645 | VCR_V_WAIT_2(var->upper_margin), | 669 | VCR_V_WAIT_2(var->upper_margin), |
646 | fbi->regs + LCDC_VCR); | 670 | fbi->regs + LCDC_VCR); |
647 | 671 | ||
648 | writel(SIZE_XMAX(var->xres) | SIZE_YMAX(var->yres), | 672 | writel(SIZE_XMAX(var->xres) | (var->yres & ymax_mask), |
649 | fbi->regs + LCDC_SIZE); | 673 | fbi->regs + LCDC_SIZE); |
650 | 674 | ||
651 | writel(fbi->pcr, fbi->regs + LCDC_PCR); | 675 | writel(fbi->pcr, fbi->regs + LCDC_PCR); |
@@ -765,6 +789,7 @@ static int __init imxfb_probe(struct platform_device *pdev) | |||
765 | return -ENOMEM; | 789 | return -ENOMEM; |
766 | 790 | ||
767 | fbi = info->par; | 791 | fbi = info->par; |
792 | fbi->devtype = pdev->id_entry->driver_data; | ||
768 | 793 | ||
769 | if (!fb_mode) | 794 | if (!fb_mode) |
770 | fb_mode = pdata->mode[0].mode.name; | 795 | fb_mode = pdata->mode[0].mode.name; |
@@ -939,6 +964,7 @@ static struct platform_driver imxfb_driver = { | |||
939 | .driver = { | 964 | .driver = { |
940 | .name = DRIVER_NAME, | 965 | .name = DRIVER_NAME, |
941 | }, | 966 | }, |
967 | .id_table = imxfb_devtype, | ||
942 | }; | 968 | }; |
943 | 969 | ||
944 | static int imxfb_setup(void) | 970 | static int imxfb_setup(void) |