Skip to contentSkip to conversation

Bring new I2C framwork to Samsung Trats board

PATCH Superseded Piotr Wilczek 2 participants 18 messages Nov 15, 2012 – Nov 20, 2012

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

cover Bring new I2C framwork to Samsung Trats board

This patchset brings new I2C framework to Samsung Trats board. It is intended to test the framework, please don't merge.

I2C clock, spacing and pinmux are added for Exynos4. The s3c24x0 i2c driver is modified to support both Exynos4.

The s3c24x0 i2c driver is modiefied for the new I2C framework. Configs for VCMA9.h and smdk5250.h boards are modified. Boards compile successfully but were not tested.

New i2c framework is enabled and tested on Samsung Trats board.

Piotr Wilczek (6):
exynos:clock: Add i2c clock
exynos:cpu: Add Exynos4 I2C spacing exynos:pinmux: Add pinmux support for i2c drivers:i2c: Modify I2C driver for Exynos4
WIP: i2c: s3c24x0: modify driver for new I2C framework
WIP: arm: trats: add support for new I2C framework

 arch/arm/cpu/armv7/exynos/clock.c      |   17 ++++
 arch/arm/cpu/armv7/exynos/pinmux.c     |   64 ++++++++++++++
 arch/arm/include/asm/arch-exynos/cpu.h |    2 +
 board/samsung/trats/trats.c            |   26 +++++-
 drivers/i2c/i2c_core.c                 |    5 +
 drivers/i2c/s3c24x0_i2c.c              |  148 ++++++++++++++++++++++++++++----
 include/configs/VCMA9.h                |    4 +
 include/configs/smdk5250.h             |    4 +
 include/configs/trats.h                |   16 +++-
 9 files changed, 263 insertions(+), 23 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/6 exynos:clock: Add i2c clock

This patch adds i2c clock for Exynos4

---
 arch/arm/cpu/armv7/exynos/clock.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/clock.c +17 -0
index 4f3b451..21e45d2 100644
@@ -732,6 +732,21 @@ static unsigned long exynos5_get_i2c_clk(void)
 	return aclk_66;
 }
 
+static unsigned long exynos4_get_i2c_clk(void)
+{
+	struct exynos4_clock *clk =
+		(struct exynos4_clock *)samsung_get_base_clock();
+	unsigned long sclk, aclk_100;
+	unsigned int ratio;
+
+	sclk = get_pll_clk(APLL);
+
+	ratio = (readl(&clk->div_top)) >> 4;
+	ratio &= 0xf;
+	aclk_100 = sclk / (ratio + 1);
+	return aclk_100;
+}
+
 unsigned long get_pll_clk(int pllreg)
 {
 	if (cpu_is_exynos5())
@@ -752,6 +767,8 @@ unsigned long get_i2c_clk(void)
 {
 	if (cpu_is_exynos5()) {
 		return exynos5_get_i2c_clk();
+	} else if (cpu_is_exynos4()) {
+		return exynos4_get_i2c_clk();
 	} else {
 		debug("I2C clock is not set for this CPU\n");
 		return 0;
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/6 exynos:cpu: Add Exynos4 I2C spacing

In reply to Piotr Wilczek

This patch add the spacing for i2c for Exynos4

---
 arch/arm/include/asm/arch-exynos/cpu.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-exynos/cpu.h +2 -0
index 2cd4ae1..3073ca1 100644
@@ -28,6 +28,8 @@
 #define EXYNOS4_ADDR_BASE		0x10000000
 
 /* EXYNOS4 */
+#define EXYNOS4_I2C_SPACING		0x10000
+
 #define EXYNOS4_GPIO_PART3_BASE		0x03860000
 #define EXYNOS4_PRO_ID			0x10000000
 #define EXYNOS4_SYSREG_BASE		0x10010000
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/6 exynos:pinmux: Add pinmux support for i2c

In reply to Piotr Wilczek

This patch add pinmux for I2C for Exynos4

---
 arch/arm/cpu/armv7/exynos/pinmux.c |   64 ++++++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +64 -0
index 7776add..44ce072 100644
@@ -265,10 +265,74 @@ static int exynos5_pinmux_config(int peripheral, int flags)
 	return 0;
 }
 
+static void exynos4_i2c_config(int peripheral, int flags)
+{
+	struct exynos4_gpio_part1 *gpio1 =
+		(struct exynos4_gpio_part1 *) samsung_get_base_gpio_part1();
+
+	switch (peripheral) {
+	case PERIPH_ID_I2C0:
+		s5p_gpio_cfg_pin(&gpio1->d1, 0, GPIO_FUNC(0x2));
+		s5p_gpio_cfg_pin(&gpio1->d1, 1, GPIO_FUNC(0x2));
+		break;
+	case PERIPH_ID_I2C1:
+		s5p_gpio_cfg_pin(&gpio1->d1, 2, GPIO_FUNC(0x2));
+		s5p_gpio_cfg_pin(&gpio1->d1, 3, GPIO_FUNC(0x2));
+		break;
+	case PERIPH_ID_I2C2:
+		s5p_gpio_cfg_pin(&gpio1->a0, 6, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->a0, 7, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C3:
+		s5p_gpio_cfg_pin(&gpio1->a1, 2, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->a1, 3, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C4:
+		s5p_gpio_cfg_pin(&gpio1->b, 2, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->b, 3, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C5:
+		s5p_gpio_cfg_pin(&gpio1->b, 6, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->b, 7, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C6:
+		s5p_gpio_cfg_pin(&gpio1->c1, 3, GPIO_FUNC(0x4));
+		s5p_gpio_cfg_pin(&gpio1->c1, 4, GPIO_FUNC(0x4));
+		break;
+	case PERIPH_ID_I2C7:
+		s5p_gpio_cfg_pin(&gpio1->d0, 2, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->d0, 3, GPIO_FUNC(0x3));
+		break;
+	}
+}
+
+static int exynos4_pinmux_config(int peripheral, int flags)
+{
+	switch (peripheral) {
+	case PERIPH_ID_I2C0:
+	case PERIPH_ID_I2C1:
+	case PERIPH_ID_I2C2:
+	case PERIPH_ID_I2C3:
+	case PERIPH_ID_I2C4:
+	case PERIPH_ID_I2C5:
+	case PERIPH_ID_I2C6:
+	case PERIPH_ID_I2C7:
+		exynos4_i2c_config(peripheral, flags);
+		break;
+	default:
+		debug("%s: invalid peripheral %d", __func__, peripheral);
+		return -1;
+	}
+
+	return 0;
+}
+
 int exynos_pinmux_config(int peripheral, int flags)
 {
 	if (cpu_is_exynos5())
 		return exynos5_pinmux_config(peripheral, flags);
+	else if (cpu_is_exynos4())
+		return exynos4_pinmux_config(peripheral, flags);
 	else {
 		debug("pinmux functionality not supported\n");
 		return -1;
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 4/6 drivers:i2c: Modify I2C driver for Exynos4

In reply to Piotr Wilczek

This patch modifies the S3C i2c driver to support both Exynos4 and Exynos5

---
 drivers/i2c/s3c24x0_i2c.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
drivers/i2c/s3c24x0_i2c.c +12 -7
index 9bc4c7f..90d297a 100644
@@ -27,7 +27,7 @@
  */
 
 #include <common.h>
-#ifdef CONFIG_EXYNOS5
+#if (defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 #include <asm/arch/clk.h>
 #include <asm/arch/cpu.h>
 #else
@@ -62,7 +62,7 @@
 
 static unsigned int g_current_bus;	/* Stores Current I2C Bus */
 
-#ifndef CONFIG_EXYNOS5
+#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 static int GetI2CSDA(void)
 {
 	struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
@@ -121,7 +121,12 @@ static void ReadWriteByte(struct s3c24x0_i2c *i2c)
 
 static struct s3c24x0_i2c *get_base_i2c(void)
 {
-#ifdef CONFIG_EXYNOS5
+#ifdef CONFIG_EXYNOS4
+	struct s3c24x0_i2c *i2c = (struct s3c24x0_i2c *)(samsung_get_base_i2c()
+							+ (EXYNOS4_I2C_SPACING
+							* g_current_bus));
+	return i2c;
+#elif defined CONFIG_EXYNOS5
 	struct s3c24x0_i2c *i2c = (struct s3c24x0_i2c *)(samsung_get_base_i2c()
 							+ (EXYNOS5_I2C_SPACING
 							* g_current_bus));
@@ -134,7 +139,7 @@ static struct s3c24x0_i2c *get_base_i2c(void)
 static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
 {
 	ulong freq, pres = 16, div;
-#ifdef CONFIG_EXYNOS5
+#if (defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 	freq = get_i2c_clk();
 #else
 	freq = get_PCLK();
@@ -188,7 +193,7 @@ unsigned int i2c_get_bus_num(void)
 void i2c_init(int speed, int slaveadd)
 {
 	struct s3c24x0_i2c *i2c;
-#ifndef CONFIG_EXYNOS5
+#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 	struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
 #endif
 	int i;
@@ -204,7 +209,7 @@ void i2c_init(int speed, int slaveadd)
 		i--;
 	}
 
-#ifndef CONFIG_EXYNOS5
+#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 	if ((readl(&i2c->iicstat) & I2CSTAT_BSY) || GetI2CSDA() == 0) {
 #ifdef CONFIG_S3C2410
 		ulong old_gpecon = readl(&gpio->gpecon);
@@ -248,7 +253,7 @@ void i2c_init(int speed, int slaveadd)
 		writel(old_gpecon, &gpio->pgcon);
 #endif
 	}
-#endif /* #ifndef CONFIG_EXYNOS5 */
+#endif /* #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5) */
 	i2c_ch_init(i2c, speed, slaveadd);
 }
 
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH 5/6 WIP: i2c: s3c24x0: modify driver for new I2C framework

In reply to Piotr Wilczek

This patch modifies s3c24x0 driver for the new I2C framework. Configs for VCMA9.h and smdk5250.h boards are modified. Boards compile successfully but were not tested.

---
 drivers/i2c/i2c_core.c     |    5 ++
 drivers/i2c/s3c24x0_i2c.c  |  129 ++++++++++++++++++++++++++++++++++++++++---
 include/configs/VCMA9.h    |    4 ++
 include/configs/smdk5250.h |    4 ++
 4 files changed, 133 insertions(+), 9 deletions(-)
drivers/i2c/i2c_core.c +5 -0
index d3b5a8d..f0816f7 100644
@@ -10,6 +10,10 @@
 extern struct i2c_adapter fsl_i2c_adap[];
 #endif
 
+#ifdef CONFIG_DRIVER_S3C24X0_I2C
+extern struct i2c_adapter s3c24x0_i2c_adap[];
+#endif
+
 #ifdef CONFIG_SYS_I2C_SOFT
 extern struct i2c_adapter soft_i2c_adap[];
 #endif
@@ -214,6 +218,7 @@ unsigned int i2c_get_bus_num(void)
  */
 int i2c_set_bus_num(unsigned int bus)
 {
+
 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
 	int		i;
 	uint8_t	buf;
drivers/i2c/s3c24x0_i2c.c +120 -9

193 lines not on this page · raw message

include/configs/VCMA9.h +4 -0
index fb7d922..f1de21d 100644
@@ -95,6 +95,10 @@
 /* we use the built-in I2C controller */
 #define CONFIG_DRIVER_S3C24X0_I2C
 
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
 /* use EEPROM for environment vars */
include/configs/smdk5250.h +4 -0
index c0f8622..cb0f449 100644
@@ -204,6 +204,10 @@
 #define CONFIG_MAX_I2C_NUM	8
 #define CONFIG_SYS_I2C_SLAVE    0x0
 
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
 /* Ethernet Controllor Driver */
 #ifdef CONFIG_CMD_NET
 #define CONFIG_SMC911X
Signature · 1 line
1.7.5.4
#6 lore raw

PATCH 5/6 WIP: i2c: s3c24x0: modify driver for new I2C framework

Hello Piotr,

Quoted 14 lines · Piotr Wilczek

This patch modifies s3c24x0 driver for the new I2C framework. Configs for VCMA9.h and smdk5250.h boards are modified. Boards compile successfully but were not tested.

---
  drivers/i2c/i2c_core.c     |    5 ++
  drivers/i2c/s3c24x0_i2c.c  |  129 ++++++++++++++++++++++++++++++++++++++++---
  include/configs/VCMA9.h    |    4 ++
  include/configs/smdk5250.h |    4 ++
  4 files changed, 133 insertions(+), 9 deletions(-)

[...]

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd) · line 158

Quoted 9 lines
drivers/i2c/s3c24x0_i2c.c +0 -1
index 90d297a..d473eaa 100644
@@ -155,7 +155,6 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
 
  	/* set prescaler, divisor according to freq, also set ACKGEN, IRQ */
  	writel((div&  0x0F) | 0xA0 | ((pres == 512) ? 0x40 : 0),&i2c->iiccon);
-

Why this delete?

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd) · line 169

Quoted 7 lines
drivers/i2c/s3c24x0_i2c.c +0 -0
  	/* init to SLAVE REVEIVE and set slaveaddr */
  	writel(0,&i2c->iicstat);
  	writel(slaveadd,&i2c->iicadd);
@@ -168,7 +167,7 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
   */
 
  #ifdef CONFIG_I2C_MULTI_BUS

This define can go completely away.

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd) · line 170

Quoted 2 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
-int i2c_set_bus_num(unsigned int bus)
+int s3c24x0_i2c_set_bus_num(unsigned int bus)

all functions are static now, please change.

drivers/i2c/s3c24x0_i2c.c int i2c_set_bus_num(unsigned int bus) · line 186

Quoted 9 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
  {
  	struct s3c24x0_i2c *i2c;
 
@@ -184,13 +183,13 @@ int i2c_set_bus_num(unsigned int bus)
  	return 0;
  }
 
-unsigned int i2c_get_bus_num(void)
+unsigned int s3c24x0_i2c_get_bus_num(void)

No longer needed.

drivers/i2c/s3c24x0_i2c.c int i2c_set_bus_num(unsigned int bus) · line 192

Quoted 7 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
  {
  	return g_current_bus;
  }
  #endif
 
-void i2c_init(int speed, int slaveadd)
+void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)

static.

drivers/i2c/s3c24x0_i2c.c void i2c_init(int speed, int slaveadd) · line 200

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +1 -2
  {
  	struct s3c24x0_i2c *i2c;
  #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
@@ -198,8 +197,7 @@ void i2c_init(int speed, int slaveadd)
  #endif
  	int i;
 
-	/* By default i2c channel 0 is the current bus */
-	g_current_bus = 0;
+	g_current_bus = adap->hwadapnr;

Can we please delete g_current_bus and use adap->hwadapnr only. g_current_bus should go away completely.

drivers/i2c/s3c24x0_i2c.c static int i2c_transfer(struct s3c24x0_i2c *i2c, · line 416

Quoted 9 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
  	i2c = get_base_i2c();
 
  	/* wait for some time to give previous transfer a chance to finish */
@@ -415,11 +413,13 @@ static int i2c_transfer(struct s3c24x0_i2c *i2c,
  	return result;
  }
 
-int i2c_probe(uchar chip)
+int s3c24x0_i2c_probe(struct i2c_adapter *adap, uchar chip)

static.

drivers/i2c/s3c24x0_i2c.c static int i2c_transfer(struct s3c24x0_i2c *i2c, · line 421

Quoted 5 lines
drivers/i2c/s3c24x0_i2c.c +1 -0
  {
  	struct s3c24x0_i2c *i2c;
  	uchar buf[1];
 
+	g_current_bus = adap->hwadapnr;

Please get rid of g_current_bus, and use adap->hwadapnr only!

drivers/i2c/s3c24x0_i2c.c int i2c_probe(uchar chip) · line 435

Quoted 11 lines
drivers/i2c/s3c24x0_i2c.c +3 -1
+
  	i2c = get_base_i2c();
  	buf[0] = 0;
 
@@ -431,12 +431,15 @@ int i2c_probe(uchar chip)
  	return i2c_transfer(i2c, I2C_READ, chip<<  1, 0, 0, buf, 1) != I2C_OK;
  }
 
-int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *buffer, int len)

static.

Quoted 11 lines
drivers/i2c/s3c24x0_i2c.c +2 -0
  {
  	struct s3c24x0_i2c *i2c;
  	uchar xaddr[4];
  	int ret;
 
+	g_current_bus = adap->hwadapnr;
+
  	if (alen>  4) {
  		debug("I2C read: addr len %d not supported\n", alen);
  		return 1;

drivers/i2c/s3c24x0_i2c.c int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) · line 482

Quoted 6 lines
drivers/i2c/s3c24x0_i2c.c +2 -1
@@ -475,11 +478,14 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
  	return 0;
  }
 
-int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
+int s3c24x0_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *buffer, int len)

static

Quoted 12 lines
drivers/i2c/s3c24x0_i2c.c +2 -0
  {
  	struct s3c24x0_i2c *i2c;
  	uchar xaddr[4];
 
+	g_current_bus = adap->hwadapnr;
+
  	if (alen>  4) {
  		debug("I2C write: addr len %d not supported\n", alen);
  		return 1;
@@ -512,4 +518,109 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
  		(i2c, I2C_WRITE, chip<<  1,&xaddr[4 - alen], alen, buffer,
  		 len) != 0);

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) · line 529

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +9 -0
  }
+
+struct i2c_adapter s3c24x0_i2c_adap[] = {
+	{
+		.init		=	s3c24x0_i2c_init,
+		.probe		=	s3c24x0_i2c_probe,
+		.read		=	s3c24x0_i2c_read,
+		.write		=	s3c24x0_i2c_write,
+		.speed		=	CONFIG_SYS_I2C_SPEED,
+		.slaveaddr	=	CONFIG_SYS_I2C_SLAVE,

Please use a more driver specific name here, for example:
CONFIG_SYS_I2C_S3C24X0_{SPEED/SLAVE} ...

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)

Quoted 5 lines
drivers/i2c/s3c24x0_i2c.c +5 -0
+		.init_done	=	0,
+		.hwadapnr	=	0,
+		.name		=	"s3c24x0-i2c#0"
+	},
+#if CONFIG_MAX_I2C_NUM>  1

Please use a more driver specific name here, for example:
CONFIG_I2C_S3C24X0_MAX_NUM, thanks!

Quoted 1 line
drivers/i2c/s3c24x0_i2c.c +1 -0
+	{

[...]

include/configs/VCMA9.h line 96

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +2 -0
+#endif
+};
  #endif /* CONFIG_HARD_I2C */
include/configs/VCMA9.h +0 -0
index fb7d922..f1de21d 100644
@@ -95,6 +95,10 @@
  /* we use the built-in I2C controller */
  #define CONFIG_DRIVER_S3C24X0_I2C

^
Can we rename this define to CONFIG_SYS_I2C_S3C24X0

include/configs/smdk5250.h line 204

Quoted 13 lines
include/configs/VCMA9.h +4 -0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
  #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
  #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
  /* use EEPROM for environment vars */
include/configs/smdk5250.h +0 -0
index c0f8622..cb0f449 100644
@@ -204,6 +204,10 @@
  #define CONFIG_MAX_I2C_NUM	8
             ^
             Please rename

include/configs/smdk5250.h line 205

Quoted 1 line
include/configs/smdk5250.h +0 -0
  #define CONFIG_SYS_I2C_SLAVE    0x0
             ^
             Please rename

include/configs/smdk5250.h line 213

Quoted 7 lines
include/configs/smdk5250.h +4 -0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
  /* Ethernet Controllor Driver */
  #ifdef CONFIG_CMD_NET
  #define CONFIG_SMC911X

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
#7 lore raw

PATCH 5/6 WIP: i2c: s3c24x0: modify driver for new I2C framework

Hello Heiko,

Quoted 35 lines

-----Original Message-----
From: Heiko Schocher [mailto:hs at denx.de]
Sent: Friday, November 16, 2012 11:34 AM
To: Piotr Wilczek
Cc: u-boot at lists.denx.de; Minkyu Kang; Kyungmin Park; Lukasz Majewski; Simon Glass; Stephen Warren; Tom Rini
Subject: Re: [PATCH 5/6] WIP: i2c: s3c24x0: modify driver for new I2C framework

Hello Piotr,

Quoted 10 lines · Piotr Wilczek

This patch modifies s3c24x0 driver for the new I2C framework. Configs for VCMA9.h and smdk5250.h boards are modified. Boards compile successfully but were not tested.

---
  drivers/i2c/i2c_core.c     |    5 ++
  drivers/i2c/s3c24x0_i2c.c  |  129

++++++++++++++++++++++++++++++++++++++++---

Quoted 4 lines
  include/configs/VCMA9.h    |    4 ++
  include/configs/smdk5250.h |    4 ++
  4 files changed, 133 insertions(+), 9 deletions(-)

[...]

Quoted 7 lines
drivers/i2c/s3c24x0_i2c.c +0 -0
index 90d297a..d473eaa 100644
@@ -155,7 +155,6 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c,
 int speed, int slaveadd)
 
Quoted 8 lines

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, · line 157

Quoted 1 line
drivers/i2c/s3c24x0_i2c.c +0 -0
  	/* set prescaler, divisor according to freq, also set ACKGEN, IRQ

*/

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, · line 160

Quoted 3 lines
drivers/i2c/s3c24x0_i2c.c +0 -1
  	writel((div&  0x0F) | 0xA0 | ((pres == 512) ? 0x40 :
 0),&i2c->iiccon);
-

Why this delete?

Unintentional, I fix it.

Quoted 10 lines

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c,

Quoted 4 lines
drivers/i2c/s3c24x0_i2c.c +0 -0
  	/* init to SLAVE REVEIVE and set slaveaddr */
  	writel(0,&i2c->iicstat);
  	writel(slaveadd,&i2c->iicadd);
drivers/i2c/s3c24x0_i2c.c +0 -0
@@ -168,7 +167,7 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c,

int speed, int slaveadd)

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd) · line 169

Quoted 3 lines
drivers/i2c/s3c24x0_i2c.c +0 -0
   */
 
  #ifdef CONFIG_I2C_MULTI_BUS

This define can go completely away.

Right.

Quoted 5 lines

drivers/i2c/s3c24x0_i2c.c static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd) · line 170

Quoted 3 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
-int i2c_set_bus_num(unsigned int bus)
+int s3c24x0_i2c_set_bus_num(unsigned int bus)

all functions are static now, please change.

Yes, I overlooked it.

Quoted 31 lines

drivers/i2c/s3c24x0_i2c.c int i2c_set_bus_num(unsigned int bus) · line 186

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
  {
  	struct s3c24x0_i2c *i2c;
 
@@ -184,13 +183,13 @@ int i2c_set_bus_num(unsigned int bus)
  	return 0;
  }
 
-unsigned int i2c_get_bus_num(void)
+unsigned int s3c24x0_i2c_get_bus_num(void)

No longer needed.

drivers/i2c/s3c24x0_i2c.c int i2c_set_bus_num(unsigned int bus)

Quoted 8 lines
drivers/i2c/s3c24x0_i2c.c +2 -1
  {
  	return g_current_bus;
  }
  #endif
 
-void i2c_init(int speed, int slaveadd)
+void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int
+slaveadd)

static.

Quoted 7 lines
drivers/i2c/s3c24x0_i2c.c +1 -0
  {
  	struct s3c24x0_i2c *i2c;
  #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5) @@ -198,8
+197,7 @@ void i2c_init(int speed, int slaveadd)
  #endif
  	int i;
Quoted 6 lines

drivers/i2c/s3c24x0_i2c.c void i2c_init(int speed, int slaveadd) · line 200

Quoted 3 lines
drivers/i2c/s3c24x0_i2c.c +1 -2
-	/* By default i2c channel 0 is the current bus */
-	g_current_bus = 0;
+	g_current_bus = adap->hwadapnr;

Can we please delete g_current_bus and use adap->hwadapnr only. g_current_bus should go away completely.

Ok

Quoted 74 lines
Quoted 4 lines
  	i2c = get_base_i2c();

/* wait for some time to give previous transfer a chance to

finish

Quoted 1 line

*/ @@ -415,11 +413,13 @@ static int i2c_transfer(struct s3c24x0_i2c

*i2c,

drivers/i2c/s3c24x0_i2c.c static int i2c_transfer(struct s3c24x0_i2c *i2c, · line 416

Quoted 5 lines
  	return result;
  }
drivers/i2c/s3c24x0_i2c.c +1 -1
-int i2c_probe(uchar chip)
+int s3c24x0_i2c_probe(struct i2c_adapter *adap, uchar chip)

static.

drivers/i2c/s3c24x0_i2c.c

Quoted 5 lines
  {
  	struct s3c24x0_i2c *i2c;
  	uchar buf[1];
drivers/i2c/s3c24x0_i2c.c +1 -0
+	g_current_bus = adap->hwadapnr;

Please get rid of g_current_bus, and use adap->hwadapnr only!

drivers/i2c/s3c24x0_i2c.c int i2c_probe(uchar chip) · line 431

Quoted 6 lines
drivers/i2c/s3c24x0_i2c.c +1 -0
+
  	i2c = get_base_i2c();
  	buf[0] = 0;
@@ -431,12 +431,15 @@ int i2c_probe(uchar chip)
  	return i2c_transfer(i2c, I2C_READ, chip<<  1, 0, 0, buf, 1) !=

I2C_OK;

drivers/i2c/s3c24x0_i2c.c int i2c_probe(uchar chip) · line 434

Quoted 3 lines
drivers/i2c/s3c24x0_i2c.c +0 -1
  }
 
-int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int

len)

drivers/i2c/s3c24x0_i2c.c int i2c_probe(uchar chip) · line 434

Quoted 1 line
drivers/i2c/s3c24x0_i2c.c +1 -0
+int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint

addr,

drivers/i2c/s3c24x0_i2c.c int i2c_probe(uchar chip) · line 435

Quoted 1 line
drivers/i2c/s3c24x0_i2c.c +1 -0
+			int alen, uchar *buffer, int len)

static.

drivers/i2c/s3c24x0_i2c.c int i2c_read(uchar chip, uint addr, int alen,

Quoted 11 lines
drivers/i2c/s3c24x0_i2c.c +2 -0
  {
  	struct s3c24x0_i2c *i2c;
  	uchar xaddr[4];
  	int ret;
 
+	g_current_bus = adap->hwadapnr;
+
  	if (alen>  4) {
  		debug("I2C read: addr len %d not supported\n", alen);
  		return 1;
@@ -475,11 +478,14 @@ int i2c_read(uchar chip, uint addr, int alen,

uchar *buffer, int len)

drivers/i2c/s3c24x0_i2c.c int i2c_set_bus_num(unsigned int bus)

Quoted 6 lines
drivers/i2c/s3c24x0_i2c.c +1 -1
  	return 0;
  }
 
-int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int
 len)
+int s3c24x0_i2c_write(struct i2c_adapter *adap, uchar chip, uint

addr,

drivers/i2c/s3c24x0_i2c.c int i2c_read(uchar chip, uint addr, int alen, · line 483

Quoted 1 line
drivers/i2c/s3c24x0_i2c.c +1 -0
+			int alen, uchar *buffer, int len)

static

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen,

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +2 -0
  {
  	struct s3c24x0_i2c *i2c;
  	uchar xaddr[4];
 
+	g_current_bus = adap->hwadapnr;
+
  	if (alen>  4) {
  		debug("I2C write: addr len %d not supported\n", alen);

return 1;

drivers/i2c/s3c24x0_i2c.c +0 -0
@@ -512,4 +518,109 @@ int i2c_write(uchar chip, uint addr, int alen,

uchar *buffer, int len)

Quoted 15 lines

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) · line 529

Quoted 12 lines
drivers/i2c/s3c24x0_i2c.c +9 -0
  		(i2c, I2C_WRITE, chip<<  1,&xaddr[4 - alen], alen, buffer,
  		 len) != 0);
  }
+
+struct i2c_adapter s3c24x0_i2c_adap[] = {
+	{
+		.init		=	s3c24x0_i2c_init,
+		.probe		=	s3c24x0_i2c_probe,
+		.read		=	s3c24x0_i2c_read,
+		.write		=	s3c24x0_i2c_write,
+		.speed		=	CONFIG_SYS_I2C_SPEED,
+		.slaveaddr	=	CONFIG_SYS_I2C_SLAVE,

Please use a more driver specific name here, for example:
CONFIG_SYS_I2C_S3C24X0_{SPEED/SLAVE} ...

Ok

Quoted 9 lines

drivers/i2c/s3c24x0_i2c.c int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)

Quoted 6 lines
drivers/i2c/s3c24x0_i2c.c +5 -0
+		.init_done	=	0,
+		.hwadapnr	=	0,
+		.name		=	"s3c24x0-i2c#0"
+	},
+#if CONFIG_MAX_I2C_NUM>  1

Please use a more driver specific name here, for example:
CONFIG_I2C_S3C24X0_MAX_NUM, thanks!

Ok

Quoted 31 lines
Quoted 2 lines
drivers/i2c/s3c24x0_i2c.c +1 -0
+	{

[...]

include/configs/VCMA9.h line 96

Quoted 10 lines
drivers/i2c/s3c24x0_i2c.c +2 -0
+#endif
+};
  #endif /* CONFIG_HARD_I2C */
include/configs/VCMA9.h index renamed from include/configs/VCMA9.h +0 -0

fb7d922..f1de21d 100644

include/configs/VCMA9.h +0 -0
@@ -95,6 +95,10 @@
  /* we use the built-in I2C controller */
  #define CONFIG_DRIVER_S3C24X0_I2C

^
Can we rename this define to CONFIG_SYS_I2C_S3C24X0

include/configs/smdk5250.h line 204

Quoted 13 lines
include/configs/VCMA9.h +4 -0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
  #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
  #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
  /* use EEPROM for environment vars */ diff --git

a/include/configs/smdk5250.h b/include/configs/smdk5250.h index c0f8622..cb0f449 100644

include/configs/smdk5250.h +0 -0
@@ -204,6 +204,10 @@
  #define CONFIG_MAX_I2C_NUM	8
             ^
             Please rename
Quoted 3 lines

include/configs/smdk5250.h line 205

Quoted 1 line
include/configs/smdk5250.h +0 -0
  #define CONFIG_SYS_I2C_SLAVE    0x0
             ^
             Please rename

Ok

Quoted 11 lines

include/configs/smdk5250.h line 213

Quoted 8 lines
include/configs/smdk5250.h +4 -0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+
  /* Ethernet Controllor Driver */
  #ifdef CONFIG_CMD_NET
  #define CONFIG_SMC911X

Thanks!

Quoted 5 lines

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

Best regards,
Piotr Wilczek
--
Samsung Poland R&D Center | Linux Platform Group

#8 lore raw

PATCH 6/6 WIP: arm: trats: add support for new I2C framework

In reply to Piotr Wilczek

This enables new i2c framework on Trats board. Hardware s3c24x0 i2c driver is used instead of software i2c.

---
 board/samsung/trats/trats.c |   26 +++++++++++++++++++++-----
 include/configs/trats.h     |   16 ++++++++++++++--
 2 files changed, 35 insertions(+), 7 deletions(-)
board/samsung/trats/trats.c +21 -5
index e11a892..71e1975 100644
@@ -24,8 +24,10 @@
  */
 
 #include <common.h>
+#include <i2c.h>
 #include <lcd.h>
 #include <asm/io.h>
+#include <asm/arch/pinmux.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -61,6 +63,19 @@ static int hwrevision(int rev)
 
 struct s3c_plat_otg_data s5pc210_otg_data;
 
+void i2c_init_pinmux(void)
+{
+	int i, err;
+	for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
+		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
+						PINMUX_FLAG_NONE);
+		if (err) {
+			debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
+			return;
+		}
+	}
+}
+
 int board_init(void)
 {
 	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
@@ -68,6 +83,8 @@ int board_init(void)
 	check_hw_revision();
 	printf("HW Revision:\t0x%x\n", board_rev);
 
+	i2c_init_pinmux();
+
 #if defined(CONFIG_PMIC)
 	pmic_init();
 #endif
@@ -77,14 +94,9 @@ int board_init(void)
 
 void i2c_init_board(void)
 {
-	struct exynos4_gpio_part1 *gpio1 =
-		(struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
 	struct exynos4_gpio_part2 *gpio2 =
 		(struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
 
-	/* I2C_5 -> PMIC */
-	s5p_gpio_direction_output(&gpio1->b, 7, 1);
-	s5p_gpio_direction_output(&gpio1->b, 6, 1);
 	/* I2C_9 -> FG */
 	s5p_gpio_direction_output(&gpio2->y4, 0, 1);
 	s5p_gpio_direction_output(&gpio2->y4, 1, 1);
@@ -415,6 +427,8 @@ static int lcd_power(void)
 	int ret = 0;
 	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(0);
+
 	if (pmic_probe(p))
 		return 0;
 
@@ -475,6 +489,8 @@ static int mipi_power(void)
 	int ret = 0;
 	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(0);
+
 	if (pmic_probe(p))
 		return 0;
 
include/configs/trats.h +14 -2
index 106fd37..54423f4 100644
@@ -33,6 +33,7 @@
 #define CONFIG_SAMSUNG		/* in a SAMSUNG core */
 #define CONFIG_S5P		/* which is in a S5P Family */
 #define CONFIG_EXYNOS4210	/* which is in a EXYNOS4210 */
+#define CONFIG_EXYNOS4
 #define CONFIG_TRATS		/* working with TRATS */
 #define CONFIG_TIZEN		/* TIZEN lib */
 
@@ -211,18 +212,29 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
-
 #define CONFIG_SYS_I2C
 #define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SOFT_SPEED	50000
 #define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
-#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
 #define CONFIG_SYS_I2C_INIT_BOARD
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SOFT_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	15
 
+#define CONFIG_HARD_I2C
+#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_MAX_I2C_NUM	8
+#define CONFIG_SYS_I2C_SPEED	100000
+#define CONFIG_SYS_I2C_SLAVE	0x0
+#define CONFIG_CMD_I2C
+
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[5]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+#define CONFIG_SYS_I2C_BUSSES	{{0, {{{0, "S3C24X0"}, 0x00, 5}}}, \
+				}
+#define CONFIG_SYS_NUM_I2C_BUSSES 1
+
 #include <asm/arch/gpio.h>
 
 /* I2C PMIC */
Signature · 1 line
1.7.5.4
#9 lore raw

PATCH 6/6 WIP: arm: trats: add support for new I2C framework

Hello Piotr,

Quoted 33 lines · Piotr Wilczek

This enables new i2c framework on Trats board. Hardware s3c24x0 i2c driver is used instead of software i2c.

---
  board/samsung/trats/trats.c |   26 +++++++++++++++++++++-----
  include/configs/trats.h     |   16 ++++++++++++++--
  2 files changed, 35 insertions(+), 7 deletions(-)
board/samsung/trats/trats.c +5 -0
index e11a892..71e1975 100644
@@ -24,8 +24,10 @@
   */
 
  #include<common.h>
+#include<i2c.h>
  #include<lcd.h>
  #include<asm/io.h>
+#include<asm/arch/pinmux.h>
  #include<asm/arch/cpu.h>
  #include<asm/arch/gpio.h>
  #include<asm/arch/mmc.h>
@@ -61,6 +63,19 @@ static int hwrevision(int rev)
 
  struct s3c_plat_otg_data s5pc210_otg_data;
 
+void i2c_init_pinmux(void)
+{
+	int i, err;

board/samsung/trats/trats.c static int hwrevision(int rev) · line 78

Quoted 10 lines
board/samsung/trats/trats.c +10 -0
+	for (i = 0; i<  CONFIG_MAX_I2C_NUM; i++) {
+		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
+						PINMUX_FLAG_NONE);
+		if (err) {
+			debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
+			return;
+		}
+	}
+}
+

Is this change multibus specific? Why?

board/samsung/trats/trats.c int board_init(void) · line 87

Quoted 9 lines
board/samsung/trats/trats.c +2 -0
  int board_init(void)
  {
  	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
@@ -68,6 +83,8 @@ int board_init(void)
  	check_hw_revision();
  	printf("HW Revision:\t0x%x\n", board_rev);
 
+	i2c_init_pinmux();
+

Why this call not in i2c_init_board(void)?

Quoted 5 lines
board/samsung/trats/trats.c +0 -0
  #if defined(CONFIG_PMIC)
  	pmic_init();
  #endif
@@ -77,14 +94,9 @@ int board_init(void)
 

board/samsung/trats/trats.c int board_init(void) · line 87

Quoted 10 lines
board/samsung/trats/trats.c +0 -5
  void i2c_init_board(void)
  {
-	struct exynos4_gpio_part1 *gpio1 =
-		(struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
  	struct exynos4_gpio_part2 *gpio2 =
  		(struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
 
-	/* I2C_5 ->  PMIC */
-	s5p_gpio_direction_output(&gpio1->b, 7, 1);
-	s5p_gpio_direction_output(&gpio1->b, 6, 1);

Here again, what has this to do with the new multibus framework?

board/samsung/trats/trats.c static int lcd_power(void) · line 430

Quoted 8 lines
board/samsung/trats/trats.c +1 -0
  	/* I2C_9 ->  FG */
  	s5p_gpio_direction_output(&gpio2->y4, 0, 1);
  	s5p_gpio_direction_output(&gpio2->y4, 1, 1);
@@ -415,6 +427,8 @@ static int lcd_power(void)
  	int ret = 0;
  	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(0);

^
Fix number? Please use here a define.

Quoted 26 lines
board/samsung/trats/trats.c +3 -0
+
  	if (pmic_probe(p))
  		return 0;
 
@@ -475,6 +489,8 @@ static int mipi_power(void)
  	int ret = 0;
  	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(0);
+
  	if (pmic_probe(p))
  		return 0;
 
include/configs/trats.h +1 -0
index 106fd37..54423f4 100644
@@ -33,6 +33,7 @@
  #define CONFIG_SAMSUNG		/* in a SAMSUNG core */
  #define CONFIG_S5P		/* which is in a S5P Family */
  #define CONFIG_EXYNOS4210	/* which is in a EXYNOS4210 */
+#define CONFIG_EXYNOS4
  #define CONFIG_TRATS		/* working with TRATS */
  #define CONFIG_TIZEN		/* TIZEN lib */
 

include/configs/trats.h line 219

Quoted 9 lines
include/configs/trats.h +0 -2
@@ -211,18 +212,29 @@
  #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
  #define CONFIG_SYS_CACHELINE_SIZE       32
 
-
  #define CONFIG_SYS_I2C
  #define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
  #define CONFIG_SYS_I2C_SOFT_SPEED	50000
  #define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
-#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}

Why you delete here this adapter? You can use now in the new Framework Hard and soft i2c adapter ...

include/configs/trats.h line 225

Quoted 7 lines
include/configs/trats.h +1 -0
  #define CONFIG_SOFT_I2C_READ_REPEATED_START
  #define CONFIG_SYS_I2C_INIT_BOARD
  #define CONFIG_I2C_MULTI_BUS
  #define CONFIG_SOFT_I2C_MULTI_BUS
  #define CONFIG_SYS_MAX_I2C_BUS	15
 
+#define CONFIG_HARD_I2C

No longer needed

include/configs/trats.h line 229

Quoted 4 lines
include/configs/trats.h +4 -0
+#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_MAX_I2C_NUM	8
+#define CONFIG_SYS_I2C_SPEED	100000
+#define CONFIG_SYS_I2C_SLAVE	0x0

This defines please rename, as posted in previous EMail ...

include/configs/trats.h line 234

Quoted 5 lines
include/configs/trats.h +5 -0
+#define CONFIG_CMD_I2C
+
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[5]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+#define CONFIG_SYS_I2C_BUSSES	{{0, {{{0, "S3C24X0"}, 0x00, 5}}}, \

You use here only one bus, so you do not need to define this here.

include/configs/trats.h line 240

Quoted 6 lines
include/configs/trats.h +3 -0
+				}
+#define CONFIG_SYS_NUM_I2C_BUSSES 1
+
  #include<asm/arch/gpio.h>
 
  /* I2C PMIC */

bye,
Heiko

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

PATCH 6/6 WIP: arm: trats: add support for new I2C framework

Hello Heiko,

Quoted 52 lines

-----Original Message-----
From: Heiko Schocher [mailto:hs at denx.de]
Sent: Friday, November 16, 2012 11:46 AM
To: Piotr Wilczek
Cc: u-boot at lists.denx.de; Minkyu Kang; Kyungmin Park; Lukasz Majewski; Simon Glass; Stephen Warren; Tom Rini
Subject: Re: [PATCH 6/6] WIP: arm: trats: add support for new I2C framework

Hello Piotr,

Quoted 6 lines · Piotr Wilczek

This enables new i2c framework on Trats board. Hardware s3c24x0 i2c driver is used instead of software i2c.

Review

Quoted 6 lines
---
  board/samsung/trats/trats.c |   26 +++++++++++++++++++++-----
  include/configs/trats.h     |   16 ++++++++++++++--
  2 files changed, 35 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/board/samsung/trats/trats.c

Quoted 16 lines

index e11a892..71e1975 100644

board/samsung/trats/trats.c +2 -0
@@ -24,8 +24,10 @@
   */
 
  #include<common.h>
+#include<i2c.h>
  #include<lcd.h>
  #include<asm/io.h>
+#include<asm/arch/pinmux.h>
  #include<asm/arch/cpu.h>
  #include<asm/arch/gpio.h>
  #include<asm/arch/mmc.h>
@@ -61,6 +63,19 @@ static int hwrevision(int rev)
 

board/samsung/trats/trats.c static int hwrevision(int rev) · line 73

Quoted 10 lines
board/samsung/trats/trats.c +8 -0
  struct s3c_plat_otg_data s5pc210_otg_data;
 
+void i2c_init_pinmux(void)
+{
+	int i, err;
+	for (i = 0; i<  CONFIG_MAX_I2C_NUM; i++) {
+		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
+						PINMUX_FLAG_NONE);
+		if (err) {
+			debug("I2C%d not configured\n", (PERIPH_ID_I2C0 +

i));

Quoted 7 lines

board/samsung/trats/trats.c static int hwrevision(int rev) · line 78

Quoted 5 lines
board/samsung/trats/trats.c +5 -0
+			return;
+		}
+	}
+}
+

Is this change multibus specific? Why?

GPIO must be set to I2C function when hardware I2C driver is used. Also, because only one hardware I2C bus is used I should change pins function for I2C_5 only.

Quoted 8 lines
Quoted 8 lines
board/samsung/trats/trats.c +0 -0
  int board_init(void)
  {
  	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; @@ -68,6 +83,8 @@

int board_init(void)
check_hw_revision();
printf("HW Revision:\t0x%x\n", board_rev);

Quoted 4 lines

board/samsung/trats/trats.c int board_init(void) · line 87

Quoted 2 lines
board/samsung/trats/trats.c +2 -0
+	i2c_init_pinmux();
+

Why this call not in i2c_init_board(void)?

Ok

Quoted 13 lines
Quoted 13 lines
  #if defined(CONFIG_PMIC)
  	pmic_init();
  #endif
board/samsung/trats/trats.c +0 -2
@@ -77,14 +94,9 @@ int board_init(void)
 
  void i2c_init_board(void)
  {
-	struct exynos4_gpio_part1 *gpio1 =
-		(struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
  	struct exynos4_gpio_part2 *gpio2 =
  		(struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
 
Quoted 5 lines

board/samsung/trats/trats.c int board_init(void) · line 87

Quoted 3 lines
board/samsung/trats/trats.c +0 -3
-	/* I2C_5 ->  PMIC */
-	s5p_gpio_direction_output(&gpio1->b, 7, 1);
-	s5p_gpio_direction_output(&gpio1->b, 6, 1);

Here again, what has this to do with the new multibus framework?

Currently only software I2c is used and pins must be set as outputs. With this patchset I switch from software to hardware I2C for PMIC and I must change pins function from output to I2C.

Quoted 11 lines

board/samsung/trats/trats.c

Quoted 9 lines
board/samsung/trats/trats.c +0 -0
  	/* I2C_9 ->  FG */
  	s5p_gpio_direction_output(&gpio2->y4, 0, 1);
  	s5p_gpio_direction_output(&gpio2->y4, 1, 1); @@ -415,6 +427,8 @@

static int lcd_power(void)
int ret = 0;
struct pmic *p = get_pmic();

board/samsung/trats/trats.c +1 -0
+	i2c_set_bus_num(0);

^
Fix number? Please use here a define.

Ok

Quoted 31 lines
Quoted 27 lines
board/samsung/trats/trats.c +3 -0
+
  	if (pmic_probe(p))
  		return 0;
@@ -475,6 +489,8 @@ static int mipi_power(void)
  	int ret = 0;
  	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(0);
+
  	if (pmic_probe(p))
  		return 0;
 
include/configs/trats.h index renamed from include/configs/trats.h +0 -0

106fd37..54423f4 100644

include/configs/trats.h +1 -0
@@ -33,6 +33,7 @@
  #define CONFIG_SAMSUNG		/* in a SAMSUNG core */
  #define CONFIG_S5P		/* which is in a S5P Family */
  #define CONFIG_EXYNOS4210	/* which is in a EXYNOS4210 */
+#define CONFIG_EXYNOS4
  #define CONFIG_TRATS		/* working with TRATS */
  #define CONFIG_TIZEN		/* TIZEN lib */
 

include/configs/trats.h line 212

Quoted 1 line
include/configs/trats.h +0 -0
@@ -211,18 +212,29 @@
  #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR -

GENERATED_GBL_DATA_SIZE)

Quoted 2 lines
include/configs/trats.h +0 -0
  #define CONFIG_SYS_CACHELINE_SIZE       32
 
Quoted 9 lines

include/configs/trats.h line 219

Quoted 6 lines
include/configs/trats.h +0 -2
-
  #define CONFIG_SYS_I2C
  #define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
  #define CONFIG_SYS_I2C_SOFT_SPEED	50000
  #define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
-#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}

Why you delete here this adapter? You can use now in the new Framework Hard and soft i2c adapter ...

Yes, soft adapter should be kept.

Quoted 10 lines

include/configs/trats.h line 225

Quoted 8 lines
include/configs/trats.h +1 -0
  #define CONFIG_SOFT_I2C_READ_REPEATED_START
  #define CONFIG_SYS_I2C_INIT_BOARD
  #define CONFIG_I2C_MULTI_BUS
  #define CONFIG_SOFT_I2C_MULTI_BUS
  #define CONFIG_SYS_MAX_I2C_BUS	15
 
+#define CONFIG_HARD_I2C

No longer needed

Ok

Quoted 7 lines

include/configs/trats.h line 229

Quoted 5 lines
include/configs/trats.h +4 -0
+#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_MAX_I2C_NUM	8
+#define CONFIG_SYS_I2C_SPEED	100000
+#define CONFIG_SYS_I2C_SLAVE	0x0

This defines please rename, as posted in previous EMail ...

Ok

Quoted 8 lines

include/configs/trats.h line 234

Quoted 6 lines
include/configs/trats.h +5 -0
+#define CONFIG_CMD_I2C
+
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[5]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
+#define CONFIG_SYS_I2C_BUSSES	{{0, {{{0, "S3C24X0"}, 0x00, 5}}}, \

You use here only one bus, so you do not need to define this here.

Just testing, I will remove it.

Quoted 6 lines
Quoted 6 lines
include/configs/trats.h +3 -0
+				}
+#define CONFIG_SYS_NUM_I2C_BUSSES 1
+
  #include<asm/arch/gpio.h>
 
Quoted 7 lines

include/configs/trats.h line 240

Quoted 1 line
include/configs/trats.h +0 -0
  /* I2C PMIC */

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

Best regards,
Piotr Wilczek

#11 lore raw

v2 cover Bring new I2C framwork to Samsung Trats board

In reply to Piotr Wilczek

This patchset brings new I2C framework to Samsung Trats board.

I2C clock, spacing and pinmux are added for Exynos4. The s3c24x0 i2c driver is modified to support both Exynos4.

The s3c24x0 i2c driver is modiefied for the new I2C framework. Configs for VCMA9.h and smdk5250.h boards are modified. Boards compile successfully but were not tested.

New i2c framework is enabled and tested on Samsung Trats board.

Piotr Wilczek (6):
exynos:clock: Add i2c clock
exynos:cpu: Add Exynos4 I2C spacing exynos:pinmux: Add pinmux support for i2c drivers:i2c: Modify I2C driver for Exynos4 drivers:i2c:s3c24x0: modify driver for new I2C framework arm:trats: add support for new I2C framework

 arch/arm/cpu/armv7/exynos/clock.c      |   17 +++
 arch/arm/cpu/armv7/exynos/pinmux.c     |   64 +++++++++++
 arch/arm/include/asm/arch-exynos/cpu.h |    2 +
 board/samsung/smdk5250/smdk5250.c      |    4 +-
 board/samsung/trats/trats.c            |   17 +++-
 drivers/i2c/Makefile                   |    2 +-
 drivers/i2c/i2c_core.c                 |    5 +
 drivers/i2c/s3c24x0_i2c.c              |  181 +++++++++++++++++++++++---------
 include/configs/VCMA9.h                |   11 ++-
 include/configs/smdk5250.h             |   13 ++-
 include/configs/trats.h                |   35 ++++---
 11 files changed, 266 insertions(+), 85 deletions(-)
Signature · 1 line
1.7.5.4
#12 lore raw

PATCH v2 1/6 exynos:clock: Add i2c clock

This patch adds i2c clock for Exynos4

---
Changes for v2:
- none

---
 arch/arm/cpu/armv7/exynos/clock.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/clock.c +17 -0
index 4f3b451..21e45d2 100644
@@ -732,6 +732,21 @@ static unsigned long exynos5_get_i2c_clk(void)
 	return aclk_66;
 }
 
+static unsigned long exynos4_get_i2c_clk(void)
+{
+	struct exynos4_clock *clk =
+		(struct exynos4_clock *)samsung_get_base_clock();
+	unsigned long sclk, aclk_100;
+	unsigned int ratio;
+
+	sclk = get_pll_clk(APLL);
+
+	ratio = (readl(&clk->div_top)) >> 4;
+	ratio &= 0xf;
+	aclk_100 = sclk / (ratio + 1);
+	return aclk_100;
+}
+
 unsigned long get_pll_clk(int pllreg)
 {
 	if (cpu_is_exynos5())
@@ -752,6 +767,8 @@ unsigned long get_i2c_clk(void)
 {
 	if (cpu_is_exynos5()) {
 		return exynos5_get_i2c_clk();
+	} else if (cpu_is_exynos4()) {
+		return exynos4_get_i2c_clk();
 	} else {
 		debug("I2C clock is not set for this CPU\n");
 		return 0;
Signature · 1 line
1.7.5.4
#13 lore raw

PATCH v2 2/6 exynos:cpu: Add Exynos4 I2C spacing

In reply to Piotr Wilczek

This patch add the spacing for i2c for Exynos4

---
Changes for v2:
- none

---
 arch/arm/include/asm/arch-exynos/cpu.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-exynos/cpu.h +2 -0
index 2cd4ae1..3073ca1 100644
@@ -28,6 +28,8 @@
 #define EXYNOS4_ADDR_BASE		0x10000000
 
 /* EXYNOS4 */
+#define EXYNOS4_I2C_SPACING		0x10000
+
 #define EXYNOS4_GPIO_PART3_BASE		0x03860000
 #define EXYNOS4_PRO_ID			0x10000000
 #define EXYNOS4_SYSREG_BASE		0x10010000
Signature · 1 line
1.7.5.4
#14 lore raw

PATCH v2 3/6 exynos:pinmux: Add pinmux support for i2c

In reply to Piotr Wilczek

This patch add pinmux for I2C for Exynos4

---
Changes for v2:
- none

---
 arch/arm/cpu/armv7/exynos/pinmux.c |   64 ++++++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +64 -0
index 7776add..44ce072 100644
@@ -265,10 +265,74 @@ static int exynos5_pinmux_config(int peripheral, int flags)
 	return 0;
 }
 
+static void exynos4_i2c_config(int peripheral, int flags)
+{
+	struct exynos4_gpio_part1 *gpio1 =
+		(struct exynos4_gpio_part1 *) samsung_get_base_gpio_part1();
+
+	switch (peripheral) {
+	case PERIPH_ID_I2C0:
+		s5p_gpio_cfg_pin(&gpio1->d1, 0, GPIO_FUNC(0x2));
+		s5p_gpio_cfg_pin(&gpio1->d1, 1, GPIO_FUNC(0x2));
+		break;
+	case PERIPH_ID_I2C1:
+		s5p_gpio_cfg_pin(&gpio1->d1, 2, GPIO_FUNC(0x2));
+		s5p_gpio_cfg_pin(&gpio1->d1, 3, GPIO_FUNC(0x2));
+		break;
+	case PERIPH_ID_I2C2:
+		s5p_gpio_cfg_pin(&gpio1->a0, 6, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->a0, 7, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C3:
+		s5p_gpio_cfg_pin(&gpio1->a1, 2, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->a1, 3, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C4:
+		s5p_gpio_cfg_pin(&gpio1->b, 2, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->b, 3, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C5:
+		s5p_gpio_cfg_pin(&gpio1->b, 6, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->b, 7, GPIO_FUNC(0x3));
+		break;
+	case PERIPH_ID_I2C6:
+		s5p_gpio_cfg_pin(&gpio1->c1, 3, GPIO_FUNC(0x4));
+		s5p_gpio_cfg_pin(&gpio1->c1, 4, GPIO_FUNC(0x4));
+		break;
+	case PERIPH_ID_I2C7:
+		s5p_gpio_cfg_pin(&gpio1->d0, 2, GPIO_FUNC(0x3));
+		s5p_gpio_cfg_pin(&gpio1->d0, 3, GPIO_FUNC(0x3));
+		break;
+	}
+}
+
+static int exynos4_pinmux_config(int peripheral, int flags)
+{
+	switch (peripheral) {
+	case PERIPH_ID_I2C0:
+	case PERIPH_ID_I2C1:
+	case PERIPH_ID_I2C2:
+	case PERIPH_ID_I2C3:
+	case PERIPH_ID_I2C4:
+	case PERIPH_ID_I2C5:
+	case PERIPH_ID_I2C6:
+	case PERIPH_ID_I2C7:
+		exynos4_i2c_config(peripheral, flags);
+		break;
+	default:
+		debug("%s: invalid peripheral %d", __func__, peripheral);
+		return -1;
+	}
+
+	return 0;
+}
+
 int exynos_pinmux_config(int peripheral, int flags)
 {
 	if (cpu_is_exynos5())
 		return exynos5_pinmux_config(peripheral, flags);
+	else if (cpu_is_exynos4())
+		return exynos4_pinmux_config(peripheral, flags);
 	else {
 		debug("pinmux functionality not supported\n");
 		return -1;
Signature · 1 line
1.7.5.4
#15 lore raw

PATCH v2 4/6 drivers:i2c: Modify I2C driver for Exynos4

In reply to Piotr Wilczek

This patch modifies the S3C i2c driver to support both Exynos4 and Exynos5

---
Changes for v2:
- none

---
 drivers/i2c/s3c24x0_i2c.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
drivers/i2c/s3c24x0_i2c.c +12 -7
index 9bc4c7f..90d297a 100644
@@ -27,7 +27,7 @@
  */
 
 #include <common.h>
-#ifdef CONFIG_EXYNOS5
+#if (defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 #include <asm/arch/clk.h>
 #include <asm/arch/cpu.h>
 #else
@@ -62,7 +62,7 @@
 
 static unsigned int g_current_bus;	/* Stores Current I2C Bus */
 
-#ifndef CONFIG_EXYNOS5
+#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 static int GetI2CSDA(void)
 {
 	struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
@@ -121,7 +121,12 @@ static void ReadWriteByte(struct s3c24x0_i2c *i2c)
 
 static struct s3c24x0_i2c *get_base_i2c(void)
 {
-#ifdef CONFIG_EXYNOS5
+#ifdef CONFIG_EXYNOS4
+	struct s3c24x0_i2c *i2c = (struct s3c24x0_i2c *)(samsung_get_base_i2c()
+							+ (EXYNOS4_I2C_SPACING
+							* g_current_bus));
+	return i2c;
+#elif defined CONFIG_EXYNOS5
 	struct s3c24x0_i2c *i2c = (struct s3c24x0_i2c *)(samsung_get_base_i2c()
 							+ (EXYNOS5_I2C_SPACING
 							* g_current_bus));
@@ -134,7 +139,7 @@ static struct s3c24x0_i2c *get_base_i2c(void)
 static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
 {
 	ulong freq, pres = 16, div;
-#ifdef CONFIG_EXYNOS5
+#if (defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 	freq = get_i2c_clk();
 #else
 	freq = get_PCLK();
@@ -188,7 +193,7 @@ unsigned int i2c_get_bus_num(void)
 void i2c_init(int speed, int slaveadd)
 {
 	struct s3c24x0_i2c *i2c;
-#ifndef CONFIG_EXYNOS5
+#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 	struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
 #endif
 	int i;
@@ -204,7 +209,7 @@ void i2c_init(int speed, int slaveadd)
 		i--;
 	}
 
-#ifndef CONFIG_EXYNOS5
+#if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 	if ((readl(&i2c->iicstat) & I2CSTAT_BSY) || GetI2CSDA() == 0) {
 #ifdef CONFIG_S3C2410
 		ulong old_gpecon = readl(&gpio->gpecon);
@@ -248,7 +253,7 @@ void i2c_init(int speed, int slaveadd)
 		writel(old_gpecon, &gpio->pgcon);
 #endif
 	}
-#endif /* #ifndef CONFIG_EXYNOS5 */
+#endif /* #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5) */
 	i2c_ch_init(i2c, speed, slaveadd);
 }
 
Signature · 1 line
1.7.5.4
#16 lore raw

PATCH v2 5/6 drivers:i2c:s3c24x0: modify driver for new I2C framework

In reply to Piotr Wilczek

This patch modifies s3c24x0 driver for the new I2C framework. Configs of VCMA9.h and smdk5250.h boards are modified but not tested.

---
Changes for v2:
- changed i2c related names to s3c24x0 driver specfic:

	CONFIG_MAX_I2C_NUM -> CONFIG_SYS_I2C_S3C24X0_MAX_NUM
	CONFIG_DRIVER_S3C24X0_I2C -> CONFIG_SYS_I2C_S3C24X0
	CONFIG_SYS_I2C_SPEED/SLAVE -> CONFIG_SYS_I2C_S3C24X0_SPEED/SLAVE

- removed CONFIG_HARD_I2C
- removed g_current_bus and i2c_{get/set}_bus_num() functions
- changed function get_base_i2c(void) to get_base_i2c(int bus)
- made all functions static

---
 board/samsung/smdk5250/smdk5250.c |    4 +-
 drivers/i2c/Makefile              |    2 +-
 drivers/i2c/i2c_core.c            |    5 +
 drivers/i2c/s3c24x0_i2c.c         |  164 ++++++++++++++++++++++++++----------
 include/configs/VCMA9.h           |   11 ++-
 include/configs/smdk5250.h        |   13 ++--
 6 files changed, 140 insertions(+), 59 deletions(-)
board/samsung/smdk5250/smdk5250.c +2 -2
index a5816e4..0bc161a 100644
@@ -178,7 +178,7 @@ static int board_i2c_init(void)
 {
 	int i, err;
 
-	for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
+	for (i = 0; i < CONFIG_SYS_I2C_S3C24X0_MAX_NUM; i++) {
 		err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
 						PINMUX_FLAG_NONE);
 		if (err) {
@@ -186,7 +186,7 @@ static int board_i2c_init(void)
 			return err;
 		}
 	}
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_init(CONFIG_SYS_I2C_S3C24X0_SPEED, CONFIG_SYS_I2C_S3C24X0_SLAVE);
 	return 0;
 }
 #endif
drivers/i2c/Makefile +1 -1
index 2162173..09279d0 100644
@@ -37,7 +37,7 @@ COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
 COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
 COBJS-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
 COBJS-$(CONFIG_PPC4XX_I2C) += ppc4xx_i2c.o
-COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
+COBJS-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o
 COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
 COBJS-$(CONFIG_TEGRA_I2C) += tegra_i2c.o
 COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
drivers/i2c/i2c_core.c +5 -0
index d3b5a8d..143a062 100644
@@ -10,6 +10,10 @@
 extern struct i2c_adapter fsl_i2c_adap[];
 #endif
 
+#ifdef CONFIG_SYS_I2C_S3C24X0
+extern struct i2c_adapter s3c24x0_i2c_adap[];
+#endif
+
 #ifdef CONFIG_SYS_I2C_SOFT
 extern struct i2c_adapter soft_i2c_adap[];
 #endif
@@ -214,6 +218,7 @@ unsigned int i2c_get_bus_num(void)
  */
 int i2c_set_bus_num(unsigned int bus)
 {
+
 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
 	int		i;
 	uint8_t	buf;
drivers/i2c/s3c24x0_i2c.c +118 -46

237 lines not on this page · raw message

include/configs/VCMA9.h +7 -4
index fb7d922..23c9285 100644
@@ -88,12 +88,15 @@
  * the MPL VCMA9 is equipped with an ATMEL 24C256 EEPROM at
  * address 0x50 with 16bit addressing
  */
-#define CONFIG_HARD_I2C				/* I2C with hardware support */
-#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed */
-#define CONFIG_SYS_I2C_SLAVE		0x7F	/* I2C slave addr */
+#define CONFIG_SYS_I2C_S3C24X0_SPEED		100000	/* I2C speed */
+#define CONFIG_SYS_I2C_S3C24X0_SLAVE		0x7F	/* I2C slave addr */
 
 /* we use the built-in I2C controller */
-#define CONFIG_DRIVER_S3C24X0_I2C
+#define CONFIG_SYS_I2C_S3C24X0
+
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
include/configs/smdk5250.h +7 -6
index c0f8622..2de5d5c 100644
@@ -196,13 +196,14 @@
 
 /* I2C */
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_HARD_I2C
 #define CONFIG_CMD_I2C
-#define CONFIG_SYS_I2C_SPEED	100000		/* 100 Kbps */
-#define CONFIG_DRIVER_S3C24X0_I2C
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_MAX_I2C_NUM	8
-#define CONFIG_SYS_I2C_SLAVE    0x0
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_S3C24X0
+#define CONFIG_SYS_I2C_S3C24X0_MAX_NUM	8
+#define CONFIG_SYS_I2C_S3C24X0_SPEED	100000		/* 100 Kbps */
+#define CONFIG_SYS_I2C_S3C24X0_SLAVE    0x0
+#define CONFIG_SYS_I2C_ADAPTERS		{&s3c24x0_i2c_adap[0]}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 1
 
 /* Ethernet Controllor Driver */
 #ifdef CONFIG_CMD_NET
Signature · 1 line
1.7.5.4
#17 lore raw

PATCH v2 6/6 arm:trats: add support for new I2C framework

In reply to Piotr Wilczek

This enables new i2c framework on Trats board. Hardware s3c24x0 i2c driver is used instead of software i2c.

---
Changes for v2:
- hardware i2c outputs configuration moved to i2c_init_board(void) function
- used define instead of fix number on i2c_set_bus_num();
- keep soft_i2c_adap[0]
- changed i2c related names to s3c24x0 driver specfic:

	CONFIG_MAX_I2C_NUM -> CONFIG_SYS_I2C_S3C24X0_MAX_NUM
	CONFIG_DRIVER_S3C24X0_I2C -> CONFIG_SYS_I2C_S3C24X0
	CONFIG_SYS_I2C_SPEED/SLAVE -> CONFIG_SYS_I2C_S3C24X0_SPEED/SLAVE
- removed CONFIG_SYS_I2C_BUSSES
---
 board/samsung/trats/trats.c |   17 +++++++++++++----
 include/configs/trats.h     |   35 +++++++++++++++++++----------------
 2 files changed, 32 insertions(+), 20 deletions(-)
board/samsung/trats/trats.c +13 -4
index e11a892..393a910 100644
@@ -24,8 +24,10 @@
  */
 
 #include <common.h>
+#include <i2c.h>
 #include <lcd.h>
 #include <asm/io.h>
+#include <asm/arch/pinmux.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -77,14 +79,17 @@ int board_init(void)
 
 void i2c_init_board(void)
 {
-	struct exynos4_gpio_part1 *gpio1 =
-		(struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
+	int err;
 	struct exynos4_gpio_part2 *gpio2 =
 		(struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
 
 	/* I2C_5 -> PMIC */
-	s5p_gpio_direction_output(&gpio1->b, 7, 1);
-	s5p_gpio_direction_output(&gpio1->b, 6, 1);
+	err = exynos_pinmux_config(I2C_5, PINMUX_FLAG_NONE);
+	if (err) {
+		debug("I2C%d not configured\n", (I2C_5));
+		return;
+	}
+
 	/* I2C_9 -> FG */
 	s5p_gpio_direction_output(&gpio2->y4, 0, 1);
 	s5p_gpio_direction_output(&gpio2->y4, 1, 1);
@@ -415,6 +420,8 @@ static int lcd_power(void)
 	int ret = 0;
 	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(CONFIG_SYS_I2C_PMIC_BUS_NUM);
+
 	if (pmic_probe(p))
 		return 0;
 
@@ -475,6 +482,8 @@ static int mipi_power(void)
 	int ret = 0;
 	struct pmic *p = get_pmic();
 
+	i2c_set_bus_num(CONFIG_SYS_I2C_PMIC_BUS_NUM);
+
 	if (pmic_probe(p))
 		return 0;
 
include/configs/trats.h +19 -16
index 106fd37..1083e9b 100644
@@ -33,6 +33,7 @@
 #define CONFIG_SAMSUNG		/* in a SAMSUNG core */
 #define CONFIG_S5P		/* which is in a S5P Family */
 #define CONFIG_EXYNOS4210	/* which is in a EXYNOS4210 */
+#define CONFIG_EXYNOS4
 #define CONFIG_TRATS		/* working with TRATS */
 #define CONFIG_TIZEN		/* TIZEN lib */
 
@@ -211,31 +212,33 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
-
 #define CONFIG_SYS_I2C
 #define CONFIG_SYS_I2C_SOFT		/* I2C bit-banged */
 #define CONFIG_SYS_I2C_SOFT_SPEED	50000
 #define CONFIG_SYS_I2C_SOFT_SLAVE	0xFE
-#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0]}
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
 #define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SOFT_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS	15
-
-#include <asm/arch/gpio.h>
 
-/* I2C PMIC */
-#define CONFIG_SOFT_I2C_I2C5_SCL exynos4_gpio_part1_get_nr(b, 7)
-#define CONFIG_SOFT_I2C_I2C5_SDA exynos4_gpio_part1_get_nr(b, 6)
+#define CONFIG_SYS_I2C_S3C24X0
+#define CONFIG_SYS_I2C_S3C24X0_MAX_NUM	8
+#define CONFIG_SYS_I2C_S3C24X0_SPEED	100000
+#define CONFIG_SYS_I2C_S3C24X0_SLAVE	0x0
+#define CONFIG_CMD_I2C
+
+#define CONFIG_SYS_I2C_ADAPTERS		{&soft_i2c_adap[0], \
+					&s3c24x0_i2c_adap[5], \
+					}
+#define CONFIG_SYS_NUM_I2C_ADAPTERS 2
+#define CONFIG_SYS_I2C_BUSSES		{{0, {{{0, "SOFT"}, 0x00, 0} } }, \
+					{1, {{{0, "S3C24X0"}, 0x00, 5} } }, \
+					}
+#define CONFIG_SYS_NUM_I2C_BUSSES	2
+#define CONFIG_SYS_I2C_PMIC_BUS_NUM	1
 
-/* I2C FG */
-#define CONFIG_SOFT_I2C_I2C9_SCL exynos4_gpio_part2_get_nr(y4, 1)
-#define CONFIG_SOFT_I2C_I2C9_SDA exynos4_gpio_part2_get_nr(y4, 0)
+#include <asm/arch/gpio.h>
 
-#define CONFIG_SOFT_I2C_GPIO_SCL get_multi_scl_pin()
-#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()
-#define I2C_INIT multi_i2c_init()
+#define CONFIG_SOFT_I2C_GPIO_SCL exynos4_gpio_part2_get_nr(y4, 1)
+#define CONFIG_SOFT_I2C_GPIO_SDA exynos4_gpio_part2_get_nr(y4, 0)
 
 #define CONFIG_PMIC
 #define CONFIG_PMIC_I2C
Signature · 1 line
1.7.5.4