Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: mxc: implement onfi get/set features

To be able to support different ONFI timing modes we have to implement
the onfi_set_features and onfi_get_features. Tested on an i.MX25 SoC.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

authored by

Sascha Hauer and committed by
Boris Brezillon
4123ea34 907f45fb

+55
+55
drivers/mtd/nand/mxc_nand.c
··· 1239 1239 } 1240 1240 } 1241 1241 1242 + static int mxc_nand_onfi_set_features(struct mtd_info *mtd, 1243 + struct nand_chip *chip, int addr, 1244 + u8 *subfeature_param) 1245 + { 1246 + struct nand_chip *nand_chip = mtd_to_nand(mtd); 1247 + struct mxc_nand_host *host = nand_get_controller_data(nand_chip); 1248 + int i; 1249 + 1250 + if (!chip->onfi_version || 1251 + !(le16_to_cpu(chip->onfi_params.opt_cmd) 1252 + & ONFI_OPT_CMD_SET_GET_FEATURES)) 1253 + return -EINVAL; 1254 + 1255 + host->buf_start = 0; 1256 + 1257 + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) 1258 + chip->write_byte(mtd, subfeature_param[i]); 1259 + 1260 + memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize); 1261 + host->devtype_data->send_cmd(host, NAND_CMD_SET_FEATURES, false); 1262 + mxc_do_addr_cycle(mtd, addr, -1); 1263 + host->devtype_data->send_page(mtd, NFC_INPUT); 1264 + 1265 + return 0; 1266 + } 1267 + 1268 + static int mxc_nand_onfi_get_features(struct mtd_info *mtd, 1269 + struct nand_chip *chip, int addr, 1270 + u8 *subfeature_param) 1271 + { 1272 + struct nand_chip *nand_chip = mtd_to_nand(mtd); 1273 + struct mxc_nand_host *host = nand_get_controller_data(nand_chip); 1274 + int i; 1275 + 1276 + if (!chip->onfi_version || 1277 + !(le16_to_cpu(chip->onfi_params.opt_cmd) 1278 + & ONFI_OPT_CMD_SET_GET_FEATURES)) 1279 + return -EINVAL; 1280 + 1281 + *(uint32_t *)host->main_area0 = 0xdeadbeef; 1282 + 1283 + host->devtype_data->send_cmd(host, NAND_CMD_GET_FEATURES, false); 1284 + mxc_do_addr_cycle(mtd, addr, -1); 1285 + host->devtype_data->send_page(mtd, NFC_OUTPUT); 1286 + memcpy32_fromio(host->data_buf, host->main_area0, 512); 1287 + host->buf_start = 0; 1288 + 1289 + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) 1290 + *subfeature_param++ = chip->read_byte(mtd); 1291 + 1292 + return 0; 1293 + } 1294 + 1242 1295 /* 1243 1296 * The generic flash bbt decriptors overlap with our ecc 1244 1297 * hardware, so define some i.MX specific ones. ··· 1566 1513 this->read_word = mxc_nand_read_word; 1567 1514 this->write_buf = mxc_nand_write_buf; 1568 1515 this->read_buf = mxc_nand_read_buf; 1516 + this->onfi_set_features = mxc_nand_onfi_set_features; 1517 + this->onfi_get_features = mxc_nand_onfi_get_features; 1569 1518 1570 1519 host->clk = devm_clk_get(&pdev->dev, NULL); 1571 1520 if (IS_ERR(host->clk))