diff options
author | Steffen Trumtrar <s.trumtrar@pengutronix.de> | 2014-06-13 09:36:18 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-03 14:44:04 -0400 |
commit | 22dae17e7a5e8b79e5e56d1557234dda9e1dd8e2 (patch) | |
tree | 1105b3b03858f01270e32766f2cff06c49d9f5d9 | |
parent | 7171511eaec5bf23fb06078f59784a3a0626b38f (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>
-rw-r--r-- | Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 28 | ||||
-rw-r--r-- | drivers/spi/spi-dw-mmio.c | 19 |
2 files changed, 46 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt new file mode 100644 index 000000000000..bd99193e87b9 --- /dev/null +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | |||
@@ -0,0 +1,28 @@ | |||
1 | Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : "snps,dw-apb-ssi" | ||
5 | - reg : The register base for the controller. | ||
6 | - interrupts : One interrupt, used by the controller. | ||
7 | - #address-cells : <1>, as required by generic SPI binding. | ||
8 | - #size-cells : <0>, also as required by generic SPI binding. | ||
9 | |||
10 | Optional properties: | ||
11 | - cs-gpios : Specifies the gpio pis to be used for chipselects. | ||
12 | - num-cs : The number of chipselects. If omitted, this will default to 4. | ||
13 | |||
14 | Child nodes as per the generic SPI binding. | ||
15 | |||
16 | Example: | ||
17 | |||
18 | spi@fff00000 { | ||
19 | compatible = "snps,dw-apb-ssi"; | ||
20 | reg = <0xfff00000 0x1000>; | ||
21 | interrupts = <0 154 4>; | ||
22 | #address-cells = <1>; | ||
23 | #size-cells = <0>; | ||
24 | num-cs = <2>; | ||
25 | cs-gpios = <&gpio0 13 0>, | ||
26 | <&gpio0 14 0>; | ||
27 | }; | ||
28 | |||
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 | ||
127 | static const struct of_device_id dw_spi_mmio_of_match[] = { | ||
128 | { .compatible = "snps,dw-apb-ssi", }, | ||
129 | { /* end of table */} | ||
130 | }; | ||
131 | MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match); | ||
132 | |||
117 | static struct platform_driver dw_spi_mmio_driver = { | 133 | static 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 | }; |
125 | module_platform_driver(dw_spi_mmio_driver); | 142 | module_platform_driver(dw_spi_mmio_driver); |