Skip to content

Commit 48147b9

Browse files
aduggan-synadtor
authored andcommitted
Input: synaptics-rmi4 - add device tree support to the SPI transport driver
Add devicetree binding for SPI devices. Signed-off-by: Andrew Duggan <[email protected]> Acked-by: Rob Herring <[email protected]> Tested-by: Benjamin Tissoires <[email protected]> Tested-by: Linus Walleij <[email protected]> Tested-by: Bjorn Andersson <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 8d99758 commit 48147b9

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Synaptics RMI4 SPI Device Binding
2+
3+
The Synaptics RMI4 core is able to support RMI4 devices using different
4+
transports and different functions. This file describes the device tree
5+
bindings for devices using the SPI transport driver. Complete documentation
6+
for other transports and functions can be found in
7+
Documentation/devicetree/bindings/input/rmi4.
8+
9+
Required 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+
17+
Optional Properties:
18+
- interrupts: interrupt which the rmi device is connected to.
19+
- interrupt-parent: The interrupt controller.
20+
See 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+
25+
Function Parameters:
26+
Parameters 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:
28+
Documentation/devicetree/bindings/input/rmi4/rmi_f*.txt.
29+
30+
31+
32+
Example:
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+
};

Documentation/devicetree/bindings/spi/spi-bus.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ contain the following properties.
6161
used for MOSI. Defaults to 1 if not present.
6262
- spi-rx-bus-width - (optional) The bus width(number of data wires) that
6363
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.
6466

6567
Some SPI controllers and devices support Dual and Quad SPI transfer mode.
6668
It allows data in the SPI system to be transferred in 2 wires(DUAL) or 4 wires(QUAD).

drivers/input/rmi4/rmi_spi.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/slab.h>
1414
#include <linux/spi/spi.h>
1515
#include <linux/irq.h>
16+
#include <linux/of.h>
1617
#include "rmi_driver.h"
1718

1819
#define RMI_SPI_DEFAULT_XFER_BUF_SIZE 64
@@ -360,6 +361,41 @@ static int rmi_spi_init_irq(struct spi_device *spi)
360361
return 0;
361362
}
362363

364+
#ifdef CONFIG_OF
365+
static 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+
386+
static const struct of_device_id rmi_spi_of_match[] = {
387+
{ .compatible = "syna,rmi4-spi" },
388+
{},
389+
};
390+
MODULE_DEVICE_TABLE(of, rmi_spi_of_match);
391+
#else
392+
static 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+
363399
static int rmi_spi_probe(struct spi_device *spi)
364400
{
365401
struct rmi_spi_xport *rmi_spi;
@@ -377,8 +413,13 @@ static int rmi_spi_probe(struct spi_device *spi)
377413

378414
pdata = &rmi_spi->xport.pdata;
379415

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) {
381421
*pdata = *spi_pdata;
422+
}
382423

383424
if (pdata->spi_data.bits_per_word)
384425
spi->bits_per_word = pdata->spi_data.bits_per_word;
@@ -532,6 +573,7 @@ static struct spi_driver rmi_spi_driver = {
532573
.driver = {
533574
.name = "rmi4_spi",
534575
.pm = &rmi_spi_pm,
576+
.of_match_table = of_match_ptr(rmi_spi_of_match),
535577
},
536578
.id_table = rmi_id,
537579
.probe = rmi_spi_probe,

0 commit comments

Comments
 (0)