From 794912cff6dba8b5e93948243299bb0b2cb11277 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 13 Jun 2016 17:46:50 +0000 Subject: spi: sunxi: expose maximum transfer size limit The sun4i spi hardware can trasfer at most 63 bytes of data without DMA support so report the limitation. Same for sun6i. Signed-off-by: Michal Suchanek Acked-by: Maxime Ripard Signed-off-by: Mark Brown --- drivers/spi/spi-sun4i.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/spi/spi-sun4i.c') diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index 1ddd9e2309b6..07ce7c97750e 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -167,6 +167,11 @@ static void sun4i_spi_set_cs(struct spi_device *spi, bool enable) sun4i_spi_write(sspi, SUN4I_CTL_REG, reg); } +static size_t sun4i_spi_max_transfer_size(struct spi_device *spi) +{ + return SUN4I_FIFO_DEPTH - 1; +} + static int sun4i_spi_transfer_one(struct spi_master *master, struct spi_device *spi, struct spi_transfer *tfr) @@ -394,6 +399,7 @@ static int sun4i_spi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_MASK(8); master->dev.of_node = pdev->dev.of_node; master->auto_runtime_pm = true; + master->max_transfer_size = sun4i_spi_max_transfer_size; sspi->hclk = devm_clk_get(&pdev->dev, "ahb"); if (IS_ERR(sspi->hclk)) { -- cgit v1.2.3 From 0b06d8cf4f9307887d52776d77bdbc8d6dd9d98d Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Tue, 14 Jun 2016 12:10:04 +0000 Subject: spi: sunxi: set maximum and minimum speed of SPI master The speed limits are unset in the sun4i and sun6i SPI drivers. The maximum speed of SPI master is used when maximum speed of SPI slave is not specified. Also the __spi_validate function should check that transfer speeds do not exceed the master limits. The user manual for A10 and A31 specifies maximum speed of the SPI clock as 100MHz and minimum as 3kHz. Setting the SPI clock to out-of-spec values can lock up the SoC. Signed-off-by: Michal Suchanek -- v2: new patch v3: fix constant style Signed-off-by: Mark Brown --- drivers/spi/spi-sun4i.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/spi/spi-sun4i.c') diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index 07ce7c97750e..d02cf9829f1a 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -392,6 +392,8 @@ static int sun4i_spi_probe(struct platform_device *pdev) } sspi->master = master; + master->max_speed_hz = 100 * 1000 * 1000; + master->min_speed_hz = 3 * 1000; master->set_cs = sun4i_spi_set_cs; master->transfer_one = sun4i_spi_transfer_one; master->num_chipselect = 4; -- cgit v1.2.3