aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2013-08-13 13:51:55 -0400
committerBrian Norris <computersforpeace@gmail.com>2013-10-27 19:27:03 -0400
commitc7f23a70635895b5125aeb5593aaf8cb44d3a088 (patch)
tree00577a372bd5928d27c8141d99a50f198afa215b
parent535ab9033433c00116e446beaac96503c7282fd1 (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>
-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 d340b2f198c6..00022b456dff 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);
@@ -3009,10 +3014,11 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
3009 3014
3010 /* The Extended Parameter Page is supported since ONFI 2.1. */ 3015 /* The Extended Parameter Page is supported since ONFI 2.1. */
3011 if (nand_flash_detect_ext_param_page(mtd, chip, p)) 3016 if (nand_flash_detect_ext_param_page(mtd, chip, p))
3012 pr_info("Failed to detect the extended param page.\n"); 3017 pr_warn("Failed to detect ONFI extended param page\n");
3018 } else {
3019 pr_warn("Could not retrieve ONFI ECC requirements\n");
3013 } 3020 }
3014 3021
3015 pr_info("ONFI flash detected\n");
3016 return 1; 3022 return 1;
3017} 3023}
3018 3024