aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2013-08-13 13:51:55 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:06:02 -0400
commit470b1026e48aac6801971f933961acc86156fc9c (patch)
treeae522d7bb0c591fd42d31e7ef5b8a815d4a00652
parent718922f16f7257d56a7361b9eed17c7cbf2d7ce0 (diff)
mtd: nand: cleanup ONFI printed errors, warnings
The ONFI detection routine is too verbose in some cases and not verbose enough in others. This patch refactors it to print only when there are significant warnings/errors. Probing in 16-bit mode: It is unnecessary to print until after the READID (address 20h) command. READID *has* to work properly in whatever bus width configuration we are in, or else no identification mode works. So we can silence some useless warnings on systems which come up in 16-bit mode and do not even respond with an O-N-F-I string. Valid parameter page: Nobody needs to see this. Do we inform the user every time other hardware responds properly? Instead, add an error message if *no* uncorrupted parameter pages are found. ONFI ECC: Most drivers don't yet use the reported minimum ECC values, so it shouldn't yet be a fatal condition if the extended parameter page is incorrect. But we should at least give a warning for the corner cases that we don't expect. ONFI flash detected: Nobody needs to see this. This is the expected case, that we detect ONFI properly, or else it wasn't ONFI-compliant and is detected by some other routine. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Huang Shijie <b32955@freescale.com> Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Huang Shijie <b32955@freescale.com>
-rw-r--r--drivers/mtd/nand/nand_base.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d92d94bb7166..1cfad9ac3f2f 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2935,29 +2935,34 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
2935 int i; 2935 int i;
2936 int val; 2936 int val;
2937 2937
2938 /* ONFI need to be probed in 8 bits mode, and 16 bits should be selected with NAND_BUSWIDTH_AUTO */
2939 if (chip->options & NAND_BUSWIDTH_16) {
2940 pr_err("Trying ONFI probe in 16 bits mode, aborting !\n");
2941 return 0;
2942 }
2943 /* Try ONFI for unknown chip or LP */ 2938 /* Try ONFI for unknown chip or LP */
2944 chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1); 2939 chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1);
2945 if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' || 2940 if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' ||
2946 chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I') 2941 chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I')
2947 return 0; 2942 return 0;
2948 2943
2944 /*
2945 * ONFI must be probed in 8-bit mode or with NAND_BUSWIDTH_AUTO, not
2946 * with NAND_BUSWIDTH_16
2947 */
2948 if (chip->options & NAND_BUSWIDTH_16) {
2949 pr_err("ONFI cannot be probed in 16-bit mode; aborting\n");
2950 return 0;
2951 }
2952
2949 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1); 2953 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
2950 for (i = 0; i < 3; i++) { 2954 for (i = 0; i < 3; i++) {
2951 chip->read_buf(mtd, (uint8_t *)p, sizeof(*p)); 2955 chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));
2952 if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) == 2956 if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) ==
2953 le16_to_cpu(p->crc)) { 2957 le16_to_cpu(p->crc)) {
2954 pr_info("ONFI param page %d valid\n", i);
2955 break; 2958 break;
2956 } 2959 }
2957 } 2960 }
2958 2961
2959 if (i == 3) 2962 if (i == 3) {
2963 pr_err("Could not find valid ONFI parameter page; aborting\n");
2960 return 0; 2964 return 0;
2965 }
2961 2966
2962 /* Check version */ 2967 /* Check version */
2963 val = le16_to_cpu(p->revision); 2968 val = le16_to_cpu(p->revision);
@@ -3020,10 +3025,11 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
3020 3025
3021 /* The Extended Parameter Page is supported since ONFI 2.1. */ 3026 /* The Extended Parameter Page is supported since ONFI 2.1. */
3022 if (nand_flash_detect_ext_param_page(mtd, chip, p)) 3027 if (nand_flash_detect_ext_param_page(mtd, chip, p))
3023 pr_info("Failed to detect the extended param page.\n"); 3028 pr_warn("Failed to detect ONFI extended param page\n");
3029 } else {
3030 pr_warn("Could not retrieve ONFI ECC requirements\n");
3024 } 3031 }
3025 3032
3026 pr_info("ONFI flash detected\n");
3027 return 1; 3033 return 1;
3028} 3034}
3029 3035