]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Feb 2020 19:31:00 +0000 (20:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Feb 2020 19:31:00 +0000 (20:31 +0100)
added patches:
mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch

queue-4.4/mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch b/queue-4.4/mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch
new file mode 100644 (file)
index 0000000..c8c37d6
--- /dev/null
@@ -0,0 +1,64 @@
+From af3ed119329cf9690598c5a562d95dfd128e91d6 Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Wed, 4 Dec 2019 16:27:49 +0100
+Subject: mmc: spi: Toggle SPI polarity, do not hardcode it
+
+From: Linus Walleij <linus.walleij@linaro.org>
+
+commit af3ed119329cf9690598c5a562d95dfd128e91d6 upstream.
+
+The code in mmc_spi_initsequence() tries to send a burst with
+high chipselect and for this reason hardcodes the device into
+SPI_CS_HIGH.
+
+This is not good because the SPI_CS_HIGH flag indicates
+logical "asserted" CS not always the physical level. In
+some cases the signal is inverted in the GPIO library and
+in that case SPI_CS_HIGH is already set, and enforcing
+SPI_CS_HIGH again will actually drive it low.
+
+Instead of hard-coding this, toggle the polarity so if the
+default is LOW it goes high to assert chipselect but if it
+is already high then toggle it low instead.
+
+Cc: Phil Elwell <phil@raspberrypi.org>
+Reported-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Reviewed-by: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/r/20191204152749.12652-1-linus.walleij@linaro.org
+Cc: stable@vger.kernel.org
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/mmc/host/mmc_spi.c |   11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+--- a/drivers/mmc/host/mmc_spi.c
++++ b/drivers/mmc/host/mmc_spi.c
+@@ -1153,17 +1153,22 @@ static void mmc_spi_initsequence(struct
+        * SPI protocol.  Another is that when chipselect is released while
+        * the card returns BUSY status, the clock must issue several cycles
+        * with chipselect high before the card will stop driving its output.
++       *
++       * SPI_CS_HIGH means "asserted" here. In some cases like when using
++       * GPIOs for chip select, SPI_CS_HIGH is set but this will be logically
++       * inverted by gpiolib, so if we want to ascertain to drive it high
++       * we should toggle the default with an XOR as we do here.
+        */
+-      host->spi->mode |= SPI_CS_HIGH;
++      host->spi->mode ^= SPI_CS_HIGH;
+       if (spi_setup(host->spi) != 0) {
+               /* Just warn; most cards work without it. */
+               dev_warn(&host->spi->dev,
+                               "can't change chip-select polarity\n");
+-              host->spi->mode &= ~SPI_CS_HIGH;
++              host->spi->mode ^= SPI_CS_HIGH;
+       } else {
+               mmc_spi_readbytes(host, 18);
+-              host->spi->mode &= ~SPI_CS_HIGH;
++              host->spi->mode ^= SPI_CS_HIGH;
+               if (spi_setup(host->spi) != 0) {
+                       /* Wot, we can't get the same setup we had before? */
+                       dev_err(&host->spi->dev,
index 02193d456dfa8b6c876d98b70fe2423c1dae427f..23019ebfbdcf00e03e2ee28152fabbc61930ae49 100644 (file)
@@ -16,3 +16,4 @@ usb-gadget-f_ecm-use-atomic_t-to-track-in-flight-request.patch
 alsa-dummy-fix-pcm-format-loop-in-proc-output.patch
 lib-test_kasan.c-fix-memory-leak-in-kmalloc_oob_krealloc_more.patch
 powerpc-pseries-advance-pfn-if-section-is-not-present-in-lmb_is_removable.patch
+mmc-spi-toggle-spi-polarity-do-not-hardcode-it.patch