i2c: Add Loongson-2K0300 I2C controller support
Binbin Zhou
maintainerv7 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.
======
V7:
- Add Reviewed-by tag from Huacai & Andy, thanks. Patch (2/2):
- Add the REGMAP_MMIO Kconfig dependency;
- parent_rate_MHz -> parent_rate_mhz to avoid CamelCase.
Link to V6:
https://lore.kernel.org/all/[email protected]/
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 | 11 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ls2x-v2.c | 544 ++++++++++++++++++ 5 files changed, 561 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ls2x-v2.c
base-commit: 8fc326e15895c9f0403e6243dd4ad468b10aab3d
Signature · 1 line
2.52.0
Binbin Zhou
maintainerPATCH v7 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
@@ -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
Binbin Zhou
maintainerPATCH v7 2/2 i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller
In reply to Binbin ZhouThis 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 | 11 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ls2x-v2.c | 544 +++++++++++++++++++++++++++++++ 4 files changed, 557 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ls2x-v2.c
MAINTAINERS +1 -0
@@ -14965,6 +14965,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 +11 -0
@@ -850,6 +850,17 @@ 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 + select REGMAP_MMIO + 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
@@ -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
Quoted 7 lines · Binbin Zhou
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.
...
Quoted 1 line
-
parent_rate_MHz->parent_rate_mhzto avoid CamelCase.
Was it a special requirement from maintainers?
Note, the physical units are special. The m and M have quite a different multiplier value. So, even if asked by somebody I think it's still arguably should be kept as MHz.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy:
Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Binbin Zhou
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.
Quoted 5 lines
...
Quoted 1 line
-
parent_rate_MHz->parent_rate_mhzto avoid CamelCase.Was it a special requirement from maintainers?
I’m actually a bit confused, because when I submitted the v6 patchset, checkpatch didn’t issue this warning.
But now, it produces the following output:
scripts/checkpatch.pl --strict i2c-ls2k0300-v6/v6-0002*
CHECK: Avoid CamelCase: <parent_rate_MHz> #512: FILE: drivers/i2c/busses/i2c-ls2x-v2.c:437:
+ priv->parent_rate_MHz = clk_get_rate(priv->clk);
total: 0 errors, 0 warnings, 1 checks, 574 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace
Quoted 8 lines
Note, the physical units are special. The m and M have quite a different multiplier value. So, even if asked by somebody I think it's still arguably should be kept as MHz.
--
With Best Regards,
Andy Shevchenko
Signature · 2 lines
Thanks. Binbin
Quoted 3 lines · Binbin Zhou
Quoted 1 line · Andy Shevchenko
On Sat, Apr 11, 2026 at 12:58 PM Binbin Zhou <[email protected]> wrote:
...
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
-
parent_rate_MHz->parent_rate_mhzto avoid CamelCase.Was it a special requirement from maintainers?
I’m actually a bit confused, because when I submitted the v6 patchset, checkpatch didn’t issue this warning.
But now, it produces the following output:
scripts/checkpatch.pl--strict i2c-ls2k0300-v6/v6-0002*
CHECK: Avoid CamelCase: <parent_rate_MHz>
It's a false positive of the checkpatch.
Quoted 11 lines
#512: FILE:
drivers/i2c/busses/i2c-ls2x-v2.c:437:
+priv->parent_rate_MHz=clk_get_rate(priv->clk);total: 0 errors, 0 warnings, 1 checks, 574 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplaceQuoted 3 lines
Note, the physical units are special. The m and M have quite a different multiplier value. So, even if asked by somebody I think it's still arguably should be kept as MHz.
See above why.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 3 lines · Binbin Zhou
Quoted 1 line · Andy Shevchenko
On Sat, Apr 11, 2026 at 12:58 PM Binbin Zhou <[email protected]> wrote:
...
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
-
parent_rate_MHz->parent_rate_mhzto avoid CamelCase.Was it a special requirement from maintainers?
Quoted 8 lines
Quoted 6 lines
I’m actually a bit confused, because when I submitted the v6 patchset, checkpatch didn’t issue this warning.
But now, it produces the following output:
scripts/checkpatch.pl--strict i2c-ls2k0300-v6/v6-0002*
CHECK: Avoid CamelCase: <parent_rate_MHz>It's a false positive of the checkpatch.
OK, I will revert this change.
Quoted 6 lines
Quoted 6 lines
#512: FILE:
drivers/i2c/busses/i2c-ls2x-v2.c:437:
+priv->parent_rate_MHz=clk_get_rate(priv->clk);total: 0 errors, 0 warnings, 1 checks, 574 lines checked
Quoted 8 lines
Quoted 6 lines
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplaceQuoted 3 lines
Note, the physical units are special. The m and M have quite a different multiplier value. So, even if asked by somebody I think it's still arguably should be kept as MHz.
See above why.
I see, thanks.
Quoted 4 lines
--
With Best Regards,
Andy Shevchenko
Signature · 2 lines
Thanks. Binbin