Skip to contentSkip to conversation

arm nomadik: add i2c

PATCH New Heiko Schocher 3 participants 10 messages Jul 27, 2009 – Jul 28, 2009 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 0e975ff141a9923b58859fad00cf3df664f2fe04.1248427487.git.rubini@unipv.it

A message that is not in the archive (sent off-list or not yet received): 0b10781c46b757737db8ff5e49c2b8b745c9f269.1248427487.git.rubini@unipv.it

#2 lore raw

PATCH v2 2/2 arm nomadik: add i2c

Hello Alessandro,

Quoted 9 lines · Alessandro Rubini

From: Alessandro Rubini <[email protected]>

---
 board/st/nhk8815/nhk8815.c |   16 ++++++++++++++--
 include/configs/nhk8815.h  |   18 +++++++++++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

bye
Heiko

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

PATCH v2 2/2 arm nomadik: add i2c

In reply to a message not in the archive
Quoted 16 lines

}

include/configs/nhk8815.h +1 -1
index 3e2e09f..8a83d92 100644
@@ -93,7 +93,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* for initial data */
 #define CONFIG_SYS_64BIT_VSPRINTF	/* mtd desires this */
 
-#define CONFIG_MISC_INIT_R	/* call misc_init_r during start up */
+#define BOARD_LATE_INIT		/* call board_late_init during start up */
 
 /* timing informazion */
 #define CONFIG_SYS_HZ		1000 /* Mandatory... */

include/configs/nhk8815.h line 115

Quoted 6 lines
include/configs/nhk8815.h +3 -0
@@ -110,6 +110,22 @@
 #define CONFIG_PL01x_PORTS	{ (void *)CFG_SERIAL0, (void *)CFG_SERIAL1 }
 #define CONFIG_PL011_CLOCK	48000000
 
+/* i2c, for the port extenders (uses gpio.c in board directory) */
+#ifndef __ASSEMBLY__
+#include <asm/arch/gpio.h>

I really do not like to include file from the config and it will be difficult to clean up when moving to Kconfig

include/configs/nhk8815.h line 126

Quoted 11 lines
include/configs/nhk8815.h +11 -0
+#define CONFIG_CMD_I2C
+#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SPEED	400000
+#define __SDA			63
+#define __SCL			62
+#define I2C_SDA(x)		nmk_gpio_set(__SDA, x)
+#define I2C_SCL(x)		nmk_gpio_set(__SCL, x)
+#define I2C_READ		(nmk_gpio_get(__SDA)!=0)
+#define I2C_ACTIVE		nmk_gpio_dir(__SDA, 1)
+#define I2C_TRISTATE		nmk_gpio_dir(__SDA, 0)
+#define I2C_DELAY     (udelay(2))

it will better to define a couple of generic function where we implement it as this
i2c_sda()
i2c_scl()
i2c_read()
i2c_activate()
i2c_tristate()
i2c_delay()
i2c_get_bus_num()
i2c_set_bus_num()
i2c_get_bus_speed()
i2c_set_bus_speed()
i2c_init()

Best Regards,
J.

#4 lore raw

PATCH v2 2/2 arm nomadik: add i2c

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 10 lines · In message <[email protected]> you wrote:

Review line 115

Quoted 8 lines
(quoted diff) +3 -0
@@ -110,6 +110,22 @@
 #define CONFIG_PL01x_PORTS	{ (void *)CFG_SERIAL0, (void *)CFG_SERIAL1 }
 #define CONFIG_PL011_CLOCK	48000000
 
+/* i2c, for the port extenders (uses gpio.c in board directory) */
+#ifndef __ASSEMBLY__
+#include <asm/arch/gpio.h>

I really do not like to include file from the config and it will be difficult to clean up when moving to Kconfig

But this is what many other boards are doing as well:

	$ grep '#[ 	]*include' include/configs/* | wc -l
	591
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5 -0
+#define CONFIG_CMD_I2C
+#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SPEED	400000
+#define __SDA			63
+#define __SCL			62
Quoted 8 lines

Review line 126

Quoted 6 lines
(quoted diff) +6 -0
+#define I2C_SDA(x)		nmk_gpio_set(__SDA, x)
+#define I2C_SCL(x)		nmk_gpio_set(__SCL, x)
+#define I2C_READ		(nmk_gpio_get(__SDA)!=0)
+#define I2C_ACTIVE		nmk_gpio_dir(__SDA, 1)
+#define I2C_TRISTATE		nmk_gpio_dir(__SDA, 0)
+#define I2C_DELAY     (udelay(2))

it will better to define a couple of generic function where we implement it as this

But that's how the CONFIG_SOFT_I2C interface is currently designed and used by all other boards, too.

See for example here:

	$ grep I2C_ include/configs/TQM885D.h 
	#define CONFIG_SYS_I2C_SPEED            93000   /* 93 kHz is supposed to work   */
	#define CONFIG_SYS_I2C_SLAVE            0xFE
	#define I2C_INIT        (immr->im_cpm.cp_pbdir |=  PB_SCL)
	#define I2C_ACTIVE      (immr->im_cpm.cp_pbdir |=  PB_SDA)
	#define I2C_TRISTATE    (immr->im_cpm.cp_pbdir &= ~PB_SDA)
	#define I2C_READ        ((immr->im_cpm.cp_pbdat & PB_SDA) != 0)
	#define I2C_SDA(bit)    if(bit) immr->im_cpm.cp_pbdat |=  PB_SDA; \
	#define I2C_SCL(bit)    if(bit) immr->im_cpm.cp_pbdat |=  PB_SCL; \
	#define I2C_DELAY       udelay(2)       /* 1/4 I2C clock duration */
	#define CONFIG_SYS_I2C_EEPROM_ADDR      0x50            /* EEPROM AT24C??       */
	#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2                /* two byte address     */
	# define CONFIG_SYS_I2C_RTC_ADDR 0x68

