Skip to content

Commit c8d6a77

Browse files
committed
Merge remote-tracking branches 'spi/topic/pxa2xx', 'spi/topic/qup', 'spi/topic/rockchip', 'spi/topic/st-ssc4' and 'spi/topic/xlp' into spi-next
6 parents b340941 + 280af2b + d244228 + 5de7ed0 + 1051550 + bf23d19 commit c8d6a77

File tree

8 files changed

+50
-35
lines changed

8 files changed

+50
-35
lines changed

drivers/spi/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ config SPI_SIRF
580580

581581
config SPI_ST_SSC4
582582
tristate "STMicroelectronics SPI SSC-based driver"
583-
depends on ARCH_STI
583+
depends on ARCH_STI || COMPILE_TEST
584584
help
585585
STMicroelectronics SoCs support for SPI. If you say yes to
586586
this option, support will be included for the SSC driven SPI.
@@ -667,7 +667,7 @@ config SPI_XILINX
667667

668668
config SPI_XLP
669669
tristate "Netlogic XLP SPI controller driver"
670-
depends on CPU_XLP || COMPILE_TEST
670+
depends on CPU_XLP || ARCH_VULCAN || COMPILE_TEST
671671
help
672672
Enable support for the SPI controller on the Netlogic XLP SoCs.
673673
Currently supported XLP variants are XLP8XX, XLP3XX, XLP2XX, XLP9XX

drivers/spi/spi-pxa2xx-dma.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data,
3333
dmadev = drv_data->tx_chan->device->dev;
3434
sgt = &drv_data->tx_sgt;
3535
buf = drv_data->tx;
36-
drv_data->tx_map_len = len;
3736
} else {
3837
dmadev = drv_data->rx_chan->device->dev;
3938
sgt = &drv_data->rx_sgt;
4039
buf = drv_data->rx;
41-
drv_data->rx_map_len = len;
4240
}
4341

4442
nents = DIV_ROUND_UP(len, SZ_2K);
@@ -55,11 +53,7 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data,
5553
for_each_sg(sgt->sgl, sg, sgt->nents, i) {
5654
size_t bytes = min_t(size_t, len, SZ_2K);
5755

58-
if (buf)
59-
sg_set_buf(sg, pbuf, bytes);
60-
else
61-
sg_set_buf(sg, drv_data->dummy, bytes);
62-
56+
sg_set_buf(sg, pbuf, bytes);
6357
pbuf += bytes;
6458
len -= bytes;
6559
}
@@ -133,9 +127,6 @@ static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data,
133127
if (!error) {
134128
pxa2xx_spi_unmap_dma_buffers(drv_data);
135129

136-
drv_data->tx += drv_data->tx_map_len;
137-
drv_data->rx += drv_data->rx_map_len;
138-
139130
msg->actual_length += drv_data->len;
140131
msg->state = pxa2xx_spi_next_transfer(drv_data);
141132
} else {
@@ -267,19 +258,22 @@ irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data)
267258
int pxa2xx_spi_dma_prepare(struct driver_data *drv_data, u32 dma_burst)
268259
{
269260
struct dma_async_tx_descriptor *tx_desc, *rx_desc;
261+
int err = 0;
270262

271263
tx_desc = pxa2xx_spi_dma_prepare_one(drv_data, DMA_MEM_TO_DEV);
272264
if (!tx_desc) {
273265
dev_err(&drv_data->pdev->dev,
274266
"failed to get DMA TX descriptor\n");
275-
return -EBUSY;
267+
err = -EBUSY;
268+
goto err_tx;
276269
}
277270

278271
rx_desc = pxa2xx_spi_dma_prepare_one(drv_data, DMA_DEV_TO_MEM);
279272
if (!rx_desc) {
280273
dev_err(&drv_data->pdev->dev,
281274
"failed to get DMA RX descriptor\n");
282-
return -EBUSY;
275+
err = -EBUSY;
276+
goto err_rx;
283277
}
284278

285279
/* We are ready when RX completes */
@@ -289,6 +283,12 @@ int pxa2xx_spi_dma_prepare(struct driver_data *drv_data, u32 dma_burst)
289283
dmaengine_submit(rx_desc);
290284
dmaengine_submit(tx_desc);
291285
return 0;
286+
287+
err_rx:
288+
dmaengine_terminate_async(drv_data->tx_chan);
289+
err_tx:
290+
pxa2xx_spi_unmap_dma_buffers(drv_data);
291+
return err;
292292
}
293293

294294
void pxa2xx_spi_dma_start(struct driver_data *drv_data)
@@ -308,10 +308,6 @@ int pxa2xx_spi_dma_setup(struct driver_data *drv_data)
308308
dma_cap_zero(mask);
309309
dma_cap_set(DMA_SLAVE, mask);
310310

311-
drv_data->dummy = devm_kzalloc(dev, SZ_2K, GFP_KERNEL);
312-
if (!drv_data->dummy)
313-
return -ENOMEM;
314-
315311
drv_data->tx_chan = dma_request_slave_channel_compat(mask,
316312
pdata->dma_filter, pdata->tx_param, dev, "tx");
317313
if (!drv_data->tx_chan)

drivers/spi/spi-pxa2xx-pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
173173
ssp->type = c->type;
174174

175175
snprintf(buf, sizeof(buf), "pxa2xx-spi.%d", ssp->port_id);
176-
ssp->clk = clk_register_fixed_rate(&dev->dev, buf , NULL,
177-
CLK_IS_ROOT, c->max_clk_rate);
176+
ssp->clk = clk_register_fixed_rate(&dev->dev, buf , NULL, 0,
177+
c->max_clk_rate);
178178
if (IS_ERR(ssp->clk))
179179
return PTR_ERR(ssp->clk);
180180

drivers/spi/spi-pxa2xx.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,8 @@ static void giveback(struct driver_data *drv_data)
570570
/* see if the next and current messages point
571571
* to the same chip
572572
*/
573-
if (next_msg && next_msg->spi != msg->spi)
574-
next_msg = NULL;
575-
if (!next_msg || msg->state == ERROR_STATE)
573+
if ((next_msg && next_msg->spi != msg->spi) ||
574+
msg->state == ERROR_STATE)
576575
cs_deassert(drv_data);
577576
}
578577

@@ -928,6 +927,7 @@ static void pump_transfers(unsigned long data)
928927
u32 dma_thresh = drv_data->cur_chip->dma_threshold;
929928
u32 dma_burst = drv_data->cur_chip->dma_burst_size;
930929
u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data);
930+
int err;
931931

932932
/* Get current state information */
933933
message = drv_data->cur_msg;
@@ -1047,7 +1047,12 @@ static void pump_transfers(unsigned long data)
10471047
/* Ensure we have the correct interrupt handler */
10481048
drv_data->transfer_handler = pxa2xx_spi_dma_transfer;
10491049

1050-
pxa2xx_spi_dma_prepare(drv_data, dma_burst);
1050+
err = pxa2xx_spi_dma_prepare(drv_data, dma_burst);
1051+
if (err) {
1052+
message->status = err;
1053+
giveback(drv_data);
1054+
return;
1055+
}
10511056

10521057
/* Clear status and start DMA engine */
10531058
cr1 = chip->cr1 | dma_thresh | drv_data->dma_cr1;
@@ -1555,6 +1560,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
15551560
master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer;
15561561
master->fw_translate_cs = pxa2xx_spi_fw_translate_cs;
15571562
master->auto_runtime_pm = true;
1563+
master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
15581564

15591565
drv_data->ssp_type = ssp->type;
15601566

