Merge remote-tracking branches 'spi/topic/rockchip', 'spi/topic/rspi', 'spi/topic...
authorMark Brown <broonie@kernel.org>
Sun, 19 Feb 2017 16:41:05 +0000 (16:41 +0000)
committerMark Brown <broonie@kernel.org>
Sun, 19 Feb 2017 16:41:05 +0000 (16:41 +0000)
1  2  3  4  5  6 
drivers/spi/spi-rspi.c
drivers/spi/spi-s3c64xx.c
drivers/spi/spi.c

diff --combined drivers/spi/spi-rspi.c
index bc3c8686f4d95fb5cb5f7973423498a0d9f3eb5e,9daf500317376bd143cb56eb4b14738d11adbdca,58b7e68013f3bcdc39e669146b9bf017b80439ac,9daf500317376bd143cb56eb4b14738d11adbdca,9daf500317376bd143cb56eb4b14738d11adbdca,9daf500317376bd143cb56eb4b14738d11adbdca..2a10b3f94ff72a4ea3d6924a082ef6d2db174528
@@@@@@@ -808,7 -808,7 -808,7 -808,7 -808,7 -808,7 +808,7 @@@@@@@ static int qspi_transfer_out(struct rsp
                        for (i = 0; i < len; i++)
                                rspi_write_data(rspi, *tx++);
                } else {
 -----                  ret = rspi_pio_transfer(rspi, tx, NULL, n);
 +++++                  ret = rspi_pio_transfer(rspi, tx, NULL, len);
                        if (ret < 0)
                                return ret;
                }
@@@@@@@ -845,9 -845,10 -845,10 -845,10 -845,10 -845,10 +845,9 @@@@@@@ static int qspi_transfer_in(struct rspi
                        for (i = 0; i < len; i++)
                                *rx++ = rspi_read_data(rspi);
                } else {
 -----                  ret = rspi_pio_transfer(rspi, NULL, rx, n);
 +++++                  ret = rspi_pio_transfer(rspi, NULL, rx, len);
                        if (ret < 0)
                                return ret;
 -----                  *rx++ = ret;
                }
                n -= len;
        }
@@@@@@@ -1226,10 -1227,10 -1227,8 -1227,10 -1227,10 -1227,10 +1226,8 @@@@@@@ static int rspi_probe(struct platform_d
        const struct spi_ops *ops;
      
        master = spi_alloc_master(&pdev->dev, sizeof(struct rspi_data));
-- ---  if (master == NULL) {
-- ---          dev_err(&pdev->dev, "spi_alloc_master error.\n");
++ +++  if (master == NULL)
                return -ENOMEM;
-- ---  }
      
        of_id = of_match_device(rspi_of_match, &pdev->dev);
        if (of_id) {
index 186342b74141432558bb405e865398a370b2fda4,3c09e94cf827f63b20f9e53d4523cbdaeba7718d,3c09e94cf827f63b20f9e53d4523cbdaeba7718d,b8cd356d8d100c101cbfd9c10637869f2616e2b0,3c09e94cf827f63b20f9e53d4523cbdaeba7718d,3c09e94cf827f63b20f9e53d4523cbdaeba7718d..b392cca8fa4f5ba3c1c499ea8b1bc228fcabdbee
@@@@@@@ -341,50 -341,50 -341,50 -341,16 -341,50 -341,50 +341,16 @@@@@@@ static void s3c64xx_spi_set_cs(struct s
      static int s3c64xx_spi_prepare_transfer(struct spi_master *spi)
      {
        struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi);
--- --  dma_filter_fn filter = sdd->cntrlr_info->filter;
--- --  struct device *dev = &sdd->pdev->dev;
--- --  dma_cap_mask_t mask;
      
        if (is_polling(sdd))
                return 0;
      
--- --  dma_cap_zero(mask);
--- --  dma_cap_set(DMA_SLAVE, mask);
--- --
--- --  /* Acquire DMA channels */
--- --  sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter,
--- --                     sdd->cntrlr_info->dma_rx, dev, "rx");
--- --  if (!sdd->rx_dma.ch) {
--- --          dev_err(dev, "Failed to get RX DMA channel\n");
--- --          return -EBUSY;
--- --  }
        spi->dma_rx = sdd->rx_dma.ch;
--- --
--- --  sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter,
--- --                     sdd->cntrlr_info->dma_tx, dev, "tx");
--- --  if (!sdd->tx_dma.ch) {
--- --          dev_err(dev, "Failed to get TX DMA channel\n");
--- --          dma_release_channel(sdd->rx_dma.ch);
--- --          return -EBUSY;
--- --  }
        spi->dma_tx = sdd->tx_dma.ch;
      
        return 0;
      }
      
--- --static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi)
--- --{
--- --  struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi);
--- --
--- --  /* Free DMA channels */
--- --  if (!is_polling(sdd)) {
--- --          dma_release_channel(sdd->rx_dma.ch);
--- --          dma_release_channel(sdd->tx_dma.ch);
--- --  }
--- --
--- --  return 0;
--- --}
--- --
      static bool s3c64xx_spi_can_dma(struct spi_master *master,
                                struct spi_device *spi,
                                struct spi_transfer *xfer)
@@@@@@@ -1003,7 -1003,7 -1003,7 -969,7 -1003,7 -1003,7 +969,7 @@@@@@@ static struct s3c64xx_spi_info *s3c64xx
                sci->num_cs = temp;
        }
      
 -----  sci->no_cs = of_property_read_bool(dev->of_node, "broken-cs");
 +++++  sci->no_cs = of_property_read_bool(dev->of_node, "no-cs-readback");
      
        return sci;
      }
@@@@@@@ -1091,11 -1091,11 -1091,11 -1057,6 -1091,11 -1091,11 +1057,6 @@@@@@@ static int s3c64xx_spi_probe(struct pla
      
        sdd->cur_bpw = 8;
      
--- --  if (!sdd->pdev->dev.of_node && (!sci->dma_tx || !sci->dma_rx)) {
--- --          dev_warn(&pdev->dev, "Unable to get SPI tx/rx DMA data. Switching to poll mode\n");
--- --          sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
--- --  }
--- --
        sdd->tx_dma.direction = DMA_MEM_TO_DEV;
        sdd->rx_dma.direction = DMA_DEV_TO_MEM;
      
        master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer;
        master->prepare_message = s3c64xx_spi_prepare_message;
        master->transfer_one = s3c64xx_spi_transfer_one;
--- --  master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
        master->num_chipselect = sci->num_cs;
        master->dma_alignment = 8;
        master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) |
                }
        }
      
+++ ++  if (!is_polling(sdd)) {
+++ ++          /* Acquire DMA channels */
+++ ++          sdd->rx_dma.ch = dma_request_slave_channel_reason(&pdev->dev,
+++ ++                                                            "rx");
+++ ++          if (IS_ERR(sdd->rx_dma.ch)) {
+++ ++                  dev_err(&pdev->dev, "Failed to get RX DMA channel\n");
+++ ++                  ret = PTR_ERR(sdd->rx_dma.ch);
+++ ++                  goto err_disable_io_clk;
+++ ++          }
+++ ++          sdd->tx_dma.ch = dma_request_slave_channel_reason(&pdev->dev,
+++ ++                                                            "tx");
+++ ++          if (IS_ERR(sdd->tx_dma.ch)) {
+++ ++                  dev_err(&pdev->dev, "Failed to get TX DMA channel\n");
+++ ++                  ret = PTR_ERR(sdd->tx_dma.ch);
+++ ++                  goto err_release_rx_dma;
+++ ++          }
+++ ++  }
+++ ++
        pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
        pm_runtime_use_autosuspend(&pdev->dev);
        pm_runtime_set_active(&pdev->dev);
      
        dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
                                        sdd->port_id, master->num_chipselect);
