2022-04-22 22:30:38

by Zhou Yanjie

[permalink] [raw]
Subject: [PATCH v2 0/3] Improve SPI support for Ingenic SoCs.

1.Add support for using GPIOs as chip select lines on Ingenic SoCs.
2.Add support for probing the spi-ingenic driver on the JZ4775 SoC,
the X1000 SoC, and the X2000 SoC.
3.Modify annotation texts to be more in line with the current state.

v1->v2:
Use "device_property_read_u32()" instead "of_property_read_u32()" as
Paul Cercueil's suggestion.

周琰杰 (Zhou Yanjie) (3):
SPI: Ingenic: Add support for use GPIO as chip select line.
dt-bindings: SPI: Add bindings for new Ingenic SoCs.
SPI: Ingenic: Add support for new Ingenic SoCs.

.../devicetree/bindings/spi/ingenic,spi.yaml | 3 ++
drivers/spi/Kconfig | 4 +-
drivers/spi/spi-ingenic.c | 49 +++++++++++++++++++---
3 files changed, 49 insertions(+), 7 deletions(-)

--
2.7.4


2022-04-22 22:30:39

by Zhou Yanjie

[permalink] [raw]
Subject: [PATCH v2 2/3] dt-bindings: SPI: Add bindings for new Ingenic SoCs.

Add the SPI bindings for the JZ4775 SoC, the X1000 SoC,
and the X2000 SoC from Ingenic.

Signed-off-by: 周琰杰 (Zhou Yanjie) <[email protected]>
Acked-by: Krzysztof Kozlowski <[email protected]>
Acked-by: Paul Cercueil <[email protected]>
---

Notes:
v1->v2:
No change.

Documentation/devicetree/bindings/spi/ingenic,spi.yaml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/spi/ingenic,spi.yaml b/Documentation/devicetree/bindings/spi/ingenic,spi.yaml
index 5b1c7a2..360f76c 100644
--- a/Documentation/devicetree/bindings/spi/ingenic,spi.yaml
+++ b/Documentation/devicetree/bindings/spi/ingenic,spi.yaml
@@ -18,7 +18,10 @@ properties:
oneOf:
- enum:
- ingenic,jz4750-spi
+ - ingenic,jz4775-spi
- ingenic,jz4780-spi
+ - ingenic,x1000-spi
+ - ingenic,x2000-spi
- items:
- enum:
- ingenic,jz4760-spi
--
2.7.4

2022-04-22 22:30:39

by Zhou Yanjie

[permalink] [raw]
Subject: [PATCH v2 1/3] SPI: Ingenic: Add support for use GPIO as chip select line.

Add support for using GPIOs as chip select lines on Ingenic SoCs.

Signed-off-by: 周琰杰 (Zhou Yanjie) <[email protected]>
---

Notes:
v1->v2:
Use "device_property_read_u32()" instead
"of_property_read_u32()" as Paul Cercueil's suggestion.

drivers/spi/spi-ingenic.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-ingenic.c b/drivers/spi/spi-ingenic.c
index 03077a7..bb512ca 100644
--- a/drivers/spi/spi-ingenic.c
+++ b/drivers/spi/spi-ingenic.c
@@ -380,7 +380,7 @@ static int spi_ingenic_probe(struct platform_device *pdev)
struct spi_controller *ctlr;
struct ingenic_spi *priv;
void __iomem *base;
- int ret;
+ int num_cs, ret;

pdata = of_device_get_match_data(dev);
if (!pdata) {
@@ -416,6 +416,11 @@ static int spi_ingenic_probe(struct platform_device *pdev)
if (IS_ERR(priv->flen_field))
return PTR_ERR(priv->flen_field);

+ if (device_property_read_u32(dev, "num-cs", &num_cs)) {
+ dev_warn(dev, "Number of chip select lines not specified.\n");
+ num_cs = 2;
+ }
+
platform_set_drvdata(pdev, ctlr);

ctlr->prepare_transfer_hardware = spi_ingenic_prepare_hardware;
@@ -429,7 +434,9 @@ static int spi_ingenic_probe(struct platform_device *pdev)
ctlr->bits_per_word_mask = pdata->bits_per_word_mask;
ctlr->min_speed_hz = 7200;
ctlr->max_speed_hz = 54000000;
- ctlr->num_chipselect = 2;
+ ctlr->use_gpio_descriptors = true;
+ ctlr->max_native_cs = 2;
+ ctlr->num_chipselect = num_cs;
ctlr->dev.of_node = pdev->dev.of_node;

if (spi_ingenic_request_dma(ctlr, dev))
--
2.7.4

2022-04-22 23:17:27

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] SPI: Ingenic: Add support for use GPIO as chip select line.

Hi Zhou,

Le sam., avril 23 2022 at 03:09:41 +0800, 周琰杰 (Zhou Yanjie)
<[email protected]> a écrit :
> Add support for using GPIOs as chip select lines on Ingenic SoCs.
>
> Signed-off-by: 周琰杰 (Zhou Yanjie) <[email protected]>
> ---
>
> Notes:
> v1->v2:
> Use "device_property_read_u32()" instead
> "of_property_read_u32()" as Paul Cercueil's suggestion.
>
> drivers/spi/spi-ingenic.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-ingenic.c b/drivers/spi/spi-ingenic.c
> index 03077a7..bb512ca 100644
> --- a/drivers/spi/spi-ingenic.c
> +++ b/drivers/spi/spi-ingenic.c
> @@ -380,7 +380,7 @@ static int spi_ingenic_probe(struct
> platform_device *pdev)
> struct spi_controller *ctlr;
> struct ingenic_spi *priv;
> void __iomem *base;
> - int ret;
> + int num_cs, ret;
>
> pdata = of_device_get_match_data(dev);
> if (!pdata) {
> @@ -416,6 +416,11 @@ static int spi_ingenic_probe(struct
> platform_device *pdev)
> if (IS_ERR(priv->flen_field))
> return PTR_ERR(priv->flen_field);
>
> + if (device_property_read_u32(dev, "num-cs", &num_cs)) {
> + dev_warn(dev, "Number of chip select lines not specified.\n");
> + num_cs = 2;

The "num-cs" property is not required in the binding, so I don't think
the dev_warn() is warranted. Just silently set num_cs = 2.

With this addressed:
Reviewed-by: Paul Cercueil <[email protected]>

Cheers,
-Paul

> + }
> +
> platform_set_drvdata(pdev, ctlr);
>
> ctlr->prepare_transfer_hardware = spi_ingenic_prepare_hardware;
> @@ -429,7 +434,9 @@ static int spi_ingenic_probe(struct
> platform_device *pdev)
> ctlr->bits_per_word_mask = pdata->bits_per_word_mask;
> ctlr->min_speed_hz = 7200;
> ctlr->max_speed_hz = 54000000;
> - ctlr->num_chipselect = 2;
> + ctlr->use_gpio_descriptors = true;
> + ctlr->max_native_cs = 2;
> + ctlr->num_chipselect = num_cs;
> ctlr->dev.of_node = pdev->dev.of_node;
>
> if (spi_ingenic_request_dma(ctlr, dev))
> --
> 2.7.4
>


2022-04-23 15:13:20

by Zhou Yanjie

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] SPI: Ingenic: Add support for use GPIO as chip select line.

Hi Paul,

On 2022/4/23 上午3:20, Paul Cercueil wrote:
> Hi Zhou,
>
> Le sam., avril 23 2022 at 03:09:41 +0800, 周琰杰 (Zhou Yanjie)
> <[email protected]> a écrit :
>> Add support for using GPIOs as chip select lines on Ingenic SoCs.
>>
>> Signed-off-by: 周琰杰 (Zhou Yanjie) <[email protected]>
>> ---
>>
>> Notes:
>>     v1->v2:
>>     Use "device_property_read_u32()" instead
>>     "of_property_read_u32()" as Paul Cercueil's suggestion.
>>
>>  drivers/spi/spi-ingenic.c | 11 +++++++++--
>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/spi/spi-ingenic.c b/drivers/spi/spi-ingenic.c
>> index 03077a7..bb512ca 100644
>> --- a/drivers/spi/spi-ingenic.c
>> +++ b/drivers/spi/spi-ingenic.c
>> @@ -380,7 +380,7 @@ static int spi_ingenic_probe(struct
>> platform_device *pdev)
>>      struct spi_controller *ctlr;
>>      struct ingenic_spi *priv;
>>      void __iomem *base;
>> -    int ret;
>> +    int num_cs, ret;
>>
>>      pdata = of_device_get_match_data(dev);
>>      if (!pdata) {
>> @@ -416,6 +416,11 @@ static int spi_ingenic_probe(struct
>> platform_device *pdev)
>>      if (IS_ERR(priv->flen_field))
>>          return PTR_ERR(priv->flen_field);
>>
>> +    if (device_property_read_u32(dev, "num-cs", &num_cs)) {
>> +        dev_warn(dev, "Number of chip select lines not specified.\n");
>> +        num_cs = 2;
>
> The "num-cs" property is not required in the binding, so I don't think
> the dev_warn() is warranted. Just silently set num_cs = 2.
>

Sure.


> With this addressed:
> Reviewed-by: Paul Cercueil <[email protected]>
>
> Cheers,
> -Paul
>
>> +    }
>> +
>>      platform_set_drvdata(pdev, ctlr);
>>
>>      ctlr->prepare_transfer_hardware = spi_ingenic_prepare_hardware;
>> @@ -429,7 +434,9 @@ static int spi_ingenic_probe(struct
>> platform_device *pdev)
>>      ctlr->bits_per_word_mask = pdata->bits_per_word_mask;
>>      ctlr->min_speed_hz = 7200;
>>      ctlr->max_speed_hz = 54000000;
>> -    ctlr->num_chipselect = 2;
>> +    ctlr->use_gpio_descriptors = true;
>> +    ctlr->max_native_cs = 2;
>> +    ctlr->num_chipselect = num_cs;
>>      ctlr->dev.of_node = pdev->dev.of_node;
>>
>>      if (spi_ingenic_request_dma(ctlr, dev))
>> --
>> 2.7.4
>>
>