spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Subsystems (4)
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Currently, spi-s3c64xx.c needs "cs-gpio" chip select GPIO to be defined under "controller-data" node under each slave node.
&spi_x {
cs-gpios <>;
...
slave_node {
controller-data {
cs-gpio = <>;
...
};
...
};
...
};Where as, SPI core and many other drivers uses "cs-gpios" for from device tree node.
Hence, make changes in spi-s3c64xx.c driver to make use of "cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in slaves "controller-data"(child) node.
Also updates the Device tree Documentation.
---
Changes since v2:
1. updated the gpios usage in Documentation
2. use the spi->cs_gpio in the driver, instead of parsing the node again.
3. Corrected error check of the of.node and during gpio_free
.../devicetree/bindings/spi/spi-samsung.txt | 8 +++----- drivers/spi/spi-s3c64xx.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-)
Documentation/devicetree/bindings/spi/spi-samsung.txt +3 -5
@@ -42,15 +42,13 @@ Optional Board Specific Properties: - num-cs: Specifies the number of chip select lines supported. If not specified, the default number of chip select lines is set to 1. +- cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) + SPI Controller specific data in SPI slave nodes: - The spi slave nodes should provide the following information which is required by the spi controller. - - cs-gpio: A gpio specifier that specifies the gpio line used as - the slave select line by the spi controller. The format of the gpio - specifier depends on the gpio controller. - - samsung,spi-feedback-delay: The sampling phase shift to be applied on the miso line (to account for any lag in the miso line). The following are the valid values.
@@ -85,6 +83,7 @@ Example: #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&spi0_bus>; + cs-gpios = <&gpa2 5 0>; w25q80bw at 0 { #address-cells = <1>;
@@ -94,7 +93,6 @@ Example: spi-max-frequency = <10000>; controller-data { - cs-gpio = <&gpa2 5 1 0 3>; samsung,spi-feedback-delay = <0>; };
drivers/spi/spi-s3c64xx.c +6 -12
@@ -772,24 +772,19 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( cs =kzalloc (sizeof (*cs),GFP_KERNEL );if (!cs) { -of_node_put (data_np);return ERR_PTR (-ENOMEM ); } -/* The CS line is asserted/deasserted by the gpio pin */ -if (sdd->cs_gpio) - cs->line =of_get_named_gpio (data_np,"cs-gpio" ,0 ); - -if (!gpio_is_valid (cs->line)) { +if (!gpio_is_valid (spi->cs_gpio)) {dev_err (&spi->dev,"chip select gpio is not specified or invalid\n" ); -kfree (cs); -of_node_put (data_np);return ERR_PTR (-EINVAL ); } + cs->line = spi->cs_gpio;of_property_read_u32 (data_np,"samsung,spi-feedback-delay" , &fb_delay); cs->fb_delay = fb_delay;of_node_put (data_np); +return cs; }
@@ -828,8 +823,6 @@ static int s3c64xx_spi_setup(struct spi_device *spi) cs->line, err); goto err_gpio_req; } - - spi->cs_gpio = cs->line; }spi_set_ctldata (spi, cs);
@@ -884,7 +877,8 @@ setup_exit:/* setup() returns with device de-selected */ writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL ); -gpio_free (cs->line); +if (cs->line) +gpio_free (cs->line);spi_set_ctldata (spi,NULL ); err_gpio_req:
@@ -1077,7 +1071,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->sfr_start = mem_res->start; sdd->cs_gpio = true;if (pdev->dev.of_node) { -if (!of_find_property (pdev->dev.of_node,"cs-gpio" ,NULL )) +if (!of_find_property (pdev->dev.of_node,"cs-gpios" ,NULL )) sdd->cs_gpio = false; ret =of_alias_get_id (pdev->dev.of_node,"spi" );
Signature · 1 line
1.7.9.5
PATCH v3 2/2 ARM: DTS: move "cs-gpio" from "controller-data" to under spi node
This patch moves the "cs-gpio" field from "controller-data" child node to under the spi device node.
Respective changes are preposed to spi-s3c64xx.c driver.
---
Changes since v2:
None
arch/arm/boot/dts/exynos4210-smdkv310.dts | 2 +- arch/arm/boot/dts/exynos4412-trats2.dts | 2 +- arch/arm/boot/dts/exynos5250-smdk5250.dts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/exynos4210-smdkv310.dts +1 -1
@@ -169,6 +169,7 @@ spi_2: spi at 13940000 { status = "okay"; + cs-gpios = <&gpc1 2 0>; w25x80 at 0 { #address-cells = <1>;
@@ -178,7 +179,6 @@ spi-max-frequency = <1000000>; controller-data { - cs-gpio = <&gpc1 2 0>; samsung,spi-feedback-delay = <0>; };
arch/arm/boot/dts/exynos4412-trats2.dts +1 -1
@@ -512,6 +512,7 @@ spi_1: spi at 13930000 { pinctrl-names = "default"; pinctrl-0 = <&spi1_bus>; + cs-gpios = <&gpb 5 0>; status = "okay"; s5c73m3_spi: s5c73m3 {
@@ -519,7 +520,6 @@ spi-max-frequency = <50000000>; reg = <0>; controller-data { - cs-gpio = <&gpb 5 0>; samsung,spi-feedback-delay = <2>; }; };
arch/arm/boot/dts/exynos5250-smdk5250.dts +1 -1
@@ -316,6 +316,7 @@ }; spi_1: spi at 12d30000 { + cs-gpios = <&gpa2 5 0>; status = "okay"; w25q80bw at 0 {
@@ -326,7 +327,6 @@ spi-max-frequency = <1000000>; controller-data { - cs-gpio = <&gpa2 5 0>; samsung,spi-feedback-delay = <0>; };
Signature · 1 line
1.7.9.5
PATCH v3 2/2 ARM: DTS: move "cs-gpio" from "controller-data" to under spi node
Hello Naveen,
Quoted 3 lines · Naveen Krishna Chatradhi
This patch moves the "cs-gpio" field from "controller-data" child node to under the spi device node.
Your patch looks good to me but I think that the commit message is inaccurate.
It does not move the cs-gpio property to the top SPI dev node but it replaces the cs-gpio from controller-data as was specified in the old binding and use the standard cs-gpios property expected by the SPI core as is defined in the new binding.
Having a proper commit message is important since out-of-tree DTS can use this commit as a reference on how to fix their FDT in case this change broke their platforms.
Quoted 70 lines
Respective changes are preposed to
spi-s3c64xx.cdriver.Signed-off-by Naveen Krishna Chatradhi <[email protected]>Acked-by Rob Herring <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Doug Anderson <[email protected]>Cc Tomasz Figa <[email protected]>---
Changes since v2:
Nonearch/arm/boot/dts/exynos4210-smdkv310.dts | 2 +- arch/arm/boot/dts/exynos4412-trats2.dts | 2 +- arch/arm/boot/dts/exynos5250-smdk5250.dts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)arch/arm/boot/dts/exynos4210-smdkv310.dts +1
-1@@ -169,6 +169,7 @@ spi_2: spi at 13940000 { status = "okay"; + cs-gpios = <&gpc1 2 0>; w25x80 at 0 { #address-cells = <1>;@@ -178,7 +179,6 @@ spi-max-frequency = <1000000>; controller-data { - cs-gpio = <&gpc1 2 0>; samsung,spi-feedback-delay = <0>; };arch/arm/boot/dts/exynos4412-trats2.dts +1
-1@@ -512,6 +512,7 @@ spi_1: spi at 13930000 { pinctrl-names = "default"; pinctrl-0 = <&spi1_bus>; + cs-gpios = <&gpb 5 0>; status = "okay"; s5c73m3_spi: s5c73m3 {@@ -519,7 +520,6 @@ spi-max-frequency = <50000000>; reg = <0>; controller-data { - cs-gpio = <&gpb 5 0>; samsung,spi-feedback-delay = <2>; }; };arch/arm/boot/dts/exynos5250-smdk5250.dts +1
-0@@ -316,6 +316,7 @@ }; spi_1: spi at 12d30000 { + cs-gpios = <&gpa2 5 0>; status = "okay"; w25q80bw at 0 {
arch/arm/boot/dts/exynos5250-smdk5250.dts line 332
Quoted 7 lines
arch/arm/boot/dts/exynos5250-smdk5250.dts +0
-1@@ -326,7 +327,6 @@ spi-max-frequency = <1000000>; controller-data { - cs-gpio = <&gpa2 5 0>; samsung,spi-feedback-delay = <0>; };
Best regards,
Javier
PATCH v3 2/2 ARM: DTS: move "cs-gpio" from "controller-data" to under spi node
Hello Javier,
Quoted 9 lines · Javier Martinez Canillas
Hello Naveen,
Quoted 3 lines · Naveen Krishna Chatradhi
This patch moves the "cs-gpio" field from "controller-data" child node to under the spi device node.
Your patch looks good to me but I think that the commit message is inaccurate.
Quoted 8 lines
It does not move the cs-gpio property to the top SPI dev node but it replaces the cs-gpio from controller-data as was specified in the old binding and use the standard cs-gpios property expected by the SPI core as is defined in the new binding.
Having a proper commit message is important since out-of-tree DTS can use this commit as a reference on how to fix their FDT in case this change broke their platforms.
Sure, Will improve the commit message with your other points aswell.
Quoted 72 lines
Quoted 72 lines
Respective changes are preposed to
spi-s3c64xx.cdriver.Signed-off-by Naveen Krishna Chatradhi <[email protected]>Acked-by Rob Herring <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Doug Anderson <[email protected]>Cc Tomasz Figa <[email protected]>---
Changes since v2:
Nonearch/arm/boot/dts/exynos4210-smdkv310.dts | 2 +- arch/arm/boot/dts/exynos4412-trats2.dts | 2 +- arch/arm/boot/dts/exynos5250-smdk5250.dts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)arch/arm/boot/dts/exynos4210-smdkv310.dts +1
-1@@ -169,6 +169,7 @@ spi_2: spi at 13940000 { status = "okay"; + cs-gpios = <&gpc1 2 0>; w25x80 at 0 { #address-cells = <1>;@@ -178,7 +179,6 @@ spi-max-frequency = <1000000>; controller-data { - cs-gpio = <&gpc1 2 0>; samsung,spi-feedback-delay = <0>; };arch/arm/boot/dts/exynos4412-trats2.dts +1
-1@@ -512,6 +512,7 @@ spi_1: spi at 13930000 { pinctrl-names = "default"; pinctrl-0 = <&spi1_bus>; + cs-gpios = <&gpb 5 0>; status = "okay"; s5c73m3_spi: s5c73m3 {@@ -519,7 +520,6 @@ spi-max-frequency = <50000000>; reg = <0>; controller-data { - cs-gpio = <&gpb 5 0>; samsung,spi-feedback-delay = <2>; }; };arch/arm/boot/dts/exynos5250-smdk5250.dts +1
-0@@ -316,6 +316,7 @@ }; spi_1: spi at 12d30000 { + cs-gpios = <&gpa2 5 0>; status = "okay"; w25q80bw at 0 {@@ -326,7 +327,6 @@ spi-max-frequency = <1000000>;
Quoted 9 lines
arch/arm/boot/dts/exynos5250-smdk5250.dts line 332
Quoted 6 lines
arch/arm/boot/dts/exynos5250-smdk5250.dts +0
-1controller-data { - cs-gpio = <&gpa2 5 0>; samsung,spi-feedback-delay = <0>; };Best regards,
Javier
Thanks for the in depth review.
Signature · 2 lines
Shine bright, (: Nav :)
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
In reply to Naveen Krishna ChatradhiHello Naveen,
Thanks a lot for your patches and sorry that I didn't review your prior two versions but I didn't have the time yesterday.
Quoted 3 lines · Naveen Krishna Chatradhi
Currently,
spi-s3c64xx.cneeds "cs-gpio" chip select GPIO to be defined under "controller-data" node under each slave node.
I think that the commit message is not clear enough about the intentions behind your patch.
It's not only that spi-s3c64xx needs a cs-gpio chip to be defined under controller-data dev node while all other SPI drivers expects cs-gpios at the top level, but more important that currently s3c64xx driver expects to have both cs-gpio (singular) at the top level *and* cs-gpio in controller data which doesn't make too much sense.
Quoted 3 lines
&spi_x {
cs-gpios <>;
...As I said, currently it expects cs-gpio (singular) not cs-gpios (plural) as your example. It's important to have a correct commit message so future code archaeologists can have a proper picture of the situation if needed.
Quoted 11 lines
slave_node {
controller-data {
cs-gpio = <>;
...
};
...
};
...
};Quoted 7 lines
Where as, SPI core and many other drivers uses "cs-gpios" for from device tree node.
Hence, make changes in
spi-s3c64xx.cdriver to make use of "cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in slaves "controller-data"(child) node.
So, the problem is not that the binding is not consistent with other SPI drivers (that would have been bad but acceptable IMHO) but that it is completely broken. And since we have to fix it which means breaking the ABI anyways, it is better to make it consistent with other drivers and SPI core.
Quoted 2 lines
Also updates the Device tree Documentation.
While I agree with others that a binding that has been broken for a year is a binding that appears to not be used a lot, we should be more vocal about this and why breaking backward compatibility is the right approach in this case.
So, in the (theoretical?) case that users find that their platform stopped to work with their current FDT, it will be easy for them to figure out what commit break it, what was the motivation to break the ABI and what changes are needed on their DTS to make it work again.
Adding the sha1 of the culprit commit (3146bee spi: s3c64xx: Added provision for dedicated cs pin) that puts us in this situation will also be useful. Since the date of that commit is part of the rationale behind this change. (e.g: nobody cared about this binding and so can be changed).
Quoted 58 lines
Signed-off-by Naveen Krishna Chatradhi <[email protected]>Acked-by Rob Herring <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Doug Anderson <[email protected]>Cc Tomasz Figa <[email protected]>---
Changes since v2:
1. updated the gpios usage in Documentation
2. use thespi->cs_gpioin the driver, instead of parsing the node again.
3. Corrected error check of the of.node and duringgpio_free.../devicetree/bindings/spi/spi-samsung.txt | 8 +++----- drivers/spi/spi-s3c64xx.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-)Documentation/devicetree/bindings/spi/spi-samsung.txt +3
-5@@ -42,15 +42,13 @@ Optional Board Specific Properties: - num-cs: Specifies the number of chip select lines supported. If not specified, the default number of chip select lines is set to 1. +- cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) + SPI Controller specific data in SPI slave nodes: - The spi slave nodes should provide the following information which is required by the spi controller. - - cs-gpio: A gpio specifier that specifies the gpio line used as - the slave select line by the spi controller. The format of the gpio - specifier depends on the gpio controller. - - samsung,spi-feedback-delay: The sampling phase shift to be applied on the miso line (to account for any lag in the miso line). The following are the valid values.@@ -85,6 +83,7 @@ Example: #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&spi0_bus>; + cs-gpios = <&gpa2 5 0>; w25q80bw at 0 { #address-cells = <1>;@@ -94,7 +93,6 @@ Example: spi-max-frequency = <10000>; controller-data { - cs-gpio = <&gpa2 5 1 0 3>; samsung,spi-feedback-delay = <0>; };drivers/spi/spi-s3c64xx.c +0
-0
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 775
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +0
-1@@ -772,24 +772,19 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( cs =kzalloc (sizeof (*cs),GFP_KERNEL );if (!cs) { -of_node_put (data_np);
Why are you removing this?
You are not removing the call to of_get_child_by_name(slave_np, "controller-data") so on failure data_np reference counter still needs to be decremented.
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 786
Quoted 12 lines
drivers/spi/spi-s3c64xx.c +1
-7return ERR_PTR (-ENOMEM ); } -/* The CS line is asserted/deasserted by the gpio pin */ -if (sdd->cs_gpio) - cs->line =of_get_named_gpio (data_np,"cs-gpio" ,0 ); - -if (!gpio_is_valid (cs->line)) { +if (!gpio_is_valid (spi->cs_gpio)) {dev_err (&spi->dev,"chip select gpio is not specified or invalid\n" ); -kfree (cs); -of_node_put (data_np);
Again, it's wrong to remove this of_node_put(data_np) call.
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 783
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +1
-0return ERR_PTR (-EINVAL ); } + cs->line = spi->cs_gpio;
I wonder why are you keeping cs->line? AFAICT it's only used in s3c64xx_spi_setup() to request the GPIO and since you get the struct spi_device pointer as a parameter then you can just use spi->s_gpio instead.
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 787
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +1
-0of_property_read_u32 (data_np,"samsung,spi-feedback-delay" , &fb_delay); cs->fb_delay = fb_delay;of_node_put (data_np); +
Usually is better to not mix style and functionality changes in the same patch since it makes harder to review.
Quoted 13 lines
drivers/spi/spi-s3c64xx.c +0
-2return cs; }@@ -828,8 +823,6 @@ static int s3c64xx_spi_setup(struct spi_device *spi) cs->line, err); goto err_gpio_req; } - - spi->cs_gpio = cs->line; }spi_set_ctldata (spi, cs);
drivers/spi/spi-s3c64xx.c setup_exit: · line 881
Quoted 6 lines
drivers/spi/spi-s3c64xx.c +2
-1@@ -884,7 +877,8 @@ setup_exit:/* setup() returns with device de-selected */ writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL ); -gpio_free (cs->line); +if (cs->line) +gpio_free (cs->line);
Same here, we can just get rid of cs->line and use gpio_free(spi->cs_gpio) instead.
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_probe(struct platform_device *pdev) · line 1075
Quoted 10 lines
drivers/spi/spi-s3c64xx.c +1
-1spi_set_ctldata (spi,NULL ); err_gpio_req:@@ -1077,7 +1071,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->sfr_start = mem_res->start; sdd->cs_gpio = true;if (pdev->dev.of_node) { -if (!of_find_property (pdev->dev.of_node,"cs-gpio" ,NULL )) +if (!of_find_property (pdev->dev.of_node,"cs-gpios" ,NULL )) sdd->cs_gpio = false;
I think we can get rid of sdd->cs_gpio as well. You can always use gpio_is_valid(spi->cs_gpio) or if (master->cs_gpios) to figure out if the SPI device has a cs-gpios array associated.
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_probe(struct platform_device *pdev) · line 1077
Quoted 3 lines
drivers/spi/spi-s3c64xx.c +0
-0ret =of_alias_get_id (pdev->dev.of_node,"spi" );
Best regards,
Javier
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Hello Javier,
Quoted 19 lines · Javier Martinez Canillas
Hello Naveen,
Thanks a lot for your patches and sorry that I didn't review your prior two versions but I didn't have the time yesterday.
Quoted 3 lines · Naveen Krishna Chatradhi
Currently,
spi-s3c64xx.cneeds "cs-gpio" chip select GPIO to be defined under "controller-data" node under each slave node.I think that the commit message is not clear enough about the intentions behind your patch.
It's not only that spi-s3c64xx needs a cs-gpio chip to be defined under controller-data dev node while all other SPI drivers expects cs-gpios at the top level, but more important that currently s3c64xx driver expects to have both cs-gpio (singular) at the top level *and* cs-gpio in controller data which doesn't make too much sense.
Quoted 7 lines
Quoted 3 lines
&spi_x { cs-gpios <>; ...As I said, currently it expects cs-gpio (singular) not cs-gpios (plural) as your example. It's important to have a correct commit message so future code archaeologists can have a proper picture of the situation if needed.
Will add some explanation in the example, for it to be clear.
Quoted 20 lines
Quoted 12 lines
slave_node { controller-data { cs-gpio = <>; ... }; ... }; ... };Quoted 7 lines
Where as, SPI core and many other drivers uses "cs-gpios" for from device tree node.
Hence, make changes in
spi-s3c64xx.cdriver to make use of "cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in slaves "controller-data"(child) node.
Quoted 4 lines
So, the problem is not that the binding is not consistent with other SPI drivers (that would have been bad but acceptable IMHO) but that it is completely broken. And since we have to fix it which means breaking the ABI anyways, it is better to make it consistent with other drivers and SPI core.
Will take this point for the while rewriting the commit messages
Quoted 13 lines
Quoted 3 lines
Also updates the Device tree Documentation.
While I agree with others that a binding that has been broken for a year is a binding that appears to not be used a lot, we should be more vocal about this and why breaking backward compatibility is the right approach in this case.
So, in the (theoretical?) case that users find that their platform stopped to work with their current FDT, it will be easy for them to figure out what commit break it, what was the motivation to break the ABI and what changes are needed on their DTS to make it work again.
Quoted 4 lines
Adding the sha1 of the culprit commit (3146bee spi: s3c64xx: Added provision for dedicated cs pin) that puts us in this situation will also be useful. Since the date of that commit is part of the rationale behind this change. (e.g: nobody cared about this binding and so can be changed).
Will take this point for the while rewriting the commit messages
Quoted 83 lines
Quoted 59 lines
Signed-off-by Naveen Krishna Chatradhi <[email protected]>Acked-by Rob Herring <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Doug Anderson <[email protected]>Cc Tomasz Figa <[email protected]>---
Changes since v2:
1. updated the gpios usage in Documentation
2. use thespi->cs_gpioin the driver, instead of parsing the node again.
3. Corrected error check of the of.node and duringgpio_free.../devicetree/bindings/spi/spi-samsung.txt | 8 +++----- drivers/spi/spi-s3c64xx.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-)Documentation/devicetree/bindings/spi/spi-samsung.txt +3
-5@@ -42,15 +42,13 @@ Optional Board Specific Properties: - num-cs: Specifies the number of chip select lines supported. If not specified, the default number of chip select lines is set to 1. +- cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) + SPI Controller specific data in SPI slave nodes: - The spi slave nodes should provide the following information which is required by the spi controller. - - cs-gpio: A gpio specifier that specifies the gpio line used as - the slave select line by the spi controller. The format of the gpio - specifier depends on the gpio controller. - - samsung,spi-feedback-delay: The sampling phase shift to be applied on the miso line (to account for any lag in the miso line). The following are the valid values.@@ -85,6 +83,7 @@ Example: #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&spi0_bus>; + cs-gpios = <&gpa2 5 0>; w25q80bw at 0 { #address-cells = <1>;@@ -94,7 +93,6 @@ Example: spi-max-frequency = <10000>; controller-data { - cs-gpio = <&gpa2 5 1 0 3>; samsung,spi-feedback-delay = <0>; };drivers/spi/spi-s3c64xx.c +0
-0drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 775
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +0
-1@@ -772,24 +772,19 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( cs =kzalloc (sizeof (*cs),GFP_KERNEL );if (!cs) { -of_node_put (data_np);Why are you removing this?
You are not removing the call to
of_get_child_by_name(slave_np, "controller-data")so on failuredata_npreference counter still needs to be decremented.drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 786
Quoted 12 lines
drivers/spi/spi-s3c64xx.c +1
-7return ERR_PTR (-ENOMEM ); } -/* The CS line is asserted/deasserted by the gpio pin */ -if (sdd->cs_gpio) - cs->line =of_get_named_gpio (data_np,"cs-gpio" ,0 ); - -if (!gpio_is_valid (cs->line)) { +if (!gpio_is_valid (spi->cs_gpio)) {dev_err (&spi->dev,"chip select gpio is not specified or invalid\n" ); -kfree (cs); -of_node_put (data_np);
Quoted 1 line
Again, it's wrong to remove this
of_node_put(data_np)call.
Actually, i wanted to move down the of_get_child_by_name() to before of_property_read_u32() call.
Quoted 9 lines
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 783
Quoted 5 lines
drivers/spi/spi-s3c64xx.c +1
-0return ERR_PTR (-EINVAL ); } + cs->line = spi->cs_gpio;I wonder why are you keeping
cs->line? AFAICT it's only used ins3c64xx_spi_setup()to request the GPIO and since you get the structspi_devicepointer as a parameter then you can just usespi->s_gpioinstead.
I'm trying not to touch the non-DT part of the code.
struct s3c64xx_spi_csinfo *cs = spi->controller_data;
This will update the cs->line and cs->fb_delay in case of non-DT.
Quoted 25 lines
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 787
Quoted 5 lines
drivers/spi/spi-s3c64xx.c +1
-0of_property_read_u32 (data_np,"samsung,spi-feedback-delay" , &fb_delay); cs->fb_delay = fb_delay;of_node_put (data_np); +Usually is better to not mix style and functionality changes in the same patch since it makes harder to review.
Quoted 16 lines
drivers/spi/spi-s3c64xx.c +0
-2return cs; }@@ -828,8 +823,6 @@ static int s3c64xx_spi_setup(struct spi_device *spi) cs->line, err); goto err_gpio_req; } - - spi->cs_gpio = cs->line; }spi_set_ctldata (spi, cs);@@ -884,7 +877,8 @@ setup_exit:/* setup() returns with device de-selected */ writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL );
Quoted 5 lines
drivers/spi/spi-s3c64xx.c setup_exit: · line 881
Quoted 3 lines
drivers/spi/spi-s3c64xx.c +2
-1-gpio_free (cs->line); +if (cs->line) +gpio_free (cs->line);Same here, we can just get rid of
cs->lineand usegpio_free(spi->cs_gpio)instead.
This is to keep the non-DT part untouched.
Quoted 15 lines
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_probe(struct platform_device *pdev) · line 1075
Quoted 11 lines
drivers/spi/spi-s3c64xx.c +1
-1spi_set_ctldata (spi,NULL ); err_gpio_req:@@ -1077,7 +1071,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->sfr_start = mem_res->start; sdd->cs_gpio = true;if (pdev->dev.of_node) { -if (!of_find_property (pdev->dev.of_node,"cs-gpio" ,NULL )) +if (!of_find_property (pdev->dev.of_node,"cs-gpios" ,NULL )) sdd->cs_gpio = false;I think we can get rid of
sdd->cs_gpioas well. You can always usegpio_is_valid(spi->cs_gpio)or if (master->cs_gpios) to figure out if the SPI device has a cs-gpios array associated.
This is to keep the non-DT part untouched
Quoted 7 lines
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_probe(struct platform_device *pdev) · line 1077
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +0
-0ret =of_alias_get_id (pdev->dev.of_node,"spi" );Best regards,
Javier
Will re-spin after waiting for a couple of more comments. Thanks for your review.
Signature · 2 lines
Shine bright, (: Nav :)
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Hello Naveen,
Quoted 69 lines · Naveen Krishna Ch
Hello Javier,
Quoted 19 lines · Javier Martinez Canillas
Hello Naveen,
Thanks a lot for your patches and sorry that I didn't review your prior two versions but I didn't have the time yesterday.
Quoted 3 lines · Naveen Krishna Chatradhi
Currently,
spi-s3c64xx.cneeds "cs-gpio" chip select GPIO to be defined under "controller-data" node under each slave node.I think that the commit message is not clear enough about the intentions behind your patch.
It's not only that spi-s3c64xx needs a cs-gpio chip to be defined under controller-data dev node while all other SPI drivers expects cs-gpios at the top level, but more important that currently s3c64xx driver expects to have both cs-gpio (singular) at the top level *and* cs-gpio in controller data which doesn't make too much sense.
Quoted 7 lines
Quoted 3 lines
&spi_x { cs-gpios <>; ...As I said, currently it expects cs-gpio (singular) not cs-gpios (plural) as your example. It's important to have a correct commit message so future code archaeologists can have a proper picture of the situation if needed.
Will add some explanation in the example, for it to be clear.
Quoted 20 lines
Quoted 12 lines
slave_node { controller-data { cs-gpio = <>; ... }; ... }; ... };Quoted 7 lines
Where as, SPI core and many other drivers uses "cs-gpios" for from device tree node.
Hence, make changes in
spi-s3c64xx.cdriver to make use of "cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in slaves "controller-data"(child) node.Quoted 4 lines
So, the problem is not that the binding is not consistent with other SPI drivers (that would have been bad but acceptable IMHO) but that it is completely broken. And since we have to fix it which means breaking the ABI anyways, it is better to make it consistent with other drivers and SPI core.
Will take this point for the while rewriting the commit messages
Quoted 13 lines
Quoted 3 lines
Also updates the Device tree Documentation.
While I agree with others that a binding that has been broken for a year is a binding that appears to not be used a lot, we should be more vocal about this and why breaking backward compatibility is the right approach in this case.
So, in the (theoretical?) case that users find that their platform stopped to work with their current FDT, it will be easy for them to figure out what commit break it, what was the motivation to break the ABI and what changes are needed on their DTS to make it work again.
Quoted 5 lines
Quoted 4 lines
Adding the sha1 of the culprit commit (3146bee spi: s3c64xx: Added provision for dedicated cs pin) that puts us in this situation will also be useful. Since the date of that commit is part of the rationale behind this change. (e.g: nobody cared about this binding and so can be changed).
Will take this point for the while rewriting the commit messages
Awesome, thanks.
Quoted 83 lines
Quoted 83 lines
Quoted 59 lines
Signed-off-by Naveen Krishna Chatradhi <[email protected]>Acked-by Rob Herring <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Doug Anderson <[email protected]>Cc Tomasz Figa <[email protected]>---
Changes since v2:
1. updated the gpios usage in Documentation
2. use thespi->cs_gpioin the driver, instead of parsing the node again.
3. Corrected error check of the of.node and duringgpio_free.../devicetree/bindings/spi/spi-samsung.txt | 8 +++----- drivers/spi/spi-s3c64xx.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-)Documentation/devicetree/bindings/spi/spi-samsung.txt +3
-5@@ -42,15 +42,13 @@ Optional Board Specific Properties: - num-cs: Specifies the number of chip select lines supported. If not specified, the default number of chip select lines is set to 1. +- cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) + SPI Controller specific data in SPI slave nodes: - The spi slave nodes should provide the following information which is required by the spi controller. - - cs-gpio: A gpio specifier that specifies the gpio line used as - the slave select line by the spi controller. The format of the gpio - specifier depends on the gpio controller. - - samsung,spi-feedback-delay: The sampling phase shift to be applied on the miso line (to account for any lag in the miso line). The following are the valid values.@@ -85,6 +83,7 @@ Example: #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&spi0_bus>; + cs-gpios = <&gpa2 5 0>; w25q80bw at 0 { #address-cells = <1>;@@ -94,7 +93,6 @@ Example: spi-max-frequency = <10000>; controller-data { - cs-gpio = <&gpa2 5 1 0 3>; samsung,spi-feedback-delay = <0>; };drivers/spi/spi-s3c64xx.c +0
-0drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 775
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +0
-1@@ -772,24 +772,19 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( cs =kzalloc (sizeof (*cs),GFP_KERNEL );if (!cs) { -of_node_put (data_np);Why are you removing this?
You are not removing the call to
of_get_child_by_name(slave_np, "controller-data")so on failuredata_npreference counter still needs to be decremented.Quoted 12 lines
drivers/spi/spi-s3c64xx.c +1
-7return ERR_PTR (-ENOMEM ); } -/* The CS line is asserted/deasserted by the gpio pin */ -if (sdd->cs_gpio) - cs->line =of_get_named_gpio (data_np,"cs-gpio" ,0 ); - -if (!gpio_is_valid (cs->line)) { +if (!gpio_is_valid (spi->cs_gpio)) {dev_err (&spi->dev,"chip select gpio is not specified or invalid\n" ); -kfree (cs); -of_node_put (data_np);
Quoted 3 lines
Quoted 1 line
Again, it's wrong to remove this
of_node_put(data_np)call.Actually, i wanted to move down the
of_get_child_by_name()to beforeof_property_read_u32()call.
Yeah, the wrong removals seemed to me like a left over from a previous attempt to reorganize the code.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/spi/spi-s3c64xx.c +1
-0return ERR_PTR (-EINVAL ); } + cs->line = spi->cs_gpio;
Quoted 8 lines
Quoted 3 lines
I wonder why are you keeping
cs->line? AFAICT it's only used ins3c64xx_spi_setup()to request the GPIO and since you get the structspi_devicepointer as a parameter then you can just usespi->s_gpioinstead.I'm trying not to touch the non-DT part of the code.
struct
s3c64xx_spi_csinfo*cs =spi->controller_data;This will update the
cs->lineandcs->fb_delayin case of non-DT.
I see, then I prefer the opposite and do something like this on s3c64xx_spi_probe():
if (!pdev->dev.of_node)
spi->cs_gpio = cs->line;
So, cs->line is only used by non-DT platforms to pass the GPIO to be used as chip-select line. But after that use spi->cs_gpio should be used in every place. If someday all the non-DT platforms are migrated to DT then only that assignment has to be removed instead of several lines of code using cs->line currently.
Also is more consistent to use spi->cs_gpio like most SPI drivers do instead of a custom structure member.
Quoted 25 lines
Quoted 25 lines
drivers/spi/spi-s3c64xx.c static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( · line 787
Quoted 5 lines
drivers/spi/spi-s3c64xx.c +1
-0of_property_read_u32 (data_np,"samsung,spi-feedback-delay" , &fb_delay); cs->fb_delay = fb_delay;of_node_put (data_np); +Usually is better to not mix style and functionality changes in the same patch since it makes harder to review.
Quoted 16 lines
drivers/spi/spi-s3c64xx.c +0
-2return cs; }@@ -828,8 +823,6 @@ static int s3c64xx_spi_setup(struct spi_device *spi) cs->line, err); goto err_gpio_req; } - - spi->cs_gpio = cs->line; }spi_set_ctldata (spi, cs);@@ -884,7 +877,8 @@ setup_exit:/* setup() returns with device de-selected */ writel (S3C64XX_SPI_SLAVE_SIG_INACT , sdd->regs +S3C64XX_SPI_SLAVE_SEL );
Quoted 6 lines
Quoted 5 lines
drivers/spi/spi-s3c64xx.c setup_exit: · line 881
Quoted 3 lines
drivers/spi/spi-s3c64xx.c +2
-1-gpio_free (cs->line); +if (cs->line) +gpio_free (cs->line);Same here, we can just get rid of
cs->lineand usegpio_free(spi->cs_gpio)instead.This is to keep the non-DT part untouched.
I don't get why you don't want to change legacy platform code if that means improving the driver. If you don't feel confident with your changes because you don't have access to the non-DT platform to test then you can post your patches as RFC or ask people to with access to those platforms to test and collect some Tested-by tags before the patch is merged.
Quoted 15 lines
Quoted 15 lines
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_probe(struct platform_device *pdev) · line 1075
Quoted 11 lines
drivers/spi/spi-s3c64xx.c +1
-1spi_set_ctldata (spi,NULL ); err_gpio_req:@@ -1077,7 +1071,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->sfr_start = mem_res->start; sdd->cs_gpio = true;if (pdev->dev.of_node) { -if (!of_find_property (pdev->dev.of_node,"cs-gpio" ,NULL )) +if (!of_find_property (pdev->dev.of_node,"cs-gpios" ,NULL )) sdd->cs_gpio = false;I think we can get rid of
sdd->cs_gpioas well. You can always usegpio_is_valid(spi->cs_gpio)or if (master->cs_gpios) to figure out if the SPI device has a cs-gpios array associated.
Quoted 1 line
This is to keep the non-DT part untouched
sdd->cs_gpio has nothing to do with non-DT platforms AFAIU. It was introduced in the commit that initially broke this binding and it's redundant information.
It's assigned to true on s3c64xx_spi_probe() and then set to false only if of_find_property(pdev->dev.of_node, "cs-gpios", NULL) fails.
But you don't need an additional variable to get that info since gpio_is_valid(spi->cs_gpio) or if (master->cs_gpios) can tell you the same AFAIK.
Quoted 8 lines
Quoted 7 lines
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_probe(struct platform_device *pdev) · line 1077
Quoted 4 lines
drivers/spi/spi-s3c64xx.c +0
-0ret =of_alias_get_id (pdev->dev.of_node,"spi" );Best regards,
JavierWill re-spin after waiting for a couple of more comments.
Perfect, thanks a lot!
Quoted 3 lines
Thanks for your review.
Best regards,
Javier
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Quoted 4 lines · Javier Martinez Canillas
Quoted 3 lines · Naveen Krishna Ch
Quoted 1 line · Javier Martinez Canillas
On 06/11/2014 08:31 AM, Naveen Krishna Chatradhi wrote:
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
return ERR_PTR(-EINVAL); }+
cs->line=spi->cs_gpio;I wonder why are you keeping
cs->line? AFAICT it's only used ins3c64xx_spi_setup()to request the GPIO and since you get the structspi_devicepointer as a parameter then you can just usespi->s_gpioinstead.I'm trying not to touch the non-DT part of the code.
Quoted 8 lines
Quoted 3 lines
struct
s3c64xx_spi_csinfo*cs =spi->controller_data;This will update the
cs->lineandcs->fb_delayin case of non-DT.I see, then I prefer the opposite and do something like this on
s3c64xx_spi_probe():if (!pdev->dev.of_node)
spi->cs_gpio = cs->line;
Hmm, as far as I understand, spi here is spi_device, not spi_master. I don't think you have access to SPI devices on your bus in controller probe().
What I think could work is reworking the driver to:
- in DT case, don't do anything in the driver about the GPIO chip select, because it will be handled automatically by the core.
- in non-DT case, in s3c64xx_spi_setup(), just take the GPIO pin from s3c64xx_spi_csinfo struct passed through spi->controller_data, request it and save it to spi->cs_gpio,
- in non-DT case, in s3c64xx_spi_cleanup(), free the GPIO requested in s3c64xx_spi_setup() and set spi->cs_gpio to -ENOENT (as done initially in spi_alloc_device()).
Best regards,
Tomasz
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Hello Tomasz,
Quoted 23 lines · Tomasz Figa
Quoted 4 lines · Javier Martinez Canillas
Quoted 3 lines · Naveen Krishna Ch
Quoted 1 line · Javier Martinez Canillas
On 06/11/2014 08:31 AM, Naveen Krishna Chatradhi wrote:
[snip]
Quoted 15 lines
Quoted 14 lines
Quoted 9 lines
Quoted 5 lines
return ERR_PTR(-EINVAL); }+
cs->line=spi->cs_gpio;I wonder why are you keeping
cs->line? AFAICT it's only used ins3c64xx_spi_setup()to request the GPIO and since you get the structspi_devicepointer as a parameter then you can just usespi->s_gpioinstead.I'm trying not to touch the non-DT part of the code.
struct
s3c64xx_spi_csinfo*cs =spi->controller_data;This will update the
cs->lineandcs->fb_delayin case of non-DT.
Quoted 9 lines
Quoted 4 lines
I see, then I prefer the opposite and do something like this on
s3c64xx_spi_probe():if (!pdev->dev.of_node)
spi->cs_gpio = cs->line;Hmm, as far as I understand, spi here is
spi_device, notspi_master. I don't think you have access to SPI devices on your bus in controllerprobe().
Right, I was actually looking at s3c64xx_spi_setup() when I wrote that but for some reason I got confused and thought it was the probe() function.
Sorry for the confusion.
Quoted 9 lines
What I think could work is reworking the driver to:
- in DT case, don't do anything in the driver about the GPIO chip select, because it will be handled automatically by the core.
- in non-DT case, in
s3c64xx_spi_setup(), just take the GPIO pin froms3c64xx_spi_csinfostruct passed throughspi->controller_data, request it and save it tospi->cs_gpio,
Quoted 7 lines
- in non-DT case, in
s3c64xx_spi_cleanup(), free the GPIO requested ins3c64xx_spi_setup()and setspi->cs_gpioto-ENOENT(as done initially inspi_alloc_device()).Best regards,
Tomasz
Best regards,
Javier
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
In reply to Tomasz FigaHello Tomasz,
Quoted 28 lines · Tomasz Figa
Quoted 4 lines · Javier Martinez Canillas
Quoted 3 lines · Naveen Krishna Ch
Quoted 1 line · Javier Martinez Canillas
On 06/11/2014 08:31 AM, Naveen Krishna Chatradhi wrote:
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
return ERR_PTR(-EINVAL); }+
cs->line=spi->cs_gpio;I wonder why are you keeping
cs->line? AFAICT it's only used ins3c64xx_spi_setup()to request the GPIO and since you get the structspi_devicepointer as a parameter then you can just usespi->s_gpioinstead.I'm trying not to touch the non-DT part of the code.
Quoted 8 lines
Quoted 3 lines
struct
s3c64xx_spi_csinfo*cs =spi->controller_data;This will update the
cs->lineandcs->fb_delayin case of non-DT.I see, then I prefer the opposite and do something like this on
s3c64xx_spi_probe():if (!pdev->dev.of_node)
spi->cs_gpio = cs->line;
Quoted 8 lines
Hmm, as far as I understand, spi here is
spi_device, notspi_master. I don't think you have access to SPI devices on your bus in controllerprobe().What I think could work is reworking the driver to:
- in DT case, don't do anything in the driver about the GPIO chip select, because it will be handled automatically by the core.
But, i see that gpio_request_one is needed in _setup function in the driver. Except that no other gpio related operation is needed in the driver.
Quoted 8 lines
- in non-DT case, in
s3c64xx_spi_setup(), just take the GPIO pin froms3c64xx_spi_csinfostruct passed throughspi->controller_data, request it and save it tospi->cs_gpio,- in non-DT case, in
s3c64xx_spi_cleanup(), free the GPIO requested ins3c64xx_spi_setup()and setspi->cs_gpioto-ENOENT(as done initially inspi_alloc_device()).
Its better going back to the working way.
Quoted 3 lines
Best regards,
Tomasz
Signature · 2 lines
Shine bright, (: Nav :)
Mark Brown
maintainerPATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
Quoted 7 lines · Naveen Krishna Ch
Quoted 2 lines · Tomasz Figa
- in DT case, don't do anything in the driver about the GPIO chip select, because it will be handled automatically by the core.
But, i see that
gpio_request_oneis needed in_setupfunction in the driver. Except that no other gpio related operation is needed in the driver.
Ideally this code could be moved into the core too - indeed, ideally the
non-DT case could be handled by the core too except for the bit where we
look up what GPIO to use.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140611/22e2901e/attachment.sig>
PATCH v3 1/2 spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
In reply to Naveen Krishna ChQuoted 35 lines · Naveen Krishna Ch
Hello Tomasz,
Quoted 32 lines · Tomasz Figa
Quoted 4 lines · Javier Martinez Canillas
Quoted 3 lines · Naveen Krishna Ch
Quoted 1 line · Javier Martinez Canillas
On 06/11/2014 08:31 AM, Naveen Krishna Chatradhi wrote:
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
return ERR_PTR(-EINVAL); }+
cs->line=spi->cs_gpio;I wonder why are you keeping
cs->line? AFAICT it's only used ins3c64xx_spi_setup()to request the GPIO and since you get the structspi_devicepointer as a parameter then you can just usespi->s_gpioinstead.I'm trying not to touch the non-DT part of the code.
Quoted 8 lines
Quoted 3 lines
struct
s3c64xx_spi_csinfo*cs =spi->controller_data;This will update the
cs->lineandcs->fb_delayin case of non-DT.I see, then I prefer the opposite and do something like this on
s3c64xx_spi_probe():if (!pdev->dev.of_node)
spi->cs_gpio = cs->line;Hmm, as far as I understand, spi here is
spi_device, notspi_master. I don't think you have access to SPI devices on your bus in controllerprobe().
Quoted 6 lines
Quoted 4 lines
What I think could work is reworking the driver to:
- in DT case, don't do anything in the driver about the GPIO chip select, because it will be handled automatically by the core.
But, i see that
gpio_request_oneis needed in_setupfunction in the driver. Except that no other gpio related operation is needed in the driver.
This should be handled by SPI core as well, but apparently it isn't. So the scheme of work in s3c64xx_spi_setup() changes as in pseudocode below:
if (!DT) spi->cs_gpio = cs->line; if (gpio_is_valid(spi->cs_gpio)) gpio_request_one(spi->cs_gpio);
and in s3c64xx_spi_cleanup():
if (gpio_is_valid(spi->cs_gpio)) gpio_free(spi->cs_gpio); if (!DT) spi->cs_gpio = -ENOENT;
Quoted 9 lines
Quoted 8 lines
- in non-DT case, in
s3c64xx_spi_setup(), just take the GPIO pin froms3c64xx_spi_csinfostruct passed throughspi->controller_data, request it and save it tospi->cs_gpio,- in non-DT case, in
s3c64xx_spi_cleanup(), free the GPIO requested ins3c64xx_spi_setup()and setspi->cs_gpioto-ENOENT(as done initially inspi_alloc_device()).Its better going back to the working way.
Hmm?
Best regards,
Tomasz