Skip to content

Ensure High and Low periods of SCL are correct

Lucas Tanure linux-amlogic linux-arm-kernel linux-i2c lkml 2 versions – Applied

Status from this message: Applied to for-next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 5 repliesApplied
  2. v13 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- Keep the previous calculation for Meson6
- Use I2C_MAX_STANDARD_MODE_FREQ
- move the comment before the if()
- use FIELD_PREP for setting div_l
- Drop removal of meson_i2c_data

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2i2c: meson: Use _SHIFT and _MASK for register definitionsdrivers/i2c/busses/i2c-meson.c+22 -192 replies
2/2i2c: meson: Use 50% duty cycle for I2C clockdrivers/i2c/busses/i2c-meson.c+60 -102 replies

Reviews trailers per patch

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

PatchNeil Armstrong
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] Ensure High and Low periods of SCL are correct

The default duty cycle of 33% is less than the required by the I2C specs for the LOW period of the SCL clock at 100KHz bus speed.

So, for 100Khz or less, use 50%H/50%L duty cycle, and for the clock above 100Khz, use 40%H/60%L duty cycle. That ensures the low period of SCL is always more than the minimum required by the specs at any given frequency.

I did a few measures on the Khadas Vim3 board:

i2c_AO (i2c@5000):

Before the patchset, I got:
- 100KHz: 3.338us HIGH, 6.746us LOW, 33%/67%, Freq 99KHz (Not Valid tHIGH < 4.0us)
- 400KHz: 860ns HIGH, 1.734us LOW, 33.15%/62.85%, Freq 385.505KHz (Valid)
- 1000KHz: 362ns HIGH, 732ns LOW, 33.09%/66.91%, Freq 914.077KHz (Valid)

With the patchset
- 100KHz: 4.952us HIGH, 5.134us LOW, 49%/51%, Freq 99KHz (Valid)
- 400KHz: 966ns HIGH, 1.628us LOW, 37.24%/62.76%, Freq 385.505KHz (Valid)
- 1000KHz: 372ns HIGH, 720ns LOW, 34.07%/65.93%, Freq 915.741KHz (Valid)

i2c3 (i2c@1c000):

Before the patchset, I got:
- 100KHz: 3.348us HIGH, 6.704us LOW, 33%/67%, Freq 99.5KHz (Not Valid tHIGH < 4.0us)
- 400KHz: 864ns HIGH, 1.69us LOW, 33.83%/62.17%, Freq 391.543KHz (Valid)
- 1000KHz: 360ns HIGH, 690ns LOW, 34.29%/65.71%, Freq 952.381KHz (Valid)

With the patchset
- 100KHz: 4.958us HIGH, 5.092us LOW, 49%/51%, Freq 99KHz (Valid)
- 400KHz: 970ns HIGH, 1.582us LOW, 38%/62%, Freq 391.85KHz (Valid)
- 1000KHz: 370ns HIGH, 680ns LOW, 35.24%/64.76%, Freq 952.57KHz (Valid)

v2 changelog:
- Keep the previous calculation for Meson6
- Use I2C_MAX_STANDARD_MODE_FREQ
- move the comment before the if()
- use FIELD_PREP for setting div_l
- Drop removal of meson_i2c_data

Previous versions:
V1: https://lkml.org/lkml/2022/3/26/109

Lucas Tanure (2):
i2c: meson: Use _SHIFT and _MASK for register definitions
i2c: meson: Use 50% duty cycle for I2C clock

 drivers/i2c/busses/i2c-meson.c | 111 ++++++++++++++++++++++++---------
 1 file changed, 82 insertions(+), 29 deletions(-)
Signature · 1 line
2.35.1