public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC 0/3 rev 3] I2C bus registration helper
@ 2007-11-07 10:54 Jarkko Nikula
  2007-11-07 10:54 ` [PATCH 1/3] ARM: OMAP: Add helper module for board specific I2C bus registration Jarkko Nikula
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jarkko Nikula @ 2007-11-07 10:54 UTC (permalink / raw)
  To: linux-omap-open-source

Third version of I2C bus registration helper. Now omap_i2c_mux_pins
is supposed to stay here for doing pin muxing for I2C as suggested by David

http://linux.omap.com/pipermail/linux-omap-open-source/2007-November/011906.html

Patch 2 differs only in board-h4.c where omap_cfg_reg calls are removed.
Patch 3 is the same than previously.

-- 
Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] ARM: OMAP: Add helper module for board specific I2C bus registration
  2007-11-07 10:54 [PATCH/RFC 0/3 rev 3] I2C bus registration helper Jarkko Nikula
@ 2007-11-07 10:54 ` Jarkko Nikula
  2007-11-07 10:54 ` [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper Jarkko Nikula
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Jarkko Nikula @ 2007-11-07 10:54 UTC (permalink / raw)
  To: linux-omap-open-source

This helper module simplifies I2C bus registration for different OMAP
platforms by doing registration in one place only and to allow board
specific bus configuration like clock rate and number of busses configured.

Helper should cover OMAP processors from first to third generation.

This patch just adds the feature and current implementation cleanup and
board file modifications will be done in following patches.

Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
---
 arch/arm/plat-omap/Makefile        |    1 +
 arch/arm/plat-omap/i2c.c           |  148 ++++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-omap/common.h |    7 ++
 3 files changed, 156 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/i2c.c

diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 282ea00..9d97ae5 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_OMAP_COMPONENT_VERSION) += component-version.o
 obj-$(CONFIG_OMAP_GPIO_SWITCH) += gpio-switch.o
 obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
 obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
+obj-$(CONFIG_I2C_OMAP) += i2c.o
 
 # OMAP MMU framework
 obj-$(CONFIG_OMAP_MMU_FWK) += mmu.o
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
new file mode 100644
index 0000000..b771a5d
--- /dev/null
+++ b/arch/arm/plat-omap/i2c.c
@@ -0,0 +1,148 @@
+/*
+ * linux/arch/arm/plat-omap/i2c.c
+ *
+ * Helper module for board specific I2C bus registration
+ *
+ * Copyright (C) 2007 Nokia Corporation.
+ *
+ * Contact: Jarkko Nikula <jarkko.nikula@nokia.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <asm/mach-types.h>
+#include <asm/arch/mux.h>
+
+#define OMAP_I2C_SIZE		0x3f
+#define OMAP1_I2C_BASE		0xfffb3800
+#define OMAP2_I2C_BASE1		0x48070000
+#define OMAP2_I2C_BASE2		0x48072000
+#define OMAP2_I2C_BASE3		0x48060000
+
+static const char name[] = "i2c_omap";
+
+#define I2C_RESOURCE_BUILDER(base, irq)			\
+	{						\
+		.start	= (base),			\
+		.end	= (base) + OMAP_I2C_SIZE,	\
+		.flags	= IORESOURCE_MEM,		\
+	},						\
+	{						\
+		.start	= (irq),			\
+		.flags	= IORESOURCE_IRQ,		\
+	},
+
+static struct resource i2c_resources[][2] = {
+	{ I2C_RESOURCE_BUILDER(0, 0) },
+#if	defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
+	{ I2C_RESOURCE_BUILDER(OMAP2_I2C_BASE2, INT_24XX_I2C2_IRQ) },
+#endif
+#if	defined(CONFIG_ARCH_OMAP34XX)
+	{ I2C_RESOURCE_BUILDER(OMAP2_I2C_BASE3, INT_34XX_I2C3_IRQ) },
+#endif
+};
+
+#define I2C_DEV_BUILDER(bus_id, res, data)		\
+	{						\
+		.id	= (bus_id),			\
+		.name	= name,				\
+		.num_resources	= ARRAY_SIZE(res),	\
+		.resource	= (res),		\
+		.dev		= {			\
+			.platform_data	= (data),	\
+		},					\
+	}
+
+static u32 i2c_rate[ARRAY_SIZE(i2c_resources)];
+static struct platform_device omap_i2c_devices[] = {
+	I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_rate[0]),
+#if	defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
+	I2C_DEV_BUILDER(2, i2c_resources[1], &i2c_rate[1]),
+#endif
+#if	defined(CONFIG_ARCH_OMAP34XX)
+	I2C_DEV_BUILDER(3, i2c_resources[2], &i2c_rate[2]),
+#endif
+};
+
+static void omap_i2c_mux_pins(int bus_id)
+{
+	/* TODO: Muxing for OMAP3 */
+	switch (bus_id) {
+	case 1:
+		if (cpu_class_is_omap1()) {
+			omap_cfg_reg(I2C_SCL);
+			omap_cfg_reg(I2C_SDA);
+		} else if (cpu_class_is_omap2()) {
+			omap_cfg_reg(M19_24XX_I2C1_SCL);
+			omap_cfg_reg(L15_24XX_I2C1_SDA);
+		}
+		break;
+	case 2:
+		if (cpu_is_omap24xx()) {
+			omap_cfg_reg(J15_24XX_I2C2_SCL);
+			omap_cfg_reg(H19_24XX_I2C2_SDA);
+		}
+		break;
+	}
+}
+
+int omap_register_i2c_bus(int bus_id, u32 clkrate,
+			  struct i2c_board_info const *info,
+			  unsigned len)
+{
+	int ports, err;
+	struct platform_device *pdev;
+	struct resource *res;
+	resource_size_t base, irq;
+
+	if (cpu_class_is_omap1())
+		ports = 1;
+	else if (cpu_is_omap24xx())
+		ports = 2;
+	else if (cpu_is_omap34xx())
+		ports = 3;
+
+	BUG_ON(bus_id < 1 || bus_id > ports);
+
+	if (info) {
+		err = i2c_register_board_info(bus_id, info, len);
+		if (err)
+			return err;
+	}
+
+	pdev = &omap_i2c_devices[bus_id - 1];
+	*(u32 *)pdev->dev.platform_data = clkrate;
+
+	if (bus_id == 1) {
+		res = pdev->resource;
+		if (cpu_class_is_omap1()) {
+			base = OMAP1_I2C_BASE;
+			irq = INT_I2C;
+		} else {
+			base = OMAP2_I2C_BASE1;
+			irq = INT_24XX_I2C1_IRQ;
+		}
+		res[0].start = base;
+		res[0].end = base + OMAP_I2C_SIZE;
+		res[1].start = irq;
+	}
+
+	omap_i2c_mux_pins(bus_id);
+	return platform_device_register(pdev);
+}
diff --git a/include/asm-arm/arch-omap/common.h b/include/asm-arm/arch-omap/common.h
index 08d58ab..089ddc7 100644
--- a/include/asm-arm/arch-omap/common.h
+++ b/include/asm-arm/arch-omap/common.h
@@ -27,10 +27,17 @@
 #ifndef __ARCH_ARM_MACH_OMAP_COMMON_H
 #define __ARCH_ARM_MACH_OMAP_COMMON_H
 
+#ifdef CONFIG_I2C_OMAP
+#include <linux/i2c.h>
+#endif
+
 struct sys_timer;
 
 extern void omap_map_common_io(void);
 extern struct sys_timer omap_timer;
 extern void omap_serial_init(void);
+extern int omap_register_i2c_bus(int bus_id, u32 clkrate,
+				 struct i2c_board_info const *info,
+				 unsigned len);
 
 #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper
  2007-11-07 10:54 [PATCH/RFC 0/3 rev 3] I2C bus registration helper Jarkko Nikula
  2007-11-07 10:54 ` [PATCH 1/3] ARM: OMAP: Add helper module for board specific I2C bus registration Jarkko Nikula
