Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-30 Thread Tony Lindgren
* Vimal Singh  [091129 22:11]:
> On Mon, Nov 23, 2009 at 11:15 PM, Tony Lindgren  wrote:
> > * Vimal Singh  [091119 00:52]:
> >> On Wed, Nov 18, 2009 at 10:37 PM, Tony Lindgren  wrote:
> >> > * Vimal Singh  [091118 06:38]:
> >> >> Tony,
> >> >>
> >> >> On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
> >> >> > * Vimal Singh  [091110 02:08]:
> >> >> >> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 
> >> >> >> 2001
> >> >> >> From: Vimal Singh 
> >> >> >> Date: Tue, 10 Nov 2009 11:42:45 +0530
> >> >> >> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
> >> >>
> >> >> [...]
> >> >>
> >> >> >> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, 
> >> >> >> uint64_t len)
> >> >> >> +{
> >> >> >> +     int ret = 0;
> >> >> >> +     int chipnr;
> >> >> >> +     int status;
> >> >> >> +     unsigned long page;
> >> >> >> +     struct nand_chip *this = mtd->priv;
> >> >> >> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
> >> >> >> +                     (int)ofs, (int)len);
> >> >> >> +
> >> >> >> +     /* select the NAND device */
> >> >> >> +     chipnr = (int)(ofs >> this->chip_shift);
> >> >> >> +     this->select_chip(mtd, chipnr);
> >> >> >> +     /* check the WP bit */
> >> >> >> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
> >> >> >> +     if ((this->read_byte(mtd) & 0x80) == 0) {
> >> >> >> +             printk(KERN_ERR "nand_unlock: Device is write 
> >> >> >> protected!\n");
> >> >> >> +             ret = -EINVAL;
> >> >> >> +             goto out;
> >> >> >> +     }
> >> >> >> +
> >> >> >> +     if ((ofs & (mtd->writesize - 1)) != 0) {
> >> >> >> +             printk(KERN_ERR "nand_unlock: Start address must be"
> >> >> >> +                             "beginning of nand page!\n");
> >> >> >> +             ret = -EINVAL;
> >> >> >> +             goto out;
> >> >> >> +     }
> >> >> >> +
> >> >> >> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
> >> >> >> +             printk(KERN_ERR "nand_unlock: Length must be a 
> >> >> >> multiple of "
> >> >> >> +                             "nand page size!\n");
> >> >> >> +             ret = -EINVAL;
> >> >> >> +             goto out;
> >> >> >> +     }
> >> >> >> +
> >> >> >> +     /* submit address of first page to unlock */
> >> >> >> +     page = (unsigned long)(ofs >> this->page_shift);
> >> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & 
> >> >> >> this->pagemask);
> >> >> >> +
> >> >> >> +     /* submit ADDRESS of LAST page to unlock */
> >> >> >> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
> >> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & 
> >> >> >> this->pagemask);
> >> >> >> +
> >> >> >> +     /* call wait ready function */
> >> >> >> +     status = this->waitfunc(mtd, this);
> >> >> >> +     udelay(1000);
> >> >> >> +     /* see if device thinks it succeeded */
> >> >> >> +     if (status & 0x01) {
> >> >> >> +             /* there was an error */
> >> >> >> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", 
> >> >> >> status);
> >> >> >> +             ret = -EIO;
> >> >> >> +             goto out;
> >> >> >> +     }
> >> >> >> +
> >> >> >> + out:
> >> >> >> +     /* de-select the NAND device */
> >> >> >> +     this->select_chip(mtd, -1);
> >> >> >> +     return ret;
> >> >> >> +}
> >> >> >
> >> >> > Isn't the unlocking generic to the NAND device driver? Or is it 
> >> >> > somehow board
> >> >> > specific?
> >> >>
> >> >> Yes, zoom2 boards come up with whole NAND locked, whereas it is not
> >> >> case for SDP boards.
> >> >
> >> > But the procedure should be done under drivers/mtd I believe using some
> >> > standard tools.
> >>
> >> OK, I'll take this discussion to mtd mailing list. For now I'll remove
> >> this from here.
> >
> > OK, I'd assume there's some standard way to handle this for all NOR
> > drivers.
> >
> >> >
> >> >> >
> >> >> >
> >> >> >> +static struct mtd_partition ldp_nand_partitions[] = {
> >> >> >> +     /* All the partition sizes are listed in terms of NAND block 
> >> >> >> size */
> >> >> >> +     {
> >> >> >> +             .name           = "X-Loader-NAND",
> >> >> >> +             .offset         = 0,
> >> >> >> +             .size           = 4 * (64 * 2048),      /* 512KB, 
> >> >> >> 0x8 */
> >> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
> >> >> >> read-only */
> >> >> >> +     },
> >> >> >> +     {
> >> >> >> +             .name           = "U-Boot-NAND",
> >> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> >> >> 0x8 */
> >> >> >> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 
> >> >> >> 0x14 */
> >> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
> >> >> >> read-only */
> >> >> >> +     },
> >> >> >> +     {
> >> >> >> +             .name           = "Boot Env-NAND",
> >> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> >> >> 0

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-29 Thread Vimal Singh
On Mon, Nov 23, 2009 at 11:15 PM, Tony Lindgren  wrote:
> * Vimal Singh  [091119 00:52]:
>> On Wed, Nov 18, 2009 at 10:37 PM, Tony Lindgren  wrote:
>> > * Vimal Singh  [091118 06:38]:
>> >> Tony,
>> >>
>> >> On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
>> >> > * Vimal Singh  [091110 02:08]:
>> >> >> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
>> >> >> From: Vimal Singh 
>> >> >> Date: Tue, 10 Nov 2009 11:42:45 +0530
>> >> >> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
>> >>
>> >> [...]
>> >>
>> >> >> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, 
>> >> >> uint64_t len)
>> >> >> +{
>> >> >> +     int ret = 0;
>> >> >> +     int chipnr;
>> >> >> +     int status;
>> >> >> +     unsigned long page;
>> >> >> +     struct nand_chip *this = mtd->priv;
>> >> >> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
>> >> >> +                     (int)ofs, (int)len);
>> >> >> +
>> >> >> +     /* select the NAND device */
>> >> >> +     chipnr = (int)(ofs >> this->chip_shift);
>> >> >> +     this->select_chip(mtd, chipnr);
>> >> >> +     /* check the WP bit */
>> >> >> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
>> >> >> +     if ((this->read_byte(mtd) & 0x80) == 0) {
>> >> >> +             printk(KERN_ERR "nand_unlock: Device is write 
>> >> >> protected!\n");
>> >> >> +             ret = -EINVAL;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> +     if ((ofs & (mtd->writesize - 1)) != 0) {
>> >> >> +             printk(KERN_ERR "nand_unlock: Start address must be"
>> >> >> +                             "beginning of nand page!\n");
>> >> >> +             ret = -EINVAL;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
>> >> >> +             printk(KERN_ERR "nand_unlock: Length must be a multiple 
>> >> >> of "
>> >> >> +                             "nand page size!\n");
>> >> >> +             ret = -EINVAL;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> +     /* submit address of first page to unlock */
>> >> >> +     page = (unsigned long)(ofs >> this->page_shift);
>> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & this->pagemask);
>> >> >> +
>> >> >> +     /* submit ADDRESS of LAST page to unlock */
>> >> >> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
>> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & this->pagemask);
>> >> >> +
>> >> >> +     /* call wait ready function */
>> >> >> +     status = this->waitfunc(mtd, this);
>> >> >> +     udelay(1000);
>> >> >> +     /* see if device thinks it succeeded */
>> >> >> +     if (status & 0x01) {
>> >> >> +             /* there was an error */
>> >> >> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", 
>> >> >> status);
>> >> >> +             ret = -EIO;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> + out:
>> >> >> +     /* de-select the NAND device */
>> >> >> +     this->select_chip(mtd, -1);
>> >> >> +     return ret;
>> >> >> +}
>> >> >
>> >> > Isn't the unlocking generic to the NAND device driver? Or is it somehow 
>> >> > board
>> >> > specific?
>> >>
>> >> Yes, zoom2 boards come up with whole NAND locked, whereas it is not
>> >> case for SDP boards.
>> >
>> > But the procedure should be done under drivers/mtd I believe using some
>> > standard tools.
>>
>> OK, I'll take this discussion to mtd mailing list. For now I'll remove
>> this from here.
>
> OK, I'd assume there's some standard way to handle this for all NOR
> drivers.
>
>> >
>> >> >
>> >> >
>> >> >> +static struct mtd_partition ldp_nand_partitions[] = {
>> >> >> +     /* All the partition sizes are listed in terms of NAND block 
>> >> >> size */
>> >> >> +     {
>> >> >> +             .name           = "X-Loader-NAND",
>> >> >> +             .offset         = 0,
>> >> >> +             .size           = 4 * (64 * 2048),      /* 512KB, 
>> >> >> 0x8 */
>> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
>> >> >> read-only */
>> >> >> +     },
>> >> >> +     {
>> >> >> +             .name           = "U-Boot-NAND",
>> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> >> 0x8 */
>> >> >> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 
>> >> >> 0x14 */
>> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
>> >> >> read-only */
>> >> >> +     },
>> >> >> +     {
>> >> >> +             .name           = "Boot Env-NAND",
>> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> >> 0x1c */
>> >> >> +             .size           = 2 * (64 * 2048),      /* 256KB, 
>> >> >> 0x4 */
>> >> >> +     },
>> >> >> +     {
>> >> >> +             .name           = "Kernel-NAND",
>> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> >> 0x020*/
>> >> >> +        

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-29 Thread Vimal Singh
On Mon, Nov 23, 2009 at 11:15 PM, Tony Lindgren  wrote:
> * Vimal Singh  [091119 00:52]:
>> On Wed, Nov 18, 2009 at 10:37 PM, Tony Lindgren  wrote:
>> > * Vimal Singh  [091118 06:38]:
>> >> Tony,
>> >>
>> >> On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
>> >> > * Vimal Singh  [091110 02:08]:
>> >> >> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
>> >> >> From: Vimal Singh 
>> >> >> Date: Tue, 10 Nov 2009 11:42:45 +0530
>> >> >> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
>> >>
>> >> [...]
>> >>
>> >> >> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, 
>> >> >> uint64_t len)
>> >> >> +{
>> >> >> +     int ret = 0;
>> >> >> +     int chipnr;
>> >> >> +     int status;
>> >> >> +     unsigned long page;
>> >> >> +     struct nand_chip *this = mtd->priv;
>> >> >> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
>> >> >> +                     (int)ofs, (int)len);
>> >> >> +
>> >> >> +     /* select the NAND device */
>> >> >> +     chipnr = (int)(ofs >> this->chip_shift);
>> >> >> +     this->select_chip(mtd, chipnr);
>> >> >> +     /* check the WP bit */
>> >> >> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
>> >> >> +     if ((this->read_byte(mtd) & 0x80) == 0) {
>> >> >> +             printk(KERN_ERR "nand_unlock: Device is write 
>> >> >> protected!\n");
>> >> >> +             ret = -EINVAL;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> +     if ((ofs & (mtd->writesize - 1)) != 0) {
>> >> >> +             printk(KERN_ERR "nand_unlock: Start address must be"
>> >> >> +                             "beginning of nand page!\n");
>> >> >> +             ret = -EINVAL;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
>> >> >> +             printk(KERN_ERR "nand_unlock: Length must be a multiple 
>> >> >> of "
>> >> >> +                             "nand page size!\n");
>> >> >> +             ret = -EINVAL;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> +     /* submit address of first page to unlock */
>> >> >> +     page = (unsigned long)(ofs >> this->page_shift);
>> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & this->pagemask);
>> >> >> +
>> >> >> +     /* submit ADDRESS of LAST page to unlock */
>> >> >> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
>> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & this->pagemask);
>> >> >> +
>> >> >> +     /* call wait ready function */
>> >> >> +     status = this->waitfunc(mtd, this);
>> >> >> +     udelay(1000);
>> >> >> +     /* see if device thinks it succeeded */
>> >> >> +     if (status & 0x01) {
>> >> >> +             /* there was an error */
>> >> >> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", 
>> >> >> status);
>> >> >> +             ret = -EIO;
>> >> >> +             goto out;
>> >> >> +     }
>> >> >> +
>> >> >> + out:
>> >> >> +     /* de-select the NAND device */
>> >> >> +     this->select_chip(mtd, -1);
>> >> >> +     return ret;
>> >> >> +}
>> >> >
>> >> > Isn't the unlocking generic to the NAND device driver? Or is it somehow 
>> >> > board
>> >> > specific?
>> >>
>> >> Yes, zoom2 boards come up with whole NAND locked, whereas it is not
>> >> case for SDP boards.
>> >
>> > But the procedure should be done under drivers/mtd I believe using some
>> > standard tools.
>>
>> OK, I'll take this discussion to mtd mailing list. For now I'll remove
>> this from here.
>
> OK, I'd assume there's some standard way to handle this for all NOR
> drivers.
>
>> >
>> >> >
>> >> >
>> >> >> +static struct mtd_partition ldp_nand_partitions[] = {
>> >> >> +     /* All the partition sizes are listed in terms of NAND block 
>> >> >> size */
>> >> >> +     {
>> >> >> +             .name           = "X-Loader-NAND",
>> >> >> +             .offset         = 0,
>> >> >> +             .size           = 4 * (64 * 2048),      /* 512KB, 
>> >> >> 0x8 */
>> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
>> >> >> read-only */
>> >> >> +     },
>> >> >> +     {
>> >> >> +             .name           = "U-Boot-NAND",
>> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> >> 0x8 */
>> >> >> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 
>> >> >> 0x14 */
>> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
>> >> >> read-only */
>> >> >> +     },
>> >> >> +     {
>> >> >> +             .name           = "Boot Env-NAND",
>> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> >> 0x1c */
>> >> >> +             .size           = 2 * (64 * 2048),      /* 256KB, 
>> >> >> 0x4 */
>> >> >> +     },
>> >> >> +     {
>> >> >> +             .name           = "Kernel-NAND",
>> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> >> 0x020*/
>> >> >> +        

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-23 Thread Tony Lindgren
* Vimal Singh  [091119 00:52]:
> On Wed, Nov 18, 2009 at 10:37 PM, Tony Lindgren  wrote:
> > * Vimal Singh  [091118 06:38]:
> >> Tony,
> >>
> >> On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
> >> > * Vimal Singh  [091110 02:08]:
> >> >> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
> >> >> From: Vimal Singh 
> >> >> Date: Tue, 10 Nov 2009 11:42:45 +0530
> >> >> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
> >>
> >> [...]
> >>
> >> >> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, 
> >> >> uint64_t len)
> >> >> +{
> >> >> +     int ret = 0;
> >> >> +     int chipnr;
> >> >> +     int status;
> >> >> +     unsigned long page;
> >> >> +     struct nand_chip *this = mtd->priv;
> >> >> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
> >> >> +                     (int)ofs, (int)len);
> >> >> +
> >> >> +     /* select the NAND device */
> >> >> +     chipnr = (int)(ofs >> this->chip_shift);
> >> >> +     this->select_chip(mtd, chipnr);
> >> >> +     /* check the WP bit */
> >> >> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
> >> >> +     if ((this->read_byte(mtd) & 0x80) == 0) {
> >> >> +             printk(KERN_ERR "nand_unlock: Device is write 
> >> >> protected!\n");
> >> >> +             ret = -EINVAL;
> >> >> +             goto out;
> >> >> +     }
> >> >> +
> >> >> +     if ((ofs & (mtd->writesize - 1)) != 0) {
> >> >> +             printk(KERN_ERR "nand_unlock: Start address must be"
> >> >> +                             "beginning of nand page!\n");
> >> >> +             ret = -EINVAL;
> >> >> +             goto out;
> >> >> +     }
> >> >> +
> >> >> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
> >> >> +             printk(KERN_ERR "nand_unlock: Length must be a multiple 
> >> >> of "
> >> >> +                             "nand page size!\n");
> >> >> +             ret = -EINVAL;
> >> >> +             goto out;
> >> >> +     }
> >> >> +
> >> >> +     /* submit address of first page to unlock */
> >> >> +     page = (unsigned long)(ofs >> this->page_shift);
> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & this->pagemask);
> >> >> +
> >> >> +     /* submit ADDRESS of LAST page to unlock */
> >> >> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
> >> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & this->pagemask);
> >> >> +
> >> >> +     /* call wait ready function */
> >> >> +     status = this->waitfunc(mtd, this);
> >> >> +     udelay(1000);
> >> >> +     /* see if device thinks it succeeded */
> >> >> +     if (status & 0x01) {
> >> >> +             /* there was an error */
> >> >> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", 
> >> >> status);
> >> >> +             ret = -EIO;
> >> >> +             goto out;
> >> >> +     }
> >> >> +
> >> >> + out:
> >> >> +     /* de-select the NAND device */
> >> >> +     this->select_chip(mtd, -1);
> >> >> +     return ret;
> >> >> +}
> >> >
> >> > Isn't the unlocking generic to the NAND device driver? Or is it somehow 
> >> > board
> >> > specific?
> >>
> >> Yes, zoom2 boards come up with whole NAND locked, whereas it is not
> >> case for SDP boards.
> >
> > But the procedure should be done under drivers/mtd I believe using some
> > standard tools.
> 
> OK, I'll take this discussion to mtd mailing list. For now I'll remove
> this from here.

OK, I'd assume there's some standard way to handle this for all NOR
drivers.
 
> >
> >> >
> >> >
> >> >> +static struct mtd_partition ldp_nand_partitions[] = {
> >> >> +     /* All the partition sizes are listed in terms of NAND block size 
> >> >> */
> >> >> +     {
> >> >> +             .name           = "X-Loader-NAND",
> >> >> +             .offset         = 0,
> >> >> +             .size           = 4 * (64 * 2048),      /* 512KB, 0x8 
> >> >> */
> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
> >> >> read-only */
> >> >> +     },
> >> >> +     {
> >> >> +             .name           = "U-Boot-NAND",
> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> >> 0x8 */
> >> >> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 
> >> >> 0x14 */
> >> >> +             .mask_flags     = MTD_WRITEABLE,        /* force 
> >> >> read-only */
> >> >> +     },
> >> >> +     {
> >> >> +             .name           = "Boot Env-NAND",
> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> >> 0x1c */
> >> >> +             .size           = 2 * (64 * 2048),      /* 256KB, 0x4 
> >> >> */
> >> >> +     },
> >> >> +     {
> >> >> +             .name           = "Kernel-NAND",
> >> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> >> 0x020*/
> >> >> +             .size           = 240 * (64 * 2048),    /* 30M, 0x1E0 
> >> >> */
> >> >> +     },
> >> >> +#ifdef CONFIG_MACH_OMAP_ZOOM2
> >> >> +     {
> >> >> +             .name           =

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-19 Thread Vimal Singh
On Wed, Nov 18, 2009 at 10:37 PM, Tony Lindgren  wrote:
> * Vimal Singh  [091118 06:38]:
>> Tony,
>>
>> On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
>> > * Vimal Singh  [091110 02:08]:
>> >> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
>> >> From: Vimal Singh 
>> >> Date: Tue, 10 Nov 2009 11:42:45 +0530
>> >> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
>>
>> [...]
>>
>> >> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, 
>> >> uint64_t len)
>> >> +{
>> >> +     int ret = 0;
>> >> +     int chipnr;
>> >> +     int status;
>> >> +     unsigned long page;
>> >> +     struct nand_chip *this = mtd->priv;
>> >> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
>> >> +                     (int)ofs, (int)len);
>> >> +
>> >> +     /* select the NAND device */
>> >> +     chipnr = (int)(ofs >> this->chip_shift);
>> >> +     this->select_chip(mtd, chipnr);
>> >> +     /* check the WP bit */
>> >> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
>> >> +     if ((this->read_byte(mtd) & 0x80) == 0) {
>> >> +             printk(KERN_ERR "nand_unlock: Device is write 
>> >> protected!\n");
>> >> +             ret = -EINVAL;
>> >> +             goto out;
>> >> +     }
>> >> +
>> >> +     if ((ofs & (mtd->writesize - 1)) != 0) {
>> >> +             printk(KERN_ERR "nand_unlock: Start address must be"
>> >> +                             "beginning of nand page!\n");
>> >> +             ret = -EINVAL;
>> >> +             goto out;
>> >> +     }
>> >> +
>> >> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
>> >> +             printk(KERN_ERR "nand_unlock: Length must be a multiple of "
>> >> +                             "nand page size!\n");
>> >> +             ret = -EINVAL;
>> >> +             goto out;
>> >> +     }
>> >> +
>> >> +     /* submit address of first page to unlock */
>> >> +     page = (unsigned long)(ofs >> this->page_shift);
>> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & this->pagemask);
>> >> +
>> >> +     /* submit ADDRESS of LAST page to unlock */
>> >> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
>> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & this->pagemask);
>> >> +
>> >> +     /* call wait ready function */
>> >> +     status = this->waitfunc(mtd, this);
>> >> +     udelay(1000);
>> >> +     /* see if device thinks it succeeded */
>> >> +     if (status & 0x01) {
>> >> +             /* there was an error */
>> >> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", 
>> >> status);
>> >> +             ret = -EIO;
>> >> +             goto out;
>> >> +     }
>> >> +
>> >> + out:
>> >> +     /* de-select the NAND device */
>> >> +     this->select_chip(mtd, -1);
>> >> +     return ret;
>> >> +}
>> >
>> > Isn't the unlocking generic to the NAND device driver? Or is it somehow 
>> > board
>> > specific?
>>
>> Yes, zoom2 boards come up with whole NAND locked, whereas it is not
>> case for SDP boards.
>
> But the procedure should be done under drivers/mtd I believe using some
> standard tools.

OK, I'll take this discussion to mtd mailing list. For now I'll remove
this from here.

>
>> >
>> >
>> >> +static struct mtd_partition ldp_nand_partitions[] = {
>> >> +     /* All the partition sizes are listed in terms of NAND block size */
>> >> +     {
>> >> +             .name           = "X-Loader-NAND",
>> >> +             .offset         = 0,
>> >> +             .size           = 4 * (64 * 2048),      /* 512KB, 0x8 */
>> >> +             .mask_flags     = MTD_WRITEABLE,        /* force read-only 
>> >> */
>> >> +     },
>> >> +     {
>> >> +             .name           = "U-Boot-NAND",
>> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x8 
>> >> */
>> >> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 0x14 
>> >> */
>> >> +             .mask_flags     = MTD_WRITEABLE,        /* force read-only 
>> >> */
>> >> +     },
>> >> +     {
>> >> +             .name           = "Boot Env-NAND",
>> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> 0x1c */
>> >> +             .size           = 2 * (64 * 2048),      /* 256KB, 0x4 */
>> >> +     },
>> >> +     {
>> >> +             .name           = "Kernel-NAND",
>> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> 0x020*/
>> >> +             .size           = 240 * (64 * 2048),    /* 30M, 0x1E0 */
>> >> +     },
>> >> +#ifdef CONFIG_MACH_OMAP_ZOOM2
>> >> +     {
>> >> +             .name           = "system",
>> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> 0x200 */
>> >> +             .size           = 1280 * (64 * 2048),   /* 160M, 0xA00 
>> >> */
>> >> +     },
>> >> +     {
>> >> +             .name           = "userdata",
>> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
>> >> 0xC00 */
>> >> +             .size           = 25

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-18 Thread Tony Lindgren
* Vimal Singh  [091118 06:38]:
> Tony,
> 
> On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
> > * Vimal Singh  [091110 02:08]:
> >> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
> >> From: Vimal Singh 
> >> Date: Tue, 10 Nov 2009 11:42:45 +0530
> >> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
> 
> [...]
> 
> >> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, 
> >> uint64_t len)
> >> +{
> >> +     int ret = 0;
> >> +     int chipnr;
> >> +     int status;
> >> +     unsigned long page;
> >> +     struct nand_chip *this = mtd->priv;
> >> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
> >> +                     (int)ofs, (int)len);
> >> +
> >> +     /* select the NAND device */
> >> +     chipnr = (int)(ofs >> this->chip_shift);
> >> +     this->select_chip(mtd, chipnr);
> >> +     /* check the WP bit */
> >> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
> >> +     if ((this->read_byte(mtd) & 0x80) == 0) {
> >> +             printk(KERN_ERR "nand_unlock: Device is write protected!\n");
> >> +             ret = -EINVAL;
> >> +             goto out;
> >> +     }
> >> +
> >> +     if ((ofs & (mtd->writesize - 1)) != 0) {
> >> +             printk(KERN_ERR "nand_unlock: Start address must be"
> >> +                             "beginning of nand page!\n");
> >> +             ret = -EINVAL;
> >> +             goto out;
> >> +     }
> >> +
> >> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
> >> +             printk(KERN_ERR "nand_unlock: Length must be a multiple of "
> >> +                             "nand page size!\n");
> >> +             ret = -EINVAL;
> >> +             goto out;
> >> +     }
> >> +
> >> +     /* submit address of first page to unlock */
> >> +     page = (unsigned long)(ofs >> this->page_shift);
> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & this->pagemask);
> >> +
> >> +     /* submit ADDRESS of LAST page to unlock */
> >> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
> >> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & this->pagemask);
> >> +
> >> +     /* call wait ready function */
> >> +     status = this->waitfunc(mtd, this);
> >> +     udelay(1000);
> >> +     /* see if device thinks it succeeded */
> >> +     if (status & 0x01) {
> >> +             /* there was an error */
> >> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", 
> >> status);
> >> +             ret = -EIO;
> >> +             goto out;
> >> +     }
> >> +
> >> + out:
> >> +     /* de-select the NAND device */
> >> +     this->select_chip(mtd, -1);
> >> +     return ret;
> >> +}
> >
> > Isn't the unlocking generic to the NAND device driver? Or is it somehow 
> > board
> > specific?
> 
> Yes, zoom2 boards come up with whole NAND locked, whereas it is not
> case for SDP boards.

