Skip to contentSkip to conversation

riscv: spacemit: add i2c support to K1 SoC

PATCH Superseded Troy Mitchell 7 participants 27 messages Oct 28, 2024 – Nov 24, 2024

Subsystems (5)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover riscv: spacemit: add i2c support to K1 SoC

Hi all,

This patch implements I2C driver for the SpacemiT K1 SoC, providing basic support for I2C read/write communication which compatible with standard I2C bus specifications.

In this version, the driver defaults to use fast-speed-mode and interrupts for transmission, and does not support DMA, high-speed mode, or FIFO.

The docs of I2C can be found here, in chapter 16.1 I2C [1]

Troy Mitchell (2):
dt-bindings: i2c: spacemit: add support for K1 SoC
i2c: spacemit: add support for SpacemiT K1 SoC

 .../bindings/i2c/spacemit,k1-i2c.yaml         |  51 ++
 drivers/i2c/busses/Kconfig                    |  18 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-k1.c                   | 658 ++++++++++++++++++
 4 files changed, 728 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
 create mode 100644 drivers/i2c/busses/i2c-k1.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/2 dt-bindings: i2c: spacemit: add support for K1 SoC

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +51 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-frequency:
+    description:
+      Desired I2C bus clock frequency in Hz. As only fast and high-speed
+      modes are supported by hardware, possible values are 100000 and 400000.
+    enum: [100000, 400000]
+    default: 100000
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c@d4010800 {
+        compatible = "spacemit,k1-i2c";
+        reg = <0x0 0xd4010800 0x0 0x38>;
+        interrupt-parent = <&plic>;
+        interrupts = <36>;
+        clocks = <&ccu 90>;
+        clock-frequency = <100000>;
+    };
+
+...
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 5 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---

Where is the changelog? Nothing here, nothing in cover letter.

I asked for several changes, so now I don't know if you implemented them.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 11 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---

Where is the changelog? Nothing here, nothing in cover letter.

I asked for several changes, so now I don't know if you implemented them.

I deleted the FIFO property because I believe your suggestion is correct. this should be decided by the driver, even though the FIFO is provided by the hardware.

Apologies for missing the changelog. To correct this, should I send a v3 version with the changelog or resend v2?

Quoted 4 lines

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 13 lines · Troy Mitchell
Quoted 11 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---

Where is the changelog? Nothing here, nothing in cover letter.

I asked for several changes, so now I don't know if you implemented them.

Quoted 6 lines

I deleted the FIFO property because I believe your suggestion is correct. this should be decided by the driver, even though the FIFO is provided by the hardware.

Apologies for missing the changelog. To correct this, should I send a v3 version with the changelog or resend v2?

Reply now with changelog. Your binding has some other unrelated and incorrect changes, which I do not understand.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 9 lines · Krzysztof Kozlowski
Quoted 7 lines · Troy Mitchell
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---

Change in v2:
- drop fifo-disable property
- unevaluatedProperties goes after required: block
- drop alias

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Where is the changelog? Nothing here, nothing in cover letter.

It seems like it was accidentally dropped seeing there are the dashes.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

I asked for several changes, so now I don't know if you implemented them.

I deleted the FIFO property because I believe your suggestion is correct. this should be decided by the driver, even though the FIFO is provided by the hardware.

Quoted 5 lines
Quoted 2 lines

Apologies for missing the changelog. To correct this, should I send a v3 version with the changelog or resend v2?

Reply now with changelog. Your binding has some other unrelated and incorrect changes, which I do not understand.

...

Thanks,
Jesse Taube

Quoted 9 lines

Best regards,
Krzysztof

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#6 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 8 lines · Jesse T
Quoted 7 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell
Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

---

Change in v2:
- drop fifo-disable property
- unevaluatedProperties goes after required: block
- drop alias

b4 diff disagrees with you :/

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

In reply to Krzysztof Kozlowski
Quoted 8 lines · Krzysztof Kozlowski
Quoted 7 lines · Troy Mitchell
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---

Change in v2:
- Change the maxItems of reg from 1 to 2 in properties
- Change 'i2c' to 'I2C' in the commit message.
- Drop fifo-disable property
- Drop alias in dts example
- Move unevaluatedProperties after required: block

Quoted 19 lines
Quoted 6 lines
Quoted 5 lines

Where is the changelog? Nothing here, nothing in cover letter.

I asked for several changes, so now I don't know if you implemented them.

Quoted 6 lines

I deleted the FIFO property because I believe your suggestion is correct. this should be decided by the driver, even though the FIFO is provided by the hardware.

Apologies for missing the changelog. To correct this, should I send a v3 version with the changelog or resend v2?