drivers/spi/spi-pxa2xx.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct driver_data {
5656
struct sg_table tx_sgt;
5757
int rx_nents;
5858
int tx_nents;
59-
void *dummy;
6059
atomic_t dma_running;
6160

6261
/* Current message transfer state info */
@@ -69,8 +68,6 @@ struct driver_data {
6968
void *rx;
7069
void *rx_end;
7170
int dma_mapped;
72-
size_t rx_map_len;
73-
size_t tx_map_len;
7471
u8 n_bytes;
7572
int (*write)(struct driver_data *drv_data);
7673
int (*read)(struct driver_data *drv_data);

drivers/spi/spi-qup.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,10 @@ static int spi_qup_pm_suspend_runtime(struct device *device)
937937
config = readl(controller->base + QUP_CONFIG);
938938
config |= QUP_CONFIG_CLOCK_AUTO_GATE;
939939
writel_relaxed(config, controller->base + QUP_CONFIG);
940+
941+
clk_disable_unprepare(controller->cclk);
942+
clk_disable_unprepare(controller->iclk);
943+
940944
return 0;
941945
}
942946

@@ -945,6 +949,15 @@ static int spi_qup_pm_resume_runtime(struct device *device)
945949
struct spi_master *master = dev_get_drvdata(device);
946950
struct spi_qup *controller = spi_master_get_devdata(master);
947951
u32 config;
952+
int ret;
953+
954+
ret = clk_prepare_enable(controller->iclk);
955+
if (ret)
956+
return ret;
957+
958+
ret = clk_prepare_enable(controller->cclk);
959+
if (ret)
960+
return ret;
948961

949962
/* Disable clocks auto gaiting */
950963
config = readl_relaxed(controller->base + QUP_CONFIG);
@@ -1017,6 +1030,8 @@ static int spi_qup_remove(struct platform_device *pdev)
10171030

10181031
pm_runtime_put_noidle(&pdev->dev);
10191032
pm_runtime_disable(&pdev->dev);
1033+
spi_master_put(master);
1034+
10201035
return 0;
10211036
}
10221037

drivers/spi/spi-rockchip.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,8 @@ static int rockchip_spi_probe(struct platform_device *pdev)
744744
rs->dma_rx.ch = dma_request_chan(rs->dev, "rx");
745745
if (IS_ERR(rs->dma_rx.ch)) {
746746
if (PTR_ERR(rs->dma_rx.ch) == -EPROBE_DEFER) {
747-
dma_release_channel(rs->dma_tx.ch);
748-
rs->dma_tx.ch = NULL;
749747
ret = -EPROBE_DEFER;
750-
goto err_get_fifo_len;
748+
goto err_free_dma_tx;
751749
}
752750
dev_warn(rs->dev, "Failed to request RX DMA channel\n");
753751
rs->dma_rx.ch = NULL;
@@ -775,10 +773,11 @@ static int rockchip_spi_probe(struct platform_device *pdev)
775773

776774
err_register_master:
777775
pm_runtime_disable(&pdev->dev);
778-
if (rs->dma_tx.ch)
779-
dma_release_channel(rs->dma_tx.ch);
780776
if (rs->dma_rx.ch)
781777
dma_release_channel(rs->dma_rx.ch);
778+
err_free_dma_tx:
779+
if (rs->dma_tx.ch)
780+
dma_release_channel(rs->dma_tx.ch);
782781
err_get_fifo_len:
783782
clk_disable_unprepare(rs->spiclk);
784783
err_spiclk_enable:

drivers/spi/spi-st-ssc4.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,13 @@ static int spi_st_probe(struct platform_device *pdev)
345345
spi_st->clk = devm_clk_get(&pdev->dev, "ssc");
346346
if (IS_ERR(spi_st->clk)) {
347347
dev_err(&pdev->dev, "Unable to request clock\n");
348-
return PTR_ERR(spi_st->clk);
348+
ret = PTR_ERR(spi_st->clk);
349+
goto put_master;
349350
}
350351

351352
ret = spi_st_clk_enable(spi_st);
352353
if (ret)
353-
return ret;
354+
goto put_master;
354355

355356
init_completion(&spi_st->done);
356357

@@ -408,7 +409,8 @@ static int spi_st_probe(struct platform_device *pdev)
408409

409410
clk_disable:
410411
spi_st_clk_disable(spi_st);
411-
412+
put_master:
413+
spi_master_put(master);
412414
return ret;
413415
}
414416

0 commit comments

Comments
 (0)