Skip to content

Commit

Permalink
Merge remote-tracking branch 'spi/for-5.10' into spi-5.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Dec 17, 2020
2 parents 2fee958 + 9326e4f commit 127a7a9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion drivers/spi/spi-dw-bt1.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@ static int dw_spi_bt1_probe(struct platform_device *pdev)
dws->bus_num = pdev->id;
dws->reg_io_width = 4;
dws->max_freq = clk_get_rate(dwsbt1->clk);
if (!dws->max_freq)
if (!dws->max_freq) {
ret = -EINVAL;
goto err_disable_clk;
}

init_func = device_get_match_data(&pdev->dev);
ret = init_func(pdev, dwsbt1);
Expand Down
6 changes: 3 additions & 3 deletions drivers/spi/spi-fsl-dspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ static int dspi_init(struct fsl_dspi *dspi)
unsigned int mcr;

/* Set idle states for all chip select signals to high */
mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->num_chipselect - 1, 0));
mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->max_native_cs - 1, 0));

if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
mcr |= SPI_MCR_XSPI;
Expand Down Expand Up @@ -1250,7 +1250,7 @@ static int dspi_probe(struct platform_device *pdev)

pdata = dev_get_platdata(&pdev->dev);
if (pdata) {
ctlr->num_chipselect = pdata->cs_num;
ctlr->num_chipselect = ctlr->max_native_cs = pdata->cs_num;
ctlr->bus_num = pdata->bus_num;

/* Only Coldfire uses platform data */
Expand All @@ -1263,7 +1263,7 @@ static int dspi_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "can't get spi-num-chipselects\n");
goto out_ctlr_put;
}
ctlr->num_chipselect = cs_num;
ctlr->num_chipselect = ctlr->max_native_cs = cs_num;

of_property_read_u32(np, "bus-num", &bus_num);
ctlr->bus_num = bus_num;
Expand Down
11 changes: 8 additions & 3 deletions drivers/spi/spi-fsl-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,11 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
type = fsl_spi_get_type(&ofdev->dev);
if (type == TYPE_FSL) {
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
bool spisel_boot = false;
#if IS_ENABLED(CONFIG_FSL_SOC)
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
bool spisel_boot = of_property_read_bool(np, "fsl,spisel_boot");

spisel_boot = of_property_read_bool(np, "fsl,spisel_boot");
if (spisel_boot) {
pinfo->immr_spi_cs = ioremap(get_immrbase() + IMMR_SPI_CS_OFFSET, 4);
if (!pinfo->immr_spi_cs)
Expand All @@ -734,10 +735,14 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
* supported on the GRLIB variant.
*/
ret = gpiod_count(dev, "cs");
if (ret <= 0)
if (ret < 0)
ret = 0;
if (ret == 0 && !spisel_boot) {
pdata->max_chipselect = 1;
else
} else {
pdata->max_chipselect = ret + spisel_boot;
pdata->cs_control = fsl_spi_cs_control;
}
}

ret = of_address_to_resource(np, 0, &mem);
Expand Down
3 changes: 2 additions & 1 deletion drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3378,7 +3378,8 @@ int spi_setup(struct spi_device *spi)
if (status)
return status;

if (!spi->max_speed_hz)
if (!spi->max_speed_hz ||
spi->max_speed_hz > spi->controller->max_speed_hz)
spi->max_speed_hz = spi->controller->max_speed_hz;

mutex_lock(&spi->controller->io_mutex);
Expand Down

0 comments on commit 127a7a9

Please sign in to comment.