i2c: add master driver for mellanox systems
Subsystems (3)
PATCH v9 1/1 i2c: add master driver for mellanox systems
From: Vadim Pasternak <[email protected]>
Device driver for Mellanox I2C controller logic, implemented in Lattice CPLD device.
Device supports:
- Master mode
- One physical bus
- Polling mode
The Kconfig currently controlling compilation of this code is:
drivers/i2c/busses/Kconfig:config I2C_MLXCPLD
---v8->v9
Comments pointed out by Wolfram:
- fix typo in comment;
- use quirk parameters for the message number validation;v7->v8
Comments pointed out by Wolfram:
- Remove descriptions for two structures, since the members have self-explaining names;
- Populate the structure i2c_adapter_quirks, so core will make length validation, as a result remove mlxcpld_i2c_invalid_len,
and move common length calculation to mlxcpld_i2c_xfer. Consider removing of mlxcpld_i2c_check_msg_params after core quirks is able to handle messages full validation;
- Use ENXIO error code for NACK;v6->v7
Comments pointed out by Peter:
- Fix grammar in doc file;
- Fix description for CMD in doc file;
- Fix grammar for NUM_DATA, DATAx in doc file;
- Rename mlxcpld_i2c_curr_transf to mlxcpld_i2c_curr_xfer;
- Make code in mlxcpld_i2c_lpc_write_buf more readable and mlxcpld_i2c_lpc_read_buf, compact and elegant;
- Fix multiline comments;v5->v6:
Comments pointed out by Vladimir:
- Drop the line with module path from the header;
- In description of mlxcpld_i2c_priv remove lpc_gen_dec_reg asnd dev_id;
- In mlxcpld_i2c_priv change type of the filed base_addr to u16 for the alignment with in/out and remove unused dev_id;
- Fix misspelling in comment for mlxcpld_i2c_invalid_len;
- Remove comment regarding EBUSY return in mlxcpld_i2c_check_busy;
- Use sizeof of the target storage in allocation in probe routine;v4->v5:
Comments pointed out by Vladimir:
- Remove "default n" from Kconfig;
- Fix the comments for timeout and pool time;
- Optimize error flow in mlxcpld_i2c_probe;v3->v4:
Comments pointed out by Vladimir:
- Set default to no in Kconfig;
- Make mlxcpld_i2c_plat_dev static and add empty line before the declaration;
- In function mlxcpld_i2c_invalid_len remove (msg->len < 0), since len is unsigned;
- Remove unused symbol mlxcpld_i2c_plat_dev;
- Remove extra spaces in comments to mlxcpld_i2c_check_msg_params;
- Remove unnecessary round braces in mlxcpld_i2c_set_transf_data;
- Remove the assignment of 'i' variable in mlxcpld_i2c_wait_for_tc;
- Add extra line in mlxcpld_i2c_xfer;
- Move assignment of the adapter's fields retries and nr inside mlxcpld_i2c_adapter declaration;v2->v3:
Comments pointed out by Vladimir:
- Use tab symbol as indentation in Kconfig
- Add the Kconfig section preserving the alphabetical order - added within "Other I2C/SMBus bus drivers" after I2C_ELEKTOR (but after this sections others are not follow alphabetical);
- Change license to dual;
- Replace ADRR with ADDR in macros;
- Remove unused macros: MLXCPLD_LPCI2C_LPF_DFLT, MLXCPLD_LPCI2C_HALF_CYC_100, MLXCPLD_LPCI2C_I2C_HOLD_100, MLXCPLD_LPCI2C_HALF_CYC_REG, MLXCPLD_LPCI2C_I2C_HOLD_REG;
- Fix checkpatch warnings (**/ and the end of comment);
- Add empty line before structures mlxcpld_i2c_regs, mlxcpld_i2c_curr_transf, mlxcpld_i2c_priv;
- Remove unused structure mlxcpld_i2c_regs;
- Remove from mlxcpld_i2c_priv the next fields:
retr_num, poll_time, block_sz, xfer_to; use instead macros
respectively: MLXCPLD_I2C_RETR_NUM, MLXCPLD_I2C_POLL_TIME, MLXCPLD_I2C_DATA_REG_SZ, MLXCPLD_I2C_XFER_TO;
- In mlxcpld_i2c_invalid_len remove unnecessary else;
- Optimize mlxcpld_i2c_set_transf_data;
- mlxcpld_i2c_reset - add empty lines after/before mutex lock/unlock;
- mlxcpld_i2c_wait_for_free - cover case timeout is equal MLXCPLD_I2C_XFER_TO;
- mlxcpld_i2c_wait_for_tc:
- Do not assign err in declaration (also err is removed);
- Insert empty line before case MLXCPLD_LPCI2C_ACK_IND;
- inside case MLXCPLD_LPCI2C_ACK_IND - avoid unnecessary
indentation;
- Remove case MLXCPLD_LPCI2C_ERR_IND and remove this macro;
- Add empty lines in mlxcpld_i2c_xfer before/after mutex_lock/ mutex_unlock;
- In mlxcpld_i2c_probe add emtpy line after platform_set_drvdata;
- Replace platfrom handle pdev in mlxcpld_i2c_priv with the pointer to the structure device;
- Place assignment of base_addr near the others;
- Enclose e-mail with <>;
Fixes added by Vadim:
- Change structure description format according to Documentation/kernel-documentation.rst guideline;
- mlxcpld_i2c_wait_for_tc: return error if status reaches default case;v1->v2
Fixes added by Vadim:
- Put new record in Makefile in alphabetic order;
- Remove http://www.mellanox.com from MAINTAINERS record;
--- Documentation/i2c/busses/i2c-mlxcpld | 47 ++++ MAINTAINERS | 8 + drivers/i2c/busses/Kconfig | 11 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-mlxcpld.c | 504 +++++++++++++++++++++++++++++++++++ 5 files changed, 571 insertions(+) create mode 100644 Documentation/i2c/busses/i2c-mlxcpld create mode 100644 drivers/i2c/busses/i2c-mlxcpld.c
Documentation/i2c/busses/i2c-mlxcpld new file +47 -0
@@ -0,0 +1,47 @@ +Driver i2c-mlxcpld + +Author: Michael Shych <[email protected]> + +This is the Mellanox I2C controller logic, implemented in Lattice CPLD +device. +Device supports: + - Master mode. + - One physical bus. + - Polling mode. + +This controller is equipped within the next Mellanox systems: +"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410", "msb7800", +"msn2740", "msn2100". + +The next transaction types are supported: + - Receive Byte/Block. + - Send Byte/Block. + - Read Byte/Block. + - Write Byte/Block. + +Registers: +CTRL 0x1 - control reg. + Resets all the registers. +HALF_CYC 0x4 - cycle reg. + Configure the width of I2C SCL half clock cycle (in 4 LPC_CLK + units). +I2C_HOLD 0x5 - hold reg. + OE (output enable) is delayed by value set to this register + (in LPC_CLK units) +CMD 0x6 - command reg. + Bit 0, 0 = write, 1 = read. + Bits [7:1] - the 7bit Address of the I2C device. + It should be written last as it triggers an I2C transaction. +NUM_DATA 0x7 - data size reg. + Number of data bytes to write in read transaction +NUM_ADDR 0x8 - address reg. + Number of address bytes to write in read transaction. +STATUS 0x9 - status reg. + Bit 0 - transaction is completed. + Bit 4 - ACK/NACK. +DATAx 0xa - 0x54 - 68 bytes data buffer regs. + For write transaction address is specified in four first bytes + (DATA1 - DATA4), data starting from DATA4. + For read transactions address is sent in a separate transaction and + specified in the four first bytes (DATA0 - DATA3). Data is read + starting from DATA0.
MAINTAINERS +8 -0
@@ -7881,6 +7881,14 @@ W: http://www.mellanox.com Q: http://patchwork.ozlabs.org/project/netdev/list/ F: drivers/net/ethernet/mellanox/mlxsw/ +MELLANOX MLXCPLD I2C DRIVER +M: Vadim Pasternak <[email protected]> +M: Michael Shych <[email protected]> +L: [email protected] +S: Supported +F: drivers/i2c/busses/i2c-mlxcpld.c +F: Documentation/i2c/busses/i2c-mlxcpld + MELLANOX MLXCPLD LED DRIVER M: Vadim Pasternak <[email protected]> L: [email protected]
drivers/i2c/busses/Kconfig +11 -0
@@ -1150,6 +1150,17 @@ config I2C_ELEKTOR This support is also available as a module. If so, the module will be called i2c-elektor. +config I2C_MLXCPLD + tristate "Mellanox I2C driver" + depends on X86_64 + help + This exposes the Mellanox platform I2C busses to the linux I2C layer + for X86 based systems. + Controller is implemented as CPLD logic. + + This driver can also be built as a module. If so, the module will be + called as i2c-mlxcpld. + config I2C_PCA_ISA tristate "PCA9564/PCA9665 on an ISA bus" depends on ISA
drivers/i2c/busses/Makefile +1 -0
@@ -116,6 +116,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o +obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o obj-$(CONFIG_I2C_OPAL) += i2c-opal.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
drivers/i2c/busses/i2c-mlxcpld.c new file +504 -0
504 lines not on this page · raw message
Signature · 1 line
2.1.4
Wolfram Sang
AppliedQuoted 9 lines · On Sun, Nov 20, 2016 at 04:56:14PM +0000, [email protected] wrote:
From: Vadim Pasternak <[email protected]>
Device driver for Mellanox I2C controller logic, implemented in Lattice CPLD device.
Device supports:
- Master mode
- One physical bus
- Polling mode
Quoted 7 lines
The
Kconfigcurrently controlling compilation of this code is:
drivers/i2c/busses/Kconfig:configI2C_MLXCPLDSigned-off-by Michael Shych <[email protected]>Signed-off-by Vadim Pasternak <[email protected]>Reviewed-by Jiri Pirko <[email protected]>Reviewed-by Vladimir Zapolskiy <[email protected]>
Applied to for-next, thanks!
Quoted 24 lines
-----Original Message-----
From: Wolfram Sang [mailto:[email protected]]
Sent: Thursday, November 24, 2016 4:52 PM
To: Vadim Pasternak <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Michael Shych <[email protected]>
Subject: Re: [patch v9 1/1] i2c: add master driver for mellanox systemsQuoted 12 lines · On Sun, Nov 20, 2016 at 04:56:14PM +0000, [email protected] wrote:
From: Vadim Pasternak <[email protected]>
Device driver for Mellanox I2C controller logic, implemented in Lattice CPLD device.
Device supports:
- Master mode
- One physical bus
- Polling modeThe
Kconfigcurrently controlling compilation of this code is:
drivers/i2c/busses/Kconfig:configI2C_MLXCPLD
Quoted 6 lines
Quoted 4 lines
Signed-off-by Michael Shych <[email protected]>Signed-off-by Vadim Pasternak <[email protected]>Reviewed-by Jiri Pirko <[email protected]>Reviewed-by Vladimir Zapolskiy <[email protected]>Applied to for-next, thanks!
Thank you very,
Vadim.