Skip to content

Commit

Permalink
imx6: add support for edo-4 mode NAND
Browse files Browse the repository at this point in the history
The Cypress S34ML16G2 2GiB NAND flash that is being used on newer revision
boards (as the Micron 2GiB part went end of life) does not support the
get/set features ONFI command causing the edo mode setting to fail.

Resolve this by only performing the get/set on chips that support those
commands.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
  • Loading branch information
Gateworks committed Sep 13, 2019
1 parent bc4e236 commit f3fbc0e
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions drivers/mtd/nand/gpmi-nand/gpmi-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,23 +928,31 @@ static int enable_edo_mode(struct gpmi_nand_data *this, int mode)
if (!feature)
return -ENOMEM;

nand->select_chip(mtd, 0);
/* Only try to set/get features if this ONFI NAND supports it.
If SET_GET_FEATURES is not supported, skip it,
and just set the host timing. */
if (le16_to_cpu(nand->onfi_params.opt_cmd)
& ONFI_OPT_CMD_SET_GET_FEATURES) {

nand->select_chip(mtd, 0);

/* [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;

/* [2] send GET FEATURE command to double-check the timing mode */
memset(feature, 0, ONFI_SUBFEATURE_PARAM_LEN);
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);

/* [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;

/* [2] send GET FEATURE command to double-check the timing mode */
memset(feature, 0, ONFI_SUBFEATURE_PARAM_LEN);
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);
}

/* [3] set the main IO clock, 100MHz for mode 5, 80MHz for mode 4. */
rate = (mode == 5) ? 100000000 : 80000000;
Expand Down

0 comments on commit f3fbc0e

Please sign in to comment.