i2c: add driver for Mellanox BlueField SoC
Khalil Blaiech
maintainerv11 cover i2c: add driver for Mellanox BlueField SoC
From: Khalil Blaiech <[email protected]>
Add I2C SMBus driver and device tree bindings documentation.
The Mellanox BlueField is a System-on-Chip (SoC) that combines Arm cores and ConnectX network adapter technology intended to accelerate storage network solutions. The Mellanox BlueField incorporates various I2C devices that are accessed using SMBus protocol, a variant of the I2C protocol. On storage controllers, the BlueField SoC is connected to a management controller board, e.g., BMC via an I2C bus.
An I2C driver running on the Arm side is needed to manage the hardware I2C controllers. The driver enables a master function to transfer data back and forth from/to I2C devices, such as EEPROM parts and implements a slave function to handle the BMC controller requests.
---v10->v11:
- Fixing checkpatch (--strict) warnings.
- Fixing sparse warnings.v9->v10:
- Fixing compile issue when building with gcc 9.3.0 and Werror enabled; remove unused variable in mlxbf_slave_enable().v8->v9:
- Fixing implicit declaration of devm_ioremap_nocache and ioremap_nocache build error.v7->v8:
- Updating the dependency expression in Kconfig.
- Fixing an implicit fallthrough build error.v6->v7:
- Fixing kernel coding style issues as suggested by Mellanox internal code reviewers.
- Updating the dependency expression in Kconfig.
- Fixing various device driver bugs.
- Adding an entry to MAINTAINERS file.v5->v6:
- Fixing kernel coding style issues detected using '--strict' flag.
- Updating the device binding documentation to add support for BlueField-2 SoCs.v4->v5:
- Fixing device driver bug.v3->v4:
- Review of the device binding documentation to fix format issue and miscellaneous cleanup.v2->v3:
- Various device driver changes and bug fixes.
- Updating the device property in the device binding documentation and file format review.v1->v2:
- Various device driver changes and bug fixes.
- Cleanup of the device binding documentation.
Khalil Blaiech (2):
i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
.../devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt | 42 + MAINTAINERS | 6 + drivers/i2c/busses/Kconfig | 13 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-mlxbf.c | 2506 ++++++++++++++++++++ 5 files changed, 2568 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt create mode 100644 drivers/i2c/busses/i2c-mlxbf.c
Signature · 1 line
2.1.2
Khalil Blaiech
maintainerPATCH v11 1/2 i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
From: Khalil Blaiech <[email protected]>
Add BlueField I2C driver to offer master and slave support for Mellanox BlueField SoCs. The driver implements an SMBus adapter and interfaces to multiple busses that can be probed using both ACPI and Device Tree infrastructures.
The driver supports several SMBus operations to transfer data back and forth from/to various I2C devices. It is mainly intended to be consumed by userspace tools and utilities, such as i2c-tools and decode-dimms to collect memory module information.
On the other hand, the driver has a slave function to support, among others, an IPMB interface that requires both master and slave functions to handle transfers between the BlueField SoC and a board management controllers (e.g., BMC).
---v10->v11:
- Fixing checkpatch (--strict) warnings.
- Fixing sparse warnings.v9->v10:
- Fixing compile issue when building with gcc 9.3.0 and Werror enabled; remove unused variable in mlxbf_slave_enable().v8->v9:
- Replacing devm_ioremap_nocache and ioremap_nocache with devm_ioremap since the non-cached interface has been removed.v7->v8:
- Removing 'COMPILE_TEST' dependency in Kconfig.
- Fixing switch statement fallthrough comment to prevent warnings and/or build errors.v6->v7:
- Fixing kernel coding style issues.
- Rewording of the commit message.
- Renaming of the driver filename.
- Renaming of the macro, struture, variable and function names to be consistent with the module name.
- Removing 'MELLANOX_PLATFORM' dependency in Kconfig.
- Fixing bug in mlxbf_i2c_get_shared_resource() to prevent null pointer dereference.
- Fixing bug in mlxbf_i2c_release_gpio() to prevent the use of null pointers.
- Adding an entry to MAINTAINERS file.v5->v6:
- Fixing kernel coding style issues detected using '--strict' flag.
- Updating SPDX identifier and module license.v4->v5:
- Fixing bug in mlx_slave_enale routine.v2->v3:
- Updating the "compatible" string and add a new entry to the mlx_i2c_dt_ids array.
- Adding a new entry to the mlx_i2c_acpi_ids array to support a new device _HID.
- Updating the device probe routines to derive the device type based on the instance property described in either devicetree or ACPI.
- Definition of new handlers to request and release the shared resources. These handlers relies on the device type.v1->v2:
- Updating the '.compatible' field of of_device_id.
- Updating mlx_i2c_of_probe() call to extract the bus identifier from the pre-defined aliases.
- Removing the 'profile' property.
- Setting the timing parameters according to the value of 'clock-frequency' property.
- Convertng the timing configuration from KHz to Hz.
--- MAINTAINERS | 6 + drivers/i2c/busses/Kconfig | 13 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-mlxbf.c | 2506 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2526 insertions(+) create mode 100644 drivers/i2c/busses/i2c-mlxbf.c
MAINTAINERS +6 -0
@@ -11096,6 +11096,12 @@ W: http://www.melfas.com F: Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt F: drivers/input/touchscreen/melfas_mip4.c +MELLANOX BLUEFIELD I2C DRIVER +M: Khalil Blaiech <[email protected]> +L: [email protected] +S: Supported +F: drivers/i2c/busses/i2c-mlxbf.c + MELLANOX ETHERNET DRIVER (mlx4_en) M: Tariq Toukan <[email protected]> L: [email protected]
drivers/i2c/busses/Kconfig +13 -0
@@ -730,6 +730,19 @@ config I2C_LPC2K This driver can also be built as a module. If so, the module will be called i2c-lpc2k. +config I2C_MLXBF + tristate "Mellanox BlueField I2C controller" + depends on ARM64 + help + Enabling this option will add I2C SMBus support for Mellanox BlueField + system. + + This driver can also be built as a module. If so, the module will be + called i2c-mlxbf. + + This driver implements an I2C SMBus host controller and enables both + master and slave functions. + config I2C_MESON tristate "Amlogic Meson I2C controller" depends on ARCH_MESON || COMPILE_TEST
drivers/i2c/busses/Makefile +1 -0
@@ -140,6 +140,7 @@ 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_ICY) += i2c-icy.o +obj-$(CONFIG_I2C_MLXBF) += i2c-mlxbf.o obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o obj-$(CONFIG_I2C_OPAL) += i2c-opal.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
drivers/i2c/busses/i2c-mlxbf.c new file +2506 -0
2,506 lines not on this page · raw message
Signature · 1 line
2.1.2
Wolfram Sang
AppliedRe: [PATCH v11 1/2] i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
Quoted 12 lines · Khalil Blaiech
From: Khalil Blaiech <[email protected]>
Add BlueField I2C driver to offer master and slave support for Mellanox BlueField SoCs. The driver implements an SMBus adapter and interfaces to multiple busses that can be probed using both ACPI and Device Tree infrastructures.
The driver supports several SMBus operations to transfer data back and forth from/to various I2C devices. It is mainly intended to be consumed by userspace tools and utilities, such as i2c-tools and decode-dimms to collect memory module information.
Quoted 7 lines
On the other hand, the driver has a slave function to support, among others, an IPMB interface that requires both master and slave functions to handle transfers between the BlueField SoC and a board management controllers (e.g., BMC).
Signed-off-by Khalil Blaiech <[email protected]>Reviewed-by Vadim Pasternak <[email protected]>
Applied to for-next, thanks!
Khalil Blaiech
maintainerRE: [PATCH v11 1/2] i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
Wolfram, thank you very much.
I have seen that you applied it to "for-next" branch. I 'll address the build issue as soon as possible and post a v12 with the appropriate tags.
Quoted 27 lines
-----Original Message-----
From: Wolfram Sang <[email protected]>
Sent: Sunday, September 27, 2020 9:55 AM
To: Khalil Blaiech <[email protected]>
Cc: [email protected]; Khalil Blaiech <[email protected]>; Vadim Pasternak <[email protected]>
Subject: Re: [PATCH v11 1/2] i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoCQuoted 17 lines · Khalil Blaiech
From: Khalil Blaiech <[email protected]>
Add BlueField I2C driver to offer master and slave support for Mellanox BlueField SoCs. The driver implements an SMBus adapter and interfaces to multiple busses that can be probed using both ACPI and Device Tree infrastructures.
The driver supports several SMBus operations to transfer data back and forth from/to various I2C devices. It is mainly intended to be consumed by userspace tools and utilities, such as i2c-tools and decode-dimms to collect memory module information.
On the other hand, the driver has a slave function to support, among others, an IPMB interface that requires both master and slave functions to handle transfers between the BlueField SoC and a board management controllers (e.g., BMC).
Quoted 4 lines
Quoted 2 lines
Signed-off-by Khalil Blaiech <[email protected]>Reviewed-by Vadim Pasternak <[email protected]>Applied to for-next, thanks!
Thanks,
-Khalil
Re: [PATCH v11 1/2] i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
Quoted 4 lines · Khalil Blaiech
Wolfram, thank you very much.
I have seen that you applied it to "for-next" branch. I 'll address the build issue as soon as possible and post a v12 with the appropriate tags.
You are welcome. But please don't send new versions anymore now but only incremental patches which go on top of v11. That is the normal procedure. Thank you as well!
Khalil Blaiech
maintainerRE: [PATCH v11 1/2] i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
Quoted 9 lines
Quoted 5 lines
Wolfram, thank you very much.
I have seen that you applied it to "for-next" branch. I 'll address the build issue as soon as possible and post a v12 with the appropriate tags.You are welcome. But please don't send new versions anymore now but only incremental patches which go on top of v11. That is the normal procedure. Thank you as well!
Thank you.
Please note that I addressed the build issue and converted the DT file into YAML schema.
Please allow some time for the internal review, I will post the patches to the Linux kernel afterwards.
Khalil Blaiech
maintainerRE: [PATCH v11 1/2] i2c: i2c-mlxbf: I2C SMBus driver for Mellanox BlueField SoC
Quoted 12 lines
Quoted 8 lines
Quoted 6 lines
Wolfram, thank you very much.
I have seen that you applied it to "for-next" branch. I 'll address the build issue as soon as possible and post a v12 with the appropriate tags.You are welcome. But please don't send new versions anymore now but
only
Quoted 2 lines
incremental patches which go on top of v11. That is the normal procedure. Thank you as well!
Quoted 6 lines
Thank you.
Please note that I addressed the build issue and converted the DT file into YAML schema.
Please allow some time for the internal review, I will post the patches to the Linux kernel afterwards.
Wolfram, apologies for the delay. The Nvidia internal review is taking more than I would've thought. The good news, most of the changes have been approved. A couple are still under discussion. I'll do my best to post the set of patches early next week or hopefully by the end of this week.
Thanks,
-Khalil
Khalil Blaiech
maintainerPATCH v11 2/2 dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
In reply to Khalil BlaiechFrom: Khalil Blaiech <[email protected]>
Add device tree bindings documentation for Mellanox BlueField I2C SMBus controller.
---v5->v6:
- Adding description of an extra resource to be consistent with new BlueField-2 SoCs.
- Adding an additional example of device instance.v3->v4:
- Re-ordering of the property descriptions.
- Removing useless register addresses from the resource description.
- Definition of default clock-frequency value.
- Fixing format issues; removing spaces.
- Removing "aliases" from Example section.
- Renaming device instance node in Example section.v2->v3:
- Removing shared resources from the controller instance.
- Updating the 'compatible' property and support the second generation of the Mellanox BlueField SoC.
- Fixing file format; replacing spaces with tabs.v1->v2:
- Enumeration of the device resources.
- Updating the 'compatible' property to make it less generic.
- Removing the 'bus' index property and replace it with standard approach to read the bus identifier.
- Getting rid of the 'profile' property.
- Using 'clock-frequency' property instead of 'bus-freq'.
- Convertion of the clock frequency from KHz to Hz.
- Removing useless examples.
--- .../devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt
Documentation/devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt new file +42 -0
@@ -0,0 +1,42 @@ +Device tree configuration for the Mellanox I2C SMBus on BlueField SoCs + +Required Properties: + +- compatible : should be "mellanox,i2c-mlxbf1" or "mellanox,i2c-mlxbf2". + +- reg : address offset and length of the device registers. The + registers consist of the following set of resources: + 1) Smbus block registers. + 2) Cause master registers. + 3) Cause slave registers. + 4) Cause coalesce registers (if compatible isn't set + to "mellanox,i2c-mlxbf1"). + +- interrupts : interrupt number. + +Optional Properties: + +- clock-frequency : bus frequency used to configure timing registers; + allowed values are 100000, 400000 and 1000000; + those are expressed in Hz. Default is 100000. + +Example: + +i2c@2804000 { + compatible = "mellanox,i2c-mlxbf1"; + reg = <0x02804000 0x800>, + <0x02801200 0x020>, + <0x02801260 0x020>; + interrupts = <57>; + clock-frequency = <100000>; +}; + +i2c@2808800 { + compatible = "mellanox,i2c-mlxbf2"; + reg = <0x02808800 0x600>, + <0x02808e00 0x020>, + <0x02808e20 0x020>, + <0x02808e40 0x010>; + interrupts = <57>; + clock-frequency = <400000>; +};
Signature · 1 line
2.1.2
Rob Herring
maintainerRe: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
Quoted 2 lines · Khalil Blaiech
From: Khalil Blaiech <[email protected]>
Use scripts/get_maintainers.pl and send to the right lists/people. Specifically, this needs to go to the DT list to get in my queue.
Quoted 34 lines
Add device tree bindings documentation for Mellanox BlueField I2C SMBus controller.
Signed-off-by Khalil Blaiech <[email protected]>---
v5->v6:
- Adding description of an extra resource to be consistent with new BlueField-2 SoCs.
- Adding an additional example of device instance.v3->v4:
- Re-ordering of the property descriptions.
- Removing useless register addresses from the resource description.
- Definition of default clock-frequency value.
- Fixing format issues; removing spaces.
- Removing "aliases" from Example section.
- Renaming device instance node in Example section.v2->v3:
- Removing shared resources from the controller instance.
- Updating the 'compatible' property and support the second generation of the Mellanox BlueField SoC.
- Fixing file format; replacing spaces with tabs.v1->v2:
- Enumeration of the device resources.
- Updating the 'compatible' property to make it less generic.
- Removing the 'bus' index property and replace it with standard approach to read the bus identifier.
- Getting rid of the 'profile' property.
- Using 'clock-frequency' property instead of 'bus-freq'.
- Convertion of the clock frequency from KHz to Hz.
- Removing useless examples.
Quoted 4 lines
--- .../devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt
Sorry, but DT bindings are now in DT schema format.
Rob
Khalil Blaiech
maintainerRE: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
Quoted 11 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Tuesday, September 22, 2020 7:05 PM
To: Khalil Blaiech <[email protected]>
Cc: Linux I2C <[email protected]>; Khalil Blaiech <[email protected]>; Vadim Pasternak <[email protected]>
Subject: Re: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
Quoted 6 lines
Quoted 2 lines · Khalil Blaiech
From: Khalil Blaiech <[email protected]>
Use
scripts/get_maintainers.pland send to the right lists/people. Specifically, this needs to go to the DT list to get in my queue.
Understood!
Sorry about that.
Quoted 37 lines
Quoted 35 lines
Add device tree bindings documentation for Mellanox BlueField I2C SMBus controller.
Signed-off-by Khalil Blaiech <[email protected]>---
v5->v6:
- Adding description of an extra resource to be consistent with new BlueField-2 SoCs.
- Adding an additional example of device instance.v3->v4:
- Re-ordering of the property descriptions.
- Removing useless register addresses from the resource description.
- Definition of default clock-frequency value.
- Fixing format issues; removing spaces.
- Removing "aliases" from Example section.
- Renaming device instance node in Example section.v2->v3:
- Removing shared resources from the controller instance.
- Updating the 'compatible' property and support the second generation of the Mellanox BlueField SoC.
- Fixing file format; replacing spaces with tabs.v1->v2:
- Enumeration of the device resources.
- Updating the 'compatible' property to make it less generic.
- Removing the 'bus' index property and replace it with standard approach to read the bus identifier.
- Getting rid of the 'profile' property.
- Using 'clock-frequency' property instead of 'bus-freq'.
- Convertion of the clock frequency from KHz to Hz.
- Removing useless examples.Quoted 2 lines
--- .../devicetree/bindings/i2c/mellanox,i2c-mlxbf.txt | 42
Quoted 6 lines
++++++++++++++++++++++
Quoted 2 lines
1 file changed, 42 insertions(+) create mode 100644
Documentation/devicetree/bindings/i2c/mellanox,i2c-mlxbf.txtSorry, but DT bindings are now in DT schema format.
Got it.
Quoted 2 lines
Rob
Thanks,
-Khalil
Wolfram Sang
AppliedRe: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
In reply to Khalil BlaiechQuoted 6 lines · Khalil Blaiech
From: Khalil Blaiech <[email protected]>
Add device tree bindings documentation for Mellanox BlueField I2C SMBus controller.
Signed-off-by Khalil Blaiech <[email protected]>
Applied to for-next, thanks!
A first incremental improvement could be converting this file to the YAML format. And add the new file to your MAINTAINERS entry.
All that aside, thank you for your patience and for keeping at it!
Khalil Blaiech
maintainerRE: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
Quoted 11 lines
-----Original Message-----
From: Wolfram Sang <[email protected]>
Sent: Sunday, September 27, 2020 9:57 AM
To: Khalil Blaiech <[email protected]>
Cc: Rob Herring <[email protected]>; [email protected]; Khalil Blaiech <[email protected]>; Vadim Pasternak <[email protected]>
Subject: Re: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoCOn Tue, Sep 22, 2020 at 06:49:38PM -0400, Khalil Blaiech wrote:
Quoted 8 lines
Quoted 6 lines
From: Khalil Blaiech <[email protected]>
Add device tree bindings documentation for Mellanox BlueField I2C SMBus controller.
Signed-off-by Khalil Blaiech <[email protected]>Applied to for-next, thanks!
Again, thank you very much.
Quoted 3 lines
A first incremental improvement could be converting this file to the YAML format. And add the new file to your
MAINTAINERSentry.
Will do.
Our driver supports both ACPI and devicetree. However, the platform firmware running on our platform implements ACPI and doesn't really rely on devicetree. Do you think we should keep the devicetree support? Or should I get rid of it before we apply the patch?
Your feedback is much appreciated.
Quoted 2 lines
All that aside, thank you for your patience and for keeping at it!
Thanks.
Re: [PATCH v11 2/2] dt-bindings: i2c: I2C binding for Mellanox BlueField SoC
Quoted 5 lines
Our driver supports both ACPI and devicetree. However, the platform firmware running on our platform implements ACPI and doesn't really rely on devicetree. Do you think we should keep the devicetree support? Or should I get rid of it before we apply the patch?
Usually, I'd say, if it is not used, remove it. If it would be used in the near future, then we could keep it. But that you know better than I do :)