diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index d9f7947..b321c59 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2839,7 +2839,9 @@ { int status; - if (!chip->onfi_version) + if (!chip->onfi_version || + !(le16_to_cpu(chip->onfi_params.opt_cmd) + & ONFI_OPT_CMD_SET_GET_FEATURES)) return -EINVAL; chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1); @@ -2860,7 +2862,9 @@ static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip, int addr, uint8_t *subfeature_param) { - if (!chip->onfi_version) + if (!chip->onfi_version || + !(le16_to_cpu(chip->onfi_params.opt_cmd) + & ONFI_OPT_CMD_SET_GET_FEATURES)) return -EINVAL; /* clear the sub feature parameters */ diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c index cba0bee..337748a 100644 --- a/drivers/mtd/nand/nand_mxs.c +++ b/drivers/mtd/nand/nand_mxs.c @@ -459,7 +459,7 @@ /* Execute the DMA chain. */ ret = mxs_dma_go(channel); if (ret) - printf("MXS NAND: Error sending command\n"); + printf("MXS NAND: Error sending command (%d)\n", ret); mxs_nand_return_dma_descs(nand_info); @@ -815,7 +815,7 @@ /* Execute the DMA chain. */ ret = mxs_dma_go(channel); if (ret) { - printf("MXS NAND: DMA read error\n"); + printf("MXS NAND: DMA read error (ecc)\n"); goto rtn; } @@ -2030,19 +2030,23 @@ nand->select_chip(mtd, 0); - /* [1] send SET FEATURE commond to NAND */ - feature[0] = mode; + if (le16_to_cpu(nand->onfi_params.opt_cmd) + & ONFI_OPT_CMD_SET_GET_FEATURES) { - ret = nand->onfi_set_features(mtd, nand, - ONFI_FEATURE_ADDR_TIMING_MODE, feature); - if (ret) - goto err_out; + /* [1] send SET FEATURE commond to NAND */ + feature[0] = mode; - /* [2] send GET FEATURE command to double-check the timing mode */ - ret = nand->onfi_get_features(mtd, nand, + ret = nand->onfi_set_features(mtd, nand, ONFI_FEATURE_ADDR_TIMING_MODE, feature); - if (ret || feature[0] != mode) - goto err_out; + if (ret) + goto err_out; + + /* [2] send GET FEATURE command to double-check the timing mode */ + ret = nand->onfi_get_features(mtd, nand, + ONFI_FEATURE_ADDR_TIMING_MODE, feature); + if (ret || feature[0] != mode) + goto err_out; + } nand->select_chip(mtd, -1); diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 27538c3..88a8fe9 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -222,6 +222,9 @@ /* ONFI subfeature parameters length */ #define ONFI_SUBFEATURE_PARAM_LEN 4 +/* ONFI optional commands SET/GET FEATURES supported? */ +#define ONFI_OPT_CMD_SET_GET_FEATURES (1 << 2) + struct nand_onfi_params { /* rev info and features block */ /* 'O' 'N' 'F' 'I' */