Commit 96cba9b0 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Olof Johansson

platform/chrome: chromeos_laptop - instantiate Atmel at primary address

The new Atmel MXT driver expects i2c client's address contain the
primary (main address) of the chip, and calculates the expected
bootloader address form the primary 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 which confuses the driver.

To work around this issue let's probe the primary address first. If the
device is not detected at the primary address we'll probe alternative
addresses as "dummy" devices. If any of them are found, destroy the
dummy client and instantiate client with proper name at primary address
still.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parent 8ce58093
...@@ -133,12 +133,13 @@ static struct i2c_client *__add_probed_i2c_device( ...@@ -133,12 +133,13 @@ static struct i2c_client *__add_probed_i2c_device(
const char *name, const char *name,
int bus, int bus,
struct i2c_board_info *info, struct i2c_board_info *info,
const unsigned short *addrs) const unsigned short *alt_addr_list)
{ {
const struct dmi_device *dmi_dev; const struct dmi_device *dmi_dev;
const struct dmi_dev_onboard *dev_data; const struct dmi_dev_onboard *dev_data;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_client *client; struct i2c_client *client = NULL;
const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
if (bus < 0) if (bus < 0)
return NULL; return NULL;
...@@ -169,8 +170,28 @@ static struct i2c_client *__add_probed_i2c_device( ...@@ -169,8 +170,28 @@ static struct i2c_client *__add_probed_i2c_device(
return NULL; return NULL;
} }
/* add the i2c device */ /*
client = i2c_new_probed_device(adapter, info, addrs, NULL); * Add the i2c device. If we can't detect it at the primary
* address we scan secondary addresses. In any case the client
* structure gets assigned primary address.
*/
client = i2c_new_probed_device(adapter, info, addr_list, NULL);
if (!client && alt_addr_list) {
struct i2c_board_info dummy_info = {
I2C_BOARD_INFO("dummy", info->addr),
};
struct i2c_client *dummy;
dummy = i2c_new_probed_device(adapter, &dummy_info,
alt_addr_list, NULL);
if (dummy) {
pr_debug("%s %d-%02x is probed at %02x\n",
__func__, bus, info->addr, dummy->addr);
i2c_unregister_device(dummy);
client = i2c_new_device(adapter, info);
}
}
if (!client) if (!client)
pr_notice("%s failed to register device %d-%02x\n", pr_notice("%s failed to register device %d-%02x\n",
__func__, bus, info->addr); __func__, bus, info->addr);
...@@ -254,12 +275,10 @@ static struct i2c_client *add_i2c_device(const char *name, ...@@ -254,12 +275,10 @@ static struct i2c_client *add_i2c_device(const char *name,
enum i2c_adapter_type type, enum i2c_adapter_type type,
struct i2c_board_info *info) struct i2c_board_info *info)
{ {
const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
return __add_probed_i2c_device(name, return __add_probed_i2c_device(name,
find_i2c_adapter_num(type), find_i2c_adapter_num(type),
info, info,
addr_list); NULL);
} }
static int setup_cyapa_tp(enum i2c_adapter_type type) static int setup_cyapa_tp(enum i2c_adapter_type type)
...@@ -275,7 +294,6 @@ static int setup_cyapa_tp(enum i2c_adapter_type type) ...@@ -275,7 +294,6 @@ static int setup_cyapa_tp(enum i2c_adapter_type type)
static int setup_atmel_224s_tp(enum i2c_adapter_type type) static int setup_atmel_224s_tp(enum i2c_adapter_type type)
{ {
const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR, const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR,
ATMEL_TP_I2C_ADDR,
I2C_CLIENT_END }; I2C_CLIENT_END };
if (tp) if (tp)
return 0; return 0;
...@@ -289,7 +307,6 @@ static int setup_atmel_224s_tp(enum i2c_adapter_type type) ...@@ -289,7 +307,6 @@ static int setup_atmel_224s_tp(enum i2c_adapter_type type)
static int setup_atmel_1664s_ts(enum i2c_adapter_type type) static int setup_atmel_1664s_ts(enum i2c_adapter_type type)
{ {
const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR, const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR,
ATMEL_TS_I2C_ADDR,
I2C_CLIENT_END }; I2C_CLIENT_END };
if (ts) if (ts)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment