Merge branch 'next' into for-linus
Prepare input updates for 3.19.
This commit is contained in:
@@ -215,6 +215,36 @@ config MOUSE_CYAPA
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called cyapa.
|
||||
|
||||
config MOUSE_ELAN_I2C
|
||||
tristate "ELAN I2C Touchpad support"
|
||||
depends on I2C
|
||||
help
|
||||
This driver adds support for Elan I2C/SMbus Trackpads.
|
||||
|
||||
Say Y here if you have a ELAN I2C/SMbus Touchpad.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called elan_i2c.
|
||||
|
||||
config MOUSE_ELAN_I2C_I2C
|
||||
bool "Enable I2C support"
|
||||
depends on MOUSE_ELAN_I2C
|
||||
default y
|
||||
help
|
||||
Say Y here if Elan Touchpad in your system is connected to
|
||||
a standard I2C controller.
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
config MOUSE_ELAN_I2C_SMBUS
|
||||
bool "Enable SMbus support"
|
||||
depends on MOUSE_ELAN_I2C
|
||||
help
|
||||
Say Y here if Elan Touchpad in your system is connected to
|
||||
a SMbus adapter.
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
config MOUSE_INPORT
|
||||
tristate "InPort/MS/ATIXL busmouse"
|
||||
depends on ISA
|
||||
|
@@ -9,6 +9,7 @@ obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o
|
||||
obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o
|
||||
obj-$(CONFIG_MOUSE_BCM5974) += bcm5974.o
|
||||
obj-$(CONFIG_MOUSE_CYAPA) += cyapa.o
|
||||
obj-$(CONFIG_MOUSE_ELAN_I2C) += elan_i2c.o
|
||||
obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o
|
||||
obj-$(CONFIG_MOUSE_INPORT) += inport.o
|
||||
obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
|
||||
@@ -34,3 +35,7 @@ psmouse-$(CONFIG_MOUSE_PS2_SENTELIC) += sentelic.o
|
||||
psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
|
||||
psmouse-$(CONFIG_MOUSE_PS2_TOUCHKIT) += touchkit_ps2.o
|
||||
psmouse-$(CONFIG_MOUSE_PS2_CYPRESS) += cypress_ps2.o
|
||||
|
||||
elan_i2c-objs := elan_i2c_core.o
|
||||
elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_I2C) += elan_i2c_i2c.o
|
||||
elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_SMBUS) += elan_i2c_smbus.o
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* Daniel Kurtz <djkurtz@chromium.org>
|
||||
* Benson Leung <bleung@chromium.org>
|
||||
*
|
||||
* Copyright (C) 2011-2012 Cypress Semiconductor, Inc.
|
||||
* Copyright (C) 2011-2014 Cypress Semiconductor, Inc.
|
||||
* Copyright (C) 2011-2012 Google, Inc.
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
@@ -206,7 +206,6 @@ struct cyapa {
|
||||
struct i2c_client *client;
|
||||
struct input_dev *input;
|
||||
char phys[32]; /* device physical location */
|
||||
int irq;
|
||||
bool irq_wake; /* irq wake is enabled */
|
||||
bool smbus;
|
||||
|
||||
@@ -422,8 +421,8 @@ static ssize_t cyapa_read_block(struct cyapa *cyapa, u8 cmd_idx, u8 *values)
|
||||
*/
|
||||
static int cyapa_get_state(struct cyapa *cyapa)
|
||||
{
|
||||
int ret;
|
||||
u8 status[BL_STATUS_SIZE];
|
||||
int error;
|
||||
|
||||
cyapa->state = CYAPA_STATE_NO_DEVICE;
|
||||
|
||||
@@ -433,18 +432,18 @@ static int cyapa_get_state(struct cyapa *cyapa)
|
||||
* If the device is in operation mode, this will be the DATA regs.
|
||||
*
|
||||
*/
|
||||
ret = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE,
|
||||
status);
|
||||
error = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, BL_STATUS_SIZE,
|
||||
status);
|
||||
|
||||
/*
|
||||
* On smbus systems in OP mode, the i2c_reg_read will fail with
|
||||
* -ETIMEDOUT. In this case, try again using the smbus equivalent
|
||||
* command. This should return a BL_HEAD indicating CYAPA_STATE_OP.
|
||||
*/
|
||||
if (cyapa->smbus && (ret == -ETIMEDOUT || ret == -ENXIO))
|
||||
ret = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status);
|
||||
if (cyapa->smbus && (error == -ETIMEDOUT || error == -ENXIO))
|
||||
error = cyapa_read_block(cyapa, CYAPA_CMD_BL_STATUS, status);
|
||||
|
||||
if (ret != BL_STATUS_SIZE)
|
||||
if (error != BL_STATUS_SIZE)
|
||||
goto error;
|
||||
|
||||
if ((status[REG_OP_STATUS] & OP_STATUS_SRC) == OP_STATUS_SRC) {
|
||||
@@ -454,7 +453,7 @@ static int cyapa_get_state(struct cyapa *cyapa)
|
||||
cyapa->state = CYAPA_STATE_OP;
|
||||
break;
|
||||
default:
|
||||
ret = -EAGAIN;
|
||||
error = -EAGAIN;
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
@@ -468,7 +467,7 @@ static int cyapa_get_state(struct cyapa *cyapa)
|
||||
|
||||
return 0;
|
||||
error:
|
||||
return (ret < 0) ? ret : -EAGAIN;
|
||||
return (error < 0) ? error : -EAGAIN;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -487,31 +486,31 @@ error:
|
||||
*/
|
||||
static int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout)
|
||||
{
|
||||
int ret;
|
||||
int error;
|
||||
int tries = timeout / 100;
|
||||
|
||||
ret = cyapa_get_state(cyapa);
|
||||
while ((ret || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) {
|
||||
error = cyapa_get_state(cyapa);
|
||||
while ((error || cyapa->state >= CYAPA_STATE_BL_BUSY) && tries--) {
|
||||
msleep(100);
|
||||
ret = cyapa_get_state(cyapa);
|
||||
error = cyapa_get_state(cyapa);
|
||||
}
|
||||
return (ret == -EAGAIN || ret == -ETIMEDOUT) ? -ETIMEDOUT : ret;
|
||||
return (error == -EAGAIN || error == -ETIMEDOUT) ? -ETIMEDOUT : error;
|
||||
}
|
||||
|
||||
static int cyapa_bl_deactivate(struct cyapa *cyapa)
|
||||
{
|
||||
int ret;
|
||||
int error;
|
||||
|
||||
ret = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate),
|
||||
bl_deactivate);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate),
|
||||
bl_deactivate);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* wait for bootloader to switch to idle state; should take < 100ms */
|
||||
msleep(100);
|
||||
ret = cyapa_poll_state(cyapa, 500);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
error = cyapa_poll_state(cyapa, 500);
|
||||
if (error)
|
||||
return error;
|
||||
if (cyapa->state != CYAPA_STATE_BL_IDLE)
|
||||
return -EAGAIN;
|
||||
return 0;
|
||||
@@ -532,11 +531,11 @@ static int cyapa_bl_deactivate(struct cyapa *cyapa)
|
||||
*/
|
||||
static int cyapa_bl_exit(struct cyapa *cyapa)
|
||||
{
|
||||
int ret;
|
||||
int error;
|
||||
|
||||
ret = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/*
|
||||
* Wait for bootloader to exit, and operation mode to start.
|
||||
@@ -548,9 +547,9 @@ static int cyapa_bl_exit(struct cyapa *cyapa)
|
||||
* updated to new firmware, it must first calibrate its sensors, which
|
||||
* can take up to an additional 2 seconds.
|
||||
*/
|
||||
ret = cyapa_poll_state(cyapa, 2000);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
error = cyapa_poll_state(cyapa, 2000);
|
||||
if (error < 0)
|
||||
return error;
|
||||
if (cyapa->state != CYAPA_STATE_OP)
|
||||
return -EAGAIN;
|
||||
|
||||
@@ -577,10 +576,13 @@ static int cyapa_set_power_mode(struct cyapa *cyapa, u8 power_mode)
|
||||
power = ret & ~PWR_MODE_MASK;
|
||||
power |= power_mode & PWR_MODE_MASK;
|
||||
ret = cyapa_write_byte(cyapa, CYAPA_CMD_POWER_MODE, power);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to set power_mode 0x%02x err = %d\n",
|
||||
power_mode, ret);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cyapa_get_query_data(struct cyapa *cyapa)
|
||||
@@ -637,28 +639,28 @@ static int cyapa_check_is_operational(struct cyapa *cyapa)
|
||||
{
|
||||
struct device *dev = &cyapa->client->dev;
|
||||
static const char unique_str[] = "CYTRA";
|
||||
int ret;
|
||||
int error;
|
||||
|
||||
ret = cyapa_poll_state(cyapa, 2000);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
error = cyapa_poll_state(cyapa, 2000);
|
||||
if (error)
|
||||
return error;
|
||||
switch (cyapa->state) {
|
||||
case CYAPA_STATE_BL_ACTIVE:
|
||||
ret = cyapa_bl_deactivate(cyapa);
|
||||
if (ret)
|
||||
return ret;
|
||||
error = cyapa_bl_deactivate(cyapa);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Fallthrough state */
|
||||
case CYAPA_STATE_BL_IDLE:
|
||||
ret = cyapa_bl_exit(cyapa);
|
||||
if (ret)
|
||||
return ret;
|
||||
error = cyapa_bl_exit(cyapa);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Fallthrough state */
|
||||
case CYAPA_STATE_OP:
|
||||
ret = cyapa_get_query_data(cyapa);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
error = cyapa_get_query_data(cyapa);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* only support firmware protocol gen3 */
|
||||
if (cyapa->gen != CYAPA_GEN3) {
|
||||
@@ -753,18 +755,42 @@ static u8 cyapa_check_adapter_functionality(struct i2c_client *client)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cyapa_open(struct input_dev *input)
|
||||
{
|
||||
struct cyapa *cyapa = input_get_drvdata(input);
|
||||
struct i2c_client *client = cyapa->client;
|
||||
int error;
|
||||
|
||||
error = cyapa_set_power_mode(cyapa, PWR_MODE_FULL_ACTIVE);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "set active power failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
enable_irq(client->irq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cyapa_close(struct input_dev *input)
|
||||
{
|
||||
struct cyapa *cyapa = input_get_drvdata(input);
|
||||
|
||||
disable_irq(cyapa->client->irq);
|
||||
cyapa_set_power_mode(cyapa, PWR_MODE_OFF);
|
||||
}
|
||||
|
||||
static int cyapa_create_input_dev(struct cyapa *cyapa)
|
||||
{
|
||||
struct device *dev = &cyapa->client->dev;
|
||||
int ret;
|
||||
struct input_dev *input;
|
||||
int error;
|
||||
|
||||
if (!cyapa->physical_size_x || !cyapa->physical_size_y)
|
||||
return -EINVAL;
|
||||
|
||||
input = cyapa->input = input_allocate_device();
|
||||
input = devm_input_allocate_device(dev);
|
||||
if (!input) {
|
||||
dev_err(dev, "allocate memory for input device failed\n");
|
||||
dev_err(dev, "failed to allocate memory for input device.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -772,14 +798,17 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
|
||||
input->phys = cyapa->phys;
|
||||
input->id.bustype = BUS_I2C;
|
||||
input->id.version = 1;
|
||||
input->id.product = 0; /* means any product in eventcomm. */
|
||||
input->id.product = 0; /* Means any product in eventcomm. */
|
||||
input->dev.parent = &cyapa->client->dev;
|
||||
|
||||
input->open = cyapa_open;
|
||||
input->close = cyapa_close;
|
||||
|
||||
input_set_drvdata(input, cyapa);
|
||||
|
||||
__set_bit(EV_ABS, input->evbit);
|
||||
|
||||
/* finger position */
|
||||
/* Finger position */
|
||||
input_set_abs_params(input, ABS_MT_POSITION_X, 0, cyapa->max_abs_x, 0,
|
||||
0);
|
||||
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cyapa->max_abs_y, 0,
|
||||
@@ -801,35 +830,25 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
|
||||
if (cyapa->btn_capability == CAPABILITY_LEFT_BTN_MASK)
|
||||
__set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
|
||||
|
||||
/* handle pointer emulation and unused slots in core */
|
||||
ret = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS,
|
||||
INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED);
|
||||
if (ret) {
|
||||
dev_err(dev, "allocate memory for MT slots failed, %d\n", ret);
|
||||
goto err_free_device;
|
||||
/* Handle pointer emulation and unused slots in core */
|
||||
error = input_mt_init_slots(input, CYAPA_MAX_MT_SLOTS,
|
||||
INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to initialize MT slots: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Register the device in input subsystem */
|
||||
ret = input_register_device(input);
|
||||
if (ret) {
|
||||
dev_err(dev, "input device register failed, %d\n", ret);
|
||||
goto err_free_device;
|
||||
}
|
||||
cyapa->input = input;
|
||||
return 0;
|
||||
|
||||
err_free_device:
|
||||
input_free_device(input);
|
||||
cyapa->input = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cyapa_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
int ret;
|
||||
u8 adapter_func;
|
||||
struct cyapa *cyapa;
|
||||
struct device *dev = &client->dev;
|
||||
struct cyapa *cyapa;
|
||||
u8 adapter_func;
|
||||
int error;
|
||||
|
||||
adapter_func = cyapa_check_adapter_functionality(client);
|
||||
if (adapter_func == CYAPA_ADAPTER_FUNC_NONE) {
|
||||
@@ -837,11 +856,9 @@ static int cyapa_probe(struct i2c_client *client,
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
cyapa = kzalloc(sizeof(struct cyapa), GFP_KERNEL);
|
||||
if (!cyapa) {
|
||||
dev_err(dev, "allocate memory for cyapa failed\n");
|
||||
cyapa = devm_kzalloc(dev, sizeof(struct cyapa), GFP_KERNEL);
|
||||
if (!cyapa)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cyapa->gen = CYAPA_GEN3;
|
||||
cyapa->client = client;
|
||||
@@ -852,67 +869,61 @@ static int cyapa_probe(struct i2c_client *client,
|
||||
/* i2c isn't supported, use smbus */
|
||||
if (adapter_func == CYAPA_ADAPTER_FUNC_SMBUS)
|
||||
cyapa->smbus = true;
|
||||
|
||||
cyapa->state = CYAPA_STATE_NO_DEVICE;
|
||||
ret = cyapa_check_is_operational(cyapa);
|
||||
if (ret) {
|
||||
dev_err(dev, "device not operational, %d\n", ret);
|
||||
goto err_mem_free;
|
||||
|
||||
error = cyapa_check_is_operational(cyapa);
|
||||
if (error) {
|
||||
dev_err(dev, "device not operational, %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
ret = cyapa_create_input_dev(cyapa);
|
||||
if (ret) {
|
||||
dev_err(dev, "create input_dev instance failed, %d\n", ret);
|
||||
goto err_mem_free;
|
||||
/* Power down the device until we need it */
|
||||
error = cyapa_set_power_mode(cyapa, PWR_MODE_OFF);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to quiesce the device: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
ret = cyapa_set_power_mode(cyapa, PWR_MODE_FULL_ACTIVE);
|
||||
if (ret) {
|
||||
dev_err(dev, "set active power failed, %d\n", ret);
|
||||
goto err_unregister_device;
|
||||
error = cyapa_create_input_dev(cyapa);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = devm_request_threaded_irq(dev, client->irq,
|
||||
NULL, cyapa_irq,
|
||||
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
|
||||
"cyapa", cyapa);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to request threaded irq: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
cyapa->irq = client->irq;
|
||||
ret = request_threaded_irq(cyapa->irq,
|
||||
NULL,
|
||||
cyapa_irq,
|
||||
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
|
||||
"cyapa",
|
||||
cyapa);
|
||||
if (ret) {
|
||||
dev_err(dev, "IRQ request failed: %d\n, ", ret);
|
||||
goto err_unregister_device;
|
||||
/* Disable IRQ until the device is opened */
|
||||
disable_irq(client->irq);
|
||||
|
||||
/* Register the device in input subsystem */
|
||||
error = input_register_device(cyapa->input);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to register input device: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister_device:
|
||||
input_unregister_device(cyapa->input);
|
||||
err_mem_free:
|
||||
kfree(cyapa);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cyapa_remove(struct i2c_client *client)
|
||||
static int __maybe_unused cyapa_suspend(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cyapa *cyapa = i2c_get_clientdata(client);
|
||||
|
||||
free_irq(cyapa->irq, cyapa);
|
||||
input_unregister_device(cyapa->input);
|
||||
cyapa_set_power_mode(cyapa, PWR_MODE_OFF);
|
||||
kfree(cyapa);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int cyapa_suspend(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct input_dev *input = cyapa->input;
|
||||
u8 power_mode;
|
||||
struct cyapa *cyapa = dev_get_drvdata(dev);
|
||||
int error;
|
||||
|
||||
disable_irq(cyapa->irq);
|
||||
error = mutex_lock_interruptible(&input->mutex);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
disable_irq(client->irq);
|
||||
|
||||
/*
|
||||
* Set trackpad device to idle mode if wakeup is allowed,
|
||||
@@ -920,31 +931,44 @@ static int cyapa_suspend(struct device *dev)
|
||||
*/
|
||||
power_mode = device_may_wakeup(dev) ? PWR_MODE_IDLE
|
||||
: PWR_MODE_OFF;
|
||||
ret = cyapa_set_power_mode(cyapa, power_mode);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "set power mode failed, %d\n", ret);
|
||||
error = cyapa_set_power_mode(cyapa, power_mode);
|
||||
if (error)
|
||||
dev_err(dev, "resume: set power mode to %d failed: %d\n",
|
||||
power_mode, error);
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
cyapa->irq_wake = (enable_irq_wake(cyapa->irq) == 0);
|
||||
cyapa->irq_wake = (enable_irq_wake(client->irq) == 0);
|
||||
|
||||
mutex_unlock(&input->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cyapa_resume(struct device *dev)
|
||||
static int __maybe_unused cyapa_resume(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct cyapa *cyapa = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cyapa *cyapa = i2c_get_clientdata(client);
|
||||
struct input_dev *input = cyapa->input;
|
||||
u8 power_mode;
|
||||
int error;
|
||||
|
||||
mutex_lock(&input->mutex);
|
||||
|
||||
if (device_may_wakeup(dev) && cyapa->irq_wake)
|
||||
disable_irq_wake(cyapa->irq);
|
||||
disable_irq_wake(client->irq);
|
||||
|
||||
ret = cyapa_set_power_mode(cyapa, PWR_MODE_FULL_ACTIVE);
|
||||
if (ret)
|
||||
dev_warn(dev, "resume active power failed, %d\n", ret);
|
||||
power_mode = input->users ? PWR_MODE_FULL_ACTIVE : PWR_MODE_OFF;
|
||||
error = cyapa_set_power_mode(cyapa, PWR_MODE_FULL_ACTIVE);
|
||||
if (error)
|
||||
dev_warn(dev, "resume: set power mode to %d failed: %d\n",
|
||||
power_mode, error);
|
||||
|
||||
enable_irq(client->irq);
|
||||
|
||||
mutex_unlock(&input->mutex);
|
||||
|
||||
enable_irq(cyapa->irq);
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(cyapa_pm_ops, cyapa_suspend, cyapa_resume);
|
||||
|
||||
@@ -962,7 +986,6 @@ static struct i2c_driver cyapa_driver = {
|
||||
},
|
||||
|
||||
.probe = cyapa_probe,
|
||||
.remove = cyapa_remove,
|
||||
.id_table = cyapa_id_table,
|
||||
};
|
||||
|
||||
|
86
drivers/input/mouse/elan_i2c.h
Normal file
86
drivers/input/mouse/elan_i2c.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Elan I2C/SMBus Touchpad driver
|
||||
*
|
||||
* Copyright (c) 2013 ELAN Microelectronics Corp.
|
||||
*
|
||||
* Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
|
||||
* Version: 1.5.5
|
||||
*
|
||||
* Based on cyapa driver:
|
||||
* copyright (c) 2011-2012 Cypress Semiconductor, Inc.
|
||||
* copyright (c) 2011-2012 Google, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Trademarks are the property of their respective owners.
|
||||
*/
|
||||
|
||||
#ifndef _ELAN_I2C_H
|
||||
#define _ELAN_i2C_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#define ETP_ENABLE_ABS 0x0001
|
||||
#define ETP_ENABLE_CALIBRATE 0x0002
|
||||
#define ETP_DISABLE_CALIBRATE 0x0000
|
||||
#define ETP_DISABLE_POWER 0x0001
|
||||
|
||||
/* IAP Firmware handling */
|
||||
#define ETP_FW_NAME "elan_i2c.bin"
|
||||
#define ETP_IAP_START_ADDR 0x0083
|
||||
#define ETP_FW_IAP_PAGE_ERR (1 << 5)
|
||||
#define ETP_FW_IAP_INTF_ERR (1 << 4)
|
||||
#define ETP_FW_PAGE_SIZE 64
|
||||
#define ETP_FW_PAGE_COUNT 768
|
||||
#define ETP_FW_SIZE (ETP_FW_PAGE_SIZE * ETP_FW_PAGE_COUNT)
|
||||
|
||||
struct i2c_client;
|
||||
struct completion;
|
||||
|
||||
enum tp_mode {
|
||||
IAP_MODE = 1,
|
||||
MAIN_MODE
|
||||
};
|
||||
|
||||
struct elan_transport_ops {
|
||||
int (*initialize)(struct i2c_client *client);
|
||||
int (*sleep_control)(struct i2c_client *, bool sleep);
|
||||
int (*power_control)(struct i2c_client *, bool enable);
|
||||
int (*set_mode)(struct i2c_client *client, u8 mode);
|
||||
|
||||
int (*calibrate)(struct i2c_client *client);
|
||||
int (*calibrate_result)(struct i2c_client *client, u8 *val);
|
||||
|
||||
int (*get_baseline_data)(struct i2c_client *client,
|
||||
bool max_baseliune, u8 *value);
|
||||
|
||||
int (*get_version)(struct i2c_client *client, bool iap, u8 *version);
|
||||
int (*get_sm_version)(struct i2c_client *client, u8 *version);
|
||||
int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
|
||||
int (*get_product_id)(struct i2c_client *client, u8 *id);
|
||||
|
||||
int (*get_max)(struct i2c_client *client,
|
||||
unsigned int *max_x, unsigned int *max_y);
|
||||
int (*get_resolution)(struct i2c_client *client,
|
||||
u8 *hw_res_x, u8 *hw_res_y);
|
||||
int (*get_num_traces)(struct i2c_client *client,
|
||||
unsigned int *x_tracenum,
|
||||
unsigned int *y_tracenum);
|
||||
|
||||
int (*iap_get_mode)(struct i2c_client *client, enum tp_mode *mode);
|
||||
int (*iap_reset)(struct i2c_client *client);
|
||||
|
||||
int (*prepare_fw_update)(struct i2c_client *client);
|
||||
int (*write_fw_block)(struct i2c_client *client,
|
||||
const u8 *page, u16 checksum, int idx);
|
||||
int (*finish_fw_update)(struct i2c_client *client,
|
||||
struct completion *reset_done);
|
||||
|
||||
int (*get_report)(struct i2c_client *client, u8 *report);
|
||||
};
|
||||
|
||||
extern const struct elan_transport_ops elan_smbus_ops, elan_i2c_ops;
|
||||
|
||||
#endif /* _ELAN_I2C_H */
|
1137
drivers/input/mouse/elan_i2c_core.c
Normal file
1137
drivers/input/mouse/elan_i2c_core.c
Normal file
File diff suppressed because it is too large
Load Diff
611
drivers/input/mouse/elan_i2c_i2c.c
Normal file
611
drivers/input/mouse/elan_i2c_i2c.c
Normal file
@@ -0,0 +1,611 @@
|
||||
/*
|
||||
* Elan I2C/SMBus Touchpad driver - I2C interface
|
||||
*
|
||||
* Copyright (c) 2013 ELAN Microelectronics Corp.
|
||||
*
|
||||
* Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
|
||||
* Version: 1.5.5
|
||||
*
|
||||
* Based on cyapa driver:
|
||||
* copyright (c) 2011-2012 Cypress Semiconductor, Inc.
|
||||
* copyright (c) 2011-2012 Google, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Trademarks are the property of their respective owners.
|
||||
*/
|
||||
|
||||
#include <linux/completion.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/sched.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
#include "elan_i2c.h"
|
||||
|
||||
/* Elan i2c commands */
|
||||
#define ETP_I2C_RESET 0x0100
|
||||
#define ETP_I2C_WAKE_UP 0x0800
|
||||
#define ETP_I2C_SLEEP 0x0801
|
||||
#define ETP_I2C_DESC_CMD 0x0001
|
||||
#define ETP_I2C_REPORT_DESC_CMD 0x0002
|
||||
#define ETP_I2C_STAND_CMD 0x0005
|
||||
#define ETP_I2C_UNIQUEID_CMD 0x0101
|
||||
#define ETP_I2C_FW_VERSION_CMD 0x0102
|
||||
#define ETP_I2C_SM_VERSION_CMD 0x0103
|
||||
#define ETP_I2C_XY_TRACENUM_CMD 0x0105
|
||||
#define ETP_I2C_MAX_X_AXIS_CMD 0x0106
|
||||
#define ETP_I2C_MAX_Y_AXIS_CMD 0x0107
|
||||
#define ETP_I2C_RESOLUTION_CMD 0x0108
|
||||
#define ETP_I2C_IAP_VERSION_CMD 0x0110
|
||||
#define ETP_I2C_SET_CMD 0x0300
|
||||
#define ETP_I2C_POWER_CMD 0x0307
|
||||
#define ETP_I2C_FW_CHECKSUM_CMD 0x030F
|
||||
#define ETP_I2C_IAP_CTRL_CMD 0x0310
|
||||
#define ETP_I2C_IAP_CMD 0x0311
|
||||
#define ETP_I2C_IAP_RESET_CMD 0x0314
|
||||
#define ETP_I2C_IAP_CHECKSUM_CMD 0x0315
|
||||
#define ETP_I2C_CALIBRATE_CMD 0x0316
|
||||
#define ETP_I2C_MAX_BASELINE_CMD 0x0317
|
||||
#define ETP_I2C_MIN_BASELINE_CMD 0x0318
|
||||
|
||||
#define ETP_I2C_REPORT_LEN 34
|
||||
#define ETP_I2C_DESC_LENGTH 30
|
||||
#define ETP_I2C_REPORT_DESC_LENGTH 158
|
||||
#define ETP_I2C_INF_LENGTH 2
|
||||
#define ETP_I2C_IAP_PASSWORD 0x1EA5
|
||||
#define ETP_I2C_IAP_RESET 0xF0F0
|
||||
#define ETP_I2C_MAIN_MODE_ON (1 << 9)
|
||||
#define ETP_I2C_IAP_REG_L 0x01
|
||||
#define ETP_I2C_IAP_REG_H 0x06
|
||||
|
||||
static int elan_i2c_read_block(struct i2c_client *client,
|
||||
u16 reg, u8 *val, u16 len)
|
||||
{
|
||||
__le16 buf[] = {
|
||||
cpu_to_le16(reg),
|
||||
};
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
.addr = client->addr,
|
||||
.flags = client->flags & I2C_M_TEN,
|
||||
.len = sizeof(buf),
|
||||
.buf = (u8 *)buf,
|
||||
},
|
||||
{
|
||||
.addr = client->addr,
|
||||
.flags = (client->flags & I2C_M_TEN) | I2C_M_RD,
|
||||
.len = len,
|
||||
.buf = val,
|
||||
}
|
||||
};
|
||||
int ret;
|
||||
|
||||
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
|
||||
return ret == ARRAY_SIZE(msgs) ? 0 : (ret < 0 ? ret : -EIO);
|
||||
}
|
||||
|
||||
static int elan_i2c_read_cmd(struct i2c_client *client, u16 reg, u8 *val)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = elan_i2c_read_block(client, reg, val, ETP_I2C_INF_LENGTH);
|
||||
if (retval < 0) {
|
||||
dev_err(&client->dev, "reading cmd (0x%04x) fail.\n", reg);
|
||||
return retval;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_write_cmd(struct i2c_client *client, u16 reg, u16 cmd)
|
||||
{
|
||||
__le16 buf[] = {
|
||||
cpu_to_le16(reg),
|
||||
cpu_to_le16(cmd),
|
||||
};
|
||||
struct i2c_msg msg = {
|
||||
.addr = client->addr,
|
||||
.flags = client->flags & I2C_M_TEN,
|
||||
.len = sizeof(buf),
|
||||
.buf = (u8 *)buf,
|
||||
};
|
||||
int ret;
|
||||
|
||||
ret = i2c_transfer(client->adapter, &msg, 1);
|
||||
return ret == 1 ? 0 : (ret < 0 ? ret : -EIO);
|
||||
}
|
||||
|
||||
static int elan_i2c_initialize(struct i2c_client *client)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
int error;
|
||||
u8 val[256];
|
||||
|
||||
error = elan_i2c_write_cmd(client, ETP_I2C_STAND_CMD, ETP_I2C_RESET);
|
||||
if (error) {
|
||||
dev_err(dev, "device reset failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Wait for the device to reset */
|
||||
msleep(100);
|
||||
|
||||
/* get reset acknowledgement 0000 */
|
||||
error = i2c_master_recv(client, val, ETP_I2C_INF_LENGTH);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "failed to read reset response: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = elan_i2c_read_block(client, ETP_I2C_DESC_CMD,
|
||||
val, ETP_I2C_DESC_LENGTH);
|
||||
if (error) {
|
||||
dev_err(dev, "cannot get device descriptor: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = elan_i2c_read_block(client, ETP_I2C_REPORT_DESC_CMD,
|
||||
val, ETP_I2C_REPORT_DESC_LENGTH);
|
||||
if (error) {
|
||||
dev_err(dev, "fetching report descriptor failed.: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_sleep_control(struct i2c_client *client, bool sleep)
|
||||
{
|
||||
return elan_i2c_write_cmd(client, ETP_I2C_STAND_CMD,
|
||||
sleep ? ETP_I2C_SLEEP : ETP_I2C_WAKE_UP);
|
||||
}
|
||||
|
||||
static int elan_i2c_power_control(struct i2c_client *client, bool enable)
|
||||
{
|
||||
u8 val[2];
|
||||
u16 reg;
|
||||
int error;
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_POWER_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev,
|
||||
"failed to read current power state: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
reg = le16_to_cpup((__le16 *)val);
|
||||
if (enable)
|
||||
reg &= ~ETP_DISABLE_POWER;
|
||||
else
|
||||
reg |= ETP_DISABLE_POWER;
|
||||
|
||||
error = elan_i2c_write_cmd(client, ETP_I2C_POWER_CMD, reg);
|
||||
if (error) {
|
||||
dev_err(&client->dev,
|
||||
"failed to write current power state: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_set_mode(struct i2c_client *client, u8 mode)
|
||||
{
|
||||
return elan_i2c_write_cmd(client, ETP_I2C_SET_CMD, mode);
|
||||
}
|
||||
|
||||
|
||||
static int elan_i2c_calibrate(struct i2c_client *client)
|
||||
{
|
||||
return elan_i2c_write_cmd(client, ETP_I2C_CALIBRATE_CMD, 1);
|
||||
}
|
||||
|
||||
static int elan_i2c_calibrate_result(struct i2c_client *client, u8 *val)
|
||||
{
|
||||
return elan_i2c_read_block(client, ETP_I2C_CALIBRATE_CMD, val, 1);
|
||||
}
|
||||
|
||||
static int elan_i2c_get_baseline_data(struct i2c_client *client,
|
||||
bool max_baseline, u8 *value)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client,
|
||||
max_baseline ? ETP_I2C_MAX_BASELINE_CMD :
|
||||
ETP_I2C_MIN_BASELINE_CMD,
|
||||
val);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
*value = le16_to_cpup((__le16 *)val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_version(struct i2c_client *client,
|
||||
bool iap, u8 *version)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client,
|
||||
iap ? ETP_I2C_IAP_VERSION_CMD :
|
||||
ETP_I2C_FW_VERSION_CMD,
|
||||
val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get %s version: %d\n",
|
||||
iap ? "IAP" : "FW", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*version = val[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *version)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_SM_VERSION_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get SM version: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*version = val[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_product_id(struct i2c_client *client, u8 *id)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_UNIQUEID_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get product ID: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*id = val[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_checksum(struct i2c_client *client,
|
||||
bool iap, u16 *csum)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client,
|
||||
iap ? ETP_I2C_IAP_CHECKSUM_CMD :
|
||||
ETP_I2C_FW_CHECKSUM_CMD,
|
||||
val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get %s checksum: %d\n",
|
||||
iap ? "IAP" : "FW", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*csum = le16_to_cpup((__le16 *)val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_max(struct i2c_client *client,
|
||||
unsigned int *max_x, unsigned int *max_y)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_MAX_X_AXIS_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get X dimension: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*max_x = le16_to_cpup((__le16 *)val) & 0x0fff;
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_MAX_Y_AXIS_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get Y dimension: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*max_y = le16_to_cpup((__le16 *)val) & 0x0fff;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_resolution(struct i2c_client *client,
|
||||
u8 *hw_res_x, u8 *hw_res_y)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_RESOLUTION_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get resolution: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*hw_res_x = val[0];
|
||||
*hw_res_y = val[1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_num_traces(struct i2c_client *client,
|
||||
unsigned int *x_traces,
|
||||
unsigned int *y_traces)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_XY_TRACENUM_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get trace info: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*x_traces = val[0] - 1;
|
||||
*y_traces = val[1] - 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_iap_get_mode(struct i2c_client *client, enum tp_mode *mode)
|
||||
{
|
||||
int error;
|
||||
u16 constant;
|
||||
u8 val[3];
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_IAP_CTRL_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev,
|
||||
"failed to read iap control register: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
constant = le16_to_cpup((__le16 *)val);
|
||||
dev_dbg(&client->dev, "iap control reg: 0x%04x.\n", constant);
|
||||
|
||||
*mode = (constant & ETP_I2C_MAIN_MODE_ON) ? MAIN_MODE : IAP_MODE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_iap_reset(struct i2c_client *client)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = elan_i2c_write_cmd(client, ETP_I2C_IAP_RESET_CMD,
|
||||
ETP_I2C_IAP_RESET);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "cannot reset IC: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_set_flash_key(struct i2c_client *client)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = elan_i2c_write_cmd(client, ETP_I2C_IAP_CMD,
|
||||
ETP_I2C_IAP_PASSWORD);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "cannot set flash key: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_prepare_fw_update(struct i2c_client *client)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
int error;
|
||||
enum tp_mode mode;
|
||||
u8 val[3];
|
||||
u16 password;
|
||||
|
||||
/* Get FW in which mode (IAP_MODE/MAIN_MODE) */
|
||||
error = elan_i2c_iap_get_mode(client, &mode);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (mode == IAP_MODE) {
|
||||
/* Reset IC */
|
||||
error = elan_i2c_iap_reset(client);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
msleep(30);
|
||||
}
|
||||
|
||||
/* Set flash key*/
|
||||
error = elan_i2c_set_flash_key(client);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Wait for F/W IAP initialization */
|
||||
msleep(mode == MAIN_MODE ? 100 : 30);
|
||||
|
||||
/* Check if we are in IAP mode or not */
|
||||
error = elan_i2c_iap_get_mode(client, &mode);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (mode == MAIN_MODE) {
|
||||
dev_err(dev, "wrong mode: %d\n", mode);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Set flash key again */
|
||||
error = elan_i2c_set_flash_key(client);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Wait for F/W IAP initialization */
|
||||
msleep(30);
|
||||
|
||||
/* read back to check we actually enabled successfully. */
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_IAP_CMD, val);
|
||||
if (error) {
|
||||
dev_err(dev, "cannot read iap password: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
password = le16_to_cpup((__le16 *)val);
|
||||
if (password != ETP_I2C_IAP_PASSWORD) {
|
||||
dev_err(dev, "wrong iap password: 0x%X\n", password);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_write_fw_block(struct i2c_client *client,
|
||||
const u8 *page, u16 checksum, int idx)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
u8 page_store[ETP_FW_PAGE_SIZE + 4];
|
||||
u8 val[3];
|
||||
u16 result;
|
||||
int ret, error;
|
||||
|
||||
page_store[0] = ETP_I2C_IAP_REG_L;
|
||||
page_store[1] = ETP_I2C_IAP_REG_H;
|
||||
memcpy(&page_store[2], page, ETP_FW_PAGE_SIZE);
|
||||
/* recode checksum at last two bytes */
|
||||
put_unaligned_le16(checksum, &page_store[ETP_FW_PAGE_SIZE + 2]);
|
||||
|
||||
ret = i2c_master_send(client, page_store, sizeof(page_store));
|
||||
if (ret != sizeof(page_store)) {
|
||||
error = ret < 0 ? ret : -EIO;
|
||||
dev_err(dev, "Failed to write page %d: %d\n", idx, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Wait for F/W to update one page ROM data. */
|
||||
msleep(20);
|
||||
|
||||
error = elan_i2c_read_cmd(client, ETP_I2C_IAP_CTRL_CMD, val);
|
||||
if (error) {
|
||||
dev_err(dev, "Failed to read IAP write result: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
result = le16_to_cpup((__le16 *)val);
|
||||
if (result & (ETP_FW_IAP_PAGE_ERR | ETP_FW_IAP_INTF_ERR)) {
|
||||
dev_err(dev, "IAP reports failed write: %04hx\n",
|
||||
result);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_finish_fw_update(struct i2c_client *client,
|
||||
struct completion *completion)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
long ret;
|
||||
int error;
|
||||
int len;
|
||||
u8 buffer[ETP_I2C_INF_LENGTH];
|
||||
|
||||
reinit_completion(completion);
|
||||
enable_irq(client->irq);
|
||||
|
||||
error = elan_i2c_write_cmd(client, ETP_I2C_STAND_CMD, ETP_I2C_RESET);
|
||||
if (!error)
|
||||
ret = wait_for_completion_interruptible_timeout(completion,
|
||||
msecs_to_jiffies(300));
|
||||
disable_irq(client->irq);
|
||||
|
||||
if (error) {
|
||||
dev_err(dev, "device reset failed: %d\n", error);
|
||||
return error;
|
||||
} else if (ret == 0) {
|
||||
dev_err(dev, "timeout waiting for device reset\n");
|
||||
return -ETIMEDOUT;
|
||||
} else if (ret < 0) {
|
||||
error = ret;
|
||||
dev_err(dev, "error waiting for device reset: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
len = i2c_master_recv(client, buffer, ETP_I2C_INF_LENGTH);
|
||||
if (len != ETP_I2C_INF_LENGTH) {
|
||||
error = len < 0 ? len : -EIO;
|
||||
dev_err(dev, "failed to read INT signal: %d (%d)\n",
|
||||
error, len);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_i2c_get_report(struct i2c_client *client, u8 *report)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = i2c_master_recv(client, report, ETP_I2C_REPORT_LEN);
|
||||
if (len < 0) {
|
||||
dev_err(&client->dev, "failed to read report data: %d\n", len);
|
||||
return len;
|
||||
}
|
||||
|
||||
if (len != ETP_I2C_REPORT_LEN) {
|
||||
dev_err(&client->dev,
|
||||
"wrong report length (%d vs %d expected)\n",
|
||||
len, ETP_I2C_REPORT_LEN);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct elan_transport_ops elan_i2c_ops = {
|
||||
.initialize = elan_i2c_initialize,
|
||||
.sleep_control = elan_i2c_sleep_control,
|
||||
.power_control = elan_i2c_power_control,
|
||||
.set_mode = elan_i2c_set_mode,
|
||||
|
||||
.calibrate = elan_i2c_calibrate,
|
||||
.calibrate_result = elan_i2c_calibrate_result,
|
||||
|
||||
.get_baseline_data = elan_i2c_get_baseline_data,
|
||||
|
||||
.get_version = elan_i2c_get_version,
|
||||
.get_sm_version = elan_i2c_get_sm_version,
|
||||
.get_product_id = elan_i2c_get_product_id,
|
||||
.get_checksum = elan_i2c_get_checksum,
|
||||
|
||||
.get_max = elan_i2c_get_max,
|
||||
.get_resolution = elan_i2c_get_resolution,
|
||||
.get_num_traces = elan_i2c_get_num_traces,
|
||||
|
||||
.iap_get_mode = elan_i2c_iap_get_mode,
|
||||
.iap_reset = elan_i2c_iap_reset,
|
||||
|
||||
.prepare_fw_update = elan_i2c_prepare_fw_update,
|
||||
.write_fw_block = elan_i2c_write_fw_block,
|
||||
.finish_fw_update = elan_i2c_finish_fw_update,
|
||||
|
||||
.get_report = elan_i2c_get_report,
|
||||
};
|
514
drivers/input/mouse/elan_i2c_smbus.c
Normal file
514
drivers/input/mouse/elan_i2c_smbus.c
Normal file
@@ -0,0 +1,514 @@
|
||||
/*
|
||||
* Elan I2C/SMBus Touchpad driver - SMBus interface
|
||||
*
|
||||
* Copyright (c) 2013 ELAN Microelectronics Corp.
|
||||
*
|
||||
* Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
|
||||
* Version: 1.5.5
|
||||
*
|
||||
* Based on cyapa driver:
|
||||
* copyright (c) 2011-2012 Cypress Semiconductor, Inc.
|
||||
* copyright (c) 2011-2012 Google, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Trademarks are the property of their respective owners.
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include "elan_i2c.h"
|
||||
|
||||
/* Elan SMbus commands */
|
||||
#define ETP_SMBUS_IAP_CMD 0x00
|
||||
#define ETP_SMBUS_ENABLE_TP 0x20
|
||||
#define ETP_SMBUS_SLEEP_CMD 0x21
|
||||
#define ETP_SMBUS_IAP_PASSWORD_WRITE 0x29
|
||||
#define ETP_SMBUS_IAP_PASSWORD_READ 0x80
|
||||
#define ETP_SMBUS_WRITE_FW_BLOCK 0x2A
|
||||
#define ETP_SMBUS_IAP_RESET_CMD 0x2B
|
||||
#define ETP_SMBUS_RANGE_CMD 0xA0
|
||||
#define ETP_SMBUS_FW_VERSION_CMD 0xA1
|
||||
#define ETP_SMBUS_XY_TRACENUM_CMD 0xA2
|
||||
#define ETP_SMBUS_SM_VERSION_CMD 0xA3
|
||||
#define ETP_SMBUS_UNIQUEID_CMD 0xA3
|
||||
#define ETP_SMBUS_RESOLUTION_CMD 0xA4
|
||||
#define ETP_SMBUS_HELLOPACKET_CMD 0xA7
|
||||
#define ETP_SMBUS_PACKET_QUERY 0xA8
|
||||
#define ETP_SMBUS_IAP_VERSION_CMD 0xAC
|
||||
#define ETP_SMBUS_IAP_CTRL_CMD 0xAD
|
||||
#define ETP_SMBUS_IAP_CHECKSUM_CMD 0xAE
|
||||
#define ETP_SMBUS_FW_CHECKSUM_CMD 0xAF
|
||||
#define ETP_SMBUS_MAX_BASELINE_CMD 0xC3
|
||||
#define ETP_SMBUS_MIN_BASELINE_CMD 0xC4
|
||||
#define ETP_SMBUS_CALIBRATE_QUERY 0xC5
|
||||
|
||||
#define ETP_SMBUS_REPORT_LEN 32
|
||||
#define ETP_SMBUS_REPORT_OFFSET 2
|
||||
#define ETP_SMBUS_HELLOPACKET_LEN 5
|
||||
#define ETP_SMBUS_IAP_PASSWORD 0x1234
|
||||
#define ETP_SMBUS_IAP_MODE_ON (1 << 6)
|
||||
|
||||
static int elan_smbus_initialize(struct i2c_client *client)
|
||||
{
|
||||
u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 };
|
||||
u8 values[ETP_SMBUS_HELLOPACKET_LEN] = { 0, 0, 0, 0, 0 };
|
||||
int len, error;
|
||||
|
||||
/* Get hello packet */
|
||||
len = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_HELLOPACKET_CMD, values);
|
||||
if (len != ETP_SMBUS_HELLOPACKET_LEN) {
|
||||
dev_err(&client->dev, "hello packet length fail: %d\n", len);
|
||||
error = len < 0 ? len : -EIO;
|
||||
return error;
|
||||
}
|
||||
|
||||
/* compare hello packet */
|
||||
if (memcmp(values, check, ETP_SMBUS_HELLOPACKET_LEN)) {
|
||||
dev_err(&client->dev, "hello packet fail [%*px]\n",
|
||||
ETP_SMBUS_HELLOPACKET_LEN, values);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
/* enable tp */
|
||||
error = i2c_smbus_write_byte(client, ETP_SMBUS_ENABLE_TP);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to enable touchpad: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_set_mode(struct i2c_client *client, u8 mode)
|
||||
{
|
||||
u8 cmd[4] = { 0x00, 0x07, 0x00, mode };
|
||||
|
||||
return i2c_smbus_write_block_data(client, ETP_SMBUS_IAP_CMD,
|
||||
sizeof(cmd), cmd);
|
||||
}
|
||||
|
||||
static int elan_smbus_sleep_control(struct i2c_client *client, bool sleep)
|
||||
{
|
||||
if (sleep)
|
||||
return i2c_smbus_write_byte(client, ETP_SMBUS_SLEEP_CMD);
|
||||
else
|
||||
return 0; /* XXX should we send ETP_SMBUS_ENABLE_TP here? */
|
||||
}
|
||||
|
||||
static int elan_smbus_power_control(struct i2c_client *client, bool enable)
|
||||
{
|
||||
return 0; /* A no-op */
|
||||
}
|
||||
|
||||
static int elan_smbus_calibrate(struct i2c_client *client)
|
||||
{
|
||||
u8 cmd[4] = { 0x00, 0x08, 0x00, 0x01 };
|
||||
|
||||
return i2c_smbus_write_block_data(client, ETP_SMBUS_IAP_CMD,
|
||||
sizeof(cmd), cmd);
|
||||
}
|
||||
|
||||
static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_CALIBRATE_QUERY, val);
|
||||
if (error < 0)
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_baseline_data(struct i2c_client *client,
|
||||
bool max_baseline, u8 *value)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
max_baseline ?
|
||||
ETP_SMBUS_MAX_BASELINE_CMD :
|
||||
ETP_SMBUS_MIN_BASELINE_CMD,
|
||||
val);
|
||||
if (error < 0)
|
||||
return error;
|
||||
|
||||
*value = be16_to_cpup((__be16 *)val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_version(struct i2c_client *client,
|
||||
bool iap, u8 *version)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
iap ? ETP_SMBUS_IAP_VERSION_CMD :
|
||||
ETP_SMBUS_FW_VERSION_CMD,
|
||||
val);
|
||||
if (error < 0) {
|
||||
dev_err(&client->dev, "failed to get %s version: %d\n",
|
||||
iap ? "IAP" : "FW", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*version = val[2];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *version)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_SM_VERSION_CMD, val);
|
||||
if (error < 0) {
|
||||
dev_err(&client->dev, "failed to get SM version: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*version = val[0]; /* XXX Why 0 and not 2 as in IAP/FW versions? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_product_id(struct i2c_client *client, u8 *id)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_UNIQUEID_CMD, val);
|
||||
if (error < 0) {
|
||||
dev_err(&client->dev, "failed to get product ID: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*id = val[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_checksum(struct i2c_client *client,
|
||||
bool iap, u16 *csum)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
iap ? ETP_SMBUS_FW_CHECKSUM_CMD :
|
||||
ETP_SMBUS_IAP_CHECKSUM_CMD,
|
||||
val);
|
||||
if (error < 0) {
|
||||
dev_err(&client->dev, "failed to get %s checksum: %d\n",
|
||||
iap ? "IAP" : "FW", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*csum = be16_to_cpup((__be16 *)val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_max(struct i2c_client *client,
|
||||
unsigned int *max_x, unsigned int *max_y)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client, ETP_SMBUS_RANGE_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get dimensions: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*max_x = (0x0f & val[0]) << 8 | val[1];
|
||||
*max_y = (0xf0 & val[0]) << 4 | val[2];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_resolution(struct i2c_client *client,
|
||||
u8 *hw_res_x, u8 *hw_res_y)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_RESOLUTION_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get resolution: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*hw_res_x = val[1] & 0x0F;
|
||||
*hw_res_y = (val[1] & 0xF0) >> 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_num_traces(struct i2c_client *client,
|
||||
unsigned int *x_traces,
|
||||
unsigned int *y_traces)
|
||||
{
|
||||
int error;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_XY_TRACENUM_CMD, val);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "failed to get trace info: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
*x_traces = val[1] - 1;
|
||||
*y_traces = val[2] - 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_iap_get_mode(struct i2c_client *client,
|
||||
enum tp_mode *mode)
|
||||
{
|
||||
int error;
|
||||
u16 constant;
|
||||
u8 val[3];
|
||||
|
||||
error = i2c_smbus_read_block_data(client, ETP_SMBUS_IAP_CTRL_CMD, val);
|
||||
if (error < 0) {
|
||||
dev_err(&client->dev, "failed to read iap ctrol register: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
constant = be16_to_cpup((__be16 *)val);
|
||||
dev_dbg(&client->dev, "iap control reg: 0x%04x.\n", constant);
|
||||
|
||||
*mode = (constant & ETP_SMBUS_IAP_MODE_ON) ? IAP_MODE : MAIN_MODE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_iap_reset(struct i2c_client *client)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = i2c_smbus_write_byte(client, ETP_SMBUS_IAP_RESET_CMD);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "cannot reset IC: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_set_flash_key(struct i2c_client *client)
|
||||
{
|
||||
int error;
|
||||
u8 cmd[4] = { 0x00, 0x0B, 0x00, 0x5A };
|
||||
|
||||
error = i2c_smbus_write_block_data(client, ETP_SMBUS_IAP_CMD,
|
||||
sizeof(cmd), cmd);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "cannot set flash key: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_prepare_fw_update(struct i2c_client *client)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
int len;
|
||||
int error;
|
||||
enum tp_mode mode;
|
||||
u8 val[3];
|
||||
u8 cmd[4] = {0x0F, 0x78, 0x00, 0x06};
|
||||
u16 password;
|
||||
|
||||
/* Get FW in which mode (IAP_MODE/MAIN_MODE) */
|
||||
error = elan_smbus_iap_get_mode(client, &mode);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (mode == MAIN_MODE) {
|
||||
|
||||
/* set flash key */
|
||||
error = elan_smbus_set_flash_key(client);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* write iap password */
|
||||
if (i2c_smbus_write_byte(client,
|
||||
ETP_SMBUS_IAP_PASSWORD_WRITE) < 0) {
|
||||
dev_err(dev, "cannot write iap password\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
error = i2c_smbus_write_block_data(client, ETP_SMBUS_IAP_CMD,
|
||||
sizeof(cmd), cmd);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to write iap password: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read back password to make sure we enabled flash
|
||||
* successfully.
|
||||
*/
|
||||
len = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_IAP_PASSWORD_READ,
|
||||
val);
|
||||
if (len < sizeof(u16)) {
|
||||
error = len < 0 ? len : -EIO;
|
||||
dev_err(dev, "failed to read iap password: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
password = be16_to_cpup((__be16 *)val);
|
||||
if (password != ETP_SMBUS_IAP_PASSWORD) {
|
||||
dev_err(dev, "wrong iap password = 0x%X\n", password);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Wait 30ms for MAIN_MODE change to IAP_MODE */
|
||||
msleep(30);
|
||||
}
|
||||
|
||||
error = elan_smbus_set_flash_key(client);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* Reset IC */
|
||||
error = elan_smbus_iap_reset(client);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int elan_smbus_write_fw_block(struct i2c_client *client,
|
||||
const u8 *page, u16 checksum, int idx)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
int error;
|
||||
u16 result;
|
||||
u8 val[3];
|
||||
|
||||
/*
|
||||
* Due to the limitation of smbus protocol limiting
|
||||
* transfer to 32 bytes at a time, we must split block
|
||||
* in 2 transfers.
|
||||
*/
|
||||
error = i2c_smbus_write_block_data(client,
|
||||
ETP_SMBUS_WRITE_FW_BLOCK,
|
||||
ETP_FW_PAGE_SIZE / 2,
|
||||
page);
|
||||
if (error) {
|
||||
dev_err(dev, "Failed to write page %d (part %d): %d\n",
|
||||
idx, 1, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = i2c_smbus_write_block_data(client,
|
||||
ETP_SMBUS_WRITE_FW_BLOCK,
|
||||
ETP_FW_PAGE_SIZE / 2,
|
||||
page + ETP_FW_PAGE_SIZE / 2);
|
||||
if (error) {
|
||||
dev_err(dev, "Failed to write page %d (part %d): %d\n",
|
||||
idx, 2, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* Wait for F/W to update one page ROM data. */
|
||||
usleep_range(8000, 10000);
|
||||
|
||||
error = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_IAP_CTRL_CMD, val);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "Failed to read IAP write result: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
result = be16_to_cpup((__be16 *)val);
|
||||
if (result & (ETP_FW_IAP_PAGE_ERR | ETP_FW_IAP_INTF_ERR)) {
|
||||
dev_err(dev, "IAP reports failed write: %04hx\n",
|
||||
result);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = i2c_smbus_read_block_data(client,
|
||||
ETP_SMBUS_PACKET_QUERY,
|
||||
&report[ETP_SMBUS_REPORT_OFFSET]);
|
||||
if (len < 0) {
|
||||
dev_err(&client->dev, "failed to read report data: %d\n", len);
|
||||
return len;
|
||||
}
|
||||
|
||||
if (len != ETP_SMBUS_REPORT_LEN) {
|
||||
dev_err(&client->dev,
|
||||
"wrong report length (%d vs %d expected)\n",
|
||||
len, ETP_SMBUS_REPORT_LEN);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int elan_smbus_finish_fw_update(struct i2c_client *client,
|
||||
struct completion *fw_completion)
|
||||
{
|
||||
/* No special handling unlike I2C transport */
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct elan_transport_ops elan_smbus_ops = {
|
||||
.initialize = elan_smbus_initialize,
|
||||
.sleep_control = elan_smbus_sleep_control,
|
||||
.power_control = elan_smbus_power_control,
|
||||
.set_mode = elan_smbus_set_mode,
|
||||
|
||||
.calibrate = elan_smbus_calibrate,
|
||||
.calibrate_result = elan_smbus_calibrate_result,
|
||||
|
||||
.get_baseline_data = elan_smbus_get_baseline_data,
|
||||
|
||||
.get_version = elan_smbus_get_version,
|
||||
.get_sm_version = elan_smbus_get_sm_version,
|
||||
.get_product_id = elan_smbus_get_product_id,
|
||||
.get_checksum = elan_smbus_get_checksum,
|
||||
|
||||
.get_max = elan_smbus_get_max,
|
||||
.get_resolution = elan_smbus_get_resolution,
|
||||
.get_num_traces = elan_smbus_get_num_traces,
|
||||
|
||||
.iap_get_mode = elan_smbus_iap_get_mode,
|
||||
.iap_reset = elan_smbus_iap_reset,
|
||||
|
||||
.prepare_fw_update = elan_smbus_prepare_fw_update,
|
||||
.write_fw_block = elan_smbus_write_fw_block,
|
||||
.finish_fw_update = elan_smbus_finish_fw_update,
|
||||
|
||||
.get_report = elan_smbus_get_report,
|
||||
};
|
@@ -16,14 +16,14 @@ void lifebook_module_init(void);
|
||||
int lifebook_detect(struct psmouse *psmouse, bool set_properties);
|
||||
int lifebook_init(struct psmouse *psmouse);
|
||||
#else
|
||||
inline void lifebook_module_init(void)
|
||||
static inline void lifebook_module_init(void)
|
||||
{
|
||||
}
|
||||
inline int lifebook_detect(struct psmouse *psmouse, bool set_properties)
|
||||
static inline int lifebook_detect(struct psmouse *psmouse, bool set_properties)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
inline int lifebook_init(struct psmouse *psmouse)
|
||||
static inline int lifebook_init(struct psmouse *psmouse)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
@@ -318,8 +318,7 @@ static int navpoint_remove(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int navpoint_suspend(struct device *dev)
|
||||
static int __maybe_unused navpoint_suspend(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct navpoint *navpoint = platform_get_drvdata(pdev);
|
||||
@@ -333,7 +332,7 @@ static int navpoint_suspend(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int navpoint_resume(struct device *dev)
|
||||
static int __maybe_unused navpoint_resume(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct navpoint *navpoint = platform_get_drvdata(pdev);
|
||||
@@ -346,7 +345,6 @@ static int navpoint_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(navpoint_pm_ops, navpoint_suspend, navpoint_resume);
|
||||
|
||||
|
@@ -614,8 +614,7 @@ static int synaptics_i2c_remove(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int synaptics_i2c_suspend(struct device *dev)
|
||||
static int __maybe_unused synaptics_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct synaptics_i2c *touch = i2c_get_clientdata(client);
|
||||
@@ -628,7 +627,7 @@ static int synaptics_i2c_suspend(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int synaptics_i2c_resume(struct device *dev)
|
||||
static int __maybe_unused synaptics_i2c_resume(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
@@ -643,7 +642,6 @@ static int synaptics_i2c_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(synaptics_i2c_pm, synaptics_i2c_suspend,
|
||||
synaptics_i2c_resume);
|
||||
|
Reference in New Issue
Block a user