Commit fc7c882a authored by Jingle Wu's avatar Jingle Wu Committed by Dmitry Torokhov

Input: elan_i2c - make fetching IC type of older controllers more robust

On older controllers IC type is reported in the 2nd byte of
ETP_I2C_OSM_VERSION_CMD, however if controller's firmware is not flashed
correctly it may return incorrect data. Fortunately there is also
ETP_I2C_IAP_VERSION_P0_CMD command that can be used when controller in
either normal or IAP mode, and which is guaranteed to return accurate data,
so let's use it.
Signed-off-by: default avatarJingle Wu <jingle.wu@emc.com.tw>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 77da21c5
...@@ -312,7 +312,6 @@ static int elan_initialize(struct elan_tp_data *data) ...@@ -312,7 +312,6 @@ static int elan_initialize(struct elan_tp_data *data)
static int elan_query_device_info(struct elan_tp_data *data) static int elan_query_device_info(struct elan_tp_data *data)
{ {
int error; int error;
u16 ic_type;
error = data->ops->get_version(data->client, false, &data->fw_version); error = data->ops->get_version(data->client, false, &data->fw_version);
if (error) if (error)
...@@ -336,12 +335,7 @@ static int elan_query_device_info(struct elan_tp_data *data) ...@@ -336,12 +335,7 @@ static int elan_query_device_info(struct elan_tp_data *data)
if (error) if (error)
return error; return error;
if (data->pattern == 0x01) error = elan_get_fwinfo(data->ic_type, &data->fw_validpage_count,
ic_type = data->ic_type;
else
ic_type = data->iap_version;
error = elan_get_fwinfo(ic_type, &data->fw_validpage_count,
&data->fw_signature_address); &data->fw_signature_address);
if (error) if (error)
dev_warn(&data->client->dev, dev_warn(&data->client->dev,
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#define ETP_I2C_RESOLUTION_CMD 0x0108 #define ETP_I2C_RESOLUTION_CMD 0x0108
#define ETP_I2C_PRESSURE_CMD 0x010A #define ETP_I2C_PRESSURE_CMD 0x010A
#define ETP_I2C_IAP_VERSION_CMD 0x0110 #define ETP_I2C_IAP_VERSION_CMD 0x0110
#define ETP_I2C_IC_TYPE_P0_CMD 0x0110
#define ETP_I2C_SET_CMD 0x0300 #define ETP_I2C_SET_CMD 0x0300
#define ETP_I2C_POWER_CMD 0x0307 #define ETP_I2C_POWER_CMD 0x0307
#define ETP_I2C_FW_CHECKSUM_CMD 0x030F #define ETP_I2C_FW_CHECKSUM_CMD 0x030F
...@@ -330,7 +331,14 @@ static int elan_i2c_get_sm_version(struct i2c_client *client, ...@@ -330,7 +331,14 @@ static int elan_i2c_get_sm_version(struct i2c_client *client,
return error; return error;
} }
*version = val[0]; *version = val[0];
*ic_type = val[1];
error = elan_i2c_read_cmd(client, ETP_I2C_IC_TYPE_P0_CMD, val);
if (error) {
dev_err(&client->dev, "failed to get ic type: %d\n",
error);
return error;
}
*ic_type = val[0];
error = elan_i2c_read_cmd(client, ETP_I2C_NSM_VERSION_CMD, error = elan_i2c_read_cmd(client, ETP_I2C_NSM_VERSION_CMD,
val); val);
......
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