No subject
If you use from actual 2.6 Linux the drivers/i2c/algos/i2c-algo-bit.c bitbang driver with gpio support (drivers/i2c/busses/i2c-gpio.c) you get called your gpio_get/set_value (pin, state) function in your board code (or gpio code)!
And in this function you have to switch dependent on the pin, and then again to switch dependent on the state, before you can do any action ... so tell me, where we are worser, when we making
#define I2C_SDA(bit) \
switch(cur_adap_nr->hw_adapnr) { \
case 0: \
if (bit) { \
/* set pin for adapter 0 = 1*/ \
} else { \
/* set pin for adapter 0 = 0*/ \
} \
[...] \
} \
} \in board config file ... OK, we are worser against your approach, because we have for all I2C_SDA, I2C_SCL accesses + 1 switch, but I don;t think this is such a problem.
Quoted 8 lines
That means that implementation is much worse than _EXISTING_ one. And out of decent and much worse one which one would you choose?
Quoted 4 lines
Quoted 1 line
The
soft_i2c.cis _NOT_ a driver _SOURCE_. It is a _TEMPLATE_ that makes aThis is your implementation. It is not the only possible implemen- tation. Please try and open your mind to discuss alternative possibilities as well.
Quoted 5 lines
No, it is NOT my implementation. It is _EXISTING_ driver in the main tree. I did _NOT_ change the driver, I just made several copies of it.
And, BTW, you can see something very similar in Linux kernel (
i2c-algo-bit.c.)
Please have a deeper look in it, see above comment.
Quoted 4 lines
I'm open to any alternative possibilities but I can not see anything better. That _EXISTING_
soft_i2c.cwe have in the current tree is a little miracle that was there since the start of times so I can't see any reason to throw it away and reinvent the wheel.
Nobody wants to throw it away!
Quoted 10 lines
Quoted 8 lines
Quoted 7 lines
The former does not require additional adapter struct member,
hwadap_no. And, unlike the latter, it is self-contained, it doesn't require any external global variable to decide what to do. One can initialize all adapters by:for (i = 0; i < NUM_I2C_ADAPTERS; i++) i2c_adap[i]->init(...);Most probably we never *want* to initialize all adapters...
It is easier that way and wouldn't do any harm in most cases...
But it is not needed when doing this in i2c_set_bus_num() !! It is sufficent to init a hardwareadapter, when switching to 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