[PATCH v4 0/3] i2c: rework and extend RTL9300 I2C driver

Jonas Jelonek posted 3 patches 2 months, 1 week ago
There is a newer version of this series
.../bindings/i2c/realtek,rtl9301-i2c.yaml     |  58 ++++-
drivers/i2c/busses/i2c-rtl9300.c              | 231 +++++++++++++-----
2 files changed, 218 insertions(+), 71 deletions(-)
[PATCH v4 0/3] i2c: rework and extend RTL9300 I2C driver
Posted by Jonas Jelonek 2 months, 1 week ago
This patch series reworks the current implementation of the driver for
I2C controller integrated into RTL9300 SoCs to simplify support
extension, and adds support for the RTL9310 series.
Goal of this is to have RTL9310 support upstream in a proper
implementation to be able to drop downstream versions of this driver.

The first patch reworks the driver to use more of the regmap API.
Instead of using macros, all registers are defined as reg_field and
operations on these registers are performed using regmap_field and the
corresponding API. This simplifies adding support for further chip
families and avoids potential redundant code by just providing
chip-specific functions for every chip family.

The second patch extends the existing dt-bindings of RTL9300 for RTL9310
support.

The third patch makes use of previous changes by adding support for the
RTL9310 series, providing the correct register definitions and a few
specifics. This also uses a new vendor dt-property which was added by
the second patch to properly manage the I2C controllers. Having this
property is necessary to properly describe the hardware and allow the
driver to correctly work with the I2C controllers.

Both has been tested successfully on RTL9302B-based Zyxel XGS1210-12
and RTL9313-based Netgear MS510TXM.

Compile-tested with Linux, run-tested as backport in OpenWrt on the
aforementioned devices.

--
Changelog

v4: - fixed an incorrect check for number of channels which was already
      present in original code

v3: - narrowed vendor property per variant to be required only
      for RTL9310
    - narrowed usable child-node i2c addresses per variant
    - no changes to driver patches

v2: - Patch 1:
        - adjusted commit message
        - retained Tested-By and Reviewed-By from Chris Packham
    - Patch 2:
        - simplified check as suggested by Markus Stockhausen
        - fixed commit message
    - Patch 3 (all requested by Krzysztof):
        - use vendor property instead of generic
        - add front compatibles to make binding complete
        - fix commit message
    - reordered patches, dt-bindings patch now comes before its 'user'
    - properly add device-tree list and relevant maintainers to To/Cc

--

Jonas Jelonek (3):
  i2c: rework RTL9300 I2C controller driver
  dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9310 support
  i2c: add RTL9310 support to RTL9300 I2C controller driver

 .../bindings/i2c/realtek,rtl9301-i2c.yaml     |  58 ++++-
 drivers/i2c/busses/i2c-rtl9300.c              | 231 +++++++++++++-----
 2 files changed, 218 insertions(+), 71 deletions(-)

-- 
2.48.1
Re: [PATCH v4 0/3] i2c: rework and extend RTL9300 I2C driver
Posted by Jonas Jelonek 2 months ago
Hi all,

On 29.07.2025 09:51, Jonas Jelonek wrote:
> This patch series reworks the current implementation of the driver for
> I2C controller integrated into RTL9300 SoCs to simplify support
> extension, and adds support for the RTL9310 series.
> Goal of this is to have RTL9310 support upstream in a proper
> implementation to be able to drop downstream versions of this driver.
>
> The first patch reworks the driver to use more of the regmap API.
> Instead of using macros, all registers are defined as reg_field and
> operations on these registers are performed using regmap_field and the
> corresponding API. This simplifies adding support for further chip
> families and avoids potential redundant code by just providing
> chip-specific functions for every chip family.
>
> The second patch extends the existing dt-bindings of RTL9300 for RTL9310
> support.
>
> The third patch makes use of previous changes by adding support for the
> RTL9310 series, providing the correct register definitions and a few
> specifics. This also uses a new vendor dt-property which was added by
> the second patch to properly manage the I2C controllers. Having this
> property is necessary to properly describe the hardware and allow the
> driver to correctly work with the I2C controllers.
>
> Both has been tested successfully on RTL9302B-based Zyxel XGS1210-12
> and RTL9313-based Netgear MS510TXM.
>
> Compile-tested with Linux, run-tested as backport in OpenWrt on the
> aforementioned devices.
>
> --
> Changelog
>
> v4: - fixed an incorrect check for number of channels which was already
>       present in original code
>
> v3: - narrowed vendor property per variant to be required only
>       for RTL9310
>     - narrowed usable child-node i2c addresses per variant
>     - no changes to driver patches
>
> v2: - Patch 1:
>         - adjusted commit message
>         - retained Tested-By and Reviewed-By from Chris Packham
>     - Patch 2:
>         - simplified check as suggested by Markus Stockhausen
>         - fixed commit message
>     - Patch 3 (all requested by Krzysztof):
>         - use vendor property instead of generic
>         - add front compatibles to make binding complete
>         - fix commit message
>     - reordered patches, dt-bindings patch now comes before its 'user'
>     - properly add device-tree list and relevant maintainers to To/Cc
>
> --
>
> Jonas Jelonek (3):
>   i2c: rework RTL9300 I2C controller driver
>   dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9310 support
>   i2c: add RTL9310 support to RTL9300 I2C controller driver
>
>  .../bindings/i2c/realtek,rtl9301-i2c.yaml     |  58 ++++-
>  drivers/i2c/busses/i2c-rtl9300.c              | 231 +++++++++++++-----
>  2 files changed, 218 insertions(+), 71 deletions(-)
>

If accepted, this should be merged AFTER the recent patchset from Sven [1].

I'll rebase this on top of [1], fix outstanding issues and probably propose some
more cleanup in the next version (because I'm not satisfied with how the code is
currently structured).

Best regards,
Jonas

[1] https://lore.kernel.org/linux-i2c/20250803-i2c-rtl9300-multi-byte-v2-0-9b7b759fe2b6@narfation.org/