ar71xx: spi-ath79: fix initial GPIO CS line setup
authorGabor Juhos <juhosg@openwrt.org>
Sat, 22 Feb 2014 16:17:28 +0000 (16:17 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 22 Feb 2014 16:17:28 +0000 (16:17 +0000)
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 39695

target/linux/ar71xx/patches-3.10/200-spi-ath79-fix-initial-GPIO-CS-line-setup.patch [new file with mode: 0644]
target/linux/ar71xx/patches-3.10/206-spi-ath79-make-chipselect-logic-more-flexible.patch

diff --git a/target/linux/ar71xx/patches-3.10/200-spi-ath79-fix-initial-GPIO-CS-line-setup.patch b/target/linux/ar71xx/patches-3.10/200-spi-ath79-fix-initial-GPIO-CS-line-setup.patch
new file mode 100644 (file)
index 0000000..4665794
--- /dev/null
@@ -0,0 +1,37 @@
+From 3a7853f0dd24e81dc920c98a5c7e8cfdde81bb45 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Thu, 16 Jan 2014 16:58:58 +0100
+Subject: [PATCH] spi-ath79: fix initial GPIO CS line setup
+
+The 'ath79_spi_setup_cs' function initializes the chip
+select line of a given SPI device in order to make sure
+that the device is inactive.
+
+If the SPI_CS_HIGH bit is set for a given device, it
+means that the CS line of that device is active HIGH
+so it must be set to LOW initially. In case of GPIO
+CS lines, the 'ath79_spi_setup_cs' function does the
+opposite of that due to the wrong GPIO flags.
+
+Fix the code to use the correct GPIO flags.
+
+Reported-by: Ronald Wahl <ronald.wahl@raritan.com>
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/spi/spi-ath79.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/spi/spi-ath79.c
++++ b/drivers/spi/spi-ath79.c
+@@ -132,9 +132,9 @@ static int ath79_spi_setup_cs(struct spi
+               flags = GPIOF_DIR_OUT;
+               if (spi->mode & SPI_CS_HIGH)
+-                      flags |= GPIOF_INIT_HIGH;
+-              else
+                       flags |= GPIOF_INIT_LOW;
++              else
++                      flags |= GPIOF_INIT_HIGH;
+               status = gpio_request_one(cdata->gpio, flags,
+                                         dev_name(&spi->dev));
index 93df466fdf74981cdb6b7c2217943a7552303c2c..b57dd5d5bab51bf3fe2c02f43f4cd07ed7dd2edc 100644 (file)
@@ -236,9 +236,9 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
 +      case ATH79_SPI_CS_TYPE_GPIO:
                flags = GPIOF_DIR_OUT;
                if (spi->mode & SPI_CS_HIGH)
-                       flags |= GPIOF_INIT_HIGH;
-               else
                        flags |= GPIOF_INIT_LOW;
+               else
+                       flags |= GPIOF_INIT_HIGH;
  
 -              status = gpio_request_one(cdata->gpio, flags,
 +              status = gpio_request_one(cdata->cs_line, flags,