diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-11-06 20:33:31 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-11-12 08:36:23 +0100 |
commit | e55e5cd0fd064788f0a9389cfcabb1a0fc507f9e (patch) | |
tree | 29eee8e12ae87083b0a03a9c93080dbd9aa36e35 /drivers/spi/atmel_spi.c | |
parent | b93dfd23c2449d3b4c886d3f5d51a53aa6a906b4 (diff) | |
download | barebox-e55e5cd0fd064788f0a9389cfcabb1a0fc507f9e.tar.gz barebox-e55e5cd0fd064788f0a9389cfcabb1a0fc507f9e.tar.xz |
atmel_spi: after setup the cs need to be disable
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/spi/atmel_spi.c')
-rw-r--r-- | drivers/spi/atmel_spi.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index afbca9fb1b..dbf6af8328 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -66,6 +66,18 @@ static inline bool atmel_spi_is_v2(void) return !cpu_is_at91rm9200(); } +static void atmel_spi_chipselect(struct spi_device *spi, struct atmel_spi *as, int on) +{ + struct spi_master *master = &as->master; + int cs_pin; + int val = ((spi->mode & SPI_CS_HIGH) != 0) == on; + + BUG_ON(spi->chip_select >= master->num_chipselect); + cs_pin = as->cs_pins[spi->chip_select]; + + gpio_direction_output(cs_pin, val); +} + static int atmel_spi_setup(struct spi_device *spi) { struct spi_master *master = spi->master; @@ -78,7 +90,7 @@ static int atmel_spi_setup(struct spi_device *spi) if (spi->controller_data) { csr = (u32)spi->controller_data; spi_writel(as, CSR0, csr); - return 0; + goto out; } dev_dbg(master->dev, "%s mode 0x%08x bits_per_word: %d speed: %d\n", @@ -140,19 +152,10 @@ static int atmel_spi_setup(struct spi_device *spi) if (bits > 0) spi->controller_data = (void *)csr; - return 0; -} - -static void atmel_spi_chipselect(struct spi_device *spi, struct atmel_spi *as, int on) -{ - struct spi_master *master = &as->master; - int cs_pin; - int val = ((spi->mode & SPI_CS_HIGH) != 0) == on; - - BUG_ON(spi->chip_select >= master->num_chipselect); - cs_pin = as->cs_pins[spi->chip_select]; +out: + atmel_spi_chipselect(spi, as, 0); - gpio_direction_output(cs_pin, val); + return 0; } static int atmel_spi_xchg(struct atmel_spi *as, u32 tx_val) |