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

Pull input updates from Dmitry Torokhov:

 - update the ili210x touchscreen driver, refreshing the code and adding
   support for ILI251X line

 - add support for st1633 to the st1232 touchscreen driver

 - add support for sx8650 to the the sx8654 touchscreen driver

 - add support for Evervision FT5726 to the edt-ft5x06 touchscreen
   driver

 - add support for gt5688 to the Goodix touchscreen driver

 - new vibrator driver for MSM SOCs

 - miscellaneous fixes for the rest of input drivers

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (53 commits)
  Input: wacom_serial4 - add support for Wacom ArtPad II tablet
  Input: elan_i2c - add id for touchpad found in Lenovo s21e-20
  Input: raspberrypi-ts - select CONFIG_INPUT_POLLDEV
  Input: msm-vibrator - use correct gpio header
  Input: ti_am335x_tsc - remove set but not used variable 'tscadc_dev'
  Input: i8042 - rework DT node name comparisons
  Input: goodix - print values in case of inconsistencies
  Input: goodix - refer to touchscreen.txt in device tree bindings
  Input: goodix - support Goodix gt5688
  Input: synaptics_i2c - remove redundant spinlock
  Input: db9 - mark expected switch fall-through
  Input: qt2160 - remove redundant spinlock
  Input: st1232 - handle common DT bindings
  Input: ims-pcu - switch to using brightness_set_blocking()
  Input: st1232 - switch to gpiod API
  Input: ili210x - fetch touchscreen geometry from DT
  Input: msm-vibrator - tweak an error message
  Input: tm2-touchkey - acknowledge that setting brightness is a blocking call
  Input: stmfts - acknowledge that setting brightness is a blocking call
  Input: ili210x - switch to using devm_device_add_group()
  ...
This commit is contained in:
Linus Torvalds
2019-03-11 10:57:11 -07:00
當前提交 4f0237062c
共有 33 個文件被更改,包括 1207 次插入367 次删除

查看文件

@@ -699,6 +699,7 @@ config TOUCHSCREEN_EDT_FT5X06
config TOUCHSCREEN_RASPBERRYPI_FW
tristate "Raspberry Pi's firmware base touch screen support"
depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n && COMPILE_TEST)
select INPUT_POLLDEV
help
Say Y here if you have the official Raspberry Pi 7 inch screen on
your system.
@@ -1168,11 +1169,11 @@ config TOUCHSCREEN_SIS_I2C
module will be called sis_i2c.
config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
tristate "Sitronix ST1232 or ST1633 touchscreen controllers"
depends on I2C
help
Say Y here if you want to support Sitronix ST1232
touchscreen controller.
Say Y here if you want to support the Sitronix ST1232
or ST1633 touchscreen controller.
If unsure, say N.

查看文件

@@ -246,11 +246,14 @@ static void ad7879_timer(struct timer_list *t)
static irqreturn_t ad7879_irq(int irq, void *handle)
{
struct ad7879 *ts = handle;
int error;
regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
ts->conversion_data, AD7879_NR_SENSE);
if (!ad7879_report(ts))
error = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
ts->conversion_data, AD7879_NR_SENSE);
if (error)
dev_err_ratelimited(ts->dev, "failed to read %#02x: %d\n",
AD7879_REG_XPLUS, error);
else if (!ad7879_report(ts))
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
return IRQ_HANDLED;

查看文件

