mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] i2c fix + prepare for at24 support
@ 2012-11-03 20:46 Jean-Christophe PLAGNIOL-VILLARD
  2012-11-03 20:53 ` [PATCH 1/3] i2c: algo-bit add missing acknak Jean-Christophe PLAGNIOL-VILLARD
  2012-11-12  7:40 ` [PATCH 0/3] i2c fix + prepare for at24 support Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-03 20:46 UTC (permalink / raw)
  To: barebox

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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] i2c: algo-bit add missing acknak
  2012-11-03 20:46 [PATCH 0/3] i2c fix + prepare for at24 support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-03 20:53 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-11-03 20:53   ` [PATCH 2/3] i2c: introduce i2c_new_dummy Jean-Christophe PLAGNIOL-VILLARD
  2012-11-03 20:53   ` [PATCH 3/3] i2c: add id_table support Jean-Christophe PLAGNIOL-VILLARD
  2012-11-12  7:40 ` [PATCH 0/3] i2c fix + prepare for at24 support Sascha Hauer
  1 sibling, 2 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-03 20:53 UTC (permalink / raw)
  To: barebox

This is need for sequential read/write.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/i2c/algos/i2c-algo-bit.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 37af27c..dc43eb8 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -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;
 }
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] i2c: introduce i2c_new_dummy
  2012-11-03 20:53 ` [PATCH 1/3] i2c: algo-bit add missing acknak Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-03 20:53   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-11-03 20:53   ` [PATCH 3/3] i2c: add id_table support Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-03 20:53 UTC (permalink / raw)
  To: barebox

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).

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/i2c/i2c.c |   28 ++++++++++++++++++++++++++++
 include/i2c/i2c.h |    8 ++++++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 3af5c32..92d9442 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -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
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index b059119..dc5e5fc 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -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);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] i2c: add id_table support
  2012-11-03 20:53 ` [PATCH 1/3] i2c: algo-bit add missing acknak Jean-Christophe PLAGNIOL-VILLARD
  2012-11-03 20:53   ` [PATCH 2/3] i2c: introduce i2c_new_dummy Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-03 20:53   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-03 20:53 UTC (permalink / raw)
  To: barebox

this will be use by at24 driver

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/i2c/i2c.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 92d9442..94f23dd 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -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)
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] i2c fix + prepare for at24 support
  2012-11-03 20:46 [PATCH 0/3] i2c fix + prepare for at24 support Jean-Christophe PLAGNIOL-VILLARD
  2012-11-03 20:53 ` [PATCH 1/3] i2c: algo-bit add missing acknak Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-12  7:40 ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2012-11-12  7:40 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sat, Nov 03, 2012 at 09:46:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 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)

Applied, thanks

Sascha

> 
> ----------------------------------------------------------------
> 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
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-12  7:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-03 20:46 [PATCH 0/3] i2c fix + prepare for at24 support Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 20:53 ` [PATCH 1/3] i2c: algo-bit add missing acknak Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 20:53   ` [PATCH 2/3] i2c: introduce i2c_new_dummy Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 20:53   ` [PATCH 3/3] i2c: add id_table support Jean-Christophe PLAGNIOL-VILLARD
2012-11-12  7:40 ` [PATCH 0/3] i2c fix + prepare for at24 support Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox