aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-dw-mmio.c
diff options
context:
space:
mode:
authorSteffen Trumtrar <s.trumtrar@pengutronix.de>2014-06-13 09:36:18 -0400
committerMark Brown <broonie@linaro.org>2014-07-03 14:44:04 -0400
commit22dae17e7a5e8b79e5e56d1557234dda9e1dd8e2 (patch)
tree1105b3b03858f01270e32766f2cff06c49d9f5d9 /drivers/spi/spi-dw-mmio.c
parent7171511eaec5bf23fb06078f59784a3a0626b38f (diff)
spi: dw-mmio: add devicetree support
Allow probing the dw-mmio from devicetree. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-dw-mmio.c')
-rw-r--r--drivers/spi/spi-dw-mmio.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index a5cba14ac3d2..21ce0e36fa00 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -16,7 +16,9 @@
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17#include <linux/scatterlist.h> 17#include <linux/scatterlist.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h>
19#include <linux/of_gpio.h> 20#include <linux/of_gpio.h>
21#include <linux/of_platform.h>
20 22
21#include "spi-dw.h" 23#include "spi-dw.h"
22 24
@@ -33,6 +35,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
33 struct dw_spi *dws; 35 struct dw_spi *dws;
34 struct resource *mem; 36 struct resource *mem;
35 int ret; 37 int ret;
38 int num_cs;
36 39
37 dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), 40 dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio),
38 GFP_KERNEL); 41 GFP_KERNEL);
@@ -68,9 +71,16 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
68 return ret; 71 return ret;
69 72
70 dws->bus_num = pdev->id; 73 dws->bus_num = pdev->id;
71 dws->num_cs = 4; 74
72 dws->max_freq = clk_get_rate(dwsmmio->clk); 75 dws->max_freq = clk_get_rate(dwsmmio->clk);
73 76
77 num_cs = 4;
78
79 if (pdev->dev.of_node)
80 of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs);
81
82 dws->num_cs = num_cs;
83
74 if (pdev->dev.of_node) { 84 if (pdev->dev.of_node) {
75 int i; 85 int i;
76 86
@@ -114,12 +124,19 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
114 return 0; 124 return 0;
115} 125}
116 126
127static const struct of_device_id dw_spi_mmio_of_match[] = {
128 { .compatible = "snps,dw-apb-ssi", },
129 { /* end of table */}
130};
131MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);
132
117static struct platform_driver dw_spi_mmio_driver = { 133static struct platform_driver dw_spi_mmio_driver = {
118 .probe = dw_spi_mmio_probe, 134 .probe = dw_spi_mmio_probe,
119 .remove = dw_spi_mmio_remove, 135 .remove = dw_spi_mmio_remove,
120 .driver = { 136 .driver = {
121 .name = DRIVER_NAME, 137 .name = DRIVER_NAME,
122 .owner = THIS_MODULE, 138 .owner = THIS_MODULE,
139 .of_match_table = dw_spi_mmio_of_match,
123 }, 140 },
124}; 141};
125module_platform_driver(dw_spi_mmio_driver); 142module_platform_driver(dw_spi_mmio_driver);