Enabling I2C2 on Linux (Diva)

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Diva-am335x-overview.png Applies to Diva
Tux.png Applies to Linux

Introduction[edit | edit source]

This article shows how to enable the I2C2 interface which can be used in a standard Linux application.

Pin Mux Option[edit | edit source]

I2C2 data/clock signals are available at different Diva pins. We chose the following configuration:

Signal Diva Connector Phisical Pin CPU Ball
I2C2_SCL J1.37 D17
I2C2_SDA J1.39 D18

Linux kernel patches[edit | edit source]

200px-Emblem-important.svg.png

The patches below applies to DIVELK 1.0.0 Linux source tree.

The files arch/arm/mach-omap2/board-diva.c and arch/arm/mach-omap2/diva_pinmux_table.h must be modified according to the following patches:

diff --git a/arch/arm/mach-omap2/board-diva.c b/arch/arm/mach-omap2/board-diva.c
index 42898e9..282917d 100644
--- a/arch/arm/mach-omap2/board-diva.c
+++ b/arch/arm/mach-omap2/board-diva.c
@@ -734,6 +734,14 @@ static void __init diva_i2c_init(void)
 				ARRAY_SIZE(am335x_i2c0_boardinfo));
 }
 
+/* ------------ I2C2 BUS -------------------------------------------------*/
+
+static void i2c2_init(int evm_id, int profile)
+{
+	setup_pin_mux(i2c2_pin_mux);
+	omap_register_i2c_bus(3, 100, NULL, 0);
+}
+
 
 /* ------------ USB BUS -------------------------------------------------*/
 static struct omap_musb_board_data musb_board_data = {
@@ -880,6 +888,8 @@ static struct evm_dev_cfg diva_dev_cfg[] = {
 	
 	{w1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
 	
+	{i2c2_init, DEV_ON_BASEBOARD, PROFILE_NONE},
+	
 /*	{enable_ecap2,     DEV_ON_BASEBOARD, PROFILE_NONE},*/
 /*	{mmc1_wl12xx_init,	DEV_ON_BASEBOARD, PROFILE_NONE},*/
 /*	{uart1_wl12xx_init, DEV_ON_BASEBOARD, PROFILE_NONE},*/
diff --git a/arch/arm/mach-omap2/diva_pinmux_table.h b/arch/arm/mach-omap2/diva_pinmux_table.h
index f6647b0..8d88a27 100644
--- a/arch/arm/mach-omap2/diva_pinmux_table.h
+++ b/arch/arm/mach-omap2/diva_pinmux_table.h
@@ -179,6 +179,14 @@ static struct pinmux_config w1_gpio_pin_mux[] = {
 	{NULL, 0},
 };
 
+static struct pinmux_config i2c2_pin_mux[] = {
+	{"uart1_ctsn.i2c2_sda",    OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW |
+					AM33XX_PULL_UP | AM33XX_INPUT_EN},
+	{"uart1_rtsn.i2c2_scl",   OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW |
+					AM33XX_PULL_UP | AM33XX_INPUT_EN},
+	{NULL, 0},
+};
+
 /*
  * the following mux configurations are un-tested but are left here for
  * reference. They are all comment-out to avoid "defined but not used" warning
@@ -265,14 +273,6 @@ static struct pinmux_config i2c1_pin_mux[] = {
 	{NULL, 0},
 };
 
-static struct pinmux_config i2c2_pin_mux[] = {
-	{"uart1_ctsn.i2c2_sda",    OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW |
-					AM33XX_PULL_UP | AM33XX_INPUT_EN},
-	{"uart1_rtsn.i2c2_scl",   OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW |
-					AM33XX_PULL_UP | AM33XX_INPUT_EN},
-	{NULL, 0},
-};
-
 static struct pinmux_config mmc0_cd_only_pin_mux[] = {
 	{"gpmc_csn1.gpio1_30",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
 	{NULL, 0},

The kernel must be rebuilt to make these modifications effective.

Using the interface[edit | edit source]

Users can access the peripherals connected to the I2C2 bus through the I2C-dev framework. For further information, please refer to

Patch download[edit | edit source]

File:Divelk-i2c2-enable.patch.zip