diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-14 02:38:37 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-14 02:38:37 +0300 |
commit | bb3dd056ed1af9b186f0d9fe849eab78c51d14ce (patch) | |
tree | ba5c44647d2ee786426d53c446a99dcecd64e9fb /drivers/spi/spi.c | |
parent | 7b882cb800095f216c9da6b6735d10d26df8168b (diff) | |
parent | fafd67940774733fa97f4b09412aea6981b82e0a (diff) | |
download | linux-bb3dd056ed1af9b186f0d9fe849eab78c51d14ce.tar.xz |
Merge tag 'spi-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi updates from Mark Brown:
"The nicest things about this release for me is seeing some older
drivers getting some cleanups and modernization, it's really good to
see things moving forwards even for older drivers.
In content terms it's a fairly humdrum release but where the work has
been happening is great.
- Support for simultaneous use of internal and GPIO chip selects for
devices that require the use of the internal select even if it's
not connected and a GPIO is actually routed to the slave device.
- A major rework and cleanup of the fsl-espi driver from Heiner
Kallweit which should make it work substantially better.
- DMA support for Freescale DSPI IPs.
- New drivers for Freescale LPSPI IPs and Marvell Armada 3700.
- Support for Allwinner H3"
* tag 'spi-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (85 commits)
spi: mvebu: fix baudrate calculation for armada variant
spi: Add support for Armada 3700 SPI Controller
spi: armada-3700: Add documentation for the Armada 3700 SPI Controller
spi: fsl-lpspi: quit reading rx fifo under error condition
spi: fsl-lpspi: use GPL as module license
spi: fsl-espi: fix ioread16/iowrite16 endianness
spi: fsl-espi: remove unused linearization code
spi: fsl-espi: eliminate need for linearization when reading from hardware
spi: fsl-espi: eliminate need for linearization when writing to hardware
spi: fsl-espi: determine need for byte swap only once
spi: fsl-lpspi: read lpspi tx/rx fifo size in probe()
spi: fsl-lpspi: use wait_for_completion_timeout() while waiting transfer done
spi: orion: fix comment to mention MVEBU
spi: atmel: remove the use of private channel fields
spi: atmel: trivial: remove unused fields in DMA structure
spi: atmel: Use SPI core DMA mapping framework
spi: atmel: Use core SPI_MASTER_MUST_[RT]X handling
spi: atmel: trivial: move info banner to latest probe action
spi: imx: replace schedule() with cond_resched()
spi: imx: fix potential shift truncation
...
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 838783c3fed0..656dd3e3220c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -697,10 +697,15 @@ static void spi_set_cs(struct spi_device *spi, bool enable) if (spi->mode & SPI_CS_HIGH) enable = !enable; - if (gpio_is_valid(spi->cs_gpio)) + if (gpio_is_valid(spi->cs_gpio)) { gpio_set_value(spi->cs_gpio, !enable); - else if (spi->master->set_cs) + /* Some SPI masters need both GPIO CS & slave_select */ + if ((spi->master->flags & SPI_MASTER_GPIO_SS) && + spi->master->set_cs) + spi->master->set_cs(spi, !enable); + } else if (spi->master->set_cs) { spi->master->set_cs(spi, !enable); + } } #ifdef CONFIG_HAS_DMA @@ -720,6 +725,7 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, int desc_len; int sgs; struct page *vm_page; + struct scatterlist *sg; void *sg_buf; size_t min; int i, ret; @@ -738,6 +744,7 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, if (ret != 0) return ret; + sg = &sgt->sgl[0]; for (i = 0; i < sgs; i++) { if (vmalloced_buf || kmap_buf) { @@ -751,16 +758,17 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, sg_free_table(sgt); return -ENOMEM; } - sg_set_page(&sgt->sgl[i], vm_page, + sg_set_page(sg, vm_page, min, offset_in_page(buf)); } else { min = min_t(size_t, len, desc_len); sg_buf = buf; - sg_set_buf(&sgt->sgl[i], sg_buf, min); + sg_set_buf(sg, sg_buf, min); } buf += min; len -= min; + sg = sg_next(sg); } ret = dma_map_sg(dev, sgt->sgl, sgt->nents, dir); @@ -1034,8 +1042,14 @@ static int spi_transfer_one_message(struct spi_master *master, if (msg->status != -EINPROGRESS) goto out; - if (xfer->delay_usecs) - udelay(xfer->delay_usecs); + if (xfer->delay_usecs) { + u16 us = xfer->delay_usecs; + + if (us <= 10) + udelay(us); + else + usleep_range(us, us + DIV_ROUND_UP(us, 10)); + } if (xfer->cs_change) { if (list_is_last(&xfer->transfer_list, |