aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-09-14 03:19:00 -0400
committerShawn Guo <shawn.guo@linaro.org>2012-10-14 22:03:15 -0400
commit5bdfba29f18f0a36df8e28328315213ea47eb529 (patch)
tree6c35d12ded1ee1c2fafd8eaada320d926651d1a3 /drivers/i2c
parent881994638c4033815dcdd26f43d209e83760d493 (diff)
i2c: imx: remove cpu_is_xxx by using platform_device_id
This is some amount of work left/forgot from device tree conversion. Instead of checking cpu_is_xxx to determine the controller type, the driver should use platform_device_id, which should match the device tree compatible string. The patch changes the driver to use platform_device_id rather than cpu_is_xxx to determine the controller type/version. It also updates the platform code and device tree source 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: Wolfram Sang <w.sang@pengutronix.de> Cc: linux-i2c@vger.kernel.org
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-imx.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 2ef162d148cb..b9734747d610 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -52,8 +52,6 @@
52#include <linux/of_device.h> 52#include <linux/of_device.h>
53#include <linux/of_i2c.h> 53#include <linux/of_i2c.h>
54#include <linux/pinctrl/consumer.h> 54#include <linux/pinctrl/consumer.h>
55
56#include <mach/hardware.h>
57#include <linux/platform_data/i2c-imx.h> 55#include <linux/platform_data/i2c-imx.h>
58 56
59/** Defines ******************************************************************** 57/** Defines ********************************************************************
@@ -115,6 +113,11 @@ static u16 __initdata i2c_clk_div[50][2] = {
115 { 3072, 0x1E }, { 3840, 0x1F } 113 { 3072, 0x1E }, { 3840, 0x1F }
116}; 114};
117 115
116enum imx_i2c_type {
117 IMX1_I2C,
118 IMX21_I2C,
119};
120
118struct imx_i2c_struct { 121struct imx_i2c_struct {
119 struct i2c_adapter adapter; 122 struct i2c_adapter adapter;
120 struct clk *clk; 123 struct clk *clk;
@@ -124,13 +127,33 @@ struct imx_i2c_struct {
124 unsigned int disable_delay; 127 unsigned int disable_delay;
125 int stopped; 128 int stopped;
126 unsigned int ifdr; /* IMX_I2C_IFDR */ 129 unsigned int ifdr; /* IMX_I2C_IFDR */
130 enum imx_i2c_type devtype;
131};
132
133static struct platform_device_id imx_i2c_devtype[] = {
134 {
135 .name = "imx1-i2c",
136 .driver_data = IMX1_I2C,
137 }, {
138 .name = "imx21-i2c",
139 .driver_data = IMX21_I2C,
140 }, {
141 /* sentinel */
142 }
127}; 143};
144MODULE_DEVICE_TABLE(platform, imx_i2c_devtype);
128 145
129static const struct of_device_id i2c_imx_dt_ids[] = { 146static const struct of_device_id i2c_imx_dt_ids[] = {
130 { .compatible = "fsl,imx1-i2c", }, 147 { .compatible = "fsl,imx1-i2c", .data = &imx_i2c_devtype[IMX1_I2C], },
148 { .compatible = "fsl,imx21-i2c", .data = &imx_i2c_devtype[IMX21_I2C], },
131 { /* sentinel */ } 149 { /* sentinel */ }
132}; 150};
133 151
152static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx)
153{
154 return i2c_imx->devtype == IMX1_I2C;
155}
156
134/** Functions for IMX I2C adapter driver *************************************** 157/** Functions for IMX I2C adapter driver ***************************************
135*******************************************************************************/ 158*******************************************************************************/
136 159
@@ -223,7 +246,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
223 temp &= ~(I2CR_MSTA | I2CR_MTX); 246 temp &= ~(I2CR_MSTA | I2CR_MTX);
224 writeb(temp, i2c_imx->base + IMX_I2C_I2CR); 247 writeb(temp, i2c_imx->base + IMX_I2C_I2CR);
225 } 248 }
226 if (cpu_is_mx1()) { 249 if (is_imx1_i2c(i2c_imx)) {
227 /* 250 /*
228 * This delay caused by an i.MXL hardware bug. 251 * This delay caused by an i.MXL hardware bug.
229 * If no (or too short) delay, no "STOP" bit will be generated. 252 * If no (or too short) delay, no "STOP" bit will be generated.
@@ -465,6 +488,8 @@ static struct i2c_algorithm i2c_imx_algo = {
465 488
466static int __init i2c_imx_probe(struct platform_device *pdev) 489static int __init i2c_imx_probe(struct platform_device *pdev)
467{ 490{
491 const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
492 &pdev->dev);
468 struct imx_i2c_struct *i2c_imx; 493 struct imx_i2c_struct *i2c_imx;
469 struct resource *res; 494 struct resource *res;
470 struct imxi2c_platform_data *pdata = pdev->dev.platform_data; 495 struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
@@ -497,6 +522,10 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
497 return -ENOMEM; 522 return -ENOMEM;
498 } 523 }
499 524
525 if (of_id)
526 pdev->id_entry = of_id->data;
527 i2c_imx->devtype = pdev->id_entry->driver_data;
528
500 /* Setup i2c_imx driver structure */ 529 /* Setup i2c_imx driver structure */
501 strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name)); 530 strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name));
502 i2c_imx->adapter.owner = THIS_MODULE; 531 i2c_imx->adapter.owner = THIS_MODULE;
@@ -593,7 +622,8 @@ static struct platform_driver i2c_imx_driver = {
593 .name = DRIVER_NAME, 622 .name = DRIVER_NAME,
594 .owner = THIS_MODULE, 623 .owner = THIS_MODULE,
595 .of_match_table = i2c_imx_dt_ids, 624 .of_match_table = i2c_imx_dt_ids,
596 } 625 },
626 .id_table = imx_i2c_devtype,
597}; 627};
598 628
599static int __init i2c_adap_imx_init(void) 629static int __init i2c_adap_imx_init(void)