Skip to content

Commit 2f19e7a

Browse files
committed
Mark writes: "spi: Fixes for v4.19 Quite a few fixes for the Renesas drivers in here, plus a fix for the Tegra driver and some documentation fixes for the recently added spi-mem code. The Tegra fix is relatively large but fairly straightforward and mechanical, it runs on probe so it's been reasonably well covered in -next testing." * tag 'spi-fix-v4.19-rc5' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: spi-mem: Move the DMA-able constraint doc to the kerneldoc header spi: spi-mem: Add missing description for data.nbytes field spi: rspi: Fix interrupted DMA transfers spi: rspi: Fix invalid SPI use during system suspend spi: sh-msiof: Fix handling of write value for SISTR register spi: sh-msiof: Fix invalid SPI use during system suspend spi: gpio: Fix copy-and-paste error spi: tegra20-slink: explicitly enable/disable clock
2 parents 8f05661 + c949a8e commit 2f19e7a

File tree

5 files changed

+86
-18
lines changed

5 files changed

+86
-18
lines changed

drivers/spi/spi-gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ static int spi_gpio_request(struct device *dev,
300300
*mflags |= SPI_MASTER_NO_RX;
301301

302302
spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
303-
if (IS_ERR(spi_gpio->mosi))
304-
return PTR_ERR(spi_gpio->mosi);
303+
if (IS_ERR(spi_gpio->sck))
304+
return PTR_ERR(spi_gpio->sck);
305305

306306
for (i = 0; i < num_chipselects; i++) {
307307
spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs",

drivers/spi/spi-rspi.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,13 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
598598

599599
ret = wait_event_interruptible_timeout(rspi->wait,
600600
rspi->dma_callbacked, HZ);
601-
if (ret > 0 && rspi->dma_callbacked)
601+
if (ret > 0 && rspi->dma_callbacked) {
602602
ret = 0;
603-
else if (!ret) {
604-
dev_err(&rspi->master->dev, "DMA timeout\n");
605-
ret = -ETIMEDOUT;
603+
} else {
604+
if (!ret) {
605+
dev_err(&rspi->master->dev, "DMA timeout\n");
606+
ret = -ETIMEDOUT;
607+
}
606608
if (tx)
607609
dmaengine_terminate_all(rspi->master->dma_tx);
608610
if (rx)
@@ -1350,12 +1352,36 @@ static const struct platform_device_id spi_driver_ids[] = {
13501352

13511353
MODULE_DEVICE_TABLE(platform, spi_driver_ids);
13521354

1355+
#ifdef CONFIG_PM_SLEEP
1356+
static int rspi_suspend(struct device *dev)
1357+
{
1358+
struct platform_device *pdev = to_platform_device(dev);
1359+
struct rspi_data *rspi = platform_get_drvdata(pdev);
1360+
1361+
return spi_master_suspend(rspi->master);
1362+
}
1363+
1364+
static int rspi_resume(struct device *dev)
1365+
{
1366+
struct platform_device *pdev = to_platform_device(dev);
1367+
struct rspi_data *rspi = platform_get_drvdata(pdev);
1368+
1369+
return spi_master_resume(rspi->master);
1370+
}
1371+
1372+
static SIMPLE_DEV_PM_OPS(rspi_pm_ops, rspi_suspend, rspi_resume);
1373+
#define DEV_PM_OPS &rspi_pm_ops
1374+
#else
1375+
#define DEV_PM_OPS NULL
1376+
#endif /* CONFIG_PM_SLEEP */
1377+
13531378
static struct platform_driver rspi_driver = {
13541379
.probe = rspi_probe,
13551380
.remove = rspi_remove,
13561381
.id_table = spi_driver_ids,
13571382
.driver = {
13581383
.name = "renesas_spi",
1384+
.pm = DEV_PM_OPS,
13591385
.of_match_table = of_match_ptr(rspi_of_match),
13601386
},
13611387
};

drivers/spi/spi-sh-msiof.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,8 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
397397

398398
static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
399399
{
400-
sh_msiof_write(p, STR, sh_msiof_read(p, STR));
400+
sh_msiof_write(p, STR,
401+
sh_msiof_read(p, STR) & ~(STR_TDREQ | STR_RDREQ));
401402
}
402403

403404
static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p,
@@ -1426,12 +1427,37 @@ static const struct platform_device_id spi_driver_ids[] = {
14261427
};
14271428
MODULE_DEVICE_TABLE(platform, spi_driver_ids);
14281429

1430+
#ifdef CONFIG_PM_SLEEP
1431+
static int sh_msiof_spi_suspend(struct device *dev)
1432+
{
1433+
struct platform_device *pdev = to_platform_device(dev);
1434+
struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
1435+
1436+
return spi_master_suspend(p->master);
1437+
}
1438+
1439+
static int sh_msiof_spi_resume(struct device *dev)
1440+
{
1441+
struct platform_device *pdev = to_platform_device(dev);
1442+
struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
1443+
1444+
return spi_master_resume(p->master);
1445+
}
1446+
1447+
static SIMPLE_DEV_PM_OPS(sh_msiof_spi_pm_ops, sh_msiof_spi_suspend,
1448+
sh_msiof_spi_resume);
1449+
#define DEV_PM_OPS &sh_msiof_spi_pm_ops
1450+
#else
1451+
#define DEV_PM_OPS NULL
1452+
#endif /* CONFIG_PM_SLEEP */
1453+
14291454
static struct platform_driver sh_msiof_spi_drv = {
14301455
.probe = sh_msiof_spi_probe,
14311456
.remove = sh_msiof_spi_remove,
14321457
.id_table = spi_driver_ids,
14331458
.driver = {
14341459
.name = "spi_sh_msiof",
1460+
.pm = DEV_PM_OPS,
14351461
.of_match_table = of_match_ptr(sh_msiof_match),
14361462
},
14371463
};

drivers/spi/spi-tegra20-slink.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,24 @@ static int tegra_slink_probe(struct platform_device *pdev)
10631063
goto exit_free_master;
10641064
}
10651065

1066+
/* disabled clock may cause interrupt storm upon request */
1067+
tspi->clk = devm_clk_get(&pdev->dev, NULL);
1068+
if (IS_ERR(tspi->clk)) {
1069+
ret = PTR_ERR(tspi->clk);
1070+
dev_err(&pdev->dev, "Can not get clock %d\n", ret);
1071+
goto exit_free_master;
1072+
}
1073+
ret = clk_prepare(tspi->clk);
1074+
if (ret < 0) {
1075+
dev_err(&pdev->dev, "Clock prepare failed %d\n", ret);
1076+
goto exit_free_master;
1077+
}
1078+
ret = clk_enable(tspi->clk);
1079+
if (ret < 0) {
1080+
dev_err(&pdev->dev, "Clock enable failed %d\n", ret);
1081+
goto exit_free_master;
1082+
}
1083+
10661084
spi_irq = platform_get_irq(pdev, 0);
10671085
tspi->irq = spi_irq;
10681086
ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
@@ -1071,14 +1089,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
10711089
if (ret < 0) {
10721090
dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
10731091
tspi->irq);
1074-
goto exit_free_master;
1075-
}
1076-
1077-
tspi->clk = devm_clk_get(&pdev->dev, NULL);
1078-
if (IS_ERR(tspi->clk)) {
1079-
dev_err(&pdev->dev, "can not get clock\n");
1080-
ret = PTR_ERR(tspi->clk);
1081-
goto exit_free_irq;
1092+
goto exit_clk_disable;
10821093
}
10831094

10841095
tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
@@ -1138,6 +1149,8 @@ static int tegra_slink_probe(struct platform_device *pdev)
11381149
tegra_slink_deinit_dma_param(tspi, true);
11391150
exit_free_irq:
11401151
free_irq(spi_irq, tspi);
1152+
exit_clk_disable:
1153+
clk_disable(tspi->clk);
11411154
exit_free_master:
11421155
spi_master_put(master);
11431156
return ret;
@@ -1150,6 +1163,8 @@ static int tegra_slink_remove(struct platform_device *pdev)
11501163

11511164
free_irq(tspi->irq, tspi);
11521165

1166+
clk_disable(tspi->clk);
1167+
11531168
if (tspi->tx_dma_chan)
11541169
tegra_slink_deinit_dma_param(tspi, false);
11551170

include/linux/spi/spi-mem.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ enum spi_mem_data_dir {
8181
* @dummy.buswidth: number of IO lanes used to transmit the dummy bytes
8282
* @data.buswidth: number of IO lanes used to send/receive the data
8383
* @data.dir: direction of the transfer
84-
* @data.buf.in: input buffer
85-
* @data.buf.out: output buffer
84+
* @data.nbytes: number of data bytes to send/receive. Can be zero if the
85+
* operation does not involve transferring data
86+
* @data.buf.in: input buffer (must be DMA-able)
87+
* @data.buf.out: output buffer (must be DMA-able)
8688
*/
8789
struct spi_mem_op {
8890
struct {
@@ -105,7 +107,6 @@ struct spi_mem_op {
105107
u8 buswidth;
106108
enum spi_mem_data_dir dir;
107109
unsigned int nbytes;
108-
/* buf.{in,out} must be DMA-able. */
109110
union {
110111
void *in;
111112
const void *out;

0 commit comments

Comments
 (0)