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

From: Clark Wang
Date: Tue Apr 23 2019 - 06:46:28 EST


Add "fsl,spi-num-chipselects" check to support multi SS function in PIO
mode.

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

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;
--
2.17.1