[v2,0/3] P2040/P2041 i2c recovery erratum

Message ID 20210507004047.4454-1-chris.packham@alliedtelesis.co.nz
Headers show
Series
  • P2040/P2041 i2c recovery erratum
Related show

Message

Chris Packham May 7, 2021, 12:40 a.m.
The P2040/P2041 has an erratum where the i2c recovery scheme
documented in the reference manual (and currently implemented
in the i2c-mpc.c driver) does not work. The errata document
provides an alternative that does work. This series implements
that alternative and uses a property in the devicetree to
decide when the alternative mechanism is needed.

Chris Packham (3):
  dt-bindings: i2c: mpc: Add fsl,i2c-erratum-a004447 flag
  powerpc/fsl: set fsl,i2c-erratum-a004447 flag for P2041 i2c
    controllers
  i2c: mpc: implement erratum A-004447 workaround

 .../devicetree/bindings/i2c/i2c-mpc.yaml      |  7 ++
 arch/powerpc/boot/dts/fsl/p2041si-post.dtsi   | 16 ++++
 drivers/i2c/busses/i2c-mpc.c                  | 84 ++++++++++++++++++-
 3 files changed, 105 insertions(+), 2 deletions(-)

Comments

Joakim Tjernlund May 7, 2021, 8:24 a.m. | #1
On Fri, 2021-05-07 at 10:04 +0200, Joakim Tjernlund wrote:
> On Fri, 2021-05-07 at 12:40 +1200, Chris Packham wrote:

> > The i2c controllers on the P2040/P2041 have an erratum where the

> > documented scheme for i2c bus recovery will not work (A-004447). A

> > different mechanism is needed which is documented in the P2040 Chip

> > Errata Rev Q (latest available at the time of writing).

> 

> From what I can tell this Erratum also applies to P1010

> 

>  Jocke


Reference: https://media.digikey.com/pdf/PCNs/Freescale/P1010CE_RevL.pdf

Also, I think this series should go to stable.

 Jocke
Joakim Tjernlund May 7, 2021, 2:52 p.m. | #2
On Fri, 2021-05-07 at 14:46 +0300, Andy Shevchenko wrote:
> On Fri, May 7, 2021 at 3:40 AM Chris Packham

> <chris.packham@alliedtelesis.co.nz> wrote:

> > 

> > The P2040/P2041 has an erratum where the normal i2c recovery mechanism

> > does not work. Implement the alternative recovery mechanism documented

> > in the P2040 Chip Errata Rev Q.

> 

> Thanks.

> 

> > +static int i2c_mpc_wait_sr(struct mpc_i2c *i2c, int mask)

> > +{

> > +       int ret;

> > +       u8 val;

> > +

> > +       ret = readb_poll_timeout(i2c->base + MPC_I2C_SR, val,

> > +                                val & mask, 0, 100);

> > +

> > +       return ret;

> > +}

> 

> So, now you may shrink it even further, i.e.

> 

>        void __iomem *sr = i2c->base + MPC_I2C_SR;

>        u8 val;

> 

>        return readb_poll_timeout(sr, val, val & mask, 0, 100);

> 


val looks uninitialised before use?
Chris Packham May 9, 2021, 9:11 p.m. | #3
On 7/05/21 8:24 pm, Joakim Tjernlund wrote:
> On Fri, 2021-05-07 at 10:04 +0200, Joakim Tjernlund wrote:

>> On Fri, 2021-05-07 at 12:40 +1200, Chris Packham wrote:

>>> The i2c controllers on the P2040/P2041 have an erratum where the

>>> documented scheme for i2c bus recovery will not work (A-004447). A

>>> different mechanism is needed which is documented in the P2040 Chip

>>> Errata Rev Q (latest available at the time of writing).

>>  From what I can tell this Erratum also applies to P1010

Will add for v3.
>>   Jocke

> Reference: https://media.digikey.com/pdf/PCNs/Freescale/P1010CE_RevL.pdf

>

> Also, I think this series should go to stable.

This series builds on changes that have been merged for v5.13. I haven't 
checked if it applies to stable, I think at least commit 65171b2df15e 
("i2c: mpc: Make use of i2c_recover_bus()") would need to come along 
with it.