mtd: nand: provision full ID support
cover mtd: nand: provision full ID support
From: Artem Bityutskiy <[email protected]>
Hi,
this is an RFC which adds full ID support provision which Huang can then use to solve his problem described here:
http://thread.gmane.org/gmane.linux.kernel/1428345/focus=45290
But before adding full ID support, I cleaned up things a little and removed AG-AND support as part of the clean-up.
Thanks,
Artem.
PATCH 1/12 mtd: nand_ids: minor clean-ups
From: Artem Bityutskiy <[email protected]>
Clean-up the code a little bit:
* clean-up commentaries.
* move macro definitions to the top of the file.
--- drivers/mtd/nand/nand_ids.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/mtd/nand/nand_ids.c +12 -14
@@ -10,17 +10,17 @@*/ #include <linux/module.h> #include <linux/mtd/nand.h> + +#define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS +#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16) +/* -* Chip ID list -* -* Name. ID code, pagesize, chipsize in MegaByte, eraseblock size, -* options -* -* Pagesize; 0, 256, 512 -* 0 get this information from the extended chip ID -+ 256 256 Byte page size -* 512 512 Byte page size -*/ +* The chip ID list: +* name, device ID, page size, chip size in MiB, eraseblock size, options +* +* If page size and eraseblock size is 0, the sizes are taken from the extended +* chip ID. +*/ struct nand_flash_dev nand_flash_ids[] = {#ifdef CONFIG_MTD_NAND_MUSEUM_IDS
@@ -67,11 +67,9 @@ struct nand_flash_dev nand_flash_ids[] = { {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0},/* -* These are the new chips with large page size. The pagesize and the -* erasesize is determined from the extended id bytes +* These are the new chips with large page size, page size and +* eraseblock size is determined from the extended id bytes. */ -#define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS -#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)/* 512 Megabit */ {"NAND 64MiB 1,8V 8-bit", 0xA2, 0, 64, 0, LP_OPTIONS},
Signature · 1 line
1.7.10.4
Re: [PATCH 01/12] mtd: nand_ids: minor clean-ups
Quoted 17 lines · Artem Bityutskiy
drivers/mtd/nand/nand_ids.c +4
-4@@ -10,17 +10,17 @@*/ #include <linux/module.h> #include <linux/mtd/nand.h> + +#define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS +#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16) +/* -* Chip ID list -* -* Name. ID code, pagesize, chipsize in MegaByte, eraseblock size, -* options
drivers/mtd/nand/nand_ids.c line 21
Quoted 10 lines
drivers/mtd/nand/nand_ids.c +4
-6-* -* Pagesize; 0, 256, 512 -* 0 get this information from the extended chip ID -+ 256 256 Byte page size -* 512 512 Byte page size -*/ +* The chip ID list: +* name, device ID, page size, chip size in MiB, eraseblock size, options +* +* If page size and eraseblock size is 0, the sizes are taken from the extended
Grammar correction: "is" should be "are".
drivers/mtd/nand/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { · line 71
Quoted 11 lines
drivers/mtd/nand/nand_ids.c +2
-2+* chip ID. +*/ struct nand_flash_dev nand_flash_ids[] = {#ifdef CONFIG_MTD_NAND_MUSEUM_IDS @@ -67,11 +67,9 @@ struct nand_flash_dev nand_flash_ids[] = { {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0},/* -* These are the new chips with large page size. The pagesize and the -* erasesize is determined from the extended id bytes
The original form has incorrect grammar; "is" should be "are".
drivers/mtd/nand/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { · line 71
Quoted 2 lines
drivers/mtd/nand/nand_ids.c +2
-0+* These are the new chips with large page size, page size and +* eraseblock size is determined from the extended id bytes.
This is also incorrect grammar. It uses a comma to divide sentences and also uses "is". I would write something like this:
"These are the new chips with large page size. Their page size and eraseblock size are determined from the extended ID bytes."
Quoted 9 lines
drivers/mtd/nand/nand_ids.c +0
-3*/ -#define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS -#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)/* 512 Megabit */ {"NAND 64MiB 1,8V 8-bit", 0xA2, 0, 64, 0, LP_OPTIONS}, --1.7.10.4
Brian
Re: [PATCH 01/12] mtd: nand_ids: minor clean-ups
Quoted 8 lines · Brian Norris
drivers/mtd/nand/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { · line 71
Quoted 2 lines
drivers/mtd/nand/nand_ids.c +2
-0+* These are the new chips with large page size, page size and +* eraseblock size is determined from the extended id bytes. This is also incorrect grammar. It uses a comma to divide sentences and also uses "is". I would write something like this:
"These are the new chips with large page size. Their page size and eraseblock size are determined from the extended ID bytes."
Thanks Brian, will fix.
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH 2/12 mtd: remove museum NAND ID's support
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
It is probably OK to remove support for really old NAND chips of 8MiB or smaller size. We had a separate configuration option for them:CONFIG_MTD_NAND_MUSEUM_IDS, which we remove along with this patch.
--- drivers/mtd/nand/Kconfig | 8 -------- drivers/mtd/nand/nand_ids.c | 19 ------------------- 2 files changed, 27 deletions(-)
drivers/mtd/nand/Kconfig +0 -8
@@ -41,14 +41,6 @@ config MTD_SM_COMMON tristate default n -config MTD_NAND_MUSEUM_IDS - bool "Enable chip ids for obsolete ancient NAND devices" - default n - help - Enable this option only when your board has first generation - NAND chips (page size 256 byte, erase size 4-8KiB). The IDs - of these chips were reused by later, larger chips. - config MTD_NAND_DENALI tristate "Support Denali NAND controller" help
drivers/mtd/nand/nand_ids.c +0 -19
@@ -22,25 +22,6 @@* chip ID. */ struct nand_flash_dev nand_flash_ids[] = { - -#ifdef CONFIG_MTD_NAND_MUSEUM_IDS - {"NAND 1MiB 5V 8-bit", 0x6e, 256, 1, 0x1000, 0}, - {"NAND 2MiB 5V 8-bit", 0x64, 256, 2, 0x1000, 0}, - {"NAND 4MiB 5V 8-bit", 0x6b, 512, 4, 0x2000, 0}, - {"NAND 1MiB 3,3V 8-bit", 0xe8, 256, 1, 0x1000, 0}, - {"NAND 1MiB 3,3V 8-bit", 0xec, 256, 1, 0x1000, 0}, - {"NAND 2MiB 3,3V 8-bit", 0xea, 256, 2, 0x1000, 0}, - {"NAND 4MiB 3,3V 8-bit", 0xd5, 512, 4, 0x2000, 0}, - {"NAND 4MiB 3,3V 8-bit", 0xe3, 512, 4, 0x2000, 0}, - {"NAND 4MiB 3,3V 8-bit", 0xe5, 512, 4, 0x2000, 0}, - {"NAND 8MiB 3,3V 8-bit", 0xd6, 512, 8, 0x2000, 0}, - - {"NAND 8MiB 1,8V 8-bit", 0x39, 512, 8, 0x2000, 0}, - {"NAND 8MiB 3,3V 8-bit", 0xe6, 512, 8, 0x2000, 0}, - {"NAND 8MiB 1,8V 16-bit", 0x49, 512, 8, 0x2000, NAND_BUSWIDTH_16}, - {"NAND 8MiB 3,3V 16-bit", 0x59, 512, 8, 0x2000, NAND_BUSWIDTH_16}, -#endif - {"NAND 16MiB 1,8V 8-bit" ,0x33 ,512 ,16 ,0x4000 ,0 }, {"NAND 16MiB 3,3V 8-bit" ,0x73 ,512 ,16 ,0x4000 ,0 }, {"NAND 16MiB 1,8V 16-bit" ,0x43 ,512 ,16 ,0x4000 ,NAND_BUSWIDTH_16 },
Signature · 1 line
1.7.10.4
Re: [PATCH 02/12] mtd: remove museum NAND ID's support
Quoted 7 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
It is probably OK to remove support for really old NAND chips of 8MiB or smaller size. We had a separate configuration option for them:
CONFIG_MTD_NAND_MUSEUM_IDS, which we remove along with this patch.Signed-off-by Artem Bityutskiy <[email protected]>
I have never seen any of these NAND. So FWIW:
Re[2]: [PATCH 02/12] mtd: remove museum NAND ID's support
In reply to Artem BityutskiyQuoted 7 lines · Artem Bityutskiy
Quoted 6 lines
From: Artem Bityutskiy <[email protected]>
It is probably OK to remove support for really old NAND chips of 8MiB or smaller size. We had a separate configuration option for them:
CONFIG_MTD_NAND_MUSEUM_IDS, which we remove along with this patch.
Quoted 5 lines
Quoted 1 line
Signed-off-by Artem Bityutskiy <[email protected]>I have never seen any of these NAND. So FWIW:
Acked-by Brian Norris <[email protected]>
My previous post on this topic did not go, so I will repeat:
These chips are used in DiskOnChip and removing identifiers will lead to malfunction of systems using DiskOnChip as extra memory.
---
PATCH 3/12 arm: defconfigs: lpc32xx_defconfig: remove museum NAND option
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
The MTD_NAND_MUSEUM_IDS configuration options was removed - update the lpc32xx_defconfig file.
--- arch/arm/configs/lpc32xx_defconfig | 1 - 1 file changed, 1 deletion(-)
arch/arm/configs/lpc32xx_defconfig +0 -1
@@ -55,7 +55,6 @@ CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_M25P80=y CONFIG_MTD_NAND=y -CONFIG_MTD_NAND_MUSEUM_IDS=y CONFIG_MTD_NAND_SLC_LPC32XX=y CONFIG_MTD_NAND_MLC_LPC32XX=y CONFIG_BLK_DEV_LOOP=y
Signature · 1 line
1.7.10.4
PATCH 4/12 mtd: nand: remove the rtc_from4 driver support
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
The AG-AND support is about to be removed from MTD, because this technology is dead for long time. Thus, remove this the only AG-AND driver we have in the kernel tree.
--- drivers/mtd/nand/Kconfig | 10 - drivers/mtd/nand/rtc_from4.c | 624 ------------------------------------------ 2 files changed, 634 deletions(-) delete mode 100644 drivers/mtd/nand/rtc_from4.c
drivers/mtd/nand/Kconfig +0 -10
@@ -193,16 +193,6 @@ config MTD_NAND_BF5XX_BOOTROM_ECC If unsure, say N. -config MTD_NAND_RTC_FROM4 - tristate "Renesas Flash ROM 4-slot interface board (FROM_BOARD4)" - depends on SH_SOLUTION_ENGINE - select REED_SOLOMON - select REED_SOLOMON_DEC8 - select BITREVERSE - help - This enables the driver for the Renesas Technology AG-AND - flash interface board (FROM_BOARD4) - config MTD_NAND_PPCHAMELEONEVB tristate "NAND Flash device on PPChameleonEVB board" depends on PPCHAMELEONEVB && BROKEN
drivers/mtd/nand/rtc_from4.c deleted +0 -624
624 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 5/12 mtd: nand: remove AG-AND support
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
We have only one AG-AND driver and it was not touched since 2005. It looks like AG-AND was not really make it to mass-production and can be considered a dead technology.
--- drivers/mtd/nand/nand_base.c | 78 ++---------------------------------------- drivers/mtd/nand/nand_bbt.c | 25 -------------- drivers/mtd/nand/nand_ids.c | 13 ------- include/linux/mtd/nand.h | 16 --------- 4 files changed, 2 insertions(+), 130 deletions(-)
drivers/mtd/nand/nand_base.c +2 -76
@@ -4,7 +4,6 @@* Overview: * This is the generic MTD driver for NAND flash devices. It should be * capable of working with almost all NAND chips currently available. -* Basic support for AG-AND chips is provided. * * Additional technical information is available on * http://www.linux-mtd.infradead.org/doc/nand.html
@@ -22,7 +21,6 @@* Enable cached programming for 2k page size chips * Check, if mtd->ecctype should be set to MTD_ECC_HW * if we have HW ECC support. -* The AG-AND chips have nice features for speed improvement, * which are not supported yet. Read / program 4 pages in one go. * BBT table is not serialized, has to be fixed *
@@ -836,9 +834,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)*/ ndelay (100 ); -if ((state ==FL_ERASING ) && (chip->options &NAND_IS_AND )) - chip->cmdfunc (mtd,NAND_CMD_STATUS_MULTI ,-1 ,-1 ); -else +if (state ==FL_ERASING ) chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 );if (in_interrupt () || oops_in_progress)
@@ -2465,24 +2461,6 @@ static void single_erase_cmd(struct mtd_info *mtd, int page) }/** -* multi_erase_cmd - [GENERIC] AND specific block erase command function -* @mtd: MTD device structure -* @page: the page address of the block which will be erased -* -* AND multi block erase command function. Erase 4 consecutive blocks. -*/ -static void multi_erase_cmd (struct mtd_info *mtd,int page) -{ -struct nand_chip *chip = mtd->priv; -/* Send commands to erase a block */ - chip->cmdfunc (mtd,NAND_CMD_ERASE1 ,-1 , page++); - chip->cmdfunc (mtd,NAND_CMD_ERASE1 ,-1 , page++); - chip->cmdfunc (mtd,NAND_CMD_ERASE1 ,-1 , page++); - chip->cmdfunc (mtd,NAND_CMD_ERASE1 ,-1 , page); - chip->cmdfunc (mtd,NAND_CMD_ERASE2 ,-1 ,-1 ); -} - -/** * nand_erase - [MTD Interface] erase block(s) * @mtd: MTD device structure * @instr: erase instruction
@@ -2494,7 +2472,6 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)return nand_erase_nand (mtd, instr,0 ); } -#define BBT_PAGE_MASK 0xffffff3f/** * nand_erase_nand - [INTERN] erase block(s) * @mtd: MTD device structure
@@ -2508,8 +2485,6 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, {int page, status, pages_per_block, ret, chipnr;struct nand_chip *chip = mtd->priv; -loff_t rewrite_bbt[NAND_MAX_CHIPS ] = {0 }; -unsigned int bbt_masked_page =0xffffffff ;loff_t len; pr_debug("%s: start = 0x%012llx, len = %llu\n",
@@ -2540,15 +2515,6 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, goto erase_exit; } -/* -* If BBT requires refresh, set the BBT page mask to see if the BBT -* should be rewritten. Otherwise the mask is set to 0xffffffff which -* can not be matched. This is also done when the bbt is actually -* erased to avoid recursive updates. -*/ -if (chip->options &BBT_AUTO_REFRESH && !allowbbt) - bbt_masked_page = chip->bbt_td->pages[chipnr] &BBT_PAGE_MASK ; -/* Loop through the pages */ len = instr->len;
@@ -2594,15 +2560,6 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, goto erase_exit; } -/* -* If BBT requires refresh, set the BBT rewrite flag to the -* page being erased. -*/ -if (bbt_masked_page !=0xffffffff && - (page &BBT_PAGE_MASK ) == bbt_masked_page) - rewrite_bbt[chipnr] = - ((loff_t )page << chip->page_shift); -/* Increment page address and decrement length */ len -= (1 << chip->phys_erase_shift); page += pages_per_block;
@@ -2612,15 +2569,6 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, chipnr++; chip->select_chip (mtd,-1 ); chip->select_chip (mtd, chipnr); - -/* -* If BBT requires refresh and BBT-PERCHIP, set the BBT -* page mask to see if this BBT should be rewritten. -*/ -if (bbt_masked_page !=0xffffffff && - (chip->bbt_td->options &NAND_BBT_PERCHIP )) - bbt_masked_page = chip->bbt_td->pages[chipnr] & -BBT_PAGE_MASK ; } } instr->state =MTD_ERASE_DONE ;
@@ -2637,23 +2585,6 @@ erase_exit:if (!ret)mtd_erase_callback (instr); -/* -* If BBT requires refresh and erase was successful, rewrite any -* selected bad block tables. -*/ -if (bbt_masked_page ==0xffffffff || ret) -return ret; - -for (chipnr =0 ; chipnr < chip->numchips; chipnr++) { -if (!rewrite_bbt[chipnr]) -continue ; -/* Update the BBT for chip */ -pr_debug ("%s: nand_update_bbt (%d:0x%0llx 0x%0x)\n" , - __func__, chipnr, rewrite_bbt[chipnr], - chip->bbt_td->pages[chipnr]); -nand_update_bbt (mtd, rewrite_bbt[chipnr]); - } -/* Return more or less happy */ return ret; }
@@ -3286,12 +3217,7 @@ ident_done: } chip->badblockbits =8 ; - -/* Check for AND chips with 4 page planes */ -if (chip->options &NAND_4PAGE_ARRAY ) - chip->erase_cmd = multi_erase_cmd; -else - chip->erase_cmd = single_erase_cmd; + chip->erase_cmd = single_erase_cmd;/* Do not replace user supplied command function! */ if (mtd->writesize >512 && chip->cmdfunc == nand_command)
drivers/mtd/nand/nand_bbt.c +0 -25
@@ -1240,15 +1240,6 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)*/ static uint8_t scan_ff_pattern[] = {0xff ,0xff }; -static uint8_t scan_agand_pattern[] = {0x1C ,0x71 ,0xC7 ,0x1C ,0x71 ,0xC7 }; - -static struct nand_bbt_descr agand_flashbased = { - .options =NAND_BBT_SCANEMPTY |NAND_BBT_SCANALLPAGES , - .offs =0x20 , - .len =6 , - .pattern = scan_agand_pattern -}; -/* Generic flash bbt descriptors */ static uint8_t bbt_pattern[] = {'B' ,'b' ,'t' ,'0' };static uint8_t mirror_pattern[] = {'1' ,'t' ,'b' ,'B' };
@@ -1333,22 +1324,6 @@ int nand_default_bbt(struct mtd_info *mtd) {struct nand_chip *this = mtd->priv; -/* -* Default for AG-AND. We must use a flash based bad block table as the -* devices have factory marked _good_ blocks. Erasing those blocks -* leads to loss of the good / bad information, so we _must_ store this -* information in a good / bad table during startup. -*/ -if (this->options &NAND_IS_AND ) { -/* Use the default pattern descriptors */ -if (!this->bbt_td) { - this->bbt_td = &bbt_main_descr; - this->bbt_md = &bbt_mirror_descr; - } - this->bbt_options |=NAND_BBT_USE_FLASH ; -return nand_scan_bbt (mtd, &agand_flashbased); - } -/* Is a flash based bad block table requested? */ if (this->bbt_options &NAND_BBT_USE_FLASH ) {/* Use the default pattern descriptors */
drivers/mtd/nand/nand_ids.c +0 -13
@@ -125,19 +125,6 @@ struct nand_flash_dev nand_flash_ids[] = { {"NAND 64GiB 1,8V 16-bit", 0x2E, 0, 65536, 0, LP_OPTIONS16}, {"NAND 64GiB 3,3V 16-bit", 0x4E, 0, 65536, 0, LP_OPTIONS16}, -/* -* Renesas AND 1 Gigabit. Those chips do not support extended id and -* have a strange page/block layout ! The chosen minimum erasesize is -* 4 * 2 * 2048 = 16384 Byte, as those chips have an array of 4 page -* planes 1 block = 2 pages, but due to plane arrangement the blocks -* 0-3 consists of page 0 + 4,1 + 5, 2 + 6, 3 + 7 Anyway JFFS2 would -* increase the eraseblock size so we chose a combined one which can be -* erased in one go There are more speed improvements for reads and -* writes possible, but not implemented now -*/ - {"AND 128MiB 3,3V 8-bit", 0x01, 2048, 128, 0x4000, - NAND_IS_AND | NAND_4PAGE_ARRAY | BBT_AUTO_REFRESH}, - {NULL,} };
include/linux/mtd/nand.h +0 -16
@@ -171,22 +171,6 @@ typedef enum {#define NAND_CACHEPRG 0x00000008/* Chip has copy back function */ #define NAND_COPYBACK 0x00000010 -/* -* AND Chip which has 4 banks and a confusing page / block -* assignment. See Renesas datasheet for further information. -*/ -#define NAND_IS_AND 0x00000020 -/* -* Chip has a array of 4 pages which can be read without -* additional ready /busy waits. -*/ -#define NAND_4PAGE_ARRAY 0x00000040 -/* -* Chip requires that BBT is periodically rewritten to prevent -* bits from adjacent blocks from 'leaking' in altering data. -* This happens with the Renesas AG-AND chips, possibly others. -*/ -#define BBT_AUTO_REFRESH 0x00000080/* Chip does not allow subpage writes */ #define NAND_NO_SUBPAGE_WRITE 0x00000200
Signature · 1 line
1.7.10.4
Re: [PATCH 05/12] mtd: nand: remove AG-AND support
Quoted 5 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
We have only one AG-AND driver and it was not touched since 2005. It looks like AG-AND was not really make it to mass-production and can be considered a dead technology.
You might want to include in your commit message that BBT_AUTO_REFRESH was only needed for AG-AND. You drop it here (which is perfectly reasonable) but it is technically provided as a generic feature which *could* be used outside of AG-AND.
Quoted 12 lines
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/nand_base.c | 78 ++---------------------------------------- drivers/mtd/nand/nand_bbt.c | 25 -------------- drivers/mtd/nand/nand_ids.c | 13 ------- include/linux/mtd/nand.h | 16 --------- 4 files changed, 2 insertions(+), 130 deletions(-)drivers/mtd/nand/nand_base.c +0
-0
...
drivers/mtd/nand/nand_base.c line 26
Quoted 8 lines
drivers/mtd/nand/nand_base.c +0
-1@@ -22,7 +21,6 @@* Enable cached programming for 2k page size chips * Check, if mtd->ecctype should be set to MTD_ECC_HW * if we have HW ECC support. -* The AG-AND chips have nice features for speed improvement, * which are not supported yet. Read / program 4 pages in one go. * BBT table is not serialized, has to be fixed *
You cut this off mid-sentence. Did you mean to cut three lines here, instead of just one?
drivers/mtd/nand/nand_base.c static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) · line 838
Quoted 9 lines
drivers/mtd/nand/nand_base.c +1
-3@@ -836,9 +834,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)*/ ndelay (100 ); -if ((state ==FL_ERASING ) && (chip->options &NAND_IS_AND )) - chip->cmdfunc (mtd,NAND_CMD_STATUS_MULTI ,-1 ,-1 ); -else +if (state ==FL_ERASING ) chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 );
This is not a precise refactor. All non-AND flash would previously have run the STATUS command, but now you make it only run when FL_ERASING. Shouldn't it just be an unconditional cmdfunc(STATUS)?
drivers/mtd/nand/nand_base.c static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) · line 840
Quoted 1 line
drivers/mtd/nand/nand_base.c +0
-0if (in_interrupt () || oops_in_progress)
...
The rest looks OK to me.
Brian
Re: [PATCH 05/12] mtd: nand: remove AG-AND support
Quoted 11 lines · Brian Norris
Quoted 5 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
We have only one AG-AND driver and it was not touched since 2005. It looks like AG-AND was not really make it to mass-production and can be considered a dead technology.
You might want to include in your commit message that
BBT_AUTO_REFRESHwas only needed for AG-AND. You drop it here (which is perfectly reasonable) but it is technically provided as a generic feature which *could* be used outside of AG-AND.
OK, will do, thanks!
Quoted 11 lines
drivers/mtd/nand/nand_base.c line 26
Quoted 8 lines
drivers/mtd/nand/nand_base.c +0
-1@@ -22,7 +21,6 @@* Enable cached programming for 2k page size chips * Check, if mtd->ecctype should be set to MTD_ECC_HW * if we have HW ECC support. -* The AG-AND chips have nice features for speed improvement, * which are not supported yet. Read / program 4 pages in one go. * BBT table is not serialized, has to be fixed * You cut this off mid-sentence. Did you mean to cut three lines here, instead of just one?
Oops.
Quoted 9 lines
drivers/mtd/nand/nand_base.c static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) · line 838
Quoted 5 lines
drivers/mtd/nand/nand_base.c +1
-3-if ((state ==FL_ERASING ) && (chip->options &NAND_IS_AND )) - chip->cmdfunc (mtd,NAND_CMD_STATUS_MULTI ,-1 ,-1 ); -else +if (state ==FL_ERASING ) chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 );This is not a precise refactor. All non-AND flash would previously have run the STATUS command, but now you make it only run when
FL_ERASING. Shouldn't it just be an unconditional cmdfunc(STATUS)?
OOPS!
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH 6/12 mtd: nand: remove a bunch of unused commands
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
--- drivers/mtd/nand/cafe_nand.c | 6 ------ drivers/mtd/nand/nand_base.c | 10 ---------- drivers/mtd/nand/nandsim.c | 8 -------- drivers/mtd/nand/nuc900_nand.c | 9 --------- include/linux/mtd/nand.h | 20 -------------------- 5 files changed, 53 deletions(-)
drivers/mtd/nand/cafe_nand.c +0 -6
@@ -303,13 +303,7 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,case NAND_CMD_SEQIN :case NAND_CMD_RNDIN :case NAND_CMD_STATUS : -case NAND_CMD_DEPLETE1 :case NAND_CMD_RNDOUT : -case NAND_CMD_STATUS_ERROR : -case NAND_CMD_STATUS_ERROR0 : -case NAND_CMD_STATUS_ERROR1 : -case NAND_CMD_STATUS_ERROR2 : -case NAND_CMD_STATUS_ERROR3 :cafe_writel (cafe, cafe->ctl2,NAND_CTRL2 );return ; }
drivers/mtd/nand/nand_base.c +0 -10
@@ -669,16 +669,6 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,case NAND_CMD_SEQIN :case NAND_CMD_RNDIN :case NAND_CMD_STATUS : -case NAND_CMD_DEPLETE1 : -return ; - -case NAND_CMD_STATUS_ERROR : -case NAND_CMD_STATUS_ERROR0 : -case NAND_CMD_STATUS_ERROR1 : -case NAND_CMD_STATUS_ERROR2 : -case NAND_CMD_STATUS_ERROR3 : -/* Read error status commands require only a short delay */ -udelay (chip->chip_delay);return ;case NAND_CMD_RESET :
drivers/mtd/nand/nandsim.c +0 -8
@@ -218,7 +218,6 @@ MODULE_PARM_DESC(bch, "Enable BCH ecc and set how many bits should "#define STATE_CMD_READOOB 0x00000005/* read OOB area */ #define STATE_CMD_ERASE1 0x00000006/* sector erase first command */ #define STATE_CMD_STATUS 0x00000007/* read status */ -#define STATE_CMD_STATUS_M 0x00000008/* read multi-plane status (isn't implemented) */ #define STATE_CMD_SEQIN 0x00000009/* sequential data input */ #define STATE_CMD_READID 0x0000000A/* read ID */ #define STATE_CMD_ERASE2 0x0000000B/* sector erase second command */
@@ -406,8 +405,6 @@ static struct nandsim_operations { {OPT_ANY, {STATE_CMD_ERASE1, STATE_ADDR_SEC, STATE_CMD_ERASE2 | ACTION_SECERASE, STATE_READY}},/* Read status */ {OPT_ANY, {STATE_CMD_STATUS, STATE_DATAOUT_STATUS, STATE_READY}}, -/* Read multi-plane status */ - {OPT_SMARTMEDIA, {STATE_CMD_STATUS_M, STATE_DATAOUT_STATUS_M, STATE_READY}},/* Read ID */ {OPT_ANY, {STATE_CMD_READID, STATE_ADDR_ZERO, STATE_DATAOUT_ID, STATE_READY}},/* Large page devices read page */
@@ -1079,8 +1076,6 @@ static char *get_state_name(uint32_t state)return "STATE_CMD_ERASE1" ;case STATE_CMD_STATUS :return "STATE_CMD_STATUS" ; -case STATE_CMD_STATUS_M : -return "STATE_CMD_STATUS_M" ;case STATE_CMD_SEQIN :return "STATE_CMD_SEQIN" ;case STATE_CMD_READID :
@@ -1145,7 +1140,6 @@ static int check_command(int cmd)case NAND_CMD_RNDOUTSTART :return 0 ; -case NAND_CMD_STATUS_MULTI :default :return 1 ; }
@@ -1171,8 +1165,6 @@ static uint32_t get_state_by_command(unsigned command)return STATE_CMD_ERASE1 ;case NAND_CMD_STATUS :return STATE_CMD_STATUS ; -case NAND_CMD_STATUS_MULTI : -return STATE_CMD_STATUS_M ;case NAND_CMD_SEQIN :return STATE_CMD_SEQIN ;case NAND_CMD_READID :
drivers/mtd/nand/nuc900_nand.c +0 -9
@@ -177,15 +177,6 @@ static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command,case NAND_CMD_SEQIN :case NAND_CMD_RNDIN :case NAND_CMD_STATUS : -case NAND_CMD_DEPLETE1 : -return ; - -case NAND_CMD_STATUS_ERROR : -case NAND_CMD_STATUS_ERROR0 : -case NAND_CMD_STATUS_ERROR1 : -case NAND_CMD_STATUS_ERROR2 : -case NAND_CMD_STATUS_ERROR3 : -udelay (chip->chip_delay);return ;case NAND_CMD_RESET :
include/linux/mtd/nand.h +0 -20
@@ -86,7 +86,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);#define NAND_CMD_READOOB 0x50#define NAND_CMD_ERASE1 0x60#define NAND_CMD_STATUS 0x70 -#define NAND_CMD_STATUS_MULTI 0x71#define NAND_CMD_SEQIN 0x80#define NAND_CMD_RNDIN 0x85#define NAND_CMD_READID 0x90
@@ -105,25 +104,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);#define NAND_CMD_RNDOUTSTART 0xE0#define NAND_CMD_CACHEDPROG 0x15 -/* Extended commands for AG-AND device */ -/* -* Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but -* there is no way to distinguish that from NAND_CMD_READ0 -* until the remaining sequence of commands has been completed -* so add a high order bit and mask it off in the command. -*/ -#define NAND_CMD_DEPLETE1 0x100 -#define NAND_CMD_DEPLETE2 0x38 -#define NAND_CMD_STATUS_MULTI 0x71 -#define NAND_CMD_STATUS_ERROR 0x72 -/* multi-bank error status (banks 0-3) */ -#define NAND_CMD_STATUS_ERROR0 0x73 -#define NAND_CMD_STATUS_ERROR1 0x74 -#define NAND_CMD_STATUS_ERROR2 0x75 -#define NAND_CMD_STATUS_ERROR3 0x76 -#define NAND_CMD_STATUS_RESET 0x7f -#define NAND_CMD_STATUS_CLEAR 0xff -#define NAND_CMD_NONE -1/* Status bits */
Signature · 1 line
1.7.10.4
Re: [PATCH 06/12] mtd: nand: remove a bunch of unused commands
+ Alexander
Quoted 11 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/cafe_nand.c | 6 ------ drivers/mtd/nand/nand_base.c | 10 ---------- drivers/mtd/nand/nandsim.c | 8 -------- drivers/mtd/nand/nuc900_nand.c | 9 --------- include/linux/mtd/nand.h | 20 -------------------- 5 files changed, 53 deletions(-)
... trimmed ...
Quoted 14 lines
include/linux/mtd/nand.h +0
-1@@ -86,7 +86,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);#define NAND_CMD_READOOB 0x50#define NAND_CMD_ERASE1 0x60#define NAND_CMD_STATUS 0x70 -#define NAND_CMD_STATUS_MULTI 0x71#define NAND_CMD_SEQIN 0x80#define NAND_CMD_RNDIN 0x85#define NAND_CMD_READID 0x90@@ -105,25 +104,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);#define NAND_CMD_RNDOUTSTART 0xE0
include/linux/mtd/nand.h extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); · line 115
Quoted 10 lines
include/linux/mtd/nand.h +0
-8#define NAND_CMD_CACHEDPROG 0x15 -/* Extended commands for AG-AND device */ -/* -* Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but -* there is no way to distinguish that from NAND_CMD_READ0 -* until the remaining sequence of commands has been completed -* so add a high order bit and mask it off in the command. -*/ -#define NAND_CMD_DEPLETE1 0x100
Perhaps this is the reason for the "unnecessary command masking" noted by Alexander? There is one instance of a command function which masks command & 0xff. Maybe Alexander's patch can be updated to mention this likely cause for the original masking and can be applied on top of Artem's cleanup series? Anyway, the mask was likely not used anyway, since (as Artem mentions in this patch series) AG-AND had very little general use (or none?).
Quoted 4 lines
include/linux/mtd/nand.h +0
-4-#define NAND_CMD_DEPLETE2 0x38 -#define NAND_CMD_STATUS_MULTI 0x71 -#define NAND_CMD_STATUS_ERROR 0x72 -/* multi-bank error status (banks 0-3) */
include/linux/mtd/nand.h extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); · line 109
Quoted 10 lines
include/linux/mtd/nand.h +0
-7-#define NAND_CMD_STATUS_ERROR0 0x73 -#define NAND_CMD_STATUS_ERROR1 0x74 -#define NAND_CMD_STATUS_ERROR2 0x75 -#define NAND_CMD_STATUS_ERROR3 0x76 -#define NAND_CMD_STATUS_RESET 0x7f -#define NAND_CMD_STATUS_CLEAR 0xff -#define NAND_CMD_NONE -1/* Status bits */
Brian
Re[2]: [PATCH 06/12] mtd: nand: remove a bunch of unused commands
In reply to Artem BityutskiyQuoted 14 lines · Artem Bityutskiy
Quoted 11 lines
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/cafe_nand.c | 6 ------ drivers/mtd/nand/nand_base.c | 10 ---------- drivers/mtd/nand/nandsim.c | 8 -------- drivers/mtd/nand/nuc900_nand.c | 9 --------- include/linux/mtd/nand.h | 20 -------------------- 5 files changed, 53 deletions(-)... trimmed ...
...
Quoted 7 lines
Quoted 6 lines
- * Note: the command for
NAND_CMD_DEPLETE1is really0x00but- * there is no way to distinguish that from NAND_CMD_READ0 - * until the remaining sequence of commands has been completed - * so add a high order bit and mask it off in the command.- */
-#defineNAND_CMD_DEPLETE10x100
Quoted 7 lines
Perhaps this is the reason for the "unnecessary command masking" noted by Alexander? There is one instance of a command function which masks command &
0xff. Maybe Alexander's patch can be updated to mention this likely cause for the original masking and can be applied on top of Artem's cleanup series? Anyway, the mask was likely not used anyway, since (as Artem mentions in this patch series) AG-AND had very little general use (or none?).
My patch is cleanup only. I think that the mask was originally included to limit the byte boundaries. However, this is not necessary because callback functions "cmd_ctrl" use writeb/iowrite8 for send command, ie do not allow the use of the wrong size. Address also passed to "cmd_ctrl" via "cmd" parameter, which is not masked but only shifted, i.e. we have a values above 0xff, so that is not a problem.
---
Re: Re[2]: [PATCH 06/12] mtd: nand: remove a bunch of unused commands
Quoted 30 lines · Alexander Shiyan
Quoted 14 lines · Artem Bityutskiy
Quoted 11 lines
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/cafe_nand.c | 6 ------ drivers/mtd/nand/nand_base.c | 10 ---------- drivers/mtd/nand/nandsim.c | 8 -------- drivers/mtd/nand/nuc900_nand.c | 9 --------- include/linux/mtd/nand.h | 20 -------------------- 5 files changed, 53 deletions(-)... trimmed ...
...
Quoted 7 lines
Quoted 6 lines
- * Note: the command for
NAND_CMD_DEPLETE1is really0x00but- * there is no way to distinguish that from NAND_CMD_READ0 - * until the remaining sequence of commands has been completed - * so add a high order bit and mask it off in the command.- */
-#defineNAND_CMD_DEPLETE10x100Quoted 7 lines
Perhaps this is the reason for the "unnecessary command masking" noted by Alexander? There is one instance of a command function which masks command &
0xff. Maybe Alexander's patch can be updated to mention this likely cause for the original masking and can be applied on top of Artem's cleanup series? Anyway, the mask was likely not used anyway, since (as Artem mentions in this patch series) AG-AND had very little general use (or none?).
Quoted 6 lines
My patch is cleanup only. I think that the mask was originally included to limit the byte boundaries. However, this is not necessary because callback functions "
cmd_ctrl" use writeb/iowrite8 for send command, ie do not allow the use of the wrong size. Address also passed to "cmd_ctrl" via "cmd" parameter, which is not masked but only shifted, i.e. we have a values above0xff, so that is not a problem.
To be clear, I'm referring to your patch:
[PATCH 1/3] mtd: nand_base: Removed unnecessary command masking
The function that you are editing (nand_command_lp) can be used for AG-AND devices. The driver (rtc_from4.c - slated for removal in this series) can send NAND_CMD_DEPLETE1, which according to the comments in nand.h that I highlight above, should be "mask[ed] ... off in the command". So without Artem's change, your patch is actually breaking rtc_from4.c. Unforunately, no one bothered to actually document this within nand_command_lp, but such is life.
Brian
Re[4]: [PATCH 06/12] mtd: nand: remove a bunch of unused commands
Quoted 38 lines · Alexander Shiyan
Quoted 30 lines
Quoted 14 lines · Artem Bityutskiy
Quoted 11 lines
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/cafe_nand.c | 6 ------ drivers/mtd/nand/nand_base.c | 10 ---------- drivers/mtd/nand/nandsim.c | 8 -------- drivers/mtd/nand/nuc900_nand.c | 9 --------- include/linux/mtd/nand.h | 20 -------------------- 5 files changed, 53 deletions(-)... trimmed ...
...
Quoted 7 lines
Quoted 6 lines
- * Note: the command for
NAND_CMD_DEPLETE1is really0x00but- * there is no way to distinguish that from NAND_CMD_READ0 - * until the remaining sequence of commands has been completed - * so add a high order bit and mask it off in the command.- */
-#defineNAND_CMD_DEPLETE10x100Quoted 7 lines
Perhaps this is the reason for the "unnecessary command masking" noted by Alexander? There is one instance of a command function which masks command &
0xff. Maybe Alexander's patch can be updated to mention this likely cause for the original masking and can be applied on top of Artem's cleanup series? Anyway, the mask was likely not used anyway, since (as Artem mentions in this patch series) AG-AND had very little general use (or none?).Quoted 6 lines
My patch is cleanup only. I think that the mask was originally included to limit the byte boundaries. However, this is not necessary because callback functions "
cmd_ctrl" use writeb/iowrite8 for send command, ie do not allow the use of the wrong size. Address also passed to "cmd_ctrl" via "cmd" parameter, which is not masked but only shifted, i.e. we have a values above0xff, so that is not a problem.
Quoted 5 lines
To be clear, I'm referring to your patch:
[PATCH 1/3] mtd:
nand_base: Removed unnecessary command maskingThe function that you are editing (
nand_command_lp) can be used for
OK, for Samsung chips too.
Quoted 4 lines
AG-AND devices. The driver (
rtc_from4.c- slated for removal in this series) can sendNAND_CMD_DEPLETE1, which according to the comments innand.hthat I highlight above, should be "mask[ed] ... off in the command". So without Artem's change, your patch is actually breaking
Where it breaks? "rtc_from4_hwcontrol" use writeb() for "cmd" parameter, so its not breaks. Is I think incorrect?
Quoted 2 lines
rtc_from4.c. Unforunately, no one bothered to actually document this withinnand_command_lp, but such is life.
---
Re: Re[4]: [PATCH 06/12] mtd: nand: remove a bunch of unused commands
Quoted 38 lines · Alexander Shiyan
Quoted 38 lines · Alexander Shiyan
Quoted 36 lines
Quoted 14 lines · Artem Bityutskiy
Quoted 11 lines
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/cafe_nand.c | 6 ------ drivers/mtd/nand/nand_base.c | 10 ---------- drivers/mtd/nand/nandsim.c | 8 -------- drivers/mtd/nand/nuc900_nand.c | 9 --------- include/linux/mtd/nand.h | 20 -------------------- 5 files changed, 53 deletions(-)... trimmed ...
...
Quoted 7 lines
Quoted 6 lines
- * Note: the command for
NAND_CMD_DEPLETE1is really0x00but- * there is no way to distinguish that from NAND_CMD_READ0 - * until the remaining sequence of commands has been completed - * so add a high order bit and mask it off in the command.- */
-#defineNAND_CMD_DEPLETE10x100Quoted 7 lines
Perhaps this is the reason for the "unnecessary command masking" noted by Alexander? There is one instance of a command function which masks command &
0xff. Maybe Alexander's patch can be updated to mention this likely cause for the original masking and can be applied on top of Artem's cleanup series? Anyway, the mask was likely not used anyway, since (as Artem mentions in this patch series) AG-AND had very little general use (or none?).My patch is cleanup only. I think that the mask was originally included to limit the byte boundaries. However, this is not necessary because callback functions "
cmd_ctrl" use writeb/iowrite8 for send command, ie do not allow the use of the wrong size. Address also passed to "cmd_ctrl" via "cmd" parameter, which is not masked but only shifted, i.e. we have a values above0xff, so that is not a problem.
Quoted 7 lines
Quoted 5 lines
To be clear, I'm referring to your patch:
[PATCH 1/3] mtd:
nand_base: Removed unnecessary command maskingThe function that you are editing (
nand_command_lp) can be used forOK, for Samsung chips too.
Sure, and many others. But the AG-AND are the only case where you would use a command that is not 8 bits anyway.
Quoted 7 lines
Quoted 4 lines
AG-AND devices. The driver (
rtc_from4.c- slated for removal in this series) can sendNAND_CMD_DEPLETE1, which according to the comments innand.hthat I highlight above, should be "mask[ed] ... off in the command". So without Artem's change, your patch is actually breakingWhere it breaks? "
rtc_from4_hwcontrol" usewriteb()for "cmd" parameter, so its not breaks. Is I think incorrect?
I see. I guess it is correct, but it still hard to follow the logic that leads me to believe that this is a 100% correct change. I would appreciate it if:
(1) We remove all commands that are larger than 8-bit (as with Artem's current patch set)
(2) Alexander explains his change in more detail.
Anyway, I will move discussion of his changes back to his patch set, not here.
Quoted 4 lines
Quoted 2 lines
rtc_from4.c. Unforunately, no one bothered to actually document this withinnand_command_lp, but such is life.---
Brian
PATCH 7/12 mtd: nand: remove NAND_NO_PADDING macro
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
It is not used anywhere.
--- include/linux/mtd/nand.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
include/linux/mtd/nand.h +1 -5
@@ -145,8 +145,6 @@ typedef enum {*/ /* Buswidth is 16 bit */ #define NAND_BUSWIDTH_16 0x00000002 -/* Device supports partial programming without padding */ -#define NAND_NO_PADDING 0x00000004/* Chip has cache program function */ #define NAND_CACHEPRG 0x00000008/* Chip has copy back function */
@@ -164,11 +162,9 @@ typedef enum {#define NAND_SUBPAGE_READ 0x00001000/* Options valid for Samsung large page devices */ -#define NAND_SAMSUNG_LP_OPTIONS \ - (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) +#define NAND_SAMSUNG_LP_OPTIONS (NAND_CACHEPRG | NAND_COPYBACK)/* Macros to identify the above */ -#define NAND_MUST_PAD (chip) (!(chip->options & NAND_NO_PADDING))#define NAND_HAS_CACHEPROG (chip) ((chip->options & NAND_CACHEPRG))#define NAND_HAS_COPYBACK (chip) ((chip->options & NAND_COPYBACK))#define NAND_HAS_SUBPAGE_READ (chip) ((chip->options & NAND_SUBPAGE_READ))
Signature · 1 line
1.7.10.4
PATCH 8/12 mtd: nand: remove NAND_COPYBACK macro
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
It is unused.
--- include/linux/mtd/nand.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/mtd/nand.h +1 -4
@@ -147,8 +147,6 @@ typedef enum {#define NAND_BUSWIDTH_16 0x00000002/* Chip has cache program function */ #define NAND_CACHEPRG 0x00000008 -/* Chip has copy back function */ -#define NAND_COPYBACK 0x00000010/* Chip does not allow subpage writes */ #define NAND_NO_SUBPAGE_WRITE 0x00000200
@@ -162,11 +160,10 @@ typedef enum {#define NAND_SUBPAGE_READ 0x00001000/* Options valid for Samsung large page devices */ -#define NAND_SAMSUNG_LP_OPTIONS (NAND_CACHEPRG | NAND_COPYBACK) +#define NAND_SAMSUNG_LP_OPTIONS (NAND_CACHEPRG)/* Macros to identify the above */ #define NAND_HAS_CACHEPROG (chip) ((chip->options & NAND_CACHEPRG)) -#define NAND_HAS_COPYBACK (chip) ((chip->options & NAND_COPYBACK))#define NAND_HAS_SUBPAGE_READ (chip) ((chip->options & NAND_SUBPAGE_READ))/* Non chip related options */
Signature · 1 line
1.7.10.4
PATCH 9/12 mtd: nand: use NAND_HAS_CACHEPROG
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
We have this unused macro, let's use it and justify its existence.
--- drivers/mtd/nand/nand_base.c | 2 +- include/linux/mtd/nand.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +1 -1
@@ -2045,7 +2045,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,*/ cached =0 ; -if (!cached || !(chip->options &NAND_CACHEPRG )) { +if (!cached || !NAND_HAS_CACHEPROG (chip)) { chip->cmdfunc (mtd,NAND_CMD_PAGEPROG ,-1 ,-1 ); status = chip->waitfunc (mtd, chip);
include/linux/mtd/nand.h +1 -1
@@ -160,7 +160,7 @@ typedef enum {#define NAND_SUBPAGE_READ 0x00001000/* Options valid for Samsung large page devices */ -#define NAND_SAMSUNG_LP_OPTIONS (NAND_CACHEPRG) +#define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG/* Macros to identify the above */ #define NAND_HAS_CACHEPROG (chip) ((chip->options & NAND_CACHEPRG))
Signature · 1 line
1.7.10.4
PATCH 10/12 mtd: nand_ids: introduce helper macros
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
Introduce helper macros for defining NAND chips. These macros do not really add much value in the current code-base. However, we are going to add full ID support which adds some more complexity to the table, and helper macros become useful for readability.
--- drivers/mtd/nand/nand_ids.c | 159 +++++++++++++++++++++--------------------- drivers/mtd/nand/sm_common.c | 64 ++++++++--------- include/linux/mtd/nand.h | 17 +++++ 3 files changed, 127 insertions(+), 113 deletions(-)
drivers/mtd/nand/nand_ids.c +78 -81
@@ -15,37 +15,34 @@#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)/* -* The chip ID list: -* name, device ID, page size, chip size in MiB, eraseblock size, options -* -* If page size and eraseblock size is 0, the sizes are taken from the extended -* chip ID. +* The list of supported chips. If page size and eraseblock size is 0, the +* sizes are taken from the extended chip ID. */ struct nand_flash_dev nand_flash_ids[] = { - {"NAND 16MiB 1,8V 8-bit" ,0x33 ,512 ,16 ,0x4000 ,0 }, - {"NAND 16MiB 3,3V 8-bit" ,0x73 ,512 ,16 ,0x4000 ,0 }, - {"NAND 16MiB 1,8V 16-bit" ,0x43 ,512 ,16 ,0x4000 ,NAND_BUSWIDTH_16 }, - {"NAND 16MiB 3,3V 16-bit" ,0x53 ,512 ,16 ,0x4000 ,NAND_BUSWIDTH_16 }, - - {"NAND 32MiB 1,8V 8-bit" ,0x35 ,512 ,32 ,0x4000 ,0 }, - {"NAND 32MiB 3,3V 8-bit" ,0x75 ,512 ,32 ,0x4000 ,0 }, - {"NAND 32MiB 1,8V 16-bit" ,0x45 ,512 ,32 ,0x4000 ,NAND_BUSWIDTH_16 }, - {"NAND 32MiB 3,3V 16-bit" ,0x55 ,512 ,32 ,0x4000 ,NAND_BUSWIDTH_16 }, - - {"NAND 64MiB 1,8V 8-bit" ,0x36 ,512 ,64 ,0x4000 ,0 }, - {"NAND 64MiB 3,3V 8-bit" ,0x76 ,512 ,64 ,0x4000 ,0 }, - {"NAND 64MiB 1,8V 16-bit" ,0x46 ,512 ,64 ,0x4000 ,NAND_BUSWIDTH_16 }, - {"NAND 64MiB 3,3V 16-bit" ,0x56 ,512 ,64 ,0x4000 ,NAND_BUSWIDTH_16 }, - - {"NAND 128MiB 1,8V 8-bit" ,0x78 ,512 ,128 ,0x4000 ,0 }, - {"NAND 128MiB 1,8V 8-bit" ,0x39 ,512 ,128 ,0x4000 ,0 }, - {"NAND 128MiB 3,3V 8-bit" ,0x79 ,512 ,128 ,0x4000 ,0 }, - {"NAND 128MiB 1,8V 16-bit" ,0x72 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 }, - {"NAND 128MiB 1,8V 16-bit" ,0x49 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 }, - {"NAND 128MiB 3,3V 16-bit" ,0x74 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 }, - {"NAND 128MiB 3,3V 16-bit" ,0x59 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 }, - - {"NAND 256MiB 3,3V 8-bit" ,0x71 ,512 ,256 ,0x4000 ,0 }, +TABLE_NAND ("NAND 16MiB 1,8V 8-bit" ,0x33 ,512 ,16 ,0x4000 ,0 ), +TABLE_NAND ("NAND 16MiB 3,3V 8-bit" ,0x73 ,512 ,16 ,0x4000 ,0 ), +TABLE_NAND ("NAND 16MiB 1,8V 16-bit" ,0x43 ,512 ,16 ,0x4000 ,NAND_BUSWIDTH_16 ), +TABLE_NAND ("NAND 16MiB 3,3V 16-bit" ,0x53 ,512 ,16 ,0x4000 ,NAND_BUSWIDTH_16 ), + +TABLE_NAND ("NAND 32MiB 1,8V 8-bit" ,0x35 ,512 ,32 ,0x4000 ,0 ), +TABLE_NAND ("NAND 32MiB 3,3V 8-bit" ,0x75 ,512 ,32 ,0x4000 ,0 ), +TABLE_NAND ("NAND 32MiB 1,8V 16-bit" ,0x45 ,512 ,32 ,0x4000 ,NAND_BUSWIDTH_16 ), +TABLE_NAND ("NAND 32MiB 3,3V 16-bit" ,0x55 ,512 ,32 ,0x4000 ,NAND_BUSWIDTH_16 ), + +TABLE_NAND ("NAND 64MiB 1,8V 8-bit" ,0x36 ,512 ,64 ,0x4000 ,0 ), +TABLE_NAND ("NAND 64MiB 3,3V 8-bit" ,0x76 ,512 ,64 ,0x4000 ,0 ), +TABLE_NAND ("NAND 64MiB 1,8V 16-bit" ,0x46 ,512 ,64 ,0x4000 ,NAND_BUSWIDTH_16 ), +TABLE_NAND ("NAND 64MiB 3,3V 16-bit" ,0x56 ,512 ,64 ,0x4000 ,NAND_BUSWIDTH_16 ), + +TABLE_NAND ("NAND 128MiB 1,8V 8-bit" ,0x78 ,512 ,128 ,0x4000 ,0 ), +TABLE_NAND ("NAND 128MiB 1,8V 8-bit" ,0x39 ,512 ,128 ,0x4000 ,0 ), +TABLE_NAND ("NAND 128MiB 3,3V 8-bit" ,0x79 ,512 ,128 ,0x4000 ,0 ), +TABLE_NAND ("NAND 128MiB 1,8V 16-bit" ,0x72 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 ), +TABLE_NAND ("NAND 128MiB 1,8V 16-bit" ,0x49 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 ), +TABLE_NAND ("NAND 128MiB 3,3V 16-bit" ,0x74 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 ), +TABLE_NAND ("NAND 128MiB 3,3V 16-bit" ,0x59 ,512 ,128 ,0x4000 ,NAND_BUSWIDTH_16 ), + +TABLE_NAND ("NAND 256MiB 3,3V 8-bit" ,0x71 ,512 ,256 ,0x4000 ,0 ),/* * These are the new chips with large page size, page size and
@@ -53,79 +50,79 @@ struct nand_flash_dev nand_flash_ids[] = {*/ /* 512 Megabit */ - {"NAND 64MiB 1,8V 8-bit", 0xA2, 0, 64, 0, LP_OPTIONS}, - {"NAND 64MiB 1,8V 8-bit", 0xA0, 0, 64, 0, LP_OPTIONS}, - {"NAND 64MiB 3,3V 8-bit", 0xF2, 0, 64, 0, LP_OPTIONS}, - {"NAND 64MiB 3,3V 8-bit", 0xD0, 0, 64, 0, LP_OPTIONS}, - {"NAND 64MiB 3,3V 8-bit", 0xF0, 0, 64, 0, LP_OPTIONS}, - {"NAND 64MiB 1,8V 16-bit", 0xB2, 0, 64, 0, LP_OPTIONS16}, - {"NAND 64MiB 1,8V 16-bit", 0xB0, 0, 64, 0, LP_OPTIONS16}, - {"NAND 64MiB 3,3V 16-bit", 0xC2, 0, 64, 0, LP_OPTIONS16}, - {"NAND 64MiB 3,3V 16-bit", 0xC0, 0, 64, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 64MiB 1,8V 8-bit" ,0xA2 ,64 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64MiB 1,8V 8-bit" ,0xA0 ,64 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64MiB 3,3V 8-bit" ,0xF2 ,64 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64MiB 3,3V 8-bit" ,0xD0 ,64 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64MiB 3,3V 8-bit" ,0xF0 ,64 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64MiB 1,8V 16-bit" ,0xB2 ,64 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 64MiB 1,8V 16-bit" ,0xB0 ,64 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 64MiB 3,3V 16-bit" ,0xC2 ,64 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 64MiB 3,3V 16-bit" ,0xC0 ,64 ,LP_OPTIONS16 ),/* 1 Gigabit */ - {"NAND 128MiB 1,8V 8-bit", 0xA1, 0, 128, 0, LP_OPTIONS}, - {"NAND 128MiB 3,3V 8-bit", 0xF1, 0, 128, 0, LP_OPTIONS}, - {"NAND 128MiB 3,3V 8-bit", 0xD1, 0, 128, 0, LP_OPTIONS}, - {"NAND 128MiB 1,8V 16-bit", 0xB1, 0, 128, 0, LP_OPTIONS16}, - {"NAND 128MiB 3,3V 16-bit", 0xC1, 0, 128, 0, LP_OPTIONS16}, - {"NAND 128MiB 1,8V 16-bit", 0xAD, 0, 128, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 128MiB 1,8V 8-bit" ,0xA1 ,128 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 128MiB 3,3V 8-bit" ,0xF1 ,128 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 128MiB 3,3V 8-bit" ,0xD1 ,128 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 128MiB 1,8V 16-bit" ,0xB1 ,128 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 128MiB 3,3V 16-bit" ,0xC1 ,128 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 128MiB 1,8V 16-bit" ,0xAD ,128 ,LP_OPTIONS16 ),/* 2 Gigabit */ - {"NAND 256MiB 1,8V 8-bit", 0xAA, 0, 256, 0, LP_OPTIONS}, - {"NAND 256MiB 3,3V 8-bit", 0xDA, 0, 256, 0, LP_OPTIONS}, - {"NAND 256MiB 1,8V 16-bit", 0xBA, 0, 256, 0, LP_OPTIONS16}, - {"NAND 256MiB 3,3V 16-bit", 0xCA, 0, 256, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 256MiB 1,8V 8-bit" ,0xAA ,256 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 256MiB 3,3V 8-bit" ,0xDA ,256 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 256MiB 1,8V 16-bit" ,0xBA ,256 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 256MiB 3,3V 16-bit" ,0xCA ,256 ,LP_OPTIONS16 ),/* 4 Gigabit */ - {"NAND 512MiB 1,8V 8-bit", 0xAC, 0, 512, 0, LP_OPTIONS}, - {"NAND 512MiB 3,3V 8-bit", 0xDC, 0, 512, 0, LP_OPTIONS}, - {"NAND 512MiB 1,8V 16-bit", 0xBC, 0, 512, 0, LP_OPTIONS16}, - {"NAND 512MiB 3,3V 16-bit", 0xCC, 0, 512, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 512MiB 1,8V 8-bit" ,0xAC ,512 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 512MiB 3,3V 8-bit" ,0xDC ,512 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 512MiB 1,8V 16-bit" ,0xBC ,512 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 512MiB 3,3V 16-bit" ,0xCC ,512 ,LP_OPTIONS16 ),/* 8 Gigabit */ - {"NAND 1GiB 1,8V 8-bit", 0xA3, 0, 1024, 0, LP_OPTIONS}, - {"NAND 1GiB 3,3V 8-bit", 0xD3, 0, 1024, 0, LP_OPTIONS}, - {"NAND 1GiB 1,8V 16-bit", 0xB3, 0, 1024, 0, LP_OPTIONS16}, - {"NAND 1GiB 3,3V 16-bit", 0xC3, 0, 1024, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 1GiB 1,8V 8-bit" ,0xA3 ,1024 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 1GiB 3,3V 8-bit" ,0xD3 ,1024 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 1GiB 1,8V 16-bit" ,0xB3 ,1024 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 1GiB 3,3V 16-bit" ,0xC3 ,1024 ,LP_OPTIONS16 ),/* 16 Gigabit */ - {"NAND 2GiB 1,8V 8-bit", 0xA5, 0, 2048, 0, LP_OPTIONS}, - {"NAND 2GiB 3,3V 8-bit", 0xD5, 0, 2048, 0, LP_OPTIONS}, - {"NAND 2GiB 1,8V 16-bit", 0xB5, 0, 2048, 0, LP_OPTIONS16}, - {"NAND 2GiB 3,3V 16-bit", 0xC5, 0, 2048, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 2GiB 1,8V 8-bit" ,0xA5 ,2048 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 2GiB 3,3V 8-bit" ,0xD5 ,2048 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 2GiB 1,8V 16-bit" ,0xB5 ,2048 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 2GiB 3,3V 16-bit" ,0xC5 ,2048 ,LP_OPTIONS16 ),/* 32 Gigabit */ - {"NAND 4GiB 1,8V 8-bit", 0xA7, 0, 4096, 0, LP_OPTIONS}, - {"NAND 4GiB 3,3V 8-bit", 0xD7, 0, 4096, 0, LP_OPTIONS}, - {"NAND 4GiB 1,8V 16-bit", 0xB7, 0, 4096, 0, LP_OPTIONS16}, - {"NAND 4GiB 3,3V 16-bit", 0xC7, 0, 4096, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 4GiB 1,8V 8-bit" ,0xA7 ,4096 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 4GiB 3,3V 8-bit" ,0xD7 ,4096 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 4GiB 1,8V 16-bit" ,0xB7 ,4096 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 4GiB 3,3V 16-bit" ,0xC7 ,4096 ,LP_OPTIONS16 ),/* 64 Gigabit */ - {"NAND 8GiB 1,8V 8-bit", 0xAE, 0, 8192, 0, LP_OPTIONS}, - {"NAND 8GiB 3,3V 8-bit", 0xDE, 0, 8192, 0, LP_OPTIONS}, - {"NAND 8GiB 1,8V 16-bit", 0xBE, 0, 8192, 0, LP_OPTIONS16}, - {"NAND 8GiB 3,3V 16-bit", 0xCE, 0, 8192, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 8GiB 1,8V 8-bit" ,0xAE ,8192 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 8GiB 3,3V 8-bit" ,0xDE ,8192 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 8GiB 1,8V 16-bit" ,0xBE ,8192 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 8GiB 3,3V 16-bit" ,0xCE ,8192 ,LP_OPTIONS16 ),/* 128 Gigabit */ - {"NAND 16GiB 1,8V 8-bit", 0x1A, 0, 16384, 0, LP_OPTIONS}, - {"NAND 16GiB 3,3V 8-bit", 0x3A, 0, 16384, 0, LP_OPTIONS}, - {"NAND 16GiB 1,8V 16-bit", 0x2A, 0, 16384, 0, LP_OPTIONS16}, - {"NAND 16GiB 3,3V 16-bit", 0x4A, 0, 16384, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 16GiB 1,8V 8-bit" ,0x1A ,16384 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 16GiB 3,3V 8-bit" ,0x3A ,16384 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 16GiB 1,8V 16-bit" ,0x2A ,16384 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 16GiB 3,3V 16-bit" ,0x4A ,16384 ,LP_OPTIONS16 ),/* 256 Gigabit */ - {"NAND 32GiB 1,8V 8-bit", 0x1C, 0, 32768, 0, LP_OPTIONS}, - {"NAND 32GiB 3,3V 8-bit", 0x3C, 0, 32768, 0, LP_OPTIONS}, - {"NAND 32GiB 1,8V 16-bit", 0x2C, 0, 32768, 0, LP_OPTIONS16}, - {"NAND 32GiB 3,3V 16-bit", 0x4C, 0, 32768, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 32GiB 1,8V 8-bit" ,0x1C ,32768 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 32GiB 3,3V 8-bit" ,0x3C ,32768 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 32GiB 1,8V 16-bit" ,0x2C ,32768 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 32GiB 3,3V 16-bit" ,0x4C ,32768 ,LP_OPTIONS16 ),/* 512 Gigabit */ - {"NAND 64GiB 1,8V 8-bit", 0x1E, 0, 65536, 0, LP_OPTIONS}, - {"NAND 64GiB 3,3V 8-bit", 0x3E, 0, 65536, 0, LP_OPTIONS}, - {"NAND 64GiB 1,8V 16-bit", 0x2E, 0, 65536, 0, LP_OPTIONS16}, - {"NAND 64GiB 3,3V 16-bit", 0x4E, 0, 65536, 0, LP_OPTIONS16}, +EXTENDED_ID_NAND ("NAND 64GiB 1,8V 8-bit" ,0x1E ,65536 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64GiB 3,3V 8-bit" ,0x3E ,65536 ,LP_OPTIONS ), +EXTENDED_ID_NAND ("NAND 64GiB 1,8V 16-bit" ,0x2E ,65536 ,LP_OPTIONS16 ), +EXTENDED_ID_NAND ("NAND 64GiB 3,3V 16-bit" ,0x4E ,65536 ,LP_OPTIONS16 ), - {NULL,} + {NULL} };/*
drivers/mtd/nand/sm_common.c +32 -32
74 lines not on this page · raw message
include/linux/mtd/nand.h +17 -0
@@ -539,6 +539,23 @@ struct nand_chip {#define NAND_MFR_MACRONIX 0xc2#define NAND_MFR_EON 0x92 +/* +* A helper for defining older chips which did not have page size and +* eraseblock size encoded in the chip ID bytes. +*/ +#define TABLE_NAND (nm, devid, pagesz, chipsz, erasesz, opts) \ + { .name = (nm), .id = (devid), .pagesize = (pagesz), \ + .chipsize = (chipsz), .erasesize = (erasesz), \ + .options = (opts) } + +/* +* A helper for defining newer chips which report their page size and +* eraseblock size via the extended ID bytes. +*/ +#define EXTENDED_ID_NAND (nm, devid, chipsz, opts) \ + { .name = (nm), .id = (devid), .chipsize = (chipsz), \ + .options = (opts) } +/** * struct nand_flash_dev - NAND Flash Device ID Structure * @name: Identify the device type
Signature · 1 line
1.7.10.4
Re: [PATCH 10/12] mtd: nand_ids: introduce helper macros
Quoted 14 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Introduce helper macros for defining NAND chips. These macros do not really add much value in the current code-base. However, we are going to add full ID support which adds some more complexity to the table, and helper macros become useful for readability.
Signed-off-by Artem Bityutskiy <[email protected]>--- drivers/mtd/nand/nand_ids.c | 159 +++++++++++++++++++++--------------------- drivers/mtd/nand/sm_common.c | 64 ++++++++--------- include/linux/mtd/nand.h | 17 +++++ 3 files changed, 127 insertions(+), 113 deletions(-)
...
include/linux/mtd/nand.h struct nand_chip { · line 545
Quoted 12 lines
include/linux/mtd/nand.h +4
-0@@ -539,6 +539,23 @@ struct nand_chip {#define NAND_MFR_MACRONIX 0xc2#define NAND_MFR_EON 0x92 +/* +* A helper for defining older chips which did not have page size and +* eraseblock size encoded in the chip ID bytes. +*/
Do the "TABLE_NAND" flash really "not have page size and eraseblock size encoded in the chip ID bytes"? I would say they have them "encoded" in a way: the encoding is just a 1-to-1 constant mapping!
The real difference between TABLE_NAND and EXTENDED_ID_NAND is that with EXTENDED_ID_NAND, manufacturers overloaded the same device ID so that the device ID now only represented a particular total chip size (and voltage, buswidth), and the page size, eraseblock size, and OOB size could vary while using the same device ID.
I don't know if I'm just being too picky here or if this actually is worth clarifying/improving these comments. One candidate change:
"A helper for defining older chips whose device ID determines their page size and eraseblock size."
Quoted 17 lines
include/linux/mtd/nand.h +13
-1+#define TABLE_NAND (nm, devid, pagesz, chipsz, erasesz, opts) \ + { .name = (nm), .id = (devid), .pagesize = (pagesz), \ + .chipsize = (chipsz), .erasesize = (erasesz), \ + .options = (opts) } + +/* +* A helper for defining newer chips which report their page size and +* eraseblock size via the extended ID bytes. +*/ +#define EXTENDED_ID_NAND (nm, devid, chipsz, opts) \ + { .name = (nm), .id = (devid), .chipsize = (chipsz), \ + .options = (opts) } +/** * struct nand_flash_dev - NAND Flash Device ID Structure * @name: Identify the device type --
Quoted 2 lines
1.7.10.4
Brian
Re: [PATCH 10/12] mtd: nand_ids: introduce helper macros
Quoted 15 lines · Brian Norris
Quoted 4 lines
+/*
+ * A helper for defining older chips which did not have page size and
+ * eraseblock size encoded in the chip ID bytes.
+ */Do the "
TABLE_NAND" flash really "not have page size and eraseblock size encoded in the chip ID bytes"? I would say they have them "encoded" in a way: the encoding is just a 1-to-1 constant mapping!The real difference between
TABLE_NANDandEXTENDED_ID_NANDis that withEXTENDED_ID_NAND, manufacturers overloaded the same device ID so that the device ID now only represented a particular total chip size (and voltage, buswidth), and the page size, eraseblock size, and OOB size could vary while using the same device ID.
Quoted 5 lines
I don't know if I'm just being too picky here or if this actually is worth clarifying/improving these comments. One candidate change:
"A helper for defining older chips whose device ID determines their page size and eraseblock size."
No, you are not picky, you are pointing to a serious flaw in my commentaries. Thank you. I'll update the comments accordingly and send out the new version for your review.
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH 11/12 mtd: nand: rename the id filed of 'struct nand_flash_dev'
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
The 'id' is a bit confusing name because NAND IDs are multi-byte. Re-name it to 'dev_id' to make it clear that this is the "device ID" part (the second byte).
--- drivers/mtd/devices/doc2000.c | 2 +- drivers/mtd/devices/doc2001.c | 2 +- drivers/mtd/devices/doc2001plus.c | 2 +- drivers/mtd/nand/nand_base.c | 2 +- drivers/mtd/nand/nandsim.c | 6 +++--- drivers/mtd/nand/pxa3xx_nand.c | 2 +- include/linux/mtd/nand.h | 14 +++++++------- 7 files changed, 15 insertions(+), 15 deletions(-)
drivers/mtd/devices/doc2000.c +1 -1
@@ -379,7 +379,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)/* Print and store the manufacturer and ID codes. */ for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) { -if (id == nand_flash_ids[i].id) { +if (id == nand_flash_ids[i].dev_id) {/* Try to identify manufacturer */ for (j =0 ; nand_manuf_ids[j].id !=0x0 ; j++) {if (nand_manuf_ids[j].id == mfr)
drivers/mtd/devices/doc2001.c +1 -1
@@ -206,7 +206,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)/* FIXME: to deal with multi-flash on multi-Millennium case more carefully */ for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) { -if ( id == nand_flash_ids[i].id) { +if ( id == nand_flash_ids[i].dev_id) {/* Try to identify manufacturer */ for (j =0 ; nand_manuf_ids[j].id !=0x0 ; j++) {if (nand_manuf_ids[j].id == mfr)
drivers/mtd/devices/doc2001plus.c +1 -1
@@ -314,7 +314,7 @@ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)return 0 ;for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) { -if (id == nand_flash_ids[i].id) { +if (id == nand_flash_ids[i].dev_id) {/* Try to identify manufacturer */ for (j =0 ; nand_manuf_ids[j].id !=0x0 ; j++) {if (nand_manuf_ids[j].id == mfr)
drivers/mtd/nand/nand_base.c +1 -1
@@ -3128,7 +3128,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, type = nand_flash_ids;for (; type->name !=NULL ; type++) -if (*dev_id == type->id) +if (*dev_id == type->dev_id)break ; chip->onfi_version =0 ;
drivers/mtd/nand/nandsim.c +3 -3
@@ -766,9 +766,9 @@ static int init_nandsim(struct mtd_info *mtd) }/* Detect how many ID bytes the NAND chip outputs */ -for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) { -if (second_id_byte != nand_flash_ids[i].id) -continue ; +for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) { +if (second_id_byte != nand_flash_ids[i].dev_id) +continue ; }if (ns->busw ==16 )
drivers/mtd/nand/pxa3xx_nand.c +1 -1
@@ -989,7 +989,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd) } pxa3xx_flash_ids[0 ].name = f->name; - pxa3xx_flash_ids[0 ].id = (f->chip_id >>8 ) &0xffff ; + pxa3xx_flash_ids[0 ].dev_id = (f->chip_id >>8 ) &0xffff ; pxa3xx_flash_ids[0 ].pagesize = f->page_size; chipsize = (uint64_t )f->num_blocks * f->page_per_block * f->page_size; pxa3xx_flash_ids[0 ].chipsize = chipsize >>20 ;
include/linux/mtd/nand.h +7 -7
@@ -543,23 +543,23 @@ struct nand_chip {* A helper for defining older chips which did not have page size and * eraseblock size encoded in the chip ID bytes. */ -#define TABLE_NAND (nm, devid, pagesz, chipsz, erasesz, opts) \ - { .name = (nm), .id = (devid), .pagesize = (pagesz), \ - .chipsize = (chipsz), .erasesize = (erasesz), \ +#define TABLE_NAND (nm, devid, pagesz, chipsz, erasesz, opts) \ + { .name = (nm), .dev_id = (devid), .pagesize = (pagesz), \ + .chipsize = (chipsz), .erasesize = (erasesz), \ .options = (opts) }/* * A helper for defining newer chips which report their page size and * eraseblock size via the extended ID bytes. */ -#define EXTENDED_ID_NAND (nm, devid, chipsz, opts) \ - { .name = (nm), .id = (devid), .chipsize = (chipsz), \ +#define EXTENDED_ID_NAND (nm, devid, chipsz, opts) \ + { .name = (nm), .dev_id = (devid), .chipsize = (chipsz), \ .options = (opts) }/** * struct nand_flash_dev - NAND Flash Device ID Structure * @name: Identify the device type -* @id: device ID code +* @dev_id: device ID code * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 * If the pagesize is 0, then the real pagesize * and the eraseize are determined from the
@@ -570,7 +570,7 @@ struct nand_chip {*/ struct nand_flash_dev {char *name; -int id; +int dev_id;unsigned long pagesize;unsigned long chipsize;unsigned long erasesize;
Signature · 1 line
1.7.10.4
Re: [PATCH 11/12] mtd: nand: rename the id filed of 'struct nand_flash_dev'
Quoted 7 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
The 'id' is a bit confusing name because NAND IDs are multi-byte. Re-name it to '
dev_id' to make it clear that this is the "device ID" part (the second byte).Signed-off-by Artem Bityutskiy <[email protected]>
While we're going for typos (a la Jan's comment on another part of this series) the subject of this patch/email says "filed" where it should be "field".
Still reviewing the rest of this.
Brian
PATCH 12/12 mtd: nand: provision full ID support
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
--- include/linux/mtd/nand.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
include/linux/mtd/nand.h +10 -2
@@ -559,7 +559,9 @@ struct nand_chip {/** * struct nand_flash_dev - NAND Flash Device ID Structure * @name: Identify the device type -* @dev_id: device ID code +* @mfr_id: manufecturer ID part of the full chip ID array (byte 0) +* @dev_id: device ID part of the full chip ID array (byte 1) +* @id: full device ID array * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 * If the pagesize is 0, then the real pagesize * and the eraseize are determined from the
@@ -570,7 +572,13 @@ struct nand_chip {*/ struct nand_flash_dev {char *name; -int dev_id; +union { +struct { +uint8_t mfr_id; +uint8_t dev_id; + }; +uint8_t id[8 ]; + };unsigned long pagesize;unsigned long chipsize;unsigned long erasesize;
Signature · 1 line
1.7.10.4
Quoted 5 lines · Artem Bityutskiy
/**
* structnand_flash_dev- NAND Flash Device ID Structure
* @name: Identify the device type
- * @dev_id: device ID code
+ * @mfr_id: manufecturer ID part of the full chip ID array (byte 0)
This should be 'manufacturer'.
Quoted 1 line
+ * @dev_id: device ID part of the full chip ID array (byte 1)
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 24 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- include/linux/mtd/nand.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)include/linux/mtd/nand.h +3
-1@@ -559,7 +559,9 @@ struct nand_chip {/** * struct nand_flash_dev - NAND Flash Device ID Structure * @name: Identify the device type -* @dev_id: device ID code +* @mfr_id: manufecturer ID part of the full chip ID array (byte 0) +* @dev_id: device ID part of the full chip ID array (byte 1) +* @id: full device ID array * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 * If the pagesize is 0, then the real pagesize * and the eraseize are determined from the @@ -570,7 +572,13 @@ struct nand_chip {*/
include/linux/mtd/nand.h struct nand_chip { · line 581
Quoted 10 lines
include/linux/mtd/nand.h +7
-1struct nand_flash_dev {char *name; -int dev_id; +union { +struct { +uint8_t mfr_id; +uint8_t dev_id; + }; +uint8_t id[8 ]; + };
I'm sorry that I was unable to fully review Huang's code while it was being discussed earlier. But from what I read, it seemed there was some disagreement on some of the format of the tables (e.g., Artem wondered why the extra zeroes). Now, it seems like instead, we're including duplicate fields. The "mfr_id" and "dev_id" are always the first two bytes of the "id[8]" field. Does it make sense to repeat them? And I actually don't ever see where "mfr_id" would be used.
There's also the (yet unanswered?) question of whether we reasonably would handle in this table both those chips which have their full information listed in conjunction with their 8-byte ID string and those chips with minimal information in the table, and the rest must be decoded from extended ID.
Perhaps the answer to this last question was already assumed to be "yes." But how would we differentiate the two types of table entries? Simply by seeing whether they filled out "dev_id" vs. "id[8]"? This patch doesn't clearly show how the new fields could be used.
Hopefully my comments make some sense. If they don't, then that probably means we need some more discussion before including this last patch. If they do make sense, then that probably still means this last patch needs to be rewritten and/or included only along with a series that can reasonably make use of these fields (like Huang's series).
include/linux/mtd/nand.h struct nand_chip { · line 584
Quoted 3 lines
include/linux/mtd/nand.h +0
-0unsigned long pagesize;unsigned long chipsize;unsigned long erasesize;
Thanks,
Brian
Quoted 11 lines · Brian Norris
include/linux/mtd/nand.h struct nand_chip { · line 581
Quoted 10 lines
struct nand_flash_dev { char *name;include/linux/mtd/nand.h +7
-1-int dev_id; +union { +struct { +uint8_t mfr_id; +uint8_t dev_id; + }; +uint8_t id[8 ]; + };
Quoted 7 lines
I'm sorry that I was unable to fully review Huang's code while it was being discussed earlier. But from what I read, it seemed there was some disagreement on some of the format of the tables (e.g., Artem wondered why the extra zeroes). Now, it seems like instead, we're including duplicate fields. The "
mfr_id" and "dev_id" are always the first two bytes of the "id[8]" field. Does it make sense to repeat them? And I actually don't ever see where "mfr_id" would be used.
This is not repeating. Because of the union {}, mfr_id's memory address is identical to id[0]'s address, and dev_id's memory address is identical to id[1]'s address. You can consider 'mfr_id' and 'dev_id' to be alias names for id[0] and id[1]. If one needs to have an alias name for other ID bytes, they can be added.
My idea was that type->mfr_id and type->dev_id is more readable than type->id[0] and type->id[1].
Quoted 5 lines
There's also the (yet unanswered?) question of whether we reasonably would handle in this table both those chips which have their full information listed in conjunction with their 8-byte ID string and those chips with minimal information in the table, and the rest must be decoded from extended ID.
I was thinking that we have a single table which contains both, and we make sure that all full ID records go first, and device ID-only records go last. This would mean that we first match by full ID, and then by device IDs.
Quoted 4 lines
Perhaps the answer to this last question was already assumed to be "yes." But how would we differentiate the two types of table entries? Simply by seeing whether they filled out "
dev_id" vs. "id[8]"? This patch doesn't clearly show how the new fields could be used.
I was thinking about
if (type->mfr_id == 0)
/* this is device-only ID */ else /* this is full ID */
or
static inline bool is_full_nand_id(type) {
return type->mfr_id;
}Quoted 5 lines
Hopefully my comments make some sense. If they don't, then that probably means we need some more discussion before including this last patch. If they do make sense, then that probably still means this last patch needs to be rewritten and/or included only along with a series that can reasonably make use of these fields (like Huang's series).
Sure, this is why you was in "To:" - you are the main NAND janitor nowadays, because others mostly care about their little drivers, while you demonstrated skills and will to make the general layer sane.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 7 lines · Artem Bityutskiy
I was thinking about
if (
type->mfr_id== 0)/* this is device-only ID */ else /* this is full ID */
Quoted 5 lines
or
static inline bool is_full_nand_id(type) { return type->mfr_id; }
okay. If you think we should not add another table for the full-id nand. I will follow your advice.
thanks
Huang Shijie
Quoted 25 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Signed-off-by Artem Bityutskiy <[email protected]>--- include/linux/mtd/nand.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)include/linux/mtd/nand.h +3
-1@@ -559,7 +559,9 @@ struct nand_chip {/** * struct nand_flash_dev - NAND Flash Device ID Structure * @name: Identify the device type -* @dev_id: device ID code +* @mfr_id: manufecturer ID part of the full chip ID array (byte 0) +* @dev_id: device ID part of the full chip ID array (byte 1) +* @id: full device ID array * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 * If the pagesize is 0, then the real pagesize * and the eraseize are determined from the @@ -570,7 +572,13 @@ struct nand_chip {*/ struct nand_flash_dev {
include/linux/mtd/nand.h struct nand_chip { · line 582
Quoted 10 lines
include/linux/mtd/nand.h +7
-1char *name; -int dev_id; +union { +struct { +uint8_t mfr_id; +uint8_t dev_id; + }; +uint8_t id[8 ]; + };
We can add a new helper like compare_nand_with_devid() to remove the mfr_id and dev_id, only left the id[8].
The compare_nand_with_devid() can be used in places where your patch 11 does. For example:
..............................................................
if (id == nand_flash_ids[i].dev_id) {changed to:
if (compare_nand_with_devid(id)){...............................................................
By this way, we can remove the mfr_id and dev_id.
thanks
Huang Shijie
Quoted 11 lines · Huang Shijie
include/linux/mtd/nand.h struct nand_chip { · line 581
Quoted 11 lines
struct nand_flash_dev { char *name;include/linux/mtd/nand.h +7
-1-int dev_id; +union { +struct { +uint8_t mfr_id; +uint8_t dev_id; + }; +uint8_t id[8 ]; + };
Quoted 2 lines
We can add a new helper like
compare_nand_with_devid()to remove themfr_idanddev_id, only left the id[8].
Huang, did you miss the "union { ... }" part or you think using 'id[N]' directly is readable enough?
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 12 lines · Artem Bityutskiy
Quoted 11 lines · Huang Shijie
Quoted 11 lines
struct nand_flash_dev { char *name;include/linux/mtd/nand.h +7
-1-int dev_id; +union { +struct { +uint8_t mfr_id; +uint8_t dev_id; + }; +uint8_t id[8 ]; + };
Quoted 5 lines
Quoted 2 lines
We can add a new helper like
compare_nand_with_devid()to remove themfr_idanddev_id, only left the id[8].Huang, did you miss the "union { ... }" part or you think using 'id[N]' directly is readable enough?
i think using the id[] is enough.
the union is redundant.
thanks
Huang Shijie
Quoted 7 lines · Huang Shijie
Quoted 5 lines
Quoted 2 lines
We can add a new helper like
compare_nand_with_devid()to remove themfr_idanddev_id, only left the id[8].Huang, did you miss the "union { ... }" part or you think using 'id[N]' directly is readable enough?
i think using the id[] is enough.
the union is redundant.
I just find 'type->dev_id' more readable than 'type->id[1]'...
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 8 lines · Artem Bityutskiy
Quoted 6 lines · Huang Shijie
Quoted 4 lines
Quoted 2 lines
We can add a new helper like
compare_nand_with_devid()to remove themfr_idanddev_id, only left the id[8].Huang, did you miss the "union { ... }" part or you think using 'id[N]' directly is readable enough?
i think using the id[] is enough.
the union is redundant.I just find '
type->dev_id' more readable than 'type->id[1]'...
Just a suggestion, add more comments to the code will also make it readable.
But it's ok to me if you keep the union.
thanks
Huang Shijie
Hi Artem,
Quoted 7 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Hi,
this is an RFC which adds full ID support provision which Huang can then use to solve his problem described here:
Quoted 7 lines
http://thread.gmane.org/gmane.linux.kernel/1428345/focus=45290
But before adding full ID support, I cleaned up things a little and removed AG-AND support as part of the clean-up.
Thanks,
Artem.
Thanks for the cleanup work (and thanks Huang, for the initiative on expanding the ID table). Aside from my minor comments, I'll ack patches 1 through 11:
As noted in my review, the last patch seems a little underspecified.
Brian
Quoted 5 lines · Brian Norris
Thanks for the cleanup work (and thanks Huang, for the initiative on expanding the ID table). Aside from my minor comments, I'll ack patches 1 through 11:
Acked-by Brian Norris <[email protected]>
Added this tag to 1-11, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 8 lines · Artem Bityutskiy
Quoted 5 lines · Brian Norris
Thanks for the cleanup work (and thanks Huang, for the initiative on expanding the ID table). Aside from my minor comments, I'll ack patches 1 through 11:
Acked-by Brian Norris<[email protected]>Added this tag to 1-11, thanks!
could you do a compiler test for this patch set?
I tested it, and a compiler error occurred.
thanks
Huang Shijie