History

spi: spi-omap2-mcspi: Handle DMA size restriction on AM65x

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.

Vignesh Raghavendra committed 6 years ago

Commit e4e82761 parent a5362b82 files · +27 −0Browse files

Unified · Split

2 files
  1. drivers/spi/spi-omap2-mcspi.c +26 −0
  2. include/linux/platform_data/spi-omap2-mcspi.h +1 −0
drivers/spi/spi-omap2-mcspi.c+26−0
@@ -130,6 +130,7 @@ struct omap2_mcspi { · 129 unmodified lines
130130 int fifo_depth;
131131 bool slave_aborted;
132132 unsigned int pin_dir:1;
133+ size_t max_xfer_len;
133134 };
134135
135136 struct omap2_mcspi_cs {
@@ -1305,6 +1306,18 @@ static bool omap2_mcspi_can_dma(struct spi_master *master, · 1169 unmodified lines
13051306 return (xfer->len >= DMA_MIN_BYTES);
13061307 }
13071308
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+
13081321 static int omap2_mcspi_controller_setup(struct omap2_mcspi *mcspi)
13091322 {
13101323 struct spi_master *master = mcspi->master;
@@ -1373,6 +1386,11 @@ static struct omap2_mcspi_platform_config omap4_pdata = { · 62 unmodified lines
13731386 .regs_offset = OMAP4_MCSPI_REG_OFFSET,
13741387 };
13751388
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+
13761394 static const struct of_device_id omap_mcspi_of_match[] = {
13771395 {
13781396 .compatible = "ti,omap2-mcspi",
@@ -1382,6 +1400,10 @@ static const struct of_device_id omap_mcspi_of_match[] = { · 3 unmodified lines
13821400 .compatible = "ti,omap4-mcspi",
13831401 .data = &omap4_pdata,
13841402 },
1403+ {
1404+ .compatible = "ti,am654-mcspi",
1405+ .data = &am654_pdata,
1406+ },
13851407 { },
13861408 };
13871409 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
@@ -1439,6 +1461,10 @@ static int omap2_mcspi_probe(struct platform_device *pdev) · 51 unmodified lines
14391461 mcspi->pin_dir = pdata->pin_dir;
14401462 }
14411463 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+ }
14421468
14431469 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
14441470 mcspi->base = devm_ioremap_resource(&pdev->dev, r);
include/linux/platform_data/spi-omap2-mcspi.h+1−0
@@ -11,6 +11,7 @@ struct omap2_mcspi_platform_config { · 10 unmodified lines
1111 unsigned short num_cs;
1212 unsigned int regs_offset;
1313 unsigned int pin_dir:1;
14+ size_t max_xfer_len;
1415 };
1516
1617 struct omap2_mcspi_device_config {