Skip to contentSkip to conversation

I2C bus registration helper

PATCH In review Jarkko Nikula 3 participants 7 messages Nov 7, 2007 – Nov 15, 2007

Subsystems (4)
lore
Share & tools
lore
#1 lore raw

PATCH 1/3 ARM: OMAP: Add helper module for board specific I2C bus registration

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.

---
 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
arch/arm/plat-omap/Makefile +1 -0
index 282ea00..9d97ae5 100644
@@ -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
arch/arm/plat-omap/i2c.c new file +148 -0

148 lines not on this page · raw message

include/asm-arm/arch-omap/common.h +7 -0
index 08d58ab..089ddc7 100644
@@ -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 */
Signature · 1 line
1.5.3.4
#2 lore raw

PATCH 2/3 ARM: OMAP: Use I2C bus registration helper

In reply to Jarkko Nikula

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.

---
 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(-)
arch/arm/mach-omap1/board-ams-delta.c +1 -0
index c73ca61..fc38f03 100644
@@ -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);
arch/arm/mach-omap1/board-fsample.c +1 -0
index d5f6ea1..eaf9ef5 100644
@@ -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)
arch/arm/mach-omap1/board-generic.c +1 -0
index 4b35f16..54a430f 100644
@@ -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)
arch/arm/mach-omap1/board-h2.c +1 -0
index d2214ad..722c5a4 100644
@@ -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)
arch/arm/mach-omap1/board-h3.c +1 -0
index df77cf5..8960956 100644
@@ -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)
arch/arm/mach-omap1/board-innovator.c +1 -0
index 7e63a41..48c0c41 100644
@@ -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)
arch/arm/mach-omap1/board-nokia770.c +1 -0
index df5bda2..da0b90f 100644
@@ -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();
arch/arm/mach-omap1/board-osk.c +2 -3
index 5fab8f4..7d2f21e 100644
@@ -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();
 }
 
arch/arm/mach-omap1/board-palmte.c +1 -0
index e5e0957..ccd83cf 100644
@@ -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)
arch/arm/mach-omap1/board-palmtt.c +1 -0
index dd69e01..38c9ba9 100644
@@ -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)
arch/arm/mach-omap1/board-palmz71.c +1 -0
index 6b49c71..b2ed1cb 100644
@@ -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);
 }
 
arch/arm/mach-omap1/board-perseus2.c +1 -0
index e9e352e..1b39b6b 100644
@@ -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)
arch/arm/mach-omap1/board-sx1.c +1 -0
index f25ec6f..389d3fa 100644
@@ -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 */
arch/arm/mach-omap1/board-voiceblue.c +1 -0
index 214dd19..04d9e8c 100644
@@ -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) */
arch/arm/mach-omap2/board-2430sdp.c +2 -67

77 lines not on this page · raw message

arch/arm/mach-omap2/board-apollon.c +2 -0
index ff8459c..1932d73 100644
@@ -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));
arch/arm/mach-omap2/board-generic.c +2 -0
index d8da3c1..4226464 100644
@@ -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)
arch/arm/mach-omap2/board-h4.c +2 -3
index fc30021..85649bb 100644
@@ -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();
arch/arm/mach-omap2/devices.c +0 -52

64 lines not on this page · raw message

arch/arm/plat-omap/devices.c +0 -73

85 lines not on this page · raw message

Signature · 1 line
1.5.3.4
#5 lore raw

PATCH 3/3 ARM: OMAP: N800: Use I2C bus registration helper

In reply to Jarkko Nikula

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

---
 arch/arm/mach-omap2/board-n800.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/board-n800.c +4 -6
index 81c4a8d..a3e1c2b 100644
@@ -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();
Signature · 1 line
1.5.3.4
#3 lore raw

Re: [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper

In reply to Jarkko Nikula

Jarkko,
Jarkko Nikula stated on 11/7/2007 4:54 AM:

Quoted 3 lines

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

#4 lore raw

Re: [PATCH 2/3] ARM: OMAP: Use I2C bus registration helper

Quoted 6 lines · On Thu, 08 Nov 2007 06:42:51 -0600 "ext Nishanth Menon"…

Jarkko,
Jarkko Nikula stated on 11/7/2007 4:54 AM:

Quoted 3 lines

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.

Quoted 7 lines

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