i2c fix + prepare for at24 support
Subsystems (2)
cover i2c fix + prepare for at24 support
HI,
algo-bit: fix sequential read/write support
i2c: add id_table support
i2c: add i2c_new_dummy
This prepare for the at24 eeprom support
The following changes since commit 5c90416b6ffb8d4ca7c4bc6aff92578b555cb965:
i2c: add versatile support (2012-11-02 02:17:04 +0800)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git delivery/i2c
for you to fetch changes up to 5526278ac77ecd7109c9c1bbc35d7c74875902e7:
i2c: add id_table support (2012-11-03 13:33:54 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
i2c: algo-bit add missing acknak
i2c: introduce i2c_new_dummy
i2c: add id_table support
drivers/i2c/algos/i2c-algo-bit.c | 20 ++++++++++++++++++++ drivers/i2c/i2c.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/i2c/i2c.h | 8 ++++++++ 3 files changed, 72 insertions(+), 1 deletion(-)
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 i2c: algo-bit add missing acknak
This is need for sequential read/write.
--- drivers/i2c/algos/i2c-algo-bit.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/i2c/algos/i2c-algo-bit.c +20 -0
@@ -390,6 +390,22 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)return wrcount; } +static int acknak (struct i2c_adapter *i2c_adap,int is_ack) +{ +struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + +/* assert: sda is high */ +if (is_ack)/* send ack */ +setsda (adap,0 ); +udelay ((adap->udelay +1 ) /2 ); +if (sclhi (adap) <0 ) {/* timeout */ +dev_err (&i2c_adap->dev,"readbytes: ack/nak timeout\n" ); +return -ETIMEDOUT ; + } +scllo (adap); +return 0 ; +} +static int readbytes (struct i2c_adapter *i2c_adap,struct i2c_msg *msg) {int inval;
@@ -414,6 +430,10 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) (flags &I2C_M_NO_RD_ACK ) ?"(no ack/nak)" : (count ? "A" : "NA")); + + inval =acknak (i2c_adap, count); +if (inval <0 ) +return inval; }return rdcount; }
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 i2c: introduce i2c_new_dummy
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).
--- drivers/i2c/i2c.c | 28 ++++++++++++++++++++++++++++ include/i2c/i2c.h | 8 ++++++++ 2 files changed, 36 insertions(+)
drivers/i2c/i2c.c +28 -0
@@ -282,6 +282,34 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,EXPORT_SYMBOL (i2c_new_device);/** +* 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. +*/ +struct i2c_client *i2c_new_dummy (struct i2c_adapter *adapter,u16 address) +{ +struct i2c_board_info info = { +I2C_BOARD_INFO ("dummy" , address), + }; + +return i2c_new_device (adapter, &info); +} +EXPORT_SYMBOL_GPL (i2c_new_dummy); + +/** * i2c_register_board_info - register I2C devices for a given board * * @param info array of chip descriptors
include/i2c/i2c.h +8 -0
@@ -129,6 +129,14 @@ static inline int i2c_register_board_info(int busnum,extern int i2c_add_numbered_adapter (struct i2c_adapter *adapter);struct i2c_adapter *i2c_get_adapter (int busnum); +/* For devices that use several addresses, use i2c_new_dummy() to make +* client handles for the extra addresses. +*/ +extern struct i2c_client * +i2c_new_dummy (struct i2c_adapter *adap,u16 address); + + +extern int i2c_transfer (struct i2c_adapter *adap,struct i2c_msg *msgs,int num);extern int i2c_master_send (struct i2c_client *client,const char *buf,int count);extern int i2c_master_recv (struct i2c_client *client,char *buf,int count);
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 i2c: add id_table support
In reply to Jean-Christophe PLAGNIOL-VILLARDthis will be use by at24 driver
--- drivers/i2c/i2c.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/i2c/i2c.c +16 -1
@@ -420,7 +420,22 @@ EXPORT_SYMBOL(i2c_add_numbered_adapter);static int i2c_match (struct device_d *dev,struct driver_d *drv) { -return strcmp (dev->name, drv->name) ?-1 :0 ; +if (!strcmp (dev->name, drv->name)) +return 0 ; + +if (drv->id_table) { +struct platform_device_id *id = drv->id_table; + +while (id->name) { +if (!strcmp (id->name, dev->name)) { + dev->id_entry = id; +return 0 ; + } + id++; + } + } + +return -1 ; }static int i2c_probe (struct device_d *dev)
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 13 lines · Jean-Christophe PLAGNIOL-VILLARD
HI,
algo-bit: fix sequential read/write support
i2c: add
id_tablesupport
i2c: addi2c_new_dummyThis prepare for the at24 eeprom support
The following changes since commit
5c90416b6ffb8d4ca7c4bc6aff92578b555cb965:i2c: add versatile support (2012-11-02 02:17:04 +0800)
Quoted 7 lines
are available in the git repository at:
git://git.jcrosoft.org/barebox.gitdelivery/i2cfor you to fetch changes up to
5526278ac77ecd7109c9c1bbc35d7c74875902e7:i2c: add
id_tablesupport (2012-11-03 13:33:54 +0800)
Applied, thanks
Sascha
Quoted 20 lines
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
i2c: algo-bit add missing acknak
i2c: introducei2c_new_dummy
i2c: addid_tablesupportdrivers/i2c/algos/i2c-algo-bit.c | 20 ++++++++++++++++++++ drivers/i2c/i2c.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/i2c/i2c.h | 8 ++++++++ 3 files changed, 72 insertions(+), 1 deletion(-)Best Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox