lkml.org 
[lkml]   [2023]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH RFT 2/2] i2c: rcar: improve accuracy for R-Car Gen3+
Hi Wolfram,

On Wed, Sep 13, 2023 at 11:38 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> With some new registers, SCL can be calculated to be closer to the
> desired rate. Apply the new formula for R-Car Gen3 device types.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c

> - /* keep icccr value */
> - priv->icccr = scgd << cdf_width | cdf;
> + priv->icccr = scgd << cdf_width | cdf;
> + } else {
> + u32 x, sum_ratio = RCAR_SCHD_RATIO + RCAR_SCLD_RATIO;
> + /*
> + * SCLD/SCHD ratio and SMD default value are explained above
> + * where they are defined. With these definitions, we can compute
> + * x as a base value for the SCLD/SCHD ratio:
> + *
> + * SCL = clkp / (8 + 2 * SMD + SCLD + SCHD + F[(ticf + tr + intd) * clkp])
> + * SCL = clkp / (8 + 2 * RCAR_DEFAULT_SMD + RCAR_SCLD_RATIO * x
> + * + RCAR_SCHD_RATIO * x + F[...])
> + *
> + * with: sum_ratio = RCAR_SCLD_RATIO + RCAR_SCHD_RATIO
> + * and: smd = 2 * RCAR_DEFAULT_SMD
> + *
> + * SCL = clkp / (8 + smd + sum_ratio * x + F[...])
> + * 8 + smd + sum_ratio * x + F[...] = SCL / clkp
> + * x = ((SCL / clkp) - 8 - smd - F[...]) / sum_ratio

Woops, I missed that both "SCL / clkp" above should be "clkp / SCL".

Fortunately I noticed your "[PATCH 2/2] i2c: rcar: add FastMode+
support for Gen4" fixed that, but I guess it's better to fix that in
this patch instead.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2023-09-19 13:23    [W:0.147 / U:0.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site