History

Input: synaptics-rmi4 - add device tree support to the SPI transport driver

Add devicetree binding for SPI devices.

Andrew Duggan committed 10 years ago

Commit 48147b91 parent 8d997583 files · +102 −1Browse files

Unified · Split

3 files
  1. Documentation/devicetree/bindings/input/rmi4/rmi_spi.txt +57 −0
  2. Documentation/devicetree/bindings/spi/spi-bus.txt +2 −0
  3. drivers/input/rmi4/rmi_spi.c +43 −1
Documentation/devicetree/bindings/input/rmi4/rmi_spi.txt+57−0
@@ -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 };
Documentation/devicetree/bindings/spi/spi-bus.txt+2−0
@@ -61,6 +61,8 @@ contain the following properties. · 60 unmodified lines
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) that62- 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).
drivers/input/rmi4/rmi_spi.c+43−1
@@ -13,6 +13,7 @@ · 12 unmodified lines
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 6419#define RMI_SPI_DEFAULT_XFER_BUF_SIZE 64
@@ -360,6 +361,41 @@ static int rmi_spi_init_irq(struct spi_device *spi) · 341 unmodified lines
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) · 11 unmodified lines
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 = { · 147 unmodified lines
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,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t