@ 2007-11-07 10:54 ` Jarkko Nikula
  2007-11-08 12:42   ` Nishanth Menon
  2007-11-07 10:54 ` [PATCH 3/3] ARM: OMAP: N800: " Jarkko Nikula
  2007-11-15 21:57 ` [PATCH/RFC 0/3 rev 3] " Tony Lindgren
  3 siblings, 1 reply; 7+ messages in thread
From: Jarkko Nikula @ 2007-11-07 10:54 UTC (permalink / raw)
  To: linux-omap-open-source

This patch starts using introduced I2C bus registration helper by cleaning
up registration currently done in various places and by doing necessary
board file modifications.

Patch modifies those board files that are merged upstream. Most of the
boards except osk and 2430sdp are configured to use 100 kHz I2C clock
until they are verified for higher clock.

Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
---
 arch/arm/mach-omap1/board-ams-delta.c |    1 +
 arch/arm/mach-omap1/board-fsample.c   |    1 +
 arch/arm/mach-omap1/board-generic.c   |    1 +
 arch/arm/mach-omap1/board-h2.c        |    1 +
 arch/arm/mach-omap1/board-h3.c        |    1 +
 arch/arm/mach-omap1/board-innovator.c |    1 +
 arch/arm/mach-omap1/board-nokia770.c  |    1 +
 arch/arm/mach-omap1/board-osk.c       |    5 +-
 arch/arm/mach-omap1/board-palmte.c    |    1 +
 arch/arm/mach-omap1/board-palmtt.c    |    1 +
 arch/arm/mach-omap1/board-palmz71.c   |    1 +
 arch/arm/mach-omap1/board-perseus2.c  |    1 +
 arch/arm/mach-omap1/board-sx1.c       |    1 +
 arch/arm/mach-omap1/board-voiceblue.c |    1 +
 arch/arm/mach-omap2/board-2430sdp.c   |   69 +------------------------------
 arch/arm/mach-omap2/board-apollon.c   |    2 +
 arch/arm/mach-omap2/board-generic.c   |    2 +
 arch/arm/mach-omap2/board-h4.c        |    5 +-
 arch/arm/mach-omap2/devices.c         |   52 -----------------------
 arch/arm/plat-omap/devices.c          |   73 ---------------------------------
 20 files changed, 23 insertions(+), 198 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index c73ca61..fc38f03 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -227,6 +227,7 @@ static void __init ams_delta_init(void)
 	omap_board_config = ams_delta_config;
 	omap_board_config_size = ARRAY_SIZE(ams_delta_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 
 	/* Clear latch2 (NAND, LCD, modem enable) */
 	ams_delta_latch2_write(~0, 0);
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index d5f6ea1..eaf9ef5 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -233,6 +233,7 @@ static void __init omap_fsample_init(void)
 	omap_board_config = fsample_config;
 	omap_board_config_size = ARRAY_SIZE(fsample_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init fsample_init_smc91x(void)
diff --git a/arch/arm/mach-omap1/board-generic.c b/arch/arm/mach-omap1/board-generic.c
index 4b35f16..54a430f 100644
--- a/arch/arm/mach-omap1/board-generic.c
+++ b/arch/arm/mach-omap1/board-generic.c
@@ -100,6 +100,7 @@ static void __init omap_generic_init(void)
 	omap_board_config = generic_config;
 	omap_board_config_size = ARRAY_SIZE(generic_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init omap_generic_map_io(void)
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index d2214ad..722c5a4 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -530,6 +530,7 @@ static void __init h2_init(void)
 	omap_board_config = h2_config;
 	omap_board_config_size = ARRAY_SIZE(h2_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init h2_map_io(void)
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index df77cf5..8960956 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -575,6 +575,7 @@ static void __init h3_init(void)
 	omap_board_config = h3_config;
 	omap_board_config_size = ARRAY_SIZE(h3_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init h3_init_smc91x(void)
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index 7e63a41..48c0c41 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -411,6 +411,7 @@ static void __init innovator_init(void)
 	omap_board_config = innovator_config;
 	omap_board_config_size = ARRAY_SIZE(innovator_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init innovator_map_io(void)
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index df5bda2..da0b90f 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -373,6 +373,7 @@ static void __init omap_nokia770_init(void)
 	omap_board_config_size = ARRAY_SIZE(nokia770_config);
 	omap_gpio_init();
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 	omap_dsp_init();
 	hwa742_dev_init();
 	ads7846_dev_init();
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 5fab8f4..7d2f21e 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -473,10 +473,9 @@ static void __init osk_init(void)
 	if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
 		gpio_direction_input(OMAP_MPUIO(1));
 
-	i2c_register_board_info(1, osk_i2c_board_info,
-			ARRAY_SIZE(osk_i2c_board_info));
-
 	omap_serial_init();
+	omap_register_i2c_bus(1, 400, osk_i2c_board_info,
+			      ARRAY_SIZE(osk_i2c_board_info));
 	osk_mistral_init();
 }
 
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index e5e0957..ccd83cf 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -416,6 +416,7 @@ static void __init omap_palmte_init(void)
 
 	palmte_misc_gpio_setup();
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init omap_palmte_map_io(void)
diff --git a/arch/arm/mach-omap1/board-palmtt.c b/arch/arm/mach-omap1/board-palmtt.c
index dd69e01..38c9ba9 100644
--- a/arch/arm/mach-omap1/board-palmtt.c
+++ b/arch/arm/mach-omap1/board-palmtt.c
@@ -339,6 +339,7 @@ static void __init omap_palmtt_init(void)
 
 	spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init omap_palmtt_map_io(void)
diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c
index 6b49c71..b2ed1cb 100644
--- a/arch/arm/mach-omap1/board-palmz71.c
+++ b/arch/arm/mach-omap1/board-palmz71.c
@@ -364,6 +364,7 @@ omap_palmz71_init(void)
 	spi_register_board_info(palmz71_boardinfo,
 				ARRAY_SIZE(palmz71_boardinfo));
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 	palmz71_gpio_setup(0);
 }
 
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index e9e352e..1b39b6b 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -233,6 +233,7 @@ static void __init omap_perseus2_init(void)
 	omap_board_config = perseus2_config;
 	omap_board_config_size = ARRAY_SIZE(perseus2_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 }
 
 static void __init perseus2_init_smc91x(void)
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index f25ec6f..389d3fa 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -439,6 +439,7 @@ static void __init omap_sx1_init(void)
 	omap_board_config = sx1_config;
 	omap_board_config_size = ARRAY_SIZE(sx1_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 
 	/* turn on USB power */
 	/* sx1_setusbpower(1); cant do it here because i2c is not ready */
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index 214dd19..04d9e8c 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -198,6 +198,7 @@ static void __init voiceblue_init(void)
 	omap_board_config = voiceblue_config;
 	omap_board_config_size = ARRAY_SIZE(voiceblue_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
 
 	/* There is a good chance board is going up, so enable power LED
 	 * (it is connected through invertor) */
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 9e6592c..a309948 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -354,75 +354,10 @@ static struct omap_board_config_kernel sdp2430_config[] __initdata = {
 	{OMAP_TAG_LCD, &sdp2430_lcd_config},
 };
 
-#if	defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
-
-#define OMAP2_I2C_BASE1		0x48070000
-#define OMAP2_I2C_BASE2		0x48072000
-#define OMAP2_I2C_INT1		56
-#define OMAP2_I2C_INT2		57
-
-static u32 omap2_i2c1_clkrate	= 400;
-static u32 omap2_i2c2_clkrate	= 2600;
-
-static struct resource i2c_resources1[] = {
-	{
-		.start	= OMAP2_I2C_BASE1,
-		.end	= OMAP2_I2C_BASE1 + 0x3f,
-		.flags	= IORESOURCE_MEM,
-	},
-	{
-		.start	= OMAP2_I2C_INT1,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct resource i2c_resources2[] = {
-	{
-		.start	= OMAP2_I2C_BASE2,
-		.end	= OMAP2_I2C_BASE2 + 0x3f,
-		.flags	= IORESOURCE_MEM,
-	},
-	{
-		.start	= OMAP2_I2C_INT2,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device omap_i2c_device1 = {
-	.name		= "i2c_omap",
-	.id		= 1,
-	.num_resources	= ARRAY_SIZE(i2c_resources1),
-	.resource	= i2c_resources1,
-	.dev		= {
-		.platform_data	= &omap2_i2c1_clkrate,
-	},
-};
-
-static struct platform_device omap_i2c_device2 = {
-	.name		= "i2c_omap",
-	.id		= 2,
-	.num_resources	= ARRAY_SIZE(i2c_resources2),
-	.resource	= i2c_resources2,
-	.dev		= {
-		.platform_data	= &omap2_i2c2_clkrate,
-	},
-};
-
-static void omap_init_i2c(void)
-{
-	(void) platform_device_register(&omap_i2c_device2);
-	(void) platform_device_register(&omap_i2c_device1);
-}
-
-#else
-
-static void omap_init_i2c(void) {}
-
-#endif
-
 static int __init omap2430_i2c_init(void)
 {
-	omap_init_i2c();
+	omap_register_i2c_bus(1, 400, NULL, 0);
+	omap_register_i2c_bus(2, 2600, NULL, 0);
 	return 0;
 }
 
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index ff8459c..1932d73 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -381,6 +381,8 @@ static void __init omap_apollon_init(void)
 	omap_board_config = apollon_config;
 	omap_board_config_size = ARRAY_SIZE(apollon_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
+	omap_register_i2c_bus(2, 100, NULL, 0);
 
 	spi_register_board_info(apollon_spi_board_info,
 				ARRAY_SIZE(apollon_spi_board_info));
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index d8da3c1..4226464 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -61,6 +61,8 @@ static void __init omap_generic_init(void)
 	omap_board_config = generic_config;
 	omap_board_config_size = ARRAY_SIZE(generic_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, NULL, 0);
+	omap_register_i2c_bus(2, 100, NULL, 0);
 }
 
 static void __init omap_generic_map_io(void)
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index fc30021..85649bb 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -701,13 +701,12 @@ static void __init omap_h4_init(void)
 	/* Menelaus interrupt */
 	omap_cfg_reg(W19_24XX_SYS_NIRQ);
 
-	i2c_register_board_info(1, h4_i2c_board_info,
-			ARRAY_SIZE(h4_i2c_board_info));
-
 	platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
 	omap_board_config = h4_config;
 	omap_board_config_size = ARRAY_SIZE(h4_config);
 	omap_serial_init();
+	omap_register_i2c_bus(1, 100, h4_i2c_board_info,
+			      ARRAY_SIZE(h4_i2c_board_info));
 
 	/* smc91x, debug leds, ps/2, extra uarts */
 	h4_init_debug();
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 376b49f..85bc01a 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -56,55 +56,6 @@ static inline void omap_init_camera(void)
 }
 #endif
 
-#if	!defined(CONFIG_ARCH_OMAP243X)
-#if	defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
-
-#define OMAP2_I2C_BASE2		0x48072000
-#define OMAP2_I2C_INT2		57
-
-static u32 omap2_i2c2_clkrate	= 100;
-static struct resource i2c_resources2[] = {
-	{
-		.start		= OMAP2_I2C_BASE2,
-		.end		= OMAP2_I2C_BASE2 + 0x3f,
-		.flags		= IORESOURCE_MEM,
-	},
-	{
-		.start		= OMAP2_I2C_INT2,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device omap_i2c_device2 = {
-	.name           = "i2c_omap",
-	.id             = 2,
-	.num_resources	= ARRAY_SIZE(i2c_resources2),
-	.resource	= i2c_resources2,
-	.dev		= {
-		.platform_data	= &omap2_i2c2_clkrate,
-	},
-};
-
-/* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
-static void omap_init_i2c(void)
-{
-	/* REVISIT: Second I2C not in use on H4? */
-	if (machine_is_omap_h4())
-		return;
-
-	omap_cfg_reg(J15_24XX_I2C2_SCL);
-	omap_cfg_reg(H19_24XX_I2C2_SDA);
-
-	(void) platform_device_register(&omap_i2c_device2);
-}
-
-#else
-
-static void omap_init_i2c(void) {}
-
-#endif
-#endif
-
 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
 #define OMAP2_MBOX_BASE		IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
 
@@ -278,9 +229,6 @@ static int __init omap2_init_devices(void)
 	 * in alphabetical order so they're easier to sort through.
 	 */
 	omap_init_camera();
-	if (!cpu_is_omap2430()) {
-		omap_init_i2c();
-	}
 	omap_init_mbox();
 	omap_init_mcspi();
 	omap_init_sti();
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index 6b795ab..b84e7f8 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -89,76 +89,6 @@ static inline void omap_init_dsp(void) { }
 #endif	/* CONFIG_OMAP_DSP */
 
 /*-------------------------------------------------------------------------*/
-#if	!defined(CONFIG_ARCH_OMAP243X)
-#if	defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
-
-#define	OMAP1_I2C_BASE		0xfffb3800
-#define OMAP2_I2C_BASE1		0x48070000
-#define OMAP_I2C_SIZE		0x3f
-#define OMAP1_I2C_INT		INT_I2C
-#define OMAP2_I2C_INT1		56
-
-static u32 omap2_i2c1_clkrate	= 100;
-
-static struct resource i2c_resources1[] = {
-	{
-		.start		= 0,
-		.end		= 0,
-		.flags		= IORESOURCE_MEM,
-	},
-	{
-		.start		= 0,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-/* DMA not used; works around erratum writing to non-empty i2c fifo */
-
-static struct platform_device omap_i2c_device1 = {
-	.name           = "i2c_omap",
-	.id             = 1,
-	.num_resources	= ARRAY_SIZE(i2c_resources1),
-	.resource	= i2c_resources1,
-	.dev		= {
-		.platform_data	= &omap2_i2c1_clkrate,
-	},
-};
-
-/* See also arch/arm/mach-omap2/devices.c for second I2C on 24xx */
-static void omap_init_i2c(void)
-{
-	if (cpu_is_omap242x()) {
-		i2c_resources1[0].start = OMAP2_I2C_BASE1;
-		i2c_resources1[0].end = OMAP2_I2C_BASE1 + OMAP_I2C_SIZE;
-		i2c_resources1[1].start = OMAP2_I2C_INT1;
-	} else {
-		i2c_resources1[0].start = OMAP1_I2C_BASE;
-		i2c_resources1[0].end = OMAP1_I2C_BASE + OMAP_I2C_SIZE;
-		i2c_resources1[1].start = OMAP1_I2C_INT;
-	}
-
-	/* FIXME define and use a boot tag, in case of boards that
-	 * either don't wire up I2C, or chips that mux it differently...
-	 * it can include clocking and address info, maybe more.
-	 */
-	if (cpu_class_is_omap2()) {
-		if (machine_is_omap_h4()) {
-			omap_cfg_reg(M19_24XX_I2C1_SCL);
-			omap_cfg_reg(L15_24XX_I2C1_SDA);
-		}
-	} else {
-		omap_cfg_reg(I2C_SCL);
-		omap_cfg_reg(I2C_SDA);
-	}
-
-	(void) platform_device_register(&omap_i2c_device1);
-}
-
-#else
-static inline void omap_init_i2c(void) {}
-#endif
-#endif
-/*-------------------------------------------------------------------------*/
 #if	defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
 
 static void omap_init_kp(void)
@@ -539,9 +469,6 @@ static int __init omap_init_devices(void)
 	omap_init_uwire();
 	omap_init_wdt();
 	omap_init_rng();
-	if (!cpu_is_omap2430() && !cpu_is_omap34xx()) {
-		omap_init_i2c();
-	}
 	return 0;
 }
 arch_initcall(omap_init_devices);
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ARM: OMAP: N800: Use I2C bus registration helper
  2007-11-07 10:54 [PATCH/RFC 0/3 rev 3] I2C bus registration helper Jarkko Nikula
  2007-11-07 10:54 ` [PATCH 1/3] ARM: OMAP: Add helper module for board specific I2C bus registration Jarkko Nikula
  2007-11-07 10:54 ` [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper Jarkko Nikula
@ 2007-11-07 10:54 ` Jarkko Nikula
  2007-11-15 21:57 ` [PATCH/RFC 0/3 rev 3] " Tony Lindgren
  3 siblings, 0 replies; 7+ messages in thread
From: Jarkko Nikula @ 2007-11-07 10:54 UTC (permalink / raw)
  To: linux-omap-open-source

Use 400 kHz bus clock for both busses since board components are rated
for it.

Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
---
 arch/arm/mach-omap2/board-n800.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-n800.c b/arch/arm/mach-omap2/board-n800.c
index 81c4a8d..a3e1c2b 100644
--- a/arch/arm/mach-omap2/board-n800.c
+++ b/arch/arm/mach-omap2/board-n800.c
@@ -464,12 +464,6 @@ static void __init nokia_n800_init(void)
 {
 	platform_add_devices(n800_devices, ARRAY_SIZE(n800_devices));
 
-	i2c_register_board_info(1, n800_i2c_board_info_1,
-				ARRAY_SIZE(n800_i2c_board_info_1));
-
-	i2c_register_board_info(2, n800_i2c_board_info_2,
-				ARRAY_SIZE(n800_i2c_board_info_2));
-
 	n800_flash_init();
 	n800_mmc_init();
 	n800_bt_init();
@@ -481,6 +475,10 @@ static void __init nokia_n800_init(void)
 	spi_register_board_info(n800_spi_board_info,
 				ARRAY_SIZE(n800_spi_board_info));
 	omap_serial_init();
+	omap_register_i2c_bus(1, 400, n800_i2c_board_info_1,
+			      ARRAY_SIZE(n800_i2c_board_info_1));
+	omap_register_i2c_bus(2, 400, n800_i2c_board_info_2,
+			      ARRAY_SIZE(n800_i2c_board_info_2));
 	mipid_dev_init();
 	blizzard_dev_init();
 	tsc2301_dev_init();
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper
  2007-11-07 10:54 ` [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper Jarkko Nikula
@ 2007-11-08 12:42   ` Nishanth Menon
  2007-11-09  7:14     ` Jarkko Nikula
  0 siblings, 1 reply; 7+ messages in thread
From: Nishanth Menon @ 2007-11-08 12:42 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-omap-open-source

Jarkko,
Jarkko Nikula stated on 11/7/2007 4:54 AM:
> This patch starts using introduced I2C bus registration helper by cleaning
> up registration currently done in various places and by doing necessary
> board file modifications.


How do I handle Bus segments on (currently) a hypothetical situation
where i have HS and FS devices on the same i2c bus? There was a long
discussion
(http://lists.lm-sensors.org/pipermail/i2c/2007-April/001038.html )

I am not sure we want to loose that flexibility..

Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper
  2007-11-08 12:42   ` Nishanth Menon
@ 2007-11-09  7:14     ` Jarkko Nikula
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Nikula @ 2007-11-09  7:14 UTC (permalink / raw)
  To: ext Nishanth Menon; +Cc: linux-omap-open-source

On Thu, 08 Nov 2007 06:42:51 -0600
"ext Nishanth Menon" <menon.nishanth@gmail.com> wrote:

> Jarkko,
> Jarkko Nikula stated on 11/7/2007 4:54 AM:
> > This patch starts using introduced I2C bus registration helper by
> > cleaning up registration currently done in various places and by
> > doing necessary board file modifications.
> 
> How do I handle Bus segments on (currently) a hypothetical situation
> where i have HS and FS devices on the same i2c bus? There was a long
> discussion
> (http://lists.lm-sensors.org/pipermail/i2c/2007-April/001038.html )
> 
> I am not sure we want to loose that flexibility..
> 
I didn't read the whole thread but I don't see that this framework can
cover that issue any other way than by registering the rate of slowest
known device since this is more device specific problem than bus
registration problem.

I think it is exception if there is a bus with variable speed devices
and where slower devices don't get confused when using higher speed with
other devices.

Probably that short of info can be passed via i2c_board_info? Like
separate device speed and max idle rate. Adapter driver uses then
standard speed when probing and min(device speed, bus rate, min{devices
max idle rate}) while communicating with one. So that maximum bus
communication speed would be limited either by device speed, bus rate or
slowest device idle rate depending which one is lowest.

But anyway. This sounds some short of exception, not standard procedure
we can do automatically?


	Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH/RFC 0/3 rev 3] I2C bus registration helper
  2007-11-07 10:54 [PATCH/RFC 0/3 rev 3] I2C bus registration helper Jarkko Nikula
                   ` (2 preceding siblings ...)
  2007-11-07 10:54 ` [PATCH 3/3] ARM: OMAP: N800: " Jarkko Nikula
@ 2007-11-15 21:57 ` Tony Lindgren
  3 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2007-11-15 21:57 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: linux-omap-open-source

* Jarkko Nikula <jarkko.nikula@nokia.com> [071107 03:02]:
> Third version of I2C bus registration helper. Now omap_i2c_mux_pins
> is supposed to stay here for doing pin muxing for I2C as suggested by David
> 
> http://linux.omap.com/pipermail/linux-omap-open-source/2007-November/011906.html
> 
> Patch 2 differs only in board-h4.c where omap_cfg_reg calls are removed.
> Patch 3 is the same than previously.

Pushing this series today.

Tony

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-11-15 21:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-07 10:54 [PATCH/RFC 0/3 rev 3] I2C bus registration helper Jarkko Nikula
2007-11-07 10:54 ` [PATCH 1/3] ARM: OMAP: Add helper module for board specific I2C bus registration Jarkko Nikula
2007-11-07 10:54 ` [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper Jarkko Nikula
2007-11-08 12:42   ` Nishanth Menon
2007-11-09  7:14     ` Jarkko Nikula
2007-11-07 10:54 ` [PATCH 3/3] ARM: OMAP: N800: " Jarkko Nikula
2007-11-15 21:57 ` [PATCH/RFC 0/3 rev 3] " Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox