i2c: imx: remove cpu_is_xxx by using platform_device_id
authorShawn Guo <shawn.guo@linaro.org>
Fri, 14 Sep 2012 07:19:00 +0000 (15:19 +0800)
committerShawn Guo <shawn.guo@linaro.org>
Mon, 15 Oct 2012 02:03:15 +0000 (10:03 +0800)
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
18 files changed:
Documentation/devicetree/bindings/i2c/fsl-imx-i2c.txt
arch/arm/boot/dts/imx27.dtsi
arch/arm/boot/dts/imx51.dtsi
arch/arm/boot/dts/imx53.dtsi
arch/arm/boot/dts/imx6q.dtsi
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/clk-imx31.c
arch/arm/mach-imx/clk-imx35.c
arch/arm/mach-imx/clk-imx51-imx53.c
arch/arm/mach-imx/devices/devices-common.h
arch/arm/mach-imx/devices/platform-imx-i2c.c
arch/arm/mach-imx/imx27-dt.c
arch/arm/mach-imx/imx51-dt.c
arch/arm/mach-imx/mach-imx53.c
drivers/i2c/busses/i2c-imx.c

index f3cf43b..3614242 100644 (file)
@@ -12,13 +12,13 @@ Optional properties:
 Examples:
 
 i2c@83fc4000 { /* I2C2 on i.MX51 */
-       compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+       compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
        reg = <0x83fc4000 0x4000>;
        interrupts = <63>;
 };
 
 i2c@70038000 { /* HS-I2C on i.MX51 */
-       compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+       compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
        reg = <0x70038000 0x4000>;
        interrupts = <64>;
        clock-frequency = <400000>;
index 3e54f14..67d6727 100644 (file)
                        i2c1: i2c@10012000 {
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx27-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx27-i2c", "fsl,imx21-i2c";
                                reg = <0x10012000 0x1000>;
                                interrupts = <12>;
                                status = "disabled";
                        i2c2: i2c@1001d000 {
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx27-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx27-i2c", "fsl,imx21-i2c";
                                reg = <0x1001d000 0x1000>;
                                interrupts = <1>;
                                status = "disabled";
index 75d069f..54aea74 100644 (file)
                        i2c@83fc4000 { /* I2C2 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
                                reg = <0x83fc4000 0x4000>;
                                interrupts = <63>;
                                status = "disabled";
                        i2c@83fc8000 { /* I2C1 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx51-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
                                reg = <0x83fc8000 0x4000>;
                                interrupts = <62>;
                                status = "disabled";
index 76ebb1a..caf09ff 100644 (file)
                        i2c@53fec000 { /* I2C3 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx53-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx53-i2c", "fsl,imx21-i2c";
                                reg = <0x53fec000 0x4000>;
                                interrupts = <64>;
                                status = "disabled";
                        i2c@63fc4000 { /* I2C2 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx53-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx53-i2c", "fsl,imx21-i2c";
                                reg = <0x63fc4000 0x4000>;
                                interrupts = <63>;
                                status = "disabled";
                        i2c@63fc8000 { /* I2C1 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx53-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx53-i2c", "fsl,imx21-i2c";
                                reg = <0x63fc8000 0x4000>;
                                interrupts = <62>;
                                status = "disabled";
index f3990b0..f604a44 100644 (file)
                        i2c@021a0000 { /* I2C1 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx6q-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
                                reg = <0x021a0000 0x4000>;
                                interrupts = <0 36 0x04>;
                                clocks = <&clks 125>;
                        i2c@021a4000 { /* I2C2 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx6q-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
                                reg = <0x021a4000 0x4000>;
                                interrupts = <0 37 0x04>;
                                clocks = <&clks 126>;
                        i2c@021a8000 { /* I2C3 */
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               compatible = "fsl,imx6q-i2c", "fsl,imx1-i2c";
+                               compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
                                reg = <0x021a8000 0x4000>;
                                interrupts = <0 38 0x04>;
                                clocks = <&clks 127>;
index b5f90cc..1982388 100644 (file)
@@ -95,7 +95,7 @@ int __init mx1_clocks_init(unsigned long fref)
        clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.1");
        clk_register_clkdev(clk[per1], "per", "imx1-uart.2");
        clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.2");
-       clk_register_clkdev(clk[hclk], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[hclk], NULL, "imx1-i2c.0");
        clk_register_clkdev(clk[per2], "per", "imx1-cspi.0");
        clk_register_clkdev(clk[dummy], "ipg", "imx1-cspi.0");
        clk_register_clkdev(clk[per2], "per", "imx1-cspi.1");
index fbee6a4..09fc31c 100644 (file)
@@ -166,7 +166,7 @@ int __init mx21_clocks_init(unsigned long lref, unsigned long href)
        clk_register_clkdev(clk[dma_hclk_gate], "ahb", "imx-dma");
        clk_register_clkdev(clk[dma_gate], "ipg", "imx-dma");
        clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
-       clk_register_clkdev(clk[i2c_gate], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[i2c_gate], NULL, "imx21-i2c.0");
        clk_register_clkdev(clk[kpp_gate], NULL, "mxc-keypad");
        clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1.0");
        clk_register_clkdev(clk[brom_gate], "brom", NULL);
index 08a143a..f1d75e7 100644 (file)
@@ -213,9 +213,9 @@ int __init mx25_clocks_init(void)
        clk_register_clkdev(clk[per10], "per", "mxc_pwm.3");
        clk_register_clkdev(clk[kpp_ipg], NULL, "imx-keypad");
        clk_register_clkdev(clk[tsc_ipg], NULL, "mx25-adc");
-       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.0");
-       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.1");
-       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx21-i2c.0");
+       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx21-i2c.1");
+       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx21-i2c.2");
        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");
index 31010cb..c2f111f 100644 (file)
@@ -247,8 +247,8 @@ int __init mx27_clocks_init(unsigned long fref)
        clk_register_clkdev(clk[fec_ipg_gate], "ipg", "imx27-fec.0");
        clk_register_clkdev(clk[fec_ahb_gate], "ahb", "imx27-fec.0");
        clk_register_clkdev(clk[wdog_ipg_gate], NULL, "imx2-wdt.0");
-       clk_register_clkdev(clk[i2c1_ipg_gate], NULL, "imx-i2c.0");
-       clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[i2c1_ipg_gate], NULL, "imx21-i2c.0");
+       clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx21-i2c.1");
        clk_register_clkdev(clk[owire_ipg_gate], NULL, "mxc_w1.0");
        clk_register_clkdev(clk[kpp_ipg_gate], NULL, "imx-keypad");
        clk_register_clkdev(clk[emma_ahb_gate], "emma-ahb", "mx2-camera.0");
index a4c298a..76e6462 100644 (file)
@@ -155,9 +155,9 @@ int __init mx31_clocks_init(unsigned long fref)
        clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.3");
        clk_register_clkdev(clk[uart5_gate], "per", "imx21-uart.4");
        clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.4");
-       clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
-       clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
-       clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[i2c1_gate], NULL, "imx21-i2c.0");
+       clk_register_clkdev(clk[i2c2_gate], NULL, "imx21-i2c.1");
+       clk_register_clkdev(clk[i2c3_gate], NULL, "imx21-i2c.2");
        clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1.0");
        clk_register_clkdev(clk[sdhc1_gate], NULL, "mxc-mmc.0");
        clk_register_clkdev(clk[sdhc2_gate], NULL, "mxc-mmc.1");
index ba26bf3..ee25812 100644 (file)
@@ -226,9 +226,9 @@ int __init mx35_clocks_init()
        clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
        clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
        clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0");
-       clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
-       clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
-       clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[i2c1_gate], NULL, "imx21-i2c.0");
+       clk_register_clkdev(clk[i2c2_gate], NULL, "imx21-i2c.1");
+       clk_register_clkdev(clk[i2c3_gate], NULL, "imx21-i2c.2");
        clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core");
        clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb");
        clk_register_clkdev(clk[kpp_gate], NULL, "imx-keypad");
index 024587c..2449d8f 100644 (file)
@@ -258,8 +258,8 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
        clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx35-cspi.2");
        clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0");
        clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1");
-       clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
-       clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[i2c1_gate], NULL, "imx21-i2c.0");
+       clk_register_clkdev(clk[i2c2_gate], NULL, "imx21-i2c.1");
        clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.0");
        clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.0");
        clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.0");
