Skip to content

Commit a9ae475

Browse files
Christophe Kerellomiquelraynal
authored andcommitted
mtd: rawnand: stm32_fmc2: use dma_get_slave_caps to get DMA max burst
Use dma_get_slave_caps API to get the max burst size of a DMA channel. For MP1 SoCs, MDMA is used and the max burst size is 128. For MP25 SoC, DMA3 is used and the max burst size is 64. Signed-off-by: Christophe Kerello <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent c1e04ab commit a9ae475

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

drivers/mtd/nand/raw/stm32_fmc2_nand.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ struct stm32_fmc2_nfc {
264264
struct sg_table dma_ecc_sg;
265265
u8 *ecc_buf;
266266
int dma_ecc_len;
267+
u32 tx_dma_max_burst;
268+
u32 rx_dma_max_burst;
267269

268270
struct completion complete;
269271
struct completion dma_data_complete;
@@ -347,20 +349,26 @@ static int stm32_fmc2_nfc_select_chip(struct nand_chip *chip, int chipnr)
347349
stm32_fmc2_nfc_setup(chip);
348350
stm32_fmc2_nfc_timings_init(chip);
349351

350-
if (nfc->dma_tx_ch && nfc->dma_rx_ch) {
352+
if (nfc->dma_tx_ch) {
351353
memset(&dma_cfg, 0, sizeof(dma_cfg));
352-
dma_cfg.src_addr = nfc->data_phys_addr[nfc->cs_sel];
353354
dma_cfg.dst_addr = nfc->data_phys_addr[nfc->cs_sel];
354-
dma_cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
355355
dma_cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
356-
dma_cfg.src_maxburst = 32;
357-
dma_cfg.dst_maxburst = 32;
356+
dma_cfg.dst_maxburst = nfc->tx_dma_max_burst /
357+
dma_cfg.dst_addr_width;
358358

359359
ret = dmaengine_slave_config(nfc->dma_tx_ch, &dma_cfg);
360360
if (ret) {
361361
dev_err(nfc->dev, "tx DMA engine slave config failed\n");
362362
return ret;
363363
}
364+
}
365+
366+
if (nfc->dma_rx_ch) {
367+
memset(&dma_cfg, 0, sizeof(dma_cfg));
368+
dma_cfg.src_addr = nfc->data_phys_addr[nfc->cs_sel];
369+
dma_cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
370+
dma_cfg.src_maxburst = nfc->rx_dma_max_burst /
371+
dma_cfg.src_addr_width;
364372

365373
ret = dmaengine_slave_config(nfc->dma_rx_ch, &dma_cfg);
366374
if (ret) {
@@ -1545,6 +1553,7 @@ static int stm32_fmc2_nfc_setup_interface(struct nand_chip *chip, int chipnr,
15451553

15461554
static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc)
15471555
{
1556+
struct dma_slave_caps caps;
15481557
int ret = 0;
15491558

15501559
nfc->dma_tx_ch = dma_request_chan(nfc->dev, "tx");
@@ -1557,6 +1566,11 @@ static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc)
15571566
goto err_dma;
15581567
}
15591568

1569+
ret = dma_get_slave_caps(nfc->dma_tx_ch, &caps);
1570+
if (ret)
1571+
return ret;
1572+
nfc->tx_dma_max_burst = caps.max_burst;
1573+
15601574
nfc->dma_rx_ch = dma_request_chan(nfc->dev, "rx");
15611575
if (IS_ERR(nfc->dma_rx_ch)) {
15621576
ret = PTR_ERR(nfc->dma_rx_ch);
@@ -1567,6 +1581,11 @@ static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc)
15671581
goto err_dma;
15681582
}
15691583

1584+
ret = dma_get_slave_caps(nfc->dma_rx_ch, &caps);
1585+
if (ret)
1586+
return ret;
1587+
nfc->rx_dma_max_burst = caps.max_burst;
1588+
15701589
nfc->dma_ecc_ch = dma_request_chan(nfc->dev, "ecc");
15711590
if (IS_ERR(nfc->dma_ecc_ch)) {
15721591
ret = PTR_ERR(nfc->dma_ecc_ch);

0 commit comments

Comments
 (0)