Fix OneNAND build break
Subsystems (3)
PATCH 1/1 Fix OneNAND build break
Since page size field is changed from oobblock to writesize. But OneNAND is not updated.
- fix bufferram management at erase operation
This patch includes the NAND/OneNAND state filed too.
generated against latest git tree
Thank you,
Kyungmin Park
---
common/env_onenand.c +5 -5
@@ -40,7 +40,7 @@ extern struct onenand_chip onenand_chip;/* References to names in env_common.c */ extern uchar default_environment[]; -#define ONENAND_ENV_SIZE (mtd) (mtd.oobblock - ENV_HEADER_SIZE) +#define ONENAND_ENV_SIZE (mtd) (mtd.writesize - ENV_HEADER_SIZE)char *env_name_spec ="OneNAND" ;
@@ -68,12 +68,12 @@ void env_relocate_spec(void) env_addr =CFG_ENV_ADDR ;/* Check OneNAND exist */ -if (onenand_mtd.oobblock) +if (onenand_mtd.writesize)/* Ignore read fail */ -onenand_read (&onenand_mtd, env_addr, onenand_mtd.oobblock, +onenand_read (&onenand_mtd, env_addr, onenand_mtd.writesize, &retlen, (u_char *) env_ptr);else - onenand_mtd.oobblock =MAX_ONENAND_PAGESIZE ; + onenand_mtd.writesize =MAX_ONENAND_PAGESIZE ;if (crc32 (0 , env_ptr->data,ONENAND_ENV_SIZE (onenand_mtd)) != env_ptr->crc)
@@ -109,7 +109,7 @@ int saveenv(void) env_ptr->crc =crc32 (0 , env_ptr->data,ONENAND_ENV_SIZE (onenand_mtd)); -if (onenand_write (&onenand_mtd, env_addr, onenand_mtd.oobblock, &retlen, +if (onenand_write (&onenand_mtd, env_addr, onenand_mtd.writesize, &retlen, (u_char *) env_ptr)) {printf ("OneNAND: write failed at 0x%08x\n" , instr.addr);return 2 ;
drivers/mtd/onenand/onenand_base.c +94 -37
246 lines not on this page · raw message
drivers/mtd/onenand/onenand_bbt.c +2 -2
@@ -97,7 +97,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t * buf,/* No need to read pages fully, * just read required OOB bytes */ ret =onenand_read_oob (mtd, - from + j * mtd->oobblock + + from + j * mtd->writesize + bd->offs, readlen, &retlen, &buf[0 ]);
@@ -107,7 +107,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t * buf, }if (check_short_pattern - (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { + (&buf[j * scanlen], scanlen, mtd->writesize, bd)) { bbm->bbt[i >>3 ] |=0x03 << (i &0x6 ); printk(KERN_WARNING "Bad eraseblock %d@0x%08x\n", i >> 1,
include/linux/mtd/compat.h +5 -1
@@ -18,7 +18,11 @@#define KERN_DEBUG #define kmalloc (size, flags) malloc(size) -#define kzalloc (size, flags) calloc(size, 1) +#define kzalloc (size, flags) ({ \ + void *__ret = malloc(size); \ + memset(__ret, 0, size); \ + __ret; \ +})#define vmalloc (size) malloc(size)#define kfree (ptr) free(ptr)#define vfree (ptr) free(ptr)
include/linux/mtd/mtd.h +15 -0
@@ -22,6 +22,21 @@#define MTD_ERASE_DONE 0x08#define MTD_ERASE_FAILED 0x10 +/* +* Enumeration for NAND/OneNAND flash chip state +*/ +enum { +FL_READY , +FL_READING , +FL_WRITING , +FL_ERASING , +FL_SYNCING , +FL_CACHEDPRG , +FL_RESETING , +FL_UNLOCKING , +FL_LOCKING , +}; +/* If the erase fails, fail_addr might indicate exactly which block failed. If fail_addr = 0xffffffff, the failure was not at the device level or was not specific to any particular block. */
include/linux/mtd/nand.h +1 -15
@@ -213,20 +213,6 @@ typedef enum {#define NAND_CI_CHIPNR_MSK 0x03#define NAND_CI_CELLTYPE_MSK 0x0C -/* -* nand_state_t - chip states -* Enumeration for NAND flash chip state -*/ -typedef enum { -FL_READY , -FL_READING , -FL_WRITING , -FL_ERASING , -FL_SYNCING , -FL_CACHEDPRG , -FL_PM_SUSPENDED , -}nand_state_t ; -/* Keep gcc happy */ struct nand_chip ;
@@ -416,7 +402,7 @@ struct nand_chip {uint8_t cellinfo;int badblockpos; -nand_state_t state; +int state;uint8_t *oob_poi;struct nand_hw_control *controller;
include/linux/mtd/nand_legacy.h +0 -12
@@ -55,18 +55,6 @@#define NAND_CMD_RESET 0xff/* -* Enumeration for NAND flash chip state -*/ -typedef enum { -FL_READY , -FL_READING , -FL_WRITING , -FL_ERASING , -FL_SYNCING -}nand_state_t ; - - -/* * NAND Private Flash Chip Data * * Structure overview:
include/linux/mtd/onenand.h +4 -15
@@ -17,6 +17,7 @@/* Note: The header order is impoertant */ #include <onenand_uboot.h> +#include <linux/mtd/compat.h> #include <linux/mtd/bbm.h> #define MAX_BUFFERRAM 2
@@ -28,20 +29,6 @@ extern int onenand_scan (struct mtd_info *mtd, int max_chips);extern void onenand_release (struct mtd_info *mtd);/** -* onenand_state_t - chip states -* Enumeration for OneNAND flash chip state -*/ -typedef enum { -FL_READY , -FL_READING , -FL_WRITING , -FL_ERASING , -FL_SYNCING , -FL_UNLOCKING , -FL_LOCKING , -}onenand_state_t ; - -/** * struct onenand_bufferram - OneNAND BufferRAM Data * @param block block address in BufferRAM * @param page page address in BufferRAM
@@ -103,10 +90,12 @@ struct onenand_chip {unsigned short (*read_word) (void __iomem * addr);void (*write_word) (unsigned short value,void __iomem * addr);void (*mmcontrol) (struct mtd_info * mtd,int sync_read); +int (*block_markbad)(struct mtd_info *mtd,loff_t ofs); +int (*scan_bbt)(struct mtd_info *mtd);spinlock_t chip_lock;wait_queue_head_t wq; -onenand_state_t state; +int state;struct nand_oobinfo *autooob;
include/onenand_uboot.h +3 -8
@@ -15,18 +15,13 @@#define __UBOOT_ONENAND_H#include <linux/types.h> - -struct kvec { -void *iov_base; -size_t iov_len; -}; - -typedef int spinlock_t ; -typedef int wait_queue_head_t ; +#include <mtd_uboot.h> struct mtd_info ;struct erase_info ; +extern struct mtd_info onenand_mtd; +/* Functions */ extern void onenand_init (void ); extern int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
Scott Wood
AppliedPATCH 1/1 Fix OneNAND build break
Quoted 3 lines · Kyungmin Park
Since page size field is changed from oobblock to writesize. But OneNAND is not updated.
- fix bufferram management at erase operation
This patch includes the NAND/OneNAND state filed too.
Applied to nand-flash, with some changes:
drivers/mtd/onenand/onenand_base.c static int onenand_update_bufferram(struct mtd_info *mtd, loff_t addr, · line 499
Quoted 8 lines
drivers/mtd/onenand/onenand_base.c +8
-0+static void onenand_invalidate_bufferram (struct mtd_info *mtd,loff_t addr, +unsigned int len) +{ +struct onenand_chip *this = mtd->priv; +int i; +loff_t end_addr = addr + len; + +/* Invalidate BufferRAM */
Use tabs for indentation.
Quoted 17 lines
/**
+ *onenand_block_isbad_nolock- [GENERIC] Check if a block is marked bad
+ * @param mtd MTD device structure
+ * @param ofs offset from device start
+ * @param allowbbt 1, if its allowed to access the bbt area
+ *
+ * Check, if the block is bad, Either by reading the bad block table or
+ * calling of the scan function.
+ */drivers/mtd/onenand/onenand_base.c +8
-0+static int onenand_block_isbad_nolock (struct mtd_info *mtd,loff_t ofs,int allowbbt) +{ +struct onenand_chip *this = mtd->priv; +struct bbm_info *bbm = this->bbm; + +/* Return info from the table */ +return bbm->isbad_bbt (mtd, ofs, allowbbt); +}
[snip]
Quoted 20 lines
drivers/mtd/onenand/onenand_base.c +3
-10@@ -1005,30 +1050,45 @@ void onenand_sync(struct mtd_info *mtd)* onenand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad * @param mtd MTD device structure * @param ofs offset relative to mtd start +* +* Check whether the block is bad */ int onenand_block_isbad (struct mtd_info *mtd,loff_t ofs) { -/* -* TODO -* 1. Bad block table (BBT) -* -> using NAND BBT to support JFFS2 -* 2. Bad block management (BBM) -* -> bad block replace scheme -* -* Currently we do nothing -*/ -return 0 ; +int ret;
drivers/mtd/onenand/onenand_base.c void onenand_sync(struct mtd_info *mtd) · line 1068
Quoted 10 lines
drivers/mtd/onenand/onenand_base.c +9
-0+ +/* Check for invalid offset */ +if (ofs > mtd->size) +return -EINVAL ; + +onenand_get_device (mtd,FL_READING ); + ret =onenand_block_isbad_nolock (mtd,ofs,0 ); +onenand_release_device (mtd); +return ret; }
This wasn't mentioned in the changelog.
drivers/mtd/onenand/onenand_base.c static int onenand_probe(struct mtd_info *mtd) · line 1248
Quoted 10 lines
drivers/mtd/onenand/onenand_base.c +2
-4@@ -1184,10 +1244,8 @@ static int onenand_probe(struct mtd_info *mtd)/* Reset OneNAND to read default register values */ this->write_word (ONENAND_CMD_RESET , this->base +ONENAND_BOOTRAM ); - { -int i; -for (i =0 ; i <10000 ; i++) ; - } +/* Wait reset */ + this->wait (mtd,FL_RESETING );
Nor was this.
Quoted 5 lines
include/linux/mtd/compat.h +0
-0
include/linux/mtd/compat.h line 25
Quoted 9 lines
include/linux/mtd/compat.h +5
-1@@ -18,7 +18,11 @@#define KERN_DEBUG #define kmalloc (size, flags) malloc(size) -#define kzalloc (size, flags) calloc(size, 1) +#define kzalloc (size, flags) ({ \ + void *__ret = malloc(size); \ + memset(__ret, 0, size); \ + __ret; \ +})
What's the reason for this? It fails to handle malloc() failure, BTW. Not applied.
Quoted 12 lines
include/linux/mtd/mtd.h +4
-0@@ -22,6 +22,21 @@#define MTD_ERASE_DONE 0x08#define MTD_ERASE_FAILED 0x10 +/* +* Enumeration for NAND/OneNAND flash chip state +*/ +enum {
include/linux/mtd/mtd.h line 38
Quoted 10 lines
include/linux/mtd/mtd.h +10
-0+FL_READY , +FL_READING , +FL_WRITING , +FL_ERASING , +FL_SYNCING , +FL_CACHEDPRG , +FL_RESETING , +FL_UNLOCKING , + FL_LOCKING, +};
You left out FL_PM_SUSPENDED.
Quoted 7 lines
include/onenand_uboot.h +0
-0@@ -15,18 +15,13 @@#define __UBOOT_ONENAND_H
include/onenand_uboot.h line 18
Quoted 10 lines
include/onenand_uboot.h +1
-8#include <linux/types.h> - -struct kvec { -void *iov_base; -size_t iov_len; -}; - -typedef int spinlock_t ; -typedef int wait_queue_head_t ; +#include <mtd_uboot.h>
mtd_uboot.h does not exist. Not applied.
You also need to fix read_oob/write_oob for the new API.
-Scott
PATCH 1/1 Fix OneNAND build break
In reply to Kyungmin ParkDear Kyungmin Park,
Quoted 5 lines · In message <20080813001102.GA27788@july> you wrote:
Since page size field is changed from oobblock to writesize. But OneNAND is not updated.
- fix bufferram management at erase operation
This patch includes the NAND/OneNAND state filed too.generated against latest git tree
Hm... I have marked this patch as open, but it does not apply at all. Could you please check and rebase if necessary?
Thanks.
Best regards,
Wolfgang Denk
Signature · 14 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Save energy: Drive a smaller shell. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ U-Boot-Users mailing list U-Boot-Users at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
PATCH 1/1 Fix OneNAND build break
Quoted 11 lines · Wolfgang Denk
Dear Kyungmin Park,
Quoted 5 lines · In message <20080813001102.GA27788@july> you wrote:
Since page size field is changed from oobblock to writesize. But OneNAND is not updated.
- fix bufferram management at erase operation
This patch includes the NAND/OneNAND state filed too.generated against latest git tree
Hm... I have marked this patch as open, but it does not apply at all. Could you please check and rebase if necessary?
This was applied as d438d50848e9425286e5fb0493e0affb5a0b1e1b.
-Scott
PATCH 1/1 Fix OneNAND build break
Dear Scott Wood,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Hm... I have marked this patch as open, but it does not apply at all. Could you please check and rebase if necessary?
This was applied as
d438d50848e9425286e5fb0493e0affb5a0b1e1b.
I see. Thanks for the confirmation.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de (null cookie; hope that's ok)