Skip to contentSkip to conversation

i2c: Add Loongson-2K0300 I2C controller support

PATCH Superseded Binbin Zhou 5 participants 8 messages Mar 20 – Apr 10

Subsystems (4)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Binbin Zhou

author maintainer
#0 lore raw

v6 cover i2c: Add Loongson-2K0300 I2C controller support

Hi all:

This patch set describes the I2C controller integrated the Loongson-2K0300 chip.

It has a significantly different design from the previous I2C controller(i2c-ls2x), such as support for master-slave transfer mode, and DMA transfers (implementation in progress), etc. Therefore, we try to name it i2c-ls2x-v2.

Thanks.

======
V6:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Update comment;
- Use regmap_get_device();

Link to V5:
https://lore.kernel.org/all/[email protected]/

V5:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Add time.h header file;
- Add the MHz suffix to parent_rate and freq;
- Define an iterator within the for loop, with its type being

    `unsigned int`;

- Use dev_err_probe() in loongson2_i2c_adjust_bus_speed();
- i2c_adapter_set_node()->device_set_node().

Link to V4:
https://lore.kernel.org/all/[email protected]/

V4:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- The parent_rate parameter type should be unsigned long;
- Drop fallthrough and add missing break;
- device_set_node()->i2c_adapter_set_node();
- Use i2c_parse_fw_timings();
- Use i2c_t.bus_freq_hz instead of priv->speed;
- Sperate loongson2_i2c_handle_read() into loongson2_i2c_handle_read() and loongson2_i2c_handle_rx_done().

Link to V3:
https://lore.kernel.org/all/[email protected]/

V3:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Reorder header file follow IWYU principle;
- Better indentation and coding style;
- Use generic macro definitions;
- Amend *all* struct data types;
- Correct unreasonable variable type definitions;
- Refact loongson2_i2c_isr_error();
- of_property_read_u32()->device_property_read_u32();
- Remove meaningless blank lines and output.

Link to V2:
https://lore.kernel.org/all/[email protected]/

V2:
Patch (1/2):
- Add Acked-by tag from Conor, thanks.

Patch (2/2):
- Reorder the definitions of read() and write();
- Adjust the calculation method for bus speed.

Link to V1:
https://lore.kernel.org/all/[email protected]/

Binbin Zhou (2):
dt-bindings: i2c: loongson,ls2x: Add ls2k0300-i2c compatible
i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

 .../bindings/i2c/loongson,ls2x-i2c.yaml       |   4 +
 MAINTAINERS                                   |   1 +
 drivers/i2c/busses/Kconfig                    |  10 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-ls2x-v2.c              | 544 ++++++++++++++++++
 5 files changed, 560 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ls2x-v2.c

base-commit: e9b13580b334040da0184a9f32106d808acd7fd5

Signature · 1 line
2.52.0
author maintainer
#1 lore raw

PATCH v6 1/2 dt-bindings: i2c: loongson,ls2x: Add ls2k0300-i2c compatible

Add "loongson,ls2k0300-i2c" dedicated compatible for representing I2C of Loongson-2K0300 chip, because its HW integration is quiet different from others.

---
 Documentation/devicetree/bindings/i2c/loongson,ls2x-i2c.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/i2c/loongson,ls2x-i2c.yaml +4 -0
index 67882ec6e06a..ee09c6d9c5f0 100644
@@ -16,6 +16,7 @@ properties:
   compatible:
     enum:
       - loongson,ls2k-i2c
+      - loongson,ls2k0300-i2c
       - loongson,ls7a-i2c
 
   reg:
@@ -24,6 +25,9 @@ properties:
   interrupts:
     maxItems: 1
 
+  clocks:
+    maxItems: 1
+
 required:
   - compatible
   - reg
Signature · 1 line
2.52.0
author maintainer
#2 lore raw

PATCH v6 2/2 i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

In reply to Binbin Zhou

This I2C module is integrated into the Loongson-2K0300 SoCs.

It provides multi-master functionality and controls all I2C bus-specific timing, protocols, arbitration, and timing. It supports both standard and fast modes.

---
 MAINTAINERS                      |   1 +
 drivers/i2c/busses/Kconfig       |  10 +
 drivers/i2c/busses/Makefile      |   1 +
 drivers/i2c/busses/i2c-ls2x-v2.c | 544 +++++++++++++++++++++++++++++++
 4 files changed, 556 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ls2x-v2.c
