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

Merge tag 'for-linus-20161008' of git://git.infradead.org/linux-mtd

Pull MTD updates from Brian Norris:
"I've not been very active this cycle, so these are mostly from Boris,
for the NAND flash subsystem.

NAND:

- Add the infrastructure to automate NAND timings configuration

- Provide a generic DT property to maximize ECC strength

- Some refactoring in the core bad block table handling, to help with
improving some of the logic in error cases.

- Minor cleanups and fixes

MTD:

- Add APIs for handling page pairing; this is necessary for reliably
supporting MLC and TLC NAND flash, where paired-page disturbance
affects reliability. Upper layers (e.g., UBI) should make use of
these in the near future"

* tag 'for-linus-20161008' of git://git.infradead.org/linux-mtd: (35 commits)
mtd: nand: fix trivial spelling error
mtdpart: Propagate _get/put_device()
mtd: nand: Provide nand_cleanup() function to free NAND related resources
mtd: Kill the OF_MTD Kconfig option
mtd: nand: mxc: Test CONFIG_OF instead of CONFIG_OF_MTD
mtd: nand: Fix nand_command_lp() for 8bits opcodes
mtd: nand: sunxi: Support ECC maximization
mtd: nand: Support maximizing ECC when using software BCH
mtd: nand: Add an option to maximize the ECC strength
mtd: nand: mxc: Add timing setup for v2 controllers
mtd: nand: mxc: implement onfi get/set features
mtd: nand: sunxi: switch from manual to automated timing config
mtd: nand: automate NAND timings selection
mtd: nand: Expose data interface for ONFI mode 0
mtd: nand: Add function to convert ONFI mode to data_interface
mtd: nand: convert ONFI mode into data interface
mtd: nand: Introduce nand_data_interface
mtd: nand: Create a NAND reset function
mtd: nand: remove unnecessary 'extern' from function declarations
MAINTAINERS: Add maintainer entry for Ingenic JZ4780 NAND driver
...

+1263 -459
+9
Documentation/devicetree/bindings/mtd/nand.txt
··· 35 35 - nand-ecc-step-size: integer representing the number of data bytes 36 36 that are covered by a single ECC step. 37 37 38 + - nand-ecc-maximize: boolean used to specify that you want to maximize ECC 39 + strength. The maximum ECC strength is both controller and 40 + chip dependent. The controller side has to select the ECC 41 + config providing the best strength and taking the OOB area 42 + size constraint into account. 43 + This is particularly useful when only the in-band area is 44 + used by the upper layers, and you want to make your NAND 45 + as reliable as possible. 46 + 38 47 The ECC strength and ECC step size properties define the correction capability 39 48 of a controller. Together, they say a controller can correct "{strength} bit 40 49 errors per {size} bytes".
+6
MAINTAINERS
··· 6142 6142 S: Maintained 6143 6143 F: drivers/dma/dma-jz4780.c 6144 6144 6145 + INGENIC JZ4780 NAND DRIVER 6146 + M: Harvey Hunt <harveyhuntnexus@gmail.com> 6147 + L: linux-mtd@lists.infradead.org 6148 + S: Maintained 6149 + F: drivers/mtd/nand/jz4780_* 6150 + 6145 6151 INTEGRITY MEASUREMENT ARCHITECTURE (IMA) 6146 6152 M: Mimi Zohar <zohar@linux.vnet.ibm.com> 6147 6153 M: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
+104
drivers/mtd/mtdcore.c
··· 376 376 } 377 377 378 378 /** 379 + * mtd_wunit_to_pairing_info - get pairing information of a wunit 380 + * @mtd: pointer to new MTD device info structure 381 + * @wunit: write unit we are interested in 382 + * @info: returned pairing information 383 + * 384 + * Retrieve pairing information associated to the wunit. 385 + * This is mainly useful when dealing with MLC/TLC NANDs where pages can be 386 + * paired together, and where programming a page may influence the page it is 387 + * paired with. 388 + * The notion of page is replaced by the term wunit (write-unit) to stay 389 + * consistent with the ->writesize field. 390 + * 391 + * The @wunit argument can be extracted from an absolute offset using 392 + * mtd_offset_to_wunit(). @info is filled with the pairing information attached 393 + * to @wunit. 394 + * 395 + * From the pairing info the MTD user can find all the wunits paired with 396 + * @wunit using the following loop: 397 + * 398 + * for (i = 0; i < mtd_pairing_groups(mtd); i++) { 399 + * info.pair = i; 400 + * mtd_pairing_info_to_wunit(mtd, &info); 401 + * ... 402 + * } 403 + */ 404 + int mtd_wunit_to_pairing_info(struct mtd_info *mtd, int wunit, 405 + struct mtd_pairing_info *info) 406 + { 407 + int npairs = mtd_wunit_per_eb(mtd) / mtd_pairing_groups(mtd); 408 + 409 + if (wunit < 0 || wunit >= npairs) 410 + return -EINVAL; 411 + 412 + if (mtd->pairing && mtd->pairing->get_info) 413 + return mtd->pairing->get_info(mtd, wunit, info); 414 + 415 + info->group = 0; 416 + info->pair = wunit; 417 + 418 + return 0; 419 + } 420 + EXPORT_SYMBOL_GPL(mtd_wunit_to_pairing_info); 421 + 422 + /** 423 + * mtd_wunit_to_pairing_info - get wunit from pairing information 424 + * @mtd: pointer to new MTD device info structure 425 + * @info: pairing information struct 426 + * 427 + * Returns a positive number representing the wunit associated to the info 428 + * struct, or a negative error code. 429 + * 430 + * This is the reverse of mtd_wunit_to_pairing_info(), and can help one to 431 + * iterate over all wunits of a given pair (see mtd_wunit_to_pairing_info() 432 + * doc). 433 + * 434 + * It can also be used to only program the first page of each pair (i.e. 435 + * page attached to group 0), which allows one to use an MLC NAND in 436 + * software-emulated SLC mode: 437 + * 438 + * info.group = 0; 439 + * npairs = mtd_wunit_per_eb(mtd) / mtd_pairing_groups(mtd); 440 + * for (info.pair = 0; info.pair < npairs; info.pair++) { 441 + * wunit = mtd_pairing_info_to_wunit(mtd, &info); 442 + * mtd_write(mtd, mtd_wunit_to_offset(mtd, blkoffs, wunit), 443 + * mtd->writesize, &retlen, buf + (i * mtd->writesize)); 444 + * } 445 + */ 446 + int mtd_pairing_info_to_wunit(struct mtd_info *mtd, 447 + const struct mtd_pairing_info *info) 448 + { 449 + int ngroups = mtd_pairing_groups(mtd); 450 + int npairs = mtd_wunit_per_eb(mtd) / ngroups; 451 + 452 + if (!info || info->pair < 0 || info->pair >= npairs || 453 + info->group < 0 || info->group >= ngroups) 454 + return -EINVAL; 455 + 456 + if (mtd->pairing && mtd->pairing->get_wunit) 457 + return mtd->pairing->get_wunit(mtd, info); 458 + 459 + return info->pair; 460 + } 461 + EXPORT_SYMBOL_GPL(mtd_pairing_info_to_wunit); 462 + 463 + /** 464 + * mtd_pairing_groups - get the number of pairing groups 465 + * @mtd: pointer to new MTD device info structure 466 + * 467 + * Returns the number of pairing groups. 468 + * 469 + * This number is usually equal to the number of bits exposed by a single 470 + * cell, and can be used in conjunction with mtd_pairing_info_to_wunit() 471 + * to iterate over all pages of a given pair. 472 + */ 473 + int mtd_pairing_groups(struct mtd_info *mtd) 474 + { 475 + if (!mtd->pairing || !mtd->pairing->ngroups) 476 + return 1; 477 + 478 + return mtd->pairing->ngroups; 479 + } 480 + EXPORT_SYMBOL_GPL(mtd_pairing_groups); 481 + 482 + /** 379 483 * add_mtd_device - register an MTD device 380 484 * @mtd: pointer to new MTD device info structure 381 485 *
+19
drivers/mtd/mtdpart.c
··· 317 317 return res; 318 318 } 319 319 320 + static int part_get_device(struct mtd_info *mtd) 321 + { 322 + struct mtd_part *part = mtd_to_part(mtd); 323 + return part->master->_get_device(part->master); 324 + } 325 + 326 + static void part_put_device(struct mtd_info *mtd) 327 + { 328 + struct mtd_part *part = mtd_to_part(mtd); 329 + part->master->_put_device(part->master); 330 + } 331 + 320 332 static int part_ooblayout_ecc(struct mtd_info *mtd, int section, 321 333 struct mtd_oob_region *oobregion) 322 334 { ··· 409 397 slave->mtd.oobsize = master->oobsize; 410 398 slave->mtd.oobavail = master->oobavail; 411 399 slave->mtd.subpage_sft = master->subpage_sft; 400 + slave->mtd.pairing = master->pairing; 412 401 413 402 slave->mtd.name = name; 414 403 slave->mtd.owner = master->owner; ··· 476 463 slave->mtd._block_isbad = part_block_isbad; 477 464 if (master->_block_markbad) 478 465 slave->mtd._block_markbad = part_block_markbad; 466 + 467 + if (master->_get_device) 468 + slave->mtd._get_device = part_get_device; 469 + if (master->_put_device) 470 + slave->mtd._put_device = part_put_device; 471 + 479 472 slave->mtd._erase = part_erase; 480 473 slave->master = master; 481 474 slave->offset = part->offset;
+6 -6
drivers/mtd/nand/Kconfig
··· 88 88 Support for NAND flash on Amstrad E3 (Delta). 89 89 90 90 config MTD_NAND_OMAP2 91 - tristate "NAND Flash device on OMAP2, OMAP3 and OMAP4" 92 - depends on ARCH_OMAP2PLUS 91 + tristate "NAND Flash device on OMAP2, OMAP3, OMAP4 and Keystone" 92 + depends on (ARCH_OMAP2PLUS || ARCH_KEYSTONE) 93 93 help 94 - Support for NAND flash on Texas Instruments OMAP2, OMAP3 and OMAP4 95 - platforms. 94 + Support for NAND flash on Texas Instruments OMAP2, OMAP3, OMAP4 95 + and Keystone platforms. 96 96 97 97 config MTD_NAND_OMAP_BCH 98 98 depends on MTD_NAND_OMAP2 ··· 428 428 429 429 config MTD_NAND_FSL_ELBC 430 430 tristate "NAND support for Freescale eLBC controllers" 431 - depends on PPC 431 + depends on FSL_SOC 432 432 select FSL_LBC 433 433 help 434 434 Various Freescale chips, including the 8313, include a NAND Flash ··· 438 438 439 439 config MTD_NAND_FSL_IFC 440 440 tristate "NAND support for Freescale IFC controller" 441 - depends on MTD_NAND && (FSL_SOC || ARCH_LAYERSCAPE) 441 + depends on FSL_SOC || ARCH_LAYERSCAPE 442 442 select FSL_IFC 443 443 select MEMORY 444 444 help
+1 -2
drivers/mtd/nand/bf5xx_nand.c
··· 761 761 762 762 platform_set_drvdata(pdev, info); 763 763 764 - spin_lock_init(&info->controller.lock); 765 - init_waitqueue_head(&info->controller.wq); 764 + nand_hw_control_init(&info->controller); 766 765 767 766 info->device = &pdev->dev; 768 767 info->platform = plat;
+7 -8
drivers/mtd/nand/brcmnand/brcmnand.c
··· 1336 1336 u32 *flash_cache = (u32 *)ctrl->flash_cache; 1337 1337 int i; 1338 1338 1339 - brcmnand_soc_data_bus_prepare(ctrl->soc); 1339 + brcmnand_soc_data_bus_prepare(ctrl->soc, true); 1340 1340 1341 1341 /* 1342 1342 * Must cache the FLASH_CACHE now, since changes in ··· 1349 1349 */ 1350 1350 flash_cache[i] = be32_to_cpu(brcmnand_read_fc(ctrl, i)); 1351 1351 1352 - brcmnand_soc_data_bus_unprepare(ctrl->soc); 1352 + brcmnand_soc_data_bus_unprepare(ctrl->soc, true); 1353 1353 1354 1354 /* Cleanup from HW quirk: restore SECTOR_SIZE_1K */ 1355 1355 if (host->hwcfg.sector_size_1k) ··· 1565 1565 brcmnand_waitfunc(mtd, chip); 1566 1566 1567 1567 if (likely(buf)) { 1568 - brcmnand_soc_data_bus_prepare(ctrl->soc); 1568 + brcmnand_soc_data_bus_prepare(ctrl->soc, false); 1569 1569 1570 1570 for (j = 0; j < FC_WORDS; j++, buf++) 1571 1571 *buf = brcmnand_read_fc(ctrl, j); 1572 1572 1573 - brcmnand_soc_data_bus_unprepare(ctrl->soc); 1573 + brcmnand_soc_data_bus_unprepare(ctrl->soc, false); 1574 1574 } 1575 1575 1576 1576 if (oob) ··· 1815 1815 (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS); 1816 1816 1817 1817 if (buf) { 1818 - brcmnand_soc_data_bus_prepare(ctrl->soc); 1818 + brcmnand_soc_data_bus_prepare(ctrl->soc, false); 1819 1819 1820 1820 for (j = 0; j < FC_WORDS; j++, buf++) 1821 1821 brcmnand_write_fc(ctrl, j, *buf); 1822 1822 1823 - brcmnand_soc_data_bus_unprepare(ctrl->soc); 1823 + brcmnand_soc_data_bus_unprepare(ctrl->soc, false); 1824 1824 } else if (oob) { 1825 1825 for (j = 0; j < FC_WORDS; j++) 1826 1826 brcmnand_write_fc(ctrl, j, 0xffffffff); ··· 2370 2370 2371 2371 init_completion(&ctrl->done); 2372 2372 init_completion(&ctrl->dma_done); 2373 - spin_lock_init(&ctrl->controller.lock); 2374 - init_waitqueue_head(&ctrl->controller.wq); 2373 + nand_hw_control_init(&ctrl->controller); 2375 2374 INIT_LIST_HEAD(&ctrl->host_list); 2376 2375 2377 2376 /* NAND register range */
+8 -5
drivers/mtd/nand/brcmnand/brcmnand.h
··· 23 23 struct brcmnand_soc { 24 24 bool (*ctlrdy_ack)(struct brcmnand_soc *soc); 25 25 void (*ctlrdy_set_enabled)(struct brcmnand_soc *soc, bool en); 26 - void (*prepare_data_bus)(struct brcmnand_soc *soc, bool prepare); 26 + void (*prepare_data_bus)(struct brcmnand_soc *soc, bool prepare, 27 + bool is_param); 27 28 }; 28 29 29 - static inline void brcmnand_soc_data_bus_prepare(struct brcmnand_soc *soc) 30 + static inline void brcmnand_soc_data_bus_prepare(struct brcmnand_soc *soc, 31 + bool is_param) 30 32 { 31 33 if (soc && soc->prepare_data_bus) 32 - soc->prepare_data_bus(soc, true); 34 + soc->prepare_data_bus(soc, true, is_param); 33 35 } 34 36 35 - static inline void brcmnand_soc_data_bus_unprepare(struct brcmnand_soc *soc) 37 + static inline void brcmnand_soc_data_bus_unprepare(struct brcmnand_soc *soc, 38 + bool is_param) 36 39 { 37 40 if (soc && soc->prepare_data_bus) 38 - soc->prepare_data_bus(soc, false); 41 + soc->prepare_data_bus(soc, false, is_param); 39 42 } 40 43 41 44 static inline u32 brcmnand_readl(void __iomem *addr)
+14 -4
drivers/mtd/nand/brcmnand/iproc_nand.c
··· 74 74 spin_unlock_irqrestore(&priv->idm_lock, flags); 75 75 } 76 76 77 - static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare) 77 + static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare, 78 + bool is_param) 78 79 { 79 80 struct iproc_nand_soc *priv = 80 81 container_of(soc, struct iproc_nand_soc, soc); ··· 87 86 88 87 val = brcmnand_readl(mmio); 89 88 90 - if (prepare) 91 - val |= IPROC_NAND_APB_LE_MODE; 92 - else 89 + /* 90 + * In the case of BE or when dealing with NAND data, alway configure 91 + * the APB bus to LE mode before accessing the FIFO and back to BE mode 92 + * after the access is done 93 + */ 94 + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) || !is_param) { 95 + if (prepare) 96 + val |= IPROC_NAND_APB_LE_MODE; 97 + else 98 + val &= ~IPROC_NAND_APB_LE_MODE; 99 + } else { /* when in LE accessing the parameter page, keep APB in BE */ 93 100 val &= ~IPROC_NAND_APB_LE_MODE; 101 + } 94 102 95 103 brcmnand_writel(val, mmio); 96 104
+1 -2
drivers/mtd/nand/docg4.c
··· 1249 1249 nand->options = NAND_BUSWIDTH_16 | NAND_NO_SUBPAGE_WRITE; 1250 1250 nand->IO_ADDR_R = nand->IO_ADDR_W = doc->virtadr + DOC_IOSPACE_DATA; 1251 1251 nand->controller = &nand->hwcontrol; 1252 - spin_lock_init(&nand->controller->lock); 1253 - init_waitqueue_head(&nand->controller->wq); 1252 + nand_hw_control_init(nand->controller); 1254 1253 1255 1254 /* methods */ 1256 1255 nand->cmdfunc = docg4_command;
+1 -2
drivers/mtd/nand/fsl_elbc_nand.c
··· 879 879 } 880 880 elbc_fcm_ctrl->counter++; 881 881 882 - spin_lock_init(&elbc_fcm_ctrl->controller.lock); 883 - init_waitqueue_head(&elbc_fcm_ctrl->controller.wq); 882 + nand_hw_control_init(&elbc_fcm_ctrl->controller); 884 883 fsl_lbc_ctrl_dev->nand = elbc_fcm_ctrl; 885 884 } else { 886 885 elbc_fcm_ctrl = fsl_lbc_ctrl_dev->nand;
+1 -2
drivers/mtd/nand/fsl_ifc_nand.c
··· 987 987 ifc_nand_ctrl->addr = NULL; 988 988 fsl_ifc_ctrl_dev->nand = ifc_nand_ctrl; 989 989 990 - spin_lock_init(&ifc_nand_ctrl->controller.lock); 991 - init_waitqueue_head(&ifc_nand_ctrl->controller.wq); 990 + nand_hw_control_init(&ifc_nand_ctrl->controller); 992 991 } else { 993 992 ifc_nand_ctrl = fsl_ifc_ctrl_dev->nand; 994 993 }
+2 -1
drivers/mtd/nand/gpmi-nand/gpmi-nand.c
··· 318 318 return -EINVAL; 319 319 } 320 320 321 - geo->page_size = mtd->writesize + mtd->oobsize; 321 + geo->page_size = mtd->writesize + geo->metadata_size + 322 + (geo->gf_len * geo->ecc_strength * geo->ecc_chunk_count) / 8; 322 323 geo->payload_size = mtd->writesize; 323 324 324 325 /*
+1 -2
drivers/mtd/nand/jz4780_nand.c
··· 368 368 nfc->dev = dev; 369 369 nfc->num_banks = num_banks; 370 370 371 - spin_lock_init(&nfc->controller.lock); 371 + nand_hw_control_init(&nfc->controller); 372 372 INIT_LIST_HEAD(&nfc->chips); 373 - init_waitqueue_head(&nfc->controller.wq); 374 373 375 374 ret = jz4780_nand_init_chips(nfc, pdev); 376 375 if (ret) {
+136 -1
drivers/mtd/nand/mxc_nand.c
··· 152 152 void (*select_chip)(struct mtd_info *mtd, int chip); 153 153 int (*correct_data)(struct mtd_info *mtd, u_char *dat, 154 154 u_char *read_ecc, u_char *calc_ecc); 155 + int (*setup_data_interface)(struct mtd_info *mtd, 156 + const struct nand_data_interface *conf, 157 + bool check_only); 155 158 156 159 /* 157 160 * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked ··· 1015 1012 writew(0x4, NFC_V1_V2_WRPROT); 1016 1013 } 1017 1014 1015 + static int mxc_nand_v2_setup_data_interface(struct mtd_info *mtd, 1016 + const struct nand_data_interface *conf, 1017 + bool check_only) 1018 + { 1019 + struct nand_chip *nand_chip = mtd_to_nand(mtd); 1020 + struct mxc_nand_host *host = nand_get_controller_data(nand_chip); 1021 + int tRC_min_ns, tRC_ps, ret; 1022 + unsigned long rate, rate_round; 1023 + const struct nand_sdr_timings *timings; 1024 + u16 config1; 1025 + 1026 + timings = nand_get_sdr_timings(conf); 1027 + if (IS_ERR(timings)) 1028 + return -ENOTSUPP; 1029 + 1030 + config1 = readw(NFC_V1_V2_CONFIG1); 1031 + 1032 + tRC_min_ns = timings->tRC_min / 1000; 1033 + rate = 1000000000 / tRC_min_ns; 1034 + 1035 + /* 1036 + * For tRC < 30ns we have to use EDO mode. In this case the controller 1037 + * does one access per clock cycle. Otherwise the controller does one 1038 + * access in two clock cycles, thus we have to double the rate to the 1039 + * controller. 1040 + */ 1041 + if (tRC_min_ns < 30) { 1042 + rate_round = clk_round_rate(host->clk, rate); 1043 + config1 |= NFC_V2_CONFIG1_ONE_CYCLE; 1044 + tRC_ps = 1000000000 / (rate_round / 1000); 1045 + } else { 1046 + rate *= 2; 1047 + rate_round = clk_round_rate(host->clk, rate); 1048 + config1 &= ~NFC_V2_CONFIG1_ONE_CYCLE; 1049 + tRC_ps = 1000000000 / (rate_round / 1000 / 2); 1050 + } 1051 + 1052 + /* 1053 + * The timing values compared against are from the i.MX25 Automotive 1054 + * datasheet, Table 50. NFC Timing Parameters 1055 + */ 1056 + if (timings->tCLS_min > tRC_ps - 1000 || 1057 + timings->tCLH_min > tRC_ps - 2000 || 1058 + timings->tCS_min > tRC_ps - 1000 || 1059 + timings->tCH_min > tRC_ps - 2000 || 1060 + timings->tWP_min > tRC_ps - 1500 || 1061 + timings->tALS_min > tRC_ps || 1062 + timings->tALH_min > tRC_ps - 3000 || 1063 + timings->tDS_min > tRC_ps || 1064 + timings->tDH_min > tRC_ps - 5000 || 1065 + timings->tWC_min > 2 * tRC_ps || 1066 + timings->tWH_min > tRC_ps - 2500 || 1067 + timings->tRR_min > 6 * tRC_ps || 1068 + timings->tRP_min > 3 * tRC_ps / 2 || 1069 + timings->tRC_min > 2 * tRC_ps || 1070 + timings->tREH_min > (tRC_ps / 2) - 2500) { 1071 + dev_dbg(host->dev, "Timing out of bounds\n"); 1072 + return -EINVAL; 1073 + } 1074 + 1075 + if (check_only) 1076 + return 0; 1077 + 1078 + ret = clk_set_rate(host->clk, rate); 1079 + if (ret) 1080 + return ret; 1081 + 1082 + writew(config1, NFC_V1_V2_CONFIG1); 1083 + 1084 + dev_dbg(host->dev, "Setting rate to %ldHz, %s mode\n", rate_round, 1085 + config1 & NFC_V2_CONFIG1_ONE_CYCLE ? "One cycle (EDO)" : 1086 + "normal"); 1087 + 1088 + return 0; 1089 + } 1090 + 1018 1091 static void preset_v2(struct mtd_info *mtd) 1019 1092 { 1020 1093 struct nand_chip *nand_chip = mtd_to_nand(mtd); ··· 1318 1239 } 1319 1240 } 1320 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 + host->devtype_data->send_cmd(host, NAND_CMD_GET_FEATURES, false); 1282 + mxc_do_addr_cycle(mtd, addr, -1); 1283 + host->devtype_data->send_page(mtd, NFC_OUTPUT); 1284 + memcpy32_fromio(host->data_buf, host->main_area0, 512); 1285 + host->buf_start = 0; 1286 + 1287 + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) 1288 + *subfeature_param++ = chip->read_byte(mtd); 1289 + 1290 + return 0; 1291 + } 1292 + 1321 1293 /* 1322 1294 * The generic flash bbt decriptors overlap with our ecc 1323 1295 * hardware, so define some i.MX specific ones. ··· 1457 1327 .ooblayout = &mxc_v2_ooblayout_ops, 1458 1328 .select_chip = mxc_nand_select_chip_v2, 1459 1329 .correct_data = mxc_nand_correct_data_v2_v3, 1330 + .setup_data_interface = mxc_nand_v2_setup_data_interface, 1460 1331 .irqpending_quirk = 0, 1461 1332 .needs_ip = 0, 1462 1333 .regs_offset = 0x1e00, ··· 1565 1434 }; 1566 1435 MODULE_DEVICE_TABLE(platform, mxcnd_devtype); 1567 1436 1568 - #ifdef CONFIG_OF_MTD 1437 + #ifdef CONFIG_OF 1569 1438 static const struct of_device_id mxcnd_dt_ids[] = { 1570 1439 { 1571 1440 .compatible = "fsl,imx21-nand", ··· 1644 1513 this->read_word = mxc_nand_read_word; 1645 1514 this->write_buf = mxc_nand_write_buf; 1646 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; 1647 1518 1648 1519 host->clk = devm_clk_get(&pdev->dev, NULL); 1649 1520 if (IS_ERR(host->clk)) ··· 1665 1532 } 1666 1533 if (err < 0) 1667 1534 return err; 1535 + 1536 + this->setup_data_interface = host->devtype_data->setup_data_interface; 1668 1537 1669 1538 if (host->devtype_data->needs_ip) { 1670 1539 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+234 -26
drivers/mtd/nand/nand_base.c
··· 745 745 column >>= 1; 746 746 chip->cmd_ctrl(mtd, column, ctrl); 747 747 ctrl &= ~NAND_CTRL_CHANGE; 748 - chip->cmd_ctrl(mtd, column >> 8, ctrl); 748 + 749 + /* Only output a single addr cycle for 8bits opcodes. */ 750 + if (!nand_opcode_8bits(command)) 751 + chip->cmd_ctrl(mtd, column >> 8, ctrl); 749 752 } 750 753 if (page_addr != -1) { 751 754 chip->cmd_ctrl(mtd, page_addr, ctrl); ··· 951 948 } 952 949 953 950 /** 951 + * nand_reset_data_interface - Reset data interface and timings 952 + * @chip: The NAND chip 953 + * 954 + * Reset the Data interface and timings to ONFI mode 0. 955 + * 956 + * Returns 0 for success or negative error code otherwise. 957 + */ 958 + static int nand_reset_data_interface(struct nand_chip *chip) 959 + { 960 + struct mtd_info *mtd = nand_to_mtd(chip); 961 + const struct nand_data_interface *conf; 962 + int ret; 963 + 964 + if (!chip->setup_data_interface) 965 + return 0; 966 + 967 + /* 968 + * The ONFI specification says: 969 + * " 970 + * To transition from NV-DDR or NV-DDR2 to the SDR data 971 + * interface, the host shall use the Reset (FFh) command 972 + * using SDR timing mode 0. A device in any timing mode is 973 + * required to recognize Reset (FFh) command issued in SDR 974 + * timing mode 0. 975 + * " 976 + * 977 + * Configure the data interface in SDR mode and set the 978 + * timings to timing mode 0. 979 + */ 980 + 981 + conf = nand_get_default_data_interface(); 982 + ret = chip->setup_data_interface(mtd, conf, false); 983 + if (ret) 984 + pr_err("Failed to configure data interface to SDR timing mode 0\n"); 985 + 986 + return ret; 987 + } 988 + 989 + /** 990 + * nand_setup_data_interface - Setup the best data interface and timings 991 + * @chip: The NAND chip 992 + * 993 + * Find and configure the best data interface and NAND timings supported by 994 + * the chip and the driver. 995 + * First tries to retrieve supported timing modes from ONFI information, 996 + * and if the NAND chip does not support ONFI, relies on the 997 + * ->onfi_timing_mode_default specified in the nand_ids table. 998 + * 999 + * Returns 0 for success or negative error code otherwise. 1000 + */ 1001 + static int nand_setup_data_interface(struct nand_chip *chip) 1002 + { 1003 + struct mtd_info *mtd = nand_to_mtd(chip); 1004 + int ret; 1005 + 1006 + if (!chip->setup_data_interface || !chip->data_interface) 1007 + return 0; 1008 + 1009 + /* 1010 + * Ensure the timing mode has been changed on the chip side 1011 + * before changing timings on the controller side. 1012 + */ 1013 + if (chip->onfi_version) { 1014 + u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { 1015 + chip->onfi_timing_mode_default, 1016 + }; 1017 + 1018 + ret = chip->onfi_set_features(mtd, chip, 1019 + ONFI_FEATURE_ADDR_TIMING_MODE, 1020 + tmode_param); 1021 + if (ret) 1022 + goto err; 1023 + } 1024 + 1025 + ret = chip->setup_data_interface(mtd, chip->data_interface, false); 1026 + err: 1027 + return ret; 1028 + } 1029 + 1030 + /** 1031 + * nand_init_data_interface - find the best data interface and timings 1032 + * @chip: The NAND chip 1033 + * 1034 + * Find the best data interface and NAND timings supported by the chip 1035 + * and the driver. 1036 + * First tries to retrieve supported timing modes from ONFI information, 1037 + * and if the NAND chip does not support ONFI, relies on the 1038 + * ->onfi_timing_mode_default specified in the nand_ids table. After this 1039 + * function nand_chip->data_interface is initialized with the best timing mode 1040 + * available. 1041 + * 1042 + * Returns 0 for success or negative error code otherwise. 1043 + */ 1044 + static int nand_init_data_interface(struct nand_chip *chip) 1045 + { 1046 + struct mtd_info *mtd = nand_to_mtd(chip); 1047 + int modes, mode, ret; 1048 + 1049 + if (!chip->setup_data_interface) 1050 + return 0; 1051 + 1052 + /* 1053 + * First try to identify the best timings from ONFI parameters and 1054 + * if the NAND does not support ONFI, fallback to the default ONFI 1055 + * timing mode. 1056 + */ 1057 + modes = onfi_get_async_timing_mode(chip); 1058 + if (modes == ONFI_TIMING_MODE_UNKNOWN) { 1059 + if (!chip->onfi_timing_mode_default) 1060 + return 0; 1061 + 1062 + modes = GENMASK(chip->onfi_timing_mode_default, 0); 1063 + } 1064 + 1065 + chip->data_interface = kzalloc(sizeof(*chip->data_interface), 1066 + GFP_KERNEL); 1067 + if (!chip->data_interface) 1068 + return -ENOMEM; 1069 + 1070 + for (mode = fls(modes) - 1; mode >= 0; mode--) { 1071 + ret = onfi_init_data_interface(chip, chip->data_interface, 1072 + NAND_SDR_IFACE, mode); 1073 + if (ret) 1074 + continue; 1075 + 1076 + ret = chip->setup_data_interface(mtd, chip->data_interface, 1077 + true); 1078 + if (!ret) { 1079 + chip->onfi_timing_mode_default = mode; 1080 + break; 1081 + } 1082 + } 1083 + 1084 + return 0; 1085 + } 1086 + 1087 + static void nand_release_data_interface(struct nand_chip *chip) 1088 + { 1089 + kfree(chip->data_interface); 1090 + } 1091 + 1092 + /** 1093 + * nand_reset - Reset and initialize a NAND device 1094 + * @chip: The NAND chip 1095 + * 1096 + * Returns 0 for success or negative error code otherwise 1097 + */ 1098 + int nand_reset(struct nand_chip *chip) 1099 + { 1100 + struct mtd_info *mtd = nand_to_mtd(chip); 1101 + int ret; 1102 + 1103 + ret = nand_reset_data_interface(chip); 1104 + if (ret) 1105 + return ret; 1106 + 1107 + chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 1108 + 1109 + ret = nand_setup_data_interface(chip); 1110 + if (ret) 1111 + return ret; 1112 + 1113 + return 0; 1114 + } 1115 + 1116 + /** 954 1117 * __nand_unlock - [REPLACEABLE] unlocks specified locked blocks 955 1118 * @mtd: mtd info 956 1119 * @ofs: offset to start unlock from ··· 1194 1025 * some operation can also clear the bit 7 of status register 1195 1026 * eg. erase/program a locked block 1196 1027 */ 1197 - chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 1028 + nand_reset(chip); 1198 1029 1199 1030 /* Check, if it is write protected */ 1200 1031 if (nand_check_wp(mtd)) { ··· 1253 1084 * some operation can also clear the bit 7 of status register 1254 1085 * eg. erase/program a locked block 1255 1086 */ 1256 - chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 1087 + nand_reset(chip); 1257 1088 1258 1089 /* Check, if it is write protected */ 1259 1090 if (nand_check_wp(mtd)) { ··· 2331 2162 static int nand_read_oob(struct mtd_info *mtd, loff_t from, 2332 2163 struct mtd_oob_ops *ops) 2333 2164 { 2334 - int ret = -ENOTSUPP; 2165 + int ret; 2335 2166 2336 2167 ops->retlen = 0; 2337 2168 ··· 2342 2173 return -EINVAL; 2343 2174 } 2344 2175 2176 + if (ops->mode != MTD_OPS_PLACE_OOB && 2177 + ops->mode != MTD_OPS_AUTO_OOB && 2178 + ops->mode != MTD_OPS_RAW) 2179 + return -ENOTSUPP; 2180 + 2345 2181 nand_get_device(mtd, FL_READING); 2346 - 2347 - switch (ops->mode) { 2348 - case MTD_OPS_PLACE_OOB: 2349 - case MTD_OPS_AUTO_OOB: 2350 - case MTD_OPS_RAW: 2351 - break; 2352 - 2353 - default: 2354 - goto out; 2355 - } 2356 2182 2357 2183 if (!ops->datbuf) 2358 2184 ret = nand_do_read_oob(mtd, from, ops); 2359 2185 else 2360 2186 ret = nand_do_read_ops(mtd, from, ops); 2361 2187 2362 - out: 2363 2188 nand_release_device(mtd); 2364 2189 return ret; 2365 2190 } ··· 2951 2788 * if we don't do this. I have no clue why, but I seem to have 'fixed' 2952 2789 * it in the doc2000 driver in August 1999. dwmw2. 2953 2790 */ 2954 - chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 2791 + nand_reset(chip); 2955 2792 2956 2793 /* Check, if it is write protected */ 2957 2794 if (nand_check_wp(mtd)) { ··· 3354 3191 3355 3192 if (!chip->controller) { 3356 3193 chip->controller = &chip->hwcontrol; 3357 - spin_lock_init(&chip->controller->lock); 3358 - init_waitqueue_head(&chip->controller->wq); 3194 + nand_hw_control_init(chip->controller); 3359 3195 } 3360 3196 3361 3197 } ··· 3991 3829 * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx) 3992 3830 * after power-up. 3993 3831 */ 3994 - chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 3832 + nand_reset(chip); 3995 3833 3996 3834 /* Send the command for reading device ID */ 3997 3835 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); ··· 4275 4113 if (ecc_step > 0) 4276 4114 chip->ecc.size = ecc_step; 4277 4115 4116 + if (of_property_read_bool(dn, "nand-ecc-maximize")) 4117 + chip->ecc.options |= NAND_ECC_MAXIMIZE; 4118 + 4278 4119 return 0; 4279 4120 } 4280 4121 ··· 4306 4141 if (!mtd->name && mtd->dev.parent) 4307 4142 mtd->name = dev_name(mtd->dev.parent); 4308 4143 4144 + if ((!chip->cmdfunc || !chip->select_chip) && !chip->cmd_ctrl) { 4145 + /* 4146 + * Default functions assigned for chip_select() and 4147 + * cmdfunc() both expect cmd_ctrl() to be populated, 4148 + * so we need to check that that's the case 4149 + */ 4150 + pr_err("chip.cmd_ctrl() callback is not provided"); 4151 + return -EINVAL; 4152 + } 4309 4153 /* Set the default functions */ 4310 4154 nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); 4311 4155 ··· 4329 4155 return PTR_ERR(type); 4330 4156 } 4331 4157 4158 + ret = nand_init_data_interface(chip); 4159 + if (ret) 4160 + return ret; 4161 + 4332 4162 chip->select_chip(mtd, -1); 4333 4163 4334 4164 /* Check for a chip array */ 4335 4165 for (i = 1; i < maxchips; i++) { 4336 4166 chip->select_chip(mtd, i); 4337 4167 /* See comment in nand_get_flash_type for reset */ 4338 - chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); 4168 + nand_reset(chip); 4339 4169 /* Send the command for reading device ID */ 4340 4170 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); 4341 4171 /* Read manufacturer and device IDs */ ··· 4399 4221 ecc->write_page_raw = nand_write_page_raw; 4400 4222 ecc->read_oob = nand_read_oob_std; 4401 4223 ecc->write_oob = nand_write_oob_std; 4224 + 4402 4225 /* 4403 4226 * Board driver should supply ecc.size and ecc.strength 4404 4227 * values to select how many bits are correctable. ··· 4422 4243 } 4423 4244 4424 4245 mtd_set_ooblayout(mtd, &nand_ooblayout_lp_ops); 4246 + 4247 + } 4248 + 4249 + /* 4250 + * We can only maximize ECC config when the default layout is 4251 + * used, otherwise we don't know how many bytes can really be 4252 + * used. 4253 + */ 4254 + if (mtd->ooblayout == &nand_ooblayout_lp_ops && 4255 + ecc->options & NAND_ECC_MAXIMIZE) { 4256 + int steps, bytes; 4257 + 4258 + /* Always prefer 1k blocks over 512bytes ones */ 4259 + ecc->size = 1024; 4260 + steps = mtd->writesize / ecc->size; 4261 + 4262 + /* Reserve 2 bytes for the BBM */ 4263 + bytes = (mtd->oobsize - 2) / steps; 4264 + ecc->strength = bytes * 8 / fls(8 * ecc->size); 4425 4265 } 4426 4266 4427 4267 /* See nand_bch_init() for details. */ ··· 4799 4601 EXPORT_SYMBOL(nand_scan); 4800 4602 4801 4603 /** 4802 - * nand_release - [NAND Interface] Free resources held by the NAND device 4803 - * @mtd: MTD device structure 4604 + * nand_cleanup - [NAND Interface] Free resources held by the NAND device 4605 + * @chip: NAND chip object 4804 4606 */ 4805 - void nand_release(struct mtd_info *mtd) 4607 + void nand_cleanup(struct nand_chip *chip) 4806 4608 { 4807 - struct nand_chip *chip = mtd_to_nand(mtd); 4808 - 4809 4609 if (chip->ecc.mode == NAND_ECC_SOFT && 4810 4610 chip->ecc.algo == NAND_ECC_BCH) 4811 4611 nand_bch_free((struct nand_bch_control *)chip->ecc.priv); 4812 4612 4813 - mtd_device_unregister(mtd); 4613 + nand_release_data_interface(chip); 4814 4614 4815 4615 /* Free bad block table memory */ 4816 4616 kfree(chip->bbt); ··· 4819 4623 if (chip->badblock_pattern && chip->badblock_pattern->options 4820 4624 & NAND_BBT_DYNAMICSTRUCT) 4821 4625 kfree(chip->badblock_pattern); 4626 + } 4627 + EXPORT_SYMBOL_GPL(nand_cleanup); 4628 + 4629 + /** 4630 + * nand_release - [NAND Interface] Unregister the MTD device and free resources 4631 + * held by the NAND device 4632 + * @mtd: MTD device structure 4633 + */ 4634 + void nand_release(struct mtd_info *mtd) 4635 + { 4636 + mtd_device_unregister(mtd); 4637 + nand_cleanup(mtd_to_nand(mtd)); 4822 4638 } 4823 4639 EXPORT_SYMBOL_GPL(nand_release); 4824 4640
+119 -42
drivers/mtd/nand/nand_bbt.c
··· 605 605 } 606 606 607 607 /** 608 + * get_bbt_block - Get the first valid eraseblock suitable to store a BBT 609 + * @this: the NAND device 610 + * @td: the BBT description 611 + * @md: the mirror BBT descriptor 612 + * @chip: the CHIP selector 613 + * 614 + * This functions returns a positive block number pointing a valid eraseblock 615 + * suitable to store a BBT (i.e. in the range reserved for BBT), or -ENOSPC if 616 + * all blocks are already used of marked bad. If td->pages[chip] was already 617 + * pointing to a valid block we re-use it, otherwise we search for the next 618 + * valid one. 619 + */ 620 + static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td, 621 + struct nand_bbt_descr *md, int chip) 622 + { 623 + int startblock, dir, page, numblocks, i; 624 + 625 + /* 626 + * There was already a version of the table, reuse the page. This 627 + * applies for absolute placement too, as we have the page number in 628 + * td->pages. 629 + */ 630 + if (td->pages[chip] != -1) 631 + return td->pages[chip] >> 632 + (this->bbt_erase_shift - this->page_shift); 633 + 634 + numblocks = (int)(this->chipsize >> this->bbt_erase_shift); 635 + if (!(td->options & NAND_BBT_PERCHIP)) 636 + numblocks *= this->numchips; 637 + 638 + /* 639 + * Automatic placement of the bad block table. Search direction 640 + * top -> down? 641 + */ 642 + if (td->options & NAND_BBT_LASTBLOCK) { 643 + startblock = numblocks * (chip + 1) - 1; 644 + dir = -1; 645 + } else { 646 + startblock = chip * numblocks; 647 + dir = 1; 648 + } 649 + 650 + for (i = 0; i < td->maxblocks; i++) { 651 + int block = startblock + dir * i; 652 + 653 + /* Check, if the block is bad */ 654 + switch (bbt_get_entry(this, block)) { 655 + case BBT_BLOCK_WORN: 656 + case BBT_BLOCK_FACTORY_BAD: 657 + continue; 658 + } 659 + 660 + page = block << (this->bbt_erase_shift - this->page_shift); 661 + 662 + /* Check, if the block is used by the mirror table */ 663 + if (!md || md->pages[chip] != page) 664 + return block; 665 + } 666 + 667 + return -ENOSPC; 668 + } 669 + 670 + /** 671 + * mark_bbt_block_bad - Mark one of the block reserved for BBT bad 672 + * @this: the NAND device 673 + * @td: the BBT description 674 + * @chip: the CHIP selector 675 + * @block: the BBT block to mark 676 + * 677 + * Blocks reserved for BBT can become bad. This functions is an helper to mark 678 + * such blocks as bad. It takes care of updating the in-memory BBT, marking the 679 + * block as bad using a bad block marker and invalidating the associated 680 + * td->pages[] entry. 681 + */ 682 + static void mark_bbt_block_bad(struct nand_chip *this, 683 + struct nand_bbt_descr *td, 684 + int chip, int block) 685 + { 686 + struct mtd_info *mtd = nand_to_mtd(this); 687 + loff_t to; 688 + int res; 689 + 690 + bbt_mark_entry(this, block, BBT_BLOCK_WORN); 691 + 692 + to = (loff_t)block << this->bbt_erase_shift; 693 + res = this->block_markbad(mtd, to); 694 + if (res) 695 + pr_warn("nand_bbt: error %d while marking block %d bad\n", 696 + res, block); 697 + 698 + td->pages[chip] = -1; 699 + } 700 + 701 + /** 608 702 * write_bbt - [GENERIC] (Re)write the bad block table 609 703 * @mtd: MTD device structure 610 704 * @buf: temporary buffer ··· 715 621 struct nand_chip *this = mtd_to_nand(mtd); 716 622 struct erase_info einfo; 717 623 int i, res, chip = 0; 718 - int bits, startblock, dir, page, offs, numblocks, sft, sftmsk; 624 + int bits, page, offs, numblocks, sft, sftmsk; 719 625 int nrchips, pageoffs, ooboffs; 720 626 uint8_t msk[4]; 721 627 uint8_t rcode = td->reserved_block_code; ··· 746 652 } 747 653 748 654 /* Loop through the chips */ 749 - for (; chip < nrchips; chip++) { 750 - /* 751 - * There was already a version of the table, reuse the page 752 - * This applies for absolute placement too, as we have the 753 - * page nr. in td->pages. 754 - */ 755 - if (td->pages[chip] != -1) { 756 - page = td->pages[chip]; 757 - goto write; 655 + while (chip < nrchips) { 656 + int block; 657 + 658 + block = get_bbt_block(this, td, md, chip); 659 + if (block < 0) { 660 + pr_err("No space left to write bad block table\n"); 661 + res = block; 662 + goto outerr; 758 663 } 759 664 760 665 /* 761 - * Automatic placement of the bad block table. Search direction 762 - * top -> down? 666 + * get_bbt_block() returns a block number, shift the value to 667 + * get a page number. 763 668 */ 764 - if (td->options & NAND_BBT_LASTBLOCK) { 765 - startblock = numblocks * (chip + 1) - 1; 766 - dir = -1; 767 - } else { 768 - startblock = chip * numblocks; 769 - dir = 1; 770 - } 771 - 772 - for (i = 0; i < td->maxblocks; i++) { 773 - int block = startblock + dir * i; 774 - /* Check, if the block is bad */ 775 - switch (bbt_get_entry(this, block)) { 776 - case BBT_BLOCK_WORN: 777 - case BBT_BLOCK_FACTORY_BAD: 778 - continue; 779 - } 780 - page = block << 781 - (this->bbt_erase_shift - this->page_shift); 782 - /* Check, if the block is used by the mirror table */ 783 - if (!md || md->pages[chip] != page) 784 - goto write; 785 - } 786 - pr_err("No space left to write bad block table\n"); 787 - return -ENOSPC; 788 - write: 669 + page = block << (this->bbt_erase_shift - this->page_shift); 789 670 790 671 /* Set up shift count and masks for the flash table */ 791 672 bits = td->options & NAND_BBT_NRBITS_MSK; ··· 856 787 einfo.addr = to; 857 788 einfo.len = 1 << this->bbt_erase_shift; 858 789 res = nand_erase_nand(mtd, &einfo, 1); 859 - if (res < 0) 860 - goto outerr; 790 + if (res < 0) { 791 + pr_warn("nand_bbt: error while erasing BBT block %d\n", 792 + res); 793 + mark_bbt_block_bad(this, td, chip, block); 794 + continue; 795 + } 861 796 862 797 res = scan_write_bbt(mtd, to, len, buf, 863 798 td->options & NAND_BBT_NO_OOB ? NULL : 864 799 &buf[len]); 865 - if (res < 0) 866 - goto outerr; 800 + if (res < 0) { 801 + pr_warn("nand_bbt: error while writing BBT block %d\n", 802 + res); 803 + mark_bbt_block_bad(this, td, chip, block); 804 + continue; 805 + } 867 806 868 807 pr_info("Bad block table written to 0x%012llx, version 0x%02X\n", 869 808 (unsigned long long)to, td->version[chip]); 870 809 871 810 /* Mark it as used */ 872 - td->pages[chip] = page; 811 + td->pages[chip++] = page; 873 812 } 874 813 return 0; 875 814
+264 -206
drivers/mtd/nand/nand_timings.c
··· 13 13 #include <linux/export.h> 14 14 #include <linux/mtd/nand.h> 15 15 16 - static const struct nand_sdr_timings onfi_sdr_timings[] = { 16 + static const struct nand_data_interface onfi_sdr_timings[] = { 17 17 /* Mode 0 */ 18 18 { 19 - .tADL_min = 200000, 20 - .tALH_min = 20000, 21 - .tALS_min = 50000, 22 - .tAR_min = 25000, 23 - .tCEA_max = 100000, 24 - .tCEH_min = 20000, 25 - .tCH_min = 20000, 26 - .tCHZ_max = 100000, 27 - .tCLH_min = 20000, 28 - .tCLR_min = 20000, 29 - .tCLS_min = 50000, 30 - .tCOH_min = 0, 31 - .tCS_min = 70000, 32 - .tDH_min = 20000, 33 - .tDS_min = 40000, 34 - .tFEAT_max = 1000000, 35 - .tIR_min = 10000, 36 - .tITC_max = 1000000, 37 - .tRC_min = 100000, 38 - .tREA_max = 40000, 39 - .tREH_min = 30000, 40 - .tRHOH_min = 0, 41 - .tRHW_min = 200000, 42 - .tRHZ_max = 200000, 43 - .tRLOH_min = 0, 44 - .tRP_min = 50000, 45 - .tRST_max = 250000000000ULL, 46 - .tWB_max = 200000, 47 - .tRR_min = 40000, 48 - .tWC_min = 100000, 49 - .tWH_min = 30000, 50 - .tWHR_min = 120000, 51 - .tWP_min = 50000, 52 - .tWW_min = 100000, 19 + .type = NAND_SDR_IFACE, 20 + .timings.sdr = { 21 + .tADL_min = 400000, 22 + .tALH_min = 20000, 23 + .tALS_min = 50000, 24 + .tAR_min = 25000, 25 + .tCEA_max = 100000, 26 + .tCEH_min = 20000, 27 + .tCH_min = 20000, 28 + .tCHZ_max = 100000, 29 + .tCLH_min = 20000, 30 + .tCLR_min = 20000, 31 + .tCLS_min = 50000, 32 + .tCOH_min = 0, 33 + .tCS_min = 70000, 34 + .tDH_min = 20000, 35 + .tDS_min = 40000, 36 + .tFEAT_max = 1000000, 37 + .tIR_min = 10000, 38 + .tITC_max = 1000000, 39 + .tRC_min = 100000, 40 + .tREA_max = 40000, 41 + .tREH_min = 30000, 42 + .tRHOH_min = 0, 43 + .tRHW_min = 200000, 44 + .tRHZ_max = 200000, 45 + .tRLOH_min = 0, 46 + .tRP_min = 50000, 47 + .tRR_min = 40000, 48 + .tRST_max = 250000000000ULL, 49 + .tWB_max = 200000, 50 + .tWC_min = 100000, 51 + .tWH_min = 30000, 52 + .tWHR_min = 120000, 53 + .tWP_min = 50000, 54 + .tWW_min = 100000, 55 + }, 53 56 }, 54 57 /* Mode 1 */ 55 58 { 56 - .tADL_min = 100000, 57 - .tALH_min = 10000, 58 - .tALS_min = 25000, 59 - .tAR_min = 10000, 60 - .tCEA_max = 45000, 61 - .tCEH_min = 20000, 62 - .tCH_min = 10000, 63 - .tCHZ_max = 50000, 64 - .tCLH_min = 10000, 65 - .tCLR_min = 10000, 66 - .tCLS_min = 25000, 67 - .tCOH_min = 15000, 68 - .tCS_min = 35000, 69 - .tDH_min = 10000, 70 - .tDS_min = 20000, 71 - .tFEAT_max = 1000000, 72 - .tIR_min = 0, 73 - .tITC_max = 1000000, 74 - .tRC_min = 50000, 75 - .tREA_max = 30000, 76 - .tREH_min = 15000, 77 - .tRHOH_min = 15000, 78 - .tRHW_min = 100000, 79 - .tRHZ_max = 100000, 80 - .tRLOH_min = 0, 81 - .tRP_min = 25000, 82 - .tRR_min = 20000, 83 - .tRST_max = 500000000, 84 - .tWB_max = 100000, 85 - .tWC_min = 45000, 86 - .tWH_min = 15000, 87 - .tWHR_min = 80000, 88 - .tWP_min = 25000, 89 - .tWW_min = 100000, 59 + .type = NAND_SDR_IFACE, 60 + .timings.sdr = { 61 + .tADL_min = 400000, 62 + .tALH_min = 10000, 63 + .tALS_min = 25000, 64 + .tAR_min = 10000, 65 + .tCEA_max = 45000, 66 + .tCEH_min = 20000, 67 + .tCH_min = 10000, 68 + .tCHZ_max = 50000, 69 + .tCLH_min = 10000, 70 + .tCLR_min = 10000, 71 + .tCLS_min = 25000, 72 + .tCOH_min = 15000, 73 + .tCS_min = 35000, 74 + .tDH_min = 10000, 75 + .tDS_min = 20000, 76 + .tFEAT_max = 1000000, 77 + .tIR_min = 0, 78 + .tITC_max = 1000000, 79 + .tRC_min = 50000, 80 + .tREA_max = 30000, 81 + .tREH_min = 15000, 82 + .tRHOH_min = 15000, 83 + .tRHW_min = 100000, 84 + .tRHZ_max = 100000, 85 + .tRLOH_min = 0, 86 + .tRP_min = 25000, 87 + .tRR_min = 20000, 88 + .tRST_max = 500000000, 89 + .tWB_max = 100000, 90 + .tWC_min = 45000, 91 + .tWH_min = 15000, 92 + .tWHR_min = 80000, 93 + .tWP_min = 25000, 94 + .tWW_min = 100000, 95 + }, 90 96 }, 91 97 /* Mode 2 */ 92 98 { 93 - .tADL_min = 100000, 94 - .tALH_min = 10000, 95 - .tALS_min = 15000, 96 - .tAR_min = 10000, 97 - .tCEA_max = 30000, 98 - .tCEH_min = 20000, 99 - .tCH_min = 10000, 100 - .tCHZ_max = 50000, 101 - .tCLH_min = 10000, 102 - .tCLR_min = 10000, 103 - .tCLS_min = 15000, 104 - .tCOH_min = 15000, 105 - .tCS_min = 25000, 106 - .tDH_min = 5000, 107 - .tDS_min = 15000, 108 - .tFEAT_max = 1000000, 109 - .tIR_min = 0, 110 - .tITC_max = 1000000, 111 - .tRC_min = 35000, 112 - .tREA_max = 25000, 113 - .tREH_min = 15000, 114 - .tRHOH_min = 15000, 115 - .tRHW_min = 100000, 116 - .tRHZ_max = 100000, 117 - .tRLOH_min = 0, 118 - .tRR_min = 20000, 119 - .tRST_max = 500000000, 120 - .tWB_max = 100000, 121 - .tRP_min = 17000, 122 - .tWC_min = 35000, 123 - .tWH_min = 15000, 124 - .tWHR_min = 80000, 125 - .tWP_min = 17000, 126 - .tWW_min = 100000, 99 + .type = NAND_SDR_IFACE, 100 + .timings.sdr = { 101 + .tADL_min = 400000, 102 + .tALH_min = 10000, 103 + .tALS_min = 15000, 104 + .tAR_min = 10000, 105 + .tCEA_max = 30000, 106 + .tCEH_min = 20000, 107 + .tCH_min = 10000, 108 + .tCHZ_max = 50000, 109 + .tCLH_min = 10000, 110 + .tCLR_min = 10000, 111 + .tCLS_min = 15000, 112 + .tCOH_min = 15000, 113 + .tCS_min = 25000, 114 + .tDH_min = 5000, 115 + .tDS_min = 15000, 116 + .tFEAT_max = 1000000, 117 + .tIR_min = 0, 118 + .tITC_max = 1000000, 119 + .tRC_min = 35000, 120 + .tREA_max = 25000, 121 + .tREH_min = 15000, 122 + .tRHOH_min = 15000, 123 + .tRHW_min = 100000, 124 + .tRHZ_max = 100000, 125 + .tRLOH_min = 0, 126 + .tRR_min = 20000, 127 + .tRST_max = 500000000, 128 + .tWB_max = 100000, 129 + .tRP_min = 17000, 130 + .tWC_min = 35000, 131 + .tWH_min = 15000, 132 + .tWHR_min = 80000, 133 + .tWP_min = 17000, 134 + .tWW_min = 100000, 135 + }, 127 136 }, 128 137 /* Mode 3 */ 129 138 { 130 - .tADL_min = 100000, 131 - .tALH_min = 5000, 132 - .tALS_min = 10000, 133 - .tAR_min = 10000, 134 - .tCEA_max = 25000, 135 - .tCEH_min = 20000, 136 - .tCH_min = 5000, 137 - .tCHZ_max = 50000, 138 - .tCLH_min = 5000, 139 - .tCLR_min = 10000, 140 - .tCLS_min = 10000, 141 - .tCOH_min = 15000, 142 - .tCS_min = 25000, 143 - .tDH_min = 5000, 144 - .tDS_min = 10000, 145 - .tFEAT_max = 1000000, 146 - .tIR_min = 0, 147 - .tITC_max = 1000000, 148 - .tRC_min = 30000, 149 - .tREA_max = 20000, 150 - .tREH_min = 10000, 151 - .tRHOH_min = 15000, 152 - .tRHW_min = 100000, 153 - .tRHZ_max = 100000, 154 - .tRLOH_min = 0, 155 - .tRP_min = 15000, 156 - .tRR_min = 20000, 157 - .tRST_max = 500000000, 158 - .tWB_max = 100000, 159 - .tWC_min = 30000, 160 - .tWH_min = 10000, 161 - .tWHR_min = 80000, 162 - .tWP_min = 15000, 163 - .tWW_min = 100000, 139 + .type = NAND_SDR_IFACE, 140 + .timings.sdr = { 141 + .tADL_min = 400000, 142 + .tALH_min = 5000, 143 + .tALS_min = 10000, 144 + .tAR_min = 10000, 145 + .tCEA_max = 25000, 146 + .tCEH_min = 20000, 147 + .tCH_min = 5000, 148 + .tCHZ_max = 50000, 149 + .tCLH_min = 5000, 150 + .tCLR_min = 10000, 151 + .tCLS_min = 10000, 152 + .tCOH_min = 15000, 153 + .tCS_min = 25000, 154 + .tDH_min = 5000, 155 + .tDS_min = 10000, 156 + .tFEAT_max = 1000000, 157 + .tIR_min = 0, 158 + .tITC_max = 1000000, 159 + .tRC_min = 30000, 160 + .tREA_max = 20000, 161 + .tREH_min = 10000, 162 + .tRHOH_min = 15000, 163 + .tRHW_min = 100000, 164 + .tRHZ_max = 100000, 165 + .tRLOH_min = 0, 166 + .tRP_min = 15000, 167 + .tRR_min = 20000, 168 + .tRST_max = 500000000, 169 + .tWB_max = 100000, 170 + .tWC_min = 30000, 171 + .tWH_min = 10000, 172 + .tWHR_min = 80000, 173 + .tWP_min = 15000, 174 + .tWW_min = 100000, 175 + }, 164 176 }, 165 177 /* Mode 4 */ 166 178 { 167 - .tADL_min = 70000, 168 - .tALH_min = 5000, 169 - .tALS_min = 10000, 170 - .tAR_min = 10000, 171 - .tCEA_max = 25000, 172 - .tCEH_min = 20000, 173 - .tCH_min = 5000, 174 - .tCHZ_max = 30000, 175 - .tCLH_min = 5000, 176 - .tCLR_min = 10000, 177 - .tCLS_min = 10000, 178 - .tCOH_min = 15000, 179 - .tCS_min = 20000, 180 - .tDH_min = 5000, 181 - .tDS_min = 10000, 182 - .tFEAT_max = 1000000, 183 - .tIR_min = 0, 184 - .tITC_max = 1000000, 185 - .tRC_min = 25000, 186 - .tREA_max = 20000, 187 - .tREH_min = 10000, 188 - .tRHOH_min = 15000, 189 - .tRHW_min = 100000, 190 - .tRHZ_max = 100000, 191 - .tRLOH_min = 5000, 192 - .tRP_min = 12000, 193 - .tRR_min = 20000, 194 - .tRST_max = 500000000, 195 - .tWB_max = 100000, 196 - .tWC_min = 25000, 197 - .tWH_min = 10000, 198 - .tWHR_min = 80000, 199 - .tWP_min = 12000, 200 - .tWW_min = 100000, 179 + .type = NAND_SDR_IFACE, 180 + .timings.sdr = { 181 + .tADL_min = 400000, 182 + .tALH_min = 5000, 183 + .tALS_min = 10000, 184 + .tAR_min = 10000, 185 + .tCEA_max = 25000, 186 + .tCEH_min = 20000, 187 + .tCH_min = 5000, 188 + .tCHZ_max = 30000, 189 + .tCLH_min = 5000, 190 + .tCLR_min = 10000, 191 + .tCLS_min = 10000, 192 + .tCOH_min = 15000, 193 + .tCS_min = 20000, 194 + .tDH_min = 5000, 195 + .tDS_min = 10000, 196 + .tFEAT_max = 1000000, 197 + .tIR_min = 0, 198 + .tITC_max = 1000000, 199 + .tRC_min = 25000, 200 + .tREA_max = 20000, 201 + .tREH_min = 10000, 202 + .tRHOH_min = 15000, 203 + .tRHW_min = 100000, 204 + .tRHZ_max = 100000, 205 + .tRLOH_min = 5000, 206 + .tRP_min = 12000, 207 + .tRR_min = 20000, 208 + .tRST_max = 500000000, 209 + .tWB_max = 100000, 210 + .tWC_min = 25000, 211 + .tWH_min = 10000, 212 + .tWHR_min = 80000, 213 + .tWP_min = 12000, 214 + .tWW_min = 100000, 215 + }, 201 216 }, 202 217 /* Mode 5 */ 203 218 { 204 - .tADL_min = 70000, 205 - .tALH_min = 5000, 206 - .tALS_min = 10000, 207 - .tAR_min = 10000, 208 - .tCEA_max = 25000, 209 - .tCEH_min = 20000, 210 - .tCH_min = 5000, 211 - .tCHZ_max = 30000, 212 - .tCLH_min = 5000, 213 - .tCLR_min = 10000, 214 - .tCLS_min = 10000, 215 - .tCOH_min = 15000, 216 - .tCS_min = 15000, 217 - .tDH_min = 5000, 218 - .tDS_min = 7000, 219 - .tFEAT_max = 1000000, 220 - .tIR_min = 0, 221 - .tITC_max = 1000000, 222 - .tRC_min = 20000, 223 - .tREA_max = 16000, 224 - .tREH_min = 7000, 225 - .tRHOH_min = 15000, 226 - .tRHW_min = 100000, 227 - .tRHZ_max = 100000, 228 - .tRLOH_min = 5000, 229 - .tRP_min = 10000, 230 - .tRR_min = 20000, 231 - .tRST_max = 500000000, 232 - .tWB_max = 100000, 233 - .tWC_min = 20000, 234 - .tWH_min = 7000, 235 - .tWHR_min = 80000, 236 - .tWP_min = 10000, 237 - .tWW_min = 100000, 219 + .type = NAND_SDR_IFACE, 220 + .timings.sdr = { 221 + .tADL_min = 400000, 222 + .tALH_min = 5000, 223 + .tALS_min = 10000, 224 + .tAR_min = 10000, 225 + .tCEA_max = 25000, 226 + .tCEH_min = 20000, 227 + .tCH_min = 5000, 228 + .tCHZ_max = 30000, 229 + .tCLH_min = 5000, 230 + .tCLR_min = 10000, 231 + .tCLS_min = 10000, 232 + .tCOH_min = 15000, 233 + .tCS_min = 15000, 234 + .tDH_min = 5000, 235 + .tDS_min = 7000, 236 + .tFEAT_max = 1000000, 237 + .tIR_min = 0, 238 + .tITC_max = 1000000, 239 + .tRC_min = 20000, 240 + .tREA_max = 16000, 241 + .tREH_min = 7000, 242 + .tRHOH_min = 15000, 243 + .tRHW_min = 100000, 244 + .tRHZ_max = 100000, 245 + .tRLOH_min = 5000, 246 + .tRP_min = 10000, 247 + .tRR_min = 20000, 248 + .tRST_max = 500000000, 249 + .tWB_max = 100000, 250 + .tWC_min = 20000, 251 + .tWH_min = 7000, 252 + .tWHR_min = 80000, 253 + .tWP_min = 10000, 254 + .tWW_min = 100000, 255 + }, 238 256 }, 239 257 }; 240 258 ··· 266 248 if (mode < 0 || mode >= ARRAY_SIZE(onfi_sdr_timings)) 267 249 return ERR_PTR(-EINVAL); 268 250 269 - return &onfi_sdr_timings[mode]; 251 + return &onfi_sdr_timings[mode].timings.sdr; 270 252 } 271 253 EXPORT_SYMBOL(onfi_async_timing_mode_to_sdr_timings); 254 + 255 + /** 256 + * onfi_init_data_interface - [NAND Interface] Initialize a data interface from 257 + * given ONFI mode 258 + * @iface: The data interface to be initialized 259 + * @mode: The ONFI timing mode 260 + */ 261 + int onfi_init_data_interface(struct nand_chip *chip, 262 + struct nand_data_interface *iface, 263 + enum nand_data_interface_type type, 264 + int timing_mode) 265 + { 266 + if (type != NAND_SDR_IFACE) 267 + return -EINVAL; 268 + 269 + if (timing_mode < 0 || timing_mode >= ARRAY_SIZE(onfi_sdr_timings)) 270 + return -EINVAL; 271 + 272 + *iface = onfi_sdr_timings[timing_mode]; 273 + 274 + /* 275 + * TODO: initialize timings that cannot be deduced from timing mode: 276 + * tR, tPROG, tCCS, ... 277 + * These information are part of the ONFI parameter page. 278 + */ 279 + 280 + return 0; 281 + } 282 + EXPORT_SYMBOL(onfi_init_data_interface); 283 + 284 + /** 285 + * nand_get_default_data_interface - [NAND Interface] Retrieve NAND 286 + * data interface for mode 0. This is used as default timing after 287 + * reset. 288 + */ 289 + const struct nand_data_interface *nand_get_default_data_interface(void) 290 + { 291 + return &onfi_sdr_timings[0]; 292 + } 293 + EXPORT_SYMBOL(nand_get_default_data_interface);
+1 -2
drivers/mtd/nand/ndfc.c
··· 218 218 ndfc = &ndfc_ctrl[cs]; 219 219 ndfc->chip_select = cs; 220 220 221 - spin_lock_init(&ndfc->ndfc_control.lock); 222 - init_waitqueue_head(&ndfc->ndfc_control.wq); 221 + nand_hw_control_init(&ndfc->ndfc_control); 223 222 ndfc->ofdev = ofdev; 224 223 dev_set_drvdata(&ofdev->dev, ndfc); 225 224
+1 -2
drivers/mtd/nand/pxa3xx_nand.c
··· 1810 1810 chip->cmdfunc = nand_cmdfunc; 1811 1811 } 1812 1812 1813 - spin_lock_init(&chip->controller->lock); 1814 - init_waitqueue_head(&chip->controller->wq); 1813 + nand_hw_control_init(chip->controller); 1815 1814 info->clk = devm_clk_get(&pdev->dev, NULL); 1816 1815 if (IS_ERR(info->clk)) { 1817 1816 dev_err(&pdev->dev, "failed to get nand clock\n");
+1 -2
drivers/mtd/nand/qcom_nandc.c
··· 1957 1957 INIT_LIST_HEAD(&nandc->desc_list); 1958 1958 INIT_LIST_HEAD(&nandc->host_list); 1959 1959 1960 - spin_lock_init(&nandc->controller.lock); 1961 - init_waitqueue_head(&nandc->controller.wq); 1960 + nand_hw_control_init(&nandc->controller); 1962 1961 1963 1962 return 0; 1964 1963 }
+3 -4
drivers/mtd/nand/s3c2410.c
··· 180 180 181 181 enum s3c_cpu_type cpu_type; 182 182 183 - #ifdef CONFIG_CPU_FREQ 183 + #ifdef CONFIG_ARM_S3C24XX_CPUFREQ 184 184 struct notifier_block freq_transition; 185 185 #endif 186 186 }; ··· 701 701 702 702 /* cpufreq driver support */ 703 703 704 - #ifdef CONFIG_CPU_FREQ 704 + #ifdef CONFIG_ARM_S3C24XX_CPUFREQ 705 705 706 706 static int s3c2410_nand_cpufreq_transition(struct notifier_block *nb, 707 707 unsigned long val, void *data) ··· 977 977 978 978 platform_set_drvdata(pdev, info); 979 979 980 - spin_lock_init(&info->controller.lock); 981 - init_waitqueue_head(&info->controller.wq); 980 + nand_hw_control_init(&info->controller); 982 981 983 982 /* get the clock source and enable it */ 984 983
+7 -1
drivers/mtd/nand/sh_flctl.c
··· 397 397 struct dma_chan *chan; 398 398 enum dma_transfer_direction tr_dir; 399 399 dma_addr_t dma_addr; 400 - dma_cookie_t cookie = -EINVAL; 400 + dma_cookie_t cookie; 401 401 uint32_t reg; 402 402 int ret; 403 403 ··· 423 423 desc->callback = flctl_dma_complete; 424 424 desc->callback_param = flctl; 425 425 cookie = dmaengine_submit(desc); 426 + if (dma_submit_error(cookie)) { 427 + ret = dma_submit_error(cookie); 428 + dev_warn(&flctl->pdev->dev, 429 + "DMA submit failed, falling back to PIO\n"); 430 + goto out; 431 + } 426 432 427 433 dma_async_issue_pending(chan); 428 434 } else {
+44 -64
drivers/mtd/nand/sunxi_nand.c
··· 1572 1572 #define sunxi_nand_lookup_timing(l, p, c) \ 1573 1573 _sunxi_nand_lookup_timing(l, ARRAY_SIZE(l), p, c) 1574 1574 1575 - static int sunxi_nand_chip_set_timings(struct sunxi_nand_chip *chip, 1576 - const struct nand_sdr_timings *timings) 1575 + static int sunxi_nfc_setup_data_interface(struct mtd_info *mtd, 1576 + const struct nand_data_interface *conf, 1577 + bool check_only) 1577 1578 { 1579 + struct nand_chip *nand = mtd_to_nand(mtd); 1580 + struct sunxi_nand_chip *chip = to_sunxi_nand(nand); 1578 1581 struct sunxi_nfc *nfc = to_sunxi_nfc(chip->nand.controller); 1582 + const struct nand_sdr_timings *timings; 1579 1583 u32 min_clk_period = 0; 1580 1584 s32 tWB, tADL, tWHR, tRHW, tCAD; 1581 1585 long real_clk_rate; 1586 + 1587 + timings = nand_get_sdr_timings(conf); 1588 + if (IS_ERR(timings)) 1589 + return -ENOTSUPP; 1582 1590 1583 1591 /* T1 <=> tCLS */ 1584 1592 if (timings->tCLS_min > min_clk_period) ··· 1687 1679 return tRHW; 1688 1680 } 1689 1681 1682 + if (check_only) 1683 + return 0; 1684 + 1690 1685 /* 1691 1686 * TODO: according to ONFI specs this value only applies for DDR NAND, 1692 1687 * but Allwinner seems to set this to 0x7. Mimic them for now. ··· 1721 1710 NFC_TIMING_CTL_EDO : 0; 1722 1711 1723 1712 return 0; 1724 - } 1725 - 1726 - static int sunxi_nand_chip_init_timings(struct sunxi_nand_chip *chip, 1727 - struct device_node *np) 1728 - { 1729 - struct mtd_info *mtd = nand_to_mtd(&chip->nand); 1730 - const struct nand_sdr_timings *timings; 1731 - int ret; 1732 - int mode; 1733 - 1734 - mode = onfi_get_async_timing_mode(&chip->nand); 1735 - if (mode == ONFI_TIMING_MODE_UNKNOWN) { 1736 - mode = chip->nand.onfi_timing_mode_default; 1737 - } else { 1738 - uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {}; 1739 - int i; 1740 - 1741 - mode = fls(mode) - 1; 1742 - if (mode < 0) 1743 - mode = 0; 1744 - 1745 - feature[0] = mode; 1746 - for (i = 0; i < chip->nsels; i++) { 1747 - chip->nand.select_chip(mtd, i); 1748 - ret = chip->nand.onfi_set_features(mtd, &chip->nand, 1749 - ONFI_FEATURE_ADDR_TIMING_MODE, 1750 - feature); 1751 - chip->nand.select_chip(mtd, -1); 1752 - if (ret) 1753 - return ret; 1754 - } 1755 - } 1756 - 1757 - timings = onfi_async_timing_mode_to_sdr_timings(mode); 1758 - if (IS_ERR(timings)) 1759 - return PTR_ERR(timings); 1760 - 1761 - return sunxi_nand_chip_set_timings(chip, timings); 1762 1713 } 1763 1714 1764 1715 static int sunxi_nand_ooblayout_ecc(struct mtd_info *mtd, int section, ··· 1786 1813 int nsectors; 1787 1814 int ret; 1788 1815 int i; 1816 + 1817 + if (ecc->options & NAND_ECC_MAXIMIZE) { 1818 + int bytes; 1819 + 1820 + ecc->size = 1024; 1821 + nsectors = mtd->writesize / ecc->size; 1822 + 1823 + /* Reserve 2 bytes for the BBM */ 1824 + bytes = (mtd->oobsize - 2) / nsectors; 1825 + 1826 + /* 4 non-ECC bytes are added before each ECC bytes section */ 1827 + bytes -= 4; 1828 + 1829 + /* and bytes has to be even. */ 1830 + if (bytes % 2) 1831 + bytes--; 1832 + 1833 + ecc->strength = bytes * 8 / fls(8 * ecc->size); 1834 + 1835 + for (i = 0; i < ARRAY_SIZE(strengths); i++) { 1836 + if (strengths[i] > ecc->strength) 1837 + break; 1838 + } 1839 + 1840 + if (!i) 1841 + ecc->strength = 0; 1842 + else 1843 + ecc->strength = strengths[i - 1]; 1844 + } 1789 1845 1790 1846 if (ecc->size != 512 && ecc->size != 1024) 1791 1847 return -EINVAL; ··· 1977 1975 static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, 1978 1976 struct device_node *np) 1979 1977 { 1980 - const struct nand_sdr_timings *timings; 1981 1978 struct sunxi_nand_chip *chip; 1982 1979 struct mtd_info *mtd; 1983 1980 struct nand_chip *nand; ··· 2066 2065 nand->read_buf = sunxi_nfc_read_buf; 2067 2066 nand->write_buf = sunxi_nfc_write_buf; 2068 2067 nand->read_byte = sunxi_nfc_read_byte; 2068 + nand->setup_data_interface = sunxi_nfc_setup_data_interface; 2069 2069 2070 2070 mtd = nand_to_mtd(nand); 2071 2071 mtd->dev.parent = dev; 2072 - 2073 - timings = onfi_async_timing_mode_to_sdr_timings(0); 2074 - if (IS_ERR(timings)) { 2075 - ret = PTR_ERR(timings); 2076 - dev_err(dev, 2077 - "could not retrieve timings for ONFI mode 0: %d\n", 2078 - ret); 2079 - return ret; 2080 - } 2081 - 2082 - ret = sunxi_nand_chip_set_timings(chip, timings); 2083 - if (ret) { 2084 - dev_err(dev, "could not configure chip timings: %d\n", ret); 2085 - return ret; 2086 - } 2087 2072 2088 2073 ret = nand_scan_ident(mtd, nsels, NULL); 2089 2074 if (ret) ··· 2082 2095 nand->options |= NAND_NO_SUBPAGE_WRITE; 2083 2096 2084 2097 nand->options |= NAND_SUBPAGE_READ; 2085 - 2086 - ret = sunxi_nand_chip_init_timings(chip, np); 2087 - if (ret) { 2088 - dev_err(dev, "could not configure chip timings: %d\n", ret); 2089 - return ret; 2090 - } 2091 2098 2092 2099 ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); 2093 2100 if (ret) { ··· 2156 2175 return -ENOMEM; 2157 2176 2158 2177 nfc->dev = dev; 2159 - spin_lock_init(&nfc->controller.lock); 2160 - init_waitqueue_head(&nfc->controller.wq); 2178 + nand_hw_control_init(&nfc->controller); 2161 2179 INIT_LIST_HEAD(&nfc->chips); 2162 2180 2163 2181 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+1 -2
drivers/mtd/nand/txx9ndfmc.c
··· 303 303 dev_info(&dev->dev, "CLK:%ldMHz HOLD:%d SPW:%d\n", 304 304 (gbusclk + 500000) / 1000000, hold, spw); 305 305 306 - spin_lock_init(&drvdata->hw_control.lock); 307 - init_waitqueue_head(&drvdata->hw_control.wq); 306 + nand_hw_control_init(&drvdata->hw_control); 308 307 309 308 platform_set_drvdata(dev, drvdata); 310 309 txx9ndfmc_initialize(dev);
-4
drivers/of/Kconfig
··· 90 90 help 91 91 OpenFirmware PCI IRQ routing helpers 92 92 93 - config OF_MTD 94 - depends on MTD 95 - def_bool y 96 - 97 93 config OF_RESERVED_MEM 98 94 depends on OF_EARLY_FLATTREE 99 95 bool
+107
include/linux/mtd/mtd.h
··· 127 127 struct mtd_oob_region *oobfree); 128 128 }; 129 129 130 + /** 131 + * struct mtd_pairing_info - page pairing information 132 + * 133 + * @pair: pair id 134 + * @group: group id 135 + * 136 + * The term "pair" is used here, even though TLC NANDs might group pages by 3 137 + * (3 bits in a single cell). A pair should regroup all pages that are sharing 138 + * the same cell. Pairs are then indexed in ascending order. 139 + * 140 + * @group is defining the position of a page in a given pair. It can also be 141 + * seen as the bit position in the cell: page attached to bit 0 belongs to 142 + * group 0, page attached to bit 1 belongs to group 1, etc. 143 + * 144 + * Example: 145 + * The H27UCG8T2BTR-BC datasheet describes the following pairing scheme: 146 + * 147 + * group-0 group-1 148 + * 149 + * pair-0 page-0 page-4 150 + * pair-1 page-1 page-5 151 + * pair-2 page-2 page-8 152 + * ... 153 + * pair-127 page-251 page-255 154 + * 155 + * 156 + * Note that the "group" and "pair" terms were extracted from Samsung and 157 + * Hynix datasheets, and might be referenced under other names in other 158 + * datasheets (Micron is describing this concept as "shared pages"). 159 + */ 160 + struct mtd_pairing_info { 161 + int pair; 162 + int group; 163 + }; 164 + 165 + /** 166 + * struct mtd_pairing_scheme - page pairing scheme description 167 + * 168 + * @ngroups: number of groups. Should be related to the number of bits 169 + * per cell. 170 + * @get_info: converts a write-unit (page number within an erase block) into 171 + * mtd_pairing information (pair + group). This function should 172 + * fill the info parameter based on the wunit index or return 173 + * -EINVAL if the wunit parameter is invalid. 174 + * @get_wunit: converts pairing information into a write-unit (page) number. 175 + * This function should return the wunit index pointed by the 176 + * pairing information described in the info argument. It should 177 + * return -EINVAL, if there's no wunit corresponding to the 178 + * passed pairing information. 179 + * 180 + * See mtd_pairing_info documentation for a detailed explanation of the 181 + * pair and group concepts. 182 + * 183 + * The mtd_pairing_scheme structure provides a generic solution to represent 184 + * NAND page pairing scheme. Instead of exposing two big tables to do the 185 + * write-unit <-> (pair + group) conversions, we ask the MTD drivers to 186 + * implement the ->get_info() and ->get_wunit() functions. 187 + * 188 + * MTD users will then be able to query these information by using the 189 + * mtd_pairing_info_to_wunit() and mtd_wunit_to_pairing_info() helpers. 190 + * 191 + * @ngroups is here to help MTD users iterating over all the pages in a 192 + * given pair. This value can be retrieved by MTD users using the 193 + * mtd_pairing_groups() helper. 194 + * 195 + * Examples are given in the mtd_pairing_info_to_wunit() and 196 + * mtd_wunit_to_pairing_info() documentation. 197 + */ 198 + struct mtd_pairing_scheme { 199 + int ngroups; 200 + int (*get_info)(struct mtd_info *mtd, int wunit, 201 + struct mtd_pairing_info *info); 202 + int (*get_wunit)(struct mtd_info *mtd, 203 + const struct mtd_pairing_info *info); 204 + }; 205 + 130 206 struct module; /* only needed for owner field in mtd_info */ 131 207 132 208 struct mtd_info { ··· 263 187 264 188 /* OOB layout description */ 265 189 const struct mtd_ooblayout_ops *ooblayout; 190 + 191 + /* NAND pairing scheme, only provided for MLC/TLC NANDs */ 192 + const struct mtd_pairing_scheme *pairing; 266 193 267 194 /* the ecc step size. */ 268 195 unsigned int ecc_step_size; ··· 375 296 mtd->ooblayout = ooblayout; 376 297 } 377 298 299 + static inline void mtd_set_pairing_scheme(struct mtd_info *mtd, 300 + const struct mtd_pairing_scheme *pairing) 301 + { 302 + mtd->pairing = pairing; 303 + } 304 + 378 305 static inline void mtd_set_of_node(struct mtd_info *mtd, 379 306 struct device_node *np) 380 307 { ··· 397 312 return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; 398 313 } 399 314 315 + int mtd_wunit_to_pairing_info(struct mtd_info *mtd, int wunit, 316 + struct mtd_pairing_info *info); 317 + int mtd_pairing_info_to_wunit(struct mtd_info *mtd, 318 + const struct mtd_pairing_info *info); 319 + int mtd_pairing_groups(struct mtd_info *mtd); 400 320 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); 401 321 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, 402 322 void **virt, resource_size_t *phys); ··· 486 396 return sz & mtd->writesize_mask; 487 397 return do_div(sz, mtd->writesize); 488 398 } 399 + 400 + static inline int mtd_wunit_per_eb(struct mtd_info *mtd) 401 + { 402 + return mtd->erasesize / mtd->writesize; 403 + } 404 + 405 + static inline int mtd_offset_to_wunit(struct mtd_info *mtd, loff_t offs) 406 + { 407 + return mtd_div_by_ws(mtd_mod_by_eb(offs, mtd), mtd); 408 + } 409 + 410 + static inline loff_t mtd_wunit_to_offset(struct mtd_info *mtd, loff_t base, 411 + int wunit) 412 + { 413 + return base + (wunit * mtd->writesize); 414 + } 415 + 489 416 490 417 static inline int mtd_has_oob(const struct mtd_info *mtd) 491 418 {
+165 -69
include/linux/mtd/nand.h
··· 29 29 struct device_node; 30 30 31 31 /* Scan and identify a NAND device */ 32 - extern int nand_scan(struct mtd_info *mtd, int max_chips); 32 + int nand_scan(struct mtd_info *mtd, int max_chips); 33 33 /* 34 34 * Separate phases of nand_scan(), allowing board driver to intervene 35 35 * and override command or ECC setup according to flash type. 36 36 */ 37 - extern int nand_scan_ident(struct mtd_info *mtd, int max_chips, 37 + int nand_scan_ident(struct mtd_info *mtd, int max_chips, 38 38 struct nand_flash_dev *table); 39 - extern int nand_scan_tail(struct mtd_info *mtd); 39 + int nand_scan_tail(struct mtd_info *mtd); 40 40 41 - /* Free resources held by the NAND device */ 42 - extern void nand_release(struct mtd_info *mtd); 41 + /* Unregister the MTD device and free resources held by the NAND device */ 42 + void nand_release(struct mtd_info *mtd); 43 43 44 44 /* Internal helper for board drivers which need to override command function */ 45 - extern void nand_wait_ready(struct mtd_info *mtd); 45 + void nand_wait_ready(struct mtd_info *mtd); 46 46 47 47 /* locks all blocks present in the device */ 48 - extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); 48 + int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); 49 49 50 50 /* unlocks specified locked blocks */ 51 - extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); 51 + int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); 52 52 53 53 /* The maximum number of NAND chips in an array */ 54 54 #define NAND_MAX_CHIPS 8 ··· 141 141 * pages and you want to rely on the default implementation. 142 142 */ 143 143 #define NAND_ECC_GENERIC_ERASED_CHECK BIT(0) 144 + #define NAND_ECC_MAXIMIZE BIT(1) 144 145 145 146 /* Bit mask for flags passed to do_nand_read_ecc */ 146 147 #define NAND_GET_DEVICE 0x80 ··· 461 460 wait_queue_head_t wq; 462 461 }; 463 462 463 + static inline void nand_hw_control_init(struct nand_hw_control *nfc) 464 + { 465 + nfc->active = NULL; 466 + spin_lock_init(&nfc->lock); 467 + init_waitqueue_head(&nfc->wq); 468 + } 469 + 464 470 /** 465 471 * struct nand_ecc_ctrl - Control structure for ECC 466 472 * @mode: ECC mode ··· 574 566 }; 575 567 576 568 /** 569 + * struct nand_sdr_timings - SDR NAND chip timings 570 + * 571 + * This struct defines the timing requirements of a SDR NAND chip. 572 + * These information can be found in every NAND datasheets and the timings 573 + * meaning are described in the ONFI specifications: 574 + * www.onfi.org/~/media/ONFI/specs/onfi_3_1_spec.pdf (chapter 4.15 Timing 575 + * Parameters) 576 + * 577 + * All these timings are expressed in picoseconds. 578 + * 579 + * @tALH_min: ALE hold time 580 + * @tADL_min: ALE to data loading time 581 + * @tALS_min: ALE setup time 582 + * @tAR_min: ALE to RE# delay 583 + * @tCEA_max: CE# access time 584 + * @tCEH_min: 585 + * @tCH_min: CE# hold time 586 + * @tCHZ_max: CE# high to output hi-Z 587 + * @tCLH_min: CLE hold time 588 + * @tCLR_min: CLE to RE# delay 589 + * @tCLS_min: CLE setup time 590 + * @tCOH_min: CE# high to output hold 591 + * @tCS_min: CE# setup time 592 + * @tDH_min: Data hold time 593 + * @tDS_min: Data setup time 594 + * @tFEAT_max: Busy time for Set Features and Get Features 595 + * @tIR_min: Output hi-Z to RE# low 596 + * @tITC_max: Interface and Timing Mode Change time 597 + * @tRC_min: RE# cycle time 598 + * @tREA_max: RE# access time 599 + * @tREH_min: RE# high hold time 600 + * @tRHOH_min: RE# high to output hold 601 + * @tRHW_min: RE# high to WE# low 602 + * @tRHZ_max: RE# high to output hi-Z 603 + * @tRLOH_min: RE# low to output hold 604 + * @tRP_min: RE# pulse width 605 + * @tRR_min: Ready to RE# low (data only) 606 + * @tRST_max: Device reset time, measured from the falling edge of R/B# to the 607 + * rising edge of R/B#. 608 + * @tWB_max: WE# high to SR[6] low 609 + * @tWC_min: WE# cycle time 610 + * @tWH_min: WE# high hold time 611 + * @tWHR_min: WE# high to RE# low 612 + * @tWP_min: WE# pulse width 613 + * @tWW_min: WP# transition to WE# low 614 + */ 615 + struct nand_sdr_timings { 616 + u32 tALH_min; 617 + u32 tADL_min; 618 + u32 tALS_min; 619 + u32 tAR_min; 620 + u32 tCEA_max; 621 + u32 tCEH_min; 622 + u32 tCH_min; 623 + u32 tCHZ_max; 624 + u32 tCLH_min; 625 + u32 tCLR_min; 626 + u32 tCLS_min; 627 + u32 tCOH_min; 628 + u32 tCS_min; 629 + u32 tDH_min; 630 + u32 tDS_min; 631 + u32 tFEAT_max; 632 + u32 tIR_min; 633 + u32 tITC_max; 634 + u32 tRC_min; 635 + u32 tREA_max; 636 + u32 tREH_min; 637 + u32 tRHOH_min; 638 + u32 tRHW_min; 639 + u32 tRHZ_max; 640 + u32 tRLOH_min; 641 + u32 tRP_min; 642 + u32 tRR_min; 643 + u64 tRST_max; 644 + u32 tWB_max; 645 + u32 tWC_min; 646 + u32 tWH_min; 647 + u32 tWHR_min; 648 + u32 tWP_min; 649 + u32 tWW_min; 650 + }; 651 + 652 + /** 653 + * enum nand_data_interface_type - NAND interface timing type 654 + * @NAND_SDR_IFACE: Single Data Rate interface 655 + */ 656 + enum nand_data_interface_type { 657 + NAND_SDR_IFACE, 658 + }; 659 + 660 + /** 661 + * struct nand_data_interface - NAND interface timing 662 + * @type: type of the timing 663 + * @timings: The timing, type according to @type 664 + */ 665 + struct nand_data_interface { 666 + enum nand_data_interface_type type; 667 + union { 668 + struct nand_sdr_timings sdr; 669 + } timings; 670 + }; 671 + 672 + /** 673 + * nand_get_sdr_timings - get SDR timing from data interface 674 + * @conf: The data interface 675 + */ 676 + static inline const struct nand_sdr_timings * 677 + nand_get_sdr_timings(const struct nand_data_interface *conf) 678 + { 679 + if (conf->type != NAND_SDR_IFACE) 680 + return ERR_PTR(-EINVAL); 681 + 682 + return &conf->timings.sdr; 683 + } 684 + 685 + /** 577 686 * struct nand_chip - NAND Private Flash Chip Data 578 687 * @mtd: MTD device registered to the MTD framework 579 688 * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the ··· 752 627 * also from the datasheet. It is the recommended ECC step 753 628 * size, if known; if unknown, set to zero. 754 629 * @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is 755 - * either deduced from the datasheet if the NAND 756 - * chip is not ONFI compliant or set to 0 if it is 757 - * (an ONFI chip is always configured in mode 0 758 - * after a NAND reset) 630 + * set to the actually used ONFI mode if the chip is 631 + * ONFI compliant or deduced from the datasheet if 632 + * the NAND chip is not ONFI compliant. 759 633 * @numchips: [INTERN] number of physical chips 760 634 * @chipsize: [INTERN] the size of one chip for multichip arrays 761 635 * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 ··· 774 650 * @read_retries: [INTERN] the number of read retry modes supported 775 651 * @onfi_set_features: [REPLACEABLE] set the features for ONFI nand 776 652 * @onfi_get_features: [REPLACEABLE] get the features for ONFI nand 653 + * @setup_data_interface: [OPTIONAL] setup the data interface and timing 777 654 * @bbt: [INTERN] bad block table pointer 778 655 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash 779 656 * lookup. ··· 821 696 int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip, 822 697 int feature_addr, uint8_t *subfeature_para); 823 698 int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode); 699 + int (*setup_data_interface)(struct mtd_info *mtd, 700 + const struct nand_data_interface *conf, 701 + bool check_only); 702 + 824 703 825 704 int chip_delay; 826 705 unsigned int options; ··· 853 724 struct nand_onfi_params onfi_params; 854 725 struct nand_jedec_params jedec_params; 855 726 }; 727 + 728 + struct nand_data_interface *data_interface; 856 729 857 730 int read_retries; 858 731 ··· 1024 893 extern struct nand_flash_dev nand_flash_ids[]; 1025 894 extern struct nand_manufacturers nand_manuf_ids[]; 1026 895 1027 - extern int nand_default_bbt(struct mtd_info *mtd); 1028 - extern int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); 1029 - extern int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs); 1030 - extern int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt); 1031 - extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, 1032 - int allowbbt); 1033 - extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, 1034 - size_t *retlen, uint8_t *buf); 896 + int nand_default_bbt(struct mtd_info *mtd); 897 + int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); 898 + int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs); 899 + int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt); 900 + int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, 901 + int allowbbt); 902 + int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, 903 + size_t *retlen, uint8_t *buf); 1035 904 1036 905 /** 1037 906 * struct platform_nand_chip - chip level device structure ··· 1119 988 return le16_to_cpu(chip->onfi_params.src_sync_timing_mode); 1120 989 } 1121 990 991 + int onfi_init_data_interface(struct nand_chip *chip, 992 + struct nand_data_interface *iface, 993 + enum nand_data_interface_type type, 994 + int timing_mode); 995 + 1122 996 /* 1123 997 * Check if it is a SLC nand. 1124 998 * The !nand_is_slc() can be used to check the MLC/TLC nand chips. ··· 1159 1023 : 0; 1160 1024 } 1161 1025 1162 - /* 1163 - * struct nand_sdr_timings - SDR NAND chip timings 1164 - * 1165 - * This struct defines the timing requirements of a SDR NAND chip. 1166 - * These informations can be found in every NAND datasheets and the timings 1167 - * meaning are described in the ONFI specifications: 1168 - * www.onfi.org/~/media/ONFI/specs/onfi_3_1_spec.pdf (chapter 4.15 Timing 1169 - * Parameters) 1170 - * 1171 - * All these timings are expressed in picoseconds. 1172 - */ 1173 - 1174 - struct nand_sdr_timings { 1175 - u32 tALH_min; 1176 - u32 tADL_min; 1177 - u32 tALS_min; 1178 - u32 tAR_min; 1179 - u32 tCEA_max; 1180 - u32 tCEH_min; 1181 - u32 tCH_min; 1182 - u32 tCHZ_max; 1183 - u32 tCLH_min; 1184 - u32 tCLR_min; 1185 - u32 tCLS_min; 1186 - u32 tCOH_min; 1187 - u32 tCS_min; 1188 - u32 tDH_min; 1189 - u32 tDS_min; 1190 - u32 tFEAT_max; 1191 - u32 tIR_min; 1192 - u32 tITC_max; 1193 - u32 tRC_min; 1194 - u32 tREA_max; 1195 - u32 tREH_min; 1196 - u32 tRHOH_min; 1197 - u32 tRHW_min; 1198 - u32 tRHZ_max; 1199 - u32 tRLOH_min; 1200 - u32 tRP_min; 1201 - u32 tRR_min; 1202 - u64 tRST_max; 1203 - u32 tWB_max; 1204 - u32 tWC_min; 1205 - u32 tWH_min; 1206 - u32 tWHR_min; 1207 - u32 tWP_min; 1208 - u32 tWW_min; 1209 - }; 1210 - 1211 1026 /* get timing characteristics from ONFI timing mode. */ 1212 1027 const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode); 1028 + /* get data interface from ONFI timing mode 0, used after reset. */ 1029 + const struct nand_data_interface *nand_get_default_data_interface(void); 1213 1030 1214 1031 int nand_check_erased_ecc_chunk(void *data, int datalen, 1215 1032 void *ecc, int ecclen, ··· 1182 1093 /* Default read_oob syndrome implementation */ 1183 1094 int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, 1184 1095 int page); 1096 + 1097 + /* Reset and initialize a NAND device */ 1098 + int nand_reset(struct nand_chip *chip); 1099 + 1100 + /* Free resources held by the NAND device */ 1101 + void nand_cleanup(struct nand_chip *chip); 1102 + 1185 1103 #endif /* __LINUX_MTD_NAND_H */