Skip to content

i2c: fix, rework and extend RTL9300 I2C driver

Jonas Jelonek linux-devicetree linux-i2c lkml 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest9 patches 1 replyIn review
  2. v712 patches 7 repliesSuperseded
  3. v612 patches 4 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v511 patches11 repliesSuperseded
v43 patches3 repliesSuperseded
v33 patches1 replySuperseded
v23 patches7 repliesSuperseded
v13 patches12 repliesSuperseded

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9i2c: rtl9300: use regmap fields and API for registersdrivers/i2c/busses/i2c-rtl9300.c+124 -680 replies
2/9dt-bindings: i2c: realtek,rtl9301-i2c: fix wording and typosDocumentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml+3 -30 replies
3/9i2c: rtl9300: rename internal sda_pin to sda_numdrivers/i2c/busses/i2c-rtl9300.c+12 -120 replies
4/9i2c: rtl9300: move setting SCL frequency to config_iodrivers/i2c/busses/i2c-rtl9300.c+9 -80 replies
5/9i2c: rtl9300: do not set read mode on every transferdrivers/i2c/busses/i2c-rtl9300.c+6 -50 replies
6/9i2c: rtl9300: separate xfer configuration and executiondrivers/i2c/busses/i2c-rtl9300.c+114 -1200 replies
7/9i2c: rtl9300: use scoped guard instead of explicit lock/unlockdrivers/i2c/busses/i2c-rtl9300.c+7 -110 replies
8/9dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9310 supportDocumentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml+37 -20 replies
9/9i2c: rtl9300: add support for RTL9310 I2C controllerdrivers/i2c/busses/i2c-rtl9300.c+44 -30 replies

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by.

PatchSven EckelmannChris PackhamMarkus StockhausenRob Herring (Arm)
1/9T-b R-b T-b T-b
2/9R-b T-b T-b R-b
3/9T-b R-b T-b T-b
4/9T-b R-b T-b T-b
5/9T-b R-b T-b T-b
6/9T-b R-b T-b T-b
7/9R-b T-b T-b
8/9R-b T-b R-b
9/9T-b R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v8 thread

Cover letter [PATCH v8 0/9] i2c: fix, rework and extend RTL9300 I2C driver

This patch series for the RTL9300 I2C driver:
- fixes issues, one of them in some cases causing data corruption
- reworks significant parts of the current implementation
- add support for the (quite similar) RTL9310 series

Goal of this is to fix critical issues, improve overall code quality and simplify maintainance and further extension of the driver. Moreover, it should be brought on par feature-wise with OpenWrt's downstream driver to be able to drop the downstream version.

The first three patches address bugs in the current implementation, on of them being critical and causing data corruption under certain circumstances. Although the hardware doesn't support SMBus Quick Write, the driver claims to support it with a broken implementation. This causes to execute a 16-byte Write instead of a Quick Write, e.g. causing corruption on not-write-protected SFP EEPROMs and soft-bricking them. These three patches are also sent to 'stable' because they fix critical issues.

Subsequent patches introduce various smaller and bigger enhancements. These include:
- use regmap_field + its API instead of macros + GENMASK + shifts
- refactor xfer handling
- variable renaming to avoid confusion
- move some register operations, calling them somewhere else and less frequently
- use guarded mutex instead of explicit mutex_lock/_unlock to simplify control flow

Finally, the last two patches add support for RTL9310 (mango) series to the driver and adjust the dt-bindings accordingly.

Simple operations have been tested successfully on:
- Zyxel XGS1210-12 (RTL9302B)
- TP-Link TL-ST1008F v2.0 (RTL9303)
- Netgear MS510TXM (RTL9313)

with Byte-Read, Word-Read and I2C-Block-Read. Other operations need testing from people with devices available.

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

HINT: This depends on another series by Sven Eckelmann [1] due to some
issues occured during merge of some patches.

[1] https://lore.kernel.org/linux-i2c/[email protected]/

--
Changelog

v8: - dropped accepted patches 1-3
- fixed minor issue in last patch to make second master work
- rebased on top of shyti/i2c/i2c-host to make sure it applies cleanly

v7: - included given Tested-By and Reviewed-By from Chris Packham and
Markus Stockhausen accordingly
- except for Chris' Tested-By on RTL9310 since he only tested on RTL9302C
- fixed typo as mentioned by Markuf Elfring

v6: - patch 'i2c: rtl9300: check if xfer length is valid'
- renamed to 'ensure data length is within supported range'
- added I2C quirk for zero length as suggested by Wolfram Sang
- reordered patches to have backport-worthy fixes first and enhancements/others after
- patches 'fix channel number bound check', 'check if xfer length is valid' and 'remove SMBus Quick operation support' were moved before all others
- added CC: stable to first three patches
- fixed commit message of 'dt-bindings: i2c: realtek,rtl9301-i2c:
extend for RTL9310 support'
- added a patch to use guard(mutex) instead of explicit lock/unlock as suggested by Markus Elfring
- added Reviewed-by: Rob Herring ... to dt-bindings patches
- added Tested-by: Sven Eckelmann ... to all patches (except the new patch in this version)

v5: - added more patches to fix further issues/do further cleanup
- remove SMBus Quick support (not supported by hardware)
- move setting SCL frequency to config_io
- only set read message format (RD_MODE) once on probing
- add check to avoid len = 0 being allowed as length
- adjusted cover letter

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 (9):
i2c: rtl9300: use regmap fields and API for registers
dt-bindings: i2c: realtek,rtl9301-i2c: fix wording and typos
i2c: rtl9300: rename internal sda_pin to sda_num
i2c: rtl9300: move setting SCL frequency to config_io
i2c: rtl9300: do not set read mode on every transfer
i2c: rtl9300: separate xfer configuration and execution
i2c: rtl9300: use scoped guard instead of explicit lock/unlock
dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9310 support
i2c: rtl9300: add support for RTL9310 I2C controller

 .../bindings/i2c/realtek,rtl9301-i2c.yaml     |  45 +-
 drivers/i2c/busses/i2c-rtl9300.c              | 473 +++++++++++-------
 2 files changed, 321 insertions(+), 197 deletions(-)

base-commit: 217f92d91c9faeb6b78bd6205b3585944cbcb433
prerequisite-patch-id: 773cf36a416585adc1e955c56c0d036b6cd8ebc4
prerequisite-patch-id: d8190d8d1904fc9ef151ffffb57622cd2fae623a

Signature · 1 line
2.48.1