* [PATCH 1/2] mtd: nand: Only call ONFI get/set features on supported chips
@ 2017-09-05 12:28 Sascha Hauer
2017-09-05 12:28 ` [PATCH 2/2] mtd: nand: nand_mxs: Don't call get/set features on chips which do not support it Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2017-09-05 12:28 UTC (permalink / raw)
To: Barebox List
Older versions of the ONFI spec do not support get/set features, so
do not call these commands when they are not available.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/nand/nand_base.c | 8 ++++++--
include/linux/mtd/nand.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d9f79474cd..b321c59180 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2839,7 +2839,9 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip,
{
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_set_features(struct mtd_info *mtd, struct nand_chip *chip,
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/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 27538c3f42..88a8fe9756 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -222,6 +222,9 @@ struct nand_chip;
/* 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' */
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] mtd: nand: nand_mxs: Don't call get/set features on chips which do not support it
2017-09-05 12:28 [PATCH 1/2] mtd: nand: Only call ONFI get/set features on supported chips Sascha Hauer
@ 2017-09-05 12:28 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2017-09-05 12:28 UTC (permalink / raw)
To: Barebox List
Older versions of the ONFI spec do not support get/set features, so
do not call these commands when they are not available.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/nand/nand_mxs.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index cba0beedbb..110334d256 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -2030,19 +2030,23 @@ static int mxs_nand_enable_edo_mode(struct mxs_nand_info *info)
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,
+ /* [1] send SET FEATURE commond to NAND */
+ feature[0] = mode;
+
+ ret = nand->onfi_set_features(mtd, nand,
ONFI_FEATURE_ADDR_TIMING_MODE, feature);
- if (ret)
- 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,
+ /* [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;
+ if (ret || feature[0] != mode)
+ goto err_out;
+ }
nand->select_chip(mtd, -1);
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-05 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 12:28 [PATCH 1/2] mtd: nand: Only call ONFI get/set features on supported chips Sascha Hauer
2017-09-05 12:28 ` [PATCH 2/2] mtd: nand: nand_mxs: Don't call get/set features on chips which do not support it Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox