Commit 0f3841a5 authored by Théo Lebrun's avatar Théo Lebrun Committed by Mark Brown

spi: cadence-qspi: report correct number of chip-select

Set the ->num_chipselect field in struct cqspi_st and struct
spi_controller to the current number of chip-select. The value is
dependent on declared flashes in devicetree.

Previously, the num-cs property from devicetree or the maximum value was
being reported.
Signed-off-by: default avatarThéo Lebrun <theo.lebrun@bootlin.com>
Link: https://msgid.link/r/20240209-cdns-qspi-cs-v1-3-a4f9dfed9ab4@bootlin.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7cc3522a
...@@ -1621,6 +1621,7 @@ static const struct spi_controller_mem_caps cqspi_mem_caps = { ...@@ -1621,6 +1621,7 @@ static const struct spi_controller_mem_caps cqspi_mem_caps = {
static int cqspi_setup_flash(struct cqspi_st *cqspi) static int cqspi_setup_flash(struct cqspi_st *cqspi)
{ {
unsigned int max_cs = cqspi->num_chipselect - 1;
struct platform_device *pdev = cqspi->pdev; struct platform_device *pdev = cqspi->pdev;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
...@@ -1641,6 +1642,8 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi) ...@@ -1641,6 +1642,8 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
dev_err(dev, "Chip select %d out of range.\n", cs); dev_err(dev, "Chip select %d out of range.\n", cs);
of_node_put(np); of_node_put(np);
return -EINVAL; return -EINVAL;
} else if (cs < max_cs) {
max_cs = cs;
} }
f_pdata = &cqspi->f_pdata[cs]; f_pdata = &cqspi->f_pdata[cs];
...@@ -1654,6 +1657,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi) ...@@ -1654,6 +1657,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
} }
} }
cqspi->num_chipselect = max_cs + 1;
return 0; return 0;
} }
...@@ -1864,14 +1868,14 @@ static int cqspi_probe(struct platform_device *pdev) ...@@ -1864,14 +1868,14 @@ static int cqspi_probe(struct platform_device *pdev)
cqspi->current_cs = -1; cqspi->current_cs = -1;
cqspi->sclk = 0; cqspi->sclk = 0;
host->num_chipselect = cqspi->num_chipselect;
ret = cqspi_setup_flash(cqspi); ret = cqspi_setup_flash(cqspi);
if (ret) { if (ret) {
dev_err(dev, "failed to setup flash parameters %d\n", ret); dev_err(dev, "failed to setup flash parameters %d\n", ret);
goto probe_setup_failed; goto probe_setup_failed;
} }
host->num_chipselect = cqspi->num_chipselect;
if (cqspi->use_direct_mode) { if (cqspi->use_direct_mode) {
ret = cqspi_request_mmap_dma(cqspi); ret = cqspi_request_mmap_dma(cqspi);
if (ret == -EPROBE_DEFER) if (ret == -EPROBE_DEFER)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment