Merge tag 'v5.4-rc3' into spi-5.4
[platform/kernel/linux-starfive.git] / drivers / spi / spi.c
index f9502db..38699ea 100644 (file)
@@ -1711,15 +1711,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
                spi->mode |= SPI_3WIRE;
        if (of_property_read_bool(nc, "spi-lsb-first"))
                spi->mode |= SPI_LSB_FIRST;
-
-       /*
-        * For descriptors associated with the device, polarity inversion is
-        * handled in the gpiolib, so all chip selects are "active high" in
-        * the logical sense, the gpiolib will invert the line if need be.
-        */
-       if (ctlr->use_gpio_descriptors)
-               spi->mode |= SPI_CS_HIGH;
-       else if (of_property_read_bool(nc, "spi-cs-high"))
+       if (of_property_read_bool(nc, "spi-cs-high"))
                spi->mode |= SPI_CS_HIGH;
 
        /* Device DUAL/QUAD mode */
@@ -1783,6 +1775,14 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
        }
        spi->chip_select = value;
 
+       /*
+        * For descriptors associated with the device, polarity inversion is
+        * handled in the gpiolib, so all gpio chip selects are "active high"
+        * in the logical sense, the gpiolib will invert the line if need be.
+        */
+       if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods[spi->chip_select])
+               spi->mode |= SPI_CS_HIGH;
+
        /* Device speed */
        rc = of_property_read_u32(nc, "spi-max-frequency", &value);
        if (rc) {