But the procedure should be done under drivers/mtd I believe using some
standard tools.
 
> >
> >
> >> +static struct mtd_partition ldp_nand_partitions[] = {
> >> +     /* All the partition sizes are listed in terms of NAND block size */
> >> +     {
> >> +             .name           = "X-Loader-NAND",
> >> +             .offset         = 0,
> >> +             .size           = 4 * (64 * 2048),      /* 512KB, 0x8 */
> >> +             .mask_flags     = MTD_WRITEABLE,        /* force read-only */
> >> +     },
> >> +     {
> >> +             .name           = "U-Boot-NAND",
> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x8 
> >> */
> >> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 0x14 
> >> */
> >> +             .mask_flags     = MTD_WRITEABLE,        /* force read-only */
> >> +     },
> >> +     {
> >> +             .name           = "Boot Env-NAND",
> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x1c 
> >> */
> >> +             .size           = 2 * (64 * 2048),      /* 256KB, 0x4 */
> >> +     },
> >> +     {
> >> +             .name           = "Kernel-NAND",
> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> 0x020*/
> >> +             .size           = 240 * (64 * 2048),    /* 30M, 0x1E0 */
> >> +     },
> >> +#ifdef CONFIG_MACH_OMAP_ZOOM2
> >> +     {
> >> +             .name           = "system",
> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> 0x200 */
> >> +             .size           = 1280 * (64 * 2048),   /* 160M, 0xA00 */
> >> +     },
> >> +     {
> >> +             .name           = "userdata",
> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> 0xC00 */
> >> +             .size           = 256 * (64 * 2048),    /* 32M, 0x200 */
> >> +     },
> >> +     {
> >> +             .name           = "cache",
> >> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 
> >> 0xE00 */
> >> +             .size           = 256 * (64 * 2048),    /* 32M, 0x200 */
> >> +     },

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-18 Thread Vimal Singh
Tony,

On Fri, Nov 13, 2009 at 2:14 AM, Tony Lindgren  wrote:
> * Vimal Singh  [091110 02:08]:
>> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
>> From: Vimal Singh 
>> Date: Tue, 10 Nov 2009 11:42:45 +0530
>> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards

[...]

>> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t 
>> len)
>> +{
>> +     int ret = 0;
>> +     int chipnr;
>> +     int status;
>> +     unsigned long page;
>> +     struct nand_chip *this = mtd->priv;
>> +     printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
>> +                     (int)ofs, (int)len);
>> +
>> +     /* select the NAND device */
>> +     chipnr = (int)(ofs >> this->chip_shift);
>> +     this->select_chip(mtd, chipnr);
>> +     /* check the WP bit */
>> +     this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
>> +     if ((this->read_byte(mtd) & 0x80) == 0) {
>> +             printk(KERN_ERR "nand_unlock: Device is write protected!\n");
>> +             ret = -EINVAL;
>> +             goto out;
>> +     }
>> +
>> +     if ((ofs & (mtd->writesize - 1)) != 0) {
>> +             printk(KERN_ERR "nand_unlock: Start address must be"
>> +                             "beginning of nand page!\n");
>> +             ret = -EINVAL;
>> +             goto out;
>> +     }
>> +
>> +     if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
>> +             printk(KERN_ERR "nand_unlock: Length must be a multiple of "
>> +                             "nand page size!\n");
>> +             ret = -EINVAL;
>> +             goto out;
>> +     }
>> +
>> +     /* submit address of first page to unlock */
>> +     page = (unsigned long)(ofs >> this->page_shift);
>> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & this->pagemask);
>> +
>> +     /* submit ADDRESS of LAST page to unlock */
>> +     page += (unsigned long)((ofs + len) >> this->page_shift) ;
>> +     this->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & this->pagemask);
>> +
>> +     /* call wait ready function */
>> +     status = this->waitfunc(mtd, this);
>> +     udelay(1000);
>> +     /* see if device thinks it succeeded */
>> +     if (status & 0x01) {
>> +             /* there was an error */
>> +             printk(KERN_ERR "nand_unlock: error status =0x%08x ", status);
>> +             ret = -EIO;
>> +             goto out;
>> +     }
>> +
>> + out:
>> +     /* de-select the NAND device */
>> +     this->select_chip(mtd, -1);
>> +     return ret;
>> +}
>
> Isn't the unlocking generic to the NAND device driver? Or is it somehow board
> specific?

