Commit 3f27b57c authored by Brian Niebuhr's avatar Brian Niebuhr Committed by Sekhar Nori

spi: davinci: enable and power-up SPI only when required

Enable SPI only when active transfers are in progress. Keep
it in local low power when not in use.
Signed-off-by: default avatarBrian Niebuhr <bniebuhr@efjohnson.com>
Tested-By: default avatarMichael Williamson <michael.williamson@criticallink.com>
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
parent 3409e408
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#define SPIFMT_WDELAY_SHIFT 24 #define SPIFMT_WDELAY_SHIFT 24
#define SPIFMT_PRESCALE_SHIFT 8 #define SPIFMT_PRESCALE_SHIFT 8
/* SPIPC0 */ /* SPIPC0 */
#define SPIPC0_DIFUN_MASK BIT(11) /* MISO */ #define SPIPC0_DIFUN_MASK BIT(11) /* MISO */
#define SPIPC0_DOFUN_MASK BIT(10) /* MOSI */ #define SPIPC0_DOFUN_MASK BIT(10) /* MOSI */
...@@ -67,6 +66,7 @@ ...@@ -67,6 +66,7 @@
/* SPIGCR1 */ /* SPIGCR1 */
#define SPIGCR1_CLKMOD_MASK BIT(1) #define SPIGCR1_CLKMOD_MASK BIT(1)
#define SPIGCR1_MASTER_MASK BIT(0) #define SPIGCR1_MASTER_MASK BIT(0)
#define SPIGCR1_POWERDOWN_MASK BIT(8)
#define SPIGCR1_LOOPBACK_MASK BIT(16) #define SPIGCR1_LOOPBACK_MASK BIT(16)
#define SPIGCR1_SPIENA_MASK BIT(24) #define SPIGCR1_SPIENA_MASK BIT(24)
...@@ -556,7 +556,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -556,7 +556,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
data1_reg_val = ioread32(davinci_spi->base + SPIDAT1); data1_reg_val = ioread32(davinci_spi->base + SPIDAT1);
/* Enable SPI */ clear_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_POWERDOWN_MASK);
set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_SPIENA_MASK); set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);
INIT_COMPLETION(davinci_spi->done); INIT_COMPLETION(davinci_spi->done);
...@@ -693,6 +693,9 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -693,6 +693,9 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
clear_io_bits(davinci_spi->base + SPIINT, SPIINT_DMA_REQ_EN); clear_io_bits(davinci_spi->base + SPIINT, SPIINT_DMA_REQ_EN);
} }
clear_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);
set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_POWERDOWN_MASK);
/* /*
* Check for bit error, desync error,parity error,timeout error and * Check for bit error, desync error,parity error,timeout error and
* receive overflow errors * receive overflow errors
...@@ -937,6 +940,7 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -937,6 +940,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
/* master mode default */ /* master mode default */
set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_CLKMOD_MASK); set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_CLKMOD_MASK);
set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_MASTER_MASK); set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_MASTER_MASK);
set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_POWERDOWN_MASK);
ret = spi_bitbang_start(&davinci_spi->bitbang); ret = spi_bitbang_start(&davinci_spi->bitbang);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment