I2C chip driver functionality check -- help?
To anyone who may be able to help.
Sorry if this is a repeat, but I have not seen any response, and I'm not sure the message got to the list, and this is the last remaining issue for my linux package. So just in case it did not...
I'm writing drivers for custom hardware on Octagon System's line of embedded PCs. ?I'm busy with an I2C bus and chip driver set for our GX1 based products, using kernel 2.6.2.
A simple (I hope) question:
Why doesn't bit_func() in i2c-algo-bit.c not return with the I2C_FUNC_I2C bit set?
My chip driver needs to use i2c_master_send() and i2c_master_recv(), and I cant' find any other functionality bit that makes sense. ?If I skip the functionality check, it seems to work. ?Did I miss something in the documentation, that is am I checking for the wrong functionality bit(s)?
Background:
The I2C bus is just a couple of GPIO leads from the 5530 companion part. The custom driver using the bit-bang algorithm seems to be working fine.
The custom chip driver is for a 4KByte EEPROM, of which 2KB is available to the user for static data storage (the other is used to store bios settings without need for a battery, and for video configuration and system diagnostics and test). The driver gives read-write access to the user half of the device. This too, seems to be working fine, except for the check_functionality call, which is temporarily commented out.
Both of the above will be released under the GPL, and ship with full source in our linux development kits. They are available to the project if there is any interest. Presently this combination works with 3 of Octagon's SBCs and are expected to support at least one more product currently in development.
Thanks in advance for any thoughts or suggestions.
Signature · 3 lines
-- Sean Fendt [email protected] Ph: 303 430 1500 Ext 3048
Quoted 3 lines
Sorry if this is a repeat, but I have not seen any response, and I'm not sure the message got to the list, and this is the last remaining issue for my linux package. So just in case it did not...
In doubt, you can check the mailing-list archive:
http://archives.andrew.net.au/lm-sensors/
(Your previous post is here:
http://archives.andrew.net.au/lm-sensors/msg06465.html)
Quoted 9 lines
A simple (I hope) question:
Why doesn'tbit_func()ini2c-algo-bit.cnot return with theI2C_FUNC_I2Cbit set?My chip driver needs to use
i2c_master_send()andi2c_master_recv(), and I cant' find any other functionality bit that makes sense. ?If I skip the functionality check, it seems to work. ?Did I miss something in the documentation, that is am I checking for the wrong functionality bit(s)?
I don't know (which is why I didn't answer in the first place, mind you). All I know is that this list of bits returned by i2c-algo-bit:bit_func has been reduced in Linux 2.6. This means that someone took a look and corrected the list to make it better, and did not include I2C_FUNC_I2C. This make me guess that this person knew what he/she was doing.
Maybe what you need to check is the I2C_FUNC_SMBUS_EMUL bit. But I don't know much more than you on the subject, so I'm just guessing.
Anyway, if bypassing the test make it work for you, I wouldn't bother much.
Sorry I cannot help you more.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Great question.
I just checked our sources and couldn't find any usage for I2C_FUNC_I2C except for the i2c-iop3xx driver supporting it.
Not a single chip driver checks it.
I can't say for sure what the intent was for I2C_FUNC_I2C.
But I do know that the preferred method for chip drivers, and the method that can take advantage of the functionality bitmask, is to use the i2c_smbus_xxx calls for all accesses.
Those capabilities are exported as I2C_FUNC_SMBUS_xxx bits.
The advantage is that they will work with both low-level i2c bit-banging drivers, like i2c-algo-bit, and high-level PCI SMBus drivers. That's because i2c-core contains an "emulation layer" such that calls get
converted as neccessary to work with the particular adapter.
Then you can check for the specific operations you require with the functionality, and it will work on any adapter that supports it, whether smbus or i2c.
The low-level i2c_master_xxx calls shouldn't be necessary unless you are doing i2c-specific things that i2c-core doesn't provide exported as a i2c_smbus_xxx call. And if you do need something like that, you may want to discuss it with us, perhaps it should be in i2c-core.
If you must use master_xfer, (i.e. it must be a low-level i2c adapter), the correct method of detecting that capability is
if(adapter->algo->master_xfer) {
/* you're good */
} else {
/* must be an smbus adapter */
}i.e., check that the function is non-null.
let us know if you have other questions.
mds
Quoted 37 lines · Sean S Fendt
To anyone who may be able to help.
Sorry if this is a repeat, but I have not seen any response, and I'm not sure the message got to the list, and this is the last remaining issue for my linux package. So just in case it did not...
I'm writing drivers for custom hardware on Octagon System's line of embedded PCs. I'm busy with an I2C bus and chip driver set for our GX1 based products, using kernel 2.6.2.
A simple (I hope) question:
Why doesn'tbit_func()ini2c-algo-bit.cnot return with theI2C_FUNC_I2Cbit set?My chip driver needs to use
i2c_master_send()andi2c_master_recv(), and I cant' find any other functionality bit that makes sense. If I skip the functionality check, it seems to work. Did I miss something in the documentation, that is am I checking for the wrong functionality bit(s)?Background:
The I2C bus is just a couple of GPIO leads from the 5530 companion part. The custom driver using the bit-bang algorithm seems to be working fine.
The custom chip driver is for a 4KByte EEPROM, of which 2KB is available to the user for static data storage (the other is used to store bios settings without need for a battery, and for video configuration and system diagnostics and test). The driver gives read-write access to the user half of the device. This too, seems to be working fine, except for the
check_functionalitycall, which is temporarily commented out.Both of the above will be released under the GPL, and ship with full source in our linux development kits. They are available to the project if there is any interest. Presently this combination works with 3 of Octagon's SBCs and are expected to support at least one more product currently in development.
Thanks in advance for any thoughts or suggestions.
Mark,
Thanks for the info, I think you've given me a way to test what I need.
I fear I need to use the i2c_master functions because my EEPROM uses a 2 byte address (not the chip address, but the word address for internal data, it's a
4 KB part). If I remember correctly, the i2c_smbus_xxx calls can't
correctly handle this (I had tried to use my driver with lm_sensors on a 2.4 project using the i801 SMBUS driver, and couldn't get it to work. In future we have a rule that no 2-byte address EEPROMS can exist on SMBUSes only true I2C busses).
This brings me to another question that may help me in two projects. Is there any way to use the large 2-byte address EEPROMS using only SMBUS calls?
Thanks again.
Signature · 1 line
-- Sean Fendt
Quoted 80 lines · Mark Studebaker
Great question.
I just checked our sources and couldn't find any usage for
I2C_FUNC_I2Cexcept for the i2c-iop3xx driver supporting it.
Not a single chip driver checks it.I can't say for sure what the intent was for
I2C_FUNC_I2C.But I do know that the preferred method for chip drivers, and the method that can take advantage of the functionality bitmask, is to use the
i2c_smbus_xxxcalls for all accesses.
Those capabilities are exported asI2C_FUNC_SMBUS_xxxbits.The advantage is that they will work with both low-level i2c bit-banging drivers, like i2c-algo-bit, and high-level PCI SMBus drivers. That's because i2c-core contains an "emulation layer" such that calls get
converted as neccessary to work with the particular adapter.Then you can check for the specific operations you require with the functionality, and it will work on any adapter that supports it, whether smbus or i2c.
The low-level
i2c_master_xxxcalls shouldn't be necessary unless you are doing i2c-specific things that i2c-core doesn't provide exported as ai2c_smbus_xxxcall. And if you do need something like that, you may want to discuss it with us, perhaps it should be in i2c-core.If you must use
master_xfer, (i.e. it must be a low-level i2c adapter), the correct method of detecting that capability isif(adapter->algo->master_xfer) { /* you're good */ } else { /* must be an smbus adapter */ }i.e., check that the function is non-null.
let us know if you have other questions.
mds
Quoted 38 lines · Sean S Fendt
To anyone who may be able to help.
Sorry if this is a repeat, but I have not seen any response, and I'm not sure the message got to the list, and this is the last remaining issue for my linux package. So just in case it did not...
I'm writing drivers for custom hardware on Octagon System's line of embedded PCs. I'm busy with an I2C bus and chip driver set for our GX1 based products, using kernel 2.6.2.
A simple (I hope) question:
Why doesn'tbit_func()ini2c-algo-bit.cnot return with theI2C_FUNC_I2Cbit set?My chip driver needs to use
i2c_master_send()andi2c_master_recv(), and I cant' find any other functionality bit that makes sense. If I skip the functionality check, it seems to work. Did I miss something in the documentation, that is am I checking for the wrong functionality bit(s)?Background:
The I2C bus is just a couple of GPIO leads from the 5530 companion part. The custom driver using the bit-bang algorithm seems to be working fine.
The custom chip driver is for a 4KByte EEPROM, of which 2KB is available to the user for static data storage (the other is used to store bios settings without need for a battery, and for video configuration and system diagnostics and test). The driver gives read-write access to the user half of the device. This too, seems to be working fine, except for the
check_functionalitycall, which is temporarily commented out.Both of the above will be released under the GPL, and ship with full source in our linux development kits. They are available to the project if there is any interest. Presently this combination works with 3 of Octagon's SBCs and are expected to support at least one more product currently in development.
Thanks in advance for any thoughts or suggestions.