Yes, zoom2 boards come up with whole NAND locked, whereas it is not
case for SDP boards.

>
>
>> +static struct mtd_partition ldp_nand_partitions[] = {
>> +     /* All the partition sizes are listed in terms of NAND block size */
>> +     {
>> +             .name           = "X-Loader-NAND",
>> +             .offset         = 0,
>> +             .size           = 4 * (64 * 2048),      /* 512KB, 0x8 */
>> +             .mask_flags     = MTD_WRITEABLE,        /* force read-only */
>> +     },
>> +     {
>> +             .name           = "U-Boot-NAND",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x8 */
>> +             .size           = 10 * (64 * 2048),     /* 1.25MB, 0x14 */
>> +             .mask_flags     = MTD_WRITEABLE,        /* force read-only */
>> +     },
>> +     {
>> +             .name           = "Boot Env-NAND",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x1c */
>> +             .size           = 2 * (64 * 2048),      /* 256KB, 0x4 */
>> +     },
>> +     {
>> +             .name           = "Kernel-NAND",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x020*/
>> +             .size           = 240 * (64 * 2048),    /* 30M, 0x1E0 */
>> +     },
>> +#ifdef CONFIG_MACH_OMAP_ZOOM2
>> +     {
>> +             .name           = "system",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x200 
>> */
>> +             .size           = 1280 * (64 * 2048),   /* 160M, 0xA00 */
>> +     },
>> +     {
>> +             .name           = "userdata",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0xC00 
>> */
>> +             .size           = 256 * (64 * 2048),    /* 32M, 0x200 */
>> +     },
>> +     {
>> +             .name           = "cache",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0xE00 
>> */
>> +             .size           = 256 * (64 * 2048),    /* 32M, 0x200 */
>> +     },
>> +#else
>> +     {
>> +             .name           = "File System - NAND",
>> +             .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x200 
>> */
>> +             .size           = MTDPART_SIZ_FULL,     /* 96MB, 0x600 */
>> +     },
>> +#endif
>
> Please remove the ifdefs, you should be able to compile in all mach-omap2
> boards into the same kernel binary. You should set th

Re: [PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-12 Thread Tony Lindgren
* Vimal Singh  [091110 02:08]:
> From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
> From: Vimal Singh 
> Date: Tue, 10 Nov 2009 11:42:45 +0530
> Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards
> 
> Adding NAND support for ZOOM2 and LDP board. I have tested it for ZOOM2 
> boards,
> someone can verify it for LDP, hopefully it should not have any problem.
> 
> The size of the U-Boot environment partition was increased to 1.25MB.
> 
> Vikram: Changed ldp name to zoom.
>   Future boards will be called Zoom2/3/4 etc.
>   LDP is a Zoom1. Somhow the LDP name got stuck to that.
> 
> Signed-off-by: Vimal Singh 
> Signed-off-by: Vikram Pandita 
> ---
>  arch/arm/mach-omap2/Makefile |2 +
>  arch/arm/mach-omap2/board-ldp.c  |2 +
>  arch/arm/mach-omap2/board-zoom-flash.c   |  196 
> ++
>  arch/arm/mach-omap2/board-zoom2.c|2 +
>  arch/arm/plat-omap/include/plat/board-zoom.h |   36 +
>  arch/arm/plat-omap/include/plat/nand.h   |2 +
>  6 files changed, 240 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/board-zoom-flash.c
>  create mode 100644 arch/arm/plat-omap/include/plat/board-zoom.h
> 
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 627f500..b3a9d1c 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -59,6 +59,7 @@ obj-$(CONFIG_MACH_OMAP_APOLLON) += 
> board-apollon.o
>  obj-$(CONFIG_MACH_OMAP3_BEAGLE)  += board-omap3beagle.o \
>  mmc-twl4030.o
>  obj-$(CONFIG_MACH_OMAP_LDP)  += board-ldp.o \
> +board-zoom-flash.o \
>  mmc-twl4030.o
>  obj-$(CONFIG_MACH_OVERO) += board-overo.o \
>  mmc-twl4030.o
> @@ -74,6 +75,7 @@ obj-$(CONFIG_MACH_NOKIA_RX51)   += board-rx51.o 
> \
>  board-rx51-peripherals.o \
>  mmc-twl4030.o
>  obj-$(CONFIG_MACH_OMAP_ZOOM2)+= board-zoom2.o \
> +board-zoom-flash.o \
>  mmc-twl4030.o \
>  board-zoom-debugboard.o
>  obj-$(CONFIG_MACH_CM_T35)+= board-cm-t35.o \
> diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
> index c062238..8aebdf9 100644
> --- a/arch/arm/mach-omap2/board-ldp.c
> +++ b/arch/arm/mach-omap2/board-ldp.c
> @@ -42,6 +42,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include "mmc-twl4030.h"
> 
> @@ -385,6 +386,7 @@ static void __init omap_ldp_init(void)
>   ads7846_dev_init();
>   omap_serial_init();
>   usb_musb_init();
> + zoom_flash_init();
> 
>   twl4030_mmc_init(mmc);
>   /* link regulators to MMC adapters */
> diff --git a/arch/arm/mach-omap2/board-zoom-flash.c
> b/arch/arm/mach-omap2/board-zoom-flash.c
> new file mode 100644
> index 000..1406a57
> --- /dev/null
> +++ b/arch/arm/mach-omap2/board-zoom-flash.c
> @@ -0,0 +1,196 @@
> +/*
> + * arch/arm/mach-omap2/board-zoom-flash.c
> + *
> + * Copyright (C) 2008-09 Texas Instruments Inc.
> + *
> + * Modified from mach-omap2/board-2430sdp-flash.c
> + * Author(s): Rohit Choraria 
> + *Vimal Singh 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#define NAND_CMD_UNLOCK1 0x23
> +#define NAND_CMD_UNLOCK2 0x24
> +/**
> + * @brief platform specific unlock function
> + *
> + * @param mtd - mtd info
> + * @param ofs - offset to start unlock from
> + * @param len - length to unlock
> + *
> + * @return - unlock status
> + */
> +static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t 
> len)
> +{
> + int ret = 0;
> + int chipnr;
> + int status;
> + unsigned long page;
> + struct nand_chip *this = mtd->priv;
> + printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
> + (int)ofs, (int)len);
> +
> + /* select the NAND device */
> + chipnr = (int)(ofs >> this->chip_shift);
> + this->select_chip(mtd, chipnr);
> + /* check the WP bit */
> + this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
> + if ((this->read_byte(mtd) & 0x80) == 0) {
> + printk(KERN_ERR "nand_unlock: Device is write protected!\n");
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + if ((ofs & (mtd->writesize - 1)) != 0) {
> + printk(KERN_ERR "nand

[PATCH-v5 2/4] OMAP3: Add support for NAND on ZOOM2/LDP boards

2009-11-10 Thread Vimal Singh
>From 6f535d7128ca392458dd0cb31d138cda84747c06 Mon Sep 17 00:00:00 2001
From: Vimal Singh 
Date: Tue, 10 Nov 2009 11:42:45 +0530
Subject: [PATCH] OMAP3: Add support for NAND on ZOOM2/LDP boards

Adding NAND support for ZOOM2 and LDP board. I have tested it for ZOOM2 boards,
someone can verify it for LDP, hopefully it should not have any problem.

The size of the U-Boot environment partition was increased to 1.25MB.

Vikram: Changed ldp name to zoom.
  Future boards will be called Zoom2/3/4 etc.
  LDP is a Zoom1. Somhow the LDP name got stuck to that.

Signed-off-by: Vimal Singh 
Signed-off-by: Vikram Pandita 
---
 arch/arm/mach-omap2/Makefile |2 +
 arch/arm/mach-omap2/board-ldp.c  |2 +
 arch/arm/mach-omap2/board-zoom-flash.c   |  196 ++
 arch/arm/mach-omap2/board-zoom2.c|2 +
 arch/arm/plat-omap/include/plat/board-zoom.h |   36 +
 arch/arm/plat-omap/include/plat/nand.h   |2 +
 6 files changed, 240 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-zoom-flash.c
 create mode 100644 arch/arm/plat-omap/include/plat/board-zoom.h

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 627f500..b3a9d1c 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_MACH_OMAP_APOLLON)   += 
board-apollon.o
 obj-$(CONFIG_MACH_OMAP3_BEAGLE)+= board-omap3beagle.o \
   mmc-twl4030.o
 obj-$(CONFIG_MACH_OMAP_LDP)+= board-ldp.o \
+  board-zoom-flash.o \
   mmc-twl4030.o
 obj-$(CONFIG_MACH_OVERO)   += board-overo.o \
   mmc-twl4030.o
@@ -74,6 +75,7 @@ obj-$(CONFIG_MACH_NOKIA_RX51) += board-rx51.o \
   board-rx51-peripherals.o \
   mmc-twl4030.o
 obj-$(CONFIG_MACH_OMAP_ZOOM2)  += board-zoom2.o \
+  board-zoom-flash.o \
   mmc-twl4030.o \
   board-zoom-debugboard.o
 obj-$(CONFIG_MACH_CM_T35)  += board-cm-t35.o \
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index c062238..8aebdf9 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "mmc-twl4030.h"

@@ -385,6 +386,7 @@ static void __init omap_ldp_init(void)
ads7846_dev_init();
omap_serial_init();
usb_musb_init();
+   zoom_flash_init();

twl4030_mmc_init(mmc);
/* link regulators to MMC adapters */
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c
b/arch/arm/mach-omap2/board-zoom-flash.c
new file mode 100644
index 000..1406a57
--- /dev/null
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -0,0 +1,196 @@
+/*
+ * arch/arm/mach-omap2/board-zoom-flash.c
+ *
+ * Copyright (C) 2008-09 Texas Instruments Inc.
+ *
+ * Modified from mach-omap2/board-2430sdp-flash.c
+ * Author(s): Rohit Choraria 
+ *Vimal Singh 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define NAND_CMD_UNLOCK1   0x23
+#define NAND_CMD_UNLOCK2   0x24
+/**
+ * @brief platform specific unlock function
+ *
+ * @param mtd - mtd info
+ * @param ofs - offset to start unlock from
+ * @param len - length to unlock
+ *
+ * @return - unlock status
+ */
+static int omap_ldp_nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
+{
+   int ret = 0;
+   int chipnr;
+   int status;
+   unsigned long page;
+   struct nand_chip *this = mtd->priv;
+   printk(KERN_INFO "nand_unlock: start: %08x, length: %d!\n",
+   (int)ofs, (int)len);
+
+   /* select the NAND device */
+   chipnr = (int)(ofs >> this->chip_shift);
+   this->select_chip(mtd, chipnr);
+   /* check the WP bit */
+   this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
+   if ((this->read_byte(mtd) & 0x80) == 0) {
+   printk(KERN_ERR "nand_unlock: Device is write protected!\n");
+   ret = -EINVAL;
+   goto out;
+   }
+
+   if ((ofs & (mtd->writesize - 1)) != 0) {
+   printk(KERN_ERR "nand_unlock: Start address must be"
+   "beginning of nand page!\n");
+   ret = -EINVAL;
+   goto out;
+   }
+
+   if (len == 0 || (len & (mtd->writesize - 1)) != 0) {
+   printk(KER