diff mbox

spi/spi-xilinx: Add clock support

Message ID 1457426528-15247-1-git-send-email-shubhraj@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shubhrajyoti Datta March 8, 2016, 8:42 a.m. UTC
Add basic clock support. The clocks are requested at probe
and released at remove.

Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
---
 drivers/spi/spi-xilinx.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

Comments

Soren Brinkmann March 8, 2016, 6:02 p.m. UTC | #1
On Tue, 2016-03-08 at 14:12:08 +0530, Shubhrajyoti Datta wrote:
> Add basic clock support. The clocks are requested at probe
> and released at remove.
> 
> Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
Acked-by: Sören Brinkmann <soren.brinkmann@xilinx.com>

Though, the DT bindings need to be updated accordingly.

	Sören
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown March 9, 2016, 2:42 a.m. UTC | #2
On Tue, Mar 08, 2016 at 02:12:08PM +0530, Shubhrajyoti Datta wrote:

> +	xspi->clk = devm_clk_get(&pdev->dev, NULL);
> +	if (IS_ERR(xspi->clk)) {
> +		dev_err(&pdev->dev, "input clock not found.\n");
> +		return PTR_ERR(xspi->clk);
> +	}

This changes the DT binding but does not update the binding document.
Shubhrajyoti Datta March 9, 2016, 8:53 a.m. UTC | #3
> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org]
> Sent: Wednesday, March 09, 2016 8:12 AM
> To: Shubhrajyoti Datta
> Cc: linux-spi@vger.kernel.org; Soren Brinkmann; Michal Simek; Shubhrajyoti
> Datta
> Subject: Re: [PATCH] spi/spi-xilinx: Add clock support
> 
> On Tue, Mar 08, 2016 at 02:12:08PM +0530, Shubhrajyoti Datta wrote:
> 
> > +	xspi->clk = devm_clk_get(&pdev->dev, NULL);
> > +	if (IS_ERR(xspi->clk)) {
> > +		dev_err(&pdev->dev, "input clock not found.\n");
> > +		return PTR_ERR(xspi->clk);
> > +	}
> 
> This changes the DT binding but does not update the binding document.

Thanks for review fixed  in v2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lars-Peter Clausen March 9, 2016, 9:07 a.m. UTC | #4
On 03/08/2016 09:42 AM, Shubhrajyoti Datta wrote:
> Add basic clock support. The clocks are requested at probe
> and released at remove.
> 
> Signed-off-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
> ---
>  drivers/spi/spi-xilinx.c |   13 +++++++++++++
>  1 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
> index 3009121..7e12338 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 *clk;
>  
>  	int		irq;
>  
> @@ -428,6 +430,15 @@ static int xilinx_spi_probe(struct platform_device *pdev)
>  		goto put_master;
>  	}
>  
> +	xspi->clk = devm_clk_get(&pdev->dev, NULL);

Considering that the core has multiple clock inputs this should specify
which clock you are referencing here.

Also this breaks existing devicetrees which do not specify the clock...

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

Patch

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 3009121..7e12338 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 *clk;
 
 	int		irq;
 
@@ -428,6 +430,15 @@  static int xilinx_spi_probe(struct platform_device *pdev)
 		goto put_master;
 	}
 
+	xspi->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(xspi->clk)) {
+		dev_err(&pdev->dev, "input clock not found.\n");
+		return PTR_ERR(xspi->clk);
+	}
+	ret = clk_prepare_enable(xspi->clk);
+	if (ret)
+		dev_err(&pdev->dev, "Unable to enable clock.\n");
+
 	master->bus_num = pdev->id;
 	master->num_chipselect = num_cs;
 	master->dev.of_node = pdev->dev.of_node;
@@ -485,6 +496,7 @@  static int xilinx_spi_probe(struct platform_device *pdev)
 
 put_master:
 	spi_master_put(master);
+	clk_disable_unprepare(xspi->clk);
 
 	return ret;
 }
@@ -503,6 +515,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->clk);
 
 	return 0;
 }