driver/i2c/mux: Add register-based mux i2c-mux-reg
Subsystems (3)
PATCH v5 1/1 driver/i2c/mux: Add register-based mux i2c-mux-reg
Based on i2c-mux-gpio driver, similarly the register-based mux switch from one bus to another by setting a single register. The register can be on PCIe bus, local bus, or any memory-mapped address. The endianness of such register can be specified in device tree if used, or in platform data.
---
Change log:
v5: Remove variable initial_state
Remove .owner = THIS_MODULE
v4: Rename no-read to write-only
Revise binding document
Revise endianness checking
Reorder in Kconfig and Makefile
Remove print for deferred probing
Remove debug print for unloading driver
v3: Add support of both big- and little-endian register
Add readback after writing to register
Add no-read option. By default, readback is alowed. Fix using chan_id transferred back from i2c-mux. It was mistakenly
used as an index. It is actually the data to be written.
v2: Update to GPLv2+ licence header
Use iowrite instead of direct dereference the pointer to write register Add support of difference register size of 1/2/4 bytes Remove i2c_put_adapter(parent) in probe fucntion
Replace multiple dev_info() with dev_dbg()
Add idle_in_use variable to gate using idle value
Add __iomem for register pointer
Move platform data header file to include/linux/platform_data/
.../devicetree/bindings/i2c/i2c-mux-reg.txt | 74 +++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 1 + drivers/i2c/muxes/i2c-mux-reg.c | 294 ++++++++++++++++++++ include/linux/platform_data/i2c-mux-reg.h | 44 +++ 5 files changed, 424 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt create mode 100644 drivers/i2c/muxes/i2c-mux-reg.c create mode 100644 include/linux/platform_data/i2c-mux-reg.h
Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt new file +74 -0
@@ -0,0 +1,74 @@ +Register-based I2C Bus Mux + +This binding describes an I2C bus multiplexer that uses a single register +to route the I2C signals. + +Required properties: +- compatible: i2c-mux-reg +- i2c-parent: The phandle of the I2C bus that this multiplexer's master-side + port is connected to. +* Standard I2C mux properties. See mux.txt in this directory. +* I2C child bus nodes. See mux.txt in this directory. + +Optional properties: +- reg: this pair of <offset size> specifies the register to control the mux. + The <offset size> depends on its parent node. It can be any memory-mapped + address. The size must be either 1, 2, or 4 bytes. If reg is omitted, the + resource of this device will be used. +- little-endian: The existence indicates the register is in little endian. +- big-endian: The existence indicates the register is in big endian. + If both little-endian and big-endian are omitted, the endianness of the + CPU will be used. +- write-only: The existence indicates the register is write-only. +- idle-state: value to set the muxer to when idle. When no value is + given, it defaults to the last value used. + +Whenever an access is made to a device on a child bus, the value set +in the revelant node's reg property will be output to the register. + +If an idle state is defined, using the idle-state (optional) property, +whenever an access is not being made to a device on a child bus, the +register will be set according to the idle value. + +If an idle state is not defined, the most recently used value will be +left programmed into the register. + +Example of a mux on PCIe card, the host is a powerpc SoC (big endian): + + i2c-mux { + /* the <offset size> depends on the address translation + * of the parent device. If omitted, device resource + * will be used instead. The size is to determine + * whether iowrite32, iowrite16, or iowrite8 will be used. + */ + reg = <0x6028 0x4>; + little-endian; /* little endian register on PCIe */ + compatible = "i2c-mux-reg"; + #address-cells = <1>; + #size-cells = <0>; + i2c-parent = <&i2c1>; + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + si5338: clock-generator@70 { + compatible = "silabs,si5338"; + reg = <0x70>; + /* other stuff */ + }; + }; + + i2c@1 { + /* data is written using iowrite32 */ + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + si5338: clock-generator@70 { + compatible = "silabs,si5338"; + reg = <0x70>; + /* other stuff */ + }; + }; + };
drivers/i2c/muxes/Kconfig +11 -0
@@ -60,4 +60,15 @@ config I2C_MUX_PINCTRL This driver can also be built as a module. If so, the module will be called pinctrl-i2cmux. +config I2C_MUX_REG + tristate "Register-based I2C multiplexer" + help + If you say yes to this option, support will be included for a + register based I2C multiplexer. This driver provides access to + I2C busses connected through a MUX, which is controlled + by a single register. + + This driver can also be built as a module. If so, the module + will be called i2c-mux-reg. + endmenu
drivers/i2c/muxes/Makefile +1 -0
@@ -7,5 +7,6 @@ obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o obj-$(CONFIG_I2C_MUX_PINCTRL) += i2c-mux-pinctrl.o +obj-$(CONFIG_I2C_MUX_REG) += i2c-mux-reg.o ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
drivers/i2c/muxes/i2c-mux-reg.c new file +294 -0
294 lines not on this page · raw message
include/linux/platform_data/i2c-mux-reg.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Wolfram Sang
AppliedQuoted 6 lines · York Sun
Based on i2c-mux-gpio driver, similarly the register-based mux switch from one bus to another by setting a single register. The register can be on PCIe bus, local bus, or any memory-mapped address. The endianness of such register can be specified in device tree if used, or in platform data.
Quoted 6 lines
Signed-off-by York Sun <[email protected]>CC Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>CC Paul Bolle <[email protected]>CC Peter Korsgaard <peter.korsgaard-ob4gmnvZ1/[email protected]>CC Alexander Sverdlin <[email protected]>
Applied to for-next, thanks!