Skip to content

Commit 4936ce1

Browse files
committed
Merge tag 'mtd/fixes-for-5.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
Pull MTD fixes from Miquel Raynal: "MTD: - sm_ftl: Fix NULL pointer warning. Raw NAND: - Cadence: fix compile testing. - STM32: Avoid locking. Onenand: - Fix several sparse/build warnings. SPI-NOR: - Add a flag to fix interaction with Micron parts" * tag 'mtd/fixes-for-5.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: mtd: spi-nor: Fix the writing of the Status Register on micron flashes mtd: sm_ftl: fix NULL pointer warning mtd: onenand: omap2: Pass correct flags for prep_dma_memcpy mtd: onenand: samsung: Fix iomem access with regular memcpy mtd: onenand: omap2: Fix errors in style mtd: cadence: Fix cast to pointer from integer of different size warning mtd: rawnand: stm32_fmc2: avoid to lock the CPU bus
2 parents b1d198c + 82de6a6 commit 4936ce1

File tree

8 files changed

+65
-28
lines changed

8 files changed

+65
-28
lines changed

drivers/mtd/nand/onenand/omap2.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state)
148148
unsigned long timeout;
149149
u32 syscfg;
150150

151-
if (state == FL_RESETING || state == FL_PREPARING_ERASE ||
151+
if (state == FL_RESETTING || state == FL_PREPARING_ERASE ||
152152
state == FL_VERIFYING_ERASE) {
153153
int i = 21;
154154
unsigned int intr_flags = ONENAND_INT_MASTER;
155155

156156
switch (state) {
157-
case FL_RESETING:
157+
case FL_RESETTING:
158158
intr_flags |= ONENAND_INT_RESET;
159159
break;
160160
case FL_PREPARING_ERASE:
@@ -328,7 +328,8 @@ static inline int omap2_onenand_dma_transfer(struct omap2_onenand *c,
328328
struct dma_async_tx_descriptor *tx;
329329
dma_cookie_t cookie;
330330

331-
tx = dmaengine_prep_dma_memcpy(c->dma_chan, dst, src, count, 0);
331+
tx = dmaengine_prep_dma_memcpy(c->dma_chan, dst, src, count,
332+
DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
332333
if (!tx) {
333334
dev_err(&c->pdev->dev, "Failed to prepare DMA memcpy\n");
334335
return -EIO;
@@ -375,7 +376,7 @@ static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,
375376
* context fallback to PIO mode.
376377
*/
377378
if (!virt_addr_valid(buf) || bram_offset & 3 || (size_t)buf & 3 ||
378-
count < 384 || in_interrupt() || oops_in_progress )
379+
count < 384 || in_interrupt() || oops_in_progress)
379380
goto out_copy;
380381

381382
xtra = count & 3;
@@ -422,7 +423,7 @@ static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
422423
* context fallback to PIO mode.
423424
*/
424425
if (!virt_addr_valid(buf) || bram_offset & 3 || (size_t)buf & 3 ||
425-
count < 384 || in_interrupt() || oops_in_progress )
426+
count < 384 || in_interrupt() || oops_in_progress)
426427
goto out_copy;
427428

428429
dma_src = dma_map_single(dev, buf, count, DMA_TO_DEVICE);
@@ -528,7 +529,8 @@ static int omap2_onenand_probe(struct platform_device *pdev)
528529
c->gpmc_cs, c->phys_base, c->onenand.base,
529530
c->dma_chan ? "DMA" : "PIO");
530531

531-
if ((r = onenand_scan(&c->mtd, 1)) < 0)
532+
r = onenand_scan(&c->mtd, 1);
533+
if (r < 0)
532534
goto err_release_dma;
533535

534536
freq = omap2_onenand_get_freq(c->onenand.version_id);

drivers/mtd/nand/onenand/onenand_base.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,7 @@ static int onenand_otp_write_oob_nolock(struct mtd_info *mtd, loff_t to,
28532853

28542854
/* Exit OTP access mode */
28552855
this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2856-
this->wait(mtd, FL_RESETING);
2856+
this->wait(mtd, FL_RESETTING);
28572857

28582858
status = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
28592859
status &= 0x60;
@@ -2924,7 +2924,7 @@ static int do_otp_read(struct mtd_info *mtd, loff_t from, size_t len,
29242924

29252925
/* Exit OTP access mode */
29262926
this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2927-
this->wait(mtd, FL_RESETING);
2927+
this->wait(mtd, FL_RESETTING);
29282928

29292929
return ret;
29302930
}
@@ -2968,7 +2968,7 @@ static int do_otp_write(struct mtd_info *mtd, loff_t to, size_t len,
29682968

29692969
/* Exit OTP access mode */
29702970
this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2971-
this->wait(mtd, FL_RESETING);
2971+
this->wait(mtd, FL_RESETTING);
29722972

29732973
return ret;
29742974
}
@@ -3008,7 +3008,7 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len,
30083008

30093009
/* Exit OTP access mode */
30103010
this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3011-
this->wait(mtd, FL_RESETING);
3011+
this->wait(mtd, FL_RESETTING);
30123012
} else {
30133013
ops.mode = MTD_OPS_PLACE_OOB;
30143014
ops.ooblen = len;
@@ -3413,7 +3413,7 @@ static int flexonenand_get_boundary(struct mtd_info *mtd)
34133413
this->boundary[die] = bdry & FLEXONENAND_PI_MASK;
34143414

34153415
this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3416-
this->wait(mtd, FL_RESETING);
3416+
this->wait(mtd, FL_RESETTING);
34173417

34183418
printk(KERN_INFO "Die %d boundary: %d%s\n", die,
34193419
this->boundary[die], locked ? "(Locked)" : "(Unlocked)");
@@ -3635,7 +3635,7 @@ static int flexonenand_set_boundary(struct mtd_info *mtd, int die,
36353635
ret = this->wait(mtd, FL_WRITING);
36363636
out:
36373637
this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_REG_COMMAND);
3638-
this->wait(mtd, FL_RESETING);
3638+
this->wait(mtd, FL_RESETTING);
36393639
if (!ret)
36403640
/* Recalculate device size on boundary change*/
36413641
flexonenand_get_size(mtd);
@@ -3671,7 +3671,7 @@ static int onenand_chip_probe(struct mtd_info *mtd)
36713671
/* Reset OneNAND to read default register values */
36723672
this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
36733673
/* Wait reset */
3674-
this->wait(mtd, FL_RESETING);
3674+
this->wait(mtd, FL_RESETTING);
36753675

36763676
/* Restore system configuration 1 */
36773677
this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);

drivers/mtd/nand/onenand/samsung_mtd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,12 @@ static int s5pc110_read_bufferram(struct mtd_info *mtd, int area,
675675
normal:
676676
if (count != mtd->writesize) {
677677
/* Copy the bufferram to memory to prevent unaligned access */
678-
memcpy(this->page_buf, p, mtd->writesize);
679-
p = this->page_buf + offset;
678+
memcpy_fromio(this->page_buf, p, mtd->writesize);
679+
memcpy(buffer, this->page_buf + offset, count);
680+
} else {
681+
memcpy_fromio(buffer, p, count);
680682
}
681683

682-
memcpy(buffer, p, count);
683-
684684
return 0;
685685
}
686686

drivers/mtd/nand/raw/cadence-nand-controller.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,8 @@ static void cadence_nand_get_caps(struct cdns_nand_ctrl *cdns_ctrl)
914914
/* Prepare CDMA descriptor. */
915915
static void
916916
cadence_nand_cdma_desc_prepare(struct cdns_nand_ctrl *cdns_ctrl,
917-
char nf_mem, u32 flash_ptr, char *mem_ptr,
918-
char *ctrl_data_ptr, u16 ctype)
917+
char nf_mem, u32 flash_ptr, dma_addr_t mem_ptr,
918+
dma_addr_t ctrl_data_ptr, u16 ctype)
919919
{
920920
struct cadence_nand_cdma_desc *cdma_desc = cdns_ctrl->cdma_desc;
921921

@@ -931,13 +931,13 @@ cadence_nand_cdma_desc_prepare(struct cdns_nand_ctrl *cdns_ctrl,
931931
cdma_desc->command_flags |= CDMA_CF_DMA_MASTER;
932932
cdma_desc->command_flags |= CDMA_CF_INT;
933933

934-
cdma_desc->memory_pointer = (uintptr_t)mem_ptr;
934+
cdma_desc->memory_pointer = mem_ptr;
935935
cdma_desc->status = 0;
936936
cdma_desc->sync_flag_pointer = 0;
937937
cdma_desc->sync_arguments = 0;
938938

939939
cdma_desc->command_type = ctype;
940-
cdma_desc->ctrl_data_ptr = (uintptr_t)ctrl_data_ptr;
940+
cdma_desc->ctrl_data_ptr = ctrl_data_ptr;
941941
}
942942

943943
static u8 cadence_nand_check_desc_error(struct cdns_nand_ctrl *cdns_ctrl,
@@ -1280,8 +1280,7 @@ cadence_nand_cdma_transfer(struct cdns_nand_ctrl *cdns_ctrl, u8 chip_nr,
12801280
}
12811281

12821282
cadence_nand_cdma_desc_prepare(cdns_ctrl, chip_nr, page,
1283-
(void *)dma_buf, (void *)dma_ctrl_dat,
1284-
ctype);
1283+
dma_buf, dma_ctrl_dat, ctype);
12851284

12861285
status = cadence_nand_cdma_send_and_wait(cdns_ctrl, thread_nr);
12871286

@@ -1360,7 +1359,7 @@ static int cadence_nand_erase(struct nand_chip *chip, u32 page)
13601359

13611360
cadence_nand_cdma_desc_prepare(cdns_ctrl,
13621361
cdns_chip->cs[chip->cur_cs],
1363-
page, NULL, NULL,
1362+
page, 0, 0,
13641363
CDMA_CT_ERASE);
13651364
status = cadence_nand_cdma_send_and_wait(cdns_ctrl, thread_nr);
13661365
if (status) {

drivers/mtd/nand/raw/stm32_fmc2_nand.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
/* Max ECC buffer length */
3838
#define FMC2_MAX_ECC_BUF_LEN (FMC2_BCHDSRS_LEN * FMC2_MAX_SG)
3939

40+
#define FMC2_TIMEOUT_US 1000
4041
#define FMC2_TIMEOUT_MS 1000
4142

4243
/* Timings */
@@ -53,6 +54,8 @@
5354
#define FMC2_PMEM 0x88
5455
#define FMC2_PATT 0x8c
5556
#define FMC2_HECCR 0x94
57+
#define FMC2_ISR 0x184
58+
#define FMC2_ICR 0x188
5659
#define FMC2_CSQCR 0x200
5760
#define FMC2_CSQCFGR1 0x204
5861
#define FMC2_CSQCFGR2 0x208
@@ -118,6 +121,12 @@
118121
#define FMC2_PATT_ATTHIZ(x) (((x) & 0xff) << 24)
119122
#define FMC2_PATT_DEFAULT 0x0a0a0a0a
120123

124+
/* Register: FMC2_ISR */
125+
#define FMC2_ISR_IHLF BIT(1)
126+
127+
/* Register: FMC2_ICR */
128+
#define FMC2_ICR_CIHLF BIT(1)
129+
121130
/* Register: FMC2_CSQCR */
122131
#define FMC2_CSQCR_CSQSTART BIT(0)
123132

@@ -1322,6 +1331,31 @@ static void stm32_fmc2_write_data(struct nand_chip *chip, const void *buf,
13221331
stm32_fmc2_set_buswidth_16(fmc2, true);
13231332
}
13241333

1334+
static int stm32_fmc2_waitrdy(struct nand_chip *chip, unsigned long timeout_ms)
1335+
{
1336+
struct stm32_fmc2_nfc *fmc2 = to_stm32_nfc(chip->controller);
1337+
const struct nand_sdr_timings *timings;
1338+
u32 isr, sr;
1339+
1340+
/* Check if there is no pending requests to the NAND flash */
1341+
if (readl_relaxed_poll_timeout_atomic(fmc2->io_base + FMC2_SR, sr,
1342+
sr & FMC2_SR_NWRF, 1,
1343+
FMC2_TIMEOUT_US))
1344+
dev_warn(fmc2->dev, "Waitrdy timeout\n");
1345+
1346+
/* Wait tWB before R/B# signal is low */
1347+
timings = nand_get_sdr_timings(&chip->data_interface);
1348+
ndelay(PSEC_TO_NSEC(timings->tWB_max));
1349+
1350+
/* R/B# signal is low, clear high level flag */
1351+
writel_relaxed(FMC2_ICR_CIHLF, fmc2->io_base + FMC2_ICR);
1352+
1353+
/* Wait R/B# signal is high */
1354+
return readl_relaxed_poll_timeout_atomic(fmc2->io_base + FMC2_ISR,
1355+
isr, isr & FMC2_ISR_IHLF,
1356+
5, 1000 * timeout_ms);
1357+
}
1358+
13251359
static int stm32_fmc2_exec_op(struct nand_chip *chip,
13261360
const struct nand_operation *op,
13271361
bool check_only)
@@ -1366,8 +1400,8 @@ static int stm32_fmc2_exec_op(struct nand_chip *chip,
13661400
break;
13671401

13681402
case NAND_OP_WAITRDY_INSTR:
1369-
ret = nand_soft_waitrdy(chip,
1370-
instr->ctx.waitrdy.timeout_ms);
1403+
ret = stm32_fmc2_waitrdy(chip,
1404+
instr->ctx.waitrdy.timeout_ms);
13711405
break;
13721406
}
13731407
}

drivers/mtd/sm_ftl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ static int sm_read_sector(struct sm_ftl *ftl,
247247

248248
/* FTL can contain -1 entries that are by default filled with bits */
249249
if (block == -1) {
250-
memset(buffer, 0xFF, SM_SECTOR_SIZE);
250+
if (buffer)
251+
memset(buffer, 0xFF, SM_SECTOR_SIZE);
251252
return 0;
252253
}
253254

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,6 +4596,7 @@ static void sst_set_default_init(struct spi_nor *nor)
45964596
static void st_micron_set_default_init(struct spi_nor *nor)
45974597
{
45984598
nor->flags |= SNOR_F_HAS_LOCK;
4599+
nor->flags &= ~SNOR_F_HAS_16BIT_SR;
45994600
nor->params.quad_enable = NULL;
46004601
nor->params.set_4byte = st_micron_set_4byte;
46014602
}

include/linux/mtd/flashchip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef enum {
4040
FL_READING,
4141
FL_CACHEDPRG,
4242
/* These 4 come from onenand_state_t, which has been unified here */
43-
FL_RESETING,
43+
FL_RESETTING,
4444
FL_OTPING,
4545
FL_PREPARING_ERASE,
4646
FL_VERIFYING_ERASE,

0 commit comments

Comments
 (0)