Skip to contentSkip to conversation

ARM: AM33XX: Add i2c support

PATCH New Patil 2 participants 2 messages Jan 23, 2012 – Jan 25, 2012 Arm (32-bit)

lore
Share & tools
lore

Patil

#0 lore raw

PATCH v3 3/3 ARM: AM33XX: Add i2c support

Add i2c driver board hookup for AM335X EVM

---
Changes for v3:
rebased, patches applied on top of master branch

 arch/arm/cpu/armv7/am33xx/clock.c             |    5 ++
 arch/arm/include/asm/arch-am33xx/common_def.h |    1 +
 arch/arm/include/asm/arch-am33xx/cpu.h        |    3 +-
 arch/arm/include/asm/arch-am33xx/i2c.h        |   81 +++++++++++++++++++++++++
 board/ti/am335x/evm.c                         |    7 ++
 board/ti/am335x/mux.c                         |   13 ++++
 include/configs/am335x_evm.h                  |    9 +++
 7 files changed, 118 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-am33xx/i2c.h
arch/arm/cpu/armv7/am33xx/clock.c +5 -0
index 98cfd93..bbb9c13 100644
@@ -113,6 +113,11 @@ static void enable_per_clocks(void)
 	writel(PRCM_MOD_EN, &cmper->mmc0clkctrl);
 	while (readl(&cmper->mmc0clkctrl) != PRCM_MOD_EN)
 		;
+
+	/* i2c0 */
+	writel(PRCM_MOD_EN, &cmwkup->wkup_i2c0ctrl);
+	while (readl(&cmwkup->wkup_i2c0ctrl) != PRCM_MOD_EN)
+		;
 }
 
 static void mpu_pll_config(void)
arch/arm/include/asm/arch-am33xx/common_def.h +1 -0
index 767932d..aa3b554 100644
@@ -18,5 +18,6 @@
 
 extern void enable_uart0_pin_mux(void);
 extern void enable_mmc0_pin_mux(void);
+extern void enable_i2c0_pin_mux(void);
 
 #endif/*__COMMON_DEF_H__ */
arch/arm/include/asm/arch-am33xx/cpu.h +2 -1
index 25558a2..cd002e6 100644
@@ -95,7 +95,8 @@ struct cm_wkuppll {
 	unsigned int divm2dpllper;	/* offset 0xAC */
 	unsigned int resv11[1];
 	unsigned int wkup_uart0ctrl;	/* offset 0xB4 */
-	unsigned int resv12[8];
+	unsigned int wkup_i2c0ctrl;	/* offset 0xB8 */
+	unsigned int resv12[7];
 	unsigned int divm6dpllcore;	/* offset 0xD8 */
 };
 
arch/arm/include/asm/arch-am33xx/i2c.h new file +81 -0

81 lines not on this page · raw message

board/ti/am335x/evm.c +7 -0
index 6a9f788..13dc603 100644
@@ -18,6 +18,7 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/common_def.h>
 #include <serial.h>
+#include <i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -42,6 +43,12 @@ int init_basic_setup(void)
 int board_init(void)
 {
 	enable_uart0_pin_mux();
+
+#ifdef CONFIG_I2C
+	enable_i2c0_pin_mux();
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+
 	init_basic_setup();
 
 	return 0;
board/ti/am335x/mux.c +13 -0
index 4cb0cdf..9ccb436 100644
@@ -272,6 +272,14 @@ static struct module_pin_mux mmc0_pin_mux[] = {
 };
 #endif
 
+static struct module_pin_mux i2c0_pin_mux[] = {
+	{OFFSET(i2c0_sda), (MODE(0) | RXACTIVE |
+			PULLUDEN | SLEWCTRL)}, /* I2C_DATA */
+	{OFFSET(i2c0_scl), (MODE(0) | RXACTIVE |
+			PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */
+	{-1},
+};
+
 /*
  * Configure the pin mux for the module
  */
@@ -297,3 +305,8 @@ void enable_mmc0_pin_mux(void)
 	configure_module_pin_mux(mmc0_pin_mux);
 }
 #endif
+
+void enable_i2c0_pin_mux(void)
+{
+	configure_module_pin_mux(i2c0_pin_mux);
+}
include/configs/am335x_evm.h +9 -0
index 2cea1f4..6683b3e 100644
@@ -103,6 +103,14 @@
 #define CONFIG_SYS_NS16550_CLK		(48000000)
 #define CONFIG_SYS_NS16550_COM1		0x44e09000	/* Base EVM has UART0 */
 
+/* I2C Configuration */
+#define CONFIG_I2C
+#define CONFIG_CMD_I2C
+#define CONFIG_HARD_I2C
+#define CONFIG_SYS_I2C_SPEED		100000
+#define CONFIG_SYS_I2C_SLAVE		1
+#define CONFIG_DRIVER_OMAP24XX_I2C
+
 #define CONFIG_BAUDRATE		115200
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 110, 300, 600, 1200, 2400, \
 4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600, 115200 }
@@ -131,6 +139,7 @@
 #define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
 
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
Signature · 1 line
1.7.1
#1 lore raw

PATCH v3 3/3 ARM: AM33XX: Add i2c support

Hello Patil,

Quoted 8 lines · Rachna

Add i2c driver board hookup for AM335X EVM

---
Changes for v3:
rebased, patches applied on top of master branch

Quoted 9 lines
 arch/arm/cpu/armv7/am33xx/clock.c             |    5 ++
 arch/arm/include/asm/arch-am33xx/common_def.h |    1 +
 arch/arm/include/asm/arch-am33xx/cpu.h        |    3 +-
 arch/arm/include/asm/arch-am33xx/i2c.h        |   81 +++++++++++++++++++++++++
 board/ti/am335x/evm.c                         |    7 ++
 board/ti/am335x/mux.c                         |   13 ++++
 include/configs/am335x_evm.h                  |    9 +++
 7 files changed, 118 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-am33xx/i2c.h

Applied to u-boot-i2c.git

Thanks.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany