[PATCH v7 0/2] i2c: i2c-gpio: Enhance driver for buses with shared SCL

Markus Stockhausen posted 2 patches 1 week, 4 days ago
drivers/i2c/algos/i2c-algo-bit.c |   2 +-
drivers/i2c/busses/i2c-gpio.c    | 223 +++++++++++++++++++++++++++++--
include/linux/i2c-algo-bit.h     |   1 +
3 files changed, 211 insertions(+), 15 deletions(-)
[PATCH v7 0/2] i2c: i2c-gpio: Enhance driver for buses with shared SCL
Posted by Markus Stockhausen 1 week, 4 days ago
This series adds support for devices with multiple I2C buses 
that share a single clock line.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
---

v6 -> v7
  - Handle devicetree GPIO node attributes opaque. E.g. do not 
    interpret a pin from args[0]. With this generalize the shared 
    SCL detection by simply comparing all attributes.
  - Gracefully disable pin sharing if devicetree lookup does not 
    work as expected. This avoids interference with otherwise sane
    setups. 
  - Disable bit_test only if a (potentially) shared SCL pin is
    detected.
v6: https://lore.kernel.org/linux-i2c/20260714062018.3009830-1-markus.stockhausen@gmx.de/
v6 Sashiko: https://sashiko.dev/#/patchset/20260714062018.3009830-1-markus.stockhausen%40gmx.de

v5 -> v6
  - Add legacy system detection (without dts/fwnode)
  - Add skip_bit_test setting to algorithm options via pre-commit
  - Make use of skip_bit_test in the driver
v5: https://lore.kernel.org/linux-i2c/20260713062021.2995641-1-markus.stockhausen@gmx.de/
v5 Sashiko: https://sashiko.dev/#/patchset/20260713062021.2995641-1-markus.stockhausen%40gmx.de

v4 -> v5
  - Whitespace cleanup
  - Send to LKML for Sashiko review
  - Add Reviewed-by
v4: https://lore.kernel.org/linux-i2c/20260709062534.2864521-1-markus.stockhausen@gmx.de/

v3 -> v4
  - add Reviewed-by and Tested-by
v3: https://lore.kernel.org/linux-i2c/20260520173129.1382489-1-markus.stockhausen@gmx.de/

v2 -> v3
  - Fix lockdep_set_class() with DEBUG_LOCK_ALLOC=y
v2: https://lore.kernel.org/linux-i2c/20260518161013.900504-1-markus.stockhausen@gmx.de/

v1 -> v2
  - Convert fault injector to scl->gpio (reported by test robot)
  - Use rt_mutex and i2c_lock_operations instead of pre/post_xfer
    (logic taken from i2c-cht-wc.c and enhanced)
  - i2c_gpio_lookup_scl()
    - Improve list control flow
    - Improve comment
    - Carve out SCL node comparison into i2c_gpio_scl_matches()
  - Drop "valid" attribute and directly check gpiod instead
  - Improve fwnode args check for #gpio-cells=1 case
  - Add sda/scl cleanup during probe failures
  - Replace dev_info() with dev_dbg()
  - Reflect changed locking in commmit message
  - Tested with config option GPIO_SHARED/GPIO_SHARED_PROXY
    as requested by Bartosz
v1: https://lore.kernel.org/linux-i2c/20260514092042.3265986-1-markus.stockhausen@gmx.de/

v0 -> v1
  - Initially this enhancement was submitted as a new driver with
    a new devicetree structure. After some discussion Wolfram
    advised to make only an enhancement to the i2c-gpio driver.
v0: https://lore.kernel.org/linux-i2c/20260511162528.84508-1-markus.stockhausen@gmx.de/


Markus Stockhausen (2):
  i2c: algo: bit: Allow to skip bit test
  i2c: i2c-gpio: Enhance driver for buses with shared SCL

 drivers/i2c/algos/i2c-algo-bit.c |   2 +-
 drivers/i2c/busses/i2c-gpio.c    | 223 +++++++++++++++++++++++++++++--
 include/linux/i2c-algo-bit.h     |   1 +
 3 files changed, 211 insertions(+), 15 deletions(-)

-- 
2.54.0
AW: [PATCH v7 0/2] i2c: i2c-gpio: Enhance driver for buses with shared SCL
Posted by Markus Stockhausen 1 week, 3 days ago
Hi Wolfram,
Hi Bartosz,

> Von: Markus Stockhausen <markus.stockhausen@gmx.de> 
> Gesendet: Dienstag, 14. Juli 2026 18:29
> An: wsa+renesas@sang-engineering.com; andi.shyti@kernel.org;
linusw@kernel.org; brgl@kernel.org; linux-i2c@vger.kernel.org;
linux-gpio@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: Markus Stockhausen <markus.stockhausen@gmx.de>
> Betreff: [PATCH v7 0/2] i2c: i2c-gpio: Enhance driver for buses with
shared SCL
> 
> This series adds support for devices with multiple I2C buses 
> that share a single clock line.
> 
> Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>

Thanks for your assistance and feedback. Finally Sashiko seems to be happy.

https://sashiko.dev/#/patchset/20260714162915.3018703-1-markus.stockhausen%4
0gmx.de

The core logic of the implementation is still the same you reviewed, With
Sashikos feedback the detection of sharable SCL pins has changed a bit. 
Maybe you can have a final look if i2c_gpio_create_scl() is ok for you now.

Thanks in advance.

Markus
Re: AW: [PATCH v7 0/2] i2c: i2c-gpio: Enhance driver for buses with shared SCL
Posted by Wolfram Sang 1 week, 3 days ago
Hi Markus,

> Maybe you can have a final look if i2c_gpio_create_scl() is ok for you now.

I saw that Sashiko is happy now, good work! I want to test the updated
driver on some boards with simple i2c-gpio instances, just to double
check that there are no regressions. I ran into issue unrelated to your
patches, but I am positive I can resolve them today.

Happy hacking,

   Wolfram