On AM654, McSPI can only support 4K - 1 bytes per transfer when DMA is enabled. Therefore populate master->max_transfer_size callback to inform client drivers of this restriction when DMA channels are available.
Unified · Split
| @@ -130,6 +130,7 @@ struct omap2_mcspi { · 129 unmodified lines | ||
| 130 | 130 | int fifo_depth; |
| 131 | 131 | bool slave_aborted; |
| 132 | 132 | unsigned int pin_dir:1; |
| 133 | + size_t max_xfer_len; | |
| 133 | 134 | }; |
| 134 | 135 | |
| 135 | 136 | struct omap2_mcspi_cs { |
| @@ -1305,6 +1306,18 @@ static bool omap2_mcspi_can_dma(struct spi_master *master, · 1169 unmodified lines | ||
| 1305 | 1306 | return (xfer->len >= DMA_MIN_BYTES); |
| 1306 | 1307 | } |
| 1307 | 1308 | |
| 1309 | +static size_t omap2_mcspi_max_xfer_size(struct spi_device *spi) | |
| 1310 | +{ | |
| 1311 | + struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); | |
| 1312 | + struct omap2_mcspi_dma *mcspi_dma = | |
| 1313 | + &mcspi->dma_channels[spi->chip_select]; | |
| 1314 | + | |
| 1315 | + if (mcspi->max_xfer_len && mcspi_dma->dma_rx) | |
| 1316 | + return mcspi->max_xfer_len; | |
| 1317 | + | |
| 1318 | + return SIZE_MAX; | |
| 1319 | +} | |
| 1320 | + | |
| 1308 | 1321 | static int omap2_mcspi_controller_setup(struct omap2_mcspi *mcspi) |
| 1309 | 1322 | { |
| 1310 | 1323 | struct spi_master *master = mcspi->master; |
| @@ -1373,6 +1386,11 @@ static struct omap2_mcspi_platform_config omap4_pdata = { · 62 unmodified lines | ||
| 1373 | 1386 | .regs_offset = OMAP4_MCSPI_REG_OFFSET, |
| 1374 | 1387 | }; |
| 1375 | 1388 | |
| 1389 | +static struct omap2_mcspi_platform_config am654_pdata = { | |
| 1390 | + .regs_offset = OMAP4_MCSPI_REG_OFFSET, | |
| 1391 | + .max_xfer_len = SZ_4K - 1, | |
| 1392 | +}; | |
| 1393 | + | |
| 1376 | 1394 | static const struct of_device_id omap_mcspi_of_match[] = { |
| 1377 | 1395 | { |
| 1378 | 1396 | .compatible = "ti,omap2-mcspi", |
| @@ -1382,6 +1400,10 @@ static const struct of_device_id omap_mcspi_of_match[] = { · 3 unmodified lines | ||
| 1382 | 1400 | .compatible = "ti,omap4-mcspi", |
| 1383 | 1401 | .data = &omap4_pdata, |
| 1384 | 1402 | }, |
| 1403 | + { | |
| 1404 | + .compatible = "ti,am654-mcspi", | |
| 1405 | + .data = &am654_pdata, | |
| 1406 | + }, | |
| 1385 | 1407 | { }, |
| 1386 | 1408 | }; |
| 1387 | 1409 | MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); |
| @@ -1439,6 +1461,10 @@ static int omap2_mcspi_probe(struct platform_device *pdev) · 51 unmodified lines | ||
| 1439 | 1461 | mcspi->pin_dir = pdata->pin_dir; |
| 1440 | 1462 | } |
| 1441 | 1463 | regs_offset = pdata->regs_offset; |
| 1464 | + if (pdata->max_xfer_len) { | |
| 1465 | + mcspi->max_xfer_len = pdata->max_xfer_len; | |
| 1466 | + master->max_transfer_size = omap2_mcspi_max_xfer_size; | |
| 1467 | + } | |
| 1442 | 1468 | |
| 1443 | 1469 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1444 | 1470 | mcspi->base = devm_ioremap_resource(&pdev->dev, r); |
| @@ -11,6 +11,7 @@ struct omap2_mcspi_platform_config { · 10 unmodified lines | ||
| 11 | 11 | unsigned short num_cs; |
| 12 | 12 | unsigned int regs_offset; |
| 13 | 13 | unsigned int pin_dir:1; |
| 14 | + size_t max_xfer_len; | |
| 14 | 15 | }; |
| 15 | 16 | |
| 16 | 17 | struct omap2_mcspi_device_config { |