spi-imx: fix initial chipselect settings
authorSascha Hauer <s.hauer@pengutronix.de>
Thu, 1 Oct 2009 22:44:29 +0000 (15:44 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Oct 2009 23:11:16 +0000 (16:11 -0700)
We can only setup the gpio pins in spi_setup time when we know the
SPI_CS_HIGH setting.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-K├Ânig <u.kleine-koenig@pengutronix.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/spi/spi_imx.c

index a8f9bff529e5a4c4f7c4750284a1a4fe1ec45551..b91a5a8f6da6a243d260a476b4d16be08d5a542b 100644 (file)
@@ -478,12 +478,18 @@ static int spi_imx_transfer(struct spi_device *spi,
 
 static int spi_imx_setup(struct spi_device *spi)
 {
+       struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
+       int gpio = spi_imx->chipselect[spi->chip_select];
+
        if (!spi->bits_per_word)
                spi->bits_per_word = 8;
 
        pr_debug("%s: mode %d, %u bpw, %d hz\n", __func__,
                 spi->mode, spi->bits_per_word, spi->max_speed_hz);
 
+       if (gpio >= 0)
+               gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
+
        spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
 
        return 0;
@@ -532,7 +538,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "can't get cs gpios");
                        goto out_master_put;
                }
-               gpio_direction_output(spi_imx->chipselect[i], 1);
        }
 
        spi_imx->bitbang.chipselect = spi_imx_chipselect;