i2c: tegra20: add target controller support
v2 cover i2c: tegra20: add target controller support
Hi,
this series adds I2C target mode support to the Tegra20 I2C controller. The driver is very simple and only supports single byte transfers. The goal is to remove the NVEC driver from staging with which this implentation was also tested.
I used a separate driver for the target for maintainability and extensibility reasons, in case support for more Tegra SOCs will be added. The driver was coded by use of an LLM with a few adaptions by me.
Marc
---
Changes since V1:
- fix minor issues highlighted by Uwe
- removed NACK support, because it is not used by the EC I tested the patch with
- do not access the registers or disable the IRQ and clocks again if resume failed (noted by Sashiko)
Marc Dietrich (2):
dt-bindings: i2c: Add Tegra20 I2C target controller
i2c: tegra20: Add driver for Tegra20 I2C target controller instances
.../bindings/i2c/nvidia,tegra20-i2c.yaml | 27 +- MAINTAINERS | 6 + drivers/i2c/busses/Kconfig | 14 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-tegra-target.c | 351 ++++++++++++++++++ 5 files changed, 395 insertions(+), 4 deletions(-) create mode 100644 drivers/i2c/busses/i2c-tegra-target.c
Signature · 1 line
2.55.0
PATCH v2 1/2 dt-bindings: i2c: Add Tegra20 I2C target controller
Tegra20 SoCs supports 3 instances of an I2C target controller. They share ressouces with the I2C controller instances and are introduced here via an additional compatible.
--- .../bindings/i2c/nvidia,tegra20-i2c.yaml | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +23 -4
@@ -13,11 +13,15 @@ title: NVIDIA Tegra I2C controller driver properties: compatible: oneOf: - - description: Tegra20 has 4 generic I2C controller. This can support - master and slave mode of I2C communication. The i2c-tegra driver - only support master mode of I2C communication. Driver of I2C - controller is only compatible with "nvidia,tegra20-i2c". + - description: Tegra20 has 3 instances of a generic I2C controller. + It supports controller and target mode of I2C communication. + The i2c-tegra driver only supports master mode of I2C communication. + Driver of I2C controller is only compatible with "nvidia,tegra20-i2c". const: nvidia,tegra20-i2c + - description: The i2c-tegra-target driver supports the target mode of + the generic Tegra20 I2C controller. Driver of the I2C target + controller is only compatible with "nvidia,tegra20-i2c-target". + const: nvidia,tegra20-i2c-target - description: Tegra20 has specific I2C controller called as DVC I2C controller. This only support master mode of I2C communication. Register interface/offset and interrupts handling are different than
@@ -222,3 +226,18 @@ examples: #address-cells = <1>; #size-cells = <0>; }; + + - | + i2c@7000c500 { + compatible = "nvidia,tegra20-i2c-target"; + reg = <0x7000c500 0x100>; + interrupts = <0 92 0x04>; + clocks = <&tegra_car 67>, <&tegra_car 124>; + clock-names = "div-clk", "fast-clk"; + clock-frequency = <80000>; + resets = <&tegra_car 67>; + reset-names = "i2c"; + + #address-cells = <1>; + #size-cells = <0>; + };
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 1/2] dt-bindings: i2c: Add Tegra20 I2C target controller
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] dt-bindings: i2c: tegra20: driver-specific compatible for target mode - [Low] dt-bindings: i2c…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] dt-bindings: i2c: tegra20: driver-specific compatible for target mode
- [Low] dt-bindings: i2c: tegra20: missing clock constraints for target compatible
--
commit 6d4b197a67e97b02efd062ed9f1c49931c4c0fce
Author: Marc Dietrich <[email protected]>
dt-bindings: i2c: Add Tegra20 I2C target controller
This commit adds the "nvidia,tegra20-i2c-target" compatible string and an example for the Tegra20 I2C target controller to the Tegra I2C binding schema.
Quoted 11 lines
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +0
-3@@ -13,11 +13,15 @@ title: NVIDIA Tegra I2C controller driver properties: compatible: oneOf: - - description: Tegra20 has 4 generic I2C controller. This can support - master and slave mode of I2C communication. The i2c-tegra driver - only support master mode of I2C communication. Driver of I2C
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml title: NVIDIA Tegra I2C controller driver · line 24
Quoted 10 lines
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +8
-1- controller is only compatible with "nvidia,tegra20-i2c". + - description: Tegra20 has 3 instances of a generic I2C controller. + It supports controller and target mode of I2C communication. + The i2c-tegra driver only supports master mode of I2C communication. + Driver of I2C controller is only compatible with "nvidia,tegra20-i2c". const: nvidia,tegra20-i2c + - description: The i2c-tegra-target driver supports the target mode of + the generic Tegra20 I2C controller. Driver of the I2C target + controller is only compatible with "nvidia,tegra20-i2c-target". + const: nvidia,tegra20-i2c-target
[Severity: Medium]
Should target mode use the existing "nvidia,tegra20-i2c" compatible rather than introducing a separate driver-specific compatible string?
The three generic Tegra20 I2C instances are identical hardware blocks that include both master and target registers within the same 0x100 register aperture, and are already described by "nvidia,tegra20-i2c". Defining "nvidia,tegra20-i2c-target" encodes Linux driver partitioning and operating mode selection into the Devicetree ABI, whereas standard I2C bindings keep the hardware compatible string and select target mode via child nodes using I2C_OWN_SLAVE_ADDRESS in their reg property.
[ ... ]
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml examples: · line 236
Quoted 12 lines
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +8
-0@@ -222,3 +226,18 @@ examples: #address-cells = <1>; #size-cells = <0>; }; + + - | + i2c@7000c500 { + compatible = "nvidia,tegra20-i2c-target"; + reg = <0x7000c500 0x100>; + interrupts = <0 92 0x04>; + clocks = <&tegra_car 67>, <&tegra_car 124>; + clock-names = "div-clk", "fast-clk";
[Severity: Low]
Does the allOf conditional for Tegra20 and Tegra30 clocks also need to match "nvidia,tegra20-i2c-target"?
The top-level clocks and clock-names properties only require minItems: 1 without constraining the names, and the allOf rule requiring two clocks named "div-clk" and "fast-clk" only checks for "nvidia,tegra20-i2c" and "nvidia,tegra30-i2c":
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml:
- if:
properties:
compatible:
contains:
enum:
- nvidia,tegra20-i2c
- nvidia,tegra30-i2c
then:
properties:
clocks:
minItems: 2
clock-names:
items:
- const: div-clk
- const: fast-clk
Nodes using "nvidia,tegra20-i2c-target" bypass this check, allowing wrong clock counts or names to pass dtbs_check.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/2] dt-bindings: i2c: Add Tegra20 I2C target controller
In reply to Marc DietrichQuoted 19 lines · Marc Dietrich
Tegra20 SoCs supports 3 instances of an I2C target controller. They share ressouces with the I2C controller instances and are introduced here via an additional compatible.
Signed-off-by Marc Dietrich <[email protected]>--- .../bindings/i2c/nvidia,tegra20-i2c.yaml | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +0
-2@@ -13,11 +13,15 @@ title: NVIDIA Tegra I2C controller driver properties: compatible: oneOf: - - description: Tegra20 has 4 generic I2C controller. This can support - master and slave mode of I2C communication. The i2c-tegra driver
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml title: NVIDIA Tegra I2C controller driver · line 23
Quoted 10 lines
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +7
-2- only support master mode of I2C communication. Driver of I2C - controller is only compatible with "nvidia,tegra20-i2c". + - description: Tegra20 has 3 instances of a generic I2C controller. + It supports controller and target mode of I2C communication. + The i2c-tegra driver only supports master mode of I2C communication. + Driver of I2C controller is only compatible with "nvidia,tegra20-i2c". const: nvidia,tegra20-i2c + - description: The i2c-tegra-target driver supports the target mode of + the generic Tegra20 I2C controller. Driver of the I2C target + controller is only compatible with "nvidia,tegra20-i2c-target".
Drop all driver references.
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml examples: · line 232
Quoted 12 lines
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +5
-0+ const: nvidia,tegra20-i2c-target - description: Tegra20 has specific I2C controller called as DVC I2C controller. This only support master mode of I2C communication. Register interface/offset and interrupts handling are different than@@ -222,3 +226,18 @@ examples: #address-cells = <1>; #size-cells = <0>; }; + + - | + i2c@7000c500 { + compatible = "nvidia,tegra20-i2c-target";
So no differences against existing example except compatible? Then no need for the new example.
Best regards,
Krzysztof
Re: [PATCH v2 1/2] dt-bindings: i2c: Add Tegra20 I2C target controller
In reply to Marc DietrichDocumentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml title: NVIDIA Tegra I2C controller driver · line 24
Quoted 9 lines · Marc Dietrich
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml +8
-0+ - description: Tegra20 has 3 instances of a generic I2C controller. + It supports controller and target mode of I2C communication. + The i2c-tegra driver only supports master mode of I2C communication. + Driver of I2C controller is only compatible with "nvidia,tegra20-i2c". const: nvidia,tegra20-i2c + - description: The i2c-tegra-target driver supports the target mode of + the generic Tegra20 I2C controller. Driver of the I2C target + controller is only compatible with "nvidia,tegra20-i2c-target". + const: nvidia,tegra20-i2c-target
This looks like the same device as nvidia,tegra20-i2c. Plaese document hardware differences on the SoC. I see no DTS in the patchset, so not sure if you are duplicating hardware or adding new instances.
Best regards,
Krzysztof
PATCH v2 2/2 i2c: tegra20: Add driver for Tegra20 I2C target controller instances
In reply to Marc DietrichTegra20 SoC support 3 instances of the I2C target controller. It shares ressouces with the I2C controller. Only exclusive operation as an i2c target is supported for now.
--- MAINTAINERS | 6 + drivers/i2c/busses/Kconfig | 14 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-tegra-target.c | 351 ++++++++++++++++++++++++++ 4 files changed, 372 insertions(+) create mode 100644 drivers/i2c/busses/i2c-tegra-target.c
MAINTAINERS +6 -0
@@ -26894,6 +26894,12 @@ R: Dmitry Osipenko <[email protected]> S: Supported F: drivers/i2c/busses/i2c-tegra.c +TEGRA I2C TARGET DRIVER +M: Marc Dietrich <[email protected]> +L: [email protected] +S: Maintained +F: drivers/i2c/busses/i2c-tegra-target.c + TEGRA IOMMU DRIVERS M: Thierry Reding <[email protected]> R: Krishna Reddy <[email protected]>
drivers/i2c/busses/Kconfig +14 -0
@@ -1242,6 +1242,20 @@ config I2C_TEGRA_BPMP of the BPMP firmware, and this driver merely communicates with that real driver. +config I2C_TEGRA_TARGET + tristate "NVIDIA Tegra20 I2C controller in target mode" + depends on ARCH_TEGRA_2x_SOC || COMPILE_TEST + select I2C_SLAVE + help + If you say yes to this option, support will be included for the + I2C controller embedded in NVIDIA Tegra20 SoCs when it is used as + an I2C target (slave) on the bus. A controller instance that is + described with the target compatible in the device tree cannot be + used as an I2C controller at the same time. + + This driver can also be built as a module. If so, the module will + be called i2c-tegra-target. + config I2C_UNIPHIER tristate "UniPhier FIFO-less I2C controller" depends on ARCH_UNIPHIER || COMPILE_TEST
drivers/i2c/busses/Makefile +1 -0
@@ -119,6 +119,7 @@ obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o obj-$(CONFIG_I2C_SYNQUACER) += i2c-synquacer.o obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o obj-$(CONFIG_I2C_TEGRA_BPMP) += i2c-tegra-bpmp.o +obj-$(CONFIG_I2C_TEGRA_TARGET) += i2c-tegra-target.o obj-$(CONFIG_I2C_UNIPHIER) += i2c-uniphier.o obj-$(CONFIG_I2C_UNIPHIER_F) += i2c-uniphier-f.o obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
drivers/i2c/busses/i2c-tegra-target.c new file +351 -0
351 lines not on this page · raw message
Signature · 1 line
2.55.0