Skip to content

Commit d00c50b

Browse files
committed
Merge tag 'spi-fix-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A small collection of fixes that have arrived since the merge window, the most noticable one is a fix for unmapping messages when the mapping was done with the struct device supplied to do the mapping overridden" * tag 'spi-fix-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: bcm-qspi: fix MSPI only access with bcm_qspi_exec_mem_op() spi: cadence-quadspi: fix protocol setup for non-1-1-X operations spi: core: add dma_map_dev for __spi_unmap_msg() spi: mxic: Fix an error handling path in mxic_spi_probe() spi: rpc-if: Fix RPM imbalance in probe error path
2 parents 9884976 + 2c7d1b2 commit d00c50b

5 files changed

Lines changed: 25 additions & 38 deletions

File tree

drivers/spi/spi-bcm-qspi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem,
12051205
addr = op->addr.val;
12061206
len = op->data.nbytes;
12071207

1208-
if (bcm_qspi_bspi_ver_three(qspi) == true) {
1208+
if (has_bspi(qspi) && bcm_qspi_bspi_ver_three(qspi) == true) {
12091209
/*
12101210
* The address coming into this function is a raw flash offset.
12111211
* But for BSPI <= V3, we need to convert it to a remapped BSPI
@@ -1224,7 +1224,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem,
12241224
len < 4)
12251225
mspi_read = true;
12261226

1227-
if (mspi_read)
1227+
if (!has_bspi(qspi) || mspi_read)
12281228
return bcm_qspi_mspi_exec_mem_op(spi, op);
12291229

12301230
ret = bcm_qspi_bspi_set_mode(qspi, op, 0);

drivers/spi/spi-cadence-quadspi.c

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/iopoll.h>
2020
#include <linux/jiffies.h>
2121
#include <linux/kernel.h>
22+
#include <linux/log2.h>
2223
#include <linux/module.h>
2324
#include <linux/of_device.h>
2425
#include <linux/of.h>
@@ -102,12 +103,6 @@ struct cqspi_driver_platdata {
102103
#define CQSPI_TIMEOUT_MS 500
103104
#define CQSPI_READ_TIMEOUT_MS 10
104105

105-
/* Instruction type */
106-
#define CQSPI_INST_TYPE_SINGLE 0
107-
#define CQSPI_INST_TYPE_DUAL 1
108-
#define CQSPI_INST_TYPE_QUAD 2
109-
#define CQSPI_INST_TYPE_OCTAL 3
110-
111106
#define CQSPI_DUMMY_CLKS_PER_BYTE 8
112107
#define CQSPI_DUMMY_BYTES_MAX 4
113108
#define CQSPI_DUMMY_CLKS_MAX 31
@@ -376,10 +371,6 @@ static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op, bool dtr)
376371
static int cqspi_set_protocol(struct cqspi_flash_pdata *f_pdata,
377372
const struct spi_mem_op *op)
378373
{
379-
f_pdata->inst_width = CQSPI_INST_TYPE_SINGLE;
380-
f_pdata->addr_width = CQSPI_INST_TYPE_SINGLE;
381-
f_pdata->data_width = CQSPI_INST_TYPE_SINGLE;
382-
383374
/*
384375
* For an op to be DTR, cmd phase along with every other non-empty
385376
* phase should have dtr field set to 1. If an op phase has zero
@@ -389,52 +380,39 @@ static int cqspi_set_protocol(struct cqspi_flash_pdata *f_pdata,
389380
(!op->addr.nbytes || op->addr.dtr) &&
390381
(!op->data.nbytes || op->data.dtr);
391382

392-
switch (op->data.buswidth) {
393-
case 0:
394-
break;
395-
case 1:
396-
f_pdata->data_width = CQSPI_INST_TYPE_SINGLE;
397-
break;
398-
case 2:
399-
f_pdata->data_width = CQSPI_INST_TYPE_DUAL;
400-
break;
401-
case 4:
402-
f_pdata->data_width = CQSPI_INST_TYPE_QUAD;
403-
break;
404-
case 8:
405-
f_pdata->data_width = CQSPI_INST_TYPE_OCTAL;
406-
break;
407-
default:
408-
return -EINVAL;
409-
}
383+
f_pdata->inst_width = 0;
384+
if (op->cmd.buswidth)
385+
f_pdata->inst_width = ilog2(op->cmd.buswidth);
386+
387+
f_pdata->addr_width = 0;
388+
if (op->addr.buswidth)
389+
f_pdata->addr_width = ilog2(op->addr.buswidth);
390+
391+
f_pdata->data_width = 0;
392+
if (op->data.buswidth)
393+
f_pdata->data_width = ilog2(op->data.buswidth);
410394

411395
/* Right now we only support 8-8-8 DTR mode. */
412396
if (f_pdata->dtr) {
413397
switch (op->cmd.buswidth) {
414398
case 0:
415-
break;
416399
case 8:
417-
f_pdata->inst_width = CQSPI_INST_TYPE_OCTAL;
418400
break;
419401
default:
420402
return -EINVAL;
421403
}
422404

423405
switch (op->addr.buswidth) {
424406
case 0:
425-
break;
426407
case 8:
427-
f_pdata->addr_width = CQSPI_INST_TYPE_OCTAL;
428408
break;
429409
default:
430410
return -EINVAL;
431411
}
432412

433413
switch (op->data.buswidth) {
434414
case 0:
435-
break;
436415
case 8:
437-
f_pdata->data_width = CQSPI_INST_TYPE_OCTAL;
438416
break;
439417
default:
440418
return -EINVAL;

drivers/spi/spi-mxic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ static int mxic_spi_probe(struct platform_device *pdev)
813813
if (ret) {
814814
dev_err(&pdev->dev, "spi_register_master failed\n");
815815
pm_runtime_disable(&pdev->dev);
816+
mxic_spi_mem_ecc_remove(mxic);
816817
}
817818

818819
return ret;

drivers/spi/spi-rpc-if.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,18 @@ static int rpcif_spi_probe(struct platform_device *pdev)
158158

159159
error = rpcif_hw_init(rpc, false);
160160
if (error)
161-
return error;
161+
goto out_disable_rpm;
162162

163163
error = spi_register_controller(ctlr);
164164
if (error) {
165165
dev_err(&pdev->dev, "spi_register_controller failed\n");
166-
rpcif_disable_rpm(rpc);
166+
goto out_disable_rpm;
167167
}
168168

169+
return 0;
170+
171+
out_disable_rpm:
172+
rpcif_disable_rpm(rpc);
169173
return error;
170174
}
171175

drivers/spi/spi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,15 @@ static int __spi_unmap_msg(struct spi_controller *ctlr, struct spi_message *msg)
11301130

11311131
if (ctlr->dma_tx)
11321132
tx_dev = ctlr->dma_tx->device->dev;
1133+
else if (ctlr->dma_map_dev)
1134+
tx_dev = ctlr->dma_map_dev;
11331135
else
11341136
tx_dev = ctlr->dev.parent;
11351137

11361138
if (ctlr->dma_rx)
11371139
rx_dev = ctlr->dma_rx->device->dev;
1140+
else if (ctlr->dma_map_dev)
1141+
rx_dev = ctlr->dma_map_dev;
11381142
else
11391143
rx_dev = ctlr->dev.parent;
11401144

0 commit comments

Comments
 (0)