[PATCH 3/3] spi: atmel: request cs pin via gpiolib

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Dec 28 11:46:31 EST 2012


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 793933e..08cb416 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -371,6 +371,7 @@ err:
 static int atmel_spi_probe(struct device_d *dev)
 {
 	int ret = 0;
+	int i;
 	struct spi_master *master;
 	struct atmel_spi *as;
 	struct at91_spi_platform_data *pdata = dev->platform_data;
@@ -399,6 +400,12 @@ static int atmel_spi_probe(struct device_d *dev)
 	as->cs_pins = pdata->chipselect;
 	as->regs = dev_request_mem_region(dev, 0);
 
+	for (i = 0; i <= master->num_chipselect; i++) {
+		ret = gpio_request(as->cs_pins[i], dev_name(dev));
+		if (ret)
+			goto out_gpio;
+	}
+
 	/* Initialize the hardware */
 	clk_enable(as->clk);
 	spi_writel(as, CR, SPI_BIT(SWRST));
@@ -418,6 +425,7 @@ static int atmel_spi_probe(struct device_d *dev)
 out_reset_hw:
 	spi_writel(as, CR, SPI_BIT(SWRST));
 	spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+out_gpio:
 	clk_disable(as->clk);
 	clk_put(as->clk);
 out_free:
-- 
1.7.10.4




More information about the barebox mailing list