Skip to contentSkip to conversation

i2c:soft:multi: Support for multiple soft I2C buses at TRATS

PATCH Superseded Lukasz Majewski 3 participants 24 messages Aug 28, 2012 – Sep 12, 2012 I2C

lore
Share & tools
lore
#0 lore raw

cover i2c:soft:multi: Support for multiple soft I2C buses at TRATS

Support for multiple I2C buses handling on Samsung's TRATS development board.

Those patches add multiple I2C support at soft_i2c.c code and enables it at Trats development board.

Lukasz Majewski (2):
i2c:soft:multi: Support for multiple soft I2C buses i2c:soft:multi: Enable soft I2C multibus at Trats development board

 drivers/i2c/soft_i2c.c  |   41 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats.h |   19 +++++++++++++------
 include/i2c.h           |   17 +++++++++++++++++
 3 files changed, 71 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Support for multiple soft I2C buses at soft_i2c.c

This approach defines get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Up to CONFIG_SYS_MAX_I2C_BUS devices can be utilized. Common definition of I2C_X I2C buses is provided.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
 drivers/i2c/soft_i2c.c |   41 +++++++++++++++++++++++++++++++++++++++++
 include/i2c.h          |   17 +++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
drivers/i2c/soft_i2c.c +41 -0
index 36c6114..7901f04 100644
@@ -127,6 +127,15 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(CONFIG_I2C_MULTI_BUS)
 static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
+const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS] = {
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	"soft_i2c_4",
+	"soft_i2c_5",
+	NULL,
+};
 #endif /* CONFIG_I2C_MULTI_BUS */
 
 /*-----------------------------------------------------------------------
@@ -482,3 +491,35 @@ int  i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 	send_stop();
 	return(failures);
 }
+
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */
include/i2c.h +17 -0
index 1f35acf..d563d62 100644
@@ -250,4 +250,21 @@ static inline void I2C_SET_BUS(unsigned int bus)
 		i2c_set_bus_num(bus);
 }
 
+/* Multi I2C busses handling */
+#if (defined(CONFIG_SOFT_I2C) && defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+	I2C_2,
+	I2C_3,
+	I2C_4,
+	I2C_5,
+	I2C_6
+};
+
+extern const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS];
+extern int get_multi_scl_pin(void);
+extern int get_multi_sda_pin(void);
+extern int multi_i2c_init(void);
+#endif
 #endif	/* _I2C_H_ */
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Hello Lukasz,

Quoted 25 lines · Lukasz Majewski

Support for multiple soft I2C buses at soft_i2c.c

This approach defines get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Up to CONFIG_SYS_MAX_I2C_BUS devices can be utilized. Common definition of I2C_X I2C buses is provided.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
  drivers/i2c/soft_i2c.c |   41 +++++++++++++++++++++++++++++++++++++++++
  include/i2c.h          |   17 +++++++++++++++++
  2 files changed, 58 insertions(+), 0 deletions(-)
drivers/i2c/soft_i2c.c +0 -0
index 36c6114..7901f04 100644
@@ -127,6 +127,15 @@ DECLARE_GLOBAL_DATA_PTR;
 
  #if defined(CONFIG_I2C_MULTI_BUS)

drivers/i2c/soft_i2c.c DECLARE_GLOBAL_DATA_PTR; · line 138

Quoted 10 lines
drivers/i2c/soft_i2c.c +9 -0
  static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
+const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS] = {
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	"soft_i2c_4",
+	"soft_i2c_5",
+	NULL,
+};

For what do you need "soft_i2c_name"? I see no usage of this in your patchset? Also why the "NULL" for 0-3 and 6 positions?

And what is, if CONFIG_SYS_MAX_I2C_BUS is < 7 ?

Quoted 29 lines
drivers/i2c/soft_i2c.c +22 -0
  #endif /* CONFIG_I2C_MULTI_BUS */
 
  /*-----------------------------------------------------------------------
@@ -482,3 +491,35 @@ int  i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
  	send_stop();
  	return(failures);
  }
+
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;

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

Quoted 10 lines
drivers/i2c/soft_i2c.c +10 -0
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */

Again, what is with busnr = 0-3 or 6?

This is not needed in the i2c soft file. You can define this functions board specific ... so, no change in the driver is needed ... please move this to board specific code.

Quoted 16 lines
include/i2c.h +8 -0
index 1f35acf..d563d62 100644
@@ -250,4 +250,21 @@ static inline void I2C_SET_BUS(unsigned int bus)
  		i2c_set_bus_num(bus);
  }
 
+/* Multi I2C busses handling */
+#if (defined(CONFIG_SOFT_I2C)&&  defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+	I2C_2,
+	I2C_3,
+	I2C_4,

include/i2c.h static inline void I2C_SET_BUS(unsigned int bus) · line 270

Quoted 10 lines
include/i2c.h +9 -0
+	I2C_5,
+	I2C_6
+};
+
+extern const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS];
+extern int get_multi_scl_pin(void);
+extern int get_multi_sda_pin(void);
+extern int multi_i2c_init(void);
+#endif
  #endif	/* _I2C_H_ */

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 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Hi Heiko,

Quoted 16 lines

drivers/i2c/soft_i2c.c DECLARE_GLOBAL_DATA_PTR; · line 138

Quoted 12 lines

#if defined(CONFIG_I2C_MULTI_BUS)
static unsigned int i2c_bus_num __attribute__ ((section
(".data"))) = 0; +const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS] = {

drivers/i2c/soft_i2c.c +8 -0
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	"soft_i2c_4",
+	"soft_i2c_5",
+	NULL,
+};  

For what do you need "soft_i2c_name"? I see no usage of this in your patchset? Also why the "NULL" for 0-3 and 6 positions?

Quoted 1 line

And what is, if CONFIG_SYS_MAX_I2C_BUS is < 7 ?

Indeed this can be removed - it is not needed (for now).

Quoted 34 lines
Quoted 21 lines
drivers/i2c/soft_i2c.c +21 -0
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;

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

Quoted 10 lines
drivers/i2c/soft_i2c.c +10 -0
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */  

Again, what is with busnr = 0-3 or 6?

Quoted 3 lines

This is not needed in the i2c soft file. You can define this functions board specific ... so, no change in the driver is needed ... please move this to board specific code.

Please consider, that get_multi_{sda|scl}_pin can be used by other boards. Those are written in a generic way (by calling I2C_GET_BUS()).

What here I'm trying to avoid is the code duplication for each board (e.g. Samsung's GONI, Universal, Trats, Origen ... etc).
I can agree, that now only I2C_{4|5} are defined (since for now Samsung is using I2C_4 and I2C_5).

But other cases can be also defined.

What I see even more important is a definition of (at <i2c.h>):

+#if (defined(CONFIG_SOFT_I2C)&& defined(CONFIG_I2C_MULTI_BUS)) +enum {
+ I2C_0,
+ I2C_1,
+ I2C_2,
+ I2C_3,
+ I2C_4,
+ I2C_5,
+ I2C_6
+};

since this will organize the order of multiple (soft) I2C devices.

Imagine that 2 PMICs are on the board (I2C_4 and I2C_5). I need to distinct those (when calling I2C_SET|GET_BUS)
And then support for another I2C device (e.g. I2C_2) at other subsystem is provided.
Then I can:
1. Add common definition of I2C_X (as I've proposed) to <i2c.h>
2. Add #define I2C_X on the ./include/configs/{e.g. trats}.h board.

For second approach used I need to duplicate the code for other targets (goni, universal, origen) when needed and I cannot avoid that someone else will define other names -> like #define MINE_I2C_X on his/her ./include/configs/{board}.h

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#4 lore raw

PATCH 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Hello Lukasz,

Quoted 18 lines · Lukasz Majewski

Hi Heiko,

Quoted 16 lines

drivers/i2c/soft_i2c.c DECLARE_GLOBAL_DATA_PTR; · line 138

Quoted 12 lines

#if defined(CONFIG_I2C_MULTI_BUS)
static unsigned int i2c_bus_num __attribute__ ((section
(".data"))) = 0; +const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS] = {

drivers/i2c/soft_i2c.c +8 -0
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	"soft_i2c_4",
+	"soft_i2c_5",
+	NULL,
+};

For what do you need "soft_i2c_name"? I see no usage of this in your patchset? Also why the "NULL" for 0-3 and 6 positions?

Quoted 3 lines
Quoted 1 line

And what is, if CONFIG_SYS_MAX_I2C_BUS is< 7 ?

Indeed this can be removed - it is not needed (for now).

Ok.

Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
drivers/i2c/soft_i2c.c +21 -0
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;

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

Quoted 10 lines
drivers/i2c/soft_i2c.c +10 -0
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */

Again, what is with busnr = 0-3 or 6?

Quoted 6 lines
Quoted 3 lines

This is not needed in the i2c soft file. You can define this functions board specific ... so, no change in the driver is needed ... please move this to board specific code.

Please consider, that get_multi_{sda|scl}_pin can be used by other boards. Those are written in a generic way (by calling I2C_GET_BUS()).

Got this, but why do you index them with 4 and 5 and not with 0 and 1? What is, if another board uses 0 and 1, so this would introduce the defines CONFIG_SOFT_I2C_I2C0_SDA and CONFIG_SOFT_I2C_I2C1_SDA in the "common" get_multi_sda_pin(), which leads in compilererror for your board(s) ... your proposed get_multi_sda_pin() is currently samsung specific ...

Quoted 2 lines

What here I'm trying to avoid is the code duplication for each board (e.g. Samsung's GONI, Universal, Trats, Origen ... etc).

If they use all the same function, they should end in a ../samsung/common/common.c because, currently your functions are samsung specific.

common is (from my point of view) that we add in the board config file:

+#define CONFIG_SOFT_I2C_GPIO_SCL get_multi_scl_pin() +#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()

Quoted 2 lines

I can agree, that now only I2C_{4|5} are defined (since for now Samsung is using I2C_4 and I2C_5).

and thats samsung specific ... because other boards maybe start with I2C_0 ... and this case is not respected in your patch.

Quoted 1 line

But other cases can be also defined.

Yep, and break compiling your board, as this defines are not specified.

Quoted 15 lines

What I see even more important is a definition of (at<i2c.h>):

include/i2c.h +10 -0
+#if (defined(CONFIG_SOFT_I2C)&&   defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+	I2C_2,
+	I2C_3,
+	I2C_4,
+	I2C_5,
+	I2C_6
+};

since this will organize the order of multiple (soft) I2C devices.

Quoted 7 lines

Imagine that 2 PMICs are on the board (I2C_4 and I2C_5). I need to distinct those (when calling I2C_SET|GET_BUS)
And then support for another I2C device (e.g. I2C_2) at other subsystem is provided.
Then I can:
1. Add common definition of I2C_X (as I've proposed) to<i2c.h>
2. Add #define I2C_X on the ./include/configs/{e.g. trats}.h board.

Why add "#define I2C_X" in ./include/configs/{e.g. trats}.h ? I don?t understand this ... and you do not this in your patchserie!

Quoted 2 lines

For second approach used I need to duplicate the code for other targets (goni, universal, origen) when needed and I cannot avoid that someone

or make a ../samsung/common/common.c until they are samsung specific.

Quoted 2 lines

else will define other names -> like #define MINE_I2C_X on his/her ./include/configs/{board}.h

Ok, but if you use I2C_4 and I2C_5, you must also define the I2C_0, I2C_1, I2C_2 and I2C_3 cases in the "get_multi_*" functions, as other boards would start with I2C_0 ...

... and add a documentation in README for this ...

but I mislike to introduce such a lot of defines ... instead of defining get_multi_*() board/manufacturer/soc specific ... Maybe there is a board with 10 i2c soft busses, so we must define in all boards using soft multibus this 20 (CONFIG_SOFT_I2C_I2C*_SCL/SDA)defines ... or at least define them if not defined in include/i2c.h ... bad.

bye,
Heiko

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

PATCH 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Hi Heiko,

Quoted 75 lines
Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
drivers/i2c/soft_i2c.c +21 -0
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;

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

Quoted 10 lines
drivers/i2c/soft_i2c.c +10 -0
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */

Again, what is with busnr = 0-3 or 6?

Quoted 7 lines
Quoted 3 lines

This is not needed in the i2c soft file. You can define this functions board specific ... so, no change in the driver is needed ... please move this to board specific code.

Please consider, that get_multi_{sda|scl}_pin can be used by other boards. Those are written in a generic way (by calling I2C_GET_BUS()).

Got this, but why do you index them with 4 and 5 and not with 0 and 1? What is, if another board uses 0 and 1, so this would introduce the defines CONFIG_SOFT_I2C_I2C0_SDA and CONFIG_SOFT_I2C_I2C1_SDA in the "common" get_multi_sda_pin(), which leads in compilererror for your board(s) ... your proposed get_multi_sda_pin() is currently samsung specific ...

Quoted 2 lines

What here I'm trying to avoid is the code duplication for each board (e.g. Samsung's GONI, Universal, Trats, Origen ... etc).

