arm: mxs: add i2c-devices for mx28
authorWolfram Sang <w.sang@pengutronix.de>
Mon, 28 Feb 2011 16:40:04 +0000 (17:40 +0100)
committerSascha Hauer <s.hauer@pengutronix.de>
Mon, 7 Mar 2011 18:29:17 +0000 (19:29 +0100)
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
arch/arm/mach-mxs/devices-mx28.h
arch/arm/mach-mxs/devices/Kconfig
arch/arm/mach-mxs/devices/Makefile
arch/arm/mach-mxs/devices/platform-mxs-i2c.c [new file with mode: 0644]
arch/arm/mach-mxs/include/mach/devices-common.h

index 69d19ea19d4d9909e687393cb29650d6c2b28644..a9eecdc7e22796ad95dc2f91403fe35bb18af95c 100644 (file)
@@ -33,4 +33,7 @@ extern const struct mxs_flexcan_data mx28_flexcan_data[] __initconst;
 #define mx28_add_flexcan0(pdata)       mx28_add_flexcan(0, pdata)
 #define mx28_add_flexcan1(pdata)       mx28_add_flexcan(1, pdata)
 
+extern const struct mxs_i2c_data mx28_mxs_i2c_data[] __initconst;
+#define mx28_add_mxs_i2c(id)           mxs_add_mxs_i2c(&mx28_mxs_i2c_data[id])
+
 #define mx28_add_mxs_pwm(id)           mxs_add_mxs_pwm(MX28_PWM_BASE_ADDR, id)
index 3aeec246e746755b92ce9aa2df69c81f014d70ed..a878915063edc9d0fa722ca20a93e9e2b0f0e938 100644 (file)
@@ -12,5 +12,8 @@ config MXS_HAVE_PLATFORM_FLEXCAN
        select HAVE_CAN_FLEXCAN if CAN
        bool
 
+config MXS_HAVE_PLATFORM_MXS_I2C
+       bool
+
 config MXS_HAVE_PLATFORM_MXS_PWM
        bool
index 978310fcafd6c61598dc6460c04120e3d53d3663..345b8399b80ec831161ea98a7671c280385c8a53 100644 (file)
@@ -2,4 +2,5 @@ obj-$(CONFIG_MXS_HAVE_AMBA_DUART) += amba-duart.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_AUART) += platform-auart.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
+obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_I2C) += platform-mxs-i2c.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_PWM) += platform-mxs-pwm.o
diff --git a/arch/arm/mach-mxs/devices/platform-mxs-i2c.c b/arch/arm/mach-mxs/devices/platform-mxs-i2c.c
new file mode 100644 (file)
index 0000000..eab3a06
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Pengutronix
+ * Wolfram Sang <w.sang@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <asm/sizes.h>
+#include <mach/mx28.h>
+#include <mach/devices-common.h>
+
+#define mxs_i2c_data_entry_single(soc, _id)                            \
+       {                                                               \
+               .id = _id,                                              \
+               .iobase = soc ## _I2C ## _id ## _BASE_ADDR,             \
+               .errirq = soc ## _INT_I2C ## _id ## _ERROR,             \
+               .dmairq = soc ## _INT_I2C ## _id ## _DMA,               \
+       }
+
+#define mxs_i2c_data_entry(soc, _id)                                   \
+       [_id] = mxs_i2c_data_entry_single(soc, _id)
+
+#ifdef CONFIG_SOC_IMX28
+const struct mxs_i2c_data mx28_mxs_i2c_data[] __initconst = {
+       mxs_i2c_data_entry(MX28, 0),
+       mxs_i2c_data_entry(MX28, 1),
+};
+#endif
+
+struct platform_device *__init mxs_add_mxs_i2c(const struct mxs_i2c_data *data)
+{
+       struct resource res[] = {
+               {
+                       .start = data->iobase,
+                       .end = data->iobase + SZ_8K - 1,
+                       .flags = IORESOURCE_MEM,
+               }, {
+                       .start = data->errirq,
+                       .end = data->errirq,
+                       .flags = IORESOURCE_IRQ,
+               }, {
+                       .start = data->dmairq,
+                       .end = data->dmairq,
+                       .flags = IORESOURCE_IRQ,
+               },
+       };
+
+       return mxs_add_platform_device("mxs-i2c", data->id, res,
+                                       ARRAY_SIZE(res), NULL, 0);
+}
index d460d304555537b1541488e881192c502f29f2e5..71f24484b044213e31b1c04664739e3df0c2c0b4 100644 (file)
@@ -64,6 +64,15 @@ struct platform_device *__init mxs_add_flexcan(
                const struct mxs_flexcan_data *data,
                const struct flexcan_platform_data *pdata);
 
+/* i2c */
+struct mxs_i2c_data {
+       int id;
+       resource_size_t iobase;
+       resource_size_t errirq;
+       resource_size_t dmairq;
+};
+struct platform_device * __init mxs_add_mxs_i2c(const struct mxs_i2c_data *data);
+
 /* pwm */
 struct platform_device *__init mxs_add_mxs_pwm(
                resource_size_t iobase, int id);