[EXT] Re: [PATCH v4] i2c: imx-lpi2c: return -EINVAL when i2c peripheral clk doesn't work

Carlos Song carlos.song at nxp.com
Wed Jul 26 00:32:17 PDT 2023


Hi, Andi

According to Aisheng, I find that if the i2c clock rate is not assigned on MX8,
due to chip architecture, the default speed will be 0, it cause our i2c not work.
The judgment will be triggered easily. This is a special case for imx.

The log like this:
[    2.401402] imx-lpi2c 5a800000.i2c: use pio mode
[    2.419788] i2c i2c-4: clk_per rate is 0
[    2.423724] i2c i2c-4: clk_per rate is 0
[    2.444071] i2c i2c-4: clk_per rate is 0
[    2.448011] fxos8700_i2c 4-001e: Error reading chip id
[    2.453172] fxos8700_i2c: probe of 4-001e failed with error -22
[    2.459271] i2c i2c-4: supply vdd not found, using dummy regulator
[    2.465522] i2c i2c-4: supply vddio not found, using dummy regulator
[    2.471913] i2c i2c-4: clk_per rate is 0
[    2.475867] fxas21002c_i2c: probe of 4-0020 failed with error -22
[    2.482066] i2c i2c-4: clk_per rate is 0
[    2.495716] i2c i2c-4: clk_per rate is 0
[    2.505464] i2c i2c-4: clk_per rate is 0
[    2.514786] i2c i2c-4: LPI2C adapter registered

So the patch can not be dropped.
> -----Original Message-----
> From: Andi Shyti <andi.shyti at kernel.org>
> Sent: Wednesday, July 26, 2023 7:41 AM
> To: Carlos Song <carlos.song at nxp.com>
> Cc: u.kleine-koenig at pengutronix.de; Aisheng Dong <aisheng.dong at nxp.com>;
> shawnguo at kernel.org; s.hauer at pengutronix.de; kernel at pengutronix.de;
> festevam at gmail.com; Clark Wang <xiaoning.wang at nxp.com>; Bough Chen
> <haibo.chen at nxp.com>; dl-linux-imx <linux-imx at nxp.com>;
> linux-i2c at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> linux-kernel at vger.kernel.org
> Subject: [EXT] Re: [PATCH v4] i2c: imx-lpi2c: return -EINVAL when i2c peripheral
> clk doesn't work
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report this
> email' button
> 
> 
> Hi Carlos,
> 
> > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > @@ -209,6 +209,9 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct
> *lpi2c_imx)
> >       lpi2c_imx_set_mode(lpi2c_imx);
> >
> >       clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk);
> > +     if (!clk_rate)
> > +             return -EINVAL;
> > +
> 
> this is a very unlikely to happen and generally not really appreciated.
> 
> If you got so far it's basically impossible that clk_rate is '0'.
> Uwe asked you in v2 if you actually had such case.
> 
> I don't have a strong opinion, thoug... I would drop this patch unless Dong is OK
> with it and I can accept it with his ack.
> 
> Andi
> 
> >       if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST)
> >               filt = 0;
> >       else
> > --
> > 2.34.1
> >



More information about the linux-arm-kernel mailing list