If they use all the same function, they should end in
a ../samsung/common/common.c because, currently your functions are samsung specific.

common is (from my point of view) that we add in the board config file:

(quoted diff) +2 -0
+#define CONFIG_SOFT_I2C_GPIO_SCL get_multi_scl_pin()
+#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()
Quoted 3 lines

I can agree, that now only I2C_{4|5} are defined (since for now Samsung is using I2C_4 and I2C_5).

and thats samsung specific ... because other boards maybe start with I2C_0 ... and this case is not respected in your patch.

Quoted 1 line

But other cases can be also defined.

Yep, and break compiling your board, as this defines are not specified.

Quoted 2 lines

What I see even more important is a definition of (at<i2c.h>):

Quoted 11 lines

include/i2c.h static inline void I2C_SET_BUS(unsigned int bus) · line 263

Quoted 11 lines
include/i2c.h +10 -0
+#if (defined(CONFIG_SOFT_I2C)&&   defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+	I2C_2,
+	I2C_3,
+	I2C_4,
+	I2C_5,
+	I2C_6
+};

I would like to propose that, I will rename the I2C_4 -> I2C_0 and I2C_5 -> I2C_1,

then we can define at <i2c.h> :

+#if (defined(CONFIG_SOFT_I2C)&& defined(CONFIG_I2C_MULTI_BUS))
+enum {
+ I2C_0,
+ I2C_1,
+};

And this would facilitate handling of SOFT_I2C numbering across relevant subsystems (e.g. PMICs and other).

Quoted 28 lines
Quoted 9 lines

since this will organize the order of multiple (soft) I2C devices.

Imagine that 2 PMICs are on the board (I2C_4 and I2C_5). I need to distinct those (when calling I2C_SET|GET_BUS)
And then support for another I2C device (e.g. I2C_2) at other subsystem is provided.
Then I can:
1. Add common definition of I2C_X (as I've proposed) to<i2c.h>
2. Add #define I2C_X on the ./include/configs/{e.g. trats}.h board.

Why add "#define I2C_X" in ./include/configs/{e.g. trats}.h ? I don?t understand this ... and you do not this in your
patchserie!

Quoted 3 lines

For second approach used I need to duplicate the code for other targets (goni, universal, origen) when needed and I cannot avoid that someone

or make a ../samsung/common/common.c until they are samsung
specific.

Quoted 2 lines

else will define other names -> like #define MINE_I2C_X on his/her ./include/configs/{board}.h

Ok, but if you use I2C_4 and I2C_5, you must also define the I2C_0, I2C_1, I2C_2 and I2C_3 cases in the "get_multi_*" functions, as other boards would start with I2C_0 ...

Quoted 9 lines

... and add a documentation in README for this ...

but I mislike to introduce such a lot of defines ... instead of defining get_multi_*() board/manufacturer/soc specific ... Maybe there is a board with 10 i2c soft busses, so we must define in all boards using soft multibus this 20 (CONFIG_SOFT_I2C_I2C*_SCL/SDA)defines ... or at least define them if not defined in include/i2c.h ... bad.

I will move the "get_multi_*" functions to ../samsung/common/common.c

However, I think, that it would be good to add following declarations to <i2c.h>:

extern int get_multi_scl_pin(void);
extern int get_multi_sda_pin(void);
extern int multi_i2c_init(void);

,which can be defined on different platforms.

What is your opinion about that?

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#6 lore raw

PATCH 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Hello Lukasz,

Quoted 78 lines · Lukasz Majewski

Hi Heiko,

Quoted 75 lines
Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
drivers/i2c/soft_i2c.c +21 -0
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;

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

Quoted 10 lines
drivers/i2c/soft_i2c.c +10 -0
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */

Again, what is with busnr = 0-3 or 6?

Quoted 7 lines
Quoted 3 lines

This is not needed in the i2c soft file. You can define this functions board specific ... so, no change in the driver is needed ... please move this to board specific code.

Please consider, that get_multi_{sda|scl}_pin can be used by other boards. Those are written in a generic way (by calling I2C_GET_BUS()).

Got this, but why do you index them with 4 and 5 and not with 0 and 1? What is, if another board uses 0 and 1, so this would introduce the defines CONFIG_SOFT_I2C_I2C0_SDA and CONFIG_SOFT_I2C_I2C1_SDA in the "common" get_multi_sda_pin(), which leads in compilererror for your board(s) ... your proposed get_multi_sda_pin() is currently samsung specific ...

Quoted 2 lines

What here I'm trying to avoid is the code duplication for each board (e.g. Samsung's GONI, Universal, Trats, Origen ... etc).

If they use all the same function, they should end in
a ../samsung/common/common.c because, currently your functions are samsung specific.

common is (from my point of view) that we add in the board config file:

(quoted diff) +2 -0
+#define CONFIG_SOFT_I2C_GPIO_SCL get_multi_scl_pin()
+#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()
Quoted 3 lines

I can agree, that now only I2C_{4|5} are defined (since for now Samsung is using I2C_4 and I2C_5).