MAINTAINERS +1 -0
index 96ea84948d76..b6802b3a3101 100644
@@ -14954,6 +14954,7 @@ M:	Binbin Zhou <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/i2c/loongson,ls2x-i2c.yaml
+F:	drivers/i2c/busses/i2c-ls2x-v2.c
 F:	drivers/i2c/busses/i2c-ls2x.c
 
 LOONGSON PWM DRIVER
drivers/i2c/busses/Kconfig +10 -0
index e11d50750e63..5cad2d0d2569 100644
@@ -850,6 +850,16 @@ config I2C_LS2X
 	  This driver can also be built as a module. If so, the module
 	  will be called i2c-ls2x.
 
+config I2C_LS2X_V2
+	tristate "Loongson-2 Fast Speed I2C adapter"
+	depends on LOONGARCH || COMPILE_TEST
+	help
+	  If you say yes to this option, support will be included for the
+	  I2C interface on the Loongson-2K0300 SoCs.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called i2c-ls2x-v2.
+
 config I2C_MLXBF
         tristate "Mellanox BlueField I2C controller"
         depends on (MELLANOX_PLATFORM && ARM64) || COMPILE_TEST
drivers/i2c/busses/Makefile +1 -0
index 547123ab351f..3755c54b3d82 100644
@@ -80,6 +80,7 @@ obj-$(CONFIG_I2C_KEBA)		+= i2c-keba.o
 obj-$(CONFIG_I2C_KEMPLD)	+= i2c-kempld.o
 obj-$(CONFIG_I2C_LPC2K)		+= i2c-lpc2k.o
 obj-$(CONFIG_I2C_LS2X)		+= i2c-ls2x.o
+obj-$(CONFIG_I2C_LS2X_V2)	+= i2c-ls2x-v2.o
 obj-$(CONFIG_I2C_MESON)		+= i2c-meson.o
 obj-$(CONFIG_I2C_MICROCHIP_CORE)	+= i2c-microchip-corei2c.o
 obj-$(CONFIG_I2C_MPC)		+= i2c-mpc.o
drivers/i2c/busses/i2c-ls2x-v2.c new file +544 -0

544 lines not on this page · raw message

Signature · 1 line
2.52.0
Reviewed-by on v6 2/2
#3 lore raw

Re: [PATCH v6 2/2] i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

Quoted 5 lines · Binbin Zhou

This I2C module is integrated into the Loongson-2K0300 SoCs.

It provides multi-master functionality and controls all I2C bus-specific timing, protocols, arbitration, and timing. It supports both standard and fast modes.

Looks good enough to me,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on the v6 series
#6 lore raw
In reply to Binbin Zhou

For the whole series:

Quoted 93 lines · Binbin Zhou

Hi all:

This patch set describes the I2C controller integrated the Loongson-2K0300 chip.

It has a significantly different design from the previous I2C controller(i2c-ls2x), such as support for master-slave transfer mode, and DMA transfers (implementation in progress), etc. Therefore, we try to name it i2c-ls2x-v2.

Thanks.

======
V6:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Update comment;
- Use regmap_get_device();

Link to V5:
https://lore.kernel.org/all/[email protected]/

V5:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Add time.h header file;
- Add the MHz suffix to parent_rate and freq;
- Define an iterator within the for loop, with its type being

    `unsigned int`;

- Use dev_err_probe() in loongson2_i2c_adjust_bus_speed();
- i2c_adapter_set_node()->device_set_node().

Link to V4:
https://lore.kernel.org/all/[email protected]/

V4:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- The parent_rate parameter type should be unsigned long;
- Drop fallthrough and add missing break;
- device_set_node()->i2c_adapter_set_node();
- Use i2c_parse_fw_timings();
- Use i2c_t.bus_freq_hz instead of priv->speed;
- Sperate loongson2_i2c_handle_read() into loongson2_i2c_handle_read() and loongson2_i2c_handle_rx_done().

Link to V3:
https://lore.kernel.org/all/[email protected]/

V3:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Reorder header file follow IWYU principle;
- Better indentation and coding style;
- Use generic macro definitions;
- Amend *all* struct data types;
- Correct unreasonable variable type definitions;
- Refact loongson2_i2c_isr_error();
- of_property_read_u32()->device_property_read_u32();
- Remove meaningless blank lines and output.

Link to V2:
https://lore.kernel.org/all/[email protected]/

V2:
Patch (1/2):
- Add Acked-by tag from Conor, thanks.

Patch (2/2):
- Reorder the definitions of read() and write();
- Adjust the calculation method for bus speed.

Link to V1:
https://lore.kernel.org/all/[email protected]/

Binbin Zhou (2):
dt-bindings: i2c: loongson,ls2x: Add ls2k0300-i2c compatible
i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

 .../bindings/i2c/loongson,ls2x-i2c.yaml       |   4 +
 MAINTAINERS                                   |   1 +
 drivers/i2c/busses/Kconfig                    |  10 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-ls2x-v2.c              | 544 ++++++++++++++++++
 5 files changed, 560 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ls2x-v2.c

base-commit: e9b13580b334040da0184a9f32106d808acd7fd5 --
2.52.0

#7 lore raw
In reply to Binbin Zhou

Hi all:

Quoted 20 lines · Binbin Zhou

Hi all:

This patch set describes the I2C controller integrated the Loongson-2K0300 chip.

It has a significantly different design from the previous I2C controller(i2c-ls2x), such as support for master-slave transfer mode, and DMA transfers (implementation in progress), etc. Therefore, we try to name it i2c-ls2x-v2.

Thanks.

======
V6:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Update comment;
- Use regmap_get_device();

Quoted 2 lines

Link to V5:
https://lore.kernel.org/all/[email protected]/

Gentle ping.
Any comments about this patchset ?

Quoted 67 lines

V5:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Add time.h header file;
- Add the MHz suffix to parent_rate and freq;
- Define an iterator within the for loop, with its type being

    `unsigned int`;

- Use dev_err_probe() in loongson2_i2c_adjust_bus_speed();
- i2c_adapter_set_node()->device_set_node().

Link to V4:
https://lore.kernel.org/all/[email protected]/

V4:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- The parent_rate parameter type should be unsigned long;
- Drop fallthrough and add missing break;
- device_set_node()->i2c_adapter_set_node();
- Use i2c_parse_fw_timings();
- Use i2c_t.bus_freq_hz instead of priv->speed;
- Sperate loongson2_i2c_handle_read() into loongson2_i2c_handle_read() and loongson2_i2c_handle_rx_done().

Link to V3:
https://lore.kernel.org/all/[email protected]/

V3:
- Rebase on linux-i2c/i2c-next;
Patch (2/2):
- Reorder header file follow IWYU principle;
- Better indentation and coding style;
- Use generic macro definitions;
- Amend *all* struct data types;
- Correct unreasonable variable type definitions;
- Refact loongson2_i2c_isr_error();
- of_property_read_u32()->device_property_read_u32();
- Remove meaningless blank lines and output.

Link to V2:
https://lore.kernel.org/all/[email protected]/

V2:
Patch (1/2):
- Add Acked-by tag from Conor, thanks.

Patch (2/2):
- Reorder the definitions of read() and write();
- Adjust the calculation method for bus speed.

Link to V1:
https://lore.kernel.org/all/[email protected]/

Binbin Zhou (2):
dt-bindings: i2c: loongson,ls2x: Add ls2k0300-i2c compatible
i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

 .../bindings/i2c/loongson,ls2x-i2c.yaml       |   4 +
 MAINTAINERS                                   |   1 +
 drivers/i2c/busses/Kconfig                    |  10 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-ls2x-v2.c              | 544 ++++++++++++++++++
 5 files changed, 560 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ls2x-v2.c
Quoted 4 lines

base-commit: e9b13580b334040da0184a9f32106d808acd7fd5 --
2.52.0

--
Thanks.
Binbin

maintainer
#4 lore raw

Re: [PATCH v6 2/2] i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

In reply to Binbin Zhou

Hi Binbin,

drivers/i2c/busses/Kconfig config I2C_LS2X · line 856

Quoted 4 lines
drivers/i2c/busses/Kconfig +4 -0
+config I2C_LS2X_V2
+	tristate "Loongson-2 Fast Speed I2C adapter"
+	depends on LOONGARCH || COMPILE_TEST
+	help

I'm getting a compile error here, I guess you also need REGMAP_MMIO here, right?

Andi

#5 lore raw

Re: [PATCH v6 2/2] i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller

Hi Andi:

Thanks for your review.

Quoted 10 lines · Andi Shyti

Hi Binbin,

drivers/i2c/busses/Kconfig config I2C_LS2X · line 856

Quoted 4 lines
drivers/i2c/busses/Kconfig +4 -0
+config I2C_LS2X_V2
+     tristate "Loongson-2 Fast Speed I2C adapter"
+     depends on LOONGARCH || COMPILE_TEST
+     help

I'm getting a compile error here, I guess you also need REGMAP_MMIO here, right?

Yes, that is indeed necessary. I’ll double-check to see if there are any other omissions.
It seems my other driver has a similar omission as well. Thank you very much.

Quoted 2 lines

Andi

Signature · 2 lines
Thanks.
Binbin