@@ -345,7 +345,7 @@ int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
 
        mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
 
-       clk_register_clkdev(clk[hsi2c_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[hsi2c_gate], NULL, "imx21-i2c.2");
        clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL);
        clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0");
        clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
@@ -440,7 +440,7 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
        mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
 
        clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0");
-       clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[i2c3_gate], NULL, "imx21-i2c.2");
        clk_register_clkdev(clk[fec_gate], NULL, "imx25-fec.0");
        clk_register_clkdev(clk[ipu_gate], "bus", "imx53-ipu");
        clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx53-ipu");
index eaf79d2..86bf34c 100644 (file)
@@ -118,6 +118,7 @@ struct platform_device *__init imx_add_imx_fb(
 
 #include <linux/platform_data/i2c-imx.h>
 struct imx_imx_i2c_data {
+       const char *devid;
        int id;
        resource_size_t iobase;
        resource_size_t iosize;
index e0c7d62..424ce24 100644 (file)
@@ -9,31 +9,32 @@
 #include <mach/hardware.h>
 #include "devices-common.h"
 
-#define imx_imx_i2c_data_entry_single(soc, _id, _hwid, _size)          \
+#define imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)  \
        {                                                               \
+               .devid = _devid,                                        \
                .id = _id,                                              \
                .iobase = soc ## _I2C ## _hwid ## _BASE_ADDR,           \
                .iosize = _size,                                        \
                .irq = soc ## _INT_I2C ## _hwid,                        \
        }
 
-#define imx_imx_i2c_data_entry(soc, _id, _hwid, _size)                 \
-       [_id] = imx_imx_i2c_data_entry_single(soc, _id, _hwid, _size)
+#define imx_imx_i2c_data_entry(soc, _devid, _id, _hwid, _size)         \
+       [_id] = imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)
 
 #ifdef CONFIG_SOC_IMX1
 const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst =
-       imx_imx_i2c_data_entry_single(MX1, 0, , SZ_4K);
+       imx_imx_i2c_data_entry_single(MX1, "imx1-i2c", 0, , SZ_4K);
 #endif /* ifdef CONFIG_SOC_IMX1 */
 
 #ifdef CONFIG_SOC_IMX21
 const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
-       imx_imx_i2c_data_entry_single(MX21, 0, , SZ_4K);
+       imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
 #endif /* ifdef CONFIG_SOC_IMX21 */
 
 #ifdef CONFIG_SOC_IMX25
 const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
 #define imx25_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX25, _id, _hwid, SZ_16K)
+       imx_imx_i2c_data_entry(MX25, "imx21-i2c", _id, _hwid, SZ_16K)
        imx25_imx_i2c_data_entry(0, 1),
        imx25_imx_i2c_data_entry(1, 2),
        imx25_imx_i2c_data_entry(2, 3),
@@ -43,7 +44,7 @@ const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
 #ifdef CONFIG_SOC_IMX27
 const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
 #define imx27_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX27, _id, _hwid, SZ_4K)
+       imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
        imx27_imx_i2c_data_entry(0, 1),
        imx27_imx_i2c_data_entry(1, 2),
 };