We should not attempt to change the design of the soft-I2C driver at this point in a release cycle.

If you care about these things, you should have posted such comments when Heiko asked for comments more than 4 months ago, see
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/56416

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If a train station is a place where a train stops,
                                           then what's a workstation?
#5 lore raw

PATCH v2 2/2 arm nomadik: add i2c

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hello Jean-Christophe,

Quoted 40 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 16 lines

}

include/configs/nhk8815.h +1 -1
index 3e2e09f..8a83d92 100644
@@ -93,7 +93,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* for initial data */
 #define CONFIG_SYS_64BIT_VSPRINTF	/* mtd desires this */
 
-#define CONFIG_MISC_INIT_R	/* call misc_init_r during start up */
+#define BOARD_LATE_INIT		/* call board_late_init during start up */
 
 /* timing informazion */
 #define CONFIG_SYS_HZ		1000 /* Mandatory... */

include/configs/nhk8815.h line 115

Quoted 6 lines
include/configs/nhk8815.h +3 -0
@@ -110,6 +110,22 @@
 #define CONFIG_PL01x_PORTS	{ (void *)CFG_SERIAL0, (void *)CFG_SERIAL1 }
 #define CONFIG_PL011_CLOCK	48000000
 
+/* i2c, for the port extenders (uses gpio.c in board directory) */
+#ifndef __ASSEMBLY__
+#include <asm/arch/gpio.h>

I really do not like to include file from the config and it will be difficult to clean up when moving to Kconfig

include/configs/nhk8815.h line 126

Quoted 11 lines
include/configs/nhk8815.h +11 -0
+#define CONFIG_CMD_I2C
+#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SPEED	400000
+#define __SDA			63
+#define __SCL			62
+#define I2C_SDA(x)		nmk_gpio_set(__SDA, x)
+#define I2C_SCL(x)		nmk_gpio_set(__SCL, x)
+#define I2C_READ		(nmk_gpio_get(__SDA)!=0)
+#define I2C_ACTIVE		nmk_gpio_dir(__SDA, 1)
+#define I2C_TRISTATE		nmk_gpio_dir(__SDA, 0)
+#define I2C_DELAY     (udelay(2))

it will better to define a couple of generic function where we implement it as this
i2c_sda()
i2c_scl()
i2c_read()

Quoted 8 lines

i2c_activate()
i2c_tristate()
i2c_delay()
i2c_get_bus_num()
i2c_set_bus_num()
i2c_get_bus_speed()
i2c_set_bus_speed()
i2c_init()

I posted such a suggestion in this thread, see:
http://lists.denx.de/pipermail/u-boot/2009-July/056934.html

I got no responses for this suggestion, so I talked with Wolfgang, and he convinced me, that this is not necessary.

bye
Heiko

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

PATCH v2 2/2 arm nomadik: add i2c

Quoted 52 lines · Heiko Schocher

Hello Jean-Christophe,

Quoted 40 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 16 lines

}

include/configs/nhk8815.h +1 -1
index 3e2e09f..8a83d92 100644
@@ -93,7 +93,7 @@
 #define CONFIG_SYS_GBL_DATA_SIZE	128	/* for initial data */
 #define CONFIG_SYS_64BIT_VSPRINTF	/* mtd desires this */
 
-#define CONFIG_MISC_INIT_R	/* call misc_init_r during start up */
+#define BOARD_LATE_INIT		/* call board_late_init during start up */
 
 /* timing informazion */
 #define CONFIG_SYS_HZ		1000 /* Mandatory... */

include/configs/nhk8815.h line 115

Quoted 6 lines
include/configs/nhk8815.h +3 -0
@@ -110,6 +110,22 @@
 #define CONFIG_PL01x_PORTS	{ (void *)CFG_SERIAL0, (void *)CFG_SERIAL1 }
 #define CONFIG_PL011_CLOCK	48000000
 
+/* i2c, for the port extenders (uses gpio.c in board directory) */
+#ifndef __ASSEMBLY__
+#include <asm/arch/gpio.h>

I really do not like to include file from the config and it will be difficult to clean up when moving to Kconfig

include/configs/nhk8815.h line 126

Quoted 11 lines
include/configs/nhk8815.h +11 -0
+#define CONFIG_CMD_I2C
+#define CONFIG_SOFT_I2C
+#define CONFIG_SYS_I2C_SPEED	400000
+#define __SDA			63
+#define __SCL			62
+#define I2C_SDA(x)		nmk_gpio_set(__SDA, x)
+#define I2C_SCL(x)		nmk_gpio_set(__SCL, x)
+#define I2C_READ		(nmk_gpio_get(__SDA)!=0)
+#define I2C_ACTIVE		nmk_gpio_dir(__SDA, 1)
+#define I2C_TRISTATE		nmk_gpio_dir(__SDA, 0)
+#define I2C_DELAY     (udelay(2))

it will better to define a couple of generic function where we implement it as this
i2c_sda()
i2c_scl()
i2c_read()

Quoted 8 lines

i2c_activate()
i2c_tristate()
i2c_delay()
i2c_get_bus_num()
i2c_set_bus_num()
i2c_get_bus_speed()
i2c_set_bus_speed()
i2c_init()

Quoted 2 lines

I posted such a suggestion in this thread, see:
http://lists.denx.de/pipermail/u-boot/2009-July/056934.html

sorry I've not seen yet it but full ack of the proposition :)

Quoted 3 lines

I got no responses for this suggestion, so I talked with Wolfgang, and he convinced me, that this is not necessary.

Best Regards,
J.

#7 lore raw

PATCH v2 2/2 arm nomadik: add i2c

In reply to Heiko Schocher
Quoted 14 lines
Quoted 5 lines

it will better to define a couple of generic function where we implement it as this
i2c_sda()
i2c_scl()
i2c_read()

Quoted 8 lines

i2c_activate()
i2c_tristate()
i2c_delay()
i2c_get_bus_num()
i2c_set_bus_num()
i2c_get_bus_speed()
i2c_set_bus_speed()
i2c_init()

Quoted 2 lines

I posted such a suggestion in this thread, see:
http://lists.denx.de/pipermail/u-boot/2009-July/056934.html

I've forget to mention it but we offcource can do it in 2 step

so you have my ack to applied it with the gpio patch as IMHO it more i2c than ARM

Best Regards,
J.

#8 lore raw

PATCH v2 2/2 arm nomadik: add i2c

Hello Jean-Christophe,

Quoted 13 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 13 lines
Quoted 13 lines

it will better to define a couple of generic function where we implement it as this
i2c_sda()
i2c_scl()
i2c_read()
i2c_activate()
i2c_tristate()
i2c_delay()
i2c_get_bus_num()
i2c_set_bus_num()
i2c_get_bus_speed()
i2c_set_bus_speed()
i2c_init()

Quoted 6 lines
Quoted 2 lines

I posted such a suggestion in this thread, see:
http://lists.denx.de/pipermail/u-boot/2009-July/056934.html

I've forget to mention it but we offcource can do it in 2 step

so you have my ack to applied it with the gpio patch as IMHO it more i2c than ARM

OK, so I pick up this two patches with your Acked-by.

bye
Heiko

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

PATCH v2 2/2 arm nomadik: add i2c

In reply to a message not in the archive

Hello Alessandro

Quoted 9 lines · Alessandro Rubini

From: Alessandro Rubini <[email protected]>

---
 board/st/nhk8815/nhk8815.c |   16 ++++++++++++++--
 include/configs/nhk8815.h  |   18 +++++++++++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

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

PATCH v2 1/2 arm nomadik: add gpio support

In reply to a message not in the archive
Quoted 5 lines · Alessandro Rubini

From: Alessandro Rubini <[email protected]>

Quoted 7 lines
---
 cpu/arm926ejs/nomadik/Makefile      |    2 +-
 cpu/arm926ejs/nomadik/gpio.c        |   99 +++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-nomadik/gpio.h |   42 +++++++++++++++
 3 files changed, 142 insertions(+), 1 deletions(-)
 create mode 100644 cpu/arm926ejs/nomadik/gpio.c
 create mode 100644 include/asm-arm/arch-nomadik/gpio.h

Best Regards,
J.

#11 lore raw

PATCH v2 1/2 arm nomadik: add gpio support

In reply to a message not in the archive

Hello Alessandro,

Quoted 5 lines · Alessandro Rubini

From: Alessandro Rubini <[email protected]>

Quoted 7 lines
---
 cpu/arm926ejs/nomadik/Makefile      |    2 +-
 cpu/arm926ejs/nomadik/gpio.c        |   99 +++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-nomadik/gpio.h |   42 +++++++++++++++
 3 files changed, 142 insertions(+), 1 deletions(-)
 create mode 100644 cpu/arm926ejs/nomadik/gpio.c
 create mode 100644 include/asm-arm/arch-nomadik/gpio.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