diff mbox series

[2/3] spi: lpspi: add multi SS support in PIO mode

Message ID 20190423104649.24483-3-xiaoning.wang@nxp.com (mailing list archive)
State New, archived
Headers show
Series spi: lpspi: SS function related changes | expand

Commit Message

Clark Wang April 23, 2019, 10:46 a.m. UTC
Add "fsl,spi-num-chipselects" check to support multi SS function in PIO
mode.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/spi/spi-fsl-lpspi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Fabio Estevam April 23, 2019, 11:21 a.m. UTC | #1
On Tue, Apr 23, 2019 at 7:48 AM Clark Wang <xiaoning.wang@nxp.com> wrote:
>
> Add "fsl,spi-num-chipselects" check to support multi SS function in PIO
> mode.

This custom property does not seem to be needed as the number of chip
selects can be parsed from the devicetree file directly.

We got rid of "fsl,spi-num-chipselects" property in the spi-imx driver
in this commit:

commit b36581df7e788b674a4efbb8da7fe4a00c207e8b
Author: Alexander Shiyan <shc_work@mail.ru>
Date:   Wed Jun 8 20:02:06 2016 +0300

    spi: imx: Using existing properties for chipselects

    Patch reuse existing "chip_select" and "cs_gpio(s)" fields from SPI core.

    Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
    Signed-off-by: Mark Brown <broonie@kernel.org>

and we should try to also avoid such property in spi-fsl-lpspi as well.
diff mbox series

Patch

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 19040b5ef349..a8e83cb96f61 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -841,7 +841,7 @@  static int fsl_lpspi_probe(struct platform_device *pdev)
 	struct spi_imx_master *lpspi_platform_info =
 		dev_get_platdata(&pdev->dev);
 	struct resource *res;
-	int i, ret, irq;
+	int i, ret, irq, num_cs;
 	u32 temp;
 	bool is_slave;
 
@@ -863,6 +863,16 @@  static int fsl_lpspi_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, controller);
 
+	ret = of_property_read_u32(np, "fsl,spi-num-chipselects", &num_cs);
+	if (ret < 0) {
+		if (lpspi_platform_info) {
+			num_cs = lpspi_platform_info->num_chipselect;
+			controller->num_chipselect = num_cs;
+		}
+	} else {
+		controller->num_chipselect = num_cs;
+	}
+
 	fsl_lpspi = spi_controller_get_devdata(controller);
 	fsl_lpspi->dev = &pdev->dev;
 	fsl_lpspi->is_slave = is_slave;