From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: duson <dusonlin@emc.com.tw>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input - elan_i2c: support multi ic type and iap format
Date: Mon, 8 Jun 2015 17:09:01 -0700 [thread overview]
Message-ID: <20150609000901.GC420@dtor-ws> (raw)
In-Reply-To: <FE1EA6CC-E67E-419C-9394-EFA490D8BA76@emc.com.tw>
On Sun, Jun 07, 2015 at 03:34:04AM +0800, duson wrote:
> In order to support multi ic type for i2c/smbus protocol, add get ic type
> command and check fw vaild page count and signature address function.
>
> Signed-off by: Duson Lin <dusonlin@emc.com.tw>
Applied, thank you (but please try to convince your mailer to not use
quoted printable format).
> ---
> drivers/input/mouse/elan_i2c.h | 5 ++--
> drivers/input/mouse/elan_i2c_core.c | 44 ++++++++++++++++++++++++++++++----
> drivers/input/mouse/elan_i2c_i2c.c | 5 +++-
> drivers/input/mouse/elan_i2c_smbus.c | 6 +++--
> 4 files changed, 49 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
> index 6d5f8a4..ff622a1 100644
> --- a/drivers/input/mouse/elan_i2c.h
> +++ b/drivers/input/mouse/elan_i2c.h
> @@ -33,9 +33,7 @@
> #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_VAILDPAGE_COUNT 768
> #define ETP_FW_SIGNATURE_SIZE 6
> -#define ETP_FW_SIGNATURE_ADDRESS 0xBFFA
>
> struct i2c_client;
> struct completion;
> @@ -58,7 +56,8 @@ struct elan_transport_ops {
> 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_sm_version)(struct i2c_client *client,
> + u8* ic_type, u8 *version);
> int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
> int (*get_product_id)(struct i2c_client *client, u8 *id);
>
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index fd5068b..81e7bc9 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -4,7 +4,7 @@
> * Copyright (c) 2013 ELAN Microelectronics Corp.
> *
> * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
> - * Version: 1.5.7
> + * Version: 1.5.8
> *
> * Based on cyapa driver:
> * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
> @@ -40,7 +40,7 @@
> #include "elan_i2c.h"
>
> #define DRIVER_NAME "elan_i2c"
> -#define ELAN_DRIVER_VERSION "1.5.7"
> +#define ELAN_DRIVER_VERSION "1.5.8"
> #define ETP_MAX_PRESSURE 255
> #define ETP_FWIDTH_REDUCE 90
> #define ETP_FINGER_WIDTH 15
> @@ -83,6 +83,9 @@ struct elan_tp_data {
> u16 fw_checksum;
> int pressure_adjustment;
> u8 mode;
> + u8 ic_type;
> + u16 fw_vaildpage_count;
> + u16 fw_signature_address;
>
> bool irq_wake;
>
> @@ -91,6 +94,28 @@ struct elan_tp_data {
> bool baseline_ready;
> };
>
> +static int elan_get_fwinfo(u8 ic_type, u16 *vaildpage_count,
> + u16 *signature_address)
> +{
> +
> + switch(ic_type) {
> + case 0x09:
> + *vaildpage_count = 768;
> + break;
> + case 0x0D:
> + *vaildpage_count = 896;
> + break;
> + default:
> + /* unknown ic type clear value */
> + *vaildpage_count = 0;
> + *signature_address = 0;
> + return -ENXIO;
> + }
> + *signature_address = (*vaildpage_count * ETP_FW_PAGE_SIZE)
> + - ETP_FW_SIGNATURE_SIZE;
> + return 0;
> +}
> +
> static int elan_enable_power(struct elan_tp_data *data)
> {
> int repeat = ETP_RETRY_COUNT;
> @@ -221,7 +246,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
> if (error)
> return error;
>
> - error = data->ops->get_sm_version(data->client, &data->sm_version);
> + error = data->ops->get_sm_version(data->client, &data->ic_type,
> + &data->sm_version);
> if (error)
> return error;
>
> @@ -234,6 +260,14 @@ static int elan_query_device_info(struct elan_tp_data *data)
> if (error)
> return error;
>
> + error = elan_get_fwinfo(data->ic_type, &data->fw_vaildpage_count,
> + &data->fw_signature_address);
> + if (error) {
> + dev_err(&data->client->dev,
> + "unknown ic type %d\n", data->ic_type);
> + return error;
> + }
> +
> return 0;
> }
>
> @@ -318,7 +352,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
> iap_start_addr = get_unaligned_le16(&fw->data[ETP_IAP_START_ADDR * 2]);
>
> boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
> - for (i = boot_page_count; i < ETP_FW_VAILDPAGE_COUNT; i++) {
> + for (i = boot_page_count; i < data->fw_vaildpage_count; i++) {
> u16 checksum = 0;
> const u8 *page = &fw->data[i * ETP_FW_PAGE_SIZE];
>
> @@ -454,7 +488,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
> }
>
> /* Firmware file must match signature data */
> - fw_signature = &fw->data[ETP_FW_SIGNATURE_ADDRESS];
> + fw_signature = &fw->data[data->fw_signature_address];
> if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
> dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n",
> (int)sizeof(signature), signature,
> diff --git a/drivers/input/mouse/elan_i2c_i2c.c b/drivers/input/mouse/elan_i2c_i2c.c
> index a0acbbf..549cdfb 100644
> --- a/drivers/input/mouse/elan_i2c_i2c.c
> +++ b/drivers/input/mouse/elan_i2c_i2c.c
> @@ -259,7 +259,8 @@ static int elan_i2c_get_version(struct i2c_client *client,
> return 0;
> }
>
> -static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *version)
> +static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *ic_type,
> + u8 *version)
> {
> int error;
> u8 val[3];
> @@ -271,9 +272,11 @@ static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *version)
> }
>
> *version = val[0];
> + *ic_type = val[1];
> return 0;
> }
>
> +
> static int elan_i2c_get_product_id(struct i2c_client *client, u8 *id)
> {
> int error;
> diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
> index 30ab80d..c28caef 100644
> --- a/drivers/input/mouse/elan_i2c_smbus.c
> +++ b/drivers/input/mouse/elan_i2c_smbus.c
> @@ -165,7 +165,8 @@ static int elan_smbus_get_version(struct i2c_client *client,
> return 0;
> }
>
> -static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *version)
> +static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *ic_type,
> + u8 *version)
> {
> int error;
> u8 val[3];
> @@ -177,7 +178,8 @@ static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *version)
> return error;
> }
>
> - *version = val[0]; /* XXX Why 0 and not 2 as in IAP/FW versions? */
> + *version = val[0];
> + *ic_type = val[1];
> return 0;
> }
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: duson <dusonlin@emc.com.tw>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input - elan_i2c: support multi ic type and iap format
Date: Mon, 8 Jun 2015 17:09:01 -0700 [thread overview]
Message-ID: <20150609000901.GC420@dtor-ws> (raw)
In-Reply-To: <FE1EA6CC-E67E-419C-9394-EFA490D8BA76@emc.com.tw>
On Sun, Jun 07, 2015 at 03:34:04AM +0800, duson wrote:
> In order to support multi ic type for i2c/smbus protocol, add get ic type
> command and check fw vaild page count and signature address function.
>
> Signed-off by: Duson Lin <dusonlin@emc.com.tw>
Applied, thank you (but please try to convince your mailer to not use
quoted printable format).
> ---
> drivers/input/mouse/elan_i2c.h | 5 ++--
> drivers/input/mouse/elan_i2c_core.c | 44 ++++++++++++++++++++++++++++++----
> drivers/input/mouse/elan_i2c_i2c.c | 5 +++-
> drivers/input/mouse/elan_i2c_smbus.c | 6 +++--
> 4 files changed, 49 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
> index 6d5f8a4..ff622a1 100644
> --- a/drivers/input/mouse/elan_i2c.h
> +++ b/drivers/input/mouse/elan_i2c.h
> @@ -33,9 +33,7 @@
> #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_VAILDPAGE_COUNT 768
> #define ETP_FW_SIGNATURE_SIZE 6
> -#define ETP_FW_SIGNATURE_ADDRESS 0xBFFA
>
> struct i2c_client;
> struct completion;
> @@ -58,7 +56,8 @@ struct elan_transport_ops {
> 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_sm_version)(struct i2c_client *client,
> + u8* ic_type, u8 *version);
> int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum);
> int (*get_product_id)(struct i2c_client *client, u8 *id);
>
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index fd5068b..81e7bc9 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -4,7 +4,7 @@
> * Copyright (c) 2013 ELAN Microelectronics Corp.
> *
> * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
> - * Version: 1.5.7
> + * Version: 1.5.8
> *
> * Based on cyapa driver:
> * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
> @@ -40,7 +40,7 @@
> #include "elan_i2c.h"
>
> #define DRIVER_NAME "elan_i2c"
> -#define ELAN_DRIVER_VERSION "1.5.7"
> +#define ELAN_DRIVER_VERSION "1.5.8"
> #define ETP_MAX_PRESSURE 255
> #define ETP_FWIDTH_REDUCE 90
> #define ETP_FINGER_WIDTH 15
> @@ -83,6 +83,9 @@ struct elan_tp_data {
> u16 fw_checksum;
> int pressure_adjustment;
> u8 mode;
> + u8 ic_type;
> + u16 fw_vaildpage_count;
> + u16 fw_signature_address;
>
> bool irq_wake;
>
> @@ -91,6 +94,28 @@ struct elan_tp_data {
> bool baseline_ready;
> };
>
> +static int elan_get_fwinfo(u8 ic_type, u16 *vaildpage_count,
> + u16 *signature_address)
> +{
> +
> + switch(ic_type) {
> + case 0x09:
> + *vaildpage_count = 768;
> + break;
> + case 0x0D:
> + *vaildpage_count = 896;
> + break;
> + default:
> + /* unknown ic type clear value */
> + *vaildpage_count = 0;
> + *signature_address = 0;
> + return -ENXIO;
> + }
> + *signature_address = (*vaildpage_count * ETP_FW_PAGE_SIZE)
> + - ETP_FW_SIGNATURE_SIZE;
> + return 0;
> +}
> +
> static int elan_enable_power(struct elan_tp_data *data)
> {
> int repeat = ETP_RETRY_COUNT;
> @@ -221,7 +246,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
> if (error)
> return error;
>
> - error = data->ops->get_sm_version(data->client, &data->sm_version);
> + error = data->ops->get_sm_version(data->client, &data->ic_type,
> + &data->sm_version);
> if (error)
> return error;
>
> @@ -234,6 +260,14 @@ static int elan_query_device_info(struct elan_tp_data *data)
> if (error)
> return error;
>
> + error = elan_get_fwinfo(data->ic_type, &data->fw_vaildpage_count,
> + &data->fw_signature_address);
> + if (error) {
> + dev_err(&data->client->dev,
> + "unknown ic type %d\n", data->ic_type);
> + return error;
> + }
> +
> return 0;
> }
>
> @@ -318,7 +352,7 @@ static int __elan_update_firmware(struct elan_tp_data *data,
> iap_start_addr = get_unaligned_le16(&fw->data[ETP_IAP_START_ADDR * 2]);
>
> boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE;
> - for (i = boot_page_count; i < ETP_FW_VAILDPAGE_COUNT; i++) {
> + for (i = boot_page_count; i < data->fw_vaildpage_count; i++) {
> u16 checksum = 0;
> const u8 *page = &fw->data[i * ETP_FW_PAGE_SIZE];
>
> @@ -454,7 +488,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
> }
>
> /* Firmware file must match signature data */
> - fw_signature = &fw->data[ETP_FW_SIGNATURE_ADDRESS];
> + fw_signature = &fw->data[data->fw_signature_address];
> if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {
> dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n",
> (int)sizeof(signature), signature,
> diff --git a/drivers/input/mouse/elan_i2c_i2c.c b/drivers/input/mouse/elan_i2c_i2c.c
> index a0acbbf..549cdfb 100644
> --- a/drivers/input/mouse/elan_i2c_i2c.c
> +++ b/drivers/input/mouse/elan_i2c_i2c.c
> @@ -259,7 +259,8 @@ static int elan_i2c_get_version(struct i2c_client *client,
> return 0;
> }
>
> -static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *version)
> +static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *ic_type,
> + u8 *version)
> {
> int error;
> u8 val[3];
> @@ -271,9 +272,11 @@ static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *version)
> }
>
> *version = val[0];
> + *ic_type = val[1];
> return 0;
> }
>
> +
> static int elan_i2c_get_product_id(struct i2c_client *client, u8 *id)
> {
> int error;
> diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
> index 30ab80d..c28caef 100644
> --- a/drivers/input/mouse/elan_i2c_smbus.c
> +++ b/drivers/input/mouse/elan_i2c_smbus.c
> @@ -165,7 +165,8 @@ static int elan_smbus_get_version(struct i2c_client *client,
> return 0;
> }
>
> -static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *version)
> +static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *ic_type,
> + u8 *version)
> {
> int error;
> u8 val[3];
> @@ -177,7 +178,8 @@ static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *version)
> return error;
> }
>
> - *version = val[0]; /* XXX Why 0 and not 2 as in IAP/FW versions? */
> + *version = val[0];
> + *ic_type = val[1];
> return 0;
> }
--
Dmitry
next prev parent reply other threads:[~2015-06-09 0:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-06 19:34 [PATCH] Input - elan_i2c: support multi ic type and iap format duson
2015-06-06 19:34 ` duson
2015-06-09 0:09 ` Dmitry Torokhov [this message]
2015-06-09 0:09 ` Dmitry Torokhov
2015-06-10 8:25 ` DusonLin
2015-06-10 8:25 ` DusonLin
2015-06-11 20:03 ` 'Dmitry Torokhov'
2015-06-11 20:03 ` 'Dmitry Torokhov'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150609000901.GC420@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=dusonlin@emc.com.tw \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.