--- --  dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%p, Tx-%p]\n",
--- --                                  mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
--- --                                  sci->dma_rx, sci->dma_tx);
+++ ++  dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n",
+++ ++                                  mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1);
      
        pm_runtime_mark_last_busy(&pdev->dev);
        pm_runtime_put_autosuspend(&pdev->dev);
@@@@@@@ -1219,6 -1219,6 -1219,6 -1196,12 -1219,6 -1219,6 +1196,12 @@@@@@@ err_pm_put
        pm_runtime_disable(&pdev->dev);
        pm_runtime_set_suspended(&pdev->dev);
      
+++ ++  if (!is_polling(sdd))
+++ ++          dma_release_channel(sdd->tx_dma.ch);
+++ ++err_release_rx_dma:
+++ ++  if (!is_polling(sdd))
+++ ++          dma_release_channel(sdd->rx_dma.ch);
+++ ++err_disable_io_clk:
        clk_disable_unprepare(sdd->ioclk);
      err_disable_src_clk:
        clk_disable_unprepare(sdd->src_clk);
@@@@@@@ -1239,6 -1239,6 -1239,6 -1222,11 -1239,6 -1239,6 +1222,11 @@@@@@@ static int s3c64xx_spi_remove(struct pl
      
        writel(0, sdd->regs + S3C64XX_SPI_INT_EN);
      
+++ ++  if (!is_polling(sdd)) {
+++ ++          dma_release_channel(sdd->rx_dma.ch);
+++ ++          dma_release_channel(sdd->tx_dma.ch);
+++ ++  }
+++ ++
        clk_disable_unprepare(sdd->ioclk);
      
        clk_disable_unprepare(sdd->src_clk);
diff --combined drivers/spi/spi.c
index e70955339d33d3a6566afacb90947006fcf21c7b,656dd3e3220c5062b43b5a162a078f245f90630c,656dd3e3220c5062b43b5a162a078f245f90630c,656dd3e3220c5062b43b5a162a078f245f90630c,656dd3e3220c5062b43b5a162a078f245f90630c,1861255866d78dfad51a879f42fd3541a75bece6..f274df9e0e3e2265c723139bb2b2f92ad72e32ba
@@@@@@@ -621,10 -621,8 -621,8 -621,8 -621,8 -621,8 +621,10 @@@@@@@ void spi_unregister_device(struct spi_d
        if (!spi)
                return;
      
 -----  if (spi->dev.of_node)
 +++++  if (spi->dev.of_node) {
                of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
 +++++          of_node_put(spi->dev.of_node);
 +++++  }
        if (ACPI_COMPANION(&spi->dev))
                acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
        device_unregister(&spi->dev);
@@@@@@@ -674,7 -672,7 -672,7 -672,7 -672,7 -672,7 +674,7 @@@@@@@ int spi_register_board_info(struct spi_
        if (!n)
                return -EINVAL;
      
 -----  bi = kzalloc(n * sizeof(*bi), GFP_KERNEL);
 +++++  bi = kcalloc(n, sizeof(*bi), GFP_KERNEL);
        if (!bi)
                return -ENOMEM;
      
@@@@@@@ -807,12 -805,12 -805,12 -805,12 -805,12 -805,12 +807,12 @@@@@@@ static int __spi_map_msg(struct spi_mas
        if (master->dma_tx)
                tx_dev = master->dma_tx->device->dev;
        else
 -----          tx_dev = &master->dev;
 +++++          tx_dev = master->dev.parent;
      
        if (master->dma_rx)
                rx_dev = master->dma_rx->device->dev;
        else
 -----          rx_dev = &master->dev;
 +++++          rx_dev = master->dev.parent;
      
        list_for_each_entry(xfer, &msg->transfers, transfer_list) {
                if (!master->can_dma(master, msg->spi, xfer))
@@@@@@@ -854,12 -852,12 -852,12 -852,12 -852,12 -852,12 +854,12 @@@@@@@ static int __spi_unmap_msg(struct spi_m
        if (master->dma_tx)
                tx_dev = master->dma_tx->device->dev;
        else
 -----          tx_dev = &master->dev;
 +++++          tx_dev = master->dev.parent;
      
        if (master->dma_rx)
                rx_dev = master->dma_rx->device->dev;
        else
 -----          rx_dev = &master->dev;
 +++++          rx_dev = master->dev.parent;
      
        list_for_each_entry(xfer, &msg->transfers, transfer_list) {
                if (!master->can_dma(master, msg->spi, xfer))
@@@@@@@ -1504,37 -1502,37 -1502,37 -1502,37 -1502,37 -1502,18 +1504,18 @@@@@@@ err_init_queue
      /*-------------------------------------------------------------------------*/
      
      #if defined(CONFIG_OF)
----- static struct spi_device *
----- of_register_spi_device(struct spi_master *master, struct device_node *nc)
+++++ static int of_spi_parse_dt(struct spi_master *master, struct spi_device *spi,
+++++                      struct device_node *nc)
      {
-----   struct spi_device *spi;
-----   int rc;
        u32 value;
----- 
-----   /* Alloc an spi_device */
-----   spi = spi_alloc_device(master);
-----   if (!spi) {
-----           dev_err(&master->dev, "spi_device alloc error for %s\n",
-----                   nc->full_name);
-----           rc = -ENOMEM;
-----           goto err_out;
-----   }
----- 
-----   /* Select device driver */
-----   rc = of_modalias_node(nc, spi->modalias,
-----                           sizeof(spi->modalias));
-----   if (rc < 0) {
-----           dev_err(&master->dev, "cannot find modalias for %s\n",
-----                   nc->full_name);
-----           goto err_out;
-----   }
+++++   int rc;
      
        /* Device address */
        rc = of_property_read_u32(nc, "reg", &value);
        if (rc) {
                dev_err(&master->dev, "%s has no valid 'reg' property (%d)\n",
                        nc->full_name, rc);
-----           goto err_out;
+++++           return rc;
        }
        spi->chip_select = value;
      
        if (rc) {
                dev_err(&master->dev, "%s has no valid 'spi-max-frequency' property (%d)\n",
                        nc->full_name, rc);
-----           goto err_out;
+++++           return rc;
        }
        spi->max_speed_hz = value;
      
+++++   return 0;
+++++ }
+++++ 
+++++ static struct spi_device *
+++++ of_register_spi_device(struct spi_master *master, struct device_node *nc)
+++++ {
+++++   struct spi_device *spi;
+++++   int rc;
+++++ 
+++++   /* Alloc an spi_device */
+++++   spi = spi_alloc_device(master);
+++++   if (!spi) {
+++++           dev_err(&master->dev, "spi_device alloc error for %s\n",
+++++                   nc->full_name);
+++++           rc = -ENOMEM;
+++++           goto err_out;
+++++   }
+++++ 
+++++   /* Select device driver */
+++++   rc = of_modalias_node(nc, spi->modalias,
+++++                           sizeof(spi->modalias));
+++++   if (rc < 0) {
+++++           dev_err(&master->dev, "cannot find modalias for %s\n",
+++++                   nc->full_name);
+++++           goto err_out;
+++++   }
+++++ 
+++++   rc = of_spi_parse_dt(master, spi, nc);
+++++   if (rc)
+++++           goto err_out;
+++++ 
        /* Store a pointer to the node in the device structure */
        of_node_get(nc);
        spi->dev.of_node = nc;
        if (rc) {
                dev_err(&master->dev, "spi_device register error %s\n",
                        nc->full_name);
 -----          goto err_out;
 +++++          goto err_of_node_put;
        }
      
        return spi;
      
 +++++err_of_node_put:
 +++++  of_node_put(nc);
      err_out:
        spi_dev_put(spi);
        return ERR_PTR(rc);