linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv4 1/2] spi/spi-xilinx:  Add clock support
@ 2016-03-12  8:00 Shubhrajyoti Datta
       [not found] ` <1457769637-5627-1-git-send-email-shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-12  8:00 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	michal.simek-gjFFaj9aHVfQT0dZR+AlfA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lars-Qo5EllUWu/uELgA04lAiVw,
	Shubhrajyoti Datta

Add basic clock support. The clocks are requested at probe
and released at remove.

Signed-off-by: Shubhrajyoti Datta <shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
---
v3 changes:
Do not fail probe if no clock is given
Add a clk name
Fix some space errors
v4 changes:
correct the clock name
also check for ENOENT to prevent breaking current dts

 drivers/spi/spi-xilinx.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 3009121..bd9ad61 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -21,6 +21,7 @@
 #include <linux/spi/spi_bitbang.h>
 #include <linux/spi/xilinx_spi.h>
 #include <linux/io.h>
+#include <linux/clk.h>
 
 #define XILINX_SPI_MAX_CS	32
 
@@ -83,6 +84,7 @@ struct xilinx_spi {
 	struct spi_bitbang bitbang;
 	struct completion done;
 	void __iomem	*regs;	/* virt. address of the control registers */
+	struct clk *aclk;	/* AXI clock */
 
 	int		irq;
 
@@ -428,6 +430,24 @@ static int xilinx_spi_probe(struct platform_device *pdev)
 		goto put_master;
 	}
 
+	xspi->aclk = devm_clk_get(&pdev->dev, "s_axi_aclk");
+	if (IS_ERR(xspi->aclk)) {
+		if (PTR_ERR(xspi->aclk) == -ENOENT) {
+			dev_err(&pdev->dev, "No clocks found for aclk\n");
+			xspi->aclk = NULL;
+		} else {
+			dev_err(&pdev->dev, "axi clock error %d\n", ret);
+			ret = PTR_ERR(xspi->aclk);
+			goto put_master;
+		}
+	}
+
+	ret = clk_prepare_enable(xspi->aclk);
+	if (ret) {
+		dev_err(&pdev->dev, "Unable to enable axi clock.\n");
+		goto put_master;
+	}
+
 	master->bus_num = pdev->id;
 	master->num_chipselect = num_cs;
 	master->dev.of_node = pdev->dev.of_node;
@@ -460,7 +480,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
 		ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0,
 				dev_name(&pdev->dev), xspi);
 		if (ret)
-			goto put_master;
+			goto dis_master_clk;
 	}
 
 	/* SPI controller initializations */
@@ -469,7 +489,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
 	ret = spi_bitbang_start(&xspi->bitbang);
 	if (ret) {
 		dev_err(&pdev->dev, "spi_bitbang_start FAILED\n");
-		goto put_master;
+		goto dis_master_clk;
 	}
 
 	dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n",
@@ -483,9 +503,10 @@ static int xilinx_spi_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 	return 0;
 
+dis_master_clk:
+	clk_disable_unprepare(xspi->aclk);
 put_master:
 	spi_master_put(master);
-
 	return ret;
 }
 
@@ -503,6 +524,7 @@ static int xilinx_spi_remove(struct platform_device *pdev)
 	xspi->write_fn(0, regs_base + XIPIF_V123B_DGIER_OFFSET);
 
 	spi_master_put(xspi->bitbang.master);
+	clk_disable_unprepare(xspi->aclk);
 
 	return 0;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCHv4 2/2] bindings: spi: Add clock entries for spi-xilinx
       [not found] ` <1457769637-5627-1-git-send-email-shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
@ 2016-03-12  8:00   ` Shubhrajyoti Datta
       [not found]     ` <1457769637-5627-2-git-send-email-shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-12  8:00 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	michal.simek-gjFFaj9aHVfQT0dZR+AlfA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lars-Qo5EllUWu/uELgA04lAiVw,
	Shubhrajyoti Datta

Add clock description for spi-xilinx

Signed-off-by: Shubhrajyoti Datta <shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
---
v3
Add a clock name
v4
Correct the name 
 .../devicetree/bindings/spi/spi-xilinx.txt         |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
index c7b7856..07ec09a 100644
--- a/Documentation/devicetree/bindings/spi/spi-xilinx.txt
+++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
@@ -7,6 +7,9 @@ Required properties:
 - interrupts		: Property with a value describing the interrupt
 			  number.
 - interrupt-parent	: Must be core interrupt controller
+- clocks: Input clock specifier. Refer to common clock bindings.
+- clock-names: tuple listing input clock names.
+	Required elements: "s_axi_aclk"
 
 Optional properties:
 - xlnx,num-ss-bits	: Number of chip selects used.
@@ -14,6 +17,8 @@ Optional properties:
 Example:
 	axi_quad_spi@41e00000 {
 			compatible = "xlnx,xps-spi-2.00.a";
+			clocks = <&clkc 15>;
+			clock-names = "spi_fclk";
 			interrupt-parent = <&intc>;
 			interrupts = <0 31 1>;
 			reg = <0x41e00000 0x10000>;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCHv4 2/2] bindings: spi: Add clock entries for spi-xilinx
       [not found]     ` <1457769637-5627-2-git-send-email-shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
@ 2016-03-12 10:05       ` Sören Brinkmann
  2016-03-12 15:52         ` Shubhrajyoti Datta
  0 siblings, 1 reply; 4+ messages in thread
From: Sören Brinkmann @ 2016-03-12 10:05 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	michal.simek-gjFFaj9aHVfQT0dZR+AlfA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lars-Qo5EllUWu/uELgA04lAiVw,
	Shubhrajyoti Datta

On Sat, 2016-03-12 at 13:30:37 +0530, Shubhrajyoti Datta wrote:
> Add clock description for spi-xilinx
> 
> Signed-off-by: Shubhrajyoti Datta <shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
> ---
> v3
> Add a clock name
> v4
> Correct the name 
>  .../devicetree/bindings/spi/spi-xilinx.txt         |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
> index c7b7856..07ec09a 100644
> --- a/Documentation/devicetree/bindings/spi/spi-xilinx.txt
> +++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
> @@ -7,6 +7,9 @@ Required properties:
>  - interrupts		: Property with a value describing the interrupt
>  			  number.
>  - interrupt-parent	: Must be core interrupt controller
> +- clocks: Input clock specifier. Refer to common clock bindings.
> +- clock-names: tuple listing input clock names.
> +	Required elements: "s_axi_aclk"

I thought there were too clocks? If the IP has two clocks, I think both
should be added and supported here.

>  
>  Optional properties:
>  - xlnx,num-ss-bits	: Number of chip selects used.
> @@ -14,6 +17,8 @@ Optional properties:
>  Example:
>  	axi_quad_spi@41e00000 {
>  			compatible = "xlnx,xps-spi-2.00.a";
> +			clocks = <&clkc 15>;
> +			clock-names = "spi_fclk";

Doesn't match the binding documented above.

	Sören
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCHv4 2/2] bindings: spi: Add clock entries for spi-xilinx
  2016-03-12 10:05       ` Sören Brinkmann
@ 2016-03-12 15:52         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 4+ messages in thread
From: Shubhrajyoti Datta @ 2016-03-12 15:52 UTC (permalink / raw)
  To: Sören Brinkmann
  Cc: Shubhrajyoti Datta, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Michal Simek, Mark Brown,
	Lars-Peter Clausen, Shubhrajyoti Datta

On Sat, Mar 12, 2016 at 3:35 PM, Sören Brinkmann
<soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org> wrote:
> On Sat, 2016-03-12 at 13:30:37 +0530, Shubhrajyoti Datta wrote:
>> Add clock description for spi-xilinx
>>
>> Signed-off-by: Shubhrajyoti Datta <shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
>> ---
>> v3
>> Add a clock name
>> v4
>> Correct the name
>>  .../devicetree/bindings/spi/spi-xilinx.txt         |    5 +++++
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
>> index c7b7856..07ec09a 100644
>> --- a/Documentation/devicetree/bindings/spi/spi-xilinx.txt
>> +++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
>> @@ -7,6 +7,9 @@ Required properties:
>>  - interrupts         : Property with a value describing the interrupt
>>                         number.
>>  - interrupt-parent   : Must be core interrupt controller
>> +- clocks: Input clock specifier. Refer to common clock bindings.
>> +- clock-names: tuple listing input clock names.
>> +     Required elements: "s_axi_aclk"
>
> I thought there were too clocks? If the IP has two clocks, I think both
> should be added and supported here.
>
Ok sure

>>
>>  Optional properties:
>>  - xlnx,num-ss-bits   : Number of chip selects used.
>> @@ -14,6 +17,8 @@ Optional properties:
>>  Example:
>>       axi_quad_spi@41e00000 {
>>                       compatible = "xlnx,xps-spi-2.00.a";
>> +                     clocks = <&clkc 15>;
>> +                     clock-names = "spi_fclk";
>
> Doesn't match the binding documented above.

missed it will update thanks.

>
>         Sören
> --
> To unsubscribe from this list: send the line "unsubscribe linux-spi" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-03-12 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-12  8:00 [PATCHv4 1/2] spi/spi-xilinx: Add clock support Shubhrajyoti Datta
     [not found] ` <1457769637-5627-1-git-send-email-shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2016-03-12  8:00   ` [PATCHv4 2/2] bindings: spi: Add clock entries for spi-xilinx Shubhrajyoti Datta
     [not found]     ` <1457769637-5627-2-git-send-email-shubhraj-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2016-03-12 10:05       ` Sören Brinkmann
2016-03-12 15:52         ` Shubhrajyoti Datta

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).