@@ -52,7 +53,7 @@ const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
 #ifdef CONFIG_SOC_IMX31
 const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
 #define imx31_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX31, _id, _hwid, SZ_4K)
+       imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
        imx31_imx_i2c_data_entry(0, 1),
        imx31_imx_i2c_data_entry(1, 2),
        imx31_imx_i2c_data_entry(2, 3),
@@ -62,7 +63,7 @@ const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
 #ifdef CONFIG_SOC_IMX35
 const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
 #define imx35_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX35, _id, _hwid, SZ_4K)
+       imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
        imx35_imx_i2c_data_entry(0, 1),
        imx35_imx_i2c_data_entry(1, 2),
        imx35_imx_i2c_data_entry(2, 3),
@@ -72,7 +73,7 @@ const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
 #ifdef CONFIG_SOC_IMX50
 const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst = {
 #define imx50_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX50, _id, _hwid, SZ_4K)
+       imx_imx_i2c_data_entry(MX50, "imx21-i2c", _id, _hwid, SZ_4K)
        imx50_imx_i2c_data_entry(0, 1),
        imx50_imx_i2c_data_entry(1, 2),
        imx50_imx_i2c_data_entry(2, 3),
@@ -82,10 +83,11 @@ const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst = {
 #ifdef CONFIG_SOC_IMX51
 const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
 #define imx51_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX51, _id, _hwid, SZ_4K)
+       imx_imx_i2c_data_entry(MX51, "imx21-i2c", _id, _hwid, SZ_4K)
        imx51_imx_i2c_data_entry(0, 1),
        imx51_imx_i2c_data_entry(1, 2),
        {
+               .devid = "imx21-i2c",
                .id = 2,
                .iobase = MX51_HSI2C_DMA_BASE_ADDR,
                .iosize = SZ_16K,
@@ -97,7 +99,7 @@ const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
 #ifdef CONFIG_SOC_IMX53
 const struct imx_imx_i2c_data imx53_imx_i2c_data[] __initconst = {
 #define imx53_imx_i2c_data_entry(_id, _hwid)                           \
-       imx_imx_i2c_data_entry(MX53, _id, _hwid, SZ_4K)
+       imx_imx_i2c_data_entry(MX53, "imx21-i2c", _id, _hwid, SZ_4K)
        imx53_imx_i2c_data_entry(0, 1),
        imx53_imx_i2c_data_entry(1, 2),
        imx53_imx_i2c_data_entry(2, 3),
@@ -120,7 +122,7 @@ struct platform_device *__init imx_add_imx_i2c(
                },
        };
 
-       return imx_add_platform_device("imx-i2c", data->id,
+       return imx_add_platform_device(data->devid, data->id,
                        res, ARRAY_SIZE(res),
                        pdata, sizeof(*pdata));
 }
index 83c56fb..43fbf86 100644 (file)
@@ -23,8 +23,8 @@ static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
        OF_DEV_AUXDATA("fsl,imx27-uart", MX27_UART2_BASE_ADDR, "imx21-uart.1", NULL),
        OF_DEV_AUXDATA("fsl,imx27-uart", MX27_UART3_BASE_ADDR, "imx21-uart.2", NULL),
        OF_DEV_AUXDATA("fsl,imx27-fec", MX27_FEC_BASE_ADDR, "imx27-fec.0", NULL),
-       OF_DEV_AUXDATA("fsl,imx27-i2c", MX27_I2C1_BASE_ADDR, "imx-i2c.0", NULL),
-       OF_DEV_AUXDATA("fsl,imx27-i2c", MX27_I2C2_BASE_ADDR, "imx-i2c.1", NULL),
+       OF_DEV_AUXDATA("fsl,imx27-i2c", MX27_I2C1_BASE_ADDR, "imx21-i2c.0", NULL),
+       OF_DEV_AUXDATA("fsl,imx27-i2c", MX27_I2C2_BASE_ADDR, "imx21-i2c.1", NULL),
        OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI1_BASE_ADDR, "imx27-cspi.0", NULL),
        OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI2_BASE_ADDR, "imx27-cspi.1", NULL),
        OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI3_BASE_ADDR, "imx27-cspi.2", NULL),
