From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 29/34] video: imxfb: remove cpu_is_xxx by using platform_device_id
Date: Thu, 20 Sep 2012 14:45:42 +0800 [thread overview]
Message-ID: <1348123547-31082-30-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1348123547-31082-1-git-send-email-shawn.guo@linaro.org>
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 at vger.kernel.org
---
arch/arm/mach-imx/clk-imx1.c | 6 ++---
arch/arm/mach-imx/clk-imx21.c | 6 ++---
arch/arm/mach-imx/clk-imx25.c | 6 ++---
arch/arm/mach-imx/clk-imx27.c | 6 ++---
arch/arm/mach-imx/devices/devices-common.h | 1 +
arch/arm/mach-imx/devices/platform-imx-fb.c | 11 ++++----
drivers/video/imxfb.c | 38 ++++++++++++++++++++++-----
7 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/arch/arm/mach-imx/clk-imx1.c b/arch/arm/mach-imx/clk-imx1.c
index a453e11..3413c41 100644
--- a/arch/arm/mach-imx/clk-imx1.c
+++ b/arch/arm/mach-imx/clk-imx1.c
@@ -101,9 +101,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");
diff --git a/arch/arm/mach-imx/clk-imx21.c b/arch/arm/mach-imx/clk-imx21.c
index 8aec572..fcdaa9b 100644
--- a/arch/arm/mach-imx/clk-imx21.c
+++ b/arch/arm/mach-imx/clk-imx21.c
@@ -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");
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c
index 71fe521..da7155d 100644
--- a/arch/arm/mach-imx/clk-imx25.c
+++ b/arch/arm/mach-imx/clk-imx25.c
@@ -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");
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index 71c3f12..d73d9ed 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -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");
diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
index 7fa3ef7..c32279b 100644
--- a/arch/arm/mach-imx/devices/devices-common.h
+++ b/arch/arm/mach-imx/devices/devices-common.h
@@ -100,6 +100,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;
diff --git a/arch/arm/mach-imx/devices/platform-imx-fb.c b/arch/arm/mach-imx/devices/platform-imx-fb.c
index 4e6f857..abea28b 100644
--- a/arch/arm/mach-imx/devices/platform-imx-fb.c
+++ b/arch/arm/mach-imx/devices/platform-imx-fb.c
@@ -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, \
@@ -19,22 +20,22 @@
#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(
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 53ffdfc..64a39e7 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -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;
@@ -938,6 +963,7 @@ static struct platform_driver imxfb_driver = {
.driver = {
.name = DRIVER_NAME,
},
+ .id_table = imxfb_devtype,
};
static int imxfb_setup(void)
--
1.7.9.5
next prev parent reply other threads:[~2012-09-20 6:45 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-20 6:45 [PATCH v2 00/34] i.MX multi-platform support Shawn Guo
2012-09-20 6:45 ` [PATCH v2 01/34] ARM: imx: include board headers in the same folder Shawn Guo
2012-09-20 6:45 ` [PATCH v2 02/34] ARM: imx: move iomux drivers and headers into mach-imx Shawn Guo
2012-09-20 6:45 ` [PATCH v2 03/34] ARM: imx: remove unnecessary inclusion from device-imx*.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 04/34] ARM: imx: move platform device code into mach-imx Shawn Guo
2012-09-20 6:45 ` [PATCH v2 05/34] ARM: imx: merge plat-mxc " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 06/34] ARM: imx: include common.h rather than mach/common.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 07/34] ARM: imx: ARM: imx: include cpuidle.h rather than mach/cpuidle.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 08/34] ARM: imx: include iim.h rather than mach/iim.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 09/34] ARM: imx: include iram.h rather than mach/iram.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 10/34] ARM: imx: include ulpi.h rather than mach/ulpi.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 11/34] media: mx1_camera: remove the driver Shawn Guo
2012-09-20 12:56 ` Mauro Carvalho Chehab
2012-09-20 14:47 ` Shawn Guo
2012-09-20 6:45 ` [PATCH v2 12/34] ARM: imx: remove mach/dma-mx1-mx2.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 13/34] dma: ipu: rename mach/ipu.h to include/linux/dma/ipu-dma.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 14/34] dma: imx-sdma: remove unneeded mach/hardware.h inclusion Shawn Guo
2012-09-20 6:45 ` [PATCH v2 15/34] ASoC: imx-ssi: " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 16/34] usb: ehci-mxc: " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 17/34] video: mx3fb: " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 18/34] watchdog: imx2_wdt: " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 19/34] i2c: imx: remove cpu_is_xxx by using platform_device_id Shawn Guo
2012-09-20 6:45 ` [PATCH v2 20/34] mtd: mxc_nand: " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 21/34] rtc: mxc_rtc: " Shawn Guo
2012-09-20 6:45 ` [PATCH v2 22/34] dma: imx-dma: use devm_kzalloc and devm_request_irq Shawn Guo
2012-09-20 6:45 ` [PATCH v2 23/34] dma: imx-dma: retrieve MEM and IRQ from resources Shawn Guo
2012-09-20 6:45 ` [PATCH v2 24/34] dma: imx-dma: remove cpu_is_xxx by using platform_device_id Shawn Guo
2012-09-20 6:45 ` [PATCH v2 25/34] media: mx2_camera: remove dead code in mx2_camera_add_device Shawn Guo
2012-09-20 6:45 ` [PATCH v2 26/34] media: mx2_camera: use managed functions to clean up code Shawn Guo
2012-09-20 6:45 ` [PATCH v2 27/34] media: mx2_camera: remove cpu_is_xxx by using platform_device_id Shawn Guo
2012-09-27 19:03 ` Mauro Carvalho Chehab
2012-10-06 8:26 ` Shawn Guo
2012-10-06 14:39 ` Mauro Carvalho Chehab
2012-09-20 6:45 ` [PATCH v2 28/34] mmc: mxcmmc: " Shawn Guo
2012-09-20 6:45 ` Shawn Guo [this message]
2012-09-20 6:45 ` [PATCH v2 30/34] ARM: imx: move debug macros to include/debug Shawn Guo
2012-09-20 6:45 ` [PATCH v2 31/34] ARM: imx: include hardware.h rather than mach/hardware.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 32/34] ARM: imx: remove header file mach/irqs.h Shawn Guo
2012-09-20 6:45 ` [PATCH v2 33/34] ARM: imx: call mxc_device_init() in soc specific function Shawn Guo
2012-09-20 6:45 ` [PATCH v2 34/34] ARM: imx: enable multi-platform build Shawn Guo
2012-09-20 7:39 ` [PATCH v2 00/34] i.MX multi-platform support Arnd Bergmann
2012-09-20 11:41 ` Mark Brown
2012-09-20 11:52 ` Shawn Guo
2012-09-20 12:47 ` Mark Brown
2012-09-20 13:36 ` Shawn Guo
2012-09-20 14:53 ` Shawn Guo
2012-09-20 15:56 ` Arnd Bergmann
2012-09-21 8:01 ` [alsa-devel] " Shawn Guo
2012-09-21 8:26 ` Olof Johansson
2012-09-21 16:46 ` Shawn Guo
2012-09-21 16:53 ` Shawn Guo
2012-09-22 7:41 ` Olof Johansson
2012-09-22 8:09 ` Olof Johansson
2012-09-22 9:34 ` Shawn Guo
2012-09-22 15:43 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348123547-31082-30-git-send-email-shawn.guo@linaro.org \
--to=shawn.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).