[PATCHv2 2/3] spi/spi-xilinx: Add clock support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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

Acked-by: Sören Brinkmann <soren.brinkmann@xxxxxxxxxx>
Signed-off-by: Shubhrajyoti Datta <shubhraj@xxxxxxxxxx>
---
v2 changes
Add ack

 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);
+	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;
 }
-- 
1.7.1

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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux