Skip to contentSkip to conversation

i2c: mux: mellanox: add driver

PATCH Applied [email protected] 3 participants 4 messages Nov 10, 2016 – Nov 17, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: mux: mellanox: add driver

From: Vadim Pasternak <[email protected]>

This driver allows I2C routing controlled through CPLD select registers on a wide range of Mellanox systems (CPLD Lattice device).
MUX selection is provided by digital and analog HW. Analog part is not under SW control.
Digital part is under CPLD control (channel selection/de-selection).

Connectivity schema.

.---.             .-------------.
| l |             |             |-- i2cx1 -- i2cx8
| i |-- i2cn --+--| mlxcpld mux |
| n |          |  |             |-- i2cy1 -- i2cy8
| u |          |  '-------------'
| x |          |         |
'---'          '---------'

i2c-mux-mlxpcld does not necessarily require i2c-mlxcpld. It can be used along with another bus driver, and still control i2c routing through CPLD mux selection, in case the system is equipped with CPLD capable of mux selection control.

The Kconfig currently controlling compilation of this code is:
drivers/i2c/muxes/Kconfig:config I2C_MUX_MLXCPLD

---
v5->v5+1
Comments pointed out by Peter:
- Rebase patch due to codebase change;
- Fix license;
- Edit connectivity schema in submit message;
v4->v5
Fixes issues pointed out by Peter:
- Fix text is submit message;
- Fix text in Kconfig;
- Arrange Makefile in alphabetic order;
- Fix several comments;
- Drop assignment for force to zero in probe;
- Remove error message in probe - error message from i2c_mux_add_adapter

    is sufficient;

v3->v4
Fixes issues pointed out by Peter:
- Remove mlxcpld_mux_type;
- Remove member type from mux control structure;
- Remove variable muxes;
- mlxcpld_mux_reg_write - set address from client;
- mlxcpld_mux_reg_write - try smbus_xfer
- mlxcpld_mux_select_chan - remove compare with for mux type;
- mlxcpld_mux_probe - use I2C_FUNC_SMBUS_WRITE_BYTE_DATA instead of I2C_FUNC_SMBUS_BYTE
- mlxcpld_mux_probe - remove switch statement
- mlxcpld_mux_probe - update comment;
- mlxcpld_mux_probe -change logic in testing num_adaps;
- remove members first_channel and addr from mlxcpld_mux_plat_data

    structure;

v2->v3
Fixes issues pointed out by Peter:
- Fix several comments;
- In MAINTAINERS file use linux-i2c instead of linux-kernel;
- Place include files in alphabetic order;
- When channel select fail, set last_chan to zero for cleaning last value;
- Return with error from probe if there is no platform data;
- Use i2c_mux_reg driver for the lpc_access cases:
it fit well for Mellanox system with LPC access - has been tested and it
works good.
- Limit this driver to i2c_access only one device (mlxcpld_mux_module).
v1->v2
Fixes issues pointed out by Peter:
- changes in commit cover massage;
- change leg to channel in comments;
- missed return err;
- use platform data mux array rather the offset from 1st channel in probe

    routine;
  - remove owner field from driver structure;
  - use module_i2c_driver macros, instead if __init and __exit;
  - remove deselect on exit flag;
  - add record to MAINTAINER file;
---
 MAINTAINERS                         |   7 ++
 drivers/i2c/muxes/Kconfig           |  11 ++
 drivers/i2c/muxes/Makefile          |   1 +
 drivers/i2c/muxes/i2c-mux-mlxcpld.c | 220 ++++++++++++++++++++++++++++++++++++
 include/linux/i2c/mlxcpld.h         |  52 +++++++++
 5 files changed, 291 insertions(+)
 create mode 100644 drivers/i2c/muxes/i2c-mux-mlxcpld.c
 create mode 100644 include/linux/i2c/mlxcpld.h
MAINTAINERS +7 -0
index 411e3b8..22ee29a 100644
@@ -7881,6 +7881,13 @@ W:	http://www.mellanox.com
 Q:	http://patchwork.ozlabs.org/project/netdev/list/
 F:	drivers/net/ethernet/mellanox/mlxsw/
 
+MELLANOX MLXCPLD I2C MUX DRIVER
+M:	Vadim Pasternak <[email protected]>
+M:	Michael Shych <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/i2c/muxes/i2c-mux-mlxcpld.c
+
 MELLANOX MLXCPLD LED DRIVER
 M:	Vadim Pasternak <[email protected]>
 L:	[email protected]
drivers/i2c/muxes/Kconfig +11 -0
index e280c8e..d033402 100644
@@ -81,4 +81,15 @@ config I2C_DEMUX_PINCTRL
 	  demultiplexer that uses the pinctrl subsystem. This is useful if you
 	  want to change the I2C master at run-time depending on features.
 
+config I2C_MUX_MLXCPLD
+        tristate "Mellanox CPLD based I2C multiplexer"
+        help
+          If you say yes to this option, support will be included for a
+          CPLD based I2C multiplexer. This driver provides access to
+          I2C busses connected through a MUX, which is controlled
+          by a CPLD register.
+
+          This driver can also be built as a module.  If so, the module
+          will be called i2c-mux-mlxcpld.
+
 endmenu
drivers/i2c/muxes/Makefile +1 -0
index 7c267c2..9948fa4 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE)	+= i2c-arb-gpio-challenge.o
 obj-$(CONFIG_I2C_DEMUX_PINCTRL)		+= i2c-demux-pinctrl.o
 
 obj-$(CONFIG_I2C_MUX_GPIO)	+= i2c-mux-gpio.o
+obj-$(CONFIG_I2C_MUX_MLXCPLD)	+= i2c-mux-mlxcpld.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
drivers/i2c/muxes/i2c-mux-mlxcpld.c new file +220 -0

220 lines not on this page · raw message

include/linux/i2c/mlxcpld.h new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.1.4
#1 lore raw
Quoted 7 lines · On 2016-11-10 22:26, [email protected] wrote:

From: Vadim Pasternak <[email protected]>

This driver allows I2C routing controlled through CPLD select registers on a wide range of Mellanox systems (CPLD Lattice device).
MUX selection is provided by digital and analog HW. Analog part is not under SW control.
Digital part is under CPLD control (channel selection/de-selection).

*snip*

Thanks for your patience!

I changed my Acked-by into a Signed-off-by, fixed up a few multi-line comment formatting issues, and pushed it to the i2c-mux/for-next branch at https://github.com/peda-r/i2c-mux.git

Cheers,
Peter

#2 lore raw
Quoted 19 lines

-----Original Message-----
From: Peter Rosin [mailto:[email protected]]
Sent: Friday, November 11, 2016 10:36 AM
To: Vadim Pasternak <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Michael Shych <[email protected]>
Subject: Re: [patch v5+1 repost] i2c: mux: mellanox: add driver

Quoted 7 lines · On 2016-11-10 22:26, [email protected] wrote:

From: Vadim Pasternak <[email protected]>

This driver allows I2C routing controlled through CPLD select registers on a wide range of Mellanox systems (CPLD Lattice device). MUX selection is provided by digital and analog HW. Analog part is not under SW control.
Digital part is under CPLD control (channel selection/de-selection).

Quoted 7 lines

*snip*

Thanks for your patience!

I changed my Acked-by into a Signed-off-by, fixed up a few multi-line comment formatting issues, and pushed it to the i2c-mux/for-next branch at
https://github.com/peda-r/i2c-mux.git

Thank you very much, Peter.

Cheers,
Vadim.

Quoted 3 lines

Cheers,
Peter

Applied
#3 lore raw
In reply to [email protected]
Quoted 22 lines · On Thu, Nov 10, 2016 at 09:26:23PM +0000, [email protected] wrote:

From: Vadim Pasternak <[email protected]>

This driver allows I2C routing controlled through CPLD select registers on a wide range of Mellanox systems (CPLD Lattice device).
MUX selection is provided by digital and analog HW. Analog part is not under SW control.
Digital part is under CPLD control (channel selection/de-selection).

Connectivity schema.

.---.             .-------------.
| l |             |             |-- i2cx1 -- i2cx8
| i |-- i2cn --+--| mlxcpld mux |
| n |          |  |             |-- i2cy1 -- i2cy8
| u |          |  '-------------'
| x |          |         |
'---'          '---------'

i2c-mux-mlxpcld does not necessarily require i2c-mlxcpld. It can be used along with another bus driver, and still control i2c routing through CPLD mux selection, in case the system is equipped with CPLD capable of mux selection control.

Quoted 7 lines

The Kconfig currently controlling compilation of this code is:
drivers/i2c/muxes/Kconfig:config I2C_MUX_MLXCPLD

Applied to for-next, thanks!