diff mbox series

[RESEND] i2c: mux: pca9541: Change bus control commands and release control of bus

Message ID 20200603191426.GA20270@workpc
State New
Headers show
Series [RESEND] i2c: mux: pca9541: Change bus control commands and release control of bus | expand

Commit Message

Quentin Strydom June 3, 2020, 7:14 p.m. UTC
Change current bus commands to match the pca9541a datasheet
(see table 12 on page 14 of
https://www.nxp.com/docs/en/data-sheet/PCA9541A.pdf).

Also add change so that previous master releases control of bus.

Signed-off-by: Quentin Strydom <qstrydom0@gmail.com>
---
 drivers/i2c/muxes/i2c-mux-pca9541.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index 50e1fb4aedf5..eb2552fbd0d0 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -134,7 +134,8 @@  static void pca9541_release_bus(struct i2c_client *client)
 	reg = pca9541_reg_read(client, PCA9541_CONTROL);
 	if (reg >= 0 && !busoff(reg) && mybus(reg))
 		pca9541_reg_write(client, PCA9541_CONTROL,
-				  (reg & PCA9541_CTL_NBUSON) >> 1);
+				 (reg & (PCA9541_CTL_BUSON | PCA9541_CTL_MYBUS))
+				 ^ (PCA9541_CTL_BUSON | PCA9541_CTL_MYBUS));
 }
 
 /*
@@ -163,7 +164,7 @@  static void pca9541_release_bus(struct i2c_client *client)
 
 /* Control commands per PCA9541 datasheet */
 static const u8 pca9541_control[16] = {
-	4, 0, 1, 5, 4, 4, 5, 5, 0, 0, 1, 1, 0, 4, 5, 1
+	4, 4, 5, 5, 4, 4, 5, 5, 0, 0, 1, 1, 0, 0, 1, 1
 };
 
 /*