Skip to contentSkip to conversation

mach-mxs: dynamic device creation for i.MX28-i2c

PATCH New Wolfram Sang 3 participants 5 messages Feb 18, 2011 – Feb 22, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mach-mxs: dynamic device creation for i.MX28-i2c

Currently for mx28 only, because the driver submitted for mainline does only PIOQUEUE which is only available on that cpu. mx23 can be added if support is available.

Patches are based on imx-for-2.6.39.

Wolfram Sang (2):
arm: mx23: names of interrupts and base address should match for I2C
arm: mxs: add i2c-devices

 arch/arm/mach-mxs/devices-mx28.h                |    3 +
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-i2c.c        |   56 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 ++++
 arch/arm/mach-mxs/include/mach/mx23.h           |    2 +-
 6 files changed, 73 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-i2c.c
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/2 arm: mx23: names of interrupts and base address should match for I2C

---
 arch/arm/mach-mxs/include/mach/mx23.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-mxs/include/mach/mx23.h +1 -1
index 4768402..9b610b1 100644
@@ -57,7 +57,7 @@
 #define MX23_AUDIOIN_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x04c000)
 #define MX23_LRADC_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x050000)
 #define MX23_SPDIF_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x054000)
-#define MX23_I2C0_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x058000)
+#define MX23_I2C_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x058000)
 #define MX23_RTC_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x05c000)
 #define MX23_PWM_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x064000)
 #define MX23_TIMROT_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x068000)
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 2/2 arm: mxs: add i2c-devices

In reply to Wolfram Sang
---
 arch/arm/mach-mxs/devices-mx28.h                |    3 +
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-i2c.c        |   56 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 ++++
 5 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-i2c.c
arch/arm/mach-mxs/devices-mx28.h +3 -0
index 3b18304..c581b26 100644
@@ -32,3 +32,6 @@ extern const struct mxs_flexcan_data mx28_flexcan_data[] __initconst;
 	mxs_add_flexcan(&mx28_flexcan_data[id], pdata)
 #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_i2c_data[] __initconst;
+#define mx28_add_i2c(id)	mxs_add_i2c(&mx28_i2c_data[id])
arch/arm/mach-mxs/devices/Kconfig +3 -0
index 6c65b67..c9f80e1 100644
@@ -11,3 +11,6 @@ config MXS_HAVE_PLATFORM_FEC
 config MXS_HAVE_PLATFORM_FLEXCAN
 	select HAVE_CAN_FLEXCAN if CAN
 	bool
+
+config MXS_HAVE_PLATFORM_I2C
+	bool
arch/arm/mach-mxs/devices/Makefile +1 -0
index a8dc8d5..4fb4d9a 100644
@@ -2,3 +2,4 @@ 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_I2C) += platform-i2c.o
arch/arm/mach-mxs/devices/platform-i2c.c new file +56 -0

56 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/devices-common.h +9 -0
index e7aefb4..e385ece 100644
@@ -63,3 +63,12 @@ struct mxs_flexcan_data {
 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_i2c(const struct mxs_i2c_data *data);
Signature · 1 line
1.7.2.3
#3 lore raw

PATCH 2/2 arm: mxs: add i2c-devices

Hello Wolfram,

Quoted 16 lines · Wolfram Sang
---
 arch/arm/mach-mxs/devices-mx28.h                |    3 +
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-i2c.c        |   56 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 ++++
 5 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-i2c.c
arch/arm/mach-mxs/devices-mx28.h +0 -0
index 3b18304..c581b26 100644

arch/arm/mach-mxs/devices-mx28.h extern const struct mxs_flexcan_data mx28_flexcan_data[] __initconst; · line 37

Quoted 6 lines
arch/arm/mach-mxs/devices-mx28.h +3 -0
@@ -32,3 +32,6 @@ extern const struct mxs_flexcan_data mx28_flexcan_data[] __initconst;
 	mxs_add_flexcan(&mx28_flexcan_data[id], pdata)
 #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_i2c_data[] __initconst;
+#define mx28_add_i2c(id)	mxs_add_i2c(&mx28_i2c_data[id])

I'd like to have these named "mx28_mxs_i2c_data" to have the driver name in the struct. (And by the way I already fixed that for you even before you sent out that patch :-)

Quoted 16 lines
arch/arm/mach-mxs/devices/Kconfig +3 -0
index 6c65b67..c9f80e1 100644
@@ -11,3 +11,6 @@ config MXS_HAVE_PLATFORM_FEC
 config MXS_HAVE_PLATFORM_FLEXCAN
 	select HAVE_CAN_FLEXCAN if CAN
 	bool
+
+config MXS_HAVE_PLATFORM_I2C
+	bool
arch/arm/mach-mxs/devices/Makefile +0 -0
index a8dc8d5..4fb4d9a 100644

arch/arm/mach-mxs/devices/Makefile obj-$(CONFIG_MXS_HAVE_AMBA_DUART) += amba-duart.o · line 5

Quoted 4 lines
arch/arm/mach-mxs/devices/Makefile +1 -0
@@ -2,3 +2,4 @@ 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_I2C) += platform-i2c.o

ditto

Quoted 12 lines
arch/arm/mach-mxs/devices/platform-i2c.c new file +6 -0
new file mode 100644
index 0000000..22236b2
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 Pengutronix
+ * Wolfram Sang <[email protected]>
+ *
+ * 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

arch/arm/mach-mxs/devices/platform-i2c.c line 16

Quoted 10 lines
arch/arm/mach-mxs/devices/platform-i2c.c new file +10 -0
+ * Free Software Foundation.
+ */
+#include <asm/sizes.h>
+#include <mach/mx28.h>
+#include <mach/devices-common.h>
+
+/* helper defines to fix MX23 naming anomaly */
+#define MX23_I2C0_BASE_ADDR	MX23_I2C_BASE_ADDR
+#define MX23_INT_I2C0_ERROR	MX23_INT_I2C_ERROR
+#define MX23_INT_I2C0_DMA	MX23_INT_I2C_DMA

not needed yet, but OK

arch/arm/mach-mxs/devices/platform-i2c.c line 27

Quoted 11 lines
arch/arm/mach-mxs/devices/platform-i2c.c new file +11 -0
+
+#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)

add here an addional mxs, too. (Thought I don't care that much here)

Quoted 46 lines
arch/arm/mach-mxs/devices/platform-i2c.c new file +29 -0
+
+#ifdef CONFIG_SOC_IMX28
+const struct mxs_i2c_data mx28_i2c_data[] __initconst = {
+	mxs_i2c_data_entry(MX28, 0),
+	mxs_i2c_data_entry(MX28, 1),
+};
+#endif
+
+struct platform_device *__init mxs_add_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);
+}
arch/arm/mach-mxs/include/mach/devices-common.h +9 -0
index e7aefb4..e385ece 100644
@@ -63,3 +63,12 @@ struct mxs_flexcan_data {
 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_i2c(const struct mxs_i2c_data *data);
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#4 lore raw

PATCH 2/2 arm: mxs: add i2c-devices

Quoted 16 lines · Uwe Kleine-K?nig
Quoted 16 lines
arch/arm/mach-mxs/devices/platform-i2c.c new file +9 -0
new file mode 100644
index 0000000..22236b2
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 Pengutronix
+ * Wolfram Sang <[email protected]>
+ *
+ * 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>
Quoted 9 lines

arch/arm/mach-mxs/devices/platform-i2c.c line 16

Quoted 7 lines
arch/arm/mach-mxs/devices/platform-i2c.c new file +7 -0
+#include <mach/mx28.h>
+#include <mach/devices-common.h>
+
+/* helper defines to fix MX23 naming anomaly */
+#define MX23_I2C0_BASE_ADDR	MX23_I2C_BASE_ADDR
+#define MX23_INT_I2C0_ERROR	MX23_INT_I2C_ERROR
+#define MX23_INT_I2C0_DMA	MX23_INT_I2C_DMA

not needed yet, but OK

It makes less sense to me to have these without including mx23.h.

Signature · 2 lines
Regards,
Shawn