Skip to content

Commit 9a36b58

Browse files
committed
Merge tag 'spi-fix-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A small collection of fixes that came in during the past week, a few driver specifics plus one fix for the spi-mem core where we weren't taking account of the frequency capabilities of the system when determining if it can support an operation" * tag 'spi-fix-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: st: fix PM macros to use CONFIG_PM instead of CONFIG_PM_SLEEP spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties spi: spi-fsl-lpspi: Clamp too high speed_hz spi: spi-mem: add spi_mem_adjust_op_freq() in spi_mem_supports_op() spi: spi-mem: Add missing kdoc argument spi: spi-qpic-snand: use correct CW_PER_PAGE value for OOB write
2 parents f43e6ba + 7c7cda8 commit 9a36b58

4 files changed

Lines changed: 27 additions & 17 deletions

File tree

drivers/spi/spi-fsl-lpspi.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,11 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
330330
}
331331

332332
if (config.speed_hz > perclk_rate / 2) {
333-
dev_err(fsl_lpspi->dev,
334-
"per-clk should be at least two times of transfer speed");
335-
return -EINVAL;
333+
div = 2;
334+
} else {
335+
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
336336
}
337337

338-
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
339-
340338
for (prescale = 0; prescale <= prescale_max; prescale++) {
341339
scldiv = div / (1 << prescale) - 2;
342340
if (scldiv >= 0 && scldiv < 256) {

drivers/spi/spi-mem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ static bool spi_mem_internal_supports_op(struct spi_mem *mem,
265265
*/
266266
bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op)
267267
{
268+
/* Make sure the operation frequency is correct before going futher */
269+
spi_mem_adjust_op_freq(mem, (struct spi_mem_op *)op);
270+
268271
if (spi_mem_check_op(op))
269272
return false;
270273

@@ -577,6 +580,7 @@ EXPORT_SYMBOL_GPL(spi_mem_adjust_op_freq);
577580
* spi_mem_calc_op_duration() - Derives the theoretical length (in ns) of an
578581
* operation. This helps finding the best variant
579582
* among a list of possible choices.
583+
* @mem: the SPI memory
580584
* @op: the operation to benchmark
581585
*
582586
* Some chips have per-op frequency limitations, PCBs usually have their own

drivers/spi/spi-qpic-snand.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,21 @@ static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section,
210210
struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand);
211211
struct qpic_ecc *qecc = snandc->qspi->ecc;
212212

213-
if (section > 1)
214-
return -ERANGE;
215-
216-
oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes;
217-
oobregion->offset = mtd->oobsize - oobregion->length;
213+
switch (section) {
214+
case 0:
215+
oobregion->offset = 0;
216+
oobregion->length = qecc->bytes * (qecc->steps - 1) +
217+
qecc->bbm_size;
218+
return 0;
219+
case 1:
220+
oobregion->offset = qecc->bytes * (qecc->steps - 1) +
221+
qecc->bbm_size +
222+
qecc->steps * 4;
223+
oobregion->length = mtd->oobsize - oobregion->offset;
224+
return 0;
225+
}
218226

219-
return 0;
227+
return -ERANGE;
220228
}
221229

222230
static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section,
@@ -1196,7 +1204,7 @@ static int qcom_spi_program_oob(struct qcom_nand_controller *snandc,
11961204
u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg;
11971205

11981206
cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) |
1199-
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
1207+
FIELD_PREP(CW_PER_PAGE_MASK, 0);
12001208
cfg1 = ecc_cfg->cfg1;
12011209
ecc_bch_cfg = ecc_cfg->ecc_bch_cfg;
12021210
ecc_buf_cfg = ecc_cfg->ecc_buf_cfg;

drivers/spi/spi-st-ssc4.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static void spi_st_remove(struct platform_device *pdev)
378378
pinctrl_pm_select_sleep_state(&pdev->dev);
379379
}
380380

381-
static int __maybe_unused spi_st_runtime_suspend(struct device *dev)
381+
static int spi_st_runtime_suspend(struct device *dev)
382382
{
383383
struct spi_controller *host = dev_get_drvdata(dev);
384384
struct spi_st *spi_st = spi_controller_get_devdata(host);
@@ -391,7 +391,7 @@ static int __maybe_unused spi_st_runtime_suspend(struct device *dev)
391391
return 0;
392392
}
393393

394-
static int __maybe_unused spi_st_runtime_resume(struct device *dev)
394+
static int spi_st_runtime_resume(struct device *dev)
395395
{
396396
struct spi_controller *host = dev_get_drvdata(dev);
397397
struct spi_st *spi_st = spi_controller_get_devdata(host);
@@ -428,8 +428,8 @@ static int __maybe_unused spi_st_resume(struct device *dev)
428428
}
429429

430430
static const struct dev_pm_ops spi_st_pm = {
431-
SET_SYSTEM_SLEEP_PM_OPS(spi_st_suspend, spi_st_resume)
432-
SET_RUNTIME_PM_OPS(spi_st_runtime_suspend, spi_st_runtime_resume, NULL)
431+
SYSTEM_SLEEP_PM_OPS(spi_st_suspend, spi_st_resume)
432+
RUNTIME_PM_OPS(spi_st_runtime_suspend, spi_st_runtime_resume, NULL)
433433
};
434434

435435
static const struct of_device_id stm_spi_match[] = {
@@ -441,7 +441,7 @@ MODULE_DEVICE_TABLE(of, stm_spi_match);
441441
static struct platform_driver spi_st_driver = {
442442
.driver = {
443443
.name = "spi-st",
444-
.pm = pm_sleep_ptr(&spi_st_pm),
444+
.pm = pm_ptr(&spi_st_pm),
445445
.of_match_table = of_match_ptr(stm_spi_match),
446446
},
447447
.probe = spi_st_probe,

0 commit comments

Comments
 (0)