mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect"
@ 2019-10-08  5:06 Andrey Smirnov
  2019-10-08  5:06 ` [PATCH 2/2] ARM: dts: vf610-zii-scu4-aib: Add "i2c-mux-idle-disconnect" to I2C muxes Andrey Smirnov
  2019-10-14 10:15 ` [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect" Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Smirnov @ 2019-10-08  5:06 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add support for "i2c-mux-idle-disconnect" binding to match the
behavior, already present in upstream kernel driver. This feature is a
must have for I2C bus topologies with multiple muxes connected to
child segments containing slaves with identical addresses (e.g. ZII's
SCU4)

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 42bde5ed1c..aa7dcb8c31 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -170,6 +170,16 @@ static int pca954x_select_chan(struct i2c_adapter *adap,
 	return ret;
 }
 
+static int pca954x_deselect_chan(struct i2c_adapter *adap,
+				 void *client, u32 chan)
+{
+	struct pca954x *data = i2c_get_clientdata(client);
+
+	/* Deselect active channel */
+	data->last_chan = 0;
+	return pca954x_reg_write(adap, client, data->last_chan);
+}
+
 /*
  * I2C init/probing/exit functions
  */
@@ -182,6 +192,7 @@ static int pca954x_probe(struct device_d *dev)
 	uintptr_t tmp;
 	int ret = -ENODEV;
 	int gpio;
+	bool idle_disconnect;
 
 	data = kzalloc(sizeof(struct pca954x), GFP_KERNEL);
 	if (!data) {
@@ -209,6 +220,9 @@ static int pca954x_probe(struct device_d *dev)
 	if (ret)
 		goto exit_free;
 
+	idle_disconnect = of_property_read_bool(dev->device_node,
+						"i2c-mux-idle-disconnect");
+
 	data->last_chan = 0;		   /* force the first selection */
 
 	/* Now create an adapter for each channel */
@@ -216,7 +230,10 @@ static int pca954x_probe(struct device_d *dev)
 
 		data->virt_adaps[num] =
 			i2c_add_mux_adapter(adap, &client->dev, client,
-				0, num, pca954x_select_chan, NULL);
+					    0, num, pca954x_select_chan,
+					    idle_disconnect ?
+					    pca954x_deselect_chan :
+					    NULL);
 
 		if (data->virt_adaps[num] == NULL) {
 			ret = -ENODEV;
-- 
2.21.0


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

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

* [PATCH 2/2] ARM: dts: vf610-zii-scu4-aib: Add "i2c-mux-idle-disconnect" to I2C muxes
  2019-10-08  5:06 [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect" Andrey Smirnov
@ 2019-10-08  5:06 ` Andrey Smirnov
  2019-10-14 10:15 ` [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect" Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Andrey Smirnov @ 2019-10-08  5:06 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add "i2c-mux-idle-disconnect" to I2C muxes to prevent identical slaves
from different segments from interfering with each other.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/dts/vf610-zii-scu4-aib.dts | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/vf610-zii-scu4-aib.dts b/arch/arm/dts/vf610-zii-scu4-aib.dts
index 43a13e243d..1e6a54954a 100644
--- a/arch/arm/dts/vf610-zii-scu4-aib.dts
+++ b/arch/arm/dts/vf610-zii-scu4-aib.dts
@@ -109,3 +109,11 @@
 		label = "fiber9";
 	};
 };
+
+/*
+ * FIXME: Remove once this code appears in kernel DTS
+*/
+&i2c2 {
+	tca9548@70 { i2c-mux-idle-disconnect; };
+	tca9548@71 { i2c-mux-idle-disconnect; };
+};
-- 
2.21.0


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

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

* Re: [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect"
  2019-10-08  5:06 [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect" Andrey Smirnov
  2019-10-08  5:06 ` [PATCH 2/2] ARM: dts: vf610-zii-scu4-aib: Add "i2c-mux-idle-disconnect" to I2C muxes Andrey Smirnov
@ 2019-10-14 10:15 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2019-10-14 10:15 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Mon, Oct 07, 2019 at 10:06:56PM -0700, Andrey Smirnov wrote:
> Add support for "i2c-mux-idle-disconnect" binding to match the
> behavior, already present in upstream kernel driver. This feature is a
> must have for I2C bus topologies with multiple muxes connected to
> child segments containing slaves with identical addresses (e.g. ZII's
> SCU4)
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  drivers/i2c/muxes/i2c-mux-pca954x.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

-- 
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] 3+ messages in thread

end of thread, other threads:[~2019-10-14 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08  5:06 [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect" Andrey Smirnov
2019-10-08  5:06 ` [PATCH 2/2] ARM: dts: vf610-zii-scu4-aib: Add "i2c-mux-idle-disconnect" to I2C muxes Andrey Smirnov
2019-10-14 10:15 ` [PATCH 1/2] i2c-mux-pca954x: Add support for "i2c-mux-idle-disconnect" Sascha Hauer

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