i2c/mux: Driver for PCA9541 I2C Master Selector
Subsystems (2)
PATCH v3 1/1 i2c/mux: Driver for PCA9541 I2C Master Selector
This patch adds support for PCA9541, an I2C Bus Master Selector. The driver is modeled as single channel I2C Multiplexer to be able to utilize the I2C multiplexer framework.
---
v3 changes:
- Clarified and cleaned up comments.
- No longer pass "struct i2c_adapter *" as parameter.
Get it from client->adapter if needed.
- No longer pass "struct pca9541 *" as parameter.
Pass "struct i2c_client *" instead and get "struct pca9541 *" from it if needed.
- Removed "struct i2c_client *client" from struct pca9541 since it is no longer needed.
- Moved "pca9541_release_bus(client);" ahead of i2c_add_mux_adapter() to avoid a possible race condition. Also protect the call with i2c_lock_adapter() / i2c_unlock_adapter().
- Removed __devinit from pca9541_probe() and __devexit from pca9541_remove().
v2 changes:
- Added more detailed description and reasoning why the driver was implemented as single-channel multiplexer.
- Modified arbitration algorithm, since access to i2c masters from interrupt level is not a good idea. Instead of using hrtimers and handling arbitration in interrupt, handle it from select_chan and either delay for short retry periods or sleep for long (millisecond) periods.
drivers/i2c/muxes/Kconfig | 10 + drivers/i2c/muxes/Makefile | 1 + drivers/i2c/muxes/pca9541.c | 411 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 422 insertions(+), 0 deletions(-) create mode 100644 drivers/i2c/muxes/pca9541.c
drivers/i2c/muxes/Kconfig +10 -0
@@ -5,6 +5,16 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_MUX_PCA9541 + tristate "NXP PCA9541 I2C Master Selector" + depends on EXPERIMENTAL + help + If you say yes here you get support for the NXP PCA9541 + I2C Master Selector. + + This driver can also be built as a module. If so, the module + will be called pca9541. + config I2C_MUX_PCA954x tristate "Philips PCA954x I2C Mux/switches" depends on EXPERIMENTAL
drivers/i2c/muxes/Makefile +1 -0
@@ -1,6 +1,7 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_MUX_PCA9541) += pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += pca954x.o ifeq ($(CONFIG_I2C_DEBUG_BUS),y)
drivers/i2c/muxes/pca9541.c new file +411 -0
411 lines not on this page · raw message
Signature · 1 line
1.7.3.1
Jean Delvare
AppliedQuoted 6 lines · Guenter Roeck
This patch adds support for PCA9541, an I2C Bus Master Selector. The driver is modeled as single channel I2C Multiplexer to be able to utilize the I2C multiplexer framework.
Signed-off-by Guenter Roeck <[email protected]>Reviewed-by Tom Grennan <[email protected]>
Quoted 14 lines
---
v3 changes:
- Clarified and cleaned up comments.
- No longer pass "structi2c_adapter*" as parameter.
Get it fromclient->adapterif needed.
- No longer pass "struct pca9541 *" as parameter.
Pass "structi2c_client*" instead and get "struct pca9541 *" from it if needed.
- Removed "structi2c_client*client" from struct pca9541 since it is no longer needed.
- Moved "pca9541_release_bus(client);" ahead ofi2c_add_mux_adapter()to avoid a possible race condition. Also protect the call withi2c_lock_adapter()/i2c_unlock_adapter().
- Removed__devinitfrompca9541_probe()and__devexitfrompca9541_remove().
Applied, thanks.
Would you mind adding yourself to MAINTAINERS as a maintainer for this driver? While the driver is small, it's not trivial and it's difficult to work on it without the right hardware setup.
Signature · 1 line
Jean Delvare
Quoted 22 lines · Jean Delvare
Quoted 6 lines · Guenter Roeck
This patch adds support for PCA9541, an I2C Bus Master Selector. The driver is modeled as single channel I2C Multiplexer to be able to utilize the I2C multiplexer framework.
Quoted 14 lines
---
v3 changes:
- Clarified and cleaned up comments.
- No longer pass "structi2c_adapter*" as parameter.
Get it fromclient->adapterif needed.
- No longer pass "struct pca9541 *" as parameter.
Pass "structi2c_client*" instead and get "struct pca9541 *" from it if needed.
- Removed "structi2c_client*client" from struct pca9541 since it is no longer needed.
- Moved "pca9541_release_bus(client);" ahead ofi2c_add_mux_adapter()to avoid a possible race condition. Also protect the call withi2c_lock_adapter()/i2c_unlock_adapter().
- Removed__devinitfrompca9541_probe()and__devexitfrompca9541_remove().
Quoted 6 lines
Applied, thanks.
Would you mind adding yourself to
MAINTAINERSas a maintainer for this driver? While the driver is small, it's not trivial and it's difficult to work on it without the right hardware setup.
Sure. Not intentional - I wanted to do that, just forgot. And I agree, it is pretty much impossible to maintain it unless you have HW to test it.
Want me to resubmit or send a separate patch ?
Thanks,
Guenter
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Jean Delvare
Quoted 6 lines · Guenter Roeck
This patch adds support for PCA9541, an I2C Bus Master Selector. The driver is modeled as single channel I2C Multiplexer to be able to utilize the I2C multiplexer framework.
Quoted 14 lines
---
v3 changes:
- Clarified and cleaned up comments.
- No longer pass "structi2c_adapter*" as parameter.
Get it fromclient->adapterif needed.
- No longer pass "struct pca9541 *" as parameter.
Pass "structi2c_client*" instead and get "struct pca9541 *" from it if needed.
- Removed "structi2c_client*client" from struct pca9541 since it is no longer needed.
- Moved "pca9541_release_bus(client);" ahead ofi2c_add_mux_adapter()to avoid a possible race condition. Also protect the call withi2c_lock_adapter()/i2c_unlock_adapter().
- Removed__devinitfrompca9541_probe()and__devexitfrompca9541_remove().Applied, thanks.
Quoted 8 lines
Quoted 4 lines
Would you mind adding yourself to
MAINTAINERSas a maintainer for this driver? While the driver is small, it's not trivial and it's difficult to work on it without the right hardware setup.Sure. Not intentional - I wanted to do that, just forgot. And I agree, it is pretty much impossible to maintain it unless you have HW to test it.
Want me to resubmit or send a separate patch ?
Separate patch, I'll merge them if needs be.
Signature · 1 line
Jean Delvare