Input: synaptics-rmi4: Use generic interrupt handling
Subsystems (3)
PATCH v2 1/1 Input: synaptics-rmi4: Use generic interrupt handling
Currently the RMI4 driver expects the device to have a GPIO and manages the that GPIO internally. However, this duplicates functionality which could be handled by more generic interrupt handling code. Also, some RMI devices will not have a GPIO or it won't be accessible to the rmi4 driver. This patch removes the GPIO code and instead gets the irq passed up from the underlying transport (ie i2c-core).
---
After additional testing on a platform which uses board files I realized that the platform data should be able to provide irq flags. This patch adds to V1 by addind irq_flags in the platform data and copying it to the transport device. It also or's in the IRQF_ONESHOT flag in instead of assigning them.
Thanks,
Andrew
drivers/input/rmi4/rmi_bus.h | 3 ++ drivers/input/rmi4/rmi_driver.c | 81 +++++++---------------------------------- drivers/input/rmi4/rmi_driver.h | 2 - drivers/input/rmi4/rmi_i2c.c | 28 +++----------- include/linux/rmi.h | 21 ++--------- 5 files changed, 24 insertions(+), 111 deletions(-)
drivers/input/rmi4/rmi_bus.h +3 -0
@@ -175,6 +175,9 @@ struct rmi_transport_dev {struct device *dev;struct rmi_device *rmi_dev; +int irq; +int irq_flags; +irqreturn_t (*irq_thread)(int irq,void *p);irqreturn_t (*hard_irq)(int irq,void *p);
drivers/input/rmi4/rmi_driver.c +13 -68
144 lines not on this page · raw message
drivers/input/rmi4/rmi_driver.h +0 -2
@@ -38,8 +38,6 @@ struct rmi_driver_data {bool f01_bootloader_mode;u32 attn_count; -u32 irq_debug;/* Should be bool, but debugfs wants u32 */ -bool gpio_held;int irq;int irq_flags;int num_of_irq_regs;
drivers/input/rmi4/rmi_i2c.c +5 -23
@@ -196,9 +196,9 @@ static int rmi_i2c_probe(struct i2c_client *client,return -EINVAL ; } -dev_dbg (&client->dev,"Probing %s at %#02x (GPIO %d).\n" , +dev_dbg (&client->dev,"Probing %s at %#02x.\n" , pdata->sensor_name ? pdata->sensor_name :"-no name-" , - client->addr, pdata->attn_gpio); + client->addr);if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) { dev_err(&client->dev,
@@ -206,15 +206,6 @@ static int rmi_i2c_probe(struct i2c_client *client,return -ENODEV ; } -if (pdata->gpio_config) { - retval = pdata->gpio_config (pdata->gpio_data, true); -if (retval <0 ) { -dev_err (&client->dev,"Failed to configure GPIOs, code: %d.\n" , - retval); -return retval; - } - } - rmi_i2c =devm_kzalloc (&client->dev,sizeof (struct rmi_i2c_xport ),GFP_KERNEL );if (!rmi_i2c)
@@ -226,6 +217,8 @@ static int rmi_i2c_probe(struct i2c_client *client, rmi_i2c->xport.dev = &client->dev; rmi_i2c->xport.proto_name ="i2c" ; rmi_i2c->xport.ops = &rmi_i2c_ops; + rmi_i2c->xport.irq = client->irq; + rmi_i2c->xport.irq_flags = pdata->irq_flags;/* * Setting the page to zero will (a) make sure the PSR is in a
@@ -241,7 +234,7 @@ static int rmi_i2c_probe(struct i2c_client *client,if (retval) {dev_err (&client->dev,"Failed to register transport driver at 0x%.2X.\n" , client->addr); - goto err_gpio; +return retval; }i2c_set_clientdata (client, rmi_i2c);
@@ -249,25 +242,14 @@ static int rmi_i2c_probe(struct i2c_client *client,dev_info (&client->dev,"registered rmi i2c driver at %#04x.\n" , client->addr);return 0 ; - -err_gpio: -if (pdata->gpio_config) - pdata->gpio_config (pdata->gpio_data, false); - -return retval; }static int rmi_i2c_remove (struct i2c_client *client) { -const struct rmi_device_platform_data *pdata = -dev_get_platdata (&client->dev);struct rmi_i2c_xport *rmi_i2c =i2c_get_clientdata (client);rmi_unregister_transport_device (&rmi_i2c->xport); -if (pdata->gpio_config) - pdata->gpio_config (pdata->gpio_data, false); -return 0 ; }
include/linux/rmi.h +3 -18
@@ -203,22 +203,11 @@ struct rmi_device_platform_data_spi {* * @sensor_name - this is used for various diagnostic messages. * +* @irq_flags - this is used to specify intrerrupt type flags. +* * @firmware_name - if specified will override default firmware name, * for reflashing. * -* @attn_gpio - the index of a GPIO that will be used to provide the ATTN -* interrupt from the touch sensor. -* @attn_polarity - indicates whether ATTN is active high or low. -* @level_triggered - by default, the driver uses edge triggered interrupts. -* However, this can cause problems with suspend/resume on some platforms. In -* that case, set this to 1 to use level triggered interrupts. -* @gpio_config - a routine that will be called when the driver is loaded to -* perform any platform specific GPIO configuration, and when it is unloaded -* for GPIO de-configuration. This is typically used to configure the ATTN -* GPIO and the I2C or SPI pins, if necessary. -* @gpio_data - platform specific data to be passed to the GPIO configuration -* function. -* * @poll_interval_ms - the time in milliseconds between reads of the interrupt * status register. This is ignored if attn_gpio is non-zero. *
@@ -256,11 +245,7 @@ struct rmi_device_platform_data_spi {struct rmi_device_platform_data {char *sensor_name;/* Used for diagnostics. */ -int attn_gpio; -enum rmi_attn_polarity attn_polarity; -bool level_triggered; -void *gpio_data; -int (*gpio_config)(void *gpio_data,bool configure); +int irq_flags;int poll_interval_ms;
Signature · 1 line
2.1.4
PATCH v3 1/1 Input: synaptics-rmi4: Add device tree support for RMI4 I2C devices
Add devicetree binding for I2C devices and add bindings for optional parameters in the function drivers. Parameters for function drivers are defined in child nodes for each of the functions.
---
This version fixes the issues in v2 pointed out by Benjamin Tissoires. The memory leaks in rmi_i2c and rmi_f11 are fixed by embedding the platform data in the transport device and the f11 sensor data into f11_data. Values are then filled in by device tree or copied from the platform data set in a board file. Also, rmi_of_property_read_u16/u8 now use the appropriate of_property_read_u16/u8 calls.
Thanks,
Andrew
.../devicetree/bindings/input/rmi4/rmi_f01.txt | 37 +++++ .../devicetree/bindings/input/rmi4/rmi_f11.txt | 54 +++++++ .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 51 +++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/input/rmi4/rmi_bus.c | 83 +++++++++- drivers/input/rmi4/rmi_bus.h | 12 +- drivers/input/rmi4/rmi_driver.c | 34 ++++- drivers/input/rmi4/rmi_f01.c | 50 +++++- drivers/input/rmi4/rmi_f11.c | 167 ++++++++++++++++++--- drivers/input/rmi4/rmi_i2c.c | 61 ++++++-- include/linux/rmi.h | 2 +- 11 files changed, 510 insertions(+), 42 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt
Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt new file +37 -0
@@ -0,0 +1,37 @@ +Synaptics RMI4 F01 Device Binding + +The Synaptics RMI4 core is able to support RMI4 devices using differnet +transports and differnet functions. This file describes the device tree +bindings for devices which contain Function 1. Complete documentation +for transports and other functions can be found in: +Documentation/devicetree/bindings/input/rmi4. + +Additional documentation for F01 can be found at: +http://www.synaptics.com/sites/default/files/511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf + +Optional Properties: +- syna,nosleep: If set the device will run at full power without sleeping. +- syna,wakeup-threshold: Defines the amplitude of the disturbance to the + background capacitance that will cause the + device to wake from dozing. +- syna,doze-holdoff: The delay to wait after the last finger lift and the + first doze cycle (in 0.1 second units). +- syna,doze-interval: The time period that the device sleeps between finger + activity (in 10 ms units). + + +Example of a RMI4 I2C device with F01: + Example: + &i2c1 { + rmi-i2c-dev@2c { + compatible = "syna,rmi-i2c"; + + ... + + rmi-f01@1 { + reg = <0x1>; + syna,nosleep = <1>; + }; + }; + }; +
Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt new file +54 -0
54 lines not on this page · raw message
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +51 -0
51 lines not on this page · raw message
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -85,6 +85,7 @@ spansion Spansion Inc. st STMicroelectronics ste ST-Ericsson stericsson ST-Ericsson +syna Synaptics Inc. ti Texas Instruments tlm Trusted Logic Mobility toshiba Toshiba Corporation
drivers/input/rmi4/rmi_bus.c +77 -6
122 lines not on this page · raw message
drivers/input/rmi4/rmi_bus.h +10 -2
@@ -184,6 +184,8 @@ struct rmi_transport_dev {const char *proto_name;const struct rmi_transport_ops *ops;struct rmi_transport_stats stats; + +struct rmi_device_platform_data pdata; };/**
@@ -226,10 +228,10 @@ struct rmi_device {#define to_rmi_device (d) container_of(d, struct rmi_device, dev) -static inline const struct rmi_device_platform_data * +static inline struct rmi_device_platform_data *rmi_get_platform_data (struct rmi_device *d) { -return dev_get_platdata (d->xport->dev); +return &d->xport->pdata; }bool rmi_is_physical_device (struct device *dev);
@@ -317,4 +319,10 @@ int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));extern struct bus_type rmi_bus_type; +int rmi_of_property_read_u32 (struct device *dev,u32 *result, +const char *prop,bool optional); +int rmi_of_property_read_u16 (struct device *dev,u16 *result, +const char *prop,bool optional); +int rmi_of_property_read_u8 (struct device *dev,u8 *result, +const char *prop,bool optional);#endif
drivers/input/rmi4/rmi_driver.c +33 -1
@@ -717,11 +717,37 @@ static int rmi_driver_remove(struct device *dev)return 0 ; } +#ifdef CONFIG_OF +static int rmi_driver_of_probe (struct device *dev, +struct rmi_device_platform_data *pdata) +{ +int retval; + + retval =rmi_of_property_read_u32 (dev, &pdata->poll_interval_ms, +"syna,poll-interval-ms" ,1 ); +if (retval) +return retval; + + retval =rmi_of_property_read_u32 (dev, &pdata->reset_delay_ms, +"syna,reset-delay-ms" ,1 ); +if (retval) +return retval; + +return 0 ; +} +#else +static inline int rmi_driver_of_probe (struct device *dev, +struct rmi_device_platform_data *pdata) +{ +return -ENODEV ; +} +#endif +static int rmi_driver_probe (struct device *dev) {struct rmi_driver *rmi_driver;struct rmi_driver_data *data; -const struct rmi_device_platform_data *pdata; +struct rmi_device_platform_data *pdata;struct rmi_device *rmi_dev;size_t size;void *irq_memory;
@@ -741,6 +767,12 @@ static int rmi_driver_probe(struct device *dev) pdata =rmi_get_platform_data (rmi_dev); +if (rmi_dev->xport->dev->of_node) { + retval =rmi_driver_of_probe (rmi_dev->xport->dev, pdata); +if (retval) +return retval; + } + data =kzalloc (sizeof (struct rmi_driver_data ),GFP_KERNEL );if (!data) {dev_err (dev,"%s: Failed to allocate driver data.\n" , __func__);
drivers/input/rmi4/rmi_f01.c +49 -1
71 lines not on this page · raw message
drivers/input/rmi4/rmi_f11.c +147 -20
206 lines not on this page · raw message
drivers/input/rmi4/rmi_i2c.c +50 -11
91 lines not on this page · raw message
include/linux/rmi.h +1 -1
@@ -241,7 +241,7 @@ struct rmi_device_platform_data_spi {* functions. */ struct rmi_device_platform_data { -char *sensor_name;/* Used for diagnostics. */ +const char *sensor_name;/* Used for diagnostics. */ int poll_interval_ms;
Signature · 1 line
2.1.4