@@ -31,6 +31,7 @@
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/debugfs.h>
@@ -53,6 +54,11 @@
#define M09_REGISTER_NUM_X 0x94
#define M09_REGISTER_NUM_Y 0x95
#define EV_REGISTER_THRESHOLD 0x40
#define EV_REGISTER_GAIN 0x41
#define EV_REGISTER_OFFSET_Y 0x45
#define EV_REGISTER_OFFSET_X 0x46
#define NO_REGISTER 0xff
#define WORK_REGISTER_OPMODE 0x3c
@@ -73,6 +79,7 @@ enum edt_ver {
EDT_M06,
EDT_M09,
EDT_M12,
EV_FT,
GENERIC_FT,
};
@@ -81,6 +88,8 @@ struct edt_reg_addr {
int reg_report_rate;
int reg_gain;
int reg_offset;
int reg_offset_x;
int reg_offset_y;
int reg_num_x;
int reg_num_y;
};
@@ -106,6 +115,8 @@ struct edt_ft5x06_ts_data {
int threshold;
int gain;
int offset;
int offset_x;
int offset_y;
int report_rate;
int max_support_points;
@@ -190,6 +201,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
case EDT_M09:
case EDT_M12:
case EV_FT:
case GENERIC_FT:
cmd = 0x0;
offset = 3;
@@ -242,6 +254,10 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
x = ((buf[0] << 8) | buf[1]) & 0x0fff;
y = ((buf[2] << 8) | buf[3]) & 0x0fff;
/* The FT5x26 send the y coordinate first */
if (tsdata->version == EV_FT)
swap(x, y);
id = (buf[2] >> 4) & 0x0f;
down = type != TOUCH_EVENT_UP;
@@ -275,8 +291,10 @@ static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata,
wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2];
return edt_ft5x06_ts_readwrite(tsdata->client, 4,
wrbuf, 0, NULL);
/* fallthrough */
case EDT_M09:
case EDT_M12:
case EV_FT:
case GENERIC_FT:
wrbuf[0] = addr;
wrbuf[1] = value;
@@ -315,8 +333,10 @@ static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata,
}
break;
/* fallthrough */
case EDT_M09:
case EDT_M12:
case EV_FT:
case GENERIC_FT:
wrbuf[0] = addr;
error = edt_ft5x06_ts_readwrite(tsdata->client, 1,
@@ -339,9 +359,10 @@ struct edt_ft5x06_attribute {
u8 limit_high;
u8 addr_m06;
u8 addr_m09;
u8 addr_ev;
};
#define EDT_ATTR(_field, _mode, _addr_m06, _addr_m09, \
#define EDT_ATTR(_field, _mode, _addr_m06, _addr_m09, _addr_ev, \
_limit_low, _limit_high) \
struct edt_ft5x06_attribute edt_ft5x06_attr_##_field = { \
.dattr = __ATTR(_field, _mode, \
@@ -350,6 +371,7 @@ struct edt_ft5x06_attribute {
.field_offset = offsetof(struct edt_ft5x06_ts_data, _field), \
.addr_m06 = _addr_m06, \
.addr_m09 = _addr_m09, \
.addr_ev = _addr_ev, \
.limit_low = _limit_low, \
.limit_high = _limit_high, \
}
@@ -386,6 +408,10 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev,
addr = attr->addr_m09;
break;
case EV_FT:
addr = attr->addr_ev;
break;
default:
error = -ENODEV;
goto out;
@@ -457,6 +483,10 @@ static ssize_t edt_ft5x06_setting_store(struct device *dev,
addr = attr->addr_m09;
break;
case EV_FT:
addr = attr->addr_ev;
break;
default:
error = -ENODEV;
goto out;
@@ -480,20 +510,28 @@ out:
/* m06, m09: range 0-31, m12: range 0-5 */
static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN,
M09_REGISTER_GAIN, 0, 31);
M09_REGISTER_GAIN, EV_REGISTER_GAIN, 0, 31);
/* m06, m09: range 0-31, m12: range 0-16 */
static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET,
M09_REGISTER_OFFSET, 0, 31);
M09_REGISTER_OFFSET, NO_REGISTER, 0, 31);
/* m06, m09, m12: no supported, ev_ft: range 0-80 */
static EDT_ATTR(offset_x, S_IWUSR | S_IRUGO, NO_REGISTER, NO_REGISTER,
EV_REGISTER_OFFSET_X, 0, 80);
/* m06, m09, m12: no supported, ev_ft: range 0-80 */
static EDT_ATTR(offset_y, S_IWUSR | S_IRUGO, NO_REGISTER, NO_REGISTER,
EV_REGISTER_OFFSET_Y, 0, 80);
/* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */
static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD,
M09_REGISTER_THRESHOLD, 0, 255);
M09_REGISTER_THRESHOLD, EV_REGISTER_THRESHOLD, 0, 255);
/* m06: range 3 to 14, m12: (0x64: 100Hz) */
static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE,
NO_REGISTER, 0, 255);
NO_REGISTER, NO_REGISTER, 0, 255);
static struct attribute *edt_ft5x06_attrs[] = {
&edt_ft5x06_attr_gain.dattr.attr,
&edt_ft5x06_attr_offset.dattr.attr,
&edt_ft5x06_attr_offset_x.dattr.attr,
&edt_ft5x06_attr_offset_y.dattr.attr,
&edt_ft5x06_attr_threshold.dattr.attr,
&edt_ft5x06_attr_report_rate.dattr.attr,
NULL
@@ -605,8 +643,15 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
tsdata->threshold);
edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
tsdata->gain);
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
tsdata->offset);
if (reg_addr->reg_offset != NO_REGISTER)
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
tsdata->offset);
if (reg_addr->reg_offset_x != NO_REGISTER)
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x,
tsdata->offset_x);
if (reg_addr->reg_offset_y != NO_REGISTER)
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y,
tsdata->offset_y);
if (reg_addr->reg_report_rate != NO_REGISTER)
edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
tsdata->report_rate);
@@ -867,6 +912,16 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
case 0x5a: /* Solomon Goldentek Display */
snprintf(model_name, EDT_NAME_LEN, "GKTW50SCED1R0");
break;
case 0x59: /* Evervision Display with FT5xx6 TS */
tsdata->version = EV_FT;
error = edt_ft5x06_ts_readwrite(client, 1, "\x53",
1, rdbuf);
if (error)
return error;
strlcpy(fw_version, rdbuf, 1);
snprintf(model_name, EDT_NAME_LEN,
"EVERVISION-FT5726NEi");
break;
default:
snprintf(model_name, EDT_NAME_LEN,
"generic ft5x06 (%02x)",
@@ -902,6 +957,18 @@ static void edt_ft5x06_ts_get_defaults(struct device *dev,
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, val);
tsdata->offset = val;
}
error = device_property_read_u32(dev, "offset-x", &val);
if (!error) {
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x, val);
tsdata->offset_x = val;
}
error = device_property_read_u32(dev, "offset-y", &val);
if (!error) {
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y, val);
tsdata->offset_y = val;
}
}
static void
@@ -912,7 +979,15 @@ edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata)
tsdata->threshold = edt_ft5x06_register_read(tsdata,
reg_addr->reg_threshold);
tsdata->gain = edt_ft5x06_register_read(tsdata, reg_addr->reg_gain);
tsdata->offset = edt_ft5x06_register_read(tsdata, reg_addr->reg_offset);
if (reg_addr->reg_offset != NO_REGISTER)
tsdata->offset =
edt_ft5x06_register_read(tsdata, reg_addr->reg_offset);
if (reg_addr->reg_offset_x != NO_REGISTER)
tsdata->offset_x = edt_ft5x06_register_read(tsdata,
reg_addr->reg_offset_x);
if (reg_addr->reg_offset_y != NO_REGISTER)
tsdata->offset_y = edt_ft5x06_register_read(tsdata,
reg_addr->reg_offset_y);
if (reg_addr->reg_report_rate != NO_REGISTER)
tsdata->report_rate = edt_ft5x06_register_read(tsdata,
reg_addr->reg_report_rate);
@@ -940,6 +1015,8 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
reg_addr->reg_report_rate = WORK_REGISTER_REPORT_RATE;
reg_addr->reg_gain = WORK_REGISTER_GAIN;
reg_addr->reg_offset = WORK_REGISTER_OFFSET;
reg_addr->reg_offset_x = NO_REGISTER;
reg_addr->reg_offset_y = NO_REGISTER;
reg_addr->reg_num_x = WORK_REGISTER_NUM_X;
reg_addr->reg_num_y = WORK_REGISTER_NUM_Y;
break;
@@ -950,15 +1027,30 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
reg_addr->reg_report_rate = NO_REGISTER;
reg_addr->reg_gain = M09_REGISTER_GAIN;
reg_addr->reg_offset = M09_REGISTER_OFFSET;
reg_addr->reg_offset_x = NO_REGISTER;
reg_addr->reg_offset_y = NO_REGISTER;
reg_addr->reg_num_x = M09_REGISTER_NUM_X;
reg_addr->reg_num_y = M09_REGISTER_NUM_Y;
break;
case EV_FT:
reg_addr->reg_threshold = EV_REGISTER_THRESHOLD;
reg_addr->reg_gain = EV_REGISTER_GAIN;
reg_addr->reg_offset = NO_REGISTER;
reg_addr->reg_offset_x = EV_REGISTER_OFFSET_X;
reg_addr->reg_offset_y = EV_REGISTER_OFFSET_Y;
reg_addr->reg_num_x = NO_REGISTER;
reg_addr->reg_num_y = NO_REGISTER;
reg_addr->reg_report_rate = NO_REGISTER;
break;
case GENERIC_FT:
/* this is a guesswork */
reg_addr->reg_threshold = M09_REGISTER_THRESHOLD;
reg_addr->reg_gain = M09_REGISTER_GAIN;
reg_addr->reg_offset = M09_REGISTER_OFFSET;
reg_addr->reg_offset_x = NO_REGISTER;
reg_addr->reg_offset_y = NO_REGISTER;
break;
}
}
@@ -1155,6 +1247,7 @@ static const struct edt_i2c_chip_data edt_ft6236_data = {
static const struct i2c_device_id edt_ft5x06_ts_id[] = {
{ .name = "edt-ft5x06", .driver_data = (long)&edt_ft5x06_data },
{ .name = "edt-ft5506", .driver_data = (long)&edt_ft5506_data },
{ .name = "ev-ft5726", .driver_data = (long)&edt_ft5506_data },
/* Note no edt- prefix for compatibility with the ft6236.c driver */
{ .name = "ft6236", .driver_data = (long)&edt_ft6236_data },
{ /* sentinel */ }
@@ -1167,6 +1260,7 @@ static const struct of_device_id edt_ft5x06_of_match[] = {
{ .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data },
{ .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data },
{ .compatible = "edt,edt-ft5506", .data = &edt_ft5506_data },
{ .compatible = "evervision,ev-ft5726", .data = &edt_ft5506_data },
/* Note focaltech vendor prefix for compatibility with ft6236.c */
{ .compatible = "focaltech,ft6236", .data = &edt_ft6236_data },
{ /* sentinel */ }

查看文件

@@ -216,6 +216,7 @@ static const struct goodix_chip_data *goodix_get_chip_data(u16 id)
{
switch (id) {
case 1151:
case 5688:
return &gt1x_chip_data;
case 911:
@@ -692,7 +693,9 @@ static int goodix_configure_dev(struct goodix_ts_data *ts)
touchscreen_parse_properties(ts->input_dev, true, &ts->prop);
if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) {
dev_err(&ts->client->dev, "Invalid config, using defaults\n");
dev_err(&ts->client->dev,
"Invalid config (%d, %d, %d), using defaults\n",
ts->prop.max_x, ts->prop.max_y, ts->max_touch_num);
ts->prop.max_x = GOODIX_MAX_WIDTH - 1;
ts->prop.max_y = GOODIX_MAX_HEIGHT - 1;
ts->max_touch_num = GOODIX_MAX_CONTACTS;
@@ -942,6 +945,7 @@ MODULE_DEVICE_TABLE(acpi, goodix_acpi_match);
#ifdef CONFIG_OF
static const struct of_device_id goodix_of_match[] = {
{ .compatible = "goodix,gt1151" },
{ .compatible = "goodix,gt5688" },
{ .compatible = "goodix,gt911" },
{ .compatible = "goodix,gt9110" },
{ .compatible = "goodix,gt912" },

查看文件

@@ -4,11 +4,15 @@
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/input/ili210x.h>
#include <linux/gpio/consumer.h>
#include <linux/of_device.h>
#include <asm/unaligned.h>
#define MAX_TOUCHES 2
#define ILI210X_TOUCHES 2
#define ILI251X_TOUCHES 10
#define DEFAULT_POLL_PERIOD 20
/* Touchscreen commands */
@@ -17,41 +21,32 @@
#define REG_FIRMWARE_VERSION 0x40
#define REG_CALIBRATE 0xcc
struct finger {
u8 x_low;
u8 x_high;
u8 y_low;
u8 y_high;
} __packed;
struct touchdata {
u8 status;
struct finger finger[MAX_TOUCHES];
} __packed;
struct panel_info {
struct finger finger_max;
u8 xchannel_num;
u8 ychannel_num;
} __packed;
struct firmware_version {
u8 id;
u8 major;
u8 minor;
} __packed;
enum ili2xxx_model {
MODEL_ILI210X,
MODEL_ILI251X,
};
struct ili210x {
struct i2c_client *client;
struct input_dev *input;
bool (*get_pendown_state)(void);
unsigned int poll_period;
struct delayed_work dwork;
struct gpio_desc *reset_gpio;
struct touchscreen_properties prop;
enum ili2xxx_model model;
unsigned int max_touches;
};
static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf,
size_t len)
{
struct ili210x *priv = i2c_get_clientdata(client);
struct i2c_msg msg[2] = {
{
.addr = client->addr,
@@ -67,7 +62,38 @@ static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf,
}
};
if (i2c_transfer(client->adapter, msg, 2) != 2) {
if (priv->model == MODEL_ILI251X) {
if (i2c_transfer(client->adapter, msg, 1) != 1) {
dev_err(&client->dev, "i2c transfer failed\n");
return -EIO;
}
usleep_range(5000, 5500);
if (i2c_transfer(client->adapter, msg + 1, 1) != 1) {
dev_err(&client->dev, "i2c transfer failed\n");
return -EIO;
}
} else {
if (i2c_transfer(client->adapter, msg, 2) != 2) {
dev_err(&client->dev, "i2c transfer failed\n");
return -EIO;
}
}
return 0;
}
static int ili210x_read(struct i2c_client *client, void *buf, size_t len)
{
struct i2c_msg msg = {
.addr = client->addr,
.flags = I2C_M_RD,
.len = len,
.buf = buf,
};
if (i2c_transfer(client->adapter, &msg, 1) != 1) {
dev_err(&client->dev, "i2c transfer failed\n");
return -EIO;
}
@@ -75,42 +101,72 @@ static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf,
return 0;
}
static void ili210x_report_events(struct input_dev *input,
const struct touchdata *touchdata)
static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata,
unsigned int finger,
unsigned int *x, unsigned int *y)
{
if (finger >= ILI210X_TOUCHES)
return false;
if (touchdata[0] & BIT(finger))
return false;
*x = get_unaligned_be16(touchdata + 1 + (finger * 4) + 0);
*y = get_unaligned_be16(touchdata + 1 + (finger * 4) + 2);
return true;
}
static bool ili251x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata,
unsigned int finger,
unsigned int *x, unsigned int *y)
{
if (finger >= ILI251X_TOUCHES)
return false;
*x = get_unaligned_be16(touchdata + 1 + (finger * 5) + 0);
if (!(*x & BIT(15))) /* Touch indication */
return false;
*x &= 0x3fff;
*y = get_unaligned_be16(touchdata + 1 + (finger * 5) + 2);
return true;
}
static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
{
struct input_dev *input = priv->input;
int i;
bool touch;
unsigned int x, y;
const struct finger *finger;
bool contact = false, touch = false;
unsigned int x = 0, y = 0;
for (i = 0; i < MAX_TOUCHES; i++) {
input_mt_slot(input, i);
finger = &touchdata->finger[i];
touch = touchdata->status & (1 << i);
input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
if (touch) {
x = finger->x_low | (finger->x_high << 8);
y = finger->y_low | (finger->y_high << 8);
input_report_abs(input, ABS_MT_POSITION_X, x);
input_report_abs(input, ABS_MT_POSITION_Y, y);
for (i = 0; i < priv->max_touches; i++) {
if (priv->model == MODEL_ILI210X) {
touch = ili210x_touchdata_to_coords(priv, touchdata,
i, &x, &y);
} else if (priv->model == MODEL_ILI251X) {
touch = ili251x_touchdata_to_coords(priv, touchdata,
i, &x, &y);
if (touch)
contact = true;
}
input_mt_slot(input, i);
input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
if (!touch)
continue;
touchscreen_report_pos(input, &priv->prop, x, y,
true);
}
input_mt_report_pointer_emulation(input, false);
input_sync(input);
}
static bool get_pendown_state(const struct ili210x *priv)
{
bool state = false;
if (priv->model == MODEL_ILI210X)
contact = touchdata[0] & 0xf3;
if (priv->get_pendown_state)
state = priv->get_pendown_state();
return state;
return contact;
}
static void ili210x_work(struct work_struct *work)
@@ -118,20 +174,29 @@ static void ili210x_work(struct work_struct *work)
struct ili210x *priv = container_of(work, struct ili210x,
dwork.work);
struct i2c_client *client = priv->client;
struct touchdata touchdata;
int error;
u8 touchdata[64] = { 0 };
bool touch;
int error = -EINVAL;
if (priv->model == MODEL_ILI210X) {
error = ili210x_read_reg(client, REG_TOUCHDATA,
touchdata, sizeof(touchdata));
} else if (priv->model == MODEL_ILI251X) {
error = ili210x_read_reg(client, REG_TOUCHDATA,
touchdata, 31);
if (!error && touchdata[0] == 2)
error = ili210x_read(client, &touchdata[31], 20);
}
error = ili210x_read_reg(client, REG_TOUCHDATA,
&touchdata, sizeof(touchdata));
if (error) {
dev_err(&client->dev,
"Unable to get touchdata, err = %d\n", error);
return;
}
ili210x_report_events(priv->input, &touchdata);
touch = ili210x_report_events(priv, touchdata);
if ((touchdata.status & 0xf3) || get_pendown_state(priv))
if (touch)
schedule_delayed_work(&priv->dwork,
msecs_to_jiffies(priv->poll_period));
}
@@ -180,30 +245,76 @@ static const struct attribute_group ili210x_attr_group = {
.attrs = ili210x_attributes,
};
static void ili210x_power_down(void *data)
{
struct gpio_desc *reset_gpio = data;
gpiod_set_value_cansleep(reset_gpio, 1);
}
static void ili210x_cancel_work(void *data)
{
struct ili210x *priv = data;
cancel_delayed_work_sync(&priv->dwork);
}
static int ili210x_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
const struct ili210x_platform_data *pdata = dev_get_platdata(dev);
struct ili210x *priv;
struct gpio_desc *reset_gpio;
struct input_dev *input;
struct panel_info panel;
struct firmware_version firmware;
int xmax, ymax;
enum ili2xxx_model model;
int error;
dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver");
model = (enum ili2xxx_model)id->driver_data;
if (!pdata) {
dev_err(dev, "No platform data!\n");
return -EINVAL;
}
dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver");
if (client->irq <= 0) {
dev_err(dev, "No IRQ!\n");
return -EINVAL;
}
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);
if (reset_gpio) {
error = devm_add_action_or_reset(dev, ili210x_power_down,
reset_gpio);
if (error)
return error;
usleep_range(50, 100);
gpiod_set_value_cansleep(reset_gpio, 0);
msleep(100);
}
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
input = devm_input_allocate_device(dev);
if (!input)
return -ENOMEM;
priv->client = client;
priv->input = input;
priv->poll_period = DEFAULT_POLL_PERIOD;
INIT_DELAYED_WORK(&priv->dwork, ili210x_work);
priv->reset_gpio = reset_gpio;
priv->model = model;
if (model == MODEL_ILI210X)
priv->max_touches = ILI210X_TOUCHES;
if (model == MODEL_ILI251X)
priv->max_touches = ILI251X_TOUCHES;
i2c_set_clientdata(client, priv);
/* Get firmware version */
error = ili210x_read_reg(client, REG_FIRMWARE_VERSION,
&firmware, sizeof(firmware));
@@ -213,70 +324,40 @@ static int ili210x_i2c_probe(struct i2c_client *client,
return error;
}
/* get panel info */
error = ili210x_read_reg(client, REG_PANEL_INFO, &panel, sizeof(panel));
if (error) {
dev_err(dev, "Failed to get panel information, err: %d\n",
error);
return error;
}
xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8);
ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
input = input_allocate_device();
if (!priv || !input) {
error = -ENOMEM;
goto err_free_mem;
}
priv->client = client;
priv->input = input;
priv->get_pendown_state = pdata->get_pendown_state;
priv->poll_period = pdata->poll_period ? : DEFAULT_POLL_PERIOD;
INIT_DELAYED_WORK(&priv->dwork, ili210x_work);
/* Setup input device */
input->name = "ILI210x Touchscreen";
input->id.bustype = BUS_I2C;
input->dev.parent = dev;
__set_bit(EV_SYN, input->evbit);
__set_bit(EV_KEY, input->evbit);
__set_bit(EV_ABS, input->evbit);
__set_bit(BTN_TOUCH, input->keybit);
/* Single touch */
input_set_abs_params(input, ABS_X, 0, xmax, 0, 0);
input_set_abs_params(input, ABS_Y, 0, ymax, 0, 0);
/* Multi touch */
input_mt_init_slots(input, MAX_TOUCHES, 0);
input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_X, 0, 0xffff, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 0xffff, 0, 0);
touchscreen_parse_properties(input, true, &priv->prop);
input_mt_init_slots(input, priv->max_touches, INPUT_MT_DIRECT);
i2c_set_clientdata(client, priv);
error = devm_add_action(dev, ili210x_cancel_work, priv);
if (error)
return error;
error = request_irq(client->irq, ili210x_irq, pdata->irq_flags,
client->name, priv);
error = devm_request_irq(dev, client->irq, ili210x_irq, 0,
client->name, priv);
if (error) {
dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n",
error);
goto err_free_mem;
return error;
}
error = sysfs_create_group(&dev->kobj, &ili210x_attr_group);
error = devm_device_add_group(dev, &ili210x_attr_group);
if (error) {
dev_err(dev, "Unable to create sysfs attributes, err: %d\n",
error);
goto err_free_irq;
return error;
}
error = input_register_device(priv->input);
if (error) {
dev_err(dev, "Cannot register input device, err: %d\n", error);
goto err_remove_sysfs;
return error;
}
device_init_wakeup(dev, 1);
@@ -286,28 +367,6 @@ static int ili210x_i2c_probe(struct i2c_client *client,
client->irq, firmware.id, firmware.major, firmware.minor);
return 0;
err_remove_sysfs:
sysfs_remove_group(&dev->kobj, &ili210x_attr_group);
err_free_irq:
free_irq(client->irq, priv);
err_free_mem:
input_free_device(input);
kfree(priv);
return error;
}
static int ili210x_i2c_remove(struct i2c_client *client)
{
struct ili210x *priv = i2c_get_clientdata(client);
sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group);
free_irq(priv->client->irq, priv);
cancel_delayed_work_sync(&priv->dwork);
input_unregister_device(priv->input);
kfree(priv);
return 0;
}
static int __maybe_unused ili210x_i2c_suspend(struct device *dev)
@@ -334,19 +393,27 @@ static SIMPLE_DEV_PM_OPS(ili210x_i2c_pm,
ili210x_i2c_suspend, ili210x_i2c_resume);
static const struct i2c_device_id ili210x_i2c_id[] = {
{ "ili210x", 0 },
{ "ili210x", MODEL_ILI210X },
{ "ili251x", MODEL_ILI251X },
{ }
};
MODULE_DEVICE_TABLE(i2c, ili210x_i2c_id);
static const struct of_device_id ili210x_dt_ids[] = {
{ .compatible = "ilitek,ili210x", .data = (void *)MODEL_ILI210X },
{ .compatible = "ilitek,ili251x", .data = (void *)MODEL_ILI251X },
{ },
};
MODULE_DEVICE_TABLE(of, ili210x_dt_ids);
static struct i2c_driver ili210x_ts_driver = {
.driver = {
.name = "ili210x_i2c",
.pm = &ili210x_i2c_pm,
.of_match_table = ili210x_dt_ids,
},
.id_table = ili210x_i2c_id,
.probe = ili210x_i2c_probe,
.remove = ili210x_i2c_remove,
};
module_i2c_driver(ili210x_ts_driver);

