aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Duggan <aduggan@synaptics.com>2016-03-10 18:59:52 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-03-10 19:04:25 -0500
commit48147b9768b83265bf2e1211bcadeca035011380 (patch)
tree5af450151993e3e454ef1f5d2c2111a0f94d4110
parent8d99758dee31ff4a72bfc35d3a7a51fe66b7bb91 (diff)
Input: synaptics-rmi4 - add device tree support to the SPI transport driver
Add devicetree binding for SPI devices. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Acked-by: Rob Herring <robh@kernel.org> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Tested-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--Documentation/devicetree/bindings/input/rmi4/rmi_spi.txt57
-rw-r--r--Documentation/devicetree/bindings/spi/spi-bus.txt2
-rw-r--r--drivers/input/rmi4/rmi_spi.c44
3 files changed, 102 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_spi.txt b/Documentation/devicetree/bindings/input/rmi4/rmi_spi.txt
new file mode 100644
index 000000000000..a4ca7828f21d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/rmi4/rmi_spi.txt
@@ -0,0 +1,57 @@
1Synaptics RMI4 SPI Device Binding
2
3The Synaptics RMI4 core is able to support RMI4 devices using different
4transports and different functions. This file describes the device tree
5bindings for devices using the SPI transport driver. Complete documentation
6for other transports and functions can be found in
7Documentation/devicetree/bindings/input/rmi4.
8
9Required Properties:
10- compatible: syna,rmi4-spi
11- reg: Chip select address for the device
12- #address-cells: Set to 1 to indicate that the function child nodes
13 consist of only on uint32 value.
14- #size-cells: Set to 0 to indicate that the function child nodes do not
15 have a size property.
16
17Optional Properties:
18- interrupts: interrupt which the rmi device is connected to.
19- interrupt-parent: The interrupt controller.
20See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
21
22- spi-rx-delay-us: microsecond delay after a read transfer.
23- spi-tx-delay-us: microsecond delay after a write transfer.
24
25Function Parameters:
26Parameters specific to RMI functions are contained in child nodes of the rmi device
27 node. Documentation for the parameters of each function can be found in:
28Documentation/devicetree/bindings/input/rmi4/rmi_f*.txt.
29
30
31
32Example:
33 spi@7000d800 {
34 rmi4-spi-dev@0 {
35 compatible = "syna,rmi4-spi";
36 reg = <0x0>;
37 #address-cells = <1>;
38 #size-cells = <0>;
39 spi-max-frequency = <4000000>;
40 spi-cpha;
41 spi-cpol;
42 interrupt-parent = <&gpio>;
43 interrupts = <TEGRA_GPIO(K, 2) 0x2>;
44 spi-rx-delay-us = <30>;
45
46 rmi4-f01@1 {
47 reg = <0x1>;
48 syna,nosleep-mode = <1>;
49 };
50
51 rmi4-f11@11 {
52 reg = <0x11>;
53 touchscreen-inverted-y;
54 syna,sensor-type = <2>;
55 };
56 };
57 };
diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt
index bbaa857dd68f..42d595425dfb 100644
--- a/Documentation/devicetree/bindings/spi/spi-bus.txt
+++ b/Documentation/devicetree/bindings/spi/spi-bus.txt
@@ -61,6 +61,8 @@ contain the following properties.
61 used for MOSI. Defaults to 1 if not present. 61 used for MOSI. Defaults to 1 if not present.
62- spi-rx-bus-width - (optional) The bus width(number of data wires) that 62- spi-rx-bus-width - (optional) The bus width(number of data wires) that
63 used for MISO. Defaults to 1 if not present. 63 used for MISO. Defaults to 1 if not present.
64- spi-rx-delay-us - (optional) Microsecond delay after a read transfer.
65- spi-tx-delay-us - (optional) Microsecond delay after a write transfer.
64 66
65Some SPI controllers and devices support Dual and Quad SPI transfer mode. 67Some SPI controllers and devices support Dual and Quad SPI transfer mode.
66It allows data in the SPI system to be transferred in 2 wires(DUAL) or 4 wires(QUAD). 68It allows data in the SPI system to be transferred in 2 wires(DUAL) or 4 wires(QUAD).
diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c
index 4319c634553f..55bd1b34970c 100644
--- a/drivers/input/rmi4/rmi_spi.c
+++ b/drivers/input/rmi4/rmi_spi.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/of.h>
16#include "rmi_driver.h" 17#include "rmi_driver.h"
17 18
18#define RMI_SPI_DEFAULT_XFER_BUF_SIZE 64 19#define RMI_SPI_DEFAULT_XFER_BUF_SIZE 64
@@ -360,6 +361,41 @@ static int rmi_spi_init_irq(struct spi_device *spi)
360 return 0; 361 return 0;
361} 362}
362 363
364#ifdef CONFIG_OF
365static int rmi_spi_of_probe(struct spi_device *spi,
366 struct rmi_device_platform_data *pdata)
367{
368 struct device *dev = &spi->dev;
369 int retval;
370
371 retval = rmi_of_property_read_u32(dev,
372 &pdata->spi_data.read_delay_us,
373 "spi-rx-delay-us", 1);
374 if (retval)
375 return retval;
376
377 retval = rmi_of_property_read_u32(dev,
378 &pdata->spi_data.write_delay_us,
379 "spi-tx-delay-us", 1);
380 if (retval)
381 return retval;
382
383 return 0;
384}
385
386static const struct of_device_id rmi_spi_of_match[] = {
387 { .compatible = "syna,rmi4-spi" },
388 {},
389};
390MODULE_DEVICE_TABLE(of, rmi_spi_of_match);
391#else
392static inline int rmi_spi_of_probe(struct spi_device *spi,
393 struct rmi_device_platform_data *pdata)
394{
395 return -ENODEV;
396}
397#endif
398
363static int rmi_spi_probe(struct spi_device *spi) 399static int rmi_spi_probe(struct spi_device *spi)
364{ 400{
365 struct rmi_spi_xport *rmi_spi; 401 struct rmi_spi_xport *rmi_spi;
@@ -377,8 +413,13 @@ static int rmi_spi_probe(struct spi_device *spi)
377 413
378 pdata = &rmi_spi->xport.pdata; 414 pdata = &rmi_spi->xport.pdata;
379 415
380 if (spi_pdata) 416 if (spi->dev.of_node) {
417 retval = rmi_spi_of_probe(spi, pdata);
418 if (retval)
419 return retval;
420 } else if (spi_pdata) {
381 *pdata = *spi_pdata; 421 *pdata = *spi_pdata;
422 }
382 423
383 if (pdata->spi_data.bits_per_word) 424 if (pdata->spi_data.bits_per_word)
384 spi->bits_per_word = pdata->spi_data.bits_per_word; 425 spi->bits_per_word = pdata->spi_data.bits_per_word;
@@ -532,6 +573,7 @@ static struct spi_driver rmi_spi_driver = {
532 .driver = { 573 .driver = {
533 .name = "rmi4_spi", 574 .name = "rmi4_spi",
534 .pm = &rmi_spi_pm, 575 .pm = &rmi_spi_pm,
576 .of_match_table = of_match_ptr(rmi_spi_of_match),
535 }, 577 },
536 .id_table = rmi_id, 578 .id_table = rmi_id,
537 .probe = rmi_spi_probe, 579 .probe = rmi_spi_probe,