and thats samsung specific ... because other boards maybe start with I2C_0 ... and this case is not respected in your patch.

Quoted 1 line

But other cases can be also defined.

Yep, and break compiling your board, as this defines are not specified.

Quoted 2 lines

What I see even more important is a definition of (at<i2c.h>):

Quoted 14 lines
Quoted 11 lines

include/i2c.h static inline void I2C_SET_BUS(unsigned int bus) · line 263

Quoted 11 lines
include/i2c.h +10 -0
+#if (defined(CONFIG_SOFT_I2C)&&    defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+	I2C_2,
+	I2C_3,
+	I2C_4,
+	I2C_5,
+	I2C_6
+};

I would like to propose that, I will rename the I2C_4 -> I2C_0 and I2C_5 -> I2C_1,

Yep!

Quoted 10 lines

then we can define at<i2c.h> :

include/i2c.h +5 -0
+#if (defined(CONFIG_SOFT_I2C)&&    defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+};

And this would facilitate handling of SOFT_I2C numbering across relevant subsystems (e.g. PMICs and other).

Ok.

Quoted 38 lines
Quoted 28 lines
Quoted 9 lines

since this will organize the order of multiple (soft) I2C devices.

Imagine that 2 PMICs are on the board (I2C_4 and I2C_5). I need to distinct those (when calling I2C_SET|GET_BUS)
And then support for another I2C device (e.g. I2C_2) at other subsystem is provided.
Then I can:
1. Add common definition of I2C_X (as I've proposed) to<i2c.h>
2. Add #define I2C_X on the ./include/configs/{e.g. trats}.h board.

Why add "#define I2C_X" in ./include/configs/{e.g. trats}.h ? I don?t understand this ... and you do not this in your
patchserie!

Quoted 3 lines

For second approach used I need to duplicate the code for other targets (goni, universal, origen) when needed and I cannot avoid that someone

or make a ../samsung/common/common.c until they are samsung
specific.

Quoted 2 lines

else will define other names -> like #define MINE_I2C_X on
his/her ./include/configs/{board}.h

Ok, but if you use I2C_4 and I2C_5, you must also define the I2C_0, I2C_1, I2C_2 and I2C_3 cases in the "get_multi_*" functions, as other boards would start with I2C_0 ...

Quoted 9 lines

... and add a documentation in README for this ...

but I mislike to introduce such a lot of defines ... instead of defining get_multi_*() board/manufacturer/soc specific ... Maybe there is a board with 10 i2c soft busses, so we must define in all boards using soft multibus this 20 (CONFIG_SOFT_I2C_I2C*_SCL/SDA)defines ... or at least define them if not defined in include/i2c.h ... bad.

Quoted 1 line

I will move the "get_multi_*" functions to ../samsung/common/common.c

Good.

Quoted 6 lines

However, I think, that it would be good to add following declarations to <i2c.h>:

extern int get_multi_scl_pin(void);
extern int get_multi_sda_pin(void);
extern int multi_i2c_init(void);

In the case CONFIG_I2C_MULTI_BUS is defined.

Quoted 3 lines

,which can be defined on different platforms.

What is your opinion about that?

I agree with this!

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 1/2 i2c:soft:multi: Support for multiple soft I2C buses

Hi Heiko,

Quoted 96 lines

Hello Lukasz,

Quoted 78 lines · Lukasz Majewski

Hi Heiko,

Quoted 75 lines
Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
drivers/i2c/soft_i2c.c +21 -0
+#if defined(CONFIG_I2C_MULTI_BUS)
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SCL;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SCL;
+	};
+
+	return 0;
+}
+
+int get_multi_sda_pin(void)
+{
+	switch (I2C_GET_BUS()) {
+	case I2C_4:
+		return CONFIG_SOFT_I2C_I2C4_SDA;
+	case I2C_5:
+		return CONFIG_SOFT_I2C_I2C5_SDA;

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

Quoted 10 lines
drivers/i2c/soft_i2c.c +10 -0
+	};
+
+	return 0;
+}
+
+int multi_i2c_init(void)
+{
+	return 0;
+}
+#endif /* CONFIG_I2C_MULTI_BUS */

Again, what is with busnr = 0-3 or 6?

Quoted 7 lines
Quoted 3 lines

This is not needed in the i2c soft file. You can define this functions board specific ... so, no change in the driver is needed ... please move this to board specific code.

Please consider, that get_multi_{sda|scl}_pin can be used by other boards. Those are written in a generic way (by calling I2C_GET_BUS()).

Got this, but why do you index them with 4 and 5 and not with 0 and 1? What is, if another board uses 0 and 1, so this would introduce the defines CONFIG_SOFT_I2C_I2C0_SDA and CONFIG_SOFT_I2C_I2C1_SDA in the "common" get_multi_sda_pin(), which leads in compilererror for your board(s) ... your proposed get_multi_sda_pin() is currently samsung specific ...

Quoted 2 lines

What here I'm trying to avoid is the code duplication for each board (e.g. Samsung's GONI, Universal, Trats, Origen ... etc).

If they use all the same function, they should end in
a ../samsung/common/common.c because, currently your functions are samsung specific.

common is (from my point of view) that we add in the board config file:

(quoted diff) +2 -0
+#define CONFIG_SOFT_I2C_GPIO_SCL get_multi_scl_pin()
+#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()
Quoted 3 lines

I can agree, that now only I2C_{4|5} are defined (since for now Samsung is using I2C_4 and I2C_5).

and thats samsung specific ... because other boards maybe start with I2C_0 ... and this case is not respected in your patch.

Quoted 1 line

But other cases can be also defined.

Yep, and break compiling your board, as this defines are not specified.

Quoted 2 lines

What I see even more important is a definition of (at<i2c.h>):

Quoted 14 lines
Quoted 11 lines

include/i2c.h static inline void I2C_SET_BUS(unsigned int bus) · line 263

Quoted 11 lines
include/i2c.h +10 -0
+#if (defined(CONFIG_SOFT_I2C)&&    defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+	I2C_2,
+	I2C_3,
+	I2C_4,
+	I2C_5,
+	I2C_6
+};

I would like to propose that, I will rename the I2C_4 -> I2C_0 and I2C_5 -> I2C_1,

Quoted 1 line

Yep!

Ok, so we have agreed.

Quoted 9 lines
Quoted 9 lines

then we can define at<i2c.h> :

include/i2c.h +5 -0
+#if (defined(CONFIG_SOFT_I2C)&&    defined(CONFIG_I2C_MULTI_BUS))
+enum {
+	I2C_0,
+	I2C_1,
+};
Quoted 4 lines
Quoted 2 lines

And this would facilitate handling of SOFT_I2C numbering across relevant subsystems (e.g. PMICs and other).

Ok.

Nice,

Quoted 52 lines
Quoted 40 lines
Quoted 30 lines
Quoted 11 lines

since this will organize the order of multiple (soft) I2C devices.

Imagine that 2 PMICs are on the board (I2C_4 and I2C_5). I need to distinct those (when calling I2C_SET|GET_BUS)
And then support for another I2C device (e.g. I2C_2) at other subsystem is provided.
Then I can:
1. Add common definition of I2C_X (as I've proposed) to<i2c.h>
2. Add #define I2C_X on the ./include/configs/{e.g. trats}.h board.

Why add "#define I2C_X" in ./include/configs/{e.g.
trats}.h ? I don?t understand this ... and you do not this in your patchserie!

Quoted 3 lines

For second approach used I need to duplicate the code for other targets (goni, universal, origen) when needed and I cannot avoid that someone

or make a ../samsung/common/common.c until they are samsung
specific.

Quoted 2 lines

else will define other names -> like #define MINE_I2C_X on
his/her ./include/configs/{board}.h

Ok, but if you use I2C_4 and I2C_5, you must also define the I2C_0, I2C_1, I2C_2 and I2C_3 cases in the "get_multi_*" functions, as other boards would start with I2C_0 ...

Quoted 9 lines

... and add a documentation in README for this ...

but I mislike to introduce such a lot of defines ... instead of defining get_multi_*() board/manufacturer/soc specific ... Maybe there is a board with 10 i2c soft busses, so we must define in all boards using soft multibus this 20 (CONFIG_SOFT_I2C_I2C*_SCL/SDA)defines ... or at least define them if not defined in include/i2c.h ... bad.

Quoted 2 lines

I will move the "get_multi_*" functions
to ../samsung/common/common.c

Good.

Quoted 6 lines

However, I think, that it would be good to add following declarations to <i2c.h>:

extern int get_multi_scl_pin(void);
extern int get_multi_sda_pin(void);
extern int multi_i2c_init(void);

Quoted 7 lines

In the case CONFIG_I2C_MULTI_BUS is defined.

Quoted 3 lines

,which can be defined on different platforms.

What is your opinion about that?

I agree with this!

Ok, I need this.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#8 lore raw

PATCH 2/2 i2c:soft:multi: Enable soft I2C multibus at Trats development board

In reply to Lukasz Majewski

This commit enables multibus handling at Trats development board.

---
 include/configs/trats.h |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
include/configs/trats.h +13 -6
index c6fb2e0..bb764a5 100644
@@ -235,12 +235,6 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
-#include <asm/arch/gpio.h>
-/*
- * I2C Settings
- */
-#define CONFIG_SOFT_I2C_GPIO_SCL exynos4_gpio_part1_get_nr(b, 7)
-#define CONFIG_SOFT_I2C_GPIO_SDA exynos4_gpio_part1_get_nr(b, 6)
 
 #define CONFIG_SOFT_I2C
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
@@ -248,6 +242,19 @@
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	7
 
+#include <asm/arch/gpio.h>
+
+#define CONFIG_SOFT_I2C_I2C4_SCL exynos4_gpio_part1_get_nr(b, 3)
+#define CONFIG_SOFT_I2C_I2C4_SDA exynos4_gpio_part1_get_nr(b, 2)
+
+#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_SOFT_I2C_GPIO_SCL get_multi_scl_pin()
+#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()
+/* I2C_INIT defined to skip soft_i2c.c default one */
+#define I2C_INIT multi_i2c_init()
+
 #define CONFIG_PMIC
 #define CONFIG_PMIC_I2C
 #define CONFIG_PMIC_MAX8997
Signature · 1 line
1.7.2.3
#9 lore raw

v2 cover i2c:soft:multi: Support for multiple soft I2C buses at TRATS

In reply to Lukasz Majewski

Support for multiple I2C buses handling on Samsung's TRATS development board.

Those patches add multiple I2C support for Samsung boards and enables it at Trats.

Lukasz Majewski (2):
i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards i2c:soft:multi: Enable soft I2C multibus at Trats development board

 board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++++++
 board/samsung/common/multi_i2c.c |   55 ++++++++++++++++++++++++++++++++++++++
 include/configs/trats.h          |   19 +++++++++----
 include/i2c.h                    |   11 +++++++
 4 files changed, 122 insertions(+), 6 deletions(-)
 create mode 100644 board/samsung/common/Makefile
 create mode 100644 board/samsung/common/multi_i2c.c
Signature · 1 line
1.7.2.3
#10 lore raw

PATCH v2 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Support for multiple soft I2C buses.

The goal is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_{0|1} I2C buses is provided at <i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed

---
 board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++++++
 board/samsung/common/multi_i2c.c |   55 ++++++++++++++++++++++++++++++++++++++
 include/i2c.h                    |   11 +++++++
 3 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100644 board/samsung/common/Makefile
 create mode 100644 board/samsung/common/multi_i2c.c
board/samsung/common/Makefile new file +43 -0
new file mode 100644
index 0000000..0bcd594
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2012 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)libsamsung.o
+
+COBJS-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o
+
+SRCS    := $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/samsung/common/multi_i2c.c new file +55 -0

55 lines not on this page · raw message

include/i2c.h +11 -0
index 1f35acf..00a3933 100644
@@ -250,4 +250,15 @@ static inline void I2C_SET_BUS(unsigned int bus)
 		i2c_set_bus_num(bus);
 }
 
+/* Multi I2C busses handling */
+#ifdef CONFIG_SOFT_I2C_MULTI_BUS
+enum {
+	I2C_0,
+	I2C_1,
+};
+
+extern int get_multi_scl_pin(void);
+extern int get_multi_sda_pin(void);
+extern int multi_i2c_init(void);
+#endif
 #endif	/* _I2C_H_ */
Signature · 1 line
1.7.2.3
#11 lore raw

PATCH v2 2/2 i2c:soft:multi: Enable soft I2C multibus at Trats development board

In reply to Lukasz Majewski

This commit enables multibus handling at Samsung's Trats development board.

---
Changes for v2:
- CONFIG_SOFT_I2C_MULTI_BUS flag added to Trats configuration

---
 include/configs/trats.h |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
include/configs/trats.h +13 -6
index c6fb2e0..16df4cc 100644
@@ -235,19 +235,26 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
-#include <asm/arch/gpio.h>
-/*
- * I2C Settings
- */
-#define CONFIG_SOFT_I2C_GPIO_SCL exynos4_gpio_part1_get_nr(b, 7)
-#define CONFIG_SOFT_I2C_GPIO_SDA exynos4_gpio_part1_get_nr(b, 6)
 
 #define CONFIG_SOFT_I2C
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
 #define CONFIG_SYS_I2C_SPEED	50000
 #define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SOFT_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	7
 
+#include <asm/arch/gpio.h>
+
+#define CONFIG_SOFT_I2C_I2C0_SCL exynos4_gpio_part1_get_nr(b, 7)
+#define CONFIG_SOFT_I2C_I2C0_SDA exynos4_gpio_part1_get_nr(b, 6)
+
+#define CONFIG_SOFT_I2C_I2C1_SCL exynos4_gpio_part1_get_nr(b, 3)
+#define CONFIG_SOFT_I2C_I2C1_SDA exynos4_gpio_part1_get_nr(b, 2)
+
+#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_PMIC
 #define CONFIG_PMIC_I2C
 #define CONFIG_PMIC_MAX8997
Signature · 1 line
1.7.2.3
#12 lore raw

v3 cover i2c:soft:multi: Support for multiple soft I2C buses at TRATS

In reply to Lukasz Majewski

Support for multiple I2C buses handling on Samsung's TRATS development board.

Those patches add multiple I2C support for Samsung boards and enables it at Trats.

Lukasz Majewski (2):
i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards i2c:soft:multi: Enable soft I2C multibus at Trats development board

 board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++++++
 board/samsung/common/multi_i2c.c |   55 ++++++++++++++++++++++++++++++++++++++
 include/configs/trats.h          |   21 ++++++++++----
 include/i2c.h                    |   11 +++++++
 4 files changed, 124 insertions(+), 6 deletions(-)
 create mode 100644 board/samsung/common/Makefile
 create mode 100644 board/samsung/common/multi_i2c.c
Signature · 1 line
1.7.2.3
#13 lore raw

PATCH v3 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Support for multiple soft I2C buses.

The goal is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_{0|1} I2C buses is provided at <i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed
Changes for v3:
- None

---
 board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++++++
 board/samsung/common/multi_i2c.c |   55 ++++++++++++++++++++++++++++++++++++++
 include/i2c.h                    |   11 +++++++
 3 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100644 board/samsung/common/Makefile
 create mode 100644 board/samsung/common/multi_i2c.c
board/samsung/common/Makefile new file +43 -0
new file mode 100644
index 0000000..0bcd594
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2012 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)libsamsung.o
+
+COBJS-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o
+
+SRCS    := $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/samsung/common/multi_i2c.c new file +55 -0

55 lines not on this page · raw message

include/i2c.h +11 -0
index 1f35acf..00a3933 100644
@@ -250,4 +250,15 @@ static inline void I2C_SET_BUS(unsigned int bus)
 		i2c_set_bus_num(bus);
 }
 
+/* Multi I2C busses handling */
+#ifdef CONFIG_SOFT_I2C_MULTI_BUS
+enum {
+	I2C_0,
+	I2C_1,
+};
+
+extern int get_multi_scl_pin(void);
+extern int get_multi_sda_pin(void);
+extern int multi_i2c_init(void);
+#endif
 #endif	/* _I2C_H_ */
Signature · 1 line
1.7.2.3
#14 lore raw

PATCH v3 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Hi Heiko,

include/i2c.h static inline void I2C_SET_BUS(unsigned int bus) · line 259

Quoted 9 lines

Common definition of I2C_{0|1} I2C buses is provided at <i2c.h>.

include/i2c.h +7 -0
+/* Multi I2C busses handling */
+#ifdef CONFIG_SOFT_I2C_MULTI_BUS
+enum {
+	I2C_0,
+	I2C_1,
+};
+

I've got a second thought about this numbering.
In the case of Trats:

I2C_0 in reality is I2C_5 (this from schematic/chip numbergin) and I2C_1 is I2C_9.

This numbering (I2C_5 and I2C_9) was proposed for v2 of this patch.

I will prepare v4 of this patch with a palatable I2C numbering solution.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#15 lore raw

PATCH v3 2/2 i2c:soft:multi: Enable soft I2C multibus at Trats development board

In reply to Lukasz Majewski

This commit enables multibus handling at Samsung's Trats development board.

---
Changes for v2:
- CONFIG_SOFT_I2C_MULTI_BUS flag added to Trats configuration

Changes for v3:
- correct definition of TRATS I2C_1 pins

---
 include/configs/trats.h |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
include/configs/trats.h +15 -6
index c6fb2e0..d1080d5 100644
@@ -235,19 +235,28 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
-#include <asm/arch/gpio.h>
-/*
- * I2C Settings
- */
-#define CONFIG_SOFT_I2C_GPIO_SCL exynos4_gpio_part1_get_nr(b, 7)
-#define CONFIG_SOFT_I2C_GPIO_SDA exynos4_gpio_part1_get_nr(b, 6)
 
 #define CONFIG_SOFT_I2C
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
 #define CONFIG_SYS_I2C_SPEED	50000
 #define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SOFT_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS	7
 