查看文件

@@ -11,25 +11,19 @@
*/
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/pm_qos.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/input/touchscreen.h>
#define ST1232_TS_NAME "st1232-ts"
#define MIN_X 0x00
#define MIN_Y 0x00
#define MAX_X 0x31f /* (800 - 1) */
#define MAX_Y 0x1df /* (480 - 1) */
#define MAX_AREA 0xff
#define MAX_FINGERS 2
#define ST1633_TS_NAME "st1633-ts"
struct st1232_ts_finger {
u16 x;
@@ -38,12 +32,25 @@ struct st1232_ts_finger {
bool is_valid;
};
struct st_chip_info {
bool have_z;
u16 max_x;
u16 max_y;
u16 max_area;
u16 max_fingers;
u8 start_reg;
};
struct st1232_ts_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct st1232_ts_finger finger[MAX_FINGERS];
struct touchscreen_properties prop;
struct dev_pm_qos_request low_latency_req;
int reset_gpio;
struct gpio_desc *reset_gpio;
const struct st_chip_info *chip_info;
int read_buf_len;
u8 *read_buf;
struct st1232_ts_finger *finger;
};
static int st1232_ts_read_data(struct st1232_ts_data *ts)
@@ -52,40 +59,35 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
struct i2c_client *client = ts->client;
struct i2c_msg msg[2];
int error;
u8 start_reg;
u8 buf[10];
int i, y;
u8 start_reg = ts->chip_info->start_reg;
u8 *buf = ts->read_buf;
/* read touchscreen data from ST1232 */
/* read touchscreen data */
msg[0].addr = client->addr;
msg[0].flags = 0;
msg[0].len = 1;
msg[0].buf = &start_reg;
start_reg = 0x10;
msg[1].addr = ts->client->addr;
msg[1].flags = I2C_M_RD;
msg[1].len = sizeof(buf);
msg[1].len = ts->read_buf_len;
msg[1].buf = buf;
error = i2c_transfer(client->adapter, msg, 2);
if (error < 0)
return error;
/* get "valid" bits */
finger[0].is_valid = buf[2] >> 7;
finger[1].is_valid = buf[5] >> 7;
for (i = 0, y = 0; i < ts->chip_info->max_fingers; i++, y += 3) {
finger[i].is_valid = buf[i + y] >> 7;
if (finger[i].is_valid) {
finger[i].x = ((buf[i + y] & 0x0070) << 4) | buf[i + 1];
finger[i].y = ((buf[i + y] & 0x0007) << 8) | buf[i + 2];
/* get xy coordinate */
if (finger[0].is_valid) {
finger[0].x = ((buf[2] & 0x0070) << 4) | buf[3];
finger[0].y = ((buf[2] & 0x0007) << 8) | buf[4];
finger[0].t = buf[8];
}
if (finger[1].is_valid) {
finger[1].x = ((buf[5] & 0x0070) << 4) | buf[6];
finger[1].y = ((buf[5] & 0x0007) << 8) | buf[7];
finger[1].t = buf[9];
/* st1232 includes a z-axis / touch strength */
if (ts->chip_info->have_z)
finger[i].t = buf[i + 6];
}
}
return 0;
@@ -104,13 +106,16 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
goto end;
/* multi touch protocol */
for (i = 0; i < MAX_FINGERS; i++) {
for (i = 0; i < ts->chip_info->max_fingers; i++) {
if (!finger[i].is_valid)
continue;
input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, finger[i].t);
input_report_abs(input_dev, ABS_MT_POSITION_X, finger[i].x);
input_report_abs(input_dev, ABS_MT_POSITION_Y, finger[i].y);
if (ts->chip_info->have_z)
input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
finger[i].t);
touchscreen_report_pos(input_dev, &ts->prop,
finger[i].x, finger[i].y, true);
input_mt_sync(input_dev);
count++;
}
@@ -138,17 +143,45 @@ end:
static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron)
{
if (gpio_is_valid(ts->reset_gpio))
gpio_direction_output(ts->reset_gpio, poweron);
if (ts->reset_gpio)
gpiod_set_value_cansleep(ts->reset_gpio, !poweron);
}
static const struct st_chip_info st1232_chip_info = {
.have_z = true,
.max_x = 0x31f, /* 800 - 1 */
.max_y = 0x1df, /* 480 -1 */
.max_area = 0xff,
.max_fingers = 2,
.start_reg = 0x12,
};
static const struct st_chip_info st1633_chip_info = {
.have_z = false,
.max_x = 0x13f, /* 320 - 1 */
.max_y = 0x1df, /* 480 -1 */
.max_area = 0x00,
.max_fingers = 5,
.start_reg = 0x12,
};
static int st1232_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
const struct st_chip_info *match;
struct st1232_ts_data *ts;
struct st1232_ts_finger *finger;
struct input_dev *input_dev;
int error;
match = device_get_match_data(&client->dev);
if (!match && id)
match = (const void *)id->driver_data;
if (!match) {
dev_err(&client->dev, "unknown device model\n");
return -ENODEV;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "need I2C_FUNC_I2C\n");
return -EIO;
@@ -163,6 +196,19 @@ static int st1232_ts_probe(struct i2c_client *client,
if (!ts)
return -ENOMEM;
ts->chip_info = match;
ts->finger = devm_kcalloc(&client->dev,
ts->chip_info->max_fingers, sizeof(*finger),
GFP_KERNEL);
if (!ts->finger)
return -ENOMEM;
/* allocate a buffer according to the number of registers to read */
ts->read_buf_len = ts->chip_info->max_fingers * 4;
ts->read_buf = devm_kzalloc(&client->dev, ts->read_buf_len, GFP_KERNEL);
if (!ts->read_buf)
return -ENOMEM;
input_dev = devm_input_allocate_device(&client->dev);
if (!input_dev)
return -ENOMEM;
@@ -170,15 +216,13 @@ static int st1232_ts_probe(struct i2c_client *client,
ts->client = client;
ts->input_dev = input_dev;
ts->reset_gpio = of_get_gpio(client->dev.of_node, 0);
if (gpio_is_valid(ts->reset_gpio)) {
error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL);
if (error) {
dev_err(&client->dev,
"Unable to request GPIO pin %d.\n",
ts->reset_gpio);
return error;
}
ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL,
GPIOD_OUT_HIGH);
if (IS_ERR(ts->reset_gpio)) {
error = PTR_ERR(ts->reset_gpio);
dev_err(&client->dev, "Unable to request GPIO pin: %d.\n",
error);
return error;
}
st1232_ts_power(ts, true);
@@ -192,9 +236,16 @@ static int st1232_ts_probe(struct i2c_client *client,
__set_bit(EV_KEY, input_dev->evbit);
__set_bit(EV_ABS, input_dev->evbit);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, MAX_AREA, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_X, MIN_X, MAX_X, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, MIN_Y, MAX_Y, 0, 0);
if (ts->chip_info->have_z)
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
ts->chip_info->max_area, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_X,
0, ts->chip_info->max_x, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
0, ts->chip_info->max_y, 0, 0);
touchscreen_parse_properties(input_dev, true, &ts->prop);
error = devm_request_threaded_irq(&client->dev, client->irq,
NULL, st1232_ts_irq_handler,
@@ -261,13 +312,15 @@ static SIMPLE_DEV_PM_OPS(st1232_ts_pm_ops,
st1232_ts_suspend, st1232_ts_resume);
static const struct i2c_device_id st1232_ts_id[] = {
{ ST1232_TS_NAME, 0 },
{ ST1232_TS_NAME, (unsigned long)&st1232_chip_info },
{ ST1633_TS_NAME, (unsigned long)&st1633_chip_info },
{ }
};
MODULE_DEVICE_TABLE(i2c, st1232_ts_id);
static const struct of_device_id st1232_ts_dt_ids[] = {
{ .compatible = "sitronix,st1232", },
{ .compatible = "sitronix,st1232", .data = &st1232_chip_info },
{ .compatible = "sitronix,st1633", .data = &st1633_chip_info },
{ }
};
MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
@@ -286,5 +339,6 @@ static struct i2c_driver st1232_ts_driver = {
module_i2c_driver(st1232_ts_driver);
MODULE_AUTHOR("Tony SIM <chinyeow.sim.xt@renesas.com>");
MODULE_AUTHOR("Martin Kepplinger <martin.kepplinger@ginzinger.com>");
MODULE_DESCRIPTION("SITRONIX ST1232 Touchscreen Controller Driver");
MODULE_LICENSE("GPL v2");

查看文件

@@ -106,27 +106,29 @@ struct stmfts_data {
bool running;
};
static void stmfts_brightness_set(struct led_classdev *led_cdev,
static int stmfts_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct stmfts_data *sdata = container_of(led_cdev,
struct stmfts_data, led_cdev);
int err;
if (value == sdata->led_status || !sdata->ledvdd)
return;
if (!value) {
regulator_disable(sdata->ledvdd);
} else {
err = regulator_enable(sdata->ledvdd);
if (err)
dev_warn(&sdata->client->dev,
"failed to disable ledvdd regulator: %d\n",
err);
if (value != sdata->led_status && sdata->ledvdd) {
if (!value) {
regulator_disable(sdata->ledvdd);
} else {
err = regulator_enable(sdata->ledvdd);
if (err) {
dev_warn(&sdata->client->dev,
"failed to disable ledvdd regulator: %d\n",
err);
return err;
}
}
sdata->led_status = value;
}
sdata->led_status = value;
return 0;
}
static enum led_brightness stmfts_brightness_get(struct led_classdev *led_cdev)
@@ -608,7 +610,7 @@ static int stmfts_enable_led(struct stmfts_data *sdata)
sdata->led_cdev.name = STMFTS_DEV_NAME;
sdata->led_cdev.max_brightness = LED_ON;
sdata->led_cdev.brightness = LED_OFF;
sdata->led_cdev.brightness_set = stmfts_brightness_set;
sdata->led_cdev.brightness_set_blocking = stmfts_brightness_set;
sdata->led_cdev.brightness_get = stmfts_brightness_get;
err = devm_led_classdev_register(&sdata->client->dev, &sdata->led_cdev);

查看文件

@@ -27,12 +27,16 @@
* published by the Free Software Foundation.
*/
#include <linux/input.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/of.h>
/* register addresses */
#define I2C_REG_TOUCH0 0x00
@@ -42,25 +46,28 @@
#define I2C_REG_IRQSRC 0x23
#define I2C_REG_SOFTRESET 0x3f
#define I2C_REG_SX8650_STAT 0x05
#define SX8650_STAT_CONVIRQ BIT(7)
/* commands */
#define CMD_READ_REGISTER 0x40
#define CMD_MANUAL 0xc0
#define CMD_PENTRG 0xe0
/* value for I2C_REG_SOFTRESET */
#define SOFTRESET_VALUE 0xde
/* bits for I2C_REG_IRQSRC */
#define IRQ_PENTOUCH_TOUCHCONVDONE 0x08
#define IRQ_PENRELEASE 0x04
#define IRQ_PENTOUCH_TOUCHCONVDONE BIT(3)
#define IRQ_PENRELEASE BIT(2)
/* bits for RegTouch1 */
#define CONDIRQ 0x20
#define RPDNT_100K 0x00
#define FILT_7SA 0x03
/* bits for I2C_REG_CHANMASK */
#define CONV_X 0x80
#define CONV_Y 0x40
#define CONV_X BIT(7)
#define CONV_Y BIT(6)
/* coordinates rate: higher nibble of CTRL0 register */
#define RATE_MANUAL 0x00
@@ -69,13 +76,122 @@
/* power delay: lower nibble of CTRL0 register */
#define POWDLY_1_1MS 0x0b
/* for sx8650, as we have no pen release IRQ there: timeout in ns following the
* last PENIRQ after which we assume the pen is lifted.
*/
#define SX8650_PENIRQ_TIMEOUT msecs_to_jiffies(10)
#define MAX_12BIT ((1 << 12) - 1)
#define MAX_I2C_READ_LEN 10 /* see datasheet section 5.1.5 */
/* channel definition */
#define CH_X 0x00
#define CH_Y 0x01
struct sx865x_data {
u8 cmd_manual;
u8 chan_mask;
bool has_irq_penrelease;
bool has_reg_irqmask;
irq_handler_t irqh;
};
struct sx8654 {
struct input_dev *input;
struct i2c_client *client;
struct gpio_desc *gpio_reset;
spinlock_t lock; /* for input reporting from irq/timer */
struct timer_list timer;
struct touchscreen_properties props;
const struct sx865x_data *data;
};
static inline void sx865x_penrelease(struct sx8654 *ts)
{
struct input_dev *input_dev = ts->input;
input_report_key(input_dev, BTN_TOUCH, 0);
input_sync(input_dev);
}
static void sx865x_penrelease_timer_handler(struct timer_list *t)
{
struct sx8654 *ts = from_timer(ts, t, timer);
unsigned long flags;
spin_lock_irqsave(&ts->lock, flags);
sx865x_penrelease(ts);
spin_unlock_irqrestore(&ts->lock, flags);
dev_dbg(&ts->client->dev, "penrelease by timer\n");
}
static irqreturn_t sx8650_irq(int irq, void *handle)
{
struct sx8654 *ts = handle;
struct device *dev = &ts->client->dev;
int len, i;
unsigned long flags;
u8 stat;
u16 x, y;
u16 ch;
u16 chdata;
__be16 data[MAX_I2C_READ_LEN / sizeof(__be16)];
u8 nchan = hweight32(ts->data->chan_mask);
u8 readlen = nchan * sizeof(*data);
stat = i2c_smbus_read_byte_data(ts->client, CMD_READ_REGISTER
| I2C_REG_SX8650_STAT);
if (!(stat & SX8650_STAT_CONVIRQ)) {
dev_dbg(dev, "%s ignore stat [0x%02x]", __func__, stat);
return IRQ_HANDLED;
}
len = i2c_master_recv(ts->client, (u8 *)data, readlen);
if (len != readlen) {
dev_dbg(dev, "ignore short recv (%d)\n", len);
return IRQ_HANDLED;
}
spin_lock_irqsave(&ts->lock, flags);
x = 0;
y = 0;
for (i = 0; i < nchan; i++) {
chdata = be16_to_cpu(data[i]);
if (unlikely(chdata == 0xFFFF)) {
dev_dbg(dev, "invalid qualified data @ %d\n", i);
continue;
} else if (unlikely(chdata & 0x8000)) {
dev_warn(dev, "hibit @ %d [0x%04x]\n", i, chdata);
continue;
}
ch = chdata >> 12;
if (ch == CH_X)
x = chdata & MAX_12BIT;
else if (ch == CH_Y)
y = chdata & MAX_12BIT;
else
dev_warn(dev, "unknown channel %d [0x%04x]\n", ch,
chdata);
}
touchscreen_report_pos(ts->input, &ts->props, x, y, false);
input_report_key(ts->input, BTN_TOUCH, 1);
input_sync(ts->input);
dev_dbg(dev, "point(%4d,%4d)\n", x, y);
mod_timer(&ts->timer, jiffies + SX8650_PENIRQ_TIMEOUT);
spin_unlock_irqrestore(&ts->lock, flags);
return IRQ_HANDLED;
}
static irqreturn_t sx8654_irq(int irq, void *handle)
{
struct sx8654 *sx8654 = handle;
@@ -112,8 +228,8 @@ static irqreturn_t sx8654_irq(int irq, void *handle)
x = ((data[0] & 0xf) << 8) | (data[1]);
y = ((data[2] & 0xf) << 8) | (data[3]);
input_report_abs(sx8654->input, ABS_X, x);
input_report_abs(sx8654->input, ABS_Y, y);
touchscreen_report_pos(sx8654->input, &sx8654->props, x, y,
false);
input_report_key(sx8654->input, BTN_TOUCH, 1);
input_sync(sx8654->input);
@@ -124,6 +240,25 @@ out:
return IRQ_HANDLED;
}
static int sx8654_reset(struct sx8654 *ts)
{
int err;
if (ts->gpio_reset) {
gpiod_set_value_cansleep(ts->gpio_reset, 1);
udelay(2); /* Tpulse > 1µs */
gpiod_set_value_cansleep(ts->gpio_reset, 0);
} else {
dev_dbg(&ts->client->dev, "NRST unavailable, try softreset\n");
err = i2c_smbus_write_byte_data(ts->client, I2C_REG_SOFTRESET,
SOFTRESET_VALUE);
if (err)
return err;
}
return 0;
}
static int sx8654_open(struct input_dev *dev)
{
struct sx8654 *sx8654 = input_get_drvdata(dev);
@@ -157,14 +292,17 @@ static void sx8654_close(struct input_dev *dev)
disable_irq(client->irq);
if (!sx8654->data->has_irq_penrelease)
del_timer_sync(&sx8654->timer);
/* enable manual mode mode */
error = i2c_smbus_write_byte(client, CMD_MANUAL);
error = i2c_smbus_write_byte(client, sx8654->data->cmd_manual);
if (error) {
dev_err(&client->dev, "writing command CMD_MANUAL failed");
return;
}
error = i2c_smbus_write_byte_data(client, I2C_REG_TOUCH0, 0);
error = i2c_smbus_write_byte_data(client, I2C_REG_TOUCH0, RATE_MANUAL);
if (error) {
dev_err(&client->dev, "writing to I2C_REG_TOUCH0 failed");
return;
@@ -186,6 +324,31 @@ static int sx8654_probe(struct i2c_client *client,
if (!sx8654)
return -ENOMEM;
sx8654->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset",
GPIOD_OUT_HIGH);
if (IS_ERR(sx8654->gpio_reset)) {
error = PTR_ERR(sx8654->gpio_reset);
if (error != -EPROBE_DEFER)
dev_err(&client->dev, "unable to get reset-gpio: %d\n",
error);
return error;
}
dev_dbg(&client->dev, "got GPIO reset pin\n");
sx8654->data = device_get_match_data(&client->dev);
if (!sx8654->data)
sx8654->data = (const struct sx865x_data *)id->driver_data;
if (!sx8654->data) {
dev_err(&client->dev, "invalid or missing device data\n");
return -EINVAL;
}
if (!sx8654->data->has_irq_penrelease) {
dev_dbg(&client->dev, "use timer for penrelease\n");
timer_setup(&sx8654->timer, sx865x_penrelease_timer_handler, 0);
spin_lock_init(&sx8654->lock);
}
input = devm_input_allocate_device(&client->dev);
if (!input)
return -ENOMEM;
@@ -201,43 +364,46 @@ static int sx8654_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_X, 0, MAX_12BIT, 0, 0);
input_set_abs_params(input, ABS_Y, 0, MAX_12BIT, 0, 0);
touchscreen_parse_properties(input, false, &sx8654->props);
sx8654->client = client;
sx8654->input = input;
input_set_drvdata(sx8654->input, sx8654);
error = i2c_smbus_write_byte_data(client, I2C_REG_SOFTRESET,
SOFTRESET_VALUE);
error = sx8654_reset(sx8654);
if (error) {
dev_err(&client->dev, "writing softreset value failed");
dev_err(&client->dev, "reset failed");
return error;
}
error = i2c_smbus_write_byte_data(client, I2C_REG_CHANMASK,
CONV_X | CONV_Y);
sx8654->data->chan_mask);
if (error) {
dev_err(&client->dev, "writing to I2C_REG_CHANMASK failed");
return error;
}
error = i2c_smbus_write_byte_data(client, I2C_REG_IRQMASK,
IRQ_PENTOUCH_TOUCHCONVDONE |
IRQ_PENRELEASE);
if (error) {
dev_err(&client->dev, "writing to I2C_REG_IRQMASK failed");
return error;
if (sx8654->data->has_reg_irqmask) {
error = i2c_smbus_write_byte_data(client, I2C_REG_IRQMASK,
IRQ_PENTOUCH_TOUCHCONVDONE |
IRQ_PENRELEASE);
if (error) {
dev_err(&client->dev, "writing I2C_REG_IRQMASK failed");
return error;
}
}
error = i2c_smbus_write_byte_data(client, I2C_REG_TOUCH1,
CONDIRQ | FILT_7SA);
CONDIRQ | RPDNT_100K | FILT_7SA);
if (error) {
dev_err(&client->dev, "writing to I2C_REG_TOUCH1 failed");
return error;
}
error = devm_request_threaded_irq(&client->dev, client->irq,
NULL, sx8654_irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
NULL, sx8654->data->irqh,
IRQF_ONESHOT,
client->name, sx8654);
if (error) {
dev_err(&client->dev,
@@ -256,17 +422,48 @@ static int sx8654_probe(struct i2c_client *client,
return 0;
}
static const struct sx865x_data sx8650_data = {
.cmd_manual = 0xb0,
.has_irq_penrelease = false,
.has_reg_irqmask = false,
.chan_mask = (CONV_X | CONV_Y),
.irqh = sx8650_irq,
};
static const struct sx865x_data sx8654_data = {
.cmd_manual = 0xc0,
.has_irq_penrelease = true,
.has_reg_irqmask = true,
.chan_mask = (CONV_X | CONV_Y),
.irqh = sx8654_irq,
};
#ifdef CONFIG_OF
static const struct of_device_id sx8654_of_match[] = {
{ .compatible = "semtech,sx8654", },
{ },
{
.compatible = "semtech,sx8650",
.data = &sx8650_data,
}, {
.compatible = "semtech,sx8654",
.data = &sx8654_data,
}, {
.compatible = "semtech,sx8655",
.data = &sx8654_data,
}, {
.compatible = "semtech,sx8656",
.data = &sx8654_data,
},
{ }
};
MODULE_DEVICE_TABLE(of, sx8654_of_match);
#endif
static const struct i2c_device_id sx8654_id_table[] = {
{ "semtech_sx8654", 0 },
{ },
{ .name = "semtech_sx8650", .driver_data = (long)&sx8650_data },
{ .name = "semtech_sx8654", .driver_data = (long)&sx8654_data },
{ .name = "semtech_sx8655", .driver_data = (long)&sx8654_data },
{ .name = "semtech_sx8656", .driver_data = (long)&sx8654_data },
{ }
};
MODULE_DEVICE_TABLE(i2c, sx8654_id_table);

查看文件

@@ -507,10 +507,8 @@ static int titsc_remove(struct platform_device *pdev)
static int __maybe_unused titsc_suspend(struct device *dev)
{
struct titsc *ts_dev = dev_get_drvdata(dev);
struct ti_tscadc_dev *tscadc_dev;
unsigned int idle;
tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
if (device_may_wakeup(dev)) {
titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
idle = titsc_readl(ts_dev, REG_IRQENABLE);
@@ -524,9 +522,7 @@ static int __maybe_unused titsc_suspend(struct device *dev)
static int __maybe_unused titsc_resume(struct device *dev)
{
struct titsc *ts_dev = dev_get_drvdata(dev);
struct ti_tscadc_dev *tscadc_dev;
tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
if (device_may_wakeup(dev)) {
titsc_writel(ts_dev, REG_IRQWAKEUP,
0x00);