Commit 39fada55 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull more input updates from Dmitry Torokhov:
 "Two new drivers for touchscreen controllers:

   - Silead touchscreen controllers
   - SiS 9200 family touchscreen controllers

  and a few driver fixes"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: silead - remove some dead code
  Input: sis-i2c - select CONFIG_CRC_ITU_T
  Input: add driver for SiS 9200 family I2C touchscreen controllers
  Input: ili210x - fix permissions on "calibrate" attribute
  Input: elan_i2c - properly wake up touchpad on ASUS laptops
  Input: add driver for Silead touchscreens
  Input: elantech - fix debug dump of the current packet
  Input: rotary_encoder - support binary encoding of states
  Input: xpad - power off wireless 360 controllers on suspend
  Input: i8042 - break load dependency between atkbd/psmouse and i8042
  Input: synaptics-rmi4 - do not check for NULL when calling of_node_put()
  Input: cros_ec_keyb - cleanup use of dev
parents f72035fa 22fe874f
......@@ -20,6 +20,8 @@ Optional properties:
2: Half-period mode
4: Quarter-period mode
- wakeup-source: Boolean, rotary encoder can wake up the system.
- rotary-encoder,encoding: String, the method used to encode steps.
Supported are "gray" (the default and more common) and "binary".
Deprecated properties:
- rotary-encoder,half-period: Makes the driver work on half-period mode.
......@@ -34,6 +36,7 @@ Example:
compatible = "rotary-encoder";
gpios = <&gpio 19 1>, <&gpio 20 0>; /* GPIO19 is inverted */
linux,axis = <0>; /* REL_X */
rotary-encoder,encoding = "gray";
rotary-encoder,relative-axis;
};
......@@ -42,5 +45,6 @@ Example:
gpios = <&gpio 21 0>, <&gpio 22 0>;
linux,axis = <1>; /* ABS_Y */
rotary-encoder,steps = <24>;
rotary-encoder,encoding = "binary";
rotary-encoder,rollover;
};
* GSL 1680 touchscreen controller
Required properties:
- compatible : "silead,gsl1680"
- reg : I2C slave address of the chip (0x40)
- interrupt-parent : a phandle pointing to the interrupt controller
serving the interrupt for this chip
- interrupts : interrupt specification for the gsl1680 interrupt
- power-gpios : Specification for the pin connected to the gsl1680's
shutdown input. This needs to be driven high to take the
gsl1680 out of its low power state
- touchscreen-size-x : See touchscreen.txt
- touchscreen-size-y : See touchscreen.txt
Optional properties:
- touchscreen-inverted-x : See touchscreen.txt
- touchscreen-inverted-y : See touchscreen.txt
- touchscreen-swapped-x-y : See touchscreen.txt
- silead,max-fingers : maximum number of fingers the touchscreen can detect
Example:
i2c@00000000 {
gsl1680: touchscreen@40 {
compatible = "silead,gsl1680";
reg = <0x40>;
interrupt-parent = <&pio>;
interrupts = <6 11 IRQ_TYPE_EDGE_FALLING>;
power-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>;
touchscreen-size-x = <480>;
touchscreen-size-y = <800>;
touchscreen-inverted-x;
touchscreen-swapped-x-y;
silead,max-fingers = <5>;
};
};
* SiS I2C Multiple Touch Controller
Required properties:
- compatible: must be "sis,9200-ts"
- reg: i2c slave address
- interrupt-parent: the phandle for the interrupt controller
(see interrupt binding [0])
- interrupts: touch controller interrupt (see interrupt
binding [0])
Optional properties:
- pinctrl-names: should be "default" (see pinctrl binding [1]).
- pinctrl-0: a phandle pointing to the pin settings for the
device (see pinctrl binding [1]).
- attn-gpios: the gpio pin used as attention line
- reset-gpios: the gpio pin used to reset the controller
- wakeup-source: touchscreen can be used as a wakeup source
[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
[1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
Example:
sis9255@5c {
compatible = "sis,9200-ts";
reg = <0x5c>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sis>;
interrupt-parent = <&gpio3>;
interrupts = <19 IRQ_TYPE_EDGE_FALLING>;
irq-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
reset-gpios = <&gpio2 30 GPIO_ACTIVE_LOW>;
};
......@@ -238,6 +238,7 @@ simtek
sii Seiko Instruments, Inc.
silergy Silergy Corp.
sirf SiRF Technology, Inc.
sis Silicon Integrated Systems Corp.
sitronix Sitronix Technology Corporation
skyworks Skyworks Solutions, Inc.
smsc Standard Microsystems Corporation
......
......@@ -115,6 +115,10 @@ static bool sticks_to_null;
module_param(sticks_to_null, bool, S_IRUGO);
MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads");
static bool auto_poweroff = true;
module_param(auto_poweroff, bool, S_IWUSR | S_IRUGO);
MODULE_PARM_DESC(auto_poweroff, "Power off wireless controllers on suspend");
static const struct xpad_device {
u16 idVendor;
u16 idProduct;
......@@ -1248,6 +1252,36 @@ static void xpad_stop_input(struct usb_xpad *xpad)
usb_kill_urb(xpad->irq_in);
}
static void xpad360w_poweroff_controller(struct usb_xpad *xpad)
{
unsigned long flags;
struct xpad_output_packet *packet =
&xpad->out_packets[XPAD_OUT_CMD_IDX];
spin_lock_irqsave(&xpad->odata_lock, flags);
packet->data[0] = 0x00;
packet->data[1] = 0x00;
packet->data[2] = 0x08;
packet->data[3] = 0xC0;
packet->data[4] = 0x00;
packet->data[5] = 0x00;
packet->data[6] = 0x00;
packet->data[7] = 0x00;
packet->data[8] = 0x00;
packet->data[9] = 0x00;
packet->data[10] = 0x00;
packet->data[11] = 0x00;
packet->len = 12;
packet->pending = true;
/* Reset the sequence so we send out poweroff now */
xpad->last_out_packet = -1;
xpad_try_sending_next_out_packet(xpad);
spin_unlock_irqrestore(&xpad->odata_lock, flags);
}
static int xpad360w_start_input(struct usb_xpad *xpad)
{
int error;
......@@ -1590,6 +1624,15 @@ static int xpad_suspend(struct usb_interface *intf, pm_message_t message)
* or goes away.
*/
xpad360w_stop_input(xpad);
/*
* The wireless adapter is going off now, so the
* gamepads are going to become disconnected.
* Unless explicitly disabled, power them down
* so they don't just sit there flashing.
*/
if (auto_poweroff && xpad->pad_present)
xpad360w_poweroff_controller(xpad);
} else {
mutex_lock(&input->mutex);
if (input->users)
......
......@@ -186,7 +186,7 @@ static irqreturn_t cros_ec_keyb_irq(int irq, void *data)
if (ret >= 0)
cros_ec_keyb_process(ckdev, kb_state, ret);
else
dev_err(ec->dev, "failed to get keyboard state: %d\n", ret);
dev_err(ckdev->dev, "failed to get keyboard state: %d\n", ret);
return IRQ_HANDLED;
}
......@@ -236,7 +236,7 @@ static void cros_ec_keyb_compute_valid_keys(struct cros_ec_keyb *ckdev)
static int cros_ec_keyb_probe(struct platform_device *pdev)
{
struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);
struct device *dev = ec->dev;
struct device *dev = &pdev->dev;
struct cros_ec_keyb *ckdev;
struct input_dev *idev;
struct device_node *np;
......@@ -246,23 +246,22 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
if (!np)
return -ENODEV;
ckdev = devm_kzalloc(&pdev->dev, sizeof(*ckdev), GFP_KERNEL);
ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL);
if (!ckdev)
return -ENOMEM;
err = matrix_keypad_parse_of_params(&pdev->dev, &ckdev->rows,
&ckdev->cols);
err = matrix_keypad_parse_of_params(dev, &ckdev->rows, &ckdev->cols);
if (err)
return err;
ckdev->valid_keys = devm_kzalloc(&pdev->dev, ckdev->cols, GFP_KERNEL);
ckdev->valid_keys = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL);
if (!ckdev->valid_keys)
return -ENOMEM;
ckdev->old_kb_state = devm_kzalloc(&pdev->dev, ckdev->cols, GFP_KERNEL);
ckdev->old_kb_state = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL);
if (!ckdev->old_kb_state)
return -ENOMEM;
idev = devm_input_allocate_device(&pdev->dev);
idev = devm_input_allocate_device(dev);
if (!idev)
return -ENOMEM;
......@@ -273,7 +272,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
ckdev->ec = ec;
ckdev->dev = dev;
dev_set_drvdata(&pdev->dev, ckdev);
dev_set_drvdata(dev, ckdev);
idev->name = CROS_EC_DEV_NAME;
idev->phys = ec->phys_name;
......@@ -282,7 +281,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
idev->id.bustype = BUS_VIRTUAL;
idev->id.version = 1;
idev->id.product = 0;
idev->dev.parent = &pdev->dev;
idev->dev.parent = dev;
idev->open = cros_ec_keyb_open;
idev->close = cros_ec_keyb_close;
......
......@@ -28,6 +28,11 @@
#define DRV_NAME "rotary-encoder"
enum rotary_encoder_encoding {
ROTENC_GRAY,
ROTENC_BINARY,
};
struct rotary_encoder {
struct input_dev *input;
......@@ -37,6 +42,7 @@ struct rotary_encoder {
u32 axis;
bool relative_axis;
bool rollover;
enum rotary_encoder_encoding encoding;
unsigned int pos;
......@@ -57,8 +63,9 @@ static unsigned int rotary_encoder_get_state(struct rotary_encoder *encoder)
for (i = 0; i < encoder->gpios->ndescs; ++i) {
int val = gpiod_get_value_cansleep(encoder->gpios->desc[i]);
/* convert from gray encoding to normal */
if (ret & 1)
if (encoder->encoding == ROTENC_GRAY && ret & 1)
val = !val;
ret = ret << 1 | val;
......@@ -213,6 +220,20 @@ static int rotary_encoder_probe(struct platform_device *pdev)
encoder->rollover =
device_property_read_bool(dev, "rotary-encoder,rollover");
if (!device_property_present(dev, "rotary-encoder,encoding") ||
!device_property_match_string(dev, "rotary-encoder,encoding",
"gray")) {
dev_info(dev, "gray");
encoder->encoding = ROTENC_GRAY;
} else if (!device_property_match_string(dev, "rotary-encoder,encoding",
"binary")) {
dev_info(dev, "binary");
encoder->encoding = ROTENC_BINARY;
} else {
dev_err(dev, "unknown encoding setting\n");
return -EINVAL;
}
device_property_read_u32(dev, "linux,axis", &encoder->axis);
encoder->relative_axis =
device_property_read_bool(dev, "rotary-encoder,relative-axis");
......
......@@ -4,7 +4,8 @@
* Copyright (c) 2013 ELAN Microelectronics Corp.
*
* Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
* Version: 1.6.0
* Author: KT Liao <kt.liao@emc.com.tw>
* Version: 1.6.2
*
* Based on cyapa driver:
* copyright (c) 2011-2012 Cypress Semiconductor, Inc.
......@@ -40,7 +41,7 @@
#include "elan_i2c.h"
#define DRIVER_NAME "elan_i2c"
#define ELAN_DRIVER_VERSION "1.6.1"
#define ELAN_DRIVER_VERSION "1.6.2"
#define ELAN_VENDOR_ID 0x04f3
#define ETP_MAX_PRESSURE 255
#define ETP_FWIDTH_REDUCE 90
......@@ -199,9 +200,41 @@ static int elan_sleep(struct elan_tp_data *data)
return error;
}
static int elan_query_product(struct elan_tp_data *data)
{
int error;
error = data->ops->get_product_id(data->client, &data->product_id);
if (error)
return error;
error = data->ops->get_sm_version(data->client, &data->ic_type,
&data->sm_version);
if (error)
return error;
return 0;
}
static int elan_check_ASUS_special_fw(struct elan_tp_data *data)
{
if (data->ic_type != 0x0E)
return false;
switch (data->product_id) {
case 0x05 ... 0x07:
case 0x09:
case 0x13:
return true;
default:
return false;
}
}
static int __elan_initialize(struct elan_tp_data *data)
{
struct i2c_client *client = data->client;
bool woken_up = false;
int error;
error = data->ops->initialize(client);
......@@ -210,6 +243,27 @@ static int __elan_initialize(struct elan_tp_data *data)
return error;
}
error = elan_query_product(data);
if (error)
return error;
/*
* Some ASUS devices were shipped with firmware that requires
* touchpads to be woken up first, before attempting to switch
* them into absolute reporting mode.
*/
if (elan_check_ASUS_special_fw(data)) {
error = data->ops->sleep_control(client, false);
if (error) {
dev_err(&client->dev,
"failed to wake device up: %d\n", error);
return error;
}
msleep(200);
woken_up = true;
}
data->mode |= ETP_ENABLE_ABS;
error = data->ops->set_mode(client, data->mode);
if (error) {
......@@ -218,11 +272,13 @@ static int __elan_initialize(struct elan_tp_data *data)
return error;
}
error = data->ops->sleep_control(client, false);
if (error) {
dev_err(&client->dev,
"failed to wake device up: %d\n", error);
return error;
if (!woken_up) {
error = data->ops->sleep_control(client, false);
if (error) {
dev_err(&client->dev,
"failed to wake device up: %d\n", error);
return error;
}
}
return 0;
......@@ -248,10 +304,6 @@ static int elan_query_device_info(struct elan_tp_data *data)
{
int error;
error = data->ops->get_product_id(data->client, &data->product_id);
if (error)
return error;
error = data->ops->get_version(data->client, false, &data->fw_version);
if (error)
return error;
......@@ -261,11 +313,6 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error)
return error;
error = data->ops->get_sm_version(data->client, &data->ic_type,
&data->sm_version);
if (error)
return error;
error = data->ops->get_version(data->client, true, &data->iap_version);
if (error)
return error;
......
......@@ -222,12 +222,8 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
*/
static void elantech_packet_dump(struct psmouse *psmouse)
{
int i;
psmouse_printk(KERN_DEBUG, psmouse, "PS/2 packet [");
for (i = 0; i < psmouse->pktsize; i++)
printk("%s0x%02x ", i ? ", " : " ", psmouse->packet[i]);
printk("]\n");
psmouse_printk(KERN_DEBUG, psmouse, "PS/2 packet [%*ph]\n",
psmouse->pktsize, psmouse->packet);
}
/*
......
......@@ -232,10 +232,7 @@ int rmi_register_function(struct rmi_function *fn)
void rmi_unregister_function(struct rmi_function *fn)
{
device_del(&fn->dev);
if (fn->dev.of_node)
of_node_put(fn->dev.of_node);
of_node_put(fn->dev.of_node);
put_device(&fn->dev);
}
......
......@@ -1277,6 +1277,7 @@ static int __init i8042_create_kbd_port(void)
serio->start = i8042_start;
serio->stop = i8042_stop;
serio->close = i8042_port_close;
serio->ps2_cmd_mutex = &i8042_mutex;
serio->port_data = port;
serio->dev.parent = &i8042_platform_device->dev;
strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name));
......@@ -1373,21 +1374,6 @@ static void i8042_unregister_ports(void)
}
}
/*
* Checks whether port belongs to i8042 controller.
*/
bool i8042_check_port_owner(const struct serio *port)
{
int i;
for (i = 0; i < I8042_NUM_PORTS; i++)
if (i8042_ports[i].serio == port)
return true;
return false;
}
EXPORT_SYMBOL(i8042_check_port_owner);
static void i8042_free_irqs(void)
{
if (i8042_aux_irq_registered)
......
......@@ -56,19 +56,17 @@ EXPORT_SYMBOL(ps2_sendbyte);
void ps2_begin_command(struct ps2dev *ps2dev)
{
mutex_lock(&ps2dev->cmd_mutex);
struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex;
if (i8042_check_port_owner(ps2dev->serio))
i8042_lock_chip();
mutex_lock(m);
}
EXPORT_SYMBOL(ps2_begin_command);
void ps2_end_command(struct ps2dev *ps2dev)
{
if (i8042_check_port_owner(ps2dev->serio))
i8042_unlock_chip();
struct mutex *m = ps2dev->serio->ps2_cmd_mutex ?: &ps2dev->cmd_mutex;
mutex_unlock(&ps2dev->cmd_mutex);
mutex_unlock(m);
}
EXPORT_SYMBOL(ps2_end_command);
......
......@@ -1059,6 +1059,31 @@ config TOUCHSCREEN_RM_TS
To compile this driver as a module, choose M here: the
module will be called raydium_i2c_ts.
config TOUCHSCREEN_SILEAD
tristate "Silead I2C touchscreen"
depends on I2C
help
Say Y here if you have the Silead touchscreen connected to
your system.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called silead.
config TOUCHSCREEN_SIS_I2C
tristate "SiS 9200 family I2C touchscreen"
depends on I2C
select CRC_ITU_T
depends on GPIOLIB || COMPILE_TEST
help
This enables support for SiS 9200 family over I2C based touchscreens.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called sis_i2c.
config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
......
......@@ -64,6 +64,8 @@ obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o
obj-$(CONFIG_TOUCHSCREEN_RM_TS) += raydium_i2c_ts.o
obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o
obj-$(CONFIG_TOUCHSCREEN_SILEAD) += silead.o
obj-$(CONFIG_TOUCHSCREEN_SIS_I2C) += sis_i2c.o
obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o
obj-$(CONFIG_TOUCHSCREEN_SUN4I) += sun4i-ts.o
......
......@@ -169,7 +169,7 @@ static ssize_t ili210x_calibrate(struct device *dev,
return count;
}
static DEVICE_ATTR(calibrate, 0644, NULL, ili210x_calibrate);
static DEVICE_ATTR(calibrate, S_IWUSR, NULL, ili210x_calibrate);
static struct attribute *ili210x_attributes[] = {
&dev_attr_calibrate.attr,
......
/* -------------------------------------------------------------------------
* Copyright (C) 2014-2015, Intel Corporation
*
* Derived from:
* gslX68X.c
* Copyright (C) 2010-2015, Shanghai Sileadinc Co.Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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/i2c.h>
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/pm.h>
#include <linux/irq.h>
#include <asm/unaligned.h>
#define SILEAD_TS_NAME "silead_ts"
#define SILEAD_REG_RESET 0xE0
#define SILEAD_REG_DATA 0x80
#define SILEAD_REG_TOUCH_NR 0x80
#define SILEAD_REG_POWER 0xBC
#define SILEAD_REG_CLOCK 0xE4
#define SILEAD_REG_STATUS 0xB0
#define SILEAD_REG_ID 0xFC
#define SILEAD_REG_MEM_CHECK 0xB0
#define SILEAD_STATUS_OK 0x5A5A5A5A
#define SILEAD_TS_DATA_LEN 44
#define SILEAD_CLOCK 0x04
#define SILEAD_CMD_RESET 0x88
#define SILEAD_CMD_START 0x00
#define SILEAD_POINT_DATA_LEN 0x04
#define SILEAD_POINT_Y_OFF 0x00
#define SILEAD_POINT_Y_MSB_OFF 0x01
#define SILEAD_POINT_X_OFF 0x02
#define SILEAD_POINT_X_MSB_OFF 0x03
#define SILEAD_TOUCH_ID_MASK 0xF0
#define SILEAD_CMD_SLEEP_MIN 10000
#define SILEAD_CMD_SLEEP_MAX 20000
#define SILEAD_POWER_SLEEP 20
#define SILEAD_STARTUP_SLEEP 30
#define SILEAD_MAX_FINGERS 10
enum silead_ts_power {
SILEAD_POWER_ON = 1,
SILEAD_POWER_OFF = 0
};
struct silead_ts_data {
struct i2c_client *client;
struct gpio_desc *gpio_power;
struct input_dev *input;
char fw_name[64];
struct touchscreen_properties prop;
u32 max_fingers;
u32 chip_id;
struct input_mt_pos pos[SILEAD_MAX_FINGERS];
int slots[SILEAD_MAX_FINGERS];
int id[SILEAD_MAX_FINGERS];
};
struct silead_fw_data {
u32 offset;
u32 val;
};
static int silead_ts_request_input_dev(struct silead_ts_data *data)
{
struct device *dev = &data->client->dev;
int error;
data->input = devm_input_allocate_device(dev);
if (!data->input) {
dev_err(dev,
"Failed to allocate input device\n");
return -ENOMEM;
}
input_set_abs_params(data->input, ABS_MT_POSITION_X, 0, 4095, 0, 0);
input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0, 4095, 0, 0);
touchscreen_parse_properties(data->input, true, &data->prop);
input_mt_init_slots(data->input, data->max_fingers,
INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED |
INPUT_MT_TRACK);
data->input->name = SILEAD_TS_NAME;
data->input->phys = "input/ts";
data->input->id.bustype = BUS_I2C;
error = input_register_device(data->input);
if (error) {
dev_err(dev, "Failed to register input device: %d\n", error);
return error;
}
return 0;
}
static void silead_ts_set_power(struct i2c_client *client,
enum silead_ts_power state)
{
struct silead_ts_data *data = i2c_get_clientdata(client);
if (data->gpio_power) {
gpiod_set_value_cansleep(data->gpio_power, state);
msleep(SILEAD_POWER_SLEEP);
}
}
static void silead_ts_read_data(struct i2c_client *client)
{
struct silead_ts_data *data = i2c_get_clientdata(client);
struct input_dev *input = data->input;
struct device *dev = &client->dev;
u8 *bufp, buf[SILEAD_TS_DATA_LEN];
int touch_nr, error, i;
error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_DATA,
SILEAD_TS_DATA_LEN, buf);
if (error < 0) {
dev_err(dev, "Data read error %d\n", error);
return;
}
touch_nr = buf[0];
if (touch_nr > data->max_fingers) {
dev_warn(dev, "More touches reported then supported %d > %d\n",
touch_nr, data->max_fingers);
touch_nr = data->max_fingers;
}
bufp = buf + SILEAD_POINT_DATA_LEN;
for (i = 0; i < touch_nr; i++, bufp += SILEAD_POINT_DATA_LEN) {
/* Bits 4-7 are the touch id */
data->id[i] = (bufp[SILEAD_POINT_X_MSB_OFF] &
SILEAD_TOUCH_ID_MASK) >> 4;
touchscreen_set_mt_pos(&data->pos[i], &data->prop,
get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff,
get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff);
}
input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0);
for (i = 0; i < touch_nr; i++) {
input_mt_slot(input, data->slots[i]);
input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
input_report_abs(input, ABS_MT_POSITION_X, data->pos[i].x);
input_report_abs(input, ABS_MT_POSITION_Y, data->pos[i].y);
dev_dbg(dev, "x=%d y=%d hw_id=%d sw_id=%d\n", data->pos[i].x,
data->pos[i].y, data->id[i], data->slots[i]);
}
input_mt_sync_frame(input);
input_sync(input);
}
static int silead_ts_init(struct i2c_client *client)
{
struct silead_ts_data *data = i2c_get_clientdata(client);
int error;
error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
SILEAD_CMD_RESET);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
error = i2c_smbus_write_byte_data(client, SILEAD_REG_TOUCH_NR,
data->max_fingers);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
error = i2c_smbus_write_byte_data(client, SILEAD_REG_CLOCK,
SILEAD_CLOCK);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
SILEAD_CMD_START);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
return 0;
i2c_write_err:
dev_err(&client->dev, "Registers clear error %d\n", error);
return error;
}
static int silead_ts_reset(struct i2c_client *client)
{
int error;
error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET,
SILEAD_CMD_RESET);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
error = i2c_smbus_write_byte_data(client, SILEAD_REG_CLOCK,
SILEAD_CLOCK);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
error = i2c_smbus_write_byte_data(client, SILEAD_REG_POWER,
SILEAD_CMD_START);
if (error)
goto i2c_write_err;
usleep_range(SILEAD_CMD_SLEEP_MIN, SILEAD_CMD_SLEEP_MAX);
return 0;
i2c_write_err:
dev_err(&client->dev, "Chip reset error %d\n", error);
return error;
}
static int silead_ts_startup(struct i2c_client *client)
{
int error;
error = i2c_smbus_write_byte_data(client, SILEAD_REG_RESET, 0x00);
if (error) {
dev_err(&client->dev, "Startup error %d\n", error);
return error;
}
msleep(SILEAD_STARTUP_SLEEP);
return 0;
}
static int silead_ts_load_fw(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct silead_ts_data *data = i2c_get_clientdata(client);
unsigned int fw_size, i;
const struct firmware *fw;
struct silead_fw_data *fw_data;
int error;
dev_dbg(dev, "Firmware file name: %s", data->fw_name);
error = request_firmware(&fw, data->fw_name, dev);
if (error) {
dev_err(dev, "Firmware request error %d\n", error);
return error;
}
fw_size = fw->size / sizeof(*fw_data);
fw_data = (struct silead_fw_data *)fw->data;
for (i = 0; i < fw_size; i++) {
error = i2c_smbus_write_i2c_block_data(client,
fw_data[i].offset,
4,
(u8 *)&fw_data[i].val);
if (error) {
dev_err(dev, "Firmware load error %d\n", error);
break;
}
}
release_firmware(fw);
return error ?: 0;
}
static u32 silead_ts_get_status(struct i2c_client *client)
{
int error;
__le32 status;
error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_STATUS,
sizeof(status), (u8 *)&status);
if (error < 0) {
dev_err(&client->dev, "Status read error %d\n", error);
return error;
}
return le32_to_cpu(status);
}
static int silead_ts_get_id(struct i2c_client *client)
{
struct silead_ts_data *data = i2c_get_clientdata(client);
__le32 chip_id;
int error;
error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_ID,
sizeof(chip_id), (u8 *)&chip_id);
if (error < 0) {
dev_err(&client->dev, "Chip ID read error %d\n", error);
return error;
}
data->chip_id = le32_to_cpu(chip_id);
dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id);
return 0;
}
static int silead_ts_setup(struct i2c_client *client)
{
int error;
u32 status;
silead_ts_set_power(client, SILEAD_POWER_OFF);
silead_ts_set_power(client, SILEAD_POWER_ON);
error = silead_ts_get_id(client);
if (error)
return error;
error = silead_ts_init(client);
if (error)
return error;
error = silead_ts_reset(client);
if (error)
return error;
error = silead_ts_load_fw(client);
if (error)
return error;
error = silead_ts_startup(client);
if (error)
return error;
status = silead_ts_get_status(client);
if (status != SILEAD_STATUS_OK) {
dev_err(&client->dev,
"Initialization error, status: 0x%X\n", status);
return -ENODEV;
}
return 0;
}
static irqreturn_t silead_ts_threaded_irq_handler(int irq, void *id)
{
struct silead_ts_data *data = id;
struct i2c_client *client = data->client;
silead_ts_read_data(client);
return IRQ_HANDLED;
}
static void silead_ts_read_props(struct i2c_client *client)
{
struct silead_ts_data *data = i2c_get_clientdata(client);
struct device *dev = &client->dev;
const char *str;
int error;
error = device_property_read_u32(dev, "silead,max-fingers",
&data->max_fingers);
if (error) {
dev_dbg(dev, "Max fingers read error %d\n", error);
data->max_fingers = 5; /* Most devices handle up-to 5 fingers */
}
error = device_property_read_string(dev, "touchscreen-fw-name", &str);
if (!error)
snprintf(data->fw_name, sizeof(data->fw_name), "%s", str);
else
dev_dbg(dev, "Firmware file name read error. Using default.");
}
#ifdef CONFIG_ACPI
static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
const struct i2c_device_id *id)
{
const struct acpi_device_id *acpi_id;
struct device *dev = &data->client->dev;
int i;
if (ACPI_HANDLE(dev)) {
acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
if (!acpi_id)
return -ENODEV;
snprintf(data->fw_name, sizeof(data->fw_name), "%s.fw",
acpi_id->id);
for (i = 0; i < strlen(data->fw_name); i++)
data->fw_name[i] = tolower(data->fw_name[i]);
} else {
snprintf(data->fw_name, sizeof(data->fw_name), "%s.fw",
id->name);
}
return 0;
}
#else
static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
const struct i2c_device_id *id)
{
snprintf(data->fw_name, sizeof(data->fw_name), "%s.fw", id->name);
return 0;
}
#endif
static int silead_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct silead_ts_data *data;
struct device *dev = &client->dev;
int error;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_I2C |
I2C_FUNC_SMBUS_READ_I2C_BLOCK |
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
dev_err(dev, "I2C functionality check failed\n");
return -ENXIO;
}
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
i2c_set_clientdata(client, data);
data->client = client;
error = silead_ts_set_default_fw_name(data, id);
if (error)
return error;
silead_ts_read_props(client);
/* We must have the IRQ provided by DT or ACPI subsytem */
if (client->irq <= 0)
return -ENODEV;
/* Power GPIO pin */
data->gpio_power = gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
if (IS_ERR(data->gpio_power)) {
if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER)
dev_err(dev, "Shutdown GPIO request failed\n");
return PTR_ERR(data->gpio_power);
}
error = silead_ts_setup(client);
if (error)
return error;
error = silead_ts_request_input_dev(data);
if (error)
return error;
error = devm_request_threaded_irq(dev, client->irq,
NULL, silead_ts_threaded_irq_handler,
IRQF_ONESHOT, client->name, data);
if (error) {
if (error != -EPROBE_DEFER)
dev_err(dev, "IRQ request failed %d\n", error);
return error;
}
return 0;
}
static int __maybe_unused silead_ts_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
silead_ts_set_power(client, SILEAD_POWER_OFF);
return 0;
}
static int __maybe_unused silead_ts_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
int error, status;
silead_ts_set_power(client, SILEAD_POWER_ON);
error = silead_ts_reset(client);
if (error)
return error;
error = silead_ts_startup(client);
if (error)
return error;
status = silead_ts_get_status(client);
if (status != SILEAD_STATUS_OK) {
dev_err(dev, "Resume error, status: 0x%02x\n", status);
return -ENODEV;
}
return 0;
}
static SIMPLE_DEV_PM_OPS(silead_ts_pm, silead_ts_suspend, silead_ts_resume);
static const struct i2c_device_id silead_ts_id[] = {
{ "gsl1680", 0 },
{ "gsl1688", 0 },
{ "gsl3670", 0 },
{ "gsl3675", 0 },
{ "gsl3692", 0 },
{ "mssl1680", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, silead_ts_id);
#ifdef CONFIG_ACPI
static const struct acpi_device_id silead_ts_acpi_match[] = {
{ "GSL1680", 0 },
{ "GSL1688", 0 },
{ "GSL3670", 0 },
{ "GSL3675", 0 },
{ "GSL3692", 0 },
{ "MSSL1680", 0 },
{ }
};
MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match);
#endif
static struct i2c_driver silead_ts_driver = {
.probe = silead_ts_probe,
.id_table = silead_ts_id,
.driver = {
.name = SILEAD_TS_NAME,
.acpi_match_table = ACPI_PTR(silead_ts_acpi_match),
.pm = &silead_ts_pm,
},
};
module_i2c_driver(silead_ts_driver);
MODULE_AUTHOR("Robert Dolca <robert.dolca@intel.com>");
MODULE_DESCRIPTION("Silead I2C touchscreen driver");
MODULE_LICENSE("GPL");
/*
* Touch Screen driver for SiS 9200 family I2C Touch panels
*
* Copyright (C) 2015 SiS, Inc.
* Copyright (C) 2016 Nextfour Group
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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/crc-itu-t.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <asm/unaligned.h>
#define SIS_I2C_NAME "sis_i2c_ts"
/*
* The I2C packet format:
* le16 byte count
* u8 Report ID
* <contact data - variable length>
* u8 Number of contacts
* le16 Scan Time (optional)
* le16 CRC
*
* One touch point information consists of 6+ bytes, the order is:
* u8 contact state
* u8 finger id
* le16 x axis
* le16 y axis
* u8 contact width (optional)
* u8 contact height (optional)
* u8 pressure (optional)
*
* Maximum amount of data transmitted in one shot is 64 bytes, if controller
* needs to report more contacts than fit in one packet it will send true
* number of contacts in first packet and 0 as number of contacts in second
* packet.
*/
#define SIS_MAX_PACKET_SIZE 64
#define SIS_PKT_LEN_OFFSET 0
#define SIS_PKT_REPORT_OFFSET 2 /* Report ID/type */
#define SIS_PKT_CONTACT_OFFSET 3 /* First contact */
#define SIS_SCAN_TIME_LEN 2
/* Supported report types */
#define SIS_ALL_IN_ONE_PACKAGE 0x10
#define SIS_PKT_IS_TOUCH(x) (((x) & 0x0f) == 0x01)
#define SIS_PKT_IS_HIDI2C(x) (((x) & 0x0f) == 0x06)
/* Contact properties within report */
#define SIS_PKT_HAS_AREA(x) ((x) & BIT(4))
#define SIS_PKT_HAS_PRESSURE(x) ((x) & BIT(5))
#define SIS_PKT_HAS_SCANTIME(x) ((x) & BIT(6))
/* Contact size */
#define SIS_BASE_LEN_PER_CONTACT 6
#define SIS_AREA_LEN_PER_CONTACT 2
#define SIS_PRESSURE_LEN_PER_CONTACT 1
/* Offsets within contact data */
#define SIS_CONTACT_STATUS_OFFSET 0
#define SIS_CONTACT_ID_OFFSET 1 /* Contact ID */
#define SIS_CONTACT_X_OFFSET 2
#define SIS_CONTACT_Y_OFFSET 4
#define SIS_CONTACT_WIDTH_OFFSET 6
#define SIS_CONTACT_HEIGHT_OFFSET 7
#define SIS_CONTACT_PRESSURE_OFFSET(id) (SIS_PKT_HAS_AREA(id) ? 8 : 6)
/* Individual contact state */
#define SIS_STATUS_UP 0x0
#define SIS_STATUS_DOWN 0x3
/* Touchscreen parameters */
#define SIS_MAX_FINGERS 10
#define SIS_MAX_X 4095
#define SIS_MAX_Y 4095
#define SIS_MAX_PRESSURE 255
/* Resolution diagonal */
#define SIS_AREA_LENGTH_LONGER 5792
/*((SIS_MAX_X^2) + (SIS_MAX_Y^2))^0.5*/
#define SIS_AREA_LENGTH_SHORT 5792
#define SIS_AREA_UNIT (5792 / 32)
struct sis_ts_data {
struct i2c_client *client;
struct input_dev *input;
struct gpio_desc *attn_gpio;
struct gpio_desc *reset_gpio;
u8 packet[SIS_MAX_PACKET_SIZE];
};
static int sis_read_packet(struct i2c_client *client, u8 *buf,
unsigned int *num_contacts,
unsigned int *contact_size)
{
int count_idx;
int ret;
u16 len;
u16 crc, pkg_crc;
u8 report_id;
ret = i2c_master_recv(client, buf, SIS_MAX_PACKET_SIZE);
if (ret <= 0)
return -EIO;
len = get_unaligned_le16(&buf[SIS_PKT_LEN_OFFSET]);
if (len > SIS_MAX_PACKET_SIZE) {
dev_err(&client->dev,
"%s: invalid packet length (%d vs %d)\n",
__func__, len, SIS_MAX_PACKET_SIZE);
return -E2BIG;
}
if (len < 10)
return -EINVAL;
report_id = buf[SIS_PKT_REPORT_OFFSET];
count_idx = len - 1;
*contact_size = SIS_BASE_LEN_PER_CONTACT;
if (report_id != SIS_ALL_IN_ONE_PACKAGE) {
if (SIS_PKT_IS_TOUCH(report_id)) {
/*
* Calculate CRC ignoring packet length
* in the beginning and CRC transmitted
* at the end of the packet.
*/
crc = crc_itu_t(0, buf + 2, len - 2 - 2);
pkg_crc = get_unaligned_le16(&buf[len - 2]);
if (crc != pkg_crc) {
dev_err(&client->dev,
"%s: CRC Error (%d vs %d)\n",
__func__, crc, pkg_crc);
return -EINVAL;
}
count_idx -= 2;
} else if (!SIS_PKT_IS_HIDI2C(report_id)) {
dev_err(&client->dev,
"%s: invalid packet ID %#02x\n",
__func__, report_id);
return -EINVAL;
}
if (SIS_PKT_HAS_SCANTIME(report_id))
count_idx -= SIS_SCAN_TIME_LEN;
if (SIS_PKT_HAS_AREA(report_id))
*contact_size += SIS_AREA_LEN_PER_CONTACT;
if (SIS_PKT_HAS_PRESSURE(report_id))
*contact_size += SIS_PRESSURE_LEN_PER_CONTACT;
}
*num_contacts = buf[count_idx];
return 0;
}
static int sis_ts_report_contact(struct sis_ts_data *ts, const u8 *data, u8 id)
{
struct input_dev *input = ts->input;
int slot;
u8 status = data[SIS_CONTACT_STATUS_OFFSET];
u8 pressure;
u8 height, width;
u16 x, y;
if (status != SIS_STATUS_DOWN && status != SIS_STATUS_UP) {
dev_err(&ts->client->dev, "Unexpected touch status: %#02x\n",
data[SIS_CONTACT_STATUS_OFFSET]);
return -EINVAL;
}
slot = input_mt_get_slot_by_key(input, data[SIS_CONTACT_ID_OFFSET]);
if (slot < 0)
return -ENOENT;
input_mt_slot(input, slot);
input_mt_report_slot_state(input, MT_TOOL_FINGER,
status == SIS_STATUS_DOWN);
if (status == SIS_STATUS_DOWN) {
pressure = height = width = 1;
if (id != SIS_ALL_IN_ONE_PACKAGE) {
if (SIS_PKT_HAS_AREA(id)) {
width = data[SIS_CONTACT_WIDTH_OFFSET];
height = data[SIS_CONTACT_HEIGHT_OFFSET];
}
if (SIS_PKT_HAS_PRESSURE(id))
pressure =
data[SIS_CONTACT_PRESSURE_OFFSET(id)];
}
x = get_unaligned_le16(&data[SIS_CONTACT_X_OFFSET]);
y = get_unaligned_le16(&data[SIS_CONTACT_Y_OFFSET]);
input_report_abs(input, ABS_MT_TOUCH_MAJOR,
width * SIS_AREA_UNIT);
input_report_abs(input, ABS_MT_TOUCH_MINOR,
height * SIS_AREA_UNIT);
input_report_abs(input, ABS_MT_PRESSURE, pressure);
input_report_abs(input, ABS_MT_POSITION_X, x);
input_report_abs(input, ABS_MT_POSITION_Y, y);
}
return 0;
}
static void sis_ts_handle_packet(struct sis_ts_data *ts)
{
const u8 *contact;
unsigned int num_to_report = 0;
unsigned int num_contacts;
unsigned int num_reported;
unsigned int contact_size;
int error;
u8 report_id;
do {
error = sis_read_packet(ts->client, ts->packet,
&num_contacts, &contact_size);
if (error)
break;
if (num_to_report == 0) {
num_to_report = num_contacts;
} else if (num_contacts != 0) {
dev_err(&ts->client->dev,
"%s: nonzero (%d) point count in tail packet\n",
__func__, num_contacts);
break;
}
report_id = ts->packet[SIS_PKT_REPORT_OFFSET];
contact = &ts->packet[SIS_PKT_CONTACT_OFFSET];
num_reported = 0;
while (num_to_report > 0) {
error = sis_ts_report_contact(ts, contact, report_id);
if (error)
break;
contact += contact_size;
num_to_report--;
num_reported++;
if (report_id != SIS_ALL_IN_ONE_PACKAGE &&
num_reported >= 5) {
/*
* The remainder of contacts is sent
* in the 2nd packet.
*/
break;
}
}
} while (num_to_report > 0);
input_mt_sync_frame(ts->input);
input_sync(ts->input);
}
static irqreturn_t sis_ts_irq_handler(int irq, void *dev_id)
{
struct sis_ts_data *ts = dev_id;
do {
sis_ts_handle_packet(ts);
} while (ts->attn_gpio && gpiod_get_value_cansleep(ts->attn_gpio));
return IRQ_HANDLED;
}
static void sis_ts_reset(struct sis_ts_data *ts)
{
if (ts->reset_gpio) {
/* Get out of reset */
usleep_range(1000, 2000);
gpiod_set_value(ts->reset_gpio, 1);
usleep_range(1000, 2000);
gpiod_set_value(ts->reset_gpio, 0);
msleep(100);
}
}
static int sis_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct sis_ts_data *ts;
struct input_dev *input;
int error;
ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
if (!ts)
return -ENOMEM;
ts->client = client;
i2c_set_clientdata(client, ts);
ts->attn_gpio = devm_gpiod_get_optional(&client->dev,
"attn", GPIOD_IN);
if (IS_ERR(ts->attn_gpio)) {
error = PTR_ERR(ts->attn_gpio);
if (error != -EPROBE_DEFER)
dev_err(&client->dev,
"Failed to get attention GPIO: %d\n", error);
return error;
}
ts->reset_gpio = devm_gpiod_get_optional(&client->dev,
"reset", GPIOD_OUT_LOW);
if (IS_ERR(ts->reset_gpio)) {
error = PTR_ERR(ts->reset_gpio);
if (error != -EPROBE_DEFER)
dev_err(&client->dev,
"Failed to get reset GPIO: %d\n", error);
return error;
}
sis_ts_reset(ts);
ts->input = input = devm_input_allocate_device(&client->dev);
if (!input) {
dev_err(&client->dev, "Failed to allocate input device\n");
return -ENOMEM;
}
input->name = "SiS Touchscreen";
input->id.bustype = BUS_I2C;
input_set_abs_params(input, ABS_MT_POSITION_X, 0, SIS_MAX_X, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, SIS_MAX_Y, 0, 0);
input_set_abs_params(input, ABS_MT_PRESSURE, 0, SIS_MAX_PRESSURE, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MAJOR,
0, SIS_AREA_LENGTH_LONGER, 0, 0);
input_set_abs_params(input, ABS_MT_TOUCH_MINOR,
0, SIS_AREA_LENGTH_SHORT, 0, 0);
error = input_mt_init_slots(input, SIS_MAX_FINGERS, INPUT_MT_DIRECT);
if (error) {
dev_err(&client->dev,
"Failed to initialize MT slots: %d\n", error);
return error;
}
error = devm_request_threaded_irq(&client->dev, client->irq,
NULL, sis_ts_irq_handler,
IRQF_ONESHOT,
client->name, ts);
if (error) {
dev_err(&client->dev, "Failed to request IRQ: %d\n", error);
return error;
}
error = input_register_device(ts->input);
if (error) {
dev_err(&client->dev,
"Failed to register input device: %d\n", error);
return error;
}
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id sis_ts_dt_ids[] = {
{ .compatible = "sis,9200-ts" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, sis_ts_dt_ids);
#endif
static const struct i2c_device_id sis_ts_id[] = {
{ SIS_I2C_NAME, 0 },
{ "9200-ts", 0 },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(i2c, sis_ts_id);
static struct i2c_driver sis_ts_driver = {
.driver = {
.name = SIS_I2C_NAME,
.of_match_table = of_match_ptr(sis_ts_dt_ids),
},
.probe = sis_ts_probe,
.id_table = sis_ts_id,
};
module_i2c_driver(sis_ts_driver);
MODULE_DESCRIPTION("SiS 9200 Family Touchscreen Driver");
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Mika Penttilä <mika.penttila@nextfour.com>");
......@@ -62,7 +62,6 @@ struct serio;
void i8042_lock_chip(void);
void i8042_unlock_chip(void);
int i8042_command(unsigned char *param, int command);
bool i8042_check_port_owner(const struct serio *);
int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio));
int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
......@@ -83,11 +82,6 @@ static inline int i8042_command(unsigned char *param, int command)
return -ENODEV;
}
static inline bool i8042_check_port_owner(const struct serio *serio)
{
return false;
}
static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
struct serio *serio))
{
......
......@@ -31,7 +31,8 @@ struct serio {
struct serio_device_id id;
spinlock_t lock; /* protects critical sections from port's interrupt handler */
/* Protects critical sections from port's interrupt handler */
spinlock_t lock;
int (*write)(struct serio *, unsigned char);
int (*open)(struct serio *);
......@@ -40,16 +41,29 @@ struct serio {
void (*stop)(struct serio *);
struct serio *parent;
struct list_head child_node; /* Entry in parent->children list */
/* Entry in parent->children list */
struct list_head child_node;
struct list_head children;
unsigned int depth; /* level of nesting in serio hierarchy */
/* Level of nesting in serio hierarchy */
unsigned int depth;
struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
/*
* serio->drv is accessed from interrupt handlers; when modifying
* caller should acquire serio->drv_mutex and serio->lock.
*/
struct serio_driver *drv;
/* Protects serio->drv so attributes can pin current driver */
struct mutex drv_mutex;
struct device dev;
struct list_head node;
/*
* For use by PS/2 layer when several ports share hardware and
* may get indigestion when exposed to concurrent access (i8042).
*/
struct mutex *ps2_cmd_mutex;
};
#define to_serio_port(d) container_of(d, struct serio, dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment