Merge tag 'v5.13-rc2' into spi-5.13
authorMark Brown <broonie@kernel.org>
Tue, 18 May 2021 16:24:52 +0000 (17:24 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 18 May 2021 16:24:52 +0000 (17:24 +0100)
Linux 5.13-rc2

Documentation/devicetree/bindings/spi/spi-mux.yaml
MAINTAINERS
drivers/spi/Kconfig
drivers/spi/spi-fsl-dspi.c
drivers/spi/spi-sprd.c
drivers/spi/spi-zynq-qspi.c
drivers/spi/spi.c
include/linux/spi/spi.h

index d09c6355e22dcecffcbf874cd78fe32432cb3583..51c7622dc20b41675d1138c77aa1c3297e3f7a9d 100644 (file)
@@ -72,7 +72,7 @@ examples:
 
             mux-controls = <&mux>;
 
-            spi-flash@0 {
+            flash@0 {
                 compatible = "jedec,spi-nor";
                 reg = <0>;
                 spi-max-frequency = <40000000>;
index 008fcad7ac00814a5156e1623dcf6790296ad260..49245e9fcb69a441cf363f7802f7dc3a2bd9784d 100644 (file)
@@ -17304,6 +17304,12 @@ L:     linux-i2c@vger.kernel.org
 S:     Maintained
 F:     drivers/i2c/busses/i2c-stm32*
 
+ST STM32 SPI DRIVER
+M:     Alain Volmat <alain.volmat@foss.st.com>
+L:     linux-spi@vger.kernel.org
+S:     Maintained
+F:     drivers/spi/spi-stm32.c
+
 ST STPDDC60 DRIVER
 M:     Daniel Nilsson <daniel.nilsson@flex.com>
 L:     linux-hwmon@vger.kernel.org
index 8b161ec4943bfe05d4b406c7eb96bd04c6273100..f4481fe48bf0698fbf5d371353060316473e48b4 100644 (file)
@@ -65,7 +65,7 @@ config SPI_ALTERA
          This is the driver for the Altera SPI Controller.
 
 config SPI_ALTERA_CORE
-       tristate "Altera SPI Controller core code"
+       tristate "Altera SPI Controller core code" if COMPILE_TEST
        select REGMAP
        help
          "The core code for the Altera SPI Controller"
index 0287366874882de8bd941b8617b9625288088772..fb45e6af6638136ed071c282c74572697a32d198 100644 (file)
@@ -1375,11 +1375,13 @@ poll_mode:
        ret = spi_register_controller(ctlr);
        if (ret != 0) {
                dev_err(&pdev->dev, "Problem registering DSPI ctlr\n");
-               goto out_free_irq;
+               goto out_release_dma;
        }
 
        return ret;
 
+out_release_dma:
+       dspi_release_dma(dspi);
 out_free_irq:
        if (dspi->irq)
                free_irq(dspi->irq, dspi);
index b41a75749b498ed36d1361c5d2da1e4f857cb584..28e70db9bbba852d40ab53d211aada4353cf93a2 100644 (file)
@@ -1068,6 +1068,7 @@ static const struct of_device_id sprd_spi_of_match[] = {
        { .compatible = "sprd,sc9860-spi", },
        { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, sprd_spi_of_match);
 
 static struct platform_driver sprd_spi_driver = {
        .driver = {
index 5d8a5ee62fa236bbf207f24d778209f089cb077d..5a3d81c31d0407aef1a8a898a165ecab2af9baa2 100644 (file)
@@ -367,7 +367,7 @@ static int zynq_qspi_config_op(struct zynq_qspi *xqspi, struct spi_device *spi)
 }
 
 /**
- * zynq_qspi_setup - Configure the QSPI controller
+ * zynq_qspi_setup_op - Configure the QSPI controller
  * @spi:       Pointer to the spi_device structure
  *
  * Sets the operational mode of QSPI controller for the next QSPI transfer, baud
@@ -528,18 +528,17 @@ static int zynq_qspi_exec_mem_op(struct spi_mem *mem,
        struct zynq_qspi *xqspi = spi_controller_get_devdata(mem->spi->master);
        int err = 0, i;
        u8 *tmpbuf;
-       u8 opcode = op->cmd.opcode;
 
        dev_dbg(xqspi->dev, "cmd:%#x mode:%d.%d.%d.%d\n",
-               opcode, op->cmd.buswidth, op->addr.buswidth,
+               op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
                op->dummy.buswidth, op->data.buswidth);
 
        zynq_qspi_chipselect(mem->spi, true);
        zynq_qspi_config_op(xqspi, mem->spi);
 
-       if (op->cmd.nbytes) {
+       if (op->cmd.opcode) {
                reinit_completion(&xqspi->data_completion);
-               xqspi->txbuf = &opcode;
+               xqspi->txbuf = (u8 *)&op->cmd.opcode;
                xqspi->rxbuf = NULL;
                xqspi->tx_bytes = op->cmd.nbytes;
                xqspi->rx_bytes = op->cmd.nbytes;
index ba425b9c77007ab9989d70c5be143ffebf69caa3..e353b7a9e54ebad4f5aa3d3262f474c289e3dc57 100644 (file)
@@ -47,10 +47,6 @@ static void spidev_release(struct device *dev)
 {
        struct spi_device       *spi = to_spi_device(dev);
 
-       /* spi controllers may cleanup for released devices */
-       if (spi->controller->cleanup)
-               spi->controller->cleanup(spi);
-
        spi_controller_put(spi->controller);
        kfree(spi->driver_override);
        kfree(spi);
@@ -558,6 +554,12 @@ static int spi_dev_check(struct device *dev, void *data)
        return 0;
 }
 
+static void spi_cleanup(struct spi_device *spi)
+{
+       if (spi->controller->cleanup)
+               spi->controller->cleanup(spi);
+}
+
 /**
  * spi_add_device - Add spi_device allocated with spi_alloc_device
  * @spi: spi_device to register
@@ -622,11 +624,13 @@ int spi_add_device(struct spi_device *spi)
 
        /* Device may be bound to an active driver when this returns */
        status = device_add(&spi->dev);
-       if (status < 0)
+       if (status < 0) {
                dev_err(dev, "can't add %s, status %d\n",
                                dev_name(&spi->dev), status);
-       else
+               spi_cleanup(spi);
+       } else {
                dev_dbg(dev, "registered child %s\n", dev_name(&spi->dev));
+       }
 
 done:
        mutex_unlock(&spi_add_lock);
@@ -717,7 +721,9 @@ void spi_unregister_device(struct spi_device *spi)
        if (ACPI_COMPANION(&spi->dev))
                acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
        device_remove_software_node(&spi->dev);
-       device_unregister(&spi->dev);
+       device_del(&spi->dev);
+       spi_cleanup(spi);
+       put_device(&spi->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_device);
 
@@ -814,15 +820,29 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
 
        if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio)) {
                if (!(spi->mode & SPI_NO_CS)) {
-                       if (spi->cs_gpiod)
-                               /* polarity handled by gpiolib */
-                               gpiod_set_value_cansleep(spi->cs_gpiod, activate);
-                       else
+                       if (spi->cs_gpiod) {
+                               /*
+                                * Historically ACPI has no means of the GPIO polarity and
+                                * thus the SPISerialBus() resource defines it on the per-chip
+                                * basis. In order to avoid a chain of negations, the GPIO
+                                * polarity is considered being Active High. Even for the cases
+                                * when _DSD() is involved (in the updated versions of ACPI)
+                                * the GPIO CS polarity must be defined Active High to avoid
+                                * ambiguity. That's why we use enable, that takes SPI_CS_HIGH
+                                * into account.
+                                */
+                               if (has_acpi_companion(&spi->dev))
+                                       gpiod_set_value_cansleep(spi->cs_gpiod, !enable);
+                               else
+                                       /* Polarity handled by GPIO library */
+                                       gpiod_set_value_cansleep(spi->cs_gpiod, activate);
+                       } else {
                                /*
                                 * invert the enable line, as active low is
                                 * default for SPI.
                                 */
                                gpio_set_value_cansleep(spi->cs_gpio, !enable);
+                       }
                }
                /* Some SPI masters need both GPIO CS & slave_select */
                if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
@@ -3451,9 +3471,12 @@ int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup,
 
        if (spi->controller->set_cs_timing &&
            !(spi->cs_gpiod || gpio_is_valid(spi->cs_gpio))) {
+               mutex_lock(&spi->controller->io_mutex);
+
                if (spi->controller->auto_runtime_pm) {
                        status = pm_runtime_get_sync(parent);
                        if (status < 0) {
+                               mutex_unlock(&spi->controller->io_mutex);
                                pm_runtime_put_noidle(parent);
                                dev_err(&spi->controller->dev, "Failed to power device: %d\n",
                                        status);
@@ -3464,11 +3487,13 @@ int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup,
                                                                hold, inactive);
                        pm_runtime_mark_last_busy(parent);
                        pm_runtime_put_autosuspend(parent);
-                       return status;
                } else {
-                       return spi->controller->set_cs_timing(spi, setup, hold,
+                       status = spi->controller->set_cs_timing(spi, setup, hold,
                                                              inactive);
                }
+
+               mutex_unlock(&spi->controller->io_mutex);
+               return status;
        }
 
        if ((setup && setup->unit == SPI_DELAY_UNIT_SCK) ||
index 360a3bc767ca0442dd71f7bbfab7174eb942d4df..74239d65c7fd132143c921d822ed4a39e1ecf52c 100644 (file)
@@ -644,8 +644,8 @@ struct spi_controller {
        int                     *cs_gpios;
        struct gpio_desc        **cs_gpiods;
        bool                    use_gpio_descriptors;
-       u8                      unused_native_cs;
-       u8                      max_native_cs;
+       s8                      unused_native_cs;
+       s8                      max_native_cs;
 
        /* statistics */
        struct spi_statistics   statistics;