+#include <asm/arch/gpio.h>
+
+/* I2C PMIC */
+#define CONFIG_SOFT_I2C_I2C0_SCL exynos4_gpio_part1_get_nr(b, 7)
+#define CONFIG_SOFT_I2C_I2C0_SDA exynos4_gpio_part1_get_nr(b, 6)
+
+/* I2C FG */
+#define CONFIG_SOFT_I2C_I2C1_SCL exynos4_gpio_part2_get_nr(y4, 1)
+#define CONFIG_SOFT_I2C_I2C1_SDA exynos4_gpio_part2_get_nr(y4, 0)
+
+#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_PMIC
 #define CONFIG_PMIC_I2C
 #define CONFIG_PMIC_MAX8997
Signature · 1 line
1.7.2.3
#16 lore raw

v4 cover i2c:soft:multi: Support for multiple soft I2C buses at TRATS

In reply to Lukasz Majewski

Those patches add multiple I2C support for Samsung boards and enables it on Trats.

Lukasz Majewski (2):
i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards i2c:soft:multi: Enable soft I2C multibus at Trats development board

 board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++
 board/samsung/common/multi_i2c.c |   65 ++++++++++++++++++++++++++++++++++++++
 board/samsung/trats/trats.c      |   15 +++++++++
 include/configs/trats.h          |   24 ++++++++++----
 include/i2c.h                    |   12 +++++++
 5 files changed, 152 insertions(+), 7 deletions(-)
 create mode 100644 board/samsung/common/Makefile
 create mode 100644 board/samsung/common/multi_i2c.c
Signature · 1 line
1.7.2.3
#17 lore raw

PATCH v4 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Support for multiple soft I2C buses.

Multibus I2C support is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_X I2C buses is provided at <i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed
Changes for v3:
- None
Changes for v4:
- Common definitions of available I2C buses are now defined at <i2c.h>
- Compatibility layer (I2C_0) has been added temporarily to not break the Trats I2C communication with PMIC. It will be removed when redesigned PMIC will be posted

---
 board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++
 board/samsung/common/multi_i2c.c |   65 ++++++++++++++++++++++++++++++++++++++
 include/i2c.h                    |   12 +++++++
 3 files changed, 120 insertions(+), 0 deletions(-)
 create mode 100644 board/samsung/common/Makefile
 create mode 100644 board/samsung/common/multi_i2c.c
board/samsung/common/Makefile new file +43 -0
new file mode 100644
index 0000000..0bcd594
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2012 Samsung Electronics
+# Lukasz Majewski <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)libsamsung.o
+
+COBJS-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o
+
+SRCS    := $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/samsung/common/multi_i2c.c new file +65 -0

65 lines not on this page · raw message

include/i2c.h +12 -0
index 1f35acf..16f099d 100644
@@ -250,4 +250,16 @@ static inline void I2C_SET_BUS(unsigned int bus)
 		i2c_set_bus_num(bus);
 }
 
+/* Multi I2C definitions */
+enum {
+	I2C_0, I2C_1, I2C_2, I2C_3, I2C_4, I2C_5, I2C_6, I2C_7,
+	I2C_8, I2C_9, I2C_10,
+};
+
+/* Multi I2C busses handling */
+#ifdef CONFIG_SOFT_I2C_MULTI_BUS
+extern int get_multi_scl_pin(void);
+extern int get_multi_sda_pin(void);
+extern int multi_i2c_init(void);
+#endif
 #endif	/* _I2C_H_ */
Signature · 1 line
1.7.2.3
#18 lore raw

PATCH v4 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Hello Lukasz,

Quoted 35 lines · Lukasz Majewski

Support for multiple soft I2C buses.

Multibus I2C support is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_X I2C buses is provided at<i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed
Changes for v3:
- None
Changes for v4:
- Common definitions of available I2C buses are now defined at<i2c.h>
- Compatibility layer (I2C_0) has been added temporarily to not break the Trats I2C communication with PMIC. It will be removed when redesigned PMIC will be posted

---
  board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++
  board/samsung/common/multi_i2c.c |   65 ++++++++++++++++++++++++++++++++++++++
  include/i2c.h                    |   12 +++++++
  3 files changed, 120 insertions(+), 0 deletions(-)

create mode 100644 board/samsung/common/Makefile create mode 100644 board/samsung/common/multi_i2c.c

[...]

Quoted 7 lines
(quoted diff) +1 -0
+#########################################################################
board/samsung/common/multi_i2c.c new file +0 -0
new file mode 100644
index 0000000..d6c3d37
@@ -0,0 +1,65 @@

[...]

board/samsung/common/multi_i2c.c line 34

