Re: [PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-14 Thread Benson Leung
Thanks again, Dmitry and Henrik!


On Thu, Feb 14, 2013 at 9:19 AM, Henrik Rydberg  wrote:
> On Wed, Feb 13, 2013 at 08:26:35PM -0800, Dmitry Torokhov wrote:
>> On Sun, Feb 10, 2013 at 12:15:40PM -0800, Benson Leung wrote:
>> > This patch adds support for the Cypress APA Smbus Trackpad type,
>> > which uses a modified register map that fits within the
>> > limitations of the smbus protocol.
>> >
>> > Devices that use this protocol include:
>> > CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
>> > CYTRA-103002-00 - Acer C7 Chromebook trackpad
>> > CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad
>> >
>> > Signed-off-by: Dudley Du 
>> > Signed-off-by: Benson Leung 
>> > Reviewed-by: Daniel Kurtz 
>> > ---
>> > v2 : Minor style cleanup. Removed unused struct device *dev declarations.
>> > ---
>>
>> Applied, thank you Benson.
>>
>> Henrik, I put you down as "reviewed-by".
>
> Perfect, thank you.
>
> Henrik



-- 
Benson Leung
Software Engineer, Chrom* OS
ble...@chromium.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-14 Thread Henrik Rydberg
On Wed, Feb 13, 2013 at 08:26:35PM -0800, Dmitry Torokhov wrote:
> On Sun, Feb 10, 2013 at 12:15:40PM -0800, Benson Leung wrote:
> > This patch adds support for the Cypress APA Smbus Trackpad type,
> > which uses a modified register map that fits within the
> > limitations of the smbus protocol.
> > 
> > Devices that use this protocol include:
> > CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
> > CYTRA-103002-00 - Acer C7 Chromebook trackpad
> > CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad
> > 
> > Signed-off-by: Dudley Du 
> > Signed-off-by: Benson Leung 
> > Reviewed-by: Daniel Kurtz 
> > ---
> > v2 : Minor style cleanup. Removed unused struct device *dev declarations.
> > ---
> 
> Applied, thank you Benson.
> 
> Henrik, I put you down as "reviewed-by".

Perfect, thank you.

Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-14 Thread Henrik Rydberg
On Wed, Feb 13, 2013 at 08:26:35PM -0800, Dmitry Torokhov wrote:
 On Sun, Feb 10, 2013 at 12:15:40PM -0800, Benson Leung wrote:
  This patch adds support for the Cypress APA Smbus Trackpad type,
  which uses a modified register map that fits within the
  limitations of the smbus protocol.
  
  Devices that use this protocol include:
  CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
  CYTRA-103002-00 - Acer C7 Chromebook trackpad
  CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad
  
  Signed-off-by: Dudley Du d...@cypress.com
  Signed-off-by: Benson Leung ble...@chromium.org
  Reviewed-by: Daniel Kurtz djku...@chromium.org
  ---
  v2 : Minor style cleanup. Removed unused struct device *dev declarations.
  ---
 
 Applied, thank you Benson.
 
 Henrik, I put you down as reviewed-by.

Perfect, thank you.

Henrik
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-14 Thread Benson Leung
Thanks again, Dmitry and Henrik!


On Thu, Feb 14, 2013 at 9:19 AM, Henrik Rydberg rydb...@euromail.se wrote:
 On Wed, Feb 13, 2013 at 08:26:35PM -0800, Dmitry Torokhov wrote:
 On Sun, Feb 10, 2013 at 12:15:40PM -0800, Benson Leung wrote:
  This patch adds support for the Cypress APA Smbus Trackpad type,
  which uses a modified register map that fits within the
  limitations of the smbus protocol.
 
  Devices that use this protocol include:
  CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
  CYTRA-103002-00 - Acer C7 Chromebook trackpad
  CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad
 
  Signed-off-by: Dudley Du d...@cypress.com
  Signed-off-by: Benson Leung ble...@chromium.org
  Reviewed-by: Daniel Kurtz djku...@chromium.org
  ---
  v2 : Minor style cleanup. Removed unused struct device *dev declarations.
  ---

 Applied, thank you Benson.

 Henrik, I put you down as reviewed-by.

 Perfect, thank you.

 Henrik



-- 
Benson Leung
Software Engineer, Chrom* OS
ble...@chromium.org
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-13 Thread Dmitry Torokhov
On Sun, Feb 10, 2013 at 12:15:40PM -0800, Benson Leung wrote:
> This patch adds support for the Cypress APA Smbus Trackpad type,
> which uses a modified register map that fits within the
> limitations of the smbus protocol.
> 
> Devices that use this protocol include:
> CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
> CYTRA-103002-00 - Acer C7 Chromebook trackpad
> CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad
> 
> Signed-off-by: Dudley Du 
> Signed-off-by: Benson Leung 
> Reviewed-by: Daniel Kurtz 
> ---
> v2 : Minor style cleanup. Removed unused struct device *dev declarations.
> ---

Applied, thank you Benson.

Henrik, I put you down as "reviewed-by".

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-13 Thread Dmitry Torokhov
On Sun, Feb 10, 2013 at 12:15:40PM -0800, Benson Leung wrote:
 This patch adds support for the Cypress APA Smbus Trackpad type,
 which uses a modified register map that fits within the
 limitations of the smbus protocol.
 
 Devices that use this protocol include:
 CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
 CYTRA-103002-00 - Acer C7 Chromebook trackpad
 CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad
 
 Signed-off-by: Dudley Du d...@cypress.com
 Signed-off-by: Benson Leung ble...@chromium.org
 Reviewed-by: Daniel Kurtz djku...@chromium.org
 ---
 v2 : Minor style cleanup. Removed unused struct device *dev declarations.
 ---

Applied, thank you Benson.

Henrik, I put you down as reviewed-by.

Thanks!

-- 
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-10 Thread Benson Leung
This patch adds support for the Cypress APA Smbus Trackpad type,
which uses a modified register map that fits within the
limitations of the smbus protocol.

Devices that use this protocol include:
CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
CYTRA-103002-00 - Acer C7 Chromebook trackpad
CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad

Signed-off-by: Dudley Du 
Signed-off-by: Benson Leung 
Reviewed-by: Daniel Kurtz 
---
v2 : Minor style cleanup. Removed unused struct device *dev declarations.
---
 drivers/input/mouse/cyapa.c | 180 ++--
 1 file changed, 175 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 1a14688..0ba66aa 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -208,6 +208,7 @@ struct cyapa {
char phys[32];  /* device physical location */
int irq;
bool irq_wake;  /* irq wake is enabled */
+   bool smbus;
 
/* read from query data region. */
char product_id[16];
@@ -229,6 +230,60 @@ struct cyapa_cmd_len {
u8 len;
 };
 
+#define CYAPA_ADAPTER_FUNC_NONE   0
+#define CYAPA_ADAPTER_FUNC_I2C1
+#define CYAPA_ADAPTER_FUNC_SMBUS  2
+#define CYAPA_ADAPTER_FUNC_BOTH   3
+
+/*
+ * macros for SMBus communication
+ */
+#define SMBUS_READ   0x01
+#define SMBUS_WRITE 0x00
+#define SMBUS_ENCODE_IDX(cmd, idx) ((cmd) | (((idx) & 0x03) << 1))
+#define SMBUS_ENCODE_RW(cmd, rw) ((cmd) | ((rw) & 0x01))
+#define SMBUS_BYTE_BLOCK_CMD_MASK 0x80
+#define SMBUS_GROUP_BLOCK_CMD_MASK 0x40
+
+ /* for byte read/write command */
+#define CMD_RESET 0
+#define CMD_POWER_MODE 1
+#define CMD_DEV_STATUS 2
+#define SMBUS_BYTE_CMD(cmd) (((cmd) & 0x3f) << 1)
+#define CYAPA_SMBUS_RESET SMBUS_BYTE_CMD(CMD_RESET)
+#define CYAPA_SMBUS_POWER_MODE SMBUS_BYTE_CMD(CMD_POWER_MODE)
+#define CYAPA_SMBUS_DEV_STATUS SMBUS_BYTE_CMD(CMD_DEV_STATUS)
+
+ /* for group registers read/write command */
+#define REG_GROUP_DATA 0
+#define REG_GROUP_CMD 2
+#define REG_GROUP_QUERY 3
+#define SMBUS_GROUP_CMD(grp) (0x80 | (((grp) & 0x07) << 3))
+#define CYAPA_SMBUS_GROUP_DATA SMBUS_GROUP_CMD(REG_GROUP_DATA)
+#define CYAPA_SMBUS_GROUP_CMD SMBUS_GROUP_CMD(REG_GROUP_CMD)
+#define CYAPA_SMBUS_GROUP_QUERY SMBUS_GROUP_CMD(REG_GROUP_QUERY)
+
+ /* for register block read/write command */
+#define CMD_BL_STATUS 0
+#define CMD_BL_HEAD 1
+#define CMD_BL_CMD 2
+#define CMD_BL_DATA 3
+#define CMD_BL_ALL 4
+#define CMD_BLK_PRODUCT_ID 5
+#define CMD_BLK_HEAD 6
+#define SMBUS_BLOCK_CMD(cmd) (0xc0 | (((cmd) & 0x1f) << 1))
+
+/* register block read/write command in bootloader mode */
+#define CYAPA_SMBUS_BL_STATUS SMBUS_BLOCK_CMD(CMD_BL_STATUS)
+#define CYAPA_SMBUS_BL_HEAD SMBUS_BLOCK_CMD(CMD_BL_HEAD)
+#define CYAPA_SMBUS_BL_CMD SMBUS_BLOCK_CMD(CMD_BL_CMD)
+#define CYAPA_SMBUS_BL_DATA SMBUS_BLOCK_CMD(CMD_BL_DATA)
+#define CYAPA_SMBUS_BL_ALL SMBUS_BLOCK_CMD(CMD_BL_ALL)
+
+/* register block read/write command in operational mode */
+#define CYAPA_SMBUS_BLK_PRODUCT_ID SMBUS_BLOCK_CMD(CMD_BLK_PRODUCT_ID)
+#define CYAPA_SMBUS_BLK_HEAD SMBUS_BLOCK_CMD(CMD_BLK_HEAD)
+
 static const struct cyapa_cmd_len cyapa_i2c_cmds[] = {
{ CYAPA_OFFSET_SOFT_RESET, 1 },
{ REG_OFFSET_COMMAND_BASE + 1, 1 },
@@ -245,6 +300,22 @@ static const struct cyapa_cmd_len cyapa_i2c_cmds[] = {
{ REG_OFFSET_DATA_BASE, 32 }
 };
 
+static const struct cyapa_cmd_len cyapa_smbus_cmds[] = {
+   { CYAPA_SMBUS_RESET, 1 },
+   { CYAPA_SMBUS_POWER_MODE, 1 },
+   { CYAPA_SMBUS_DEV_STATUS, 1 },
+   { CYAPA_SMBUS_GROUP_DATA, sizeof(struct cyapa_reg_data) },
+   { CYAPA_SMBUS_GROUP_CMD, 2 },
+   { CYAPA_SMBUS_GROUP_QUERY, QUERY_DATA_SIZE },
+   { CYAPA_SMBUS_BL_STATUS, 3 },
+   { CYAPA_SMBUS_BL_HEAD, 16 },
+   { CYAPA_SMBUS_BL_CMD, 16 },
+   { CYAPA_SMBUS_BL_DATA, 16 },
+   { CYAPA_SMBUS_BL_ALL, 32 },
+   { CYAPA_SMBUS_BLK_PRODUCT_ID, PRODUCT_ID_SIZE },
+   { CYAPA_SMBUS_BLK_HEAD, 16 },
+};
+
 static ssize_t cyapa_i2c_reg_read_block(struct cyapa *cyapa, u8 reg, size_t 
len,
u8 *values)
 {
@@ -257,26 +328,93 @@ static ssize_t cyapa_i2c_reg_write_block(struct cyapa 
*cyapa, u8 reg,
return i2c_smbus_write_i2c_block_data(cyapa->client, reg, len, values);
 }
 
+/*
+ * cyapa_smbus_read_block - perform smbus block read command
+ * @cyapa  - private data structure of the driver
+ * @cmd- the properly encoded smbus command
+ * @len- expected length of smbus command result
+ * @values - buffer to store smbus command result
+ *
+ * Returns negative errno, else the number of bytes written.
+ *
+ * Note:
+ * In trackpad device, the memory block allocated for I2C register map
+ * is 256 bytes, so the max read block for I2C bus is 256 bytes.
+ */
+static ssize_t cyapa_smbus_read_block(struct cyapa *cyapa, u8 cmd, size_t len,
+ u8 *values)
+{
+   ssize_t ret;
+   u8 index;
+   

[PATCH v2 1/1] Input: mouse: cyapa - Add support for cyapa smbus protocol

2013-02-10 Thread Benson Leung
This patch adds support for the Cypress APA Smbus Trackpad type,
which uses a modified register map that fits within the
limitations of the smbus protocol.

Devices that use this protocol include:
CYTRA-116001-00 - Samsung Series 5 550 Chromebook trackpad
CYTRA-103002-00 - Acer C7 Chromebook trackpad
CYTRA-101003-00 - HP Pavilion 14 Chromebook trackpad

Signed-off-by: Dudley Du d...@cypress.com
Signed-off-by: Benson Leung ble...@chromium.org
Reviewed-by: Daniel Kurtz djku...@chromium.org
---
v2 : Minor style cleanup. Removed unused struct device *dev declarations.
---
 drivers/input/mouse/cyapa.c | 180 ++--
 1 file changed, 175 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 1a14688..0ba66aa 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -208,6 +208,7 @@ struct cyapa {
char phys[32];  /* device physical location */
int irq;
bool irq_wake;  /* irq wake is enabled */
+   bool smbus;
 
/* read from query data region. */
char product_id[16];
@@ -229,6 +230,60 @@ struct cyapa_cmd_len {
u8 len;
 };
 
+#define CYAPA_ADAPTER_FUNC_NONE   0
+#define CYAPA_ADAPTER_FUNC_I2C1
+#define CYAPA_ADAPTER_FUNC_SMBUS  2
+#define CYAPA_ADAPTER_FUNC_BOTH   3
+
+/*
+ * macros for SMBus communication
+ */
+#define SMBUS_READ   0x01
+#define SMBUS_WRITE 0x00
+#define SMBUS_ENCODE_IDX(cmd, idx) ((cmd) | (((idx)  0x03)  1))
+#define SMBUS_ENCODE_RW(cmd, rw) ((cmd) | ((rw)  0x01))
+#define SMBUS_BYTE_BLOCK_CMD_MASK 0x80
+#define SMBUS_GROUP_BLOCK_CMD_MASK 0x40
+
+ /* for byte read/write command */
+#define CMD_RESET 0
+#define CMD_POWER_MODE 1
+#define CMD_DEV_STATUS 2
+#define SMBUS_BYTE_CMD(cmd) (((cmd)  0x3f)  1)
+#define CYAPA_SMBUS_RESET SMBUS_BYTE_CMD(CMD_RESET)
+#define CYAPA_SMBUS_POWER_MODE SMBUS_BYTE_CMD(CMD_POWER_MODE)
+#define CYAPA_SMBUS_DEV_STATUS SMBUS_BYTE_CMD(CMD_DEV_STATUS)
+
+ /* for group registers read/write command */
+#define REG_GROUP_DATA 0
+#define REG_GROUP_CMD 2
+#define REG_GROUP_QUERY 3
+#define SMBUS_GROUP_CMD(grp) (0x80 | (((grp)  0x07)  3))
+#define CYAPA_SMBUS_GROUP_DATA SMBUS_GROUP_CMD(REG_GROUP_DATA)
+#define CYAPA_SMBUS_GROUP_CMD SMBUS_GROUP_CMD(REG_GROUP_CMD)
+#define CYAPA_SMBUS_GROUP_QUERY SMBUS_GROUP_CMD(REG_GROUP_QUERY)
+
+ /* for register block read/write command */
+#define CMD_BL_STATUS 0
+#define CMD_BL_HEAD 1
+#define CMD_BL_CMD 2
+#define CMD_BL_DATA 3
+#define CMD_BL_ALL 4
+#define CMD_BLK_PRODUCT_ID 5
+#define CMD_BLK_HEAD 6
+#define SMBUS_BLOCK_CMD(cmd) (0xc0 | (((cmd)  0x1f)  1))
+
+/* register block read/write command in bootloader mode */
+#define CYAPA_SMBUS_BL_STATUS SMBUS_BLOCK_CMD(CMD_BL_STATUS)
+#define CYAPA_SMBUS_BL_HEAD SMBUS_BLOCK_CMD(CMD_BL_HEAD)
+#define CYAPA_SMBUS_BL_CMD SMBUS_BLOCK_CMD(CMD_BL_CMD)
+#define CYAPA_SMBUS_BL_DATA SMBUS_BLOCK_CMD(CMD_BL_DATA)
+#define CYAPA_SMBUS_BL_ALL SMBUS_BLOCK_CMD(CMD_BL_ALL)
+
+/* register block read/write command in operational mode */
+#define CYAPA_SMBUS_BLK_PRODUCT_ID SMBUS_BLOCK_CMD(CMD_BLK_PRODUCT_ID)
+#define CYAPA_SMBUS_BLK_HEAD SMBUS_BLOCK_CMD(CMD_BLK_HEAD)
+
 static const struct cyapa_cmd_len cyapa_i2c_cmds[] = {
{ CYAPA_OFFSET_SOFT_RESET, 1 },
{ REG_OFFSET_COMMAND_BASE + 1, 1 },
@@ -245,6 +300,22 @@ static const struct cyapa_cmd_len cyapa_i2c_cmds[] = {
{ REG_OFFSET_DATA_BASE, 32 }
 };
 
+static const struct cyapa_cmd_len cyapa_smbus_cmds[] = {
+   { CYAPA_SMBUS_RESET, 1 },
+   { CYAPA_SMBUS_POWER_MODE, 1 },
+   { CYAPA_SMBUS_DEV_STATUS, 1 },
+   { CYAPA_SMBUS_GROUP_DATA, sizeof(struct cyapa_reg_data) },
+   { CYAPA_SMBUS_GROUP_CMD, 2 },
+   { CYAPA_SMBUS_GROUP_QUERY, QUERY_DATA_SIZE },
+   { CYAPA_SMBUS_BL_STATUS, 3 },
+   { CYAPA_SMBUS_BL_HEAD, 16 },
+   { CYAPA_SMBUS_BL_CMD, 16 },
+   { CYAPA_SMBUS_BL_DATA, 16 },
+   { CYAPA_SMBUS_BL_ALL, 32 },
+   { CYAPA_SMBUS_BLK_PRODUCT_ID, PRODUCT_ID_SIZE },
+   { CYAPA_SMBUS_BLK_HEAD, 16 },
+};
+
 static ssize_t cyapa_i2c_reg_read_block(struct cyapa *cyapa, u8 reg, size_t 
len,
u8 *values)
 {
@@ -257,26 +328,93 @@ static ssize_t cyapa_i2c_reg_write_block(struct cyapa 
*cyapa, u8 reg,
return i2c_smbus_write_i2c_block_data(cyapa-client, reg, len, values);
 }
 
+/*
+ * cyapa_smbus_read_block - perform smbus block read command
+ * @cyapa  - private data structure of the driver
+ * @cmd- the properly encoded smbus command
+ * @len- expected length of smbus command result
+ * @values - buffer to store smbus command result
+ *
+ * Returns negative errno, else the number of bytes written.
+ *
+ * Note:
+ * In trackpad device, the memory block allocated for I2C register map
+ * is 256 bytes, so the max read block for I2C bus is 256 bytes.
+ */
+static ssize_t cyapa_smbus_read_block(struct cyapa *cyapa, u8 cmd, size_t len,
+ u8 *values)
+{
+