spi: atmel_spi: Configure CS GPIO as output
On AT91 GPIOs default to being inputs, so we need to explicitly configure CS gpio to being an output. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
d5f52220e6
commit
dd0f42879b
|
@ -172,6 +172,8 @@ static int atmel_spi_setup(struct spi_device *spi)
|
||||||
struct spi_master *master = spi->master;
|
struct spi_master *master = spi->master;
|
||||||
struct atmel_spi *as = to_atmel_spi(master);
|
struct atmel_spi *as = to_atmel_spi(master);
|
||||||
|
|
||||||
|
int npcs_pin;
|
||||||
|
unsigned active = spi->mode & SPI_CS_HIGH;
|
||||||
u32 scbr, csr;
|
u32 scbr, csr;
|
||||||
unsigned int bits = spi->bits_per_word;
|
unsigned int bits = spi->bits_per_word;
|
||||||
unsigned long bus_hz;
|
unsigned long bus_hz;
|
||||||
|
@ -183,6 +185,8 @@ static int atmel_spi_setup(struct spi_device *spi)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npcs_pin = as->cs_pins[spi->chip_select];
|
||||||
|
|
||||||
if (bits < 8 || bits > 16) {
|
if (bits < 8 || bits > 16) {
|
||||||
dev_dbg(&spi->dev,
|
dev_dbg(&spi->dev,
|
||||||
"setup: invalid bits_per_word %u (8 to 16)\n",
|
"setup: invalid bits_per_word %u (8 to 16)\n",
|
||||||
|
@ -235,7 +239,7 @@ static int atmel_spi_setup(struct spi_device *spi)
|
||||||
csr |= SPI_BF(DLYBS, 0);
|
csr |= SPI_BF(DLYBS, 0);
|
||||||
csr |= SPI_BF(DLYBCT, 0);
|
csr |= SPI_BF(DLYBCT, 0);
|
||||||
|
|
||||||
/* gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH)); */
|
gpio_direction_output(npcs_pin, !active);
|
||||||
dev_dbg(master->dev,
|
dev_dbg(master->dev,
|
||||||
"setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n",
|
"setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n",
|
||||||
bus_hz / scbr, bits, spi->mode, spi->chip_select, csr);
|
bus_hz / scbr, bits, spi->mode, spi->chip_select, csr);
|
||||||
|
|
Loading…
Reference in New Issue