[PATCH v6 3/5] i2c: davinci: calculate bus freq from Hz instead of kHz
Marcus Folkesson
marcus.folkesson at gmail.com
Tue Feb 17 01:22:47 PST 2026
Hi Andy,
On Tue, Feb 17, 2026 at 11:07:06AM +0200, Andy Shevchenko wrote:
> On Mon, Feb 16, 2026 at 01:38:15PM +0100, Marcus Folkesson wrote:
> > The bus frequency is unnecessarily converted between Hz and kHz in
> > several places.
> > This is probably an old legacy from the old times (pre-devicetrees)
> > when the davinci_i2c_platform_data took the bus_freq in kHz.
> >
> > Stick to Hz.
>
> ...
>
> > /*
> > * According to I2C-BUS Spec 2.1, in FAST-MODE LOW period should be at
> > * least 1.3uS, which is not the case with 50% duty cycle. Driving HIGH
> > * to LOW ratio as 1 to 2 is more safe.
> > */
> > - if (dev->bus_freq > 100)
> > + if (dev->bus_freq_hz > 100000)
>
> The 100000 has a definition in i2c.h....
Good point, thanks.
>
> > clkl = (clk << 1) / 3;
> > else
> > clkl = (clk >> 1);
>
> ...
>
> > r = device_property_read_u32(&pdev->dev, "clock-frequency", &prop);
>
> (Why not using i2c timings? The I²C core has an API to parse firmware properties.)
Actually, I found i2c_parse_fw_timings() just a day ago and have on my
TODO-list to convert all bus drivers to use it right after the work with this
series is done.
>
> > if (r)
> > - prop = DAVINCI_I2C_DEFAULT_BUS_FREQ;
> > + prop = I2C_MAX_STANDARD_MODE_FREQ;
>
> ...like this one.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Best regards,
Marcus Folkesson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260217/684e7c4c/attachment-0001.sig>
More information about the linux-arm-kernel
mailing list