RE: [PATCH v2 1/1] i2c: ocores: fix polling mode workaround on FU540-C000 SoC

2020-10-12 Thread Sagar Kadam


> -Original Message-
> From: Andreas Schwab 
> Sent: Friday, October 9, 2020 11:55 PM
> To: Sagar Kadam 
> Cc: linux-kernel@vger.kernel.org; linux-ri...@lists.infradead.org; linux-
> i...@vger.kernel.org; pe...@korsgaard.com; and...@lunn.ch; Paul
> Walmsley ( Sifive) ; pal...@dabbelt.com;
> a...@eecs.berkeley.edu
> Subject: Re: [PATCH v2 1/1] i2c: ocores: fix polling mode workaround on
> FU540-C000 SoC
> 
> [External Email] Do not click links or attachments unless you recognize the
> sender and know the content is safe
> 
> On Okt 09 2020, Sagar Shrikant Kadam wrote:
> 
> > diff --git a/drivers/i2c/busses/i2c-ocores.c
> > b/drivers/i2c/busses/i2c-ocores.c index f5fc75b..9b3d1ab 100644
> > --- a/drivers/i2c/busses/i2c-ocores.c
> > +++ b/drivers/i2c/busses/i2c-ocores.c
> > @@ -686,17 +686,21 @@ static int ocores_i2c_probe(struct
> > platform_device *pdev)
> >
> >   init_waitqueue_head(>wait);
> >
> > + /*
> > +  * Set OCORES_FLAG_BROKEN_IRQ to enable workaround for
> > +  * FU540-C000 SoC in polling mode.
> > +  * Since the SoC does have interrupt it's dt has the interrupt
> 
> Typo: its
> 

Thanks Andreas,
I will submit v3 with the change.

BR,
Sagar
> Andreas.
> 
> --
> Andreas Schwab, sch...@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA
> AEC1 "And now for something completely different."


Re: [PATCH v2 1/1] i2c: ocores: fix polling mode workaround on FU540-C000 SoC

2020-10-09 Thread Andreas Schwab
On Okt 09 2020, Sagar Shrikant Kadam wrote:

> diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> index f5fc75b..9b3d1ab 100644
> --- a/drivers/i2c/busses/i2c-ocores.c
> +++ b/drivers/i2c/busses/i2c-ocores.c
> @@ -686,17 +686,21 @@ static int ocores_i2c_probe(struct platform_device 
> *pdev)
>  
>   init_waitqueue_head(>wait);
>  
> + /*
> +  * Set OCORES_FLAG_BROKEN_IRQ to enable workaround for
> +  * FU540-C000 SoC in polling mode.
> +  * Since the SoC does have interrupt it's dt has the interrupt

Typo: its

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


[PATCH v2 1/1] i2c: ocores: fix polling mode workaround on FU540-C000 SoC

2020-10-09 Thread Sagar Shrikant Kadam
The FU540-C000 has a broken IRQ and support was added earlier
so that it will operate in polling mode, but seems to work only
in case interrupts property is missing from the i2c0 dt-node.
This should not be the case and the driver should handle polling
mode with the interrupt property present in i2c0 node of the
device tree.
So check if it's the FU540-C000 soc and enable polling mode master
xfers, as the IRQ for this chip is broken.

Fixes commit c45d4ba86731 ("i2c: ocores: add polling mode workaround
for Sifive FU540-C000 SoC")

Signed-off-by: Sagar Shrikant Kadam 
---
 drivers/i2c/busses/i2c-ocores.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index f5fc75b..9b3d1ab 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -686,17 +686,21 @@ static int ocores_i2c_probe(struct platform_device *pdev)
 
init_waitqueue_head(>wait);
 
+   /*
+* Set OCORES_FLAG_BROKEN_IRQ to enable workaround for
+* FU540-C000 SoC in polling mode.
+* Since the SoC does have interrupt it's dt has the interrupt
+* defined but it should be bypassed in driver as this SoC has
+* a broken IRQ, hence update the master_xfer to use polling
+* transfers.
+*/
+   if (of_device_is_compatible(pdev->dev.of_node,
+   "sifive,fu540-c000-i2c"))
+   i2c->flags |= OCORES_FLAG_BROKEN_IRQ;
+
irq = platform_get_irq(pdev, 0);
-   if (irq == -ENXIO) {
+   if (i2c->flags & OCORES_FLAG_BROKEN_IRQ || irq == -ENXIO) {
ocores_algorithm.master_xfer = ocores_xfer_polling;
-
-   /*
-* Set in OCORES_FLAG_BROKEN_IRQ to enable workaround for
-* FU540-C000 SoC in polling mode.
-*/
-   match = of_match_node(ocores_i2c_match, pdev->dev.of_node);
-   if (match && (long)match->data == TYPE_SIFIVE_REV0)
-   i2c->flags |= OCORES_FLAG_BROKEN_IRQ;
} else {
if (irq < 0)
return irq;
-- 
2.7.4