Subject: Re:Re: [PATCH v1] LoongArch: add i2c clocks and clock-div parameter parsing.

From: Hongliang Wang

Date: Mon Mar 23 2026 - 23:28:07 EST


Hi,  Binbin:


Sorry,  due to email reason,  I did not see your reply in a timely.

For your suggestion, I will make the changes as soon as possible.


Thanks,

Hongliang Wang


From: Binbin Zhou <zhoubb.aaron@xxxxxxxxx>
To: Hongliang Wang <wanghongliang@xxxxxxxxxxx>
Cc: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>,
    Andi Shyti <andi.shyti@xxxxxxxxxx>,
     linux-i2c@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx,
     loongarch@xxxxxxxxxxxxxxx
Subject: Re: [PATCH v1] LoongArch: add i2c clocks and clock-div parameter parsing.
Date: Wed, 11 Feb 2026 12:23:45 +0800    [thread overview]
Message-ID: <CAMpQs4LeFNEXyg-fVDiSDpEVdbPAY5Z5gL7-5s5uZ52BWmXP5w@xxxxxxxxxxxxxx> (raw)
In-Reply-To: <20260211025057.29746-1-wanghongliang@xxxxxxxxxxx>

Hi Hongliang:


Bad commit subject, it should start with:
i2c: ls2x:

On Wed, Feb 11, 2026 at 10:51 AM Hongliang Wang
<wanghongliang@xxxxxxxxxxx> wrote:
>
> On 3A/7A/2K platform, i2c ref clocks and clock divisor maybe
> different, through firmware parameter passing, "clocks" and
> "clock-div" are used to describe i2c ref clocks and divisor.

I feel it's necessary to specify which platforms are different in the
commit message.
>
> Signed-off-by: Hongliang Wang <wanghongliang@xxxxxxxxxxx>
> ---
>  drivers/i2c/busses/i2c-ls2x.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-ls2x.c b/drivers/i2c/busses/i2c-ls2x.c
> index b475dd27b7af..562bf32a9d6c 100644
> --- a/drivers/i2c/busses/i2c-ls2x.c
> +++ b/drivers/i2c/busses/i2c-ls2x.c
> @@ -96,6 +96,8 @@ static irqreturn_t ls2x_i2c_isr(int this_irq, void *dev_id)
>  static void ls2x_i2c_adjust_bus_speed(struct ls2x_i2c_priv *priv)
>  {
>         u16 val;
> +       u32 pclk;
> +       u32 div;

Place them in a single line.
>         struct i2c_timings *t = &priv->i2c_t;
>         struct device *dev = priv->adapter.dev.parent;
>         u32 acpi_speed = i2c_acpi_find_bus_speed(dev);
> @@ -107,12 +109,16 @@ static void ls2x_i2c_adjust_bus_speed(struct ls2x_i2c_priv *priv)
>         else
>                 t->bus_freq_hz = LS2X_I2C_FREQ_STD;
>
> +       if (!device_property_read_u32(dev, "clocks", &pclk) &&
> +               !device_property_read_u32(dev, "clock-div", &div) && div != 0)
> +               val = (pclk * 10) / (div * t->bus_freq_hz) - 1;

I think you should update dt-binding synchronously and verify whether
the existing i2c node in DTS{i} requires updating.
> +       else
> +               val = LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1;
>         /*
>          * According to the chip manual, we can only access the registers as bytes,
>          * otherwise the high bits will be truncated.
>          * So set the I2C frequency with a sequential writeb() instead of writew().
>          */
> -       val = LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1;
>         writeb(FIELD_GET(GENMASK(7, 0), val), priv->base + I2C_LS2X_PRER_LO);
>         writeb(FIELD_GET(GENMASK(15, 8), val), priv->base + I2C_LS2X_PRER_HI);
>  }
> --
> 2.47.2
>
>

--
Thanks.
Binbin