Reply now with changelog. Your binding has some other unrelated and incorrect changes, which I do not understand.

Best regards,
Krzysztof

Signature · 1 line
Troy Mitchell
#8 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 4 lines · Troy Mitchell
Quoted 2 lines · Krzysztof Kozlowski
Quoted 1 line · Troy Mitchell

On 2024/10/28 15:38, Krzysztof Kozlowski wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Troy Mitchell
Quoted 5 lines

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---

Change in v2:
- Change the maxItems of reg from 1 to 2 in properties

Why?

Quoted 4 lines

- Change 'i2c' to 'I2C' in the commit message.
- Drop fifo-disable property
- Drop alias in dts example
- Move unevaluatedProperties after required: block

Rest look ok.

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 9 lines · Krzysztof Kozlowski
Quoted 8 lines · Troy Mitchell
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell
Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

---

Change in v2:
- Change the maxItems of reg from 1 to 2 in properties

Why?

I need the address and size. In v1, I wrote it as 1, and I got the make dt_binding_check error.

Quoted 11 lines
Quoted 5 lines

- Change 'i2c' to 'I2C' in the commit message.
- Drop fifo-disable property
- Drop alias in dts example
- Move unevaluatedProperties after required: block

Rest look ok.

Best regards,
Krzysztof

Signature · 1 line
Troy Mitchell
#10 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Hi Troy,

Quoted 11 lines · Troy Mitchell
Quoted 9 lines · Krzysztof Kozlowski
Quoted 8 lines · Troy Mitchell
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Troy Mitchell
Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

---

Change in v2:
- Change the maxItems of reg from 1 to 2 in properties

Why?

I need the address and size. In v1, I wrote it as 1, and I got the make dt_binding_check error.

One "<address size>" element is just one item. maxItems > 1 would be for hardware with multiple discontiguous register ranges: <address1 size1>, <address2 size2>.

Regards,
Samuel

#11 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 3 lines · Samuel Holland

One "<address size>" element is just one item. maxItems > 1 would be for hardware with multiple discontiguous register ranges: <address1 size1>, <address2 size2>.

got it.I will fix it in next version.

Quoted 3 lines

Regards,
Samuel

Signature · 1 line
Troy Mitchell
#12 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

In reply to Troy Mitchell
Quoted 22 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +7 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +10 -0
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2

Provide changelog explaining why you are doing some changes.

List and describe items here instead.

