2013-03-30 15 views
6

Sto lavorando su un driver mfd. Esiste un singolo bus i2c, condiviso da quattro dispositivi client i2c (su un singolo circuito integrato). L'API i2c_new_dummy viene utilizzata quando si collega un adattatore a ciascun client.Cosa fa un i2c_new_dummy?

Perché è necessario disporre di una logica adattatore diversa per client diversi? Come funziona effettivamente un dispositivo mfd?

risposta

7

Come sappiamo, il bus I2C avrà 127 client dalla definizione specifica; a 7bitindirizzo con 1bit per lettura/scrittura.

Il primo byte sarà l'indirizzo I2C dispositivo , e il dispositivo corrispondente a questo indirizzo, tirerà giù il bit ACK. Segue i dati , il più delle volte questo sarà l'indirizzo di un registro.

Quindi, se si dispone di quattro client I2C, si otterranno quattro dispositivi e quattro handle client, anche se sono contenuti nel SOC .

Ma a volte non è necessario così tanto.

Un altro caso è il corrente SOC, un chip (come tps65910) avrà un sacco di funzioni, includono accensione tensione, CODEC, e così via. Ogni autista utilizzerà I2C per impostare il registro. Non è possibile richiedere un handle per un driver, quindi è per questo che chiama i2c_new_dummy.

Commenti degli 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. 
*/ 
+0

+1 per citando la documentazione del kernel. –

+0

@liyaoshi: grazie. molto chiaro..! – kzs