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

Merge tag 'mtd/fixes-for-5.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd fixes from Miquel Raynal:
"MTD fixes:

- dataflash: Add device-tree SPI IDs to avoid new warnings

Raw NAND fixes:

- Fix nand_choose_best_timings() on unsupported interface

- Fix nand_erase_op delay (wrong unit)

- fsmc:
- Fix timing computation
- Take instruction delay into account

- denali:
- Add the dependency on HAS_IOMEM to silence robots"

* tag 'mtd/fixes-for-5.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux:
mtd: dataflash: Add device-tree SPI IDs
mtd: rawnand: fsmc: Fix timing computation
mtd: rawnand: fsmc: Take instruction delay into account
mtd: rawnand: Fix nand_choose_best_timings() on unsupported interface
mtd: rawnand: Fix nand_erase_op delay
mtd: rawnand: denali: Add the dependency on HAS_IOMEM

+40 -12
+8
drivers/mtd/devices/mtd_dataflash.c
··· 96 96 struct mtd_info mtd; 97 97 }; 98 98 99 + static const struct spi_device_id dataflash_dev_ids[] = { 100 + { "at45" }, 101 + { "dataflash" }, 102 + { }, 103 + }; 104 + MODULE_DEVICE_TABLE(spi, dataflash_dev_ids); 105 + 99 106 #ifdef CONFIG_OF 100 107 static const struct of_device_id dataflash_dt_ids[] = { 101 108 { .compatible = "atmel,at45", }, ··· 934 927 .name = "mtd_dataflash", 935 928 .of_match_table = of_match_ptr(dataflash_dt_ids), 936 929 }, 930 + .id_table = dataflash_dev_ids, 937 931 938 932 .probe = dataflash_probe, 939 933 .remove = dataflash_remove,
+1 -1
drivers/mtd/nand/raw/Kconfig
··· 26 26 config MTD_NAND_DENALI_DT 27 27 tristate "Denali NAND controller as a DT device" 28 28 select MTD_NAND_DENALI 29 - depends on HAS_DMA && HAVE_CLK && OF 29 + depends on HAS_DMA && HAVE_CLK && OF && HAS_IOMEM 30 30 help 31 31 Enable the driver for NAND flash on platforms using a Denali NAND 32 32 controller as a DT device.
+28 -8
drivers/mtd/nand/raw/fsmc_nand.c
··· 15 15 16 16 #include <linux/clk.h> 17 17 #include <linux/completion.h> 18 + #include <linux/delay.h> 18 19 #include <linux/dmaengine.h> 19 20 #include <linux/dma-direction.h> 20 21 #include <linux/dma-mapping.h> ··· 93 92 #define FSMC_NAND_BANK_SZ 0x20 94 93 95 94 #define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ) 95 + 96 + /* 97 + * According to SPEAr300 Reference Manual (RM0082) 98 + * TOUDEL = 7ns (Output delay from the flip-flops to the board) 99 + * TINDEL = 5ns (Input delay from the board to the flipflop) 100 + */ 101 + #define TOUTDEL 7000 102 + #define TINDEL 5000 96 103 97 104 struct fsmc_nand_timings { 98 105 u8 tclr; ··· 286 277 { 287 278 unsigned long hclk = clk_get_rate(host->clk); 288 279 unsigned long hclkn = NSEC_PER_SEC / hclk; 289 - u32 thiz, thold, twait, tset; 280 + u32 thiz, thold, twait, tset, twait_min; 290 281 291 282 if (sdrt->tRC_min < 30000) 292 283 return -EOPNOTSUPP; ··· 318 309 else if (tims->thold > FSMC_THOLD_MASK) 319 310 tims->thold = FSMC_THOLD_MASK; 320 311 321 - twait = max(sdrt->tRP_min, sdrt->tWP_min); 322 - tims->twait = DIV_ROUND_UP(twait / 1000, hclkn) - 1; 323 - if (tims->twait == 0) 324 - tims->twait = 1; 325 - else if (tims->twait > FSMC_TWAIT_MASK) 326 - tims->twait = FSMC_TWAIT_MASK; 327 - 328 312 tset = max(sdrt->tCS_min - sdrt->tWP_min, 329 313 sdrt->tCEA_max - sdrt->tREA_max); 330 314 tims->tset = DIV_ROUND_UP(tset / 1000, hclkn) - 1; ··· 325 323 tims->tset = 1; 326 324 else if (tims->tset > FSMC_TSET_MASK) 327 325 tims->tset = FSMC_TSET_MASK; 326 + 327 + /* 328 + * According to SPEAr300 Reference Manual (RM0082) which gives more 329 + * information related to FSMSC timings than the SPEAr600 one (RM0305), 330 + * twait >= tCEA - (tset * TCLK) + TOUTDEL + TINDEL 331 + */ 332 + twait_min = sdrt->tCEA_max - ((tims->tset + 1) * hclkn * 1000) 333 + + TOUTDEL + TINDEL; 334 + twait = max3(sdrt->tRP_min, sdrt->tWP_min, twait_min); 335 + 336 + tims->twait = DIV_ROUND_UP(twait / 1000, hclkn) - 1; 337 + if (tims->twait == 0) 338 + tims->twait = 1; 339 + else if (tims->twait > FSMC_TWAIT_MASK) 340 + tims->twait = FSMC_TWAIT_MASK; 328 341 329 342 return 0; 330 343 } ··· 681 664 instr->ctx.waitrdy.timeout_ms); 682 665 break; 683 666 } 667 + 668 + if (instr->delay_ns) 669 + ndelay(instr->delay_ns); 684 670 } 685 671 686 672 return ret;
+3 -3
drivers/mtd/nand/raw/nand_base.c
··· 926 926 struct nand_sdr_timings *spec_timings) 927 927 { 928 928 const struct nand_controller_ops *ops = chip->controller->ops; 929 - int best_mode = 0, mode, ret; 929 + int best_mode = 0, mode, ret = -EOPNOTSUPP; 930 930 931 931 iface->type = NAND_SDR_IFACE; 932 932 ··· 977 977 struct nand_nvddr_timings *spec_timings) 978 978 { 979 979 const struct nand_controller_ops *ops = chip->controller->ops; 980 - int best_mode = 0, mode, ret; 980 + int best_mode = 0, mode, ret = -EOPNOTSUPP; 981 981 982 982 iface->type = NAND_NVDDR_IFACE; 983 983 ··· 1837 1837 NAND_OP_CMD(NAND_CMD_ERASE1, 0), 1838 1838 NAND_OP_ADDR(2, addrs, 0), 1839 1839 NAND_OP_CMD(NAND_CMD_ERASE2, 1840 - NAND_COMMON_TIMING_MS(conf, tWB_max)), 1840 + NAND_COMMON_TIMING_NS(conf, tWB_max)), 1841 1841 NAND_OP_WAIT_RDY(NAND_COMMON_TIMING_MS(conf, tBERS_max), 1842 1842 0), 1843 1843 };