Atmel MXT devices use different i2c addresses, depending on the current
mode of operation (bootloader or application). The Atmel MXT driver
expects i2c client's address contain the application address of the
chip, and calculates the expected bootloader address form the
application address. Unfortunately chrome_laptop does probe the devices
and if touchpad (or touchscreen, or both) comes up in bootloader mode
the i2c device gets instantiated with the bootloader address, instead of
application address, which confuses the driver.
Given that hardware on Pixel is set and is not going to change let's not
try to probe devices to see if they are present or not, but rather
instantiate them always at expected addresses.
Since all devices are now probed and/or instantiated at given address,
we no longer need to support probing multiple addresses for the same
device.
Signed-off-by: Dmitry Torokhov <[email protected]>
---
Olof,
We might want to mark this for stable as well as otherwise Pixel is
pretty broken if either touchpad or touchscreen resets to bootloader
mode.
Thanks,
Dmitry
drivers/platform/chrome/chromeos_laptop.c | 70 ++++++-------------------------
1 file changed, 13 insertions(+), 57 deletions(-)
diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index b84fdd6..57f1747 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -129,12 +129,12 @@ static struct i2c_board_info atmel_1664s_device = {
.flags = I2C_CLIENT_WAKE,
};
-static struct i2c_client *__add_probed_i2c_device(
- const char *name,
- int bus,
- struct i2c_board_info *info,
- const unsigned short *addrs)
+static struct i2c_client *add_i2c_device(const char *name,
+ int bus,
+ struct i2c_board_info *info,
+ bool probe)
{
+ const unsigned short addrs[] = { info->addr, I2C_CLIENT_END };
const struct dmi_device *dmi_dev;
const struct dmi_dev_onboard *dev_data;
struct i2c_adapter *adapter;
@@ -170,7 +170,8 @@ static struct i2c_client *__add_probed_i2c_device(
}
/* add the i2c device */
- client = i2c_new_probed_device(adapter, info, addrs, NULL);
+ client = probe ? i2c_new_probed_device(adapter, info, addrs, NULL) :
+ i2c_new_device(adapter, info);
if (!client)
pr_notice("%s failed to register device %d-%02x\n",
__func__, bus, info->addr);
@@ -225,78 +226,33 @@ static int find_i2c_adapter_num(enum i2c_adapter_type type)
return adapter->nr;
}
-/*
- * Takes a list of addresses in addrs as such :
- * { addr1, ... , addrn, I2C_CLIENT_END };
- * add_probed_i2c_device will use i2c_new_probed_device
- * and probe for devices at all of the addresses listed.
- * Returns NULL if no devices found.
- * See Documentation/i2c/instantiating-devices for more information.
- */
-static struct i2c_client *add_probed_i2c_device(
- const char *name,
- enum i2c_adapter_type type,
- struct i2c_board_info *info,
- const unsigned short *addrs)
-{
- return __add_probed_i2c_device(name,
- find_i2c_adapter_num(type),
- info,
- addrs);
-}
-
-/*
- * Probes for a device at a single address, the one provided by
- * info->addr.
- * Returns NULL if no device found.
- */
-static struct i2c_client *add_i2c_device(const char *name,
- enum i2c_adapter_type type,
- struct i2c_board_info *info)
-{
- const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
-
- return __add_probed_i2c_device(name,
- find_i2c_adapter_num(type),
- info,
- addr_list);
-}
-
static int setup_cyapa_tp(enum i2c_adapter_type type)
{
if (tp)
return 0;
/* add cyapa touchpad */
- tp = add_i2c_device("trackpad", type, &cyapa_device);
+ tp = add_i2c_device("trackpad", type, &cyapa_device, true);
return (!tp) ? -EAGAIN : 0;
}
static int setup_atmel_224s_tp(enum i2c_adapter_type type)
{
- const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR,
- ATMEL_TP_I2C_ADDR,
- I2C_CLIENT_END };
if (tp)
return 0;
/* add atmel mxt touchpad */
- tp = add_probed_i2c_device("trackpad", type,
- &atmel_224s_tp_device, addr_list);
+ tp = add_i2c_device("trackpad", type, &atmel_224s_tp_device, false);
return (!tp) ? -EAGAIN : 0;
}
static int setup_atmel_1664s_ts(enum i2c_adapter_type type)
{
- const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR,
- ATMEL_TS_I2C_ADDR,
- I2C_CLIENT_END };
if (ts)
return 0;
/* add atmel mxt touch device */
- ts = add_probed_i2c_device("touchscreen", type,
- &atmel_1664s_device, addr_list);
+ ts = add_i2c_device("touchscreen", type, &atmel_1664s_device, false);
return (!ts) ? -EAGAIN : 0;
}
@@ -306,7 +262,7 @@ static int setup_isl29018_als(enum i2c_adapter_type type)
return 0;
/* add isl29018 light sensor */
- als = add_i2c_device("lightsensor", type, &isl_als_device);
+ als = add_i2c_device("lightsensor", type, &isl_als_device, true);
return (!als) ? -EAGAIN : 0;
}
@@ -316,7 +272,7 @@ static int setup_tsl2583_als(enum i2c_adapter_type type)
return 0;
/* add tsl2583 light sensor */
- als = add_i2c_device(NULL, type, &tsl2583_als_device);
+ als = add_i2c_device(NULL, type, &tsl2583_als_device, true);
return (!als) ? -EAGAIN : 0;
}
@@ -326,7 +282,7 @@ static int setup_tsl2563_als(enum i2c_adapter_type type)
return 0;
/* add tsl2563 light sensor */
- als = add_i2c_device(NULL, type, &tsl2563_als_device);
+ als = add_i2c_device(NULL, type, &tsl2563_als_device, true);
return (!als) ? -EAGAIN : 0;
}
--
2.2.0.rc0.207.ga3a616c
--
Dmitry
On Thu, Apr 9, 2015 at 1:39 PM, Dmitry Torokhov
<[email protected]> wrote:
> Atmel MXT devices use different i2c addresses, depending on the current
> mode of operation (bootloader or application). The Atmel MXT driver
> expects i2c client's address contain the application address of the
> chip, and calculates the expected bootloader address form the
> application address. Unfortunately chrome_laptop does probe the devices
s/chrome_laptop/chromeos_laptop
> and if touchpad (or touchscreen, or both) comes up in bootloader mode
> the i2c device gets instantiated with the bootloader address, instead of
> application address, which confuses the driver.
>
> Given that hardware on Pixel is set and is not going to change let's not
> try to probe devices to see if they are present or not, but rather
> instantiate them always at expected addresses.
>
> Since all devices are now probed and/or instantiated at given address,
> we no longer need to support probing multiple addresses for the same
> device.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>
> ---
Also, since we no longer probe for the bootloader addresses, you
should remove the following two unused defines too :
#define ATMEL_TP_I2C_BL_ADDR 0x25
#define ATMEL_TS_I2C_BL_ADDR 0x26
Otherwise :
Reviewed-by: Benson Leung <[email protected]>
--
Benson Leung
Software Engineer, Chrom* OS
[email protected]