ARM: imx: dynamically register imx-i2c devices (imx31)
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 16 Jun 2010 16:03:05 +0000 (18:03 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 30 Jun 2010 07:00:43 +0000 (09:00 +0200)
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
arch/arm/mach-mx3/Kconfig
arch/arm/mach-mx3/devices-imx31.h
arch/arm/mach-mx3/devices.c
arch/arm/mach-mx3/devices.h
arch/arm/mach-mx3/mach-armadillo5x0.c
arch/arm/mach-mx3/mach-mx31ads.c
arch/arm/mach-mx3/mach-mx31moboard.c
arch/arm/mach-mx3/mach-pcm037.c
arch/arm/plat-mxc/include/mach/mx31.h

index 5611b2376f1cad2240b4e84771d7f7660c91c3e1..557a20b48830db2b738bfff00a52842cf190fea9 100644 (file)
@@ -15,6 +15,7 @@ comment "MX3 platforms:"
 config MACH_MX31ADS
        bool "Support MX31ADS platforms"
        select ARCH_MX31
+       select IMX_HAVE_PLATFORM_IMX_I2C
        default y
        help
          Include support for MX31ADS platform. This includes specific
@@ -34,6 +35,7 @@ config MACH_MX31ADS_WM1133_EV1
 config MACH_PCM037
        bool "Support Phytec pcm037 (i.MX31) platforms"
        select ARCH_MX31
+       select IMX_HAVE_PLATFORM_IMX_I2C
        select IMX_HAVE_PLATFORM_MXC_NAND
        select MXC_ULPI if USB_ULPI
        help
@@ -77,6 +79,7 @@ config MACH_MX31_3DS_MXC_NAND_USE_BBT
 config MACH_MX31MOBOARD
        bool "Support mx31moboard platforms (EPFL Mobots group)"
        select ARCH_MX31
+       select IMX_HAVE_PLATFORM_IMX_I2C
        select MXC_ULPI if USB_ULPI
        help
          Include support for mx31moboard platform. This includes specific
@@ -109,6 +112,7 @@ config MACH_PCM043
 config MACH_ARMADILLO5X0
        bool "Support Atmark Armadillo-500 Development Base Board"
        select ARCH_MX31
+       select IMX_HAVE_PLATFORM_IMX_I2C
        select IMX_HAVE_PLATFORM_MXC_NAND
        select MXC_ULPI if USB_ULPI
        help
index 8bd8b3808cae31987f27e9e6329746ba849baa86..56bc1e1ca8d6ef72d39b0933a6e30721915bf8f7 100644 (file)
@@ -9,5 +9,12 @@
 #include <mach/mx31.h>
 #include <mach/devices-common.h>
 
+#define imx31_add_imx_i2c0(pdata)      \
+       imx_add_imx_i2c(0, MX31_I2C1_BASE_ADDR, SZ_4K, MX31_INT_I2C1, pdata)
+#define imx31_add_imx_i2c1(pdata)      \
+       imx_add_imx_i2c(1, MX31_I2C2_BASE_ADDR, SZ_4K, MX31_INT_I2C2, pdata)
+#define imx31_add_imx_i2c2(pdata)      \
+       imx_add_imx_i2c(2, MX31_I2C3_BASE_ADDR, SZ_4K, MX31_INT_I2C3, pdata)
+
 #define imx31_add_mxc_nand(pdata)      \
        imx_add_mxc_nand_v1(MX31_NFC_BASE_ADDR, MX31_INT_NANDFC, pdata)
index c8db84942bff320483b9a75a1d3294b323849381..0743214127a99ade57eecb9e9050b915e3810728 100644 (file)
@@ -167,6 +167,7 @@ struct platform_device mxc_w1_master_device = {
        .resource = mxc_w1_master_resources,
 };
 
+#if defined(CONFIG_ARCH_MX35)
 static struct resource mxc_i2c0_resources[] = {
        {
                .start = I2C_BASE_ADDR,
@@ -223,6 +224,7 @@ struct platform_device mxc_i2c_device2 = {
        .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
        .resource = mxc_i2c2_resources,
 };
+#endif
 
 #ifdef CONFIG_ARCH_MX31
 static struct resource mxcsdhc0_resources[] = {
index 4a224e6dc5ee0ddf363a0a42aa847dc1efb2d687..e108fa3f5d7e44efb3b87012176352cdb1cb148c 100644 (file)
@@ -5,9 +5,11 @@ extern struct platform_device mxc_uart_device2;
 extern struct platform_device mxc_uart_device3;
 extern struct platform_device mxc_uart_device4;
 extern struct platform_device mxc_w1_master_device;
+#if defined(CONFIG_ARCH_MX35)
 extern struct platform_device mxc_i2c_device0;
 extern struct platform_device mxc_i2c_device1;
 extern struct platform_device mxc_i2c_device2;
+#endif
 extern struct platform_device mx3_ipu;
 extern struct platform_device mx3_fb;
 extern struct platform_device mx3_camera;
index 633107a69acd226407028edd782139ea3ecc0a8f..423ffe774eadc9debf2f34bdcbbdc1edb07738fa 100644 (file)
@@ -499,7 +499,6 @@ static struct imxuart_platform_data uart_pdata = {
 
 static struct platform_device *devices[] __initdata = {
        &armadillo5x0_smc911x_device,
-       &mxc_i2c_device1,
        &armadillo5x0_button_device,
 };
 
@@ -512,6 +511,7 @@ static void __init armadillo5x0_init(void)
                        ARRAY_SIZE(armadillo5x0_pins), "armadillo5x0");
 
        platform_add_devices(devices, ARRAY_SIZE(devices));
+       imx31_add_imx_i2c1(NULL);
 
        /* Register UART */
        mxc_register_device(&mxc_uart_device0, &uart_pdata);
index a68b86826e8a810931ceca9e87392f5675310890..b6dc6c848b51566bb6480ef38f23ce4e14d148a3 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/mfd/wm8350/pmic.h>
 #endif
 
+#include "devices-imx31.h"
 #include "devices.h"
 
 /* Base address of PBC controller */
@@ -500,7 +501,7 @@ static void mxc_init_i2c(void)
        mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_ALT1));
        mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_ALT1));
 
-       mxc_register_device(&mxc_i2c_device1, NULL);
+       imx31_add_imx_i2c1(NULL);
 }
 #else
 static void mxc_init_i2c(void)
index 545cfdd7e4e975843c0a1a6faba1f11c21a5f393..dd51d08f25947b55acfe5926a3569a909e6d3e65 100644 (file)
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx3.h>
 #include <mach/ipu.h>
-#include <mach/i2c.h>
 #include <mach/mmc.h>
 #include <mach/mxc_ehci.h>
 #include <mach/mx3_camera.h>
 #include <mach/spi.h>
 #include <mach/ulpi.h>
 
+#include "devices-imx31.h"
 #include "devices.h"
 
 static unsigned int moboard_pins[] = {
@@ -139,11 +139,11 @@ static struct imxuart_platform_data uart4_pdata = {
        .flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct imxi2c_platform_data moboard_i2c0_pdata = {
+static const struct imxi2c_platform_data moboard_i2c0_data __initconst = {
        .bitrate = 400000,
 };
 
-static struct imxi2c_platform_data moboard_i2c1_pdata = {
+static const struct imxi2c_platform_data moboard_i2c1_data __initconst = {
        .bitrate = 100000,
 };
 
@@ -499,8 +499,8 @@ static void __init mxc_board_init(void)
 
        mxc_register_device(&mxc_uart_device4, &uart4_pdata);
 
-       mxc_register_device(&mxc_i2c_device0, &moboard_i2c0_pdata);
-       mxc_register_device(&mxc_i2c_device1, &moboard_i2c1_pdata);
+       imx31_add_imx_i2c0(&moboard_i2c0_data);
+       imx31_add_imx_i2c1(&moboard_i2c1_data);
 
        mxc_register_device(&mxc_spi_device1, &moboard_spi1_master);
        mxc_register_device(&mxc_spi_device2, &moboard_spi2_master);
index d7fef469990a92d3d9c543ab994fa3eaea2970a5..7e3fc470d55d884ffbfb607f462c7e908b1b3f49 100644 (file)
@@ -41,7 +41,6 @@
 #include <asm/mach/map.h>
 #include <mach/common.h>
 #include <mach/hardware.h>
-#include <mach/i2c.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx3.h>
 #include <mach/ipu.h>
@@ -280,11 +279,11 @@ pcm037_nand_board_info __initconst = {
        .hw_ecc = 1,
 };
 
-static struct imxi2c_platform_data pcm037_i2c_1_data = {
+static const struct imxi2c_platform_data pcm037_i2c1_data __initconst = {
        .bitrate = 100000,
 };
 
-static struct imxi2c_platform_data pcm037_i2c_2_data = {
+static const struct imxi2c_platform_data pcm037_i2c2_data __initconst = {
        .bitrate = 20000,
 };
 
@@ -630,8 +629,8 @@ static void __init mxc_board_init(void)
        i2c_register_board_info(1, pcm037_i2c_devices,
                        ARRAY_SIZE(pcm037_i2c_devices));
 
-       mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data);
-       mxc_register_device(&mxc_i2c_device2, &pcm037_i2c_2_data);
+       imx31_add_imx_i2c1(&pcm037_i2c1_data);
+       imx31_add_imx_i2c2(&pcm037_i2c2_data);
 
        imx31_add_mxc_nand(&pcm037_nand_board_info);
        mxc_register_device(&mxcsdhc_device0, &sdhc_pdata);
index fb90e119c2b5db473a3d4e01ef48dd6a76921493..afee3ab9d62e2aef32a366f21c82350a562dab22 100644 (file)
@@ -23,7 +23,7 @@
 #define MX31_ETB_SLOT4_BASE_ADDR               (MX31_AIPS1_BASE_ADDR + 0x10000)
 #define MX31_ETB_SLOT5_BASE_ADDR               (MX31_AIPS1_BASE_ADDR + 0x14000)
 #define MX31_ECT_CTIO_BASE_ADDR                        (MX31_AIPS1_BASE_ADDR + 0x18000)
-#define MX31_I2C_BASE_ADDR                     (MX31_AIPS1_BASE_ADDR + 0x80000)
+#define MX31_I2C1_BASE_ADDR                    (MX31_AIPS1_BASE_ADDR + 0x80000)
 #define MX31_I2C3_BASE_ADDR                    (MX31_AIPS1_BASE_ADDR + 0x84000)
 #define MX31_OTG_BASE_ADDR                     (MX31_AIPS1_BASE_ADDR + 0x88000)
 #define MX31_ATA_BASE_ADDR                     (MX31_AIPS1_BASE_ADDR + 0x8c000)
@@ -145,7 +145,7 @@ static inline void mx31_setup_weimcs(size_t cs,
 #define MX31_INT_FIRI          7
 #define MX31_INT_MMC_SDHC2     8
 #define MX31_INT_MMC_SDHC1     9
-#define MX31_INT_I2C           10
+#define MX31_INT_I2C1          10
 #define MX31_INT_SSI2          11
 #define MX31_INT_SSI1          12
 #define MX31_INT_CSPI2         13