static void spi_set_cs(struct spi_device *spi, bool enable)
 {
+       bool enable1 = enable;
+
+       if (!spi->controller->set_cs_timing) {
+               if (enable1)
+                       spi_delay_exec(&spi->controller->cs_setup, NULL);
+               else
+                       spi_delay_exec(&spi->controller->cs_hold, NULL);
+       }
+
        if (spi->mode & SPI_CS_HIGH)
                enable = !enable;
 
        } else if (spi->controller->set_cs) {
                spi->controller->set_cs(spi, !enable);
        }
+
+       if (!spi->controller->set_cs_timing) {
+               if (!enable1)
+                       spi_delay_exec(&spi->controller->cs_inactive, NULL);
+       }
 }
 
 #ifdef CONFIG_HAS_DMA
 int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup,
                      struct spi_delay *hold, struct spi_delay *inactive)
 {
+       size_t len;
+
        if (spi->controller->set_cs_timing)
                return spi->controller->set_cs_timing(spi, setup, hold,
                                                      inactive);
-       return -ENOTSUPP;
+
+       if ((setup && setup->unit == SPI_DELAY_UNIT_SCK) ||
+           (hold && hold->unit == SPI_DELAY_UNIT_SCK) ||
+           (inactive && inactive->unit == SPI_DELAY_UNIT_SCK)) {
+               dev_err(&spi->dev,
+                       "Clock-cycle delays for CS not supported in SW mode\n");
+               return -ENOTSUPP;
+       }
+
+       len = sizeof(struct spi_delay);
+
+       /* copy delays to controller */
+       if (setup)
+               memcpy(&spi->controller->cs_setup, setup, len);
+       else
+               memset(&spi->controller->cs_setup, 0, len);
+
+       if (hold)
+               memcpy(&spi->controller->cs_hold, hold, len);
+       else
+               memset(&spi->controller->cs_hold, 0, len);
+
+       if (inactive)
+               memcpy(&spi->controller->cs_inactive, inactive, len);
+       else
+               memset(&spi->controller->cs_inactive, 0, len);
+
+       return 0;
 }
 EXPORT_SYMBOL_GPL(spi_set_cs_timing);