I am working on an mfd driver. There is a single i2c bus, shared by four i2c client devices (on s single IC). The i2c_new_dummy
API is used when attaching an adapter to each of the clients.
Why is it necessary to have a different adapter logic for different clients? How does an mfd device actually work?
As we know, the I2C
bus will have 127 clients from the spec definition; a 7bit
address with 1bit
for read/write.
The first byte will be the I2C
device address, and the device matching this address, will pull down the ACK
bit. Next follows the data, most of the time this will be the address of a register.
So, if you have four I2C
clients, you will get four devices and four client handles, even if they are contained in the SOC.
But sometimes you don't need so much.
Another case is on current SOC, one chip (like tps65910) will have lots of function, include turning on voltage, CODEC, and so on. Every driver will use I2C
to set the register. You can not request one handle for one driver so this is why it call i2c_new_dummy
.
Comments from kernel i2c-core.c,
/**
* i2c_new_dummy - return a new i2c device bound to a dummy driver
* @adapter: the adapter managing the device
* @address: seven bit address to be used
* Context: can sleep
*
* This returns an I2C client bound to the "dummy" driver, intended for use
* with devices that consume multiple addresses. Examples of such chips
* include various EEPROMS (like 24c04 and 24c08 models).
*
* These dummy devices have two main uses. First, most I2C and SMBus calls
* except i2c_transfer() need a client handle; the dummy will be that handle.
* And second, this prevents the specified address from being bound to a
* different driver.
*
* This returns the new i2c client, which should be saved for later use with
* i2c_unregister_device(); or NULL to indicate an error.
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With