Merge tag 'v5.15.64' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / drivers / spi / spi.c
index 556d65a..147ca28 100644 (file)
@@ -3478,6 +3478,7 @@ static int __spi_validate_bits_per_word(struct spi_controller *ctlr,
  */
 int spi_setup(struct spi_device *spi)
 {
+       struct spi_controller *ctlr = spi->controller;
        unsigned        bad_bits, ugly_bits;
        int             status;
 
@@ -3499,6 +3500,14 @@ int spi_setup(struct spi_device *spi)
                (SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL |
                 SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL)))
                return -EINVAL;
+
+       if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
+           ctlr->cs_gpiods[spi->chip_select] && !(spi->mode & SPI_CS_HIGH)) {
+               dev_dbg(&spi->dev,
+                       "setup: forcing CS_HIGH (use_gpio_descriptors)\n");
+               spi->mode |= SPI_CS_HIGH;
+       }
+
        /* help drivers fail *cleanly* when they need options
         * that aren't supported with their current controller
         * SPI_CS_WORD has a fallback software implementation,