index e105f12..a0391a1 100644 (file)
@@ -37,8 +37,8 @@ static const struct of_dev_auxdata imx51_auxdata_lookup[] __initconst = {
        OF_DEV_AUXDATA("fsl,imx51-ecspi", MX51_ECSPI1_BASE_ADDR, "imx51-ecspi.0", NULL),
        OF_DEV_AUXDATA("fsl,imx51-ecspi", MX51_ECSPI2_BASE_ADDR, "imx51-ecspi.1", NULL),
        OF_DEV_AUXDATA("fsl,imx51-cspi", MX51_CSPI_BASE_ADDR, "imx35-cspi.0", NULL),
-       OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C1_BASE_ADDR, "imx-i2c.0", NULL),
-       OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C2_BASE_ADDR, "imx-i2c.1", NULL),
+       OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C1_BASE_ADDR, "imx21-i2c.0", NULL),
+       OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C2_BASE_ADDR, "imx21-i2c.1", NULL),
        OF_DEV_AUXDATA("fsl,imx51-sdma", MX51_SDMA_BASE_ADDR, "imx35-sdma", NULL),
        OF_DEV_AUXDATA("fsl,imx51-wdt", MX51_WDOG1_BASE_ADDR, "imx2-wdt.0", NULL),
        { /* sentinel */ }
index aaa90a7..0e0aadf 100644 (file)
@@ -43,9 +43,9 @@ static const struct of_dev_auxdata imx53_auxdata_lookup[] __initconst = {
        OF_DEV_AUXDATA("fsl,imx53-ecspi", MX53_ECSPI1_BASE_ADDR, "imx51-ecspi.0", NULL),
        OF_DEV_AUXDATA("fsl,imx53-ecspi", MX53_ECSPI2_BASE_ADDR, "imx51-ecspi.1", NULL),
        OF_DEV_AUXDATA("fsl,imx53-cspi", MX53_CSPI_BASE_ADDR, "imx35-cspi.0", NULL),
-       OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C1_BASE_ADDR, "imx-i2c.0", NULL),
-       OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C2_BASE_ADDR, "imx-i2c.1", NULL),
-       OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C3_BASE_ADDR, "imx-i2c.2", NULL),
+       OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C1_BASE_ADDR, "imx21-i2c.0", NULL),
+       OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C2_BASE_ADDR, "imx21-i2c.1", NULL),
+       OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C3_BASE_ADDR, "imx21-i2c.2", NULL),
        OF_DEV_AUXDATA("fsl,imx53-sdma", MX53_SDMA_BASE_ADDR, "imx35-sdma", NULL),
        OF_DEV_AUXDATA("fsl,imx53-wdt", MX53_WDOG1_BASE_ADDR, "imx2-wdt.0", NULL),
        { /* sentinel */ }
index 2ef162d..b973474 100644 (file)
@@ -52,8 +52,6 @@
 #include <linux/of_device.h>
 #include <linux/of_i2c.h>
 #include <linux/pinctrl/consumer.h>
-
-#include <mach/hardware.h>
 #include <linux/platform_data/i2c-imx.h>
 
 /** Defines ********************************************************************
@@ -115,6 +113,11 @@ static u16 __initdata i2c_clk_div[50][2] = {
        { 3072, 0x1E }, { 3840, 0x1F }
 };
 
+enum imx_i2c_type {
+       IMX1_I2C,
+       IMX21_I2C,
+};
+
 struct imx_i2c_struct {
        struct i2c_adapter      adapter;
        struct clk              *clk;
@@ -124,13 +127,33 @@ struct imx_i2c_struct {
        unsigned int            disable_delay;
        int                     stopped;
        unsigned int            ifdr; /* IMX_I2C_IFDR */
+       enum imx_i2c_type       devtype;
+};
+
+static struct platform_device_id imx_i2c_devtype[] = {
+       {
+               .name = "imx1-i2c",
+               .driver_data = IMX1_I2C,
+       }, {
+               .name = "imx21-i2c",
+               .driver_data = IMX21_I2C,
+       }, {
+               /* sentinel */
+       }
 };
+MODULE_DEVICE_TABLE(platform, imx_i2c_devtype);
 
 static const struct of_device_id i2c_imx_dt_ids[] = {
-       { .compatible = "fsl,imx1-i2c", },
+       { .compatible = "fsl,imx1-i2c", .data = &imx_i2c_devtype[IMX1_I2C], },
+       { .compatible = "fsl,imx21-i2c", .data = &imx_i2c_devtype[IMX21_I2C], },
        { /* sentinel */ }
 };
 
+static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx)
+{
+       return i2c_imx->devtype == IMX1_I2C;
+}
+
 /** Functions for IMX I2C adapter driver ***************************************
 *******************************************************************************/
 
@@ -223,7 +246,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
                temp &= ~(I2CR_MSTA | I2CR_MTX);
                writeb(temp, i2c_imx->base + IMX_I2C_I2CR);
        }
-       if (cpu_is_mx1()) {
+       if (is_imx1_i2c(i2c_imx)) {
                /*
                 * This delay caused by an i.MXL hardware bug.
                 * If no (or too short) delay, no "STOP" bit will be generated.
@@ -465,6 +488,8 @@ static struct i2c_algorithm i2c_imx_algo = {
 
 static int __init i2c_imx_probe(struct platform_device *pdev)
 {
+       const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
+                                                          &pdev->dev);
        struct imx_i2c_struct *i2c_imx;
        struct resource *res;
        struct imxi2c_platform_data *pdata = pdev->dev.platform_data;
@@ -497,6 +522,10 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       if (of_id)
+               pdev->id_entry = of_id->data;
+       i2c_imx->devtype = pdev->id_entry->driver_data;
+
        /* Setup i2c_imx driver structure */
        strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name));
        i2c_imx->adapter.owner          = THIS_MODULE;
@@ -593,7 +622,8 @@ static struct platform_driver i2c_imx_driver = {
                .name   = DRIVER_NAME,
                .owner  = THIS_MODULE,
                .of_match_table = i2c_imx_dt_ids,
-       }
+       },
+       .id_table       = imx_i2c_devtype,
 };
 
 static int __init i2c_adap_imx_init(void)