Re: [PATCH] i2c: ls2x: Fix frequency division register access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andy:

Thanks for your reply.

On Tue, Feb 18, 2025 at 7:34 PM Andy Shevchenko <andy@xxxxxxxxxx> wrote:
>
> On Tue, Feb 18, 2025 at 07:11:33PM +0800, Binbin Zhou wrote:
> > According to the chip manual, the I2C register access type of
> > Loongson-2K2000/LS7A is "B", so we can only access registers in byte
> > form (readb/writeb).
> >
> > Although Loongson-2K0500/Loongson-2K1000 do not have similar
> > constraints, register accesses in byte form also behave correctly.
> >
> > Also, in hardware, the frequency division registers are defined as two
> > separate registers (high 8-bit and low 8-bit), so we just access them
> > directly as bytes.
>
> ...
>
> >       /* Calculate and set i2c frequency. */
> > -     writew(LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1,
> > -            priv->base + I2C_LS2X_PRER);
> > +     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);
>
> Now this needs a comment to prevent from appearing a patch that basically
> changes that back to 16-bit write.

I will add a commit here.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
>

-- 
Thanks.
Binbin





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux