Skip to content

Commit 27698cd

Browse files
committed
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
2 parents 03090cc + 27a030e commit 27698cd

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

drivers/mtd/devices/mtd_dataflash.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ struct dataflash {
9696
struct mtd_info mtd;
9797
};
9898

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+
99106
#ifdef CONFIG_OF
100107
static const struct of_device_id dataflash_dt_ids[] = {
101108
{ .compatible = "atmel,at45", },
@@ -927,6 +934,7 @@ static struct spi_driver dataflash_driver = {
927934
.name = "mtd_dataflash",
928935
.of_match_table = of_match_ptr(dataflash_dt_ids),
929936
},
937+
.id_table = dataflash_dev_ids,
930938

931939
.probe = dataflash_probe,
932940
.remove = dataflash_remove,

drivers/mtd/nand/raw/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ config MTD_NAND_DENALI_PCI
2626
config MTD_NAND_DENALI_DT
2727
tristate "Denali NAND controller as a DT device"
2828
select MTD_NAND_DENALI
29-
depends on HAS_DMA && HAVE_CLK && OF
29+
depends on HAS_DMA && HAVE_CLK && OF && HAS_IOMEM
3030
help
3131
Enable the driver for NAND flash on platforms using a Denali NAND
3232
controller as a DT device.

drivers/mtd/nand/raw/fsmc_nand.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <linux/clk.h>
1717
#include <linux/completion.h>
18+
#include <linux/delay.h>
1819
#include <linux/dmaengine.h>
1920
#include <linux/dma-direction.h>
2021
#include <linux/dma-mapping.h>
@@ -93,6 +94,14 @@
9394

9495
#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ)
9596

97+
/*
98+
* According to SPEAr300 Reference Manual (RM0082)
99+
* TOUDEL = 7ns (Output delay from the flip-flops to the board)
100+
* TINDEL = 5ns (Input delay from the board to the flipflop)
101+
*/
102+
#define TOUTDEL 7000
103+
#define TINDEL 5000
104+
96105
struct fsmc_nand_timings {
97106
u8 tclr;
98107
u8 tar;
@@ -277,7 +286,7 @@ static int fsmc_calc_timings(struct fsmc_nand_data *host,
277286
{
278287
unsigned long hclk = clk_get_rate(host->clk);
279288
unsigned long hclkn = NSEC_PER_SEC / hclk;
280-
u32 thiz, thold, twait, tset;
289+
u32 thiz, thold, twait, tset, twait_min;
281290

282291
if (sdrt->tRC_min < 30000)
283292
return -EOPNOTSUPP;
@@ -309,13 +318,6 @@ static int fsmc_calc_timings(struct fsmc_nand_data *host,
309318
else if (tims->thold > FSMC_THOLD_MASK)
310319
tims->thold = FSMC_THOLD_MASK;
311320

312-
twait = max(sdrt->tRP_min, sdrt->tWP_min);
313-
tims->twait = DIV_ROUND_UP(twait / 1000, hclkn) - 1;
314-
if (tims->twait == 0)
315-
tims->twait = 1;
316-
else if (tims->twait > FSMC_TWAIT_MASK)
317-
tims->twait = FSMC_TWAIT_MASK;
318-
319321
tset = max(sdrt->tCS_min - sdrt->tWP_min,
320322
sdrt->tCEA_max - sdrt->tREA_max);
321323
tims->tset = DIV_ROUND_UP(tset / 1000, hclkn) - 1;
@@ -324,6 +326,21 @@ static int fsmc_calc_timings(struct fsmc_nand_data *host,
324326
else if (tims->tset > FSMC_TSET_MASK)
325327
tims->tset = FSMC_TSET_MASK;
326328

329+
/*
330+
* According to SPEAr300 Reference Manual (RM0082) which gives more
331+
* information related to FSMSC timings than the SPEAr600 one (RM0305),
332+
* twait >= tCEA - (tset * TCLK) + TOUTDEL + TINDEL
333+
*/
334+
twait_min = sdrt->tCEA_max - ((tims->tset + 1) * hclkn * 1000)
335+
+ TOUTDEL + TINDEL;
336+
twait = max3(sdrt->tRP_min, sdrt->tWP_min, twait_min);
337+
338+
tims->twait = DIV_ROUND_UP(twait / 1000, hclkn) - 1;
339+
if (tims->twait == 0)
340+
tims->twait = 1;
341+
else if (tims->twait > FSMC_TWAIT_MASK)
342+
tims->twait = FSMC_TWAIT_MASK;
343+
327344
return 0;
328345
}
329346

@@ -664,6 +681,9 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
664681
instr->ctx.waitrdy.timeout_ms);
665682
break;
666683
}
684+
685+
if (instr->delay_ns)
686+
ndelay(instr->delay_ns);
667687
}
668688

669689
return ret;

drivers/mtd/nand/raw/nand_base.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ int nand_choose_best_sdr_timings(struct nand_chip *chip,
926926
struct nand_sdr_timings *spec_timings)
927927
{
928928
const struct nand_controller_ops *ops = chip->controller->ops;
929-
int best_mode = 0, mode, ret;
929+
int best_mode = 0, mode, ret = -EOPNOTSUPP;
930930

931931
iface->type = NAND_SDR_IFACE;
932932

@@ -977,7 +977,7 @@ int nand_choose_best_nvddr_timings(struct nand_chip *chip,
977977
struct nand_nvddr_timings *spec_timings)
978978
{
979979
const struct nand_controller_ops *ops = chip->controller->ops;
980-
int best_mode = 0, mode, ret;
980+
int best_mode = 0, mode, ret = -EOPNOTSUPP;
981981

982982
iface->type = NAND_NVDDR_IFACE;
983983

@@ -1837,7 +1837,7 @@ int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock)
18371837
NAND_OP_CMD(NAND_CMD_ERASE1, 0),
18381838
NAND_OP_ADDR(2, addrs, 0),
18391839
NAND_OP_CMD(NAND_CMD_ERASE2,
1840-
NAND_COMMON_TIMING_MS(conf, tWB_max)),
1840+
NAND_COMMON_TIMING_NS(conf, tWB_max)),
18411841
NAND_OP_WAIT_RDY(NAND_COMMON_TIMING_MS(conf, tBERS_max),
18421842
0),
18431843
};

0 commit comments

Comments
 (0)