Quoted 8 lines
board/samsung/common/multi_i2c.c new file +8 -0
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	unsigned int bus = I2C_GET_BUS();
+
+	switch (bus) {
+	case I2C_0: /* I2C_0 definition - compatibility layer */
+	case I2C_5:

Is this correct, that you want to use 2 i2c busses on the same pin?

Beside of that, you get my:

bye,
Heiko

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

PATCH v4 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Hi Heiko,

Thanks for comments.

Quoted 50 lines

Hello Lukasz,

Quoted 38 lines · Lukasz Majewski

Support for multiple soft I2C buses.

Multibus I2C support is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_X I2C buses is provided at<i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed
Changes for v3:
- None
Changes for v4:
- Common definitions of available I2C buses are now defined at<i2c.h>
- Compatibility layer (I2C_0) has been added temporarily to not break the Trats I2C communication with PMIC. It will be removed when redesigned PMIC will be posted

---
  board/samsung/common/Makefile    |   43 +++++++++++++++++++++++++
  board/samsung/common/multi_i2c.c |   65

++++++++++++++++++++++++++++++++++++++
include/i2c.h | 12 +++++++ 3 files changed,
120 insertions(+), 0 deletions(-) create mode 100644 board/samsung/common/Makefile create mode 100644 board/samsung/common/multi_i2c.c

[...]

Quoted 7 lines
(quoted diff) +1 -0
+#########################################################################
(quoted diff) +0 -0

b/board/samsung/common/multi_i2c.c new file mode 100644 index 0000000..d6c3d37

board/samsung/common/multi_i2c.c new file +0 -0
@@ -0,0 +1,65 @@

[...]

Quoted 10 lines

board/samsung/common/multi_i2c.c line 34

Quoted 8 lines
board/samsung/common/multi_i2c.c new file +8 -0
+/* Handle multiple I2C buses instances */
+int get_multi_scl_pin(void)
+{
+	unsigned int bus = I2C_GET_BUS();
+
+	switch (bus) {
+	case I2C_0: /* I2C_0 definition - compatibility layer */
+	case I2C_5:

Is this correct, that you want to use 2 i2c busses on the same pin?

Yes, this is correct.

Let me share with you the "master" plan for this.
The I2C_0 is needed to keep the TRATS working with current PMIC implementation.

I'm working on redesign of current PMIC implementation to support other devices responsible for power management (e.g. fuel gauge, charger, PMIC), which in case of TRATS are connected via multiple I2C buses (I2C_5 and I2C_9).

The I2C_0 case is for preserving correct operation of TRATS board until PMIC 2.0 wont be introduced to u-boot mailing list.

It will be removed just after PMIC 2.0 acceptance.

I hope, that I've expressed my intentions clearly.

Quoted 7 lines

Beside of that, you get my:

bye,
Heiko

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#20 lore raw

PATCH v4 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

In reply to Lukasz Majewski

Hi Minkyu,

Quoted 15 lines

Support for multiple soft I2C buses.

Multibus I2C support is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_X I2C buses is provided at <i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

Quoted 14 lines

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed
Changes for v3:
- None
Changes for v4:
- Common definitions of available I2C buses are now defined at <i2c.h>
- Compatibility layer (I2C_0) has been added temporarily to not break the Trats I2C communication with PMIC. It will be removed when redesigned PMIC will be posted
---

Can you evaluate those patches.

Those were acked-by Heiko already.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#21 lore raw

PATCH v4 1/2 i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards

Dear Lukasz,

Quoted 32 lines · Lukasz Majewski

Hi Minkyu,

Quoted 15 lines

Support for multiple soft I2C buses.

Multibus I2C support is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses.

Common definition of I2C_X I2C buses is provided at <i2c.h>.

TEST HW:
Samsung's Exynos4210 evt.0.1 - Trats development board

Quoted 14 lines

---
Changes for v2:
- Common Samsung code has been put to board/samsung/common/multi_i2c.c file
- I2C_{4|5} have been renamed to I2C_{0|1}
- *soft_i2c_name[] table has been removed
Changes for v3:
- None
Changes for v4:
- Common definitions of available I2C buses are now defined at <i2c.h>
- Compatibility layer (I2C_0) has been added temporarily to not break the Trats I2C communication with PMIC. It will be removed when redesigned PMIC will be posted
---

Quoted 4 lines

Can you evaluate those patches.

Those were acked-by Heiko already.

OK.
please wait few days.
I will check pending patches soon.

Thanks.
Minkyu Kang.

Signature · 2 lines
from. prom.
www.promsoft.net
#22 lore raw

PATCH v4 2/2 i2c:soft:multi: Enable soft I2C multibus at Trats development board

In reply to Lukasz Majewski

This commit enables multibus handling at Samsung's Trats development board.

---
Changes for v2:
- CONFIG_SOFT_I2C_MULTI_BUS flag added to Trats configuration

Changes for v3:
- correct definition of TRATS I2C_1 pins

Changes for v4:
- Assign I2C numbers reflecting the HW structure of Trats board
- Change the max I2C numbers to 15 from 7
- i2c_init_board() function defined for trats board

---
 board/samsung/trats/trats.c |   15 +++++++++++++++
 include/configs/trats.h     |   24 +++++++++++++++++-------
 2 files changed, 32 insertions(+), 7 deletions(-)
board/samsung/trats/trats.c +15 -0
index 4f9cb5a..e11a892 100644
@@ -75,6 +75,21 @@ int board_init(void)
 	return 0;
 }
 
+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);
+}
+
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
include/configs/trats.h +17 -7
index c6fb2e0..866c047 100644
@@ -235,18 +235,28 @@
 #define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_CACHELINE_SIZE       32
 
-#include <asm/arch/gpio.h>
-/*
- * I2C Settings
- */
-#define CONFIG_SOFT_I2C_GPIO_SCL exynos4_gpio_part1_get_nr(b, 7)
-#define CONFIG_SOFT_I2C_GPIO_SDA exynos4_gpio_part1_get_nr(b, 6)
 
 #define CONFIG_SOFT_I2C
 #define CONFIG_SOFT_I2C_READ_REPEATED_START
+#define CONFIG_SYS_I2C_INIT_BOARD
 #define CONFIG_SYS_I2C_SPEED	50000
 #define CONFIG_I2C_MULTI_BUS
-#define CONFIG_SYS_MAX_I2C_BUS	7
+#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)
+
+/* 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)
+
+#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_PMIC
 #define CONFIG_PMIC_I2C
Signature · 1 line
1.7.2.3
#23 lore raw

PATCH v4 2/2 i2c:soft:multi: Enable soft I2C multibus at Trats development board

Hello Lukasz,

Quoted 13 lines · Lukasz Majewski

This commit enables multibus handling at Samsung's Trats development board.

---
Changes for v2:
- CONFIG_SOFT_I2C_MULTI_BUS flag added to Trats configuration

Changes for v3:
- correct definition of TRATS I2C_1 pins

Quoted 8 lines

Changes for v4:
- Assign I2C numbers reflecting the HW structure of Trats board
- Change the max I2C numbers to 15 from 7
- i2c_init_board() function defined for trats board

---
  board/samsung/trats/trats.c |   15 +++++++++++++++
  include/configs/trats.h     |   24 +++++++++++++++++-------
  2 files changed, 32 insertions(+), 7 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