RE: [PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices

2010-10-14 Thread Zang Roy-R61911


> -Original Message-
> From: Wood Scott-B07421
> Sent: Friday, October 15, 2010 0:03 AM
> To: Zang Roy-R61911
> Cc: Anton Vorontsov; linux-...@lists.infradead.org;
dw...@infradead.org;
> dedeki...@gmail.com; a...@linux-foundation.org; Lan Chunhe-B25806;
Wood Scott-
> B07421; Gala Kumar-B11780; linuxppc-...@ozlabs.org
> Subject: Re: [PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt
common
> to elbc devices
> 
> On Wed, 13 Oct 2010 23:43:38 -0700
> "Zang Roy-R61911"  wrote:
> 
> > > Plus, I think the patch is not runtime bisectable (i.e. you
> > > now do request_irq() here, but not removing it from the nand
> > > driver, so nand will fail to probe).
> > Nand driver does not need to request irq. It will use the irq
requested by
> lbc.
> > remember, other lbc device may also need to use this registered irq.
> > It should not be removed in nand driver.
> 
> The point is that you need to make both changes in the same patch.

But according to previous discussion, if lbc driver is registered
successful, it will not be removed. (.remove function is dropped in the
patch). that is not bisectable?
nand driver will not touch the irq. all irq status process is in the lbc
driver.
Thanks.
Roy

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices

2010-10-14 Thread Scott Wood
On Wed, 13 Oct 2010 23:43:38 -0700
"Zang Roy-R61911"  wrote:

> > Plus, I think the patch is not runtime bisectable (i.e. you
> > now do request_irq() here, but not removing it from the nand
> > driver, so nand will fail to probe).
> Nand driver does not need to request irq. It will use the irq requested by 
> lbc.
> remember, other lbc device may also need to use this registered irq. 
> It should not be removed in nand driver.

The point is that you need to make both changes in the same patch.

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices

2010-10-13 Thread Zang Roy-R61911


> -Original Message-
> From: Anton Vorontsov [mailto:cbouatmai...@gmail.com]
> Sent: Monday, September 20, 2010 23:37 PM
> To: Zang Roy-R61911
> Cc: linux-...@lists.infradead.org; dw...@infradead.org; dedeki...@gmail.com;
> a...@linux-foundation.org; Lan Chunhe-B25806; Wood Scott-B07421; Gala Kumar-
> B11780; linuxppc-...@ozlabs.org
> Subject: Re: [PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt common
> to elbc devices
> 
> On Fri, Sep 17, 2010 at 03:01:07PM +0800, Roy Zang wrote:

[snip]

> >  int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 
> > mar)
> >  {
> > int ret = 0;
> > unsigned long flags;
> [...]
> > +static int __devinit fsl_lbc_ctrl_probe(struct platform_device *dev)
> > +{
> > +   int ret;
> > +
> > +   if (!dev->dev.of_node) {
> > +   dev_err(&dev->dev, "Device OF-Node is NULL");
> > +   return -EFAULT;
> > +   }
> > +   fsl_lbc_ctrl_dev = kzalloc(sizeof(*fsl_lbc_ctrl_dev), GFP_KERNEL);
> 
> Btw, the code in the NAND driver checks for !fsl_lbc_ctrl_dev.
> 
> So it might make sense to assign the global variable after the
> struct is fully initialized.
What struct?
assign the global variable in nand driver? 
I'd prefer init it in the lbc code.
There may be other lbc device, who will use this  global variable.

> 
> > +   if (!fsl_lbc_ctrl_dev)
> > +   return -ENOMEM;
> > +
> > +   dev_set_drvdata(&dev->dev, fsl_lbc_ctrl_dev);
> > +
> > +   spin_lock_init(&fsl_lbc_ctrl_dev->lock);
> > +   init_waitqueue_head(&fsl_lbc_ctrl_dev->irq_wait);
> > +
> > +   fsl_lbc_ctrl_dev->regs = of_iomap(dev->dev.of_node, 0);
> > +   if (!fsl_lbc_ctrl_dev->regs) {
> > +   dev_err(&dev->dev, "failed to get memory region\n");
> > +   ret = -ENODEV;
> > +   goto err;
> > +   }
> > +
> > +   fsl_lbc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
> > +   if (fsl_lbc_ctrl_dev->irq == NO_IRQ) {
> > +   dev_err(&dev->dev, "failed to get irq resource\n");
> > +   ret = -ENODEV;
> > +   goto err;
> > +   }
> > +
> > +   fsl_lbc_ctrl_dev->dev = &dev->dev;
> > +
> > +   ret = fsl_lbc_ctrl_init(fsl_lbc_ctrl_dev);
> > +   if (ret < 0)
> > +   goto err;
> > +
> > +   ret = request_irq(fsl_lbc_ctrl_dev->irq, fsl_lbc_ctrl_irq, 0,
> > +   "fsl-lbc", fsl_lbc_ctrl_dev);
> > +   if (ret != 0) {
> > +   dev_err(&dev->dev, "failed to install irq (%d)\n",
> > +   fsl_lbc_ctrl_dev->irq);
> > +   ret = fsl_lbc_ctrl_dev->irq;
> > +   goto err;
> > +   }
> > +
> > +   return 0;
> > +
> > +err:
> > +   iounmap(fsl_lbc_ctrl_dev->regs);
> > +   kfree(fsl_lbc_ctrl_dev);
> > +   return ret;
> > +}
> > +
> > +static const struct of_device_id fsl_lbc_match[] = {
> 
> #include  is needed for this.
> 
> 
> Plus, I think the patch is not runtime bisectable (i.e. you
> now do request_irq() here, but not removing it from the nand
> driver, so nand will fail to probe).
Nand driver does not need to request irq. It will use the irq requested by lbc.
remember, other lbc device may also need to use this registered irq. 
It should not be removed in nand driver.

Thanks.
Roy
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices

2010-09-20 Thread Anton Vorontsov
On Fri, Sep 17, 2010 at 03:01:07PM +0800, Roy Zang wrote:
[...]
> +struct fsl_lbc_ctrl {
> + /* device info */
> + struct device   *dev;

Forward declaration for struct device is needed (and enough).

> + struct fsl_lbc_regs __iomem *regs;
> + int irq;
> + wait_queue_head_t   irq_wait;

#include  is needed for this.

> + spinlock_t  lock;

#include 

[...]
> diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c
> index dceb8d1..4920cd3 100644
> --- a/arch/powerpc/sysdev/fsl_lbc.c
> +++ b/arch/powerpc/sysdev/fsl_lbc.c
[...]
> +#include 
> +#include 

I guess of_platform.h is not needed any longer.

> +#include 
> +#include 
>  
[...]
>   default:
>   return -EINVAL;
> @@ -143,14 +130,18 @@ EXPORT_SYMBOL(fsl_upm_find);
>   * thus UPM pattern actually executed. Note that mar usage depends on the
>   * pre-programmed AMX bits in the UPM RAM.
>   */
> +

No need for this empty line.

>  int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 mar)
>  {
>   int ret = 0;
>   unsigned long flags;
[...]
> +static int __devinit fsl_lbc_ctrl_probe(struct platform_device *dev)
> +{
> + int ret;
> +
> + if (!dev->dev.of_node) {
> + dev_err(&dev->dev, "Device OF-Node is NULL");
> + return -EFAULT;
> + }
> + fsl_lbc_ctrl_dev = kzalloc(sizeof(*fsl_lbc_ctrl_dev), GFP_KERNEL);

Btw, the code in the NAND driver checks for !fsl_lbc_ctrl_dev.

So it might make sense to assign the global variable after the
struct is fully initialized.

> + if (!fsl_lbc_ctrl_dev)
> + return -ENOMEM;
> +
> + dev_set_drvdata(&dev->dev, fsl_lbc_ctrl_dev);
> +
> + spin_lock_init(&fsl_lbc_ctrl_dev->lock);
> + init_waitqueue_head(&fsl_lbc_ctrl_dev->irq_wait);
> +
> + fsl_lbc_ctrl_dev->regs = of_iomap(dev->dev.of_node, 0);
> + if (!fsl_lbc_ctrl_dev->regs) {
> + dev_err(&dev->dev, "failed to get memory region\n");
> + ret = -ENODEV;
> + goto err;
> + }
> +
> + fsl_lbc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
> + if (fsl_lbc_ctrl_dev->irq == NO_IRQ) {
> + dev_err(&dev->dev, "failed to get irq resource\n");
> + ret = -ENODEV;
> + goto err;
> + }
> +
> + fsl_lbc_ctrl_dev->dev = &dev->dev;
> +
> + ret = fsl_lbc_ctrl_init(fsl_lbc_ctrl_dev);
> + if (ret < 0)
> + goto err;
> +
> + ret = request_irq(fsl_lbc_ctrl_dev->irq, fsl_lbc_ctrl_irq, 0,
> + "fsl-lbc", fsl_lbc_ctrl_dev);
> + if (ret != 0) {
> + dev_err(&dev->dev, "failed to install irq (%d)\n",
> + fsl_lbc_ctrl_dev->irq);
> + ret = fsl_lbc_ctrl_dev->irq;
> + goto err;
> + }
> +
> + return 0;
> +
> +err:
> + iounmap(fsl_lbc_ctrl_dev->regs);
> + kfree(fsl_lbc_ctrl_dev);
> + return ret;
> +}
> +
> +static const struct of_device_id fsl_lbc_match[] = {

#include  is needed for this.


Plus, I think the patch is not runtime bisectable (i.e. you
now do request_irq() here, but not removing it from the nand
driver, so nand will fail to probe).

Thanks,

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/3 v4] P4080/eLBC: Make Freescale elbc interrupt common to elbc devices

2010-09-17 Thread Roy Zang
From: Lan Chunhe-B25806 

Move Freescale elbc interrupt from nand dirver to elbc driver.
Then all elbc devices can use the interrupt instead of ONLY nand.

Signed-off-by: Lan Chunhe-B25806 
Signed-off-by: Roy Zang 
---
Comparing v3:
1.  minor fix from type unsigned int to u32
2.  fix platform_driver issue.
3.  add mutex for nand probe
 arch/powerpc/Kconfig   |7 +-
 arch/powerpc/include/asm/fsl_lbc.h |   31 +-
 arch/powerpc/sysdev/fsl_lbc.c  |  246 ++--
 3 files changed, 242 insertions(+), 42 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 631e5a0..44df1ba 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -687,9 +687,12 @@ config 4xx_SOC
bool
 
 config FSL_LBC
-   bool
+   bool "Freescale Local Bus support"
+   depends on FSL_SOC
help
- Freescale Localbus support
+ Enables reporting of errors from the Freescale local bus
+ controller.  Also contains some common code used by
+ drivers for specific local bus peripherals.
 
 config FSL_GTM
bool
diff --git a/arch/powerpc/include/asm/fsl_lbc.h 
b/arch/powerpc/include/asm/fsl_lbc.h
index 1b5a210..db94698 100644
--- a/arch/powerpc/include/asm/fsl_lbc.h
+++ b/arch/powerpc/include/asm/fsl_lbc.h
@@ -1,9 +1,10 @@
 /* Freescale Local Bus Controller
  *
- * Copyright (c) 2006-2007 Freescale Semiconductor
+ * Copyright (c) 2006-2007, 2010 Freescale Semiconductor
  *
  * Authors: Nick Spence ,
  *  Scott Wood 
+ *  Jack Lan 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -125,13 +126,23 @@ struct fsl_lbc_regs {
 #define LTESR_ATMW 0x0080
 #define LTESR_ATMR 0x0040
 #define LTESR_CS   0x0008
+#define LTESR_UPM  0x0002
 #define LTESR_CC   0x0001
 #define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC)
+#define LTESR_MASK  (LTESR_BM | LTESR_FCT | LTESR_PAR | LTESR_WP \
+| LTESR_ATMW | LTESR_ATMR | LTESR_CS | LTESR_UPM \
+| LTESR_CC)
+#define LTESR_CLEAR0x
+#define LTECCR_CLEAR   0x
+#define LTESR_STATUS   LTESR_MASK
+#define LTEIR_ENABLE   LTESR_MASK
+#define LTEDR_ENABLE   0x
__be32 ltedr;   /**< Transfer Error Disable Register */
__be32 lteir;   /**< Transfer Error Interrupt Register */
__be32 lteatr;  /**< Transfer Error Attributes Register */
__be32 ltear;   /**< Transfer Error Address Register */
-   u8 res6[0xC];
+   __be32 lteccr;  /**< Transfer Error ECC Register */
+   u8 res6[0x8];
__be32 lbcr;/**< Configuration Register */
 #define LBCR_LDIS  0x8000
 #define LBCR_LDIS_SHIFT31
@@ -265,7 +276,23 @@ static inline void fsl_upm_end_pattern(struct fsl_upm *upm)
cpu_relax();
 }
 
+/* overview of the fsl lbc controller */
+
+struct fsl_lbc_ctrl {
+   /* device info */
+   struct device   *dev;
+   struct fsl_lbc_regs __iomem *regs;
+   int irq;
+   wait_queue_head_t   irq_wait;
+   spinlock_t  lock;
+   void*nand;
+
+   /* status read from LTESR by irq handler */
+   unsigned intirq_status;
+};
+
 extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base,
   u32 mar);
+extern struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev;
 
 #endif /* __ASM_FSL_LBC_H */
diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c
index dceb8d1..4920cd3 100644
--- a/arch/powerpc/sysdev/fsl_lbc.c
+++ b/arch/powerpc/sysdev/fsl_lbc.c
@@ -2,8 +2,11 @@
  * Freescale LBC and UPM routines.
  *
  * Copyright (c) 2007-2008  MontaVista Software, Inc.
+ * Copyright (c) 2010 Freescale Semiconductor
  *
  * Author: Anton Vorontsov 
+ * Author: Jack Lan 
+ * Author: Roy Zang 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,37 +24,14 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 static spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock);
-static struct fsl_lbc_regs __iomem *fsl_lbc_regs;
-
-static char __initdata *compat_lbc[] = {
-   "fsl,pq2-localbus",
-   "fsl,pq2pro-localbus",
-   "fsl,pq3-localbus",
-   "fsl,elbc",
-};
-
-static int __init fsl_lbc_init(void)
-{
-   struct device_node *lbus;
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(compat_lbc); i++) {
-   lbus = of_find_compatible_node(NULL, NULL, compat_lbc[i]);
-   if (lbus)
-   goto found;
-   }
-   return -ENODEV;
-
-found:
-   fsl_lbc_regs = of_iomap(lbus, 0);
-   of_node_