Quoted 17 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +17 -0
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-frequency:
+    description:
+      Desired I2C bus clock frequency in Hz. As only fast and high-speed
+      modes are supported by hardware, possible values are 100000 and 400000.
+    enum: [100000, 400000]
+    default: 100000
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +10 -0
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c@d4010800 {
+        compatible = "spacemit,k1-i2c";
+        reg = <0x0 0xd4010800 0x0 0x38>;

Missing second item.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

In reply to Troy Mitchell

Hi Troy,

Quoted 28 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +13 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +10 -0
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1

Looking at the K1 user manual (9.1.4.77 RCPU I2C0 CLOCK RESET CONTROL REGISTER(RCPU_I2C0_CLK_RST)), I see two clocks (pclk, fclk) and a reset, which looks to be standard across the peripherals in this SoC. Please be sure that the binding covers all resources needed to use this peripheral.

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 29

Quoted 6 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +6 -0
+
+  clock-frequency:
+    description:
+      Desired I2C bus clock frequency in Hz. As only fast and high-speed
+      modes are supported by hardware, possible values are 100000 and 400000.
+    enum: [100000, 400000]

This looks wrong. In the manual I see:

* Supports standard-mode operation up to 100 Kbps
* Supports fast-mode operation up to 400Kbps
* Supports high-speed mode (HS mode) slave operation up to 3.4Mbps(High-speed I2C only)
* Supports high-speed mode (HS mode) master operation up to 3.3 Mbps (High-speed I2C only)

So even ignoring HS mode, 100 kHz and 400 kHz are only the maximums, not fixed frequencies.

Regards,
Samuel

Quoted 22 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +22 -0
+    default: 100000
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c@d4010800 {
+        compatible = "spacemit,k1-i2c";
+        reg = <0x0 0xd4010800 0x0 0x38>;
+        interrupt-parent = <&plic>;
+        interrupts = <36>;
+        clocks = <&ccu 90>;
+        clock-frequency = <100000>;
+    };
+
+...
#14 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 38 lines · Samuel Holland

Hi Troy,

Quoted 35 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +20 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2
+
+  interrupts:
+    maxItems: 1
Quoted 8 lines

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +3 -0
+
+  clocks:
+    maxItems: 1

Looking at the K1 user manual (9.1.4.77 RCPU I2C0 CLOCK RESET CONTROL
REGISTER(RCPU_I2C0_CLK_RST)), I see two clocks (pclk, fclk) and a reset, which
looks to be standard across the peripherals in this SoC. Please be sure that the
binding covers all resources needed to use this peripheral.RCPU stands for Real-time CPU, which is typically used for low power consumption

applications.
We should be using the APBC_TWSIx_CLK_RST register, but it's not listed in the user manual. However, you can find this register referenced in the K1 clock patch:
https://lore.kernel.org/all/SEYPR01MB4221AA2CA9C91A695FEFA777D7602@SEYPR01MB4221.apcprd01.prod.exchangelabs.com/

Also, to see how to enable the I2C clock in the device tree (note that the spacemit,apb_clock property is unused in the driver), check out the example here:
https://gitee.com/bianbu-linux/linux-6.1/blob/bl-v1.0.y/arch/riscv/boot/dts/spacemit/k1-x.dtsi#L1048

Quoted 17 lines

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 29

Quoted 7 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +6 -0
+
+  clock-frequency:
+    description:
+      Desired I2C bus clock frequency in Hz. As only fast and high-speed
+      modes are supported by hardware, possible values are 100000 and 400000.
+    enum: [100000, 400000]

This looks wrong. In the manual I see:

* Supports standard-mode operation up to 100 Kbps
* Supports fast-mode operation up to 400Kbps
* Supports high-speed mode (HS mode) slave operation up to 3.4Mbps(High-speed I2C only)
* Supports high-speed mode (HS mode) master operation up to 3.3 Mbps (High-speed I2C only)

Quoted 2 lines

So even ignoring HS mode, 100 kHz and 400 kHz are only the maximums, not fixed frequencies.

okay. I will fix it in next version.
and should I keep to ignore high-speed mode here?
if not, how about this:

clock-frequency:
description:
Desired I2C bus clock frequency in Hz.
K1 supports standard, fast, high-speed modes, from 1 to 3300000.
default: 100000
minimum: 1
maximum: 3300000

Quoted 27 lines

Regards,
Samuel

Quoted 22 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +22 -0
+    default: 100000
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c@d4010800 {
+        compatible = "spacemit,k1-i2c";
+        reg = <0x0 0xd4010800 0x0 0x38>;
+        interrupt-parent = <&plic>;
+        interrupts = <36>;
+        clocks = <&ccu 90>;
+        clock-frequency = <100000>;
+    };
+
+...
Signature · 1 line
Troy Mitchell
#15 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Hi Troy,

Quoted 46 lines · Troy Mitchell
Quoted 36 lines · Samuel Holland
Quoted 35 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +20 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2
+
+  interrupts:
+    maxItems: 1
Quoted 8 lines

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +3 -0
+
+  clocks:
+    maxItems: 1

Looking at the K1 user manual (9.1.4.77 RCPU I2C0 CLOCK RESET CONTROL REGISTER(RCPU_I2C0_CLK_RST)), I see two clocks (pclk, fclk) and a reset, which looks to be standard across the peripherals in this SoC. Please be sure that the binding covers all resources needed to use this peripheral.

Quoted 5 lines

RCPU stands for Real-time CPU, which is typically used for low power consumption applications.
We should be using the APBC_TWSIx_CLK_RST register, but it's not listed in the user manual. However, you can find this register referenced in the K1 clock patch:
https://lore.kernel.org/all/SEYPR01MB4221AA2CA9C91A695FEFA777D7602@SEYPR01MB4221.apcprd01.prod.exchangelabs.com/

Ah, well that driver is missing most of the bus clocks. For example, from a quick comparison with the manual, the driver includes sdh_axi_aclk, but misses all of the PWM APB clocks at APBC_PWMx_CLK_RST bit 0.

If the clock gate exists in the hardware, even if it is enabled by default, it needs to be modeled in the devicetree.

Quoted 3 lines

Also, to see how to enable the I2C clock in the device tree (note that the spacemit,apb_clock property is unused in the driver), check out the example here:
https://gitee.com/bianbu-linux/linux-6.1/blob/bl-v1.0.y/arch/riscv/boot/dts/spacemit/k1-x.dtsi#L1048

The devicetree describes the hardware, irrespective of which features the driver may or may not use.

Quoted 22 lines
Quoted 16 lines

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 29

Quoted 6 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +6 -0
+
+  clock-frequency:
+    description:
+      Desired I2C bus clock frequency in Hz. As only fast and high-speed
+      modes are supported by hardware, possible values are 100000 and 400000.
+    enum: [100000, 400000]

This looks wrong. In the manual I see:

* Supports standard-mode operation up to 100 Kbps
* Supports fast-mode operation up to 400Kbps
* Supports high-speed mode (HS mode) slave operation up to 3.4Mbps(High-speed I2C only)
* Supports high-speed mode (HS mode) master operation up to 3.3 Mbps (High-speed I2C only)

Quoted 2 lines

So even ignoring HS mode, 100 kHz and 400 kHz are only the maximums, not fixed frequencies.

okay. I will fix it in next version.
and should I keep to ignore high-speed mode here?
if not, how about this:

Quoted 7 lines

clock-frequency:
description:
Desired I2C bus clock frequency in Hz.
K1 supports standard, fast, high-speed modes, from 1 to 3300000.
default: 100000
minimum: 1
maximum: 3300000

I don't know if high-speed mode should be included, since it requires some extra negotiation to use. Assuming it should be, that looks reasonable.

Regards,
Samuel

Quoted 28 lines
Quoted 27 lines

Regards,
Samuel

Quoted 22 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +22 -0
+    default: 100000
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c@d4010800 {
+        compatible = "spacemit,k1-i2c";
+        reg = <0x0 0xd4010800 0x0 0x38>;
+        interrupt-parent = <&plic>;
+        interrupts = <36>;
+        clocks = <&ccu 90>;
+        clock-frequency = <100000>;
+    };
+
+...
#16 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

Quoted 55 lines · Samuel Holland

Hi Troy,

Quoted 46 lines · Troy Mitchell
Quoted 36 lines · Samuel Holland
Quoted 35 lines · Troy Mitchell

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +20 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2
+
+  interrupts:
+    maxItems: 1
Quoted 8 lines

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +3 -0
+
+  clocks:
+    maxItems: 1

Looking at the K1 user manual (9.1.4.77 RCPU I2C0 CLOCK RESET CONTROL REGISTER(RCPU_I2C0_CLK_RST)), I see two clocks (pclk, fclk) and a reset, which looks to be standard across the peripherals in this SoC. Please be sure that the binding covers all resources needed to use this peripheral.

Quoted 5 lines

RCPU stands for Real-time CPU, which is typically used for low power consumption applications.
We should be using the APBC_TWSIx_CLK_RST register, but it's not listed in the user manual. However, you can find this register referenced in the K1 clock patch:
https://lore.kernel.org/all/SEYPR01MB4221AA2CA9C91A695FEFA777D7602@SEYPR01MB4221.apcprd01.prod.exchangelabs.com/

Quoted 6 lines

Ah, well that driver is missing most of the bus clocks. For example, from a quick comparison with the manual, the driver includes sdh_axi_aclk, but misses all of the PWM APB clocks at APBC_PWMx_CLK_RST bit 0.

If the clock gate exists in the hardware, even if it is enabled by default, it needs to be modeled in the devicetree.

I think you mean APBCSCR? It will keep enable all time.Just a difference in frequency.

Should I add it in clockc property? If yes, how about this:
clocks:
maxItems: 1

and in dts example:

    i2c@d4010800 {
	...
        clocks = <&clk_apbc>, <&ccu 90>;
	clock-names = "clk_apbc", "clk_twsi";
        ...
    };

But one thing is, apbc_twsi is the sub-clock of clk_apbc, is this a duplicate listing?

Quoted 38 lines
Quoted 4 lines

Also, to see how to enable the I2C clock in the device tree (note that the spacemit,apb_clock property is unused in the driver), check out the example here:
https://gitee.com/bianbu-linux/linux-6.1/blob/bl-v1.0.y/arch/riscv/boot/dts/spacemit/k1-x.dtsi#L1048

The devicetree describes the hardware, irrespective of which features the driver may or may not use.

Quoted 22 lines
Quoted 16 lines

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 29

Quoted 6 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +6 -0
+
+  clock-frequency:
+    description:
+      Desired I2C bus clock frequency in Hz. As only fast and high-speed
+      modes are supported by hardware, possible values are 100000 and 400000.
+    enum: [100000, 400000]

This looks wrong. In the manual I see:

* Supports standard-mode operation up to 100 Kbps
* Supports fast-mode operation up to 400Kbps
* Supports high-speed mode (HS mode) slave operation up to 3.4Mbps(High-speed I2C only)
* Supports high-speed mode (HS mode) master operation up to 3.3 Mbps (High-speed I2C only)

Quoted 2 lines

So even ignoring HS mode, 100 kHz and 400 kHz are only the maximums, not fixed frequencies.

okay. I will fix it in next version.
and should I keep to ignore high-speed mode here?
if not, how about this:

Quoted 7 lines

clock-frequency:
description:
Desired I2C bus clock frequency in Hz.
K1 supports standard, fast, high-speed modes, from 1 to 3300000.
default: 100000
minimum: 1
maximum: 3300000

Quoted 2 lines

I don't know if high-speed mode should be included, since it requires some extra negotiation to use. Assuming it should be, that looks reasonable.

thanks.

Quoted 33 lines

Regards,
Samuel

Quoted 28 lines
Quoted 27 lines

Regards,
Samuel

Quoted 22 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +22 -0
+    default: 100000
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c@d4010800 {
+        compatible = "spacemit,k1-i2c";
+        reg = <0x0 0xd4010800 0x0 0x38>;
+        interrupt-parent = <&plic>;
+        interrupts = <36>;
+        clocks = <&ccu 90>;
+        clock-frequency = <100000>;
+    };
+
+...
Signature · 1 line
Troy Mitchell
#17 lore raw

Re: [PATCH v2 1/2] dt-bindings: i2c: spacemit: add support for K1 SoC

In reply to Samuel Holland

On Wed, Nov 06, 2024 at 06:29:56PM -0600, Samuel Holland wrote:
Hi Samuel,

I'm working on the clock driver for Spacemit K1.

Quoted 47 lines · Troy Mitchell
Quoted 46 lines · Samuel Holland
Quoted 44 lines · Troy Mitchell
Quoted 28 lines

The I2C of K1 supports fast-speed-mode and high-speed-mode, and supports FIFO transmission.

---
 .../bindings/i2c/spacemit,k1-i2c.yaml         | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +13 -0
new file mode 100644
index 000000000000..57af66f494e7
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/spacemit,k1-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C controller embedded in SpacemiT's K1 SoC
+
+maintainers:
+  - Troy Mitchell <[email protected]>
+
+properties:
+  compatible:

Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml new file +10 -0
+    const: spacemit,k1-i2c
+
+  reg:
+    maxItems: 2
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1

Looking at the K1 user manual (9.1.4.77 RCPU I2C0 CLOCK RESET CONTROL REGISTER(RCPU_I2C0_CLK_RST)), I see two clocks (pclk, fclk) and a reset, which looks to be standard across the peripherals in this SoC. Please be sure that the binding covers all resources needed to use this peripheral.

Quoted 4 lines
Quoted 4 lines

RCPU stands for Real-time CPU, which is typically used for low power consumption applications.
We should be using the APBC_TWSIx_CLK_RST register, but it's not listed in the user manual.

The vendor missed the register definition of APBC_TWSIx_CLK_RST in the documentation. There'll be an update soon.

Quoted 6 lines
Quoted 2 lines

However, you can find this register referenced in the K1 clock patch:
https://lore.kernel.org/all/SEYPR01MB4221AA2CA9C91A695FEFA777D7602@SEYPR01MB4221.apcprd01.prod.exchangelabs.com/

Ah, well that driver is missing most of the bus clocks. For example, from a quick comparison with the manual, the driver includes sdh_axi_aclk, but misses all of the PWM APB clocks at APBC_PWMx_CLK_RST bit 0.

Thanks for pointing this out. Indeeded, the v2 of clock driver is missing some bus clocks. I'm fixing them and working for a v3.

As for the I2C controller, I've confirmed with the vendor that both bus and function clocks are required for normal operation. This applies for all I2C controllers on the SoC, regardless of the region it belongs to (RCPU/APBC).

Quoted 10 lines

If the clock gate exists in the hardware, even if it is enabled by default, it needs to be modeled in the devicetree.

Quoted 3 lines

Also, to see how to enable the I2C clock in the device tree (note that the spacemit,apb_clock property is unused in the driver), check out the example here:
https://gitee.com/bianbu-linux/linux-6.1/blob/bl-v1.0.y/arch/riscv/boot/dts/spacemit/k1-x.dtsi#L1048

The devicetree describes the hardware, irrespective of which features the driver may or may not use.

Best regards,
Haylen Chu

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#18 lore raw

PATCH v2 2/2 i2c: spacemit: add support for SpacemiT K1 SoC

In reply to Troy Mitchell

This patch introduces basic I2C support for the SpacemiT K1 SoC, utilizing interrupts for transfers.

The driver has been tested using i2c-tools on a Bananapi-F3 board, and basic I2C read/write operations have been confirmed to work.

---
 drivers/i2c/busses/Kconfig  |  18 +
 drivers/i2c/busses/Makefile |   1 +
 drivers/i2c/busses/i2c-k1.c | 658 ++++++++++++++++++++++++++++++++++++
 3 files changed, 677 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-k1.c
drivers/i2c/busses/Kconfig +18 -0
index 6b3ba7e5723a..38ebfd38dc41 100644
@@ -779,6 +779,24 @@ config I2C_JZ4780
 
 	 If you don't know what to do here, say N.
 
+config I2C_K1
+	tristate "Spacemit K1 I2C adapter"
+	depends on HAS_IOMEM
+	help
+	  This option enables support for the I2C interface on the Spacemit K1
+	  platform.
+
+	  If you enable this configuration, the kernel will include support for
+	  the I2C adapter specific to the Spacemit K1 platform. This driver ca
+	  be used to manage I2C bus transactions, which are necessary for
+	  interfacing with I2C peripherals such as sensors, EEPROMs, and other
+	  devices.
+
+	  This driver can also be compiled as a module. If you choose to build
+	  it as a module, the resulting kernel module will be named `i2c-k1`.
+	  Loading this module will enable the I2C functionality for the K1
+	  platform dynamically, without requiring a rebuild of the kernel.
+
 config I2C_KEBA
 	tristate "KEBA I2C controller support"
 	depends on HAS_IOMEM
drivers/i2c/busses/Makefile +1 -0
index ecc07c50f2a0..9744b0e58598 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_I2C_IMX)		+= i2c-imx.o
 obj-$(CONFIG_I2C_IMX_LPI2C)	+= i2c-imx-lpi2c.o
 obj-$(CONFIG_I2C_IOP3XX)	+= i2c-iop3xx.o
 obj-$(CONFIG_I2C_JZ4780)	+= i2c-jz4780.o
+obj-$(CONFIG_I2C_K1)		+= i2c-k1.o
 obj-$(CONFIG_I2C_KEBA)		+= i2c-keba.o
 obj-$(CONFIG_I2C_KEMPLD)	+= i2c-kempld.o
 obj-$(CONFIG_I2C_LPC2K)		+= i2c-lpc2k.o
drivers/i2c/busses/i2c-k1.c new file +658 -0

658 lines not on this page · raw message

Signature · 1 line
2.34.1
#19 lore raw

Re: [PATCH v2 2/2] i2c: spacemit: add support for SpacemiT K1 SoC

kernel test robot noticed the following build warnings:

Hi Troy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on robh/for-next linus/master v6.12-rc5 next-20241028] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Troy-Mitchell/dt-bindings-i2c-spacemit-add-support-for-K1-SoC/20241028-133452
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20241028053220.346283-3-TroyMitchell988%40gmail.com
patch subject: [PATCH v2 2/2] i2c: spacemit: add support for SpacemiT K1 SoC
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20241028/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241028/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/i2c/busses/i2c-k1.c: In function 'spacemit_i2c_is_last_msg':

>> drivers/i2c/busses/i2c-k1.c:340:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
     340 |         if (i2c->dir == DIR_READ)
         |            ^

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for GET_FREE_REGION Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

vim +/else +340 drivers/i2c/busses/i2c-k1.c

337
338 static int spacemit_i2c_is_last_msg(struct spacemit_i2c_dev *i2c)
339 {

 > 340		if (i2c->dir == DIR_READ)

341 if (i2c->unprocessed == 1 && i2c->msg_idx == i2c->msg_num - 1)
342 return 1;
343 else if (i2c->dir == DIR_WRITE)
344 if (!i2c->unprocessed && i2c->msg_idx == i2c->msg_num - 1)
345 return 1;
346
347 return 0;
348 }
349

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#20 lore raw

Re: [PATCH v2 2/2] i2c: spacemit: add support for SpacemiT K1 SoC

In reply to Troy Mitchell
kernel test robot noticed the following build warnings:

Hi Troy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on robh/for-next linus/master v6.12-rc5 next-20241028] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Troy-Mitchell/dt-bindings-i2c-spacemit-add-support-for-K1-SoC/20241028-133452
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20241028053220.346283-3-TroyMitchell988%40gmail.com
patch subject: [PATCH v2 2/2] i2c: spacemit: add support for SpacemiT K1 SoC
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20241028/[email protected]/config)
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241028/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from drivers/i2c/busses/i2c-k1.c:7:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]

     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/i2c/busses/i2c-k1.c:343:2: warning: add explicit braces to avoid dangling else [-Wdangling-else]
     343 |         else if (i2c->dir == DIR_WRITE)
         |         ^

5 warnings generated.

vim +343 drivers/i2c/busses/i2c-k1.c

337
338 static int spacemit_i2c_is_last_msg(struct spacemit_i2c_dev *i2c)
339 {
340 if (i2c->dir == DIR_READ)
341 if (i2c->unprocessed == 1 && i2c->msg_idx == i2c->msg_num - 1)
342 return 1;

 > 343		else if (i2c->dir == DIR_WRITE)

344 if (!i2c->unprocessed && i2c->msg_idx == i2c->msg_num - 1)
345 return 1;
346
347 return 0;
348 }
349

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#21 lore raw

Re: [PATCH v2 2/2] i2c: spacemit: add support for SpacemiT K1 SoC

In reply to Troy Mitchell
Quoted 8 lines · Troy Mitchell

This patch introduces basic I2C support for the SpacemiT K1 SoC, utilizing interrupts for transfers.

The driver has been tested using i2c-tools on a Bananapi-F3 board, and basic I2C read/write operations have been confirmed to work.

--

Change in V2:
- Alphabetize Makefile and Kconfig
- Change .remove_new to .remove in struct platform_driver
- Change dev_alert to dev_warn_ratelimited in spacemit_i2c_bus_reset
- Change spacemit_i2c_read/write_reg to read/writel
- Change spacemit_i2c_dt_match to spacemit_i2c_of_match
- Clean up code flow
- Fix unnecessary line wraps
- Move spacemit_i2c_handle_err to a suitable location
- Use PTR_ERR(i2c->base) directly as the dev_err_probe parameter instead of the intermediate variable

Signature · 1 line
Troy Mitchell
#22 lore raw

Re: [PATCH v2 2/2] i2c: spacemit: add support for SpacemiT K1 SoC

In reply to Troy Mitchell
Quoted 19 lines · Troy Mitchell

This patch introduces basic I2C support for the SpacemiT K1 SoC, utilizing interrupts for transfers.

The driver has been tested using i2c-tools on a Bananapi-F3 board, and basic I2C read/write operations have been confirmed to work.

---
 drivers/i2c/busses/Kconfig  |  18 +
 drivers/i2c/busses/Makefile |   1 +
 drivers/i2c/busses/i2c-k1.c | 658 ++++++++++++++++++++++++++++++++++++
 3 files changed, 677 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-k1.c
drivers/i2c/busses/Kconfig +0 -0
index 6b3ba7e5723a..38ebfd38dc41 100644

drivers/i2c/busses/Kconfig config I2C_JZ4780 · line 784

Quoted 6 lines
drivers/i2c/busses/Kconfig +3 -0
@@ -779,6 +779,24 @@ config I2C_JZ4780
 
 	 If you don't know what to do here, say N.
 
+config I2C_K1
+	tristate "Spacemit K1 I2C adapter"
+	depends on HAS_IOMEM

I think I should retain the depends on from v1, like this:
depends on ARCH_SPACEMIT || COMPILE_TEST

Krzysztof mentioned that there is no such thing as ARCH_SPACEMIT, that's because this patch depends on the basic DT from dlan:
https://lore.kernel.org/all/[email protected]/

Quoted 18 lines
drivers/i2c/busses/Kconfig +15 -0
+	help
+	  This option enables support for the I2C interface on the Spacemit K1
+	  platform.
+
+	  If you enable this configuration, the kernel will include support for
+	  the I2C adapter specific to the Spacemit K1 platform. This driver ca
+	  be used to manage I2C bus transactions, which are necessary for
+	  interfacing with I2C peripherals such as sensors, EEPROMs, and other
+	  devices.
+
+	  This driver can also be compiled as a module. If you choose to build
+	  it as a module, the resulting kernel module will be named `i2c-k1`.
+	  Loading this module will enable the I2C functionality for the K1
+	  platform dynamically, without requiring a rebuild of the kernel.
+
 config I2C_KEBA
 	tristate "KEBA I2C controller support"
 	depends on HAS_IOMEM
Signature · 1 line
Troy Mitchell
maintainer
#23 lore raw
In reply to Troy Mitchell

Hi Tony,

Quoted 9 lines · Troy Mitchell

Hi all,

This patch implements I2C driver for the SpacemiT K1 SoC, providing basic support for I2C read/write communication which compatible with standard I2C bus specifications.

In this version, the driver defaults to use fast-speed-mode and interrupts for transmission, and does not support DMA, high-speed mode, or FIFO.

Quoted 7 lines

The docs of I2C can be found here, in chapter 16.1 I2C [1]

Troy Mitchell (2):
dt-bindings: i2c: spacemit: add support for K1 SoC
i2c: spacemit: add support for SpacemiT K1 SoC

As Krzysztof has asked, please do provide the changelog, it's important to track the progress of your series.

Thanks,
Andi

Quoted 11 lines
 .../bindings/i2c/spacemit,k1-i2c.yaml         |  51 ++
 drivers/i2c/busses/Kconfig                    |  18 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-k1.c                   | 658 ++++++++++++++++++
 4 files changed, 728 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
 create mode 100644 drivers/i2c/busses/i2c-k1.c
Signature · 1 line
2.34.1
#24 lore raw
Quoted 14 lines · Andi Shyti

Hi Tony,

Quoted 11 lines · Troy Mitchell

Hi all,

This patch implements I2C driver for the SpacemiT K1 SoC, providing basic support for I2C read/write communication which compatible with standard I2C bus specifications.

In this version, the driver defaults to use fast-speed-mode and interrupts for transmission, and does not support DMA, high-speed mode, or FIFO.

The docs of I2C can be found here, in chapter 16.1 I2C [1]

Quoted 8 lines
Quoted 5 lines

Troy Mitchell (2):
dt-bindings: i2c: spacemit: add support for K1 SoC
i2c: spacemit: add support for SpacemiT K1 SoC

As Krzysztof has asked, please do provide the changelog, it's important to track the progress of your series.

I saw a compilation warning sent to me by the robot, and I've fixed the warning. Should I resend V2 with the changelog what I miss or send V3?

Thank for your response.

Quoted 15 lines

Thanks,
Andi

Quoted 11 lines
 .../bindings/i2c/spacemit,k1-i2c.yaml         |  51 ++
 drivers/i2c/busses/Kconfig                    |  18 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-k1.c                   | 658 ++++++++++++++++++
 4 files changed, 728 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
 create mode 100644 drivers/i2c/busses/i2c-k1.c
Signature · 1 line
2.34.1
Signature · 1 line
Troy Mitchell
maintainer
#25 lore raw

Hy Troy,

Quoted 2 lines · Troy Mitchell
Quoted 1 line · Andi Shyti

Hi Tony,

Sorry, I misread your name :-/

Quoted 18 lines
Quoted 18 lines · Troy Mitchell
Quoted 16 lines

Hi all,

This patch implements I2C driver for the SpacemiT K1 SoC, providing basic support for I2C read/write communication which compatible with standard I2C bus specifications.

In this version, the driver defaults to use fast-speed-mode and interrupts for transmission, and does not support DMA, high-speed mode, or FIFO.

The docs of I2C can be found here, in chapter 16.1 I2C [1]

Troy Mitchell (2):
dt-bindings: i2c: spacemit: add support for K1 SoC
i2c: spacemit: add support for SpacemiT K1 SoC

Quoted 5 lines
Quoted 2 lines

As Krzysztof has asked, please do provide the changelog, it's important to track the progress of your series.

I saw a compilation warning sent to me by the robot, and I've fixed the warning. Should I resend V2 with the changelog what I miss or send V3?

Please send a v3. When there are compilation issues, normally patches are less keen to be reviewed.

You can add the changelog in the Patch 0/2 to avoid editing all the .patch files.

Thanks,
Andi

#26 lore raw
Quoted 7 lines · Andi Shyti

Hy Troy,

Quoted 2 lines · Troy Mitchell
Quoted 1 line · Andi Shyti

Hi Tony,

Sorry, I misread your name :-/

It doesn't matter

Quoted 25 lines
Quoted 19 lines
Quoted 19 lines · Troy Mitchell
Quoted 16 lines

Hi all,

This patch implements I2C driver for the SpacemiT K1 SoC, providing basic support for I2C read/write communication which compatible with standard I2C bus specifications.

In this version, the driver defaults to use fast-speed-mode and interrupts for transmission, and does not support DMA, high-speed mode, or FIFO.

The docs of I2C can be found here, in chapter 16.1 I2C [1]

Troy Mitchell (2):
dt-bindings: i2c: spacemit: add support for K1 SoC
i2c: spacemit: add support for SpacemiT K1 SoC

Quoted 5 lines
Quoted 2 lines

As Krzysztof has asked, please do provide the changelog, it's important to track the progress of your series.

I saw a compilation warning sent to me by the robot, and I've fixed the warning. Should I resend V2 with the changelog what I miss or send V3?

Quoted 5 lines

Please send a v3. When there are compilation issues, normally patches are less keen to be reviewed.

You can add the changelog in the Patch 0/2 to avoid editing all the .patch files.

Thanks! I'll send v3 after I get a response from Samuel.

Quoted 3 lines

Thanks,
Andi

Signature · 1 line
Troy Mitchell