83xx, i2c: add mux support for fsl_i2c
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
--- drivers/i2c/fsl_i2c.c | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-)
drivers/i2c/fsl_i2c.c +23 -1
@@ -42,6 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;#define CONFIG_SYS_SPD_BUS_NUM 0#endif static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = CONFIG_SYS_SPD_BUS_NUM; +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;static unsigned int i2c_bus_speed[2 ] = {CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SPEED };
@@ -369,6 +370,23 @@ i2c_probe(uchar chip)int i2c_set_bus_num (unsigned int bus) { +#if defined(CONFIG_I2C_MUX) + if (bus < CONFIG_SYS_MAX_I2C_BUS) { + i2c_bus_num = bus; + } else { + int ret; + + ret = i2x_mux_select_mux(bus); + if (ret == 0) { + /* with CONFIG_I2C_MUX only I2C Controller 1 + * is usable + */ + i2c_bus_num = 0; + i2c_bus_num_mux = bus; + } else + return ret; + } +#else #ifdef CONFIG_SYS_I2C2_OFFSET if (bus > 1) { #else
@@ -378,7 +396,7 @@ int i2c_set_bus_num(unsigned int bus) } i2c_bus_num = bus; - +#endif return 0 ; }
@@ -396,7 +414,11 @@ int i2c_set_bus_speed(unsigned int speed)unsigned int i2c_get_bus_num (void ) { +#if defined(CONFIG_I2C_MUX ) +return i2c_bus_num_mux; +#else return i2c_bus_num; +#endif }unsigned int i2c_get_bus_speed (void )
Signature · 5 lines
1.6.0.6 -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
drivers/i2c/fsl_i2c.c i2c_probe(uchar chip) · line 376
Quoted 8 lines · On Thu, 19 Feb 2009 17:24:09 +0100 Heiko Schocher <[email protected]> wrote:
drivers/i2c/fsl_i2c.c +4
-0@@ -369,6 +370,23 @@ i2c_probe(uchar chip)int i2c_set_bus_num (unsigned int bus) { +#if defined(CONFIG_I2C_MUX ) +if (bus <CONFIG_SYS_MAX_I2C_BUS ) { + i2c_bus_num = bus; + }else {
[1]
drivers/i2c/fsl_i2c.c i2c_probe(uchar chip) · line 388
Quoted 12 lines
drivers/i2c/fsl_i2c.c +12
-0+int ret; + + ret =i2x_mux_select_mux (bus); +if (ret ==0 ) { +/* with CONFIG_I2C_MUX only I2C Controller 1 +* is usable +*/ + i2c_bus_num =0 ; + i2c_bus_num_mux = bus; + }else +return ret; + }
how about
ret = i2x_...
if (ret)
return ret;
/* with...
drivers/i2c/fsl_i2c.c int i2c_set_bus_num(unsigned int bus) · line 399
Quoted 10 lines
drivers/i2c/fsl_i2c.c +2
-1+#else #ifdef CONFIG_SYS_I2C2_OFFSET if (bus > 1) { #else@@ -378,7 +396,7 @@ int i2c_set_bus_num(unsigned int bus) } i2c_bus_num = bus; - +#endif
reuse code and moved the ifdef up, then [1] would just be:
if (bus >= CONFIG_SYS_MAX_I2C_BUS) {
drivers/i2c/fsl_i2c.c int i2c_set_bus_speed(unsigned int speed) · line 422
Quoted 13 lines
drivers/i2c/fsl_i2c.c +4
-0return 0 ; }@@ -396,7 +414,11 @@ int i2c_set_bus_speed(unsigned int speed)unsigned int i2c_get_bus_num (void ) { +#if defined(CONFIG_I2C_MUX ) +return i2c_bus_num_mux; +#else return i2c_bus_num; +#endif }
I don't get this mux variant - why aren't we reusing i2c_bus_num in the mux case?
Kim
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Hello Kim,
Quoted 41 lines · Kim Phillips
drivers/i2c/fsl_i2c.c i2c_probe(uchar chip) · line 376
Quoted 8 lines · On Thu, 19 Feb 2009 17:24:09 +0100 Heiko Schocher <[email protected]> wrote:
drivers/i2c/fsl_i2c.c +4
-0@@ -369,6 +370,23 @@ i2c_probe(uchar chip)int i2c_set_bus_num (unsigned int bus) { +#if defined(CONFIG_I2C_MUX ) +if (bus <CONFIG_SYS_MAX_I2C_BUS ) { + i2c_bus_num = bus; + }else {[1]
drivers/i2c/fsl_i2c.c i2c_probe(uchar chip) · line 388
Quoted 12 lines
drivers/i2c/fsl_i2c.c +12
-0+int ret; + + ret =i2x_mux_select_mux (bus); +if (ret ==0 ) { +/* with CONFIG_I2C_MUX only I2C Controller 1 +* is usable +*/ + i2c_bus_num =0 ; + i2c_bus_num_mux = bus; + }else +return ret; + }how about
ret =
i2x_...
if (ret)return ret;/* with...
Quoted 7 lines
drivers/i2c/fsl_i2c.c +1
-0+#else #ifdef CONFIG_SYS_I2C2_OFFSET if (bus > 1) { #else@@ -378,7 +396,7 @@ int i2c_set_bus_num(unsigned int bus) }
Quoted 5 lines
drivers/i2c/fsl_i2c.c int i2c_set_bus_num(unsigned int bus) · line 399
Quoted 3 lines
drivers/i2c/fsl_i2c.c +1
-1i2c_bus_num = bus; - +#endif reuse code and moved the ifdef up, then [1] would just be:
Ok.
Quoted 7 lines
if (bus >=
CONFIG_SYS_MAX_I2C_BUS) {Quoted 5 lines
drivers/i2c/fsl_i2c.c +0
-0return 0 ; }@@ -396,7 +414,11 @@ int i2c_set_bus_speed(unsigned int speed)
Quoted 11 lines
drivers/i2c/fsl_i2c.c int i2c_set_bus_speed(unsigned int speed) · line 422
Quoted 8 lines
drivers/i2c/fsl_i2c.c +4
-0unsigned int i2c_get_bus_num (void ) { +#if defined(CONFIG_I2C_MUX ) +return i2c_bus_num_mux; +#else return i2c_bus_num; +#endif }I don't get this mux variant - why aren't we reusing
i2c_bus_numin the mux case?
Good question, have to think about it.
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
In reply to Kim PhillipsHello Kim,
Quoted 2 lines · Kim Phillips
On Thu, 19 Feb 2009 17:24:09 +0100
Heiko Schocher <[email protected]> wrote:
[...]
Quoted 11 lines
drivers/i2c/fsl_i2c.c int i2c_set_bus_speed(unsigned int speed) · line 422
Quoted 8 lines
unsigned int
i2c_get_bus_num(void)
{drivers/i2c/fsl_i2c.c +4
-0+#if defined(CONFIG_I2C_MUX ) +return i2c_bus_num_mux; +#else return i2c_bus_num; +#endif }I don't get this mux variant - why aren't we reusing
i2c_bus_numin the mux case?
Because i2c_bus_num is used as an index which hardware i2c controller is used (0 or 1). In CONFIG_I2C_MUX case, you have more than 2 i2c busses -> i2c_bus_num would be greater than 1, so you must have a variable, where you store which hardware adapter you use, and one which stores on which i2c bus you are.
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Quoted 18 lines · On Tue, 24 Feb 2009 08:53:33 +0100 Heiko Schocher <[email protected]> wrote:
Hello Kim,
Quoted 2 lines · Kim Phillips
On Thu, 19 Feb 2009 17:24:09 +0100
Heiko Schocher <[email protected]> wrote:[...]
Quoted 11 lines
drivers/i2c/fsl_i2c.c int i2c_set_bus_speed(unsigned int speed) · line 422
Quoted 8 lines
unsigned int
i2c_get_bus_num(void)
{drivers/i2c/fsl_i2c.c +4
-0+#if defined(CONFIG_I2C_MUX ) +return i2c_bus_num_mux; +#else return i2c_bus_num; +#endif }I don't get this mux variant - why aren't we reusing
i2c_bus_numin the mux case?
Quoted 5 lines
Because
i2c_bus_numis used as an index which hardware i2c controller is used (0 or 1). InCONFIG_I2C_MUXcase, you have more than 2 i2c busses ->i2c_bus_numwould be greater than 1, so you must have a variable, where you store which hardware adapter you use, and one which stores on which i2c bus you are.
so instead of naming it "i2c_bus_num_mux" it should be renamed "i2c_adapter_num"?, or does i2c_get_bus_num() still imply that it will return the /bus/ number? Perhaps we should we have a separate function altogether?
Kim
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Hello Kim,
Quoted 19 lines · Kim Phillips
Quoted 16 lines · On Tue, 24 Feb 2009 08:53:33 +0100 Heiko Schocher <[email protected]> wrote:
Hello Kim,
Quoted 2 lines · Kim Phillips
On Thu, 19 Feb 2009 17:24:09 +0100
Heiko Schocher <[email protected]> wrote:[...]
Quoted 10 lines
drivers/i2c/fsl_i2c.c int i2c_set_bus_speed(unsigned int speed) · line 422
Quoted 8 lines
unsigned int
i2c_get_bus_num(void)
{drivers/i2c/fsl_i2c.c +4
-0+#if defined(CONFIG_I2C_MUX ) +return i2c_bus_num_mux; +#else return i2c_bus_num; +#endif }I don't get this mux variant - why aren't we reusing
i2c_bus_numin the mux case?
Quoted 8 lines
Quoted 5 lines
Because
i2c_bus_numis used as an index which hardware i2c controller is used (0 or 1). InCONFIG_I2C_MUXcase, you have more than 2 i2c busses ->i2c_bus_numwould be greater than 1, so you must have a variable, where you store which hardware adapter you use, and one which stores on which i2c bus you are.so instead of naming it "
i2c_bus_num_mux" it should be renamed "i2c_adapter_num"?, or doesi2c_get_bus_num()still imply that it will
No, i2c_adapter_num should be 0 or 1 for Controller 0 or 1, I think, and i2c_bus_num_mux can be greater then 1.
If we would do a rename, we should rename "i2c_bus_num" to "i2c_adapter_num". In case, we don;t use i2c mux, i2c_bus_num = i2c_adapter_num. else i2c_bus_num >= i2c_adapter_num (=0 or 1)
Quoted 1 line
return the /bus/ number? Perhaps we should we have a separate function
Yes, i2c_get_bus_num() returns the bus number.
Quoted 1 line
altogether?
We should rework this "i2c multibus" instead complete, so we can remove all this instances from i2c_get_bus_num()/i2c_set_bus_num() in every i2c driver ... such an attempt was in discussion, but unfortunately failed ... but I hope I can retrigger it.
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Quoted 4 lines · Heiko Schocher
We should rework this "i2c multibus" instead complete, so we can remove all this instances from i2c_get_bus_num()/i2c_set_bus_num() in every i2c driver ... such an attempt was in discussion, but unfortunately failed ... but I hope I can retrigger it.
I was willing to write a lot of the code to implement that change (getting rid of i2c_xxx_bus_num), but aer Wolfgang shot it down, I gave up. If you do manage to turn the tide, let me know.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Hello Timur,
Quoted 10 lines · Timur Tabi
Quoted 4 lines · Heiko Schocher
We should rework this "i2c multibus" instead complete, so we can remove all this instances from i2c_get_bus_num()/i2c_set_bus_num() in every i2c driver ... such an attempt was in discussion, but unfortunately failed ... but I hope I can retrigger it.
I was willing to write a lot of the code to implement that change (getting rid of
i2c_xxx_bus_num), but aer Wolfgang shot it down, I gave up. If you do manage to turn the tide, let me know.
I actually prepare a branch for u-boot-i2c.git based on the patches from ksi, and another branch in this tree with suggestions I and Wolfgang proposed. If I am ready with that, I hope this discussion starts again ;-)
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
In reply to Heiko SchocherQuoted 9 lines · On Wed, 25 Feb 2009 09:00:39 +0100 Heiko Schocher <[email protected]> wrote:
Quoted 2 lines
so instead of naming it "
i2c_bus_num_mux" it should be renamed "i2c_adapter_num"?, or doesi2c_get_bus_num()still imply that it willNo,
i2c_adapter_numshould be 0 or 1 for Controller 0 or 1, I think, andi2c_bus_num_muxcan be greater then 1.If we would do a rename, we should rename "
i2c_bus_num" to "i2c_adapter_num". In case, we don;t use i2c mux,i2c_bus_num=i2c_adapter_num. elsei2c_bus_num>=i2c_adapter_num(=0 or 1)
sigh..that's not really that better either.
Quoted 6 lines
Quoted 1 line
altogether?
We should rework this "i2c multibus" instead complete, so we can remove all this instances from i2c_get_bus_num()/i2c_set_bus_num() in every i2c driver ... such an attempt was in discussion, but unfortunately failed ... but I hope I can retrigger it.
ok - looking forward to it.
Thanks,
Kim
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Hello Kim,
Quoted 5 lines · Kim Phillips
Quoted 2 lines · On Wed, 25 Feb 2009 09:00:39 +0100 Heiko Schocher <[email protected]> wrote:
Quoted 2 lines
so instead of naming it "
i2c_bus_num_mux" it should be renamed "i2c_adapter_num"?, or doesi2c_get_bus_num()still imply that it will
Quoted 8 lines
Quoted 6 lines
No,
i2c_adapter_numshould be 0 or 1 for Controller 0 or 1, I think, andi2c_bus_num_muxcan be greater then 1.If we would do a rename, we should rename "
i2c_bus_num" to "i2c_adapter_num". In case, we don;t use i2c mux,i2c_bus_num=i2c_adapter_num. elsei2c_bus_num>=i2c_adapter_num(=0 or 1)sigh..that's not really that better either.
yes, sorry.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
altogether?
We should rework this "i2c multibus" instead complete, so we can remove all this instances from i2c_get_bus_num()/i2c_set_bus_num() in every i2c driver ... such an attempt was in discussion, but unfortunately failed ... but I hope I can retrigger it.
ok - looking forward to it.
Yep, I hope to get this running on beginning of march, and this approach, hopefully, solves a lot of this problems.
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
In reply to Heiko SchocherQuoted 10 lines · On Thu, 19 Feb 2009 17:24:09 +0100 Heiko Schocher <[email protected]> wrote:
Signed-off-by Heiko Schocher <[email protected]>--- drivers/i2c/fsl_i2c.c | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-)drivers/i2c/fsl_i2c.c +0
-0
drivers/i2c/fsl_i2c.c DECLARE_GLOBAL_DATA_PTR; · line 45
Quoted 4 lines
drivers/i2c/fsl_i2c.c +1
-0@@ -42,6 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;#define CONFIG_SYS_SPD_BUS_NUM 0#endif static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = CONFIG_SYS_SPD_BUS_NUM; +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
also, this line gets this from the compiler:
fsl_i2c.c:45: warning: 'i2c_bus_num_mux' defined but not used
Kim
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
In reply to Heiko SchocherQuoted 2 lines · Heiko Schocher
Signed-off-by Heiko Schocher <[email protected]>---
Could you add a description that says what I2C mux support is? That would make it easier to review this patch.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH v3 4/9 83xx, i2c: add mux support for fsl_i2c
Hello Timur,
Quoted 6 lines · Timur Tabi
Quoted 2 lines · Heiko Schocher
Signed-off-by Heiko Schocher <[email protected]>---
Could you add a description that says what I2C mux support is? That would make it easier to review this patch.
Ok, do this with the next version of this patches.
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany