RE: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-09-06 Thread Zang Roy-R61911


> -Original Message-
> From: Anton Vorontsov [mailto:cbouatmai...@gmail.com]
> Sent: Monday, September 06, 2010 16:10 PM
> To: Zang Roy-R61911
> Cc: linux-...@lists.infradead.org; Lan Chunhe-B25806; linuxppc-...@ozlabs.org;
> a...@linux-foundation.org; Gala Kumar-B11780; Wood Scott-B07421
> Subject: Re: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect
> nand flash partitions
> 
> On Mon, Sep 06, 2010 at 12:49:17PM +0800, Zang Roy-R61911 wrote:
> > > On Fri, Aug 06, 2010 at 10:51:35AM +0800, Roy Zang wrote:
> > > [...]
> > > >
> > > > +static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
> > > > +
> > >
> > > Are you sure that you want it as a global var? A bit scary change.
> > >
> > > Oh, you probably don't need it, as you can get it from
> > > fsl_lbc_ctrl_dev->nand?
> > Get it form fsl_lbc_ctrl_dev->nand or assign it to
> > fsl_lbc_ctrl_dev->nand in probe?
> 
> I meant to get it from fsl_lbc_ctrl_dev->nand. I.e. in
> probe() you do: fsl_lbc_ctrl_dev->nand = elbc_fcm_ctrl, so
> you probably don't need the global var.
> 
> (fsl_lbc_ctrl_dev seems to be global as well, duh. Well,
> one variable less in the global name space. But I'd
> probably use lbc_np->data to store the LBC private
> struct).
That makes sense.
> 
> Scott seem to be fine with it as there are probably no
> plans to to add several localbus controllers into the SoCs.
> 
> But, I saw a custom board with two MPC82xx SoCs connected
> together, one as a master (core + peripheral devs), and
> other as a slave (its core was halted, and only slave's
> CPM peripheral devices were used by the master CPU).
> 
> I think it is possible to connect two (or more) SoCs in
> a such way so that two or more LBC controllers would
> be visible for the Linux.
That is an interesting case. Do you have any thought here?
Thanks.
Roy
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-09-06 Thread Anton Vorontsov
On Mon, Sep 06, 2010 at 12:49:17PM +0800, Zang Roy-R61911 wrote:
> > On Fri, Aug 06, 2010 at 10:51:35AM +0800, Roy Zang wrote:
> > [...]
> > >
> > > +static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
> > > +
> > 
> > Are you sure that you want it as a global var? A bit scary change.
> > 
> > Oh, you probably don't need it, as you can get it from
> > fsl_lbc_ctrl_dev->nand?
> Get it form fsl_lbc_ctrl_dev->nand or assign it to
> fsl_lbc_ctrl_dev->nand in probe?

I meant to get it from fsl_lbc_ctrl_dev->nand. I.e. in
probe() you do: fsl_lbc_ctrl_dev->nand = elbc_fcm_ctrl, so
you probably don't need the global var.

(fsl_lbc_ctrl_dev seems to be global as well, duh. Well,
one variable less in the global name space. But I'd
probably use lbc_np->data to store the LBC private
struct).

Scott seem to be fine with it as there are probably no
plans to to add several localbus controllers into the SoCs.

But, I saw a custom board with two MPC82xx SoCs connected
together, one as a master (core + peripheral devs), and
other as a slave (its core was halted, and only slave's
CPM peripheral devices were used by the master CPU).

I think it is possible to connect two (or more) SoCs in
a such way so that two or more LBC controllers would
be visible for the Linux.

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


RE: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-09-05 Thread Zang Roy-R61911


> -Original Message-
> From: Anton Vorontsov [mailto:cbouatmai...@gmail.com]
> Sent: Friday, September 03, 2010 19:44 PM
> To: Zang Roy-R61911
> Cc: linux-...@lists.infradead.org; Lan Chunhe-B25806; linuxppc-...@ozlabs.org;
> a...@linux-foundation.org; Gala Kumar-B11780; Wood Scott-B07421
> Subject: Re: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect
> nand flash partitions
> 
> On Fri, Aug 06, 2010 at 10:51:35AM +0800, Roy Zang wrote:
> [...]
> >
> > +static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
> > +
> 
> Are you sure that you want it as a global var? A bit scary change.
> 
> Oh, you probably don't need it, as you can get it from
> fsl_lbc_ctrl_dev->nand?
Get it form fsl_lbc_ctrl_dev->nand or assign it to fsl_lbc_ctrl_dev->nand in 
probe?
Thanks.
Roy

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


RE: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-09-05 Thread Zang Roy-R61911


> -Original Message-
> From: Anton Vorontsov [mailto:cbouatmai...@gmail.com]
> Sent: Friday, September 03, 2010 19:44 PM
> To: Zang Roy-R61911
> Cc: linux-...@lists.infradead.org; Lan Chunhe-B25806; linuxppc-...@ozlabs.org;
> a...@linux-foundation.org; Gala Kumar-B11780; Wood Scott-B07421
> Subject: Re: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect
> nand flash partitions
> 
> On Fri, Aug 06, 2010 at 10:51:35AM +0800, Roy Zang wrote:
> [...]
> >
> > +static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
> > +
> 
> Are you sure that you want it as a global var? A bit scary change.
> 
> Oh, you probably don't need it, as you can get it from
> fsl_lbc_ctrl_dev->nand?
> 
> I wonder if Scott saw these patches? Cc'ed.
Yes.
Roy
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-09-03 Thread Scott Wood
On Fri, 3 Sep 2010 15:43:57 +0400
Anton Vorontsov  wrote:

> On Fri, Aug 06, 2010 at 10:51:35AM +0800, Roy Zang wrote:
> [...]
> >  
> > +static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
> > +
> 
> Are you sure that you want it as a global var? A bit scary change.
> 
> Oh, you probably don't need it, as you can get it from
> fsl_lbc_ctrl_dev->nand?
> 
> I wonder if Scott saw these patches? Cc'ed.

I saw many iterations of these patches. :-)

I had the same reaction to this, but during internal review it did not
seem to be the most pressing concern to focus on.

In practice, there will only be one eLBC, and properly handling multiple
devices and binding the right one across this new boundary would have
been unnecessary complexity.

-Scott

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


Re: [PATCH 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-09-03 Thread Anton Vorontsov
On Fri, Aug 06, 2010 at 10:51:35AM +0800, Roy Zang wrote:
[...]
>  
> +static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
> +

Are you sure that you want it as a global var? A bit scary change.

Oh, you probably don't need it, as you can get it from
fsl_lbc_ctrl_dev->nand?

I wonder if Scott saw these patches? Cc'ed.

-- 
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 2/3][MTD] P4080/nand: Only make elbc nand driver detect nand flash partitions

2010-08-05 Thread Roy Zang
From: Lan Chunhe-B25806 

The former driver had the two functions:

1. detecting nand flash partitions;
2. registering elbc interrupt.

Now, second function is removed to fsl_lbc.c.

Signed-off-by: Lan Chunhe-B25806 
Signed-off-by: Roy Zang 
---
 drivers/mtd/nand/Kconfig |1 +
 drivers/mtd/nand/fsl_elbc_nand.c |  464 ++
 2 files changed, 170 insertions(+), 295 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index ffc3720..4b4c82e 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -459,6 +459,7 @@ config MTD_NAND_ORION
 config MTD_NAND_FSL_ELBC
tristate "NAND support for Freescale eLBC controllers"
depends on MTD_NAND && PPC_OF
+   select FSL_LBC
help
  Various Freescale chips, including the 8313, include a NAND Flash
  Controller Module with built-in hardware ECC capabilities.
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 5084cc5..7bbcb3f 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -1,9 +1,10 @@
 /* Freescale Enhanced Local Bus Controller NAND driver
  *
- * 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
@@ -24,32 +25,21 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
-#include 
 #include 
-#include 
 #include 
-
-#include 
 #include 
 
 #define MAX_BANKS 8
 #define ERR_BYTE 0xFF /* Value returned for read bytes when read failed */
 #define FCM_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait for FCM */
 
-struct fsl_elbc_ctrl;
-
 /* mtd information per set */
 
 struct fsl_elbc_mtd {
struct mtd_info mtd;
struct nand_chip chip;
-   struct fsl_elbc_ctrl *ctrl;
+   struct fsl_lbc_ctrl *ctrl;
 
struct device *dev;
int bank;   /* Chip select bank number   */
@@ -58,18 +48,12 @@ struct fsl_elbc_mtd {
unsigned int fmr;   /* FCM Flash Mode Register value */
 };
 
-/* overview of the fsl elbc controller */
+/* Freescale eLBC FCM controller infomation */
 
-struct fsl_elbc_ctrl {
+struct fsl_elbc_fcm_ctrl {
struct nand_hw_control controller;
struct fsl_elbc_mtd *chips[MAX_BANKS];
 
-   /* device info */
-   struct device *dev;
-   struct fsl_lbc_regs __iomem *regs;
-   int irq;
-   wait_queue_head_t irq_wait;
-   unsigned int irq_status; /* status read from LTESR by irq handler */
u8 __iomem *addr;/* Address of assigned FCM buffer*/
unsigned int page;   /* Last page written to / read from  */
unsigned int read_bytes; /* Number of bytes read during command   */
@@ -82,6 +66,8 @@ struct fsl_elbc_ctrl {
char *oob_poi;   /* Place to write ECC after read back*/
 };
 
+static struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
+
 /* These map to the positions used by the FCM hardware ECC generator */
 
 /* Small Page FLASH with FMR[ECCM] = 0 */
@@ -164,11 +150,11 @@ static void set_addr(struct mtd_info *mtd, int column, 
int page_addr, int oob)
 {
struct nand_chip *chip = mtd->priv;
struct fsl_elbc_mtd *priv = chip->priv;
-   struct fsl_elbc_ctrl *ctrl = priv->ctrl;
+   struct fsl_lbc_ctrl *ctrl = priv->ctrl;
struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
int buf_num;
 
-   ctrl->page = page_addr;
+   elbc_fcm_ctrl->page = page_addr;
 
out_be32(&lbc->fbar,
 page_addr >> (chip->phys_erase_shift - chip->page_shift));
@@ -185,16 +171,18 @@ static void set_addr(struct mtd_info *mtd, int column, 
int page_addr, int oob)
buf_num = page_addr & 7;
}
 
-   ctrl->addr = priv->vbase + buf_num * 1024;
-   ctrl->index = column;
+   elbc_fcm_ctrl->addr = priv->vbase + buf_num * 1024;
+   elbc_fcm_ctrl->index = column;
 
/* for OOB data point to the second half of the buffer */
if (oob)
-   ctrl->index += priv->page_size ? 2048 : 512;
+   elbc_fcm_ctrl->index += priv->page_size ? 2048 : 512;
 
-   dev_vdbg(ctrl->dev, "set_addr: bank=%d, ctrl->addr=0x%p (0x%p), "
+   dev_vdbg(priv->dev, "set_addr: bank=%d, "
+   "elbc_fcm_ctrl->addr=0x%p (0x%p), "
"index %x, pes %d ps %d\n",
-buf_num, ctrl->addr, priv->vbase, ctrl->index,
+buf_num, elbc_fcm_ctrl->addr, priv->vbase,
+elbc_fcm_ctrl->index,
 chip->phys_erase_shift, chip->page_shift);
 }
 
@@ -205,18 +193,18 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)
 {
struct nand_chip *chi