input/touchscreen: Synaptics RMI4 Touchscreen Driver
Subsystems (3)
cover input/touchscreen: Synaptics RMI4 Touchscreen Driver
This patch implements a driver supporting Synaptics ClearPad and other touchscreens that use the RMI4 protocol, as defined here:
http://www.synaptics.com/sites/default/files/511-000136-01_revD.pdf
This patch is against the v2.6.38 tag of Linus' kernel tree, commit 521cb40b0c44418a4fd36dc633f575813d59a43d.
This patch completely supersedes the previous patch of 2011/03/30. Quite a few changes have been included in this patch.
- bug fixes and changes based on input received for the 2011/03/30 patch. I'm not going to list them all here, but we have resolved all bugs and changes suggested for that patch, except as listed below. Many thanks to all the folks who took the time review that code and make suggestions.
- major reformatting, variable renaming, and other changes to meet kernel coding standards. Checkpatch.pl should run with not complaints at all, not even warnings.
- full support for all Synaptics RMI4 SPI products.
- implementation of suspend/resume behavior.
- improved error handling, particularly during initialization
- improved memory management
- extermination of printk, switching to pr_xxx (and dev_xxx where appropriate).
- A major reduction in the amoung of INFO level messages generated.
- Fixed Makefile and Kconfig.
What's not in this patch?
- the RMI bus structure still isn't where we want it to be. There's a lot of ad-hoc-ery going on to match sensor drivers to devices, and function drivers to the sensors. We know it's a mess, but want to get the core sensing functionality solid before re-arranging the guts of the system. In our opinion, it's better to have a working driver with ugly architecture than a beautiful architecture that doesn't work. Obviously it's best to have a driver that's beautiful and works, all at the same time, so after one more functional patch later in July, we intend to address the architectural issue in the next few weeks after that.
- a number of people suggested moving some header files to more sensible locations. That's an excellent idea, but because we may wind up moving them around again when we update the architecture, we decided not to implement that in order to reduce the confusion among those folks already using this code.
- full documentation - we've started this, but it is not complete by any means.
This patch supports a system having one or more RMI sensors attached to it. Most devices have just a single touch sensor, but some have more than one. An example is the Fuse concept phone, which has 4 RMI sensors in it). Each sensor implements a number of RMI4 functions, which are best represented as devices on the bus.
I2C functionality was previously ACK'ed by Jean Delvare on 2010/05/29.
We've broken this patch into 9 parts in order to keep the individual emails down to a manageable size.
1/9 - core files implementing the bus and providing global definitions
and platform data
2/9 - the physical device interface drivers for I2C and SPI
3/9 - the sensor level implementation files
4/9 - Makefile, Kconfig, and doc file.
5-9/9 - Function drivers for the following RMI4 functions
F01 device control
F05 analog data (stub)
F11 2D sensing
F19 capacitive buttons
F34 device reflash
The driver core manages the sensors on a device via the rmi bus (/sys/bus/rmi), handles interfunction communications (mostly IRQ notifications from F01 to other functions), and proxies register read/write requests to the appropriate physical layer for a given sensor.
Individual sensors are presented on the bus as /sys/bus/rmi/devices/sensor00, /sys/bus/rmi/devices/sensor01/, and so on.
Functions for each sensor are presented as devices next to that sensor, for example /sys/bus/rmi/devices/sensor00f01, /sys/bus/rmi/devices/sensor00f11, and so on.
Sensor driver instances are attached to the bus using the kernel device discovery mechanism. As described above, a future release will do the same for function driver instances, but for now we use an ad hoc mechanism to match functions to sensors. Yes, we know it's ugly.
We chose this approach because almost all RMI4 functions are independent of one another. The sole exception is F01, and its primary interaction with other functions is to notify them of the need to read or write data from or to the sensor. In the long term, this will allow 3rd parties to implement additional RMI functions in a modular fashion, without having to modify the core driver implementation or the implementation of unrelated functions.
Comments and other feedback on this driver are welcomed.
Christopher Heiny
Bill Manson
Allie Xiong
Peichen Chang
---
PATCH 1/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
Driver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_bus.c new file +383 -0
@@ -0,0 +1,383 @@ +/** +* Synaptics Register Mapped Interface (RMI4) - RMI Bus Module. +* Copyright (C) 2007 - 2011, Synaptics Incorporated +* +* Implements "rmi" bus per Documentation/driver-model/bus.txt +* +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +static const char busname[] ="rmi" ; + +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/hrtimer.h> +#include <linux/list.h> +#include <linux/miscdevice.h> +#include <linux/fs.h> +#include <linux/delay.h> +#include <linux/uaccess.h> +#include <linux/slab.h> + +#include "rmi_drvr.h" +#include "rmi.h" +#include "rmi_bus.h" +#include "rmi_platformdata.h" +#include "rmi_sensor.h" +#include "rmi_function.h" + +#define PDT_START_SCAN_LOCATION 0x00E9 +#define PDT_END_SCAN_LOCATION 0x0005 +#define PDT_ENTRY_SIZE 0x0006 + +/* definitions for rmi bus */ +struct device rmi_bus_device; + +struct bus_type rmi_bus_type; +EXPORT_SYMBOL (rmi_bus_type); + +/* +* This method is called, perhaps multiple times, whenever a new device or +* driver is added for this bus. It should return a nonzero value if the given +* device can be handled by the given driver. This function must be handled at +* the bus level, because that is where the proper logic exists; the core +* kernel cannot know how to match devices and drivers for every possible bus +* type The match function does a comparison between the hardware ID provided +* by the device itself and the IDs supported by the driver. +* +*/ +static int rmi_bus_match (struct device *dev,struct device_driver *driver) +{ +dev_dbg (dev,"%s: Matching driver %s against bus %s for rmi bus.\n" , + __func__, driver->name, dev->bus->name); +return !strcmp (dev->bus->name, driver->name); +} + +/* Stub for now. +*/ +static int rmi_bus_suspend (struct device *dev,pm_message_t state) +{ +dev_dbg (dev,"%s: RMI bus suspending." , __func__); +return 0 ; +} + +/* Stub for now. +*/ +static int rmi_bus_resume (struct device *dev) +{ +dev_dbg (dev,"%s: RMI bus resuming." , __func__); +return 0 ; +} + +/* +* This method is called, whenever a new device is added for this bus. +* It will scan the devices PDT to get the function $01 query, control, +* command and data regsiters so that it can create a function $01 (sensor) +* device for the new physical device. It also caches the PDT for later use by +* other functions that are created for the device. For example, if a function +* $11 is found it will need the query, control, command and data register +* addresses for that function. The new function could re-scan the PDT but +* since it is being done here we can cache it and keep it around. +* +* TODO: If the device is reset or some action takes place that would invalidate +* the PDT - such as a reflash of the firmware - then the device should be +* re-added to the bus and the PDT re-scanned and cached. +* +*/ +int rmi_register_sensor (struct rmi_phys_driver *rpd, +struct rmi_sensordata *sensordata) +{ +int i; +int pdt_entry_count =0 ; +struct rmi_sensor_device *rmi_sensor_dev =NULL ; +struct rmi_function_descriptor rmi_fd; +int retval; +static int index; + +/* Make sure we have a read, write, read_multiple, write_multiple +function pointers from whatever physical layer the sensor is on. +*/ +if (!rpd->name) { +pr_err ("%s: Physical driver must specify a name" , __func__); +return -EINVAL ; + } +if (!rpd->write) { +pr_err ("%s: Physical driver %s must specify a writer." , + __func__, rpd->name); +return -EINVAL ; + } +if (!rpd->read) { +pr_err ("%s: Physical driver %s must specify a reader." , + __func__, rpd->name); +return -EINVAL ; + } +if (!rpd->write_multiple) { +pr_err ("%s: Physical driver %s must specify a " +"multiple writer." , __func__, rpd->name); +return -EINVAL ; + } +if (!rpd->read_multiple) { +pr_err ("%s: Physical driver %s must specify a " +"multiple reader." , __func__, rpd->name); +return -EINVAL ; + } + +/* Get some information from the device */ +pr_debug ("%s: Identifying sensors by presence of F01..." , __func__); + +/* Scan the page descriptor table until we find F01. If we find that, +* we assume that we can reliably talk to this sensor. +*/ +for (i =PDT_START_SCAN_LOCATION ; + i >=PDT_END_SCAN_LOCATION ; i -=PDT_ENTRY_SIZE ) { + retval = rpd->read_multiple (rpd, i, (char *)&rmi_fd, +sizeof (rmi_fd)); +if (retval) { +/* failed to read next PDT entry - end PDT +scan - this may result in an incomplete set +of recognized functions - should probably +return an error but the driver may still be +viable for diagnostics and debugging so let's +let it continue. */ +pr_err + ("%s: Read Error %d when reading next PDT entry - " +"ending PDT scan." , __func__, retval); +break ; + } + +if (rmi_fd.function_number ==0x00 + || rmi_fd.function_number ==0xff ) { +/* A zero or 0xff in the function number +signals the end of the PDT */ +pr_debug ("%s: Found End of PDT." , __func__); +break ; + } + pdt_entry_count++; +if ((rmi_fd.function_number &0xff ) ==0x01 ) { +pr_debug ("%s: F01 Found - RMI Device Control" , + __func__); + +/* This appears to be a valid device, so create a sensor +* device and sensor driver for it. */ + rmi_sensor_dev = +kzalloc (sizeof (*rmi_sensor_dev),GFP_KERNEL ); +if (!rmi_sensor_dev) { +pr_err + ("%s: Error allocating memory for " +"rmi_sensor_device" , + __func__); + retval = -ENOMEM ; + goto exit_fail; + } + rmi_sensor_dev->dev.bus = &rmi_bus_type; + + retval = +rmi_sensor_register_device (rmi_sensor_dev, index++); +if (retval <0 ) { +pr_err + ("%s: Error %d registering sensor device." , + __func__, retval); + goto exit_fail; + } + + rmi_sensor_dev->driver = +rmi_sensor_create_driver (rmi_sensor_dev, rpd, + sensordata); +if (!rmi_sensor_dev->driver) { +pr_err ("%s: Failed to create sensor driver." , + __func__); + goto exit_fail; + } + + retval = +rmi_sensor_register_driver (rmi_sensor_dev->driver); +if (retval <0 ) { +pr_err + ("%s: Error %d registering sensor driver." , + __func__, retval); + goto exit_fail; + } + +/* link the attn fn in the rpd to the sensor attn fn */ + rpd->sensor = rmi_sensor_dev->driver; + rpd->attention = rmi_sensor_dev->driver->attention; + +/* All done with this sensor, fall out of scan loop. */ +break ; + }else { +/* Just print out the function found for now */ +pr_debug ("%s: Found Function %02x - Ignored.\n" , + __func__, rmi_fd.function_number &0xff ); + } + } + +/* If we actually found a sensor, keep it around. */ +if (rmi_sensor_dev) { +pr_debug ("%s: Registered sensor drivers." , __func__); + retval =0 ; + }else { +pr_err ("%s: Failed to find sensor. PDT contained %d entries." , + __func__, pdt_entry_count); + retval = -ENODEV ; + goto exit_fail; + } + +return 0 ; + +exit_fail: +if (rmi_sensor_dev) +rmi_sensor_destroy_driver (rmi_sensor_dev->driver); +kfree (rmi_sensor_dev); +return retval; +} +EXPORT_SYMBOL (rmi_register_sensor); + +int rmi_unregister_sensors (struct rmi_phys_driver *rpd) +{ +if (rpd->sensor) { +pr_warning + ("%s: WARNING: unregister of %s while %s still attached." , + __func__, rpd->name, rpd->sensor->drv.name); + } + +return 0 ; +} +EXPORT_SYMBOL (rmi_unregister_sensors); + +static void rmi_bus_dev_release (struct device *dev) +{ +pr_debug ("rmi bus device release\n" ); +} + +int rmi_register_bus_device (struct device *rmibusdev) +{ +pr_debug ("%s: Registering RMI4 bus device.\n" , __func__); + +/* Here, we simply fill in some of the embedded device structure +* fields (which individual drivers should not need to know about), +* and register the device with the driver core. */ + + rmibusdev->bus = &rmi_bus_type; + rmibusdev->parent = &rmi_bus_device; + rmibusdev->release = rmi_bus_dev_release; +dev_set_name (rmibusdev,"rmi" ); + +/* If we wanted to add bus-specific attributes to the device, +* we could do so here. */ + +return device_register (rmibusdev); +} +EXPORT_SYMBOL (rmi_register_bus_device); + +void rmi_unregister_bus_device (struct device *rmibusdev) +{ +dev_dbg (rmibusdev,"%s: Unregistering bus device." , __func__); + +device_unregister (rmibusdev); +} +EXPORT_SYMBOL (rmi_unregister_bus_device); + +static int __init rmi_bus_init (void ) +{ +int status =0 ; + +pr_info ("%s: RMI Bus Driver Init" , __func__); + +/* Register the rmi bus */ + rmi_bus_type.name = busname; + rmi_bus_type.match = rmi_bus_match; + rmi_bus_type.suspend = rmi_bus_suspend; + rmi_bus_type.resume = rmi_bus_resume; + status =bus_register (&rmi_bus_type); +if (status <0 ) { +pr_err ("%s: Error %d registering the rmi bus." , __func__, + status); + goto err_exit; + } +pr_debug ("%s: successfully registered bus." , __func__); + +return 0 ; +err_exit: +return status; +} + +static void __exit rmi_bus_exit(void) +{ +pr_debug ("%s: RMI Bus Driver Exit." , __func__); + +rmi_unregister_bus_device (&rmi_bus_device); +bus_unregister (&rmi_bus_type); +} + +/* Utility routine to handle writes to read-only attributes. Hopefully +* this will never happen, but if the user does something stupid, we don't +* want to accept it quietly (which is what can happen if you just put NULL +* for the attribute's store function). +*/ +ssize_t rmi_store_error (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +dev_warn (dev, +"RMI4 WARNING: Attempt to write %d characters to read-only " +"attribute %s." , count, attr->attr.name); +return -EPERM ; +} + +/* Utility routine to handle reads of write-only attributes. Hopefully +* this will never happen, but if the user does something stupid, we don't +* want to accept it quietly (which is what can happen if you just put NULL +* for the attribute's show function). +*/ +ssize_t rmi_show_error (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +dev_warn (dev, +"RMI4 WARNING: Attempt to read from write-only attribute %s." , + attr->attr.name); +return -EPERM ; +} + +/* Register a sensor driver on the bus. +*/ +int rmi_bus_register_sensor_driver (struct rmi_sensor_driver *sensor_driver) +{ +int retval =0 ; + + sensor_driver->drv.bus = &rmi_bus_type; + retval =driver_register (&sensor_driver->drv); +return retval; +} +EXPORT_SYMBOL (rmi_bus_register_sensor_driver); + +/* Remove a sensor driver from the bus. +*/ +void rmi_bus_unregister_sensor_driver (struct rmi_sensor_driver *sensor_driver) +{ +driver_unregister (&sensor_driver->drv); +} +EXPORT_SYMBOL (rmi_bus_unregister_sensor_driver); + +module_init (rmi_bus_init); +module_exit (rmi_bus_exit); + +MODULE_AUTHOR ("Synaptics, Inc." ); +MODULE_DESCRIPTION ("RMI4 Driver" ); +MODULE_LICENSE ("GPL" );
drivers/input/touchscreen/rmi_bus.h new file +34 -0
@@ -0,0 +1,34 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) - RMI Bus Module Header. +* Copyright (C) 2007 - 2010, Synaptics Incorporated +* +*/ +/* +* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#if !defined(_RMI_BUS_H) +#define _RMI_BUS_H + +#include "rmi_sensor.h" + +int rmi_bus_register_sensor_driver (struct rmi_sensor_driver *sensor_driver); +void rmi_bus_unregister_sensor_driver (struct rmi_sensor_driver *sensor_driver); + +#endif
drivers/input/touchscreen/rmi.h new file +72 -0
72 lines not on this page · raw message
drivers/input/touchscreen/rmi_platformdata.h new file +135 -0
135 lines not on this page · raw message
drivers/input/touchscreen/rmi_drvr.h new file +97 -0
97 lines not on this page · raw message
PATCH 2/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_i2c.c new file +528 -0
@@ -0,0 +1,528 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) I2C Physical Layer Driver. +* Copyright (c) 2007-2011, Synaptics Incorporated +* +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/module.h> +#include <linux/i2c.h> +#include <linux/platform_device.h> +#include <linux/interrupt.h> +#include <linux/delay.h> +#include <linux/slab.h> +#include "rmi_i2c.h" +#include "rmi_drvr.h" +#include "rmi_platformdata.h" +#include "rmi_sensor.h" + +#define DRIVER_NAME "rmi4_ts" +#define DEVICE_NAME "rmi4_ts" + +static const struct i2c_device_id rmi_i2c_id_table[] = { + {RMI4_I2C_DEVICE_NAME ,0 }, + {}, +}; + +MODULE_DEVICE_TABLE (i2c, rmi_i2c_id_table); + +/* +* This is the data kept on a per instance (client) basis. This data is +* always accessible by using the container_of() macro of the various elements +* inside. +*/ +struct instance_data { +int instance_no; +int irq; +struct rmi_phys_driver rmiphysdrvr; +struct i2c_client *i2cclient;/* pointer to client for later use in +read, write, read_multiple, etc. */ +struct mutex page_mutex; +struct lock_class_key page_key; +int page; +}; + +/* +* RMI devices have 16-bit addressing, but some of the physical +* implementations (like SMBus) only have 8-bit addressing. So RMI implements +* a page address at 0xff of every page so we can reliable page addresses +* every 256 registers. This function sets the page. +* +* The page_mutex lock must be held when this function is entered. +* +* param[in] id - The pointer to the instance_data struct +* param[in] page - The new page address. +* returns zero on success, non-zero on failure. +*/ +/* Writing to page select is giving errors in some configurations. It's +* not needed for basic operation [see note], so we've turned it off for the +* moment. Once we figure out why this happening (is it a bug in our code? or +* in some I2C chips? or maybe in the driver for some chips?) we'll either +* turn this opperation back on, move the choice to platform data, or +* determine whether to use it based on I2C driver capability). +* +* [NOTE: The current driver feature set doesn't require us to access +* addresses outside of the first page, so we're OK for the time being. +* Obviously this must be remedied before implementing the more advanced +* features that are in the pipeline.] +*/ +#if defined(USE_PAGESELECT ) +int rmi_set_page (struct instance_data *instancedata,unsigned int page) +{ +char txbuf[2 ]; +int retval; + txbuf[0 ] =0xff ; + txbuf[1 ] = page; + retval =i2c_master_send (instancedata->i2cclient, + txbuf,ARRAY_SIZE (txbuf)); +if (retval !=ARRAY_SIZE (txbuf)) { +dev_err (&instancedata->i2cclient->dev, +"%s: Set page failed: %d." , __func__, retval); + }else { + retval =0 ; + instancedata->page = page; + } +return retval; +} +#else +int rmi_set_page (struct instance_data *instancedata,unsigned int page) +{ +return 0 ; +} +#endif + +/* +* Same as rmi_i2c_read, except that multiple bytes are allowed to be read. +* +* param[in] pd - The pointer to the rmi_phys_driver struct +* param[in] address - The address at which to start the data read. +* param[out] valp - Pointer to the buffer where the data will be stored. This +* buffer must be at least size bytes long. +* param[in] size - The number of bytes to be read. +* returns zero upon success (with the byte read in valp), non-zero upon error. +* +*/ +static int +rmi_i2c_read_multiple (struct rmi_phys_driver *physdrvr,unsigned short address, +char *valp,int size) +{ +struct instance_data *instancedata = + container_of(physdrvr, struct instance_data, rmiphysdrvr); + +char txbuf[2 ]; +int retval =0 ; +int retry_count =0 ; + +/* Can't have anyone else changing the page behind our backs */ +mutex_lock (&instancedata->page_mutex); + +if (((address >>8 ) &0xff ) != instancedata->page) { +/* Switch pages */ + retval =rmi_set_page (instancedata, ((address >>8 ) &0xff )); +if (retval) + goto exit; + } + +retry: + txbuf[0 ] = address &0xff ; + retval =i2c_master_send (instancedata->i2cclient, txbuf,1 ); + +if (retval !=1 ) { +dev_err (&instancedata->i2cclient->dev,"%s: Write fail: %d\n" , + __func__, retval); + goto exit; + } + retval =i2c_master_recv (instancedata->i2cclient, valp, size); + +if (retval != size) { +if (++retry_count ==5 ) { +dev_err (&instancedata->i2cclient->dev, +"%s: Read of 0x%04x size %d fail: %d\n" , + __func__, address, size, retval); + }else { +mdelay (10 ); +rmi_set_page (instancedata, ((address >>8 ) &0xff )); + goto retry; + } + }else { + retval =0 ; + } +exit: + +mutex_unlock (&instancedata->page_mutex); +return retval; +} + +/* +* Read a single register through i2c. +* +* param[in] pd - The pointer to the rmi_phys_driver struct +* param[in] address - The address at which to start the data read. +* param[out] valp - Pointer to the buffer where the data will be stored. +* returns zero upon success (with the byte read in valp), non-zero upon error. +*/ +static int +rmi_i2c_read (struct rmi_phys_driver *physdrvr,unsigned short address, +char *valp) +{ +return rmi_i2c_read_multiple (physdrvr, address, valp,1 ); +} + +/* +* Write multiple registers. +* +* param[in] pd - The pointer to the rmi_phys_driver struct +* param[in] address - The address at which to start the write. +* param[in] valp - A pointer to a buffer containing the data to be written. +* param[in] size - The number of bytes to write. +* returns one upon success, something else upon error. +*/ +static int +rmi_i2c_write_multiple (struct rmi_phys_driver *physdrvr,unsigned short address, +char *valp,int size) +{ +struct instance_data *instancedata = + container_of(physdrvr, struct instance_data, rmiphysdrvr); + +unsigned char txbuf[size+1 ]; +int retval =0 ; + +memcpy (txbuf+1 , valp, size); + +/* Can't have anyone else changing the page behind our backs */ +mutex_lock (&instancedata->page_mutex); + +if (((address >>8 ) &0xff ) != instancedata->page) { +/* Switch pages */ + retval =rmi_set_page (instancedata, ((address >>8 ) &0xff )); +if (retval) + goto exit; + } + + txbuf[0 ] = address &0xff ;/* put the address in the first byte */ + retval =i2c_master_send (instancedata->i2cclient, + txbuf,ARRAY_SIZE (txbuf)); + +/* TODO: Add in retry on writes only in certain error return values */ +if (retval !=ARRAY_SIZE (txbuf)) { +dev_err (&instancedata->i2cclient->dev,"%s: Write fail: %d\n" , + __func__, retval); + goto exit; + } +exit: + +mutex_unlock (&instancedata->page_mutex); +return retval; +} + +/* +* Write a single register through i2c. +* +* param[in] pd - The pointer to the rmi_phys_driver structnew file (copy) +* param[in] address - The address at which to start the write. +* param[in] data - The data to be written. +* returns one upon success, something else upon error. +*/ +static int +rmi_i2c_write (struct rmi_phys_driver *physdrvr,unsigned short address, +char data) +{ +return rmi_i2c_write_multiple (physdrvr, address, &data,1 ); +} + +/* +* This is the Interrupt Service Routine. It just notifies the application +* layer that attention is required. +*/ +static irqreturn_t i2c_attn_isr (int irq,void *info) +{ +struct instance_data *instancedata = info; + +disable_irq_nosync (instancedata->irq); + +if (instancedata->rmiphysdrvr.attention) { + instancedata->rmiphysdrvr.attention (&instancedata->rmiphysdrvr, + instancedata->instance_no); + } + +return IRQ_HANDLED ; +} + +/* The Driver probe function - will allocate and initialize the instance +* data and request the irq and set the instance data as the clients +* platform data then register the physical driver which will do a scan of +* the RMI4 Physical Device Table and enumerate any RMI4 functions that +* have data sources associated with them. +*/ +static int +rmi_i2c_probe (struct i2c_client *client,const struct i2c_device_id *dev_id) +{ +struct instance_data *instancedata; +int retval =0 ; +struct rmi_i2c_platformdata *platformdata; +struct rmi_sensordata *sensordata; + +if (client ==NULL ) { +pr_err ("%s: Invalid NULL client received." , __func__); +return -EINVAL ; + } + + platformdata = client->dev.platform_data; +if (platformdata ==NULL ) { +dev_err (&client->dev,"%s: CONFIGURATION ERROR - " +"platform data is NULL.\n" , __func__); + retval = -EINVAL ; + } + sensordata = platformdata->sensordata; + +dev_dbg (&client->dev,"%s: Probing i2c RMI device, addr: 0x%02x" , + __func__, client->addr); + +/* Allocate and initialize the instance data for this client */ + instancedata =kzalloc (sizeof (*instancedata),GFP_KERNEL ); +if (!instancedata) { +dev_err (&client->dev, +"%s: Failed to allocate instance_data.\n" , + __func__); +return -ENOMEM ; + } + +__mutex_init (&instancedata->page_mutex,"page_mutex" , + &instancedata->page_key); + instancedata->rmiphysdrvr.name =RMI4_I2C_DRIVER_NAME ; + instancedata->rmiphysdrvr.write = rmi_i2c_write; + instancedata->rmiphysdrvr.read = rmi_i2c_read; + instancedata->rmiphysdrvr.write_multiple = rmi_i2c_write_multiple; + instancedata->rmiphysdrvr.read_multiple = rmi_i2c_read_multiple; + instancedata->rmiphysdrvr.module =THIS_MODULE ; + +/* Set default to polling in case no matching platform data is located +for this device. We'll still work but in polling mode since we didn't +find any irq info */ + instancedata->rmiphysdrvr.polling_required = true; + + instancedata->page =0xffff ;/* Force a set page the first time */ + +/* Egregiously horrible delay here that seems to prevent I2C disasters +* on certain broken dev systems. In most cases, you can safely +* leave this as zero. +*/ +if (platformdata->delay_ms >0 ) +mdelay (platformdata->delay_ms); + +dev_dbg (&client->dev,"%s: sensor addr: 0x%02x irq: 0x%x type: %d\n" , + __func__, platformdata->i2c_address, platformdata->irq, + platformdata->irq_type); +if (client->addr != platformdata->i2c_address) { +dev_err (&client->dev, +"%s: CONFIGURATION ERROR - client I2C address 0x%02x " +"doesn't match platform data address 0x%02x.\n" , + __func__, client->addr, platformdata->i2c_address); + retval = -EINVAL ; + goto error_exit; + } + + instancedata->instance_no =rmi_next_sensor_id (); + +/* set the device name using the instance_no appended to DEVICE_NAME +* to make a unique name */ +dev_set_name (&client->dev,"%s%d" ,RMI4_I2C_DEVICE_NAME , + instancedata->instance_no); + +/* Determine if we need to poll (inefficient) or use interrupts. +*/ +if (platformdata->irq) { + instancedata->irq = platformdata->irq; +switch (platformdata->irq_type) { +case IRQF_TRIGGER_NONE : +dev_warn (&client->dev,"%s: Touchscreen ATTN IRQ was " +"specified as IRQF_TRIGGER_NONE. IRQ trigger " +"configuration will be defaulted." , __func__); +break ; +case IRQF_TRIGGER_RISING : +case IRQF_TRIGGER_FALLING : +case IRQF_TRIGGER_HIGH : +case IRQF_TRIGGER_LOW : +break ; +default : +dev_warn (&client->dev, +"%s: Invalid IRQ flags in platform data.\n" , + __func__); + retval = -ENXIO ; + goto error_exit; + } + + instancedata->rmiphysdrvr.polling_required = false; + instancedata->rmiphysdrvr.irq = instancedata->irq; + + }else { + instancedata->rmiphysdrvr.polling_required = true; +dev_info (&client->dev, +"%s: No IRQ info given. Polling required.\n" , + __func__); + } + +/* Store the instance data in the i2c_client - we need to do this prior +* to calling register_physical_driver since it may use the read, write +* functions. If nothing was found then the id fields will be set to 0 +* for the irq and the default will be set to polling required so we +* will still work but in polling mode. */ +i2c_set_clientdata (client, instancedata); + +/* Copy i2c_client pointer into instance_data's i2c_client pointer for +later use in rmi4_read, rmi4_write, etc. */ + instancedata->i2cclient = client; + +/* Call the platform setup routine, to do any setup that is required +* before interacting with the device. When we refined the bus +* architecture, this will be done elsewhere. +*/ +if (sensordata && sensordata->rmi_sensor_setup) { + retval = sensordata->rmi_sensor_setup (); +if (retval) { +dev_err (&client->dev, +"%s: sensor setup failed with code %d." , + __func__, retval); + goto error_exit; + } + } + +/* Register sensor drivers - this will call the detect function that +* will then scan the device and determine the supported RMI4 sensors +* and functions. +*/ + retval = +rmi_register_sensor (&instancedata->rmiphysdrvr, + platformdata->sensordata); +if (retval) { +dev_err (&client->dev, +"%s: Failed to Register %s sensor drivers\n" , __func__, + instancedata->rmiphysdrvr.name); + goto error_exit; + } + +if (instancedata->rmiphysdrvr.polling_required == false) { + retval =request_irq (instancedata->irq, i2c_attn_isr, + platformdata->irq_type,"rmi_i2c" , + instancedata); +if (retval) { +dev_err (&client->dev, +"%s: failed to obtain IRQ %d. Result: %d." , + __func__, instancedata->irq, retval); +dev_info (&client->dev,"%s: Reverting to polling.\n" , + __func__); + instancedata->rmiphysdrvr.polling_required = true; +/* TODO: Need to revert back to polling - create and +* start timer. */ + }else { +dev_dbg (&client->dev,"%s: got irq.\n" , __func__); + } + } + +dev_dbg (&client->dev,"%s: Successfully registered %s sensor driver.\n" , + __func__, instancedata->rmiphysdrvr.name); + +pr_info ("%s: Successfully registered %s sensor driver.\n" , __func__, + instancedata->rmiphysdrvr.name); + +return retval; + +error_exit: +kfree (instancedata); +/* return error for clean-up*/ +return retval; +} + +static int rmi_i2c_remove (struct i2c_client *client) +{ +struct instance_data *instancedata =i2c_get_clientdata (client); + +dev_dbg (&client->dev,"%s: Unregistering phys driver %s\n" , __func__, + instancedata->rmiphysdrvr.name); + +rmi_unregister_sensors (&instancedata->rmiphysdrvr); + +dev_dbg (&client->dev,"%s: Unregistered phys driver %s\n" , + __func__, instancedata->rmiphysdrvr.name); + +/* only free irq if we have an irq - otherwise the instance_data +will be 0 for that field */ +if (instancedata->irq) +free_irq (instancedata->irq, instancedata); + +kfree (instancedata); +dev_dbg (&client->dev,"%s: Remove successful\n" , __func__); + +return 0 ; +} + +#ifdef CONFIG_PM +static int rmi_i2c_suspend (struct i2c_client *client,pm_message_t mesg) +{ +/* Touch sleep mode */ +return 0 ; +} + +static int rmi_i2c_resume (struct i2c_client *client) +{ +/* Re-initialize upon resume */ +return 0 ; +} +#else +#define rmi_i2c_suspend NULL +#define rmi_i2c_resume NULL +#endif + +/* +* This structure tells the i2c subsystem about us. +* +* TODO: we should add .suspend and .resume fns. +* +*/ +static struct i2c_driver rmi_i2c_driver = { + .probe = rmi_i2c_probe, + .remove = rmi_i2c_remove, + .suspend = rmi_i2c_suspend, + .resume = rmi_i2c_resume, + .driver = { + .name =RMI4_I2C_DRIVER_NAME , + .owner =THIS_MODULE , + }, + .id_table = rmi_i2c_id_table, +}; + +static int __init rmi_phys_i2c_init (void ) +{ +return i2c_add_driver (&rmi_i2c_driver); +} + +static void __exit rmi_phys_i2c_exit(void) +{ +i2c_del_driver (&rmi_i2c_driver); +} + +module_init (rmi_phys_i2c_init); +module_exit (rmi_phys_i2c_exit); + +MODULE_AUTHOR ("Synaptics, Inc." ); +MODULE_DESCRIPTION ("RMI4 Driver I2C Physical Layer" ); +MODULE_LICENSE ("GPL" );
drivers/input/touchscreen/rmi_i2c.h new file +67 -0
67 lines not on this page · raw message
drivers/input/touchscreen/rmi_spi.c new file +711 -0
711 lines not on this page · raw message
drivers/input/touchscreen/rmi_spi.h new file +114 -0
114 lines not on this page · raw message
PATCH 3/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_function.c new file +289 -0
@@ -0,0 +1,289 @@ +/** +* Synaptics Register Mapped Interface (RMI4) - RMI Function Module. +* Copyright (C) 2007 - 2011, Synaptics Incorporated +* +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/hrtimer.h> +#include <linux/miscdevice.h> +#include <linux/fs.h> +#include <linux/delay.h> +#include <linux/uaccess.h> +#include <linux/slab.h> +#include <linux/kthread.h> +#include <linux/freezer.h> +#include <linux/input.h> +#include <linux/interrupt.h> + +#include "rmi_drvr.h" +#include "rmi_function.h" +#include "rmi_bus.h" +#include "rmi_sensor.h" +#include "rmi_f01.h" +#include "rmi_f05.h" +#include "rmi_f11.h" +#include "rmi_f19.h" +#include "rmi_f34.h" + + +#define FUNCTION_NAME_SIZE 10 + +static int rmi_function_suspendable (struct rmi_function_info *rmifninfo); + + +/* NOTE: Developer - add in any new RMI4 fn data info - function number +* and ptrs to report, config, init and detect functions. This data is +* used to point to the functions that need to be called to config, init, +* detect and report data for the new RMI4 function. Refer to the RMI4 +* specification for information on RMI4 functions. +*/ +/* TODO: This will eventually be built dynamically, as individual function +* implementations registered. For now, though we create it statically. */ +static struct rmi_function_ops supported_functions[] = { +/* Fn $01 - device control */ + { + .function_number =RMI_F01_INDEX , + .inthandler = FN_01_inthandler, + .config = FN_01_config, + .init = FN_01_init, + .detect = FN_01_detect, + .attention = FN_01_attention, + .suspend = FN_01_suspend, + .resume = FN_01_resume, + .suspendable = rmi_function_suspendable}, +/* Fn $05 - analog report */ + { + .function_number =RMI_F05_INDEX , + .inthandler = FN_05_inthandler, + .config = FN_05_config, + .init = FN_05_init, + .detect = FN_05_detect, + .attention =NULL , + .suspend =NULL , + .resume =NULL , + .suspendable = rmi_function_suspendable}, +/* Fn $11 - 2D sensing */ + { + .function_number =RMI_F11_INDEX , + .inthandler = FN_11_inthandler, + .config = FN_11_config, + .init = FN_11_init, + .detect = FN_11_detect, + .attention =NULL , + .suspend =NULL , + .resume =NULL , + .suspendable = rmi_function_suspendable}, +/* Fn $19 - buttons */ + { + .function_number =RMI_F19_INDEX , + .inthandler = FN_19_inthandler, + .config = FN_19_config, + .init = FN_19_init, + .detect = FN_19_detect, + .attention =NULL , + .suspend =NULL , + .resume =NULL , + .suspendable = rmi_function_suspendable}, +/* Fn $34 - firmware reflash */ + { + .function_number =RMI_F34_INDEX , + .inthandler = FN_34_inthandler, + .config = FN_34_config, + .init = FN_34_init, + .detect = FN_34_detect, + .attention = FN_34_attention, + .suspend =NULL , + .resume =NULL , + .suspendable = rmi_function_suspendable}, +}; + +/* This function is here to provide a way for external modules to access the +* functions list. It will try to find a matching function base on the passed +* in RMI4 function number and return the pointer to the struct rmi_functions +* if a match is found or NULL if not found. +*/ +struct rmi_function_ops *rmi_find_function (int function_number) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (supported_functions); i++) { +if (function_number == supported_functions[i].function_number) +return &supported_functions[i]; + } + +return NULL ; +} +EXPORT_SYMBOL (rmi_find_function); + +static int rmi_function_suspendable (struct rmi_function_info *rmifninfo) +{ +return 1 ; +} + +static void rmi_function_config (struct rmi_function_device *function) +{ +pr_debug ("%s: rmi_function_config" , __func__); +} + +/* Just a stub for now. +*/ +static int rmi_function_suspend (struct device *dev,pm_message_t state) +{ +pr_info ("%s: function suspend called." , __func__); +return 0 ; +} + +/* Just a stub for now. +*/ +static int rmi_function_resume (struct device *dev) +{ +pr_info ("%s: function resume called." , __func__); +return 0 ; +} + +int rmi_function_register_driver (struct rmi_function_driver *drv, +int function_number) +{ +int retval =0 ; +char *driver_name; + +pr_info ("%s: Registering function driver for F%02x.\n" , __func__, + function_number); + + +/* Create a function device and function driver for this Fn */ + driver_name =kzalloc (FUNCTION_NAME_SIZE ,GFP_KERNEL ); +if (!driver_name) { +pr_err ("%s: Error allocating memory for " +"rmi_function_driver name." , __func__); +return -ENOMEM ; + } +snprintf (driver_name,FUNCTION_NAME_SIZE ,"fn%02x" , function_number); + + drv->drv.name = driver_name; + drv->module = drv->drv.owner; + + drv->drv.suspend = rmi_function_suspend; + drv->drv.resume = rmi_function_resume; + +/* register the sensor driver */ + retval =driver_register (&drv->drv); +if (retval) { +pr_err ("%s: Failed driver_register %d\n" , __func__, retval); + drv->drv.name =NULL ; +kfree (driver_name); + } + +return retval; +} +EXPORT_SYMBOL (rmi_function_register_driver); + +void rmi_function_unregister_driver (struct rmi_function_driver *drv) +{ +char *driver_name = (char *) drv->drv.name; + +pr_info ("%s: Unregistering function driver.\n" , __func__); + +/* TODO: Unregister the devices first. */ +driver_unregister (&drv->drv); +kfree (driver_name); +} +EXPORT_SYMBOL (rmi_function_unregister_driver); + +int rmi_function_register_device (struct rmi_function_device *function_device, +int fnNumber) +{ +struct input_dev *input; +int retval =0 ; + +pr_info ("%s: Registering function device for F%02x.\n" , __func__, + fnNumber); + +/* make name - fn11, fn19, etc. */ +dev_set_name (&function_device->dev,"%sfn%02x" , + function_device->sensor->drv.name, fnNumber); +dev_set_drvdata (&function_device->dev, function_device); + retval =device_register (&function_device->dev); +if (retval) { +pr_err ("%s: Failed device_register for function device.\n" , + __func__); +return retval; + } + + input =input_allocate_device (); +if (input ==NULL ) { +pr_err ("%s: Failed to allocate memory for a " +"new input device.\n" , __func__); + retval = -ENOMEM ; + goto error_exit; + } + + input->name =dev_name (&function_device->dev); + input->phys ="rmi_function" ; + function_device->input = input; + +/* init any input specific params for this function */ + function_device->rmi_funcs->init (function_device); + + retval =input_register_device (input); +if (retval) { +pr_err ("%s: Failed input_register_device.\n" , __func__); + goto error_exit; + } + +rmi_function_config (function_device); + +return retval; + +error_exit: +kfree (input); +return retval; +} +EXPORT_SYMBOL (rmi_function_register_device); + +void rmi_function_unregister_device (struct rmi_function_device *dev) +{ +pr_info ("%s: Unregistering function device.n" , __func__); + +input_unregister_device (dev->input); +device_unregister (&dev->dev); +} +EXPORT_SYMBOL (rmi_function_unregister_device); + +static int __init rmi_function_init (void ) +{ +pr_debug ("%s: RMI Function Init\n" , __func__); + +return 0 ; +} + +static void __exit rmi_function_exit(void) +{ +pr_debug ("%s: RMI Function Exit\n" , __func__); +} + +module_init (rmi_function_init); +module_exit (rmi_function_exit); + +MODULE_AUTHOR ("Synaptics, Inc." ); +MODULE_DESCRIPTION ("RMI4 Function Driver" ); +MODULE_LICENSE ("GPL" );
drivers/input/touchscreen/rmi_function.h new file +175 -0
175 lines not on this page · raw message
drivers/input/touchscreen/rmi_sensor.c new file +1059 -0
1,059 lines not on this page · raw message
drivers/input/touchscreen/rmi_sensor.h new file +128 -0
128 lines not on this page · raw message
PATCH 4/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/Makefile +2 -0
@@ -41,6 +41,8 @@ obj-$(CONFIG_TOUCHSCREEN_QT602240) += qt602240_ts.o obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o +obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) += rmi_bus.o rmi_sensor.o rmi_function.o rmi_f01.o rmi_f05.o rmi_f11.o rmi_f19.o rmi_f34.o rmi_i2c.o +obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_SPI) += rmi_bus.o rmi_sensor.o rmi_function.o rmi_f01.o rmi_f05.o rmi_f11.o rmi_f19.o rmi_f34.o rmi_spi.o obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
drivers/input/touchscreen/Kconfig +30 -0
@@ -362,6 +362,36 @@ config TOUCHSCREEN_MIGOR To compile this driver as a module, choose M here: the module will be called migor_ts. +config TOUCHSCREEN_SYNAPTICS_RMI4_I2C + tristate "Synaptics RMI4 I2C touchscreens" + depends on I2C + help + Say Y here if you have a Synaptics RMI4 I2C touchscreen connected to + your system. This enables support for Synaptics RMI4 over I2C based + touchscreens. + + If unsure, say N. + + To compile this driver as a set of modules, choose M here: the + modules will be called rmi_core, rmi_app_touchpad, rmi_phys_i2c. + +config TOUCHSCREEN_SYNAPTICS_RMI4_SPI + tristate "Synaptics RMI4 SPI touchscreens" + depends on SPI + help + Say Y here if you have a Synaptics RMI4 SPI touchscreen connected to + your system. This enables support for Synaptics RMI4 over SPI based + touchscreens. + + If unsure, say N. + + To compile this driver as a set of modules, choose M here: the + modules will be called rmi_core, rmi_app_touchpad, rmi_phys_spi. + +config SYNA_MULTI_TOUCH + bool "Synaptics pointing using multi-touch events" + depends on TOUCHSCREEN_SYNAPTICS_RMI4_I2C || TOUCHSCREEN_SYNAPTICS_RMI4_SPI + config TOUCHSCREEN_TNETV107X tristate "TI TNETV107X touchscreen support" depends on ARCH_DAVINCI_TNETV107X
Documentation/input/synaptics-rmi4.txt new file +172 -0
172 lines not on this page · raw message
PATCH 5/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_f01.h new file +121 -0
@@ -0,0 +1,121 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) Function $01 header. +* Copyright (c) 2007 - 2011, Synaptics Incorporated +* +* There is only one function $01 for each RMI4 sensor. This will be +* the function that is used to set sensor control and configurations +* and check the interrupts to find the source function that is interrupting. +* +* +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#if !defined(_RMI_F01_H) +#define _RMI_F01_H + +/* This encapsulates the information found using the RMI4 Function $01 +* query registers. There is only one Function $01 per device. +* +* Assuming appropriate endian-ness, you can populate most of this +* structure by reading query registers starting at the query base address +* that was obtained from RMI4 function 0x01 function descriptor info read +* from the Page Descriptor Table. +* +* Specific register information is provided in the comments for each field. +* For further reference, please see the "Synaptics RMI 4 Interfacing +* Guide" document : go to http://www.synaptics.com/developers/manuals - and +* select "Synaptics RMI 4 Interfacting Guide". +*/ +#define F01_PRODUCT_INFO_LENGTH 2 +#define F01_DATE_CODE_LENGTH 3 +#define F01_PRODUCT_ID_LENGTH 10 +struct rmi_F01_query { +/* The manufacturer identification byte. */ +unsigned char mfgid; + +/* The Product Properties information. */ +unsigned char properties; + +/* The product info bytes. */ +unsigned char prod_info[F01_PRODUCT_INFO_LENGTH ]; + +/* Date Code - Year, Month, Day. */ +unsigned char date_code[F01_DATE_CODE_LENGTH ]; + +/* Tester ID (14 bits). */ +unsigned short tester_id; + +/* Serial Number (14 bits). */ +unsigned short serial_num; + +/* A null-terminated string that identifies this particular product. */ +char prod_id[F01_PRODUCT_ID_LENGTH ]; +}; + +/* This encapsulates the F01 Device Control control registers. +* TODO: This isn't right. The number of interrupt enables needs to be +* determined dynamically as the sensor is initialized. Fix this. +*/ +struct rmi_F01_control { +unsigned char device_control; +unsigned char interrupt_enable[1 ]; +}; + + +/* This encapsulates the F01 Device Control data registers. +* TODO: This isn't right. The number of irqs needs to be determined +* dynamically as the sensor is initialized. Fix this. +*/ +struct rmi_F01_data { +unsigned char device_status; +unsigned char irqs[1 ]; +}; + + +void FN_01_inthandler (struct rmi_function_info *rmifninfo, +unsigned int asserted_IRQs); +int FN_01_config (struct rmi_function_info *rmifninfo); +int FN_01_init (struct rmi_function_device *function_device); +int FN_01_detect (struct rmi_function_info *rmifninfo); +void FN_01_attention (struct rmi_function_info *rmifninfo); +int FN_01_suspend (struct rmi_function_info *rmifninfo); +void FN_01_resume (struct rmi_function_info *rmifninfo); + +#define RMI_F01_SLEEP_MODE_MASK 0x03 +/* Position of bits in control register. */ +#define RMI_F01_SLEEP_MODE_OFFSET 0 + +#define RMI_SLEEP_MODE_NORMAL (0x00) +#define RMI_SLEEP_MODE_SENSOR_SLEEP (0x01) +#define RMI_SLEEP_MODE_RESERVED0 (0x02) +#define RMI_SLEEP_MODE_RESERVED1 (0x03) + +#define RMI_IS_VALID_SLEEPMODE (mode) \ + (mode < RMI_SLEEP_MODE_NORMAL || mode > RMI_SLEEP_MODE_RESERVED1) + +/* This bit is used to disable current sleep mode. */ +#define RMI_F01_NO_SLEEP_MASK 0x04 +/* Position of bits in control register. */ +#define RMI_F01_NO_SLEEP_OFFSET 2 + +#define RMI_NO_SLEEP_ENABLE (0x01) +#define RMI_NO_SLEEP_DISABLE (0x00) + +#endif
drivers/input/touchscreen/rmi_f01.c new file +825 -0
825 lines not on this page · raw message
PATCH 6/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_f05.h new file +42 -0
@@ -0,0 +1,42 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) Function $11 header. +* Copyright (c) 2007 - 2010, Synaptics Incorporated +* +* For every RMI4 function that has a data source - like 2D sensors, +* buttons, LEDs, GPIOs, etc. - the user will create a new rmi_function_xx.c +* file and add these functions to perform the config(), init(), report() +* and detect() functionality. The function pointers are then srored under +* the RMI function info and these functions will automatically be called by +* the global config(), init(), report() and detect() functions that will +* loop through all data sources and call the data sources functions using +* these functions pointed to by the function ptrs. +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#if !defined(_RMI_F05_H) +#define _RMI_F05_H + +void FN_05_inthandler (struct rmi_function_info *rmifninfo, +unsigned int asserted_IRQs); +int FN_05_config (struct rmi_function_info *rmifninfo); +int FN_05_init (struct rmi_function_device *function_device); +int FN_05_detect (struct rmi_function_info *rmifninfo); +/* No attention function for F05 */ +#endif
drivers/input/touchscreen/rmi_f05.c new file +123 -0
123 lines not on this page · raw message
PATCH 7/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_f11.h new file +80 -0
@@ -0,0 +1,80 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) Function $11 header. +* Copyright (c) 2007 - 2010, Synaptics Incorporated +* +* For every RMI4 function that has a data source - like 2D sensors, +* buttons, LEDs, GPIOs, etc. - the user will create a new rmi_function_xx.c +* file and add these functions to perform the config(), init(), report() +* and detect() functionality. The function pointers are then srored under +* the RMI function info and these functions will automatically be called by +* the global config(), init(), report() and detect() functions that will +* loop through all data sources and call the data sources functions using +* these functions pointed to by the function ptrs. +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#if !defined(_RMI_F11_H) +#define _RMI_F11_H + +/* This is the data read from the F11 query registers. +*/ +struct rmi_F11_device_query { +bool has_query_9; +unsigned char number_of_sensors; +}; + +struct rmi_F11_sensor_query { +bool configurable; +bool has_sensitivity_adjust; +bool has_gestures; +bool has_absolute; +bool has_relative; +unsigned char number_of_fingers; +unsigned char number_of_X_electrodes; +unsigned char number_of_Y_electrodes; +unsigned char maximum_electrodes; +bool has_anchored_finger; +unsigned char abs_data_size; +}; + +struct rmi_F11_control { +bool relative_ballistics; +bool relative_position_filter; +bool absolute_position_filter; +unsigned char reporting_mode; +bool manually_tracked_finger; +bool manually_tracked_finger_enable; +unsigned char motion_sensitivity; +unsigned char palm_detect_threshold; +unsigned char delta_X_pos_threshold; +unsigned char delta_Y_pos_threshold; +unsigned char velocity; +unsigned char acceleration; +unsigned short sensor_max_X_pos; +unsigned short sensor_max_Y_pos; +}; + +void FN_11_inthandler (struct rmi_function_info *rmifninfo, +unsigned int asserted_IRQs); +int FN_11_config (struct rmi_function_info *rmifninfo); +int FN_11_init (struct rmi_function_device *function_device); +int FN_11_detect (struct rmi_function_info *rmifninfo); +/* No attention function for Fn $11 */ +#endif
drivers/input/touchscreen/rmi_f11.c new file +962 -0
962 lines not on this page · raw message
PATCH 8/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_f19.h new file +63 -0
@@ -0,0 +1,63 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) Function $11 header. +* Copyright (c) 2007 - 2010, Synaptics Incorporated +* +* For every RMI4 function that has a data source - like 2D sensors, +* buttons, LEDs, GPIOs, etc. - the user will create a new rmi_function_xx.c +* file and add these functions to perform the config(), init(), report() +* and detect() functionality. The function pointers are then srored under +* the RMI function info and these functions will automatically be called by +* the global config(), init(), report() and detect() functions that will +* loop through all data sources and call the data sources functions using +* these functions pointed to by the function ptrs. +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#if !defined(_RMI_F19_H) +#define _RMI_F19_H + +/* This is the data read from the F19 query registers. +*/ +struct rmi_F19_query { +bool has_hysteresis_threshold; +bool has_sensitivity_adjust; +bool configurable; +unsigned char button_count; +}; + +struct rmi_F19_control { +unsigned char button_usage; +unsigned char filter_mode; +unsigned char *interrupt_enable_registers; +unsigned char *single_button_control; +unsigned char *sensor_map; +unsigned char *single_button_sensitivity; +unsigned char global_sensitivity_adjustment; +unsigned char global_hysteresis_threshold; +}; + + +void FN_19_inthandler (struct rmi_function_info *rmifninfo, +unsigned int asserted_IRQs); +int FN_19_config (struct rmi_function_info *rmifninfo); +int FN_19_init (struct rmi_function_device *function_device); +int FN_19_detect (struct rmi_function_info *rmifninfo); +/* No attention function for Fn $19 */ +#endif
drivers/input/touchscreen/rmi_f19.c new file +629 -0
629 lines not on this page · raw message
PATCH 9/9 input/touchscreen: Synaptics RMI4 Touchscreen Driver
In reply to Christopher HeinyDriver for Synaptics touchscreens using RMI4 protocol.
Please see the email 0/9 for a description of this patch.
---
drivers/input/touchscreen/rmi_f34.h new file +48 -0
@@ -0,0 +1,48 @@ +/** +* +* Synaptics Register Mapped Interface (RMI4) Function $34 header. +* Copyright (c) 2007 - 2011, Synaptics Incorporated +* +* There is only one function $34 for each RMI4 sensor. This will be +* the function that is used to reflash the firmware and get the +* boot loader address and the boot image block size. +* +* +*/ +/* +* This file is licensed under the GPL2 license. +* +*############################################################################# +* GPL +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +*############################################################################# +*/ + +#if !defined(_RMI_F34_H) +#define _RMI_F34_H + +/* define fn $34 commands */ +#define WRITE_FW_BLOCK 2 +#define ERASE_ALL 3 +#define READ_CONFIG_BLOCK 5 +#define WRITE_CONFIG_BLOCK 6 +#define ERASE_CONFIG 7 +#define ENABLE_FLASH_PROG 15 + +void FN_34_inthandler (struct rmi_function_info *rmifninfo, +unsigned int asserted_IRQs); +int FN_34_config (struct rmi_function_info *rmifninfo); +int FN_34_init (struct rmi_function_device *function_device); +int FN_34_detect (struct rmi_function_info *rmifninfo); +void FN_34_attention (struct rmi_function_info *rmifninfo); + +#endif
drivers/input/touchscreen/rmi_f34.c new file +556 -0
556 lines not on this page · raw message