linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi
@ 2022-12-06 22:54 Han Xu
  2022-12-06 22:54 ` [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs " Han Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Han Xu @ 2022-12-06 22:54 UTC (permalink / raw)
  To: broonie, linux-spi, linux-kernel, robh+dt, krzysztof.kozlowski+dt; +Cc: han.xu

support to get chip select number from DT file.

Signed-off-by: Han Xu <han.xu@nxp.com>
---
 drivers/spi/spi-fsl-lpspi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 6454b88c31fe..7f0562ed4d09 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -98,6 +98,7 @@ struct fsl_lpspi_data {
 	struct clk *clk_ipg;
 	struct clk *clk_per;
 	bool is_slave;
+	u32 num_cs;
 	bool is_only_cs1;
 	bool is_first_byte;
 
@@ -850,6 +851,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
 	fsl_lpspi->is_slave = is_slave;
 	fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node,
 						"fsl,spi-only-use-cs1-sel");
+	if (of_property_read_u32((&pdev->dev)->of_node, "num-cs",
+				 &fsl_lpspi->num_cs))
+		fsl_lpspi->num_cs = 1;
 
 	controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
 	controller->transfer_one = fsl_lpspi_transfer_one;
@@ -859,6 +863,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
 	controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
 	controller->dev.of_node = pdev->dev.of_node;
 	controller->bus_num = pdev->id;
+	controller->num_chipselect = fsl_lpspi->num_cs;
 	controller->slave_abort = fsl_lpspi_slave_abort;
 	if (!fsl_lpspi->is_slave)
 		controller->use_gpio_descriptors = true;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs for lpspi
  2022-12-06 22:54 [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi Han Xu
@ 2022-12-06 22:54 ` Han Xu
  2022-12-07  8:33   ` Krzysztof Kozlowski
  2022-12-07  6:38 ` [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs " Dhruva Gole
  2022-12-07 16:21 ` Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Han Xu @ 2022-12-06 22:54 UTC (permalink / raw)
  To: broonie, linux-spi, linux-kernel, robh+dt, krzysztof.kozlowski+dt; +Cc: han.xu

Add num-cs property to support multiple cs for lpspi. This property is
optional.

Signed-off-by: Han Xu <han.xu@nxp.com>
---
 Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml b/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
index 8b44284d30c6..94caa2b7e241 100644
--- a/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
+++ b/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
@@ -56,6 +56,13 @@ properties:
       this property to re-config the chipselect value in the LPSPI driver.
     type: boolean
 
+  num-cs:
+    description:
+      number of chip selects.
+    minimum: 1
+    maximum: 2
+    default: 1
+
 required:
   - compatible
   - reg
@@ -80,4 +87,5 @@ examples:
         clock-names = "per", "ipg";
         spi-slave;
         fsl,spi-only-use-cs1-sel;
+        num-cs = <2>;
     };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi
  2022-12-06 22:54 [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi Han Xu
  2022-12-06 22:54 ` [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs " Han Xu
@ 2022-12-07  6:38 ` Dhruva Gole
  2022-12-07 13:44   ` Mark Brown
  2022-12-07 16:21 ` Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Dhruva Gole @ 2022-12-07  6:38 UTC (permalink / raw)
  To: Han Xu, broonie, linux-spi, linux-kernel, robh+dt,
	krzysztof.kozlowski+dt

Hi,

On 07/12/22 04:24, Han Xu wrote:
> support to get chip select number from DT file.

In my humble opinion, a  more elaborate commit message would help.
You can add perhaps which DT node is to be set, like you might want
to say,

support to get chip select number by Setting the value of num-cs in DT

or something on those lines.
> 
> Signed-off-by: Han Xu <han.xu@nxp.com>
> ---
>   drivers/spi/spi-fsl-lpspi.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> index 6454b88c31fe..7f0562ed4d09 100644
> --- a/drivers/spi/spi-fsl-lpspi.c
> +++ b/drivers/spi/spi-fsl-lpspi.c
> @@ -98,6 +98,7 @@ struct fsl_lpspi_data {
>   	struct clk *clk_ipg;
>   	struct clk *clk_per;
>   	bool is_slave;
> +	u32 num_cs;
>   	bool is_only_cs1;
>   	bool is_first_byte;
>   
> @@ -850,6 +851,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
>   	fsl_lpspi->is_slave = is_slave;
>   	fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node,
>   						"fsl,spi-only-use-cs1-sel");
> +	if (of_property_read_u32((&pdev->dev)->of_node, "num-cs",
Running a checkpatch on this patch gave me the following,

CHECK: Unnecessary parentheses around '&pdev->dev'
#36: FILE: drivers/spi/spi-fsl-lpspi.c:854:
+       if (of_property_read_u32((&pdev->dev)->of_node, "num-cs",
+                                &fsl_lpspi->num_cs))

You might want to just do &pdev->dev->of_node instead

> +				 &fsl_lpspi->num_cs))
> +		fsl_lpspi->num_cs = 1;
I am not sure I understand why you are setting this to 1 here?
I am assuming it is because you want num_cs to default to 1 if
it is not specified in DT.

Please can you also add a dev_err and be sure to warn about this?

Also adding a comment or even a message inside dev err that you are
setting this to 1 if it fails to get from DT would be helpful.

>   
>   	controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
>   	controller->transfer_one = fsl_lpspi_transfer_one;
> @@ -859,6 +863,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
>   	controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
>   	controller->dev.of_node = pdev->dev.of_node;
>   	controller->bus_num = pdev->id;
> +	controller->num_chipselect = fsl_lpspi->num_cs;
>   	controller->slave_abort = fsl_lpspi_slave_abort;
>   	if (!fsl_lpspi->is_slave)
>   		controller->use_gpio_descriptors = true;

-- 
Thanks and Regards,
Dhruva Gole

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs for lpspi
  2022-12-06 22:54 ` [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs " Han Xu
@ 2022-12-07  8:33   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2022-12-07  8:33 UTC (permalink / raw)
  To: Han Xu, broonie, linux-spi, linux-kernel, robh+dt,
	krzysztof.kozlowski+dt

On 06/12/2022 23:54, Han Xu wrote:
> Add num-cs property to support multiple cs for lpspi. This property is
> optional.
> 
> Signed-off-by: Han Xu <han.xu@nxp.com>
> ---
>  Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml b/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
> index 8b44284d30c6..94caa2b7e241 100644
> --- a/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
> +++ b/Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
> @@ -56,6 +56,13 @@ properties:
>        this property to re-config the chipselect value in the LPSPI driver.
>      type: boolean
>  
> +  num-cs:
> +    description:
> +      number of chip selects.

You do not need description, it's already in spi-controller.yaml.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi
  2022-12-07  6:38 ` [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs " Dhruva Gole
@ 2022-12-07 13:44   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-12-07 13:44 UTC (permalink / raw)
  To: Dhruva Gole
  Cc: Han Xu, linux-spi, linux-kernel, robh+dt, krzysztof.kozlowski+dt

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

On Wed, Dec 07, 2022 at 12:08:43PM +0530, Dhruva Gole wrote:
> On 07/12/22 04:24, Han Xu wrote:
> > support to get chip select number from DT file.

> > +		fsl_lpspi->num_cs = 1;
> I am not sure I understand why you are setting this to 1 here?
> I am assuming it is because you want num_cs to default to 1 if
> it is not specified in DT.

> Please can you also add a dev_err and be sure to warn about this?

The binding says that this property is optional with a default of 1 so
it should be totally fine for a system to not specify anything.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi
  2022-12-06 22:54 [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi Han Xu
  2022-12-06 22:54 ` [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs " Han Xu
  2022-12-07  6:38 ` [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs " Dhruva Gole
@ 2022-12-07 16:21 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-12-07 16:21 UTC (permalink / raw)
  To: linux-spi, linux-kernel, robh+dt, krzysztof.kozlowski+dt, Han Xu

On Tue, 06 Dec 2022 16:54:09 -0600, Han Xu wrote:
> support to get chip select number from DT file.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi
      commit: 5f947746f0089529c85654704643f158b420ff92
[2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs for lpspi
      commit: bc9ab1b7a6c687370b5d4edf34064bf04af8d369

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-07 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 22:54 [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs for lpspi Han Xu
2022-12-06 22:54 ` [PATCH 2/2] dt-bindings: spi: spi-fsl-lpspi: add num-cs " Han Xu
2022-12-07  8:33   ` Krzysztof Kozlowski
2022-12-07  6:38 ` [PATCH 1/2] spi: spi-fsl-lpspi: support multiple cs " Dhruva Gole
2022-12-07 13:44   ` Mark Brown
2022-12-07 16:21 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).