Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-27 Thread Dmitry Torokhov
Hi Jeffrey,

On Tue, May 24, 2016 at 05:31:41PM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> >
> > BUILD_BUG_ON((RM_FW_PAGE_SIZE % RM_BL_WRT_PKG_SIZE) != 0);
> >
> > for (i = 0; i < RM_FW_PAGE_SIZE / RM_BL_WRT_PKG_SIZE; i++) {
> > buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
> > buf[BL_PAGE_STR] = i ? 0xff : 0;
> Change to buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
> > buf[BL_PKG_IDX] = i;
> >
> > xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> > memcpy([BL_DATA_STR], data, xfer_len);
> > if (len < RM_BL_WRT_PKG_SIZE)
> > memset([BL_DATA_STR + xfer_len], 0xff,
> > RM_BL_WRT_PKG_SIZE - xfer_len);
> >
> > error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
> >  RAYDIUM_WAIT_READY);
> > if (error) {
> > dev_err(>dev,
> > "page write command failed for page %d, chunk 
> > %d: %d\n",
> > page_idx, pkg_idx, error);
> > return error;
> > }
> >
> > data += xfer_len;
> > len -= xfer_len;
> > }
> This work on my hand chromebook.
> 
> > static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> > {
> > __le32 le_addr;
> > size_t xfer_len;
> > int error;
> > 
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> > 
> > le_addr = cpu_to_le32(addr);
> > 
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(le_addr));
> > if (!error)/*read from last byte addr.*/
> > error = raydium_i2c_read(client, le_addr & 0xff,
> >  data, xfer_len)
> Change as
>   error = raydium_i2c_read(client, addr & 0xff,
>data, xfer_len);
> 
> I've fixed this issues and submit new patch to upstream. Please help check 
> that.

I do not think that we want the gratuitous change from BE to LE here, as
this will give users trouble with devices that still use older
bootloader firmwares.

I did change this back to BE, along with a couple of other tweaks, and
uploaded what I hope is the final version of the patch to "raydium"
branch of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git

Please give it a try on your side and if everything works I will queue
the driver to be merged in the next merge window.

Thanks!

-- 
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-27 Thread Dmitry Torokhov
Hi Jeffrey,

On Tue, May 24, 2016 at 05:31:41PM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> >
> > BUILD_BUG_ON((RM_FW_PAGE_SIZE % RM_BL_WRT_PKG_SIZE) != 0);
> >
> > for (i = 0; i < RM_FW_PAGE_SIZE / RM_BL_WRT_PKG_SIZE; i++) {
> > buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
> > buf[BL_PAGE_STR] = i ? 0xff : 0;
> Change to buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
> > buf[BL_PKG_IDX] = i;
> >
> > xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> > memcpy([BL_DATA_STR], data, xfer_len);
> > if (len < RM_BL_WRT_PKG_SIZE)
> > memset([BL_DATA_STR + xfer_len], 0xff,
> > RM_BL_WRT_PKG_SIZE - xfer_len);
> >
> > error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
> >  RAYDIUM_WAIT_READY);
> > if (error) {
> > dev_err(>dev,
> > "page write command failed for page %d, chunk 
> > %d: %d\n",
> > page_idx, pkg_idx, error);
> > return error;
> > }
> >
> > data += xfer_len;
> > len -= xfer_len;
> > }
> This work on my hand chromebook.
> 
> > static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> > {
> > __le32 le_addr;
> > size_t xfer_len;
> > int error;
> > 
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> > 
> > le_addr = cpu_to_le32(addr);
> > 
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(le_addr));
> > if (!error)/*read from last byte addr.*/
> > error = raydium_i2c_read(client, le_addr & 0xff,
> >  data, xfer_len)
> Change as
>   error = raydium_i2c_read(client, addr & 0xff,
>data, xfer_len);
> 
> I've fixed this issues and submit new patch to upstream. Please help check 
> that.

I do not think that we want the gratuitous change from BE to LE here, as
this will give users trouble with devices that still use older
bootloader firmwares.

I did change this back to BE, along with a couple of other tweaks, and
uploaded what I hope is the final version of the patch to "raydium"
branch of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git

Please give it a try on your side and if everything works I will queue
the driver to be merged in the next merge window.

Thanks!

-- 
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-24 Thread jeffrey.lin
Hi Dmitry:
>
>   BUILD_BUG_ON((RM_FW_PAGE_SIZE % RM_BL_WRT_PKG_SIZE) != 0);
>
>   for (i = 0; i < RM_FW_PAGE_SIZE / RM_BL_WRT_PKG_SIZE; i++) {
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   buf[BL_PAGE_STR] = i ? 0xff : 0;
Change to buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = i;
>
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   memcpy([BL_DATA_STR], data, xfer_len);
>   if (len < RM_BL_WRT_PKG_SIZE)
>   memset([BL_DATA_STR + xfer_len], 0xff,
>   RM_BL_WRT_PKG_SIZE - xfer_len);
>
>   error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command failed for page %d, chunk 
> %d: %d\n",
>   page_idx, pkg_idx, error);
>   return error;
>   }
>
>   data += xfer_len;
>   len -= xfer_len;
>   }
This work on my hand chromebook.

> static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
> {
>   __le32 le_addr;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> 
>   le_addr = cpu_to_le32(addr);
> 
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len)
Change as
error = raydium_i2c_read(client, addr & 0xff,
 data, xfer_len);

I've fixed this issues and submit new patch to upstream. Please help check that.

Thanks.

Jeffrey


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-24 Thread jeffrey.lin
Hi Dmitry:
>
>   BUILD_BUG_ON((RM_FW_PAGE_SIZE % RM_BL_WRT_PKG_SIZE) != 0);
>
>   for (i = 0; i < RM_FW_PAGE_SIZE / RM_BL_WRT_PKG_SIZE; i++) {
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   buf[BL_PAGE_STR] = i ? 0xff : 0;
Change to buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = i;
>
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   memcpy([BL_DATA_STR], data, xfer_len);
>   if (len < RM_BL_WRT_PKG_SIZE)
>   memset([BL_DATA_STR + xfer_len], 0xff,
>   RM_BL_WRT_PKG_SIZE - xfer_len);
>
>   error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command failed for page %d, chunk 
> %d: %d\n",
>   page_idx, pkg_idx, error);
>   return error;
>   }
>
>   data += xfer_len;
>   len -= xfer_len;
>   }
This work on my hand chromebook.

> static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
> {
>   __le32 le_addr;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> 
>   le_addr = cpu_to_le32(addr);
> 
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len)
Change as
error = raydium_i2c_read(client, addr & 0xff,
 data, xfer_len);

I've fixed this issues and submit new patch to upstream. Please help check that.

Thanks.

Jeffrey


[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-24 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1208 
 3 files changed, 1221 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..27c84c5
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1208 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+/* Slave I2C mode */
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/* I2C bootoloader commands */
+#define RM_CMD_BOOT_PAGE_WRT   0x0B/* send bl page write */
+#define RM_CMD_BOOT_WRT0x11/* send bl write */
+#define RM_CMD_BOOT_ACK0x22/* send ack*/
+#define RM_CMD_BOOT_CHK0x33/* send data check */
+#define RM_CMD_BOOT_READ   0x44/* send wait bl data ready*/
+
+#define RM_BOOT_RDY0xFF/* bl data ready */
+
+/* I2C main commands */
+#define RM_CMD_QUERY_BANK  0x2B
+#define RM_CMD_DATA_BANK   0x4D
+#define RM_CMD_ENTER_SLEEP 0x4E
+#define RM_CMD_BANK_SWITCH 0xAA
+
+#define RM_RESET_MSG_ADDR  0x4004
+
+#define RM_MAX_READ_SIZE   56
+
+/* Touch relative info */
+#define RM_MAX_RETRIES 3
+#define RM_MAX_TOUCH_NUM   10
+#define RM_BOOT_DELAY_MS   100
+
+/* Offsets in contact data */
+#define RM_CONTACT_STATE_POS   0
+#define RM_CONTACT_X_POS   1
+#define RM_CONTACT_Y_POS   3
+#define RM_CONTACT_PRESSURE_POS5   /*FIXME, correct 5*/
+#define RM_CONTACT_WIDTH_X_POS 6
+#define RM_CONTACT_WIDTH_Y_POS 7
+
+/* Bootloader relative info */
+#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
+#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
+#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
+#define RM_FW_PAGE_SIZE128
+#define RM_MAX_FW_RETRIES  30
+#define RM_MAX_FW_SIZE (0xD000)/*define max firmware size*/
+
+#define RM_POWERON_DELAY_USEC  500
+#define RM_RESET_DELAY_MSEC50
+
+enum raydium_bl_cmd {
+   BL_HEADER = 0,
+   BL_PAGE_STR,
+   BL_PKG_IDX,
+   BL_DATA_STR,
+};
+
+enum raydium_bl_ack {
+   RAYDIUM_ACK_NULL = 0,
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-24 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1208 
 3 files changed, 1221 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..27c84c5
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1208 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+/* Slave I2C mode */
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/* I2C bootoloader commands */
+#define RM_CMD_BOOT_PAGE_WRT   0x0B/* send bl page write */
+#define RM_CMD_BOOT_WRT0x11/* send bl write */
+#define RM_CMD_BOOT_ACK0x22/* send ack*/
+#define RM_CMD_BOOT_CHK0x33/* send data check */
+#define RM_CMD_BOOT_READ   0x44/* send wait bl data ready*/
+
+#define RM_BOOT_RDY0xFF/* bl data ready */
+
+/* I2C main commands */
+#define RM_CMD_QUERY_BANK  0x2B
+#define RM_CMD_DATA_BANK   0x4D
+#define RM_CMD_ENTER_SLEEP 0x4E
+#define RM_CMD_BANK_SWITCH 0xAA
+
+#define RM_RESET_MSG_ADDR  0x4004
+
+#define RM_MAX_READ_SIZE   56
+
+/* Touch relative info */
+#define RM_MAX_RETRIES 3
+#define RM_MAX_TOUCH_NUM   10
+#define RM_BOOT_DELAY_MS   100
+
+/* Offsets in contact data */
+#define RM_CONTACT_STATE_POS   0
+#define RM_CONTACT_X_POS   1
+#define RM_CONTACT_Y_POS   3
+#define RM_CONTACT_PRESSURE_POS5   /*FIXME, correct 5*/
+#define RM_CONTACT_WIDTH_X_POS 6
+#define RM_CONTACT_WIDTH_Y_POS 7
+
+/* Bootloader relative info */
+#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
+#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
+#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
+#define RM_FW_PAGE_SIZE128
+#define RM_MAX_FW_RETRIES  30
+#define RM_MAX_FW_SIZE (0xD000)/*define max firmware size*/
+
+#define RM_POWERON_DELAY_USEC  500
+#define RM_RESET_DELAY_MSEC50
+
+enum raydium_bl_cmd {
+   BL_HEADER = 0,
+   BL_PAGE_STR,
+   BL_PKG_IDX,
+   BL_DATA_STR,
+};
+
+enum raydium_bl_ack {
+   RAYDIUM_ACK_NULL = 0,
+   RAYDIUM_WAIT_READY,
+   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-23 Thread Dmitry Torokhov
Hi Jeffrey,

On Mon, May 23, 2016 at 10:43:53PM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> 
> >static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> >{
> > __le32 le_addr;
> > size_t xfer_len;
> > u32 shift_addr;
> > int error;
> >
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> >
> > le_addr = cpu_to_le32(addr);
> >
> > shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
> Drop this. Change touch MCU setting to solve this issue
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(le_addr));
> > if (!error)/*read from last byte addr.*/
> > error = raydium_i2c_read(client, le_addr & 0xff,
> >  data, xfer_len);
> > if (error)
> > return error;
> >
> > len -= xfer_len;
> > data += xfer_len;
> > addr += xfer_len;
> > }
> >
> > return 0;
> >}
> modify as below.
> 
> static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
> {
>   __le32 le_addr;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> 
>   le_addr = cpu_to_le32(addr);
> 
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len);

No, not "le_addr & 0xff", "addr & 0xff"! When you do calculations, you
have to do it using values in CPU endianness, not fixed endianness (BE
or LE) so that the code will work on all architectures.

>   if (error)
>   return error;
> 
>   len -= xfer_len;
>   data += xfer_len;
>   addr += xfer_len;
>   }
> 
>   return 0;
> }
> 
> >
> >>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
> >>>u16 page_idx, const void *data, size_t len)
> >>> {
> >>>   u8 buf[RM_BL_WRT_LEN];
> >>>   u8 pkg_idx = 1;
> >>>   size_t xfer_len;
> >>>   int error;
> >>> 
> >>>   while (len) {
> >>>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> >>>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
> >>>   /*FIXME,Touch MCU need zero index as start page*/
> >>>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
> >>>   buf[BL_PKG_IDX] = pkg_idx++;
> >>> 
> >>>   memcpy([BL_DATA_STR], data, xfer_len);
> >>> 
> >>>   if (len < RM_BL_WRT_PKG_SIZE) {
> >>>   buf[BL_PKG_IDX] = 4;
> Drop this one. Modfy boot loader firmware to meet this issue. So final 
> function as below.
> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u16 page_idx, const void *data, size_t len)
> {
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   /*FIXME,Touch MCU need zero index as start page*/
>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = pkg_idx++;
> 
>   memcpy([BL_DATA_STR], data, xfer_len);
> 
>   if (len < RM_BL_WRT_PKG_SIZE) {
>   memset(buf + BL_DATA_STR + xfer_len, 0xff,
>   RM_BL_WRT_PKG_SIZE - xfer_len);
>   }
> 
>   error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command failed for page %d, chunk 
> %d: %d\n",
>   page_idx, pkg_idx, error);
>   return error;
>   }
>   data += xfer_len;
>   len -= xfer_len;
>   }
> 
>   return error;
> }

What will be the trigger for the flash? If you really need full page,
then you want to :

BUILD_BUG_ON((RM_FW_PAGE_SIZE % RM_BL_WRT_PKG_SIZE) != 0);

for (i = 0; i < RM_FW_PAGE_SIZE / RM_BL_WRT_PKG_SIZE; i++) {
buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
buf[BL_PAGE_STR] = i ? 0xff : 0;
buf[BL_PKG_IDX] = i;

xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
memcpy([BL_DATA_STR], data, xfer_len);
if (len < RM_BL_WRT_PKG_SIZE)

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-23 Thread Dmitry Torokhov
Hi Jeffrey,

On Mon, May 23, 2016 at 10:43:53PM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> 
> >static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> >{
> > __le32 le_addr;
> > size_t xfer_len;
> > u32 shift_addr;
> > int error;
> >
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> >
> > le_addr = cpu_to_le32(addr);
> >
> > shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
> Drop this. Change touch MCU setting to solve this issue
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(le_addr));
> > if (!error)/*read from last byte addr.*/
> > error = raydium_i2c_read(client, le_addr & 0xff,
> >  data, xfer_len);
> > if (error)
> > return error;
> >
> > len -= xfer_len;
> > data += xfer_len;
> > addr += xfer_len;
> > }
> >
> > return 0;
> >}
> modify as below.
> 
> static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
> {
>   __le32 le_addr;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> 
>   le_addr = cpu_to_le32(addr);
> 
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len);

No, not "le_addr & 0xff", "addr & 0xff"! When you do calculations, you
have to do it using values in CPU endianness, not fixed endianness (BE
or LE) so that the code will work on all architectures.

>   if (error)
>   return error;
> 
>   len -= xfer_len;
>   data += xfer_len;
>   addr += xfer_len;
>   }
> 
>   return 0;
> }
> 
> >
> >>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
> >>>u16 page_idx, const void *data, size_t len)
> >>> {
> >>>   u8 buf[RM_BL_WRT_LEN];
> >>>   u8 pkg_idx = 1;
> >>>   size_t xfer_len;
> >>>   int error;
> >>> 
> >>>   while (len) {
> >>>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> >>>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
> >>>   /*FIXME,Touch MCU need zero index as start page*/
> >>>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
> >>>   buf[BL_PKG_IDX] = pkg_idx++;
> >>> 
> >>>   memcpy([BL_DATA_STR], data, xfer_len);
> >>> 
> >>>   if (len < RM_BL_WRT_PKG_SIZE) {
> >>>   buf[BL_PKG_IDX] = 4;
> Drop this one. Modfy boot loader firmware to meet this issue. So final 
> function as below.
> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u16 page_idx, const void *data, size_t len)
> {
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   /*FIXME,Touch MCU need zero index as start page*/
>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = pkg_idx++;
> 
>   memcpy([BL_DATA_STR], data, xfer_len);
> 
>   if (len < RM_BL_WRT_PKG_SIZE) {
>   memset(buf + BL_DATA_STR + xfer_len, 0xff,
>   RM_BL_WRT_PKG_SIZE - xfer_len);
>   }
> 
>   error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command failed for page %d, chunk 
> %d: %d\n",
>   page_idx, pkg_idx, error);
>   return error;
>   }
>   data += xfer_len;
>   len -= xfer_len;
>   }
> 
>   return error;
> }

What will be the trigger for the flash? If you really need full page,
then you want to :

BUILD_BUG_ON((RM_FW_PAGE_SIZE % RM_BL_WRT_PKG_SIZE) != 0);

for (i = 0; i < RM_FW_PAGE_SIZE / RM_BL_WRT_PKG_SIZE; i++) {
buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
buf[BL_PAGE_STR] = i ? 0xff : 0;
buf[BL_PKG_IDX] = i;

xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
memcpy([BL_DATA_STR], data, xfer_len);
if (len < RM_BL_WRT_PKG_SIZE)

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-23 Thread jeffrey.lin
Hi Dmitry:

>static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
>{
>   __le32 le_addr;
>   size_t xfer_len;
>   u32 shift_addr;
>   int error;
>
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>
>   le_addr = cpu_to_le32(addr);
>
>   shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
Drop this. Change touch MCU setting to solve this issue
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len);
>   if (error)
>   return error;
>
>   len -= xfer_len;
>   data += xfer_len;
>   addr += xfer_len;
>   }
>
>   return 0;
>}
modify as below.

static int raydium_i2c_read_message(struct i2c_client *client,
u32 addr, void *data, size_t len)
{
__le32 le_addr;
size_t xfer_len;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);

le_addr = cpu_to_le32(addr);

error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
 _addr, sizeof(le_addr));
if (!error)/*read from last byte addr.*/
error = raydium_i2c_read(client, le_addr & 0xff,
 data, xfer_len);
if (error)
return error;

len -= xfer_len;
data += xfer_len;
addr += xfer_len;
}

return 0;
}

>
>>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>>>  u16 page_idx, const void *data, size_t len)
>>> {
>>> u8 buf[RM_BL_WRT_LEN];
>>> u8 pkg_idx = 1;
>>> size_t xfer_len;
>>> int error;
>>> 
>>> while (len) {
>>> xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>>> buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>>> /*FIXME,Touch MCU need zero index as start page*/
>>> buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>>> buf[BL_PKG_IDX] = pkg_idx++;
>>> 
>>> memcpy([BL_DATA_STR], data, xfer_len);
>>> 
>>> if (len < RM_BL_WRT_PKG_SIZE) {
>>> buf[BL_PKG_IDX] = 4;
Drop this one. Modfy boot loader firmware to meet this issue. So final function 
as below.
static int raydium_i2c_fw_write_page(struct i2c_client *client,
 u16 page_idx, const void *data, size_t len)
{
u8 buf[RM_BL_WRT_LEN];
u8 pkg_idx = 1;
size_t xfer_len;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
/*FIXME,Touch MCU need zero index as start page*/
buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
buf[BL_PKG_IDX] = pkg_idx++;

memcpy([BL_DATA_STR], data, xfer_len);

if (len < RM_BL_WRT_PKG_SIZE) {
memset(buf + BL_DATA_STR + xfer_len, 0xff,
RM_BL_WRT_PKG_SIZE - xfer_len);
}

error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
 RAYDIUM_WAIT_READY);
if (error) {
dev_err(>dev,
"page write command failed for page %d, chunk 
%d: %d\n",
page_idx, pkg_idx, error);
return error;
}
data += xfer_len;
len -= xfer_len;
}

return error;
}
Otherwise, Do you have any concern about my patch? If not, I'll send new patch 
soon.

Thanks.

Jeffrey


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-23 Thread jeffrey.lin
Hi Dmitry:

>static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
>{
>   __le32 le_addr;
>   size_t xfer_len;
>   u32 shift_addr;
>   int error;
>
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>
>   le_addr = cpu_to_le32(addr);
>
>   shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
Drop this. Change touch MCU setting to solve this issue
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len);
>   if (error)
>   return error;
>
>   len -= xfer_len;
>   data += xfer_len;
>   addr += xfer_len;
>   }
>
>   return 0;
>}
modify as below.

static int raydium_i2c_read_message(struct i2c_client *client,
u32 addr, void *data, size_t len)
{
__le32 le_addr;
size_t xfer_len;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);

le_addr = cpu_to_le32(addr);

error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
 _addr, sizeof(le_addr));
if (!error)/*read from last byte addr.*/
error = raydium_i2c_read(client, le_addr & 0xff,
 data, xfer_len);
if (error)
return error;

len -= xfer_len;
data += xfer_len;
addr += xfer_len;
}

return 0;
}

>
>>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>>>  u16 page_idx, const void *data, size_t len)
>>> {
>>> u8 buf[RM_BL_WRT_LEN];
>>> u8 pkg_idx = 1;
>>> size_t xfer_len;
>>> int error;
>>> 
>>> while (len) {
>>> xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>>> buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>>> /*FIXME,Touch MCU need zero index as start page*/
>>> buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>>> buf[BL_PKG_IDX] = pkg_idx++;
>>> 
>>> memcpy([BL_DATA_STR], data, xfer_len);
>>> 
>>> if (len < RM_BL_WRT_PKG_SIZE) {
>>> buf[BL_PKG_IDX] = 4;
Drop this one. Modfy boot loader firmware to meet this issue. So final function 
as below.
static int raydium_i2c_fw_write_page(struct i2c_client *client,
 u16 page_idx, const void *data, size_t len)
{
u8 buf[RM_BL_WRT_LEN];
u8 pkg_idx = 1;
size_t xfer_len;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
/*FIXME,Touch MCU need zero index as start page*/
buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
buf[BL_PKG_IDX] = pkg_idx++;

memcpy([BL_DATA_STR], data, xfer_len);

if (len < RM_BL_WRT_PKG_SIZE) {
memset(buf + BL_DATA_STR + xfer_len, 0xff,
RM_BL_WRT_PKG_SIZE - xfer_len);
}

error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
 RAYDIUM_WAIT_READY);
if (error) {
dev_err(>dev,
"page write command failed for page %d, chunk 
%d: %d\n",
page_idx, pkg_idx, error);
return error;
}
data += xfer_len;
len -= xfer_len;
}

return error;
}
Otherwise, Do you have any concern about my patch? If not, I'll send new patch 
soon.

Thanks.

Jeffrey


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-22 Thread Dmitry Torokhov
On May 22, 2016 2:32:59 AM PDT, "jeffrey.lin"  wrote:
>Hi Dmitry:
>
>+static int raydium_i2c_read_message(struct i2c_client *client,
>+  u32 addr, void *data, size_t len)
>+{
>+  __be32 be_addr;
>+  size_t xfer_len;
>+  int error;
>+
>+  while (len) {
>+  xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>+
>+  be_addr = cpu_to_be32(addr);
>+
>+  error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>+   _addr, sizeof(be_addr));
>+  if (!error)
>+  error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
>+   data, xfer_len);
>+  if (error)
>+  return error;
>+
>+  len -= xfer_len;
>+  data += xfer_len;
>+  addr += xfer_len;
>+  }
>+
>+  return 0;
>+}
>I change access address method of touch MCU direct mode so that I can
>change raydium i2c driver as below.
>
>static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
>{
>   __le32 le_addr;
>   size_t xfer_len;
>   u32 shift_addr;
>   int error;
>
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>
>   le_addr = cpu_to_le32(addr);
>
>   shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len);
>   if (error)
>   return error;
>
>   len -= xfer_len;
>   data += xfer_len;
>   addr += xfer_len;
>   }
>
>   return 0;
>}
>Is this okay? If okay, I will use this form update one new patch.

Why? It has the same problem - you can not do calculations on a variable in 
fixed endianness, because you do not know if your code will run on big or 
little endian CPU.

Doesn't my version of the code work?

>
>>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>>>  u16 page_idx, const void *data, size_t len)
>>> {
>>> u8 buf[RM_BL_WRT_LEN];
>>> u8 pkg_idx = 1;
>>> size_t xfer_len;
>>> int error;
>>> 
>>> while (len) {
>>> xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>>> buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>>> /*FIXME,Touch MCU need zero index as start page*/
>>> buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>>> buf[BL_PKG_IDX] = pkg_idx++;
>>> 
>>> memcpy([BL_DATA_STR], data, xfer_len);
>>> 
>>> if (len < RM_BL_WRT_PKG_SIZE) {
>>> buf[BL_PKG_IDX] = 4;
>
>>Why 4???
>4 is trigger index for write flash. Our page write size is 128 bytes,
>but in order to meet maximum I2C bus read/write byte limite and need
>fill full all pages of 128 bytes. So that I split 128 bytes to "4"
>section, and start burning flash if touch MCU get index "4". 

That is not the best way of handling this. What if you get 2 blocks of 
RM_BL_WRT_PKG_SIZE data worth? You will never get to index 4. You should be 
tracking number of bytes received and do flash when you get full page.

Hi Jeffrey,
Thanks.

-- 
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-22 Thread Dmitry Torokhov
On May 22, 2016 2:32:59 AM PDT, "jeffrey.lin"  wrote:
>Hi Dmitry:
>
>+static int raydium_i2c_read_message(struct i2c_client *client,
>+  u32 addr, void *data, size_t len)
>+{
>+  __be32 be_addr;
>+  size_t xfer_len;
>+  int error;
>+
>+  while (len) {
>+  xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>+
>+  be_addr = cpu_to_be32(addr);
>+
>+  error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>+   _addr, sizeof(be_addr));
>+  if (!error)
>+  error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
>+   data, xfer_len);
>+  if (error)
>+  return error;
>+
>+  len -= xfer_len;
>+  data += xfer_len;
>+  addr += xfer_len;
>+  }
>+
>+  return 0;
>+}
>I change access address method of touch MCU direct mode so that I can
>change raydium i2c driver as below.
>
>static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
>{
>   __le32 le_addr;
>   size_t xfer_len;
>   u32 shift_addr;
>   int error;
>
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>
>   le_addr = cpu_to_le32(addr);
>
>   shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(le_addr));
>   if (!error)/*read from last byte addr.*/
>   error = raydium_i2c_read(client, le_addr & 0xff,
>data, xfer_len);
>   if (error)
>   return error;
>
>   len -= xfer_len;
>   data += xfer_len;
>   addr += xfer_len;
>   }
>
>   return 0;
>}
>Is this okay? If okay, I will use this form update one new patch.

Why? It has the same problem - you can not do calculations on a variable in 
fixed endianness, because you do not know if your code will run on big or 
little endian CPU.

Doesn't my version of the code work?

>
>>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>>>  u16 page_idx, const void *data, size_t len)
>>> {
>>> u8 buf[RM_BL_WRT_LEN];
>>> u8 pkg_idx = 1;
>>> size_t xfer_len;
>>> int error;
>>> 
>>> while (len) {
>>> xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>>> buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>>> /*FIXME,Touch MCU need zero index as start page*/
>>> buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>>> buf[BL_PKG_IDX] = pkg_idx++;
>>> 
>>> memcpy([BL_DATA_STR], data, xfer_len);
>>> 
>>> if (len < RM_BL_WRT_PKG_SIZE) {
>>> buf[BL_PKG_IDX] = 4;
>
>>Why 4???
>4 is trigger index for write flash. Our page write size is 128 bytes,
>but in order to meet maximum I2C bus read/write byte limite and need
>fill full all pages of 128 bytes. So that I split 128 bytes to "4"
>section, and start burning flash if touch MCU get index "4". 

That is not the best way of handling this. What if you get 2 blocks of 
RM_BL_WRT_PKG_SIZE data worth? You will never get to index 4. You should be 
tracking number of bytes received and do flash when you get full page.

Hi Jeffrey,
Thanks.

-- 
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-22 Thread jeffrey.lin
Hi Dmitry:

>>  if (len < RM_BL_WRT_PKG_SIZE) {
>>  buf[BL_PKG_IDX] = 4;

>Why 4???
4 is trigger index for write flash. Our page write size is 128 bytes, 
but in order to meet maximum I2C bus read/write byte limite and need 
fill full all pages of 128 bytes. So that I split 128 bytes to "4" 
section, and start burning flash if touch MCU get index "4". 


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-22 Thread jeffrey.lin
Hi Dmitry:

>>  if (len < RM_BL_WRT_PKG_SIZE) {
>>  buf[BL_PKG_IDX] = 4;

>Why 4???
4 is trigger index for write flash. Our page write size is 128 bytes, 
but in order to meet maximum I2C bus read/write byte limite and need 
fill full all pages of 128 bytes. So that I split 128 bytes to "4" 
section, and start burning flash if touch MCU get index "4". 


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-22 Thread jeffrey.lin
Hi Dmitry:

+static int raydium_i2c_read_message(struct i2c_client *client,
+   u32 addr, void *data, size_t len)
+{
+   __be32 be_addr;
+   size_t xfer_len;
+   int error;
+
+   while (len) {
+   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
+
+   be_addr = cpu_to_be32(addr);
+
+   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
+_addr, sizeof(be_addr));
+   if (!error)
+   error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
+data, xfer_len);
+   if (error)
+   return error;
+
+   len -= xfer_len;
+   data += xfer_len;
+   addr += xfer_len;
+   }
+
+   return 0;
+}
I change access address method of touch MCU direct mode so that I can change 
raydium i2c driver as below.

static int raydium_i2c_read_message(struct i2c_client *client,
u32 addr, void *data, size_t len)
{
__le32 le_addr;
size_t xfer_len;
u32 shift_addr;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);

le_addr = cpu_to_le32(addr);

shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
 _addr, sizeof(le_addr));
if (!error)/*read from last byte addr.*/
error = raydium_i2c_read(client, le_addr & 0xff,
 data, xfer_len);
if (error)
return error;

len -= xfer_len;
data += xfer_len;
addr += xfer_len;
}

return 0;
}
Is this okay? If okay, I will use this form update one new patch.

>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>>   u16 page_idx, const void *data, size_t len)
>> {
>>  u8 buf[RM_BL_WRT_LEN];
>>  u8 pkg_idx = 1;
>>  size_t xfer_len;
>>  int error;
>> 
>>  while (len) {
>>  xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>>  buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>>  /*FIXME,Touch MCU need zero index as start page*/
>>  buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>>  buf[BL_PKG_IDX] = pkg_idx++;
>> 
>>  memcpy([BL_DATA_STR], data, xfer_len);
>> 
>>  if (len < RM_BL_WRT_PKG_SIZE) {
>>  buf[BL_PKG_IDX] = 4;

>Why 4???
4 is trigger index for write flash. Our page write size is 128 bytes, but in 
order to meet maximum I2C bus read/write byte limite and need fill full all 
pages of 128 bytes. So that I split 128 bytes to "4" section, and start burning 
flash if touch MCU get index "4". 


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-22 Thread jeffrey.lin
Hi Dmitry:

+static int raydium_i2c_read_message(struct i2c_client *client,
+   u32 addr, void *data, size_t len)
+{
+   __be32 be_addr;
+   size_t xfer_len;
+   int error;
+
+   while (len) {
+   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
+
+   be_addr = cpu_to_be32(addr);
+
+   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
+_addr, sizeof(be_addr));
+   if (!error)
+   error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
+data, xfer_len);
+   if (error)
+   return error;
+
+   len -= xfer_len;
+   data += xfer_len;
+   addr += xfer_len;
+   }
+
+   return 0;
+}
I change access address method of touch MCU direct mode so that I can change 
raydium i2c driver as below.

static int raydium_i2c_read_message(struct i2c_client *client,
u32 addr, void *data, size_t len)
{
__le32 le_addr;
size_t xfer_len;
u32 shift_addr;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);

le_addr = cpu_to_le32(addr);

shift_addr = le_addr >> 8;/*send the first 3rd byte addr.*/
error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
 _addr, sizeof(le_addr));
if (!error)/*read from last byte addr.*/
error = raydium_i2c_read(client, le_addr & 0xff,
 data, xfer_len);
if (error)
return error;

len -= xfer_len;
data += xfer_len;
addr += xfer_len;
}

return 0;
}
Is this okay? If okay, I will use this form update one new patch.

>> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>>   u16 page_idx, const void *data, size_t len)
>> {
>>  u8 buf[RM_BL_WRT_LEN];
>>  u8 pkg_idx = 1;
>>  size_t xfer_len;
>>  int error;
>> 
>>  while (len) {
>>  xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>>  buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>>  /*FIXME,Touch MCU need zero index as start page*/
>>  buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>>  buf[BL_PKG_IDX] = pkg_idx++;
>> 
>>  memcpy([BL_DATA_STR], data, xfer_len);
>> 
>>  if (len < RM_BL_WRT_PKG_SIZE) {
>>  buf[BL_PKG_IDX] = 4;

>Why 4???
4 is trigger index for write flash. Our page write size is 128 bytes, but in 
order to meet maximum I2C bus read/write byte limite and need fill full all 
pages of 128 bytes. So that I split 128 bytes to "4" section, and start burning 
flash if touch MCU get index "4". 


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-21 Thread Dmitry Torokhov
On Wed, May 18, 2016 at 12:07:02AM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> > >static int raydium_i2c_read_message(struct i2c_client *client,
> > >   u32 addr, void *data, size_t len)
> > >{
> > >   __be32 be_addr;
> > >   size_t xfer_len;
> > >   int error;
> > >   while (len) {
> > >   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> > >
> > >   be_addr = cpu_to_be32(addr);
> > >
> > >   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> > >_addr, sizeof(be_addr));
> > >   if (!error)
> > >   error = raydium_i2c_read(client, addr & 0xff,
> > >data, xfer_len);
> > Change as:
> > if (!error)
> > error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
> >  data, xfer_len);
> 
> >I think it is the same on LE, and I suspect it will not work correctly
> >on BE... You want to have the 8 least significant bits of the bank to be
> >used as the address, right?

> This function work correctly with the kernel 3.18 of chromebook in my
> hand. Raydium touch direct access mode can recieve the BE address

That is because it is a little-endian device.

>
> after bank switch command 0xaa. For example, if we'll read 10 bytes
> data begin on 0x12345678. We need send the command sequences as 0xaa->
> 0x12->0x34->0x56-> 0x78 and then recive 10 bytes from 0x78.
> 

Right. So the thing is - on any architecture, be it little- or
big-endian, expression "value & 0xff" will extract the 8 least
significant bits from the value, while "(value >> 24) & 0xff" will
extract the most significant bits (assuming that the value is 32 bits). So with 
your example if you do
cpu_to_be32() on LE architecture it will actually reshuffle the bytes so
that former LSB will become MSB and then you will extract that MSB and
use it. On BE arches cpu_to_be32() is a noop, so addr and be_addr will
have the same value, and your expression will produce 0x12 and not 0x78
as you expect. On the other hand, doing "addr & 0xff" will produce 0x78
regardless of endianness.

> > static int raydium_i2c_fw_write_page(struct i2c_client *client,
> >  u16 page_idx, const void *data, size_t len)
> > {
> > u8 buf[RM_BL_WRT_LEN];
> > u8 pkg_idx = 1;
> > u8 div_cnt;
> > size_t xfer_len;
> > int error;
> > int i;
> > 
> > div_cnt = len % RM_BL_WRT_PKG_SIZE ?
> > len / RM_BL_WRT_PKG_SIZE + 1:len / RM_BL_WRT_PKG_SIZE;
> >
> >Drop this. BTW, if you ever need it we have DIV_ROUND_UP macro.
> 
> > 
> > for (i = 0; i < div_cnt; i++) {
> >
> > while (len) {
> >
> > xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> > buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
> > /*FIXME,Touch MCU need zero index as start page*/
> > buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
> > buf[BL_PKG_IDX] = pkg_idx++;
> > 
> > memcpy([BL_DATA_STR], data, xfer_len);
> >
> > /* we need to pad to full page size */
> > if (len < RM_BL_WRT_PKG_SIZE)
> > memset([BL_DATA_STR] + len, 0xff,
> > RM_BL_WRT_PKG_SIZE - len);
> > 
> > if (len == 0)
> > memset(buf + BL_DATA_STR, 0xff, RM_BL_WRT_PKG_SIZE);
> > else if (len < RM_BL_WRT_PKG_SIZE)
> > memset(buf + BL_DATA_STR + xfer_len, 0xff,
> > RM_BL_WRT_PKG_SIZE - xfer_len);
> > 
> > error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
> >  RAYDIUM_WAIT_READY);
> > if (error) {
> > dev_err(>dev,
> > "page write command failed for page %d, chunk 
> > %d: %d\n",
> > page_idx, pkg_idx, error);
> > return error;
> > }
> > data += RM_BL_WRT_PKG_SIZE;
> > len -= RM_BL_WRT_PKG_SIZE;
> > }
> > 
> > return error;
> > }
> Modify as below.
> 
> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u16 page_idx, const void *data, size_t len)
> {
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   /*FIXME,Touch MCU need zero index as start page*/
>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = pkg_idx++;
> 
>   memcpy([BL_DATA_STR], data, xfer_len);
> 
>   if (len < RM_BL_WRT_PKG_SIZE) {
>   buf[BL_PKG_IDX] = 4;

Why 4???

>   memset(buf + BL_DATA_STR + xfer_len, 0xff,
>   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-21 Thread Dmitry Torokhov
On Wed, May 18, 2016 at 12:07:02AM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> > >static int raydium_i2c_read_message(struct i2c_client *client,
> > >   u32 addr, void *data, size_t len)
> > >{
> > >   __be32 be_addr;
> > >   size_t xfer_len;
> > >   int error;
> > >   while (len) {
> > >   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> > >
> > >   be_addr = cpu_to_be32(addr);
> > >
> > >   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> > >_addr, sizeof(be_addr));
> > >   if (!error)
> > >   error = raydium_i2c_read(client, addr & 0xff,
> > >data, xfer_len);
> > Change as:
> > if (!error)
> > error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
> >  data, xfer_len);
> 
> >I think it is the same on LE, and I suspect it will not work correctly
> >on BE... You want to have the 8 least significant bits of the bank to be
> >used as the address, right?

> This function work correctly with the kernel 3.18 of chromebook in my
> hand. Raydium touch direct access mode can recieve the BE address

That is because it is a little-endian device.

>
> after bank switch command 0xaa. For example, if we'll read 10 bytes
> data begin on 0x12345678. We need send the command sequences as 0xaa->
> 0x12->0x34->0x56-> 0x78 and then recive 10 bytes from 0x78.
> 

Right. So the thing is - on any architecture, be it little- or
big-endian, expression "value & 0xff" will extract the 8 least
significant bits from the value, while "(value >> 24) & 0xff" will
extract the most significant bits (assuming that the value is 32 bits). So with 
your example if you do
cpu_to_be32() on LE architecture it will actually reshuffle the bytes so
that former LSB will become MSB and then you will extract that MSB and
use it. On BE arches cpu_to_be32() is a noop, so addr and be_addr will
have the same value, and your expression will produce 0x12 and not 0x78
as you expect. On the other hand, doing "addr & 0xff" will produce 0x78
regardless of endianness.

> > static int raydium_i2c_fw_write_page(struct i2c_client *client,
> >  u16 page_idx, const void *data, size_t len)
> > {
> > u8 buf[RM_BL_WRT_LEN];
> > u8 pkg_idx = 1;
> > u8 div_cnt;
> > size_t xfer_len;
> > int error;
> > int i;
> > 
> > div_cnt = len % RM_BL_WRT_PKG_SIZE ?
> > len / RM_BL_WRT_PKG_SIZE + 1:len / RM_BL_WRT_PKG_SIZE;
> >
> >Drop this. BTW, if you ever need it we have DIV_ROUND_UP macro.
> 
> > 
> > for (i = 0; i < div_cnt; i++) {
> >
> > while (len) {
> >
> > xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> > buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
> > /*FIXME,Touch MCU need zero index as start page*/
> > buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
> > buf[BL_PKG_IDX] = pkg_idx++;
> > 
> > memcpy([BL_DATA_STR], data, xfer_len);
> >
> > /* we need to pad to full page size */
> > if (len < RM_BL_WRT_PKG_SIZE)
> > memset([BL_DATA_STR] + len, 0xff,
> > RM_BL_WRT_PKG_SIZE - len);
> > 
> > if (len == 0)
> > memset(buf + BL_DATA_STR, 0xff, RM_BL_WRT_PKG_SIZE);
> > else if (len < RM_BL_WRT_PKG_SIZE)
> > memset(buf + BL_DATA_STR + xfer_len, 0xff,
> > RM_BL_WRT_PKG_SIZE - xfer_len);
> > 
> > error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
> >  RAYDIUM_WAIT_READY);
> > if (error) {
> > dev_err(>dev,
> > "page write command failed for page %d, chunk 
> > %d: %d\n",
> > page_idx, pkg_idx, error);
> > return error;
> > }
> > data += RM_BL_WRT_PKG_SIZE;
> > len -= RM_BL_WRT_PKG_SIZE;
> > }
> > 
> > return error;
> > }
> Modify as below.
> 
> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u16 page_idx, const void *data, size_t len)
> {
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   size_t xfer_len;
>   int error;
> 
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   /*FIXME,Touch MCU need zero index as start page*/
>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = pkg_idx++;
> 
>   memcpy([BL_DATA_STR], data, xfer_len);
> 
>   if (len < RM_BL_WRT_PKG_SIZE) {
>   buf[BL_PKG_IDX] = 4;

Why 4???

>   memset(buf + BL_DATA_STR + xfer_len, 0xff,
>   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-17 Thread jeffrey.lin
Hi Dmitry:
> >static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> >{
> > __be32 be_addr;
> > size_t xfer_len;
> > int error;
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> >
> > be_addr = cpu_to_be32(addr);
> >
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(be_addr));
> > if (!error)
> > error = raydium_i2c_read(client, addr & 0xff,
> >  data, xfer_len);
> Change as:
>   if (!error)
>   error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
>data, xfer_len);

>I think it is the same on LE, and I suspect it will not work correctly
>on BE... You want to have the 8 least significant bits of the bank to be
>used as the address, right?
This function work correctly with the kernel 3.18 of chromebook in my hand. 
Raydium touch direct access mode can recieve the BE address after bank switch 
command 0xaa. For example, if we'll read 10 bytes data begin on 0x12345678. We 
need send the command sequences as 0xaa-> 0x12->0x34->0x56-> 0x78 and then 
recive 10 bytes from 0x78.

> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u16 page_idx, const void *data, size_t len)
> {
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   u8 div_cnt;
>   size_t xfer_len;
>   int error;
>   int i;
> 
>   div_cnt = len % RM_BL_WRT_PKG_SIZE ?
>   len / RM_BL_WRT_PKG_SIZE + 1:len / RM_BL_WRT_PKG_SIZE;
>
>Drop this. BTW, if you ever need it we have DIV_ROUND_UP macro.

> 
>   for (i = 0; i < div_cnt; i++) {
>
>   while (len) {
>
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   /*FIXME,Touch MCU need zero index as start page*/
>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = pkg_idx++;
> 
>   memcpy([BL_DATA_STR], data, xfer_len);
>
>   /* we need to pad to full page size */
>   if (len < RM_BL_WRT_PKG_SIZE)
>   memset([BL_DATA_STR] + len, 0xff,
>   RM_BL_WRT_PKG_SIZE - len);
> 
>   if (len == 0)
>   memset(buf + BL_DATA_STR, 0xff, RM_BL_WRT_PKG_SIZE);
>   else if (len < RM_BL_WRT_PKG_SIZE)
>   memset(buf + BL_DATA_STR + xfer_len, 0xff,
>   RM_BL_WRT_PKG_SIZE - xfer_len);
> 
>   error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command failed for page %d, chunk 
> %d: %d\n",
>   page_idx, pkg_idx, error);
>   return error;
>   }
>   data += RM_BL_WRT_PKG_SIZE;
>   len -= RM_BL_WRT_PKG_SIZE;
>   }
> 
>   return error;
> }
Modify as below.

static int raydium_i2c_fw_write_page(struct i2c_client *client,
 u16 page_idx, const void *data, size_t len)
{
u8 buf[RM_BL_WRT_LEN];
u8 pkg_idx = 1;
size_t xfer_len;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
/*FIXME,Touch MCU need zero index as start page*/
buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
buf[BL_PKG_IDX] = pkg_idx++;

memcpy([BL_DATA_STR], data, xfer_len);

if (len < RM_BL_WRT_PKG_SIZE) {
buf[BL_PKG_IDX] = 4;
memset(buf + BL_DATA_STR + xfer_len, 0xff,
RM_BL_WRT_PKG_SIZE - xfer_len);
}

error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
 RAYDIUM_WAIT_READY);
if (error) {
dev_err(>dev,
"page write command failed for page %d, chunk 
%d: %d\n",
page_idx, pkg_idx, error);
return error;
}
data += xfer_len;
len -= xfer_len;
}

return error;
> 
> >static void raydium_mt_event(struct raydium_data *ts)
> >{
> > int i;
> > int error;
> memory allocate
>   ts->report_data = kmalloc(ts->report_size, GFP_KERNEL);
>   if (!ts->report_data)
>   return;
>
>I thought I was allocating it after I queried the 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-17 Thread jeffrey.lin
Hi Dmitry:
> >static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> >{
> > __be32 be_addr;
> > size_t xfer_len;
> > int error;
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> >
> > be_addr = cpu_to_be32(addr);
> >
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(be_addr));
> > if (!error)
> > error = raydium_i2c_read(client, addr & 0xff,
> >  data, xfer_len);
> Change as:
>   if (!error)
>   error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
>data, xfer_len);

>I think it is the same on LE, and I suspect it will not work correctly
>on BE... You want to have the 8 least significant bits of the bank to be
>used as the address, right?
This function work correctly with the kernel 3.18 of chromebook in my hand. 
Raydium touch direct access mode can recieve the BE address after bank switch 
command 0xaa. For example, if we'll read 10 bytes data begin on 0x12345678. We 
need send the command sequences as 0xaa-> 0x12->0x34->0x56-> 0x78 and then 
recive 10 bytes from 0x78.

> static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u16 page_idx, const void *data, size_t len)
> {
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   u8 div_cnt;
>   size_t xfer_len;
>   int error;
>   int i;
> 
>   div_cnt = len % RM_BL_WRT_PKG_SIZE ?
>   len / RM_BL_WRT_PKG_SIZE + 1:len / RM_BL_WRT_PKG_SIZE;
>
>Drop this. BTW, if you ever need it we have DIV_ROUND_UP macro.

> 
>   for (i = 0; i < div_cnt; i++) {
>
>   while (len) {
>
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>   buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
>   /*FIXME,Touch MCU need zero index as start page*/
>   buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
>   buf[BL_PKG_IDX] = pkg_idx++;
> 
>   memcpy([BL_DATA_STR], data, xfer_len);
>
>   /* we need to pad to full page size */
>   if (len < RM_BL_WRT_PKG_SIZE)
>   memset([BL_DATA_STR] + len, 0xff,
>   RM_BL_WRT_PKG_SIZE - len);
> 
>   if (len == 0)
>   memset(buf + BL_DATA_STR, 0xff, RM_BL_WRT_PKG_SIZE);
>   else if (len < RM_BL_WRT_PKG_SIZE)
>   memset(buf + BL_DATA_STR + xfer_len, 0xff,
>   RM_BL_WRT_PKG_SIZE - xfer_len);
> 
>   error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command failed for page %d, chunk 
> %d: %d\n",
>   page_idx, pkg_idx, error);
>   return error;
>   }
>   data += RM_BL_WRT_PKG_SIZE;
>   len -= RM_BL_WRT_PKG_SIZE;
>   }
> 
>   return error;
> }
Modify as below.

static int raydium_i2c_fw_write_page(struct i2c_client *client,
 u16 page_idx, const void *data, size_t len)
{
u8 buf[RM_BL_WRT_LEN];
u8 pkg_idx = 1;
size_t xfer_len;
int error;

while (len) {
xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
buf[BL_HEADER] = RM_CMD_BOOT_PAGE_WRT;
/*FIXME,Touch MCU need zero index as start page*/
buf[BL_PAGE_STR] = page_idx ? 0xff : 0;
buf[BL_PKG_IDX] = pkg_idx++;

memcpy([BL_DATA_STR], data, xfer_len);

if (len < RM_BL_WRT_PKG_SIZE) {
buf[BL_PKG_IDX] = 4;
memset(buf + BL_DATA_STR + xfer_len, 0xff,
RM_BL_WRT_PKG_SIZE - xfer_len);
}

error = raydium_i2c_write_object(client, buf, RM_BL_WRT_LEN,
 RAYDIUM_WAIT_READY);
if (error) {
dev_err(>dev,
"page write command failed for page %d, chunk 
%d: %d\n",
page_idx, pkg_idx, error);
return error;
}
data += xfer_len;
len -= xfer_len;
}

return error;
> 
> >static void raydium_mt_event(struct raydium_data *ts)
> >{
> > int i;
> > int error;
> memory allocate
>   ts->report_data = kmalloc(ts->report_size, GFP_KERNEL);
>   if (!ts->report_data)
>   return;
>
>I thought I was allocating it after I queried the 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-17 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1208 
 3 files changed, 1221 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..3d7ff5a
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1208 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+/* Slave I2C mode */
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/* I2C bootoloader commands */
+#define RM_CMD_BOOT_PAGE_WRT   0x0B/* send bl page write */
+#define RM_CMD_BOOT_WRT0x11/* send bl write */
+#define RM_CMD_BOOT_ACK0x22/* send ack*/
+#define RM_CMD_BOOT_CHK0x33/* send data check */
+#define RM_CMD_BOOT_READ   0x44/* send wait bl data ready*/
+
+#define RM_BOOT_RDY0xFF/* bl data ready */
+
+/* I2C main commands */
+#define RM_CMD_QUERY_BANK  0x2B
+#define RM_CMD_DATA_BANK   0x4D
+#define RM_CMD_ENTER_SLEEP 0x4E
+#define RM_CMD_BANK_SWITCH 0xAA
+
+#define RM_RESET_MSG_ADDR  0x4004
+
+#define RM_MAX_READ_SIZE   56
+
+/* Touch relative info */
+#define RM_MAX_RETRIES 3
+#define RM_MAX_TOUCH_NUM   10
+#define RM_BOOT_DELAY_MS   100
+
+/* Offsets in contact data */
+#define RM_CONTACT_STATE_POS   0
+#define RM_CONTACT_X_POS   1
+#define RM_CONTACT_Y_POS   3
+#define RM_CONTACT_PRESSURE_POS5   /*FIXME, correct 5*/
+#define RM_CONTACT_WIDTH_X_POS 6
+#define RM_CONTACT_WIDTH_Y_POS 7
+
+/* Bootloader relative info */
+#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
+#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
+#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
+#define RM_FW_PAGE_SIZE128
+#define RM_MAX_FW_RETRIES  30
+#define RM_MAX_FW_SIZE (0xD000)/*define max firmware size*/
+
+#define RM_POWERON_DELAY_USEC  500
+#define RM_RESET_DELAY_MSEC50
+
+enum raydium_bl_cmd {
+   BL_HEADER = 0,
+   BL_PAGE_STR,
+   BL_PKG_IDX,
+   BL_DATA_STR,
+};
+
+enum raydium_bl_ack {
+   RAYDIUM_ACK_NULL = 0,
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-17 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1208 
 3 files changed, 1221 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..3d7ff5a
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1208 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+/* Slave I2C mode */
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/* I2C bootoloader commands */
+#define RM_CMD_BOOT_PAGE_WRT   0x0B/* send bl page write */
+#define RM_CMD_BOOT_WRT0x11/* send bl write */
+#define RM_CMD_BOOT_ACK0x22/* send ack*/
+#define RM_CMD_BOOT_CHK0x33/* send data check */
+#define RM_CMD_BOOT_READ   0x44/* send wait bl data ready*/
+
+#define RM_BOOT_RDY0xFF/* bl data ready */
+
+/* I2C main commands */
+#define RM_CMD_QUERY_BANK  0x2B
+#define RM_CMD_DATA_BANK   0x4D
+#define RM_CMD_ENTER_SLEEP 0x4E
+#define RM_CMD_BANK_SWITCH 0xAA
+
+#define RM_RESET_MSG_ADDR  0x4004
+
+#define RM_MAX_READ_SIZE   56
+
+/* Touch relative info */
+#define RM_MAX_RETRIES 3
+#define RM_MAX_TOUCH_NUM   10
+#define RM_BOOT_DELAY_MS   100
+
+/* Offsets in contact data */
+#define RM_CONTACT_STATE_POS   0
+#define RM_CONTACT_X_POS   1
+#define RM_CONTACT_Y_POS   3
+#define RM_CONTACT_PRESSURE_POS5   /*FIXME, correct 5*/
+#define RM_CONTACT_WIDTH_X_POS 6
+#define RM_CONTACT_WIDTH_Y_POS 7
+
+/* Bootloader relative info */
+#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
+#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
+#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
+#define RM_FW_PAGE_SIZE128
+#define RM_MAX_FW_RETRIES  30
+#define RM_MAX_FW_SIZE (0xD000)/*define max firmware size*/
+
+#define RM_POWERON_DELAY_USEC  500
+#define RM_RESET_DELAY_MSEC50
+
+enum raydium_bl_cmd {
+   BL_HEADER = 0,
+   BL_PAGE_STR,
+   BL_PKG_IDX,
+   BL_DATA_STR,
+};
+
+enum raydium_bl_ack {
+   RAYDIUM_ACK_NULL = 0,
+   RAYDIUM_WAIT_READY,
+   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread Dmitry Torokhov
On Mon, May 16, 2016 at 09:41:45AM -0700, Dmitry Torokhov wrote:
> On Mon, May 16, 2016 at 11:46:51PM +0800, jeffrey.lin wrote:
> > Hi Dmitry:
> > I've finished issues under the format you suggested as below.
> > 
> > >#define RM_RESET_MSG_ADDR  0x4004
> > >#define RM_FASTBOOT_MSG_ADDR   0x5620
> > 
> > >#define RM_MAX_READ_SIZE   63
> > change maximum read size to 56 bytes
> > #define RM_MAX_READ_SIZE56
> 
> OK.
> 
> > 
> > >#define RM_CONTACT_X_POS   1
> > >#define RM_CONTACT_Y_POS   3
> > >#define RM_CONTACT_PRESSURE_POS5 // XXX - check - original was 4
> > #define RM_CONTACT_PRESSURE_POS 5   /*FIXME, correct 5*/
> 
> OK.
> 
> > 
> > >#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
> > >#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
> > >#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + 
> > >RM_BL_WRT_CMD_SIZE)
> > >#define RM_FW_PAGE_SIZE128
> > >#define RM_MAX_FW_RETRIES  30
> > additional maximum firmware size for protection
> > #define RM_MAX_FW_SIZE  (0xD000)/*define max firmware 
> > size*/
> 
> OK.
> 
> > 
> > >static int raydium_i2c_read_message(struct i2c_client *client,
> > >   u32 addr, void *data, size_t len)
> > >{
> > >   __be32 be_addr;
> > >   size_t xfer_len;
> > >   int error;
> > >   while (len) {
> > >   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> > >
> > >   be_addr = cpu_to_be32(addr);
> > >
> > >   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> > >_addr, sizeof(be_addr));
> > >   if (!error)
> > >   error = raydium_i2c_read(client, addr & 0xff,
> > >data, xfer_len);
> > Change as:
> > if (!error)
> > error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
> >  data, xfer_len);
> 
> I think it is the same on LE, and I suspect it will not work correctly
> on BE... You want to have the 8 least significant bits of the bank to be
> used as the address, right?
> 
> > 
> > >static int raydium_i2c_send_message(struct i2c_client *client,
> > >   u32 addr, const void *data, size_t len)
> > >{
> > >   __be32 be_addr = cpu_to_be32(addr);
> > >   int error;
> > >   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> > >_addr, sizeof(be_addr));
> > >   if (!error)
> > >   error = raydium_i2c_send(client, addr & 0xff, data, len);
> > Change as:
> > error = raydium_i2c_send(client, (be_addr >> 24) & 0xff,
> > data, len);
> 
> Same here.
> 
> > 
> > 
> > >static int raydium_i2c_fastboot(struct i2c_client *client)
> > >{
> > /*FIXME;Correct, direct access mode is word alignment*/
> > >   u8 buf[4];
> > >   int error;
> > >
> > >   error = raydium_i2c_read_message(client, RM_FASTBOOT_MSG_ADDR,
> > >buf, sizeof(buf));
> > 
> > >static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> > >{
> > >   struct i2c_client *client = ts->client;
> > >   static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
> > >   static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
> > >   u8 buf[4];
> > >   int error;
> > >
> > >   error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
> > >   if (!error) {
> > >   // XXX FIXME: why do we compare only 1st bytes? Do we even
> > >   // need 4-byte constants?
> > >   if (buf[0] == bl_area[0])
> > >   ts->boot_mode = RAYDIUM_TS_BLDR;
> > >   else if (buf[0] == main_area[0])
> > >   ts->boot_mode = RAYDIUM_TS_MAIN;
> > >   return 0;
> > >   }
> > >
> > >   return error;
> > >}
> > Change as below,
> > static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> > {
> > struct i2c_client *client = ts->client;
> > static const u8 bl_ack = 0x62;
> > static const u8 main_ack = 0x66;
> > u8 buf[4];
> > int error;
> > 
> > error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
> > if (!error) {
> > /*FIXME, changed as one byte comparison*/
> > if (buf[0] == bl_ack)
> > ts->boot_mode = RAYDIUM_TS_BLDR;
> > else if (buf[0] == main_ack)
> > ts->boot_mode = RAYDIUM_TS_MAIN;
> > return 0;
> > }
> > 
> > return error;
> > }
> > 
> > >static int raydium_i2c_fw_write_page(struct i2c_client *client,
> > >u8 page_idx, void *data, size_t len)
> > >{
> > >   u8 buf[RM_BL_WRT_LEN];
> > >   u8 pkg_idx = 1;
> > >   size_t xfer_len;
> > >   int error;
> > >
> > >   while (len) {
> > >   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> > >
> > >   buf[BL_HEADER] = 0x0b;
> > >   // XXX FIXME: is this correct? Do we really 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread Dmitry Torokhov
On Mon, May 16, 2016 at 09:41:45AM -0700, Dmitry Torokhov wrote:
> On Mon, May 16, 2016 at 11:46:51PM +0800, jeffrey.lin wrote:
> > Hi Dmitry:
> > I've finished issues under the format you suggested as below.
> > 
> > >#define RM_RESET_MSG_ADDR  0x4004
> > >#define RM_FASTBOOT_MSG_ADDR   0x5620
> > 
> > >#define RM_MAX_READ_SIZE   63
> > change maximum read size to 56 bytes
> > #define RM_MAX_READ_SIZE56
> 
> OK.
> 
> > 
> > >#define RM_CONTACT_X_POS   1
> > >#define RM_CONTACT_Y_POS   3
> > >#define RM_CONTACT_PRESSURE_POS5 // XXX - check - original was 4
> > #define RM_CONTACT_PRESSURE_POS 5   /*FIXME, correct 5*/
> 
> OK.
> 
> > 
> > >#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
> > >#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
> > >#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + 
> > >RM_BL_WRT_CMD_SIZE)
> > >#define RM_FW_PAGE_SIZE128
> > >#define RM_MAX_FW_RETRIES  30
> > additional maximum firmware size for protection
> > #define RM_MAX_FW_SIZE  (0xD000)/*define max firmware 
> > size*/
> 
> OK.
> 
> > 
> > >static int raydium_i2c_read_message(struct i2c_client *client,
> > >   u32 addr, void *data, size_t len)
> > >{
> > >   __be32 be_addr;
> > >   size_t xfer_len;
> > >   int error;
> > >   while (len) {
> > >   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> > >
> > >   be_addr = cpu_to_be32(addr);
> > >
> > >   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> > >_addr, sizeof(be_addr));
> > >   if (!error)
> > >   error = raydium_i2c_read(client, addr & 0xff,
> > >data, xfer_len);
> > Change as:
> > if (!error)
> > error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
> >  data, xfer_len);
> 
> I think it is the same on LE, and I suspect it will not work correctly
> on BE... You want to have the 8 least significant bits of the bank to be
> used as the address, right?
> 
> > 
> > >static int raydium_i2c_send_message(struct i2c_client *client,
> > >   u32 addr, const void *data, size_t len)
> > >{
> > >   __be32 be_addr = cpu_to_be32(addr);
> > >   int error;
> > >   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> > >_addr, sizeof(be_addr));
> > >   if (!error)
> > >   error = raydium_i2c_send(client, addr & 0xff, data, len);
> > Change as:
> > error = raydium_i2c_send(client, (be_addr >> 24) & 0xff,
> > data, len);
> 
> Same here.
> 
> > 
> > 
> > >static int raydium_i2c_fastboot(struct i2c_client *client)
> > >{
> > /*FIXME;Correct, direct access mode is word alignment*/
> > >   u8 buf[4];
> > >   int error;
> > >
> > >   error = raydium_i2c_read_message(client, RM_FASTBOOT_MSG_ADDR,
> > >buf, sizeof(buf));
> > 
> > >static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> > >{
> > >   struct i2c_client *client = ts->client;
> > >   static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
> > >   static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
> > >   u8 buf[4];
> > >   int error;
> > >
> > >   error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
> > >   if (!error) {
> > >   // XXX FIXME: why do we compare only 1st bytes? Do we even
> > >   // need 4-byte constants?
> > >   if (buf[0] == bl_area[0])
> > >   ts->boot_mode = RAYDIUM_TS_BLDR;
> > >   else if (buf[0] == main_area[0])
> > >   ts->boot_mode = RAYDIUM_TS_MAIN;
> > >   return 0;
> > >   }
> > >
> > >   return error;
> > >}
> > Change as below,
> > static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> > {
> > struct i2c_client *client = ts->client;
> > static const u8 bl_ack = 0x62;
> > static const u8 main_ack = 0x66;
> > u8 buf[4];
> > int error;
> > 
> > error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
> > if (!error) {
> > /*FIXME, changed as one byte comparison*/
> > if (buf[0] == bl_ack)
> > ts->boot_mode = RAYDIUM_TS_BLDR;
> > else if (buf[0] == main_ack)
> > ts->boot_mode = RAYDIUM_TS_MAIN;
> > return 0;
> > }
> > 
> > return error;
> > }
> > 
> > >static int raydium_i2c_fw_write_page(struct i2c_client *client,
> > >u8 page_idx, void *data, size_t len)
> > >{
> > >   u8 buf[RM_BL_WRT_LEN];
> > >   u8 pkg_idx = 1;
> > >   size_t xfer_len;
> > >   int error;
> > >
> > >   while (len) {
> > >   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> > >
> > >   buf[BL_HEADER] = 0x0b;
> > >   // XXX FIXME: is this correct? Do we really 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread Dmitry Torokhov
On Mon, May 16, 2016 at 11:46:51PM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> I've finished issues under the format you suggested as below.
> 
> >#define RM_RESET_MSG_ADDR0x4004
> >#define RM_FASTBOOT_MSG_ADDR 0x5620
> 
> >#define RM_MAX_READ_SIZE 63
> change maximum read size to 56 bytes
> #define RM_MAX_READ_SIZE  56

OK.

> 
> >#define RM_CONTACT_X_POS 1
> >#define RM_CONTACT_Y_POS 3
> >#define RM_CONTACT_PRESSURE_POS  5 // XXX - check - original was 4
> #define RM_CONTACT_PRESSURE_POS   5   /*FIXME, correct 5*/

OK.

> 
> >#define RM_BL_WRT_CMD_SIZE   3   /* bl flash wrt cmd size */
> >#define RM_BL_WRT_PKG_SIZE   32  /* bl wrt pkg size */
> >#define RM_BL_WRT_LEN(RM_BL_WRT_PKG_SIZE + 
> >RM_BL_WRT_CMD_SIZE)
> >#define RM_FW_PAGE_SIZE  128
> >#define RM_MAX_FW_RETRIES30
> additional maximum firmware size for protection
> #define RM_MAX_FW_SIZE(0xD000)/*define max firmware 
> size*/

OK.

> 
> >static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> >{
> > __be32 be_addr;
> > size_t xfer_len;
> > int error;
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> >
> > be_addr = cpu_to_be32(addr);
> >
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(be_addr));
> > if (!error)
> > error = raydium_i2c_read(client, addr & 0xff,
> >  data, xfer_len);
> Change as:
>   if (!error)
>   error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
>data, xfer_len);

I think it is the same on LE, and I suspect it will not work correctly
on BE... You want to have the 8 least significant bits of the bank to be
used as the address, right?

> 
> >static int raydium_i2c_send_message(struct i2c_client *client,
> > u32 addr, const void *data, size_t len)
> >{
> > __be32 be_addr = cpu_to_be32(addr);
> > int error;
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(be_addr));
> > if (!error)
> > error = raydium_i2c_send(client, addr & 0xff, data, len);
> Change as:
>   error = raydium_i2c_send(client, (be_addr >> 24) & 0xff,
>   data, len);

Same here.

> 
> 
> >static int raydium_i2c_fastboot(struct i2c_client *client)
> >{
>   /*FIXME;Correct, direct access mode is word alignment*/
> > u8 buf[4];
> > int error;
> >
> > error = raydium_i2c_read_message(client, RM_FASTBOOT_MSG_ADDR,
> >  buf, sizeof(buf));
> 
> >static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> >{
> > struct i2c_client *client = ts->client;
> > static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
> > static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
> > u8 buf[4];
> > int error;
> >
> > error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
> > if (!error) {
> > // XXX FIXME: why do we compare only 1st bytes? Do we even
> > // need 4-byte constants?
> > if (buf[0] == bl_area[0])
> > ts->boot_mode = RAYDIUM_TS_BLDR;
> > else if (buf[0] == main_area[0])
> > ts->boot_mode = RAYDIUM_TS_MAIN;
> > return 0;
> > }
> >
> > return error;
> >}
> Change as below,
> static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> {
>   struct i2c_client *client = ts->client;
>   static const u8 bl_ack = 0x62;
>   static const u8 main_ack = 0x66;
>   u8 buf[4];
>   int error;
> 
>   error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
>   if (!error) {
>   /*FIXME, changed as one byte comparison*/
>   if (buf[0] == bl_ack)
>   ts->boot_mode = RAYDIUM_TS_BLDR;
>   else if (buf[0] == main_ack)
>   ts->boot_mode = RAYDIUM_TS_MAIN;
>   return 0;
>   }
> 
>   return error;
> }
> 
> >static int raydium_i2c_fw_write_page(struct i2c_client *client,
> >  u8 page_idx, void *data, size_t len)
> >{
> > u8 buf[RM_BL_WRT_LEN];
> > u8 pkg_idx = 1;
> > size_t xfer_len;
> > int error;
> >
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> >
> > buf[BL_HEADER] = 0x0b;
> > // XXX FIXME: is this correct? Do we really want all pages
> > // after 1st to have 0xff? Should it be a counter?
> > // Why do we need both pages and packages within pages?
> > buf[BL_PAGE_STR] = 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread Dmitry Torokhov
On Mon, May 16, 2016 at 11:46:51PM +0800, jeffrey.lin wrote:
> Hi Dmitry:
> I've finished issues under the format you suggested as below.
> 
> >#define RM_RESET_MSG_ADDR0x4004
> >#define RM_FASTBOOT_MSG_ADDR 0x5620
> 
> >#define RM_MAX_READ_SIZE 63
> change maximum read size to 56 bytes
> #define RM_MAX_READ_SIZE  56

OK.

> 
> >#define RM_CONTACT_X_POS 1
> >#define RM_CONTACT_Y_POS 3
> >#define RM_CONTACT_PRESSURE_POS  5 // XXX - check - original was 4
> #define RM_CONTACT_PRESSURE_POS   5   /*FIXME, correct 5*/

OK.

> 
> >#define RM_BL_WRT_CMD_SIZE   3   /* bl flash wrt cmd size */
> >#define RM_BL_WRT_PKG_SIZE   32  /* bl wrt pkg size */
> >#define RM_BL_WRT_LEN(RM_BL_WRT_PKG_SIZE + 
> >RM_BL_WRT_CMD_SIZE)
> >#define RM_FW_PAGE_SIZE  128
> >#define RM_MAX_FW_RETRIES30
> additional maximum firmware size for protection
> #define RM_MAX_FW_SIZE(0xD000)/*define max firmware 
> size*/

OK.

> 
> >static int raydium_i2c_read_message(struct i2c_client *client,
> > u32 addr, void *data, size_t len)
> >{
> > __be32 be_addr;
> > size_t xfer_len;
> > int error;
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
> >
> > be_addr = cpu_to_be32(addr);
> >
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(be_addr));
> > if (!error)
> > error = raydium_i2c_read(client, addr & 0xff,
> >  data, xfer_len);
> Change as:
>   if (!error)
>   error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
>data, xfer_len);

I think it is the same on LE, and I suspect it will not work correctly
on BE... You want to have the 8 least significant bits of the bank to be
used as the address, right?

> 
> >static int raydium_i2c_send_message(struct i2c_client *client,
> > u32 addr, const void *data, size_t len)
> >{
> > __be32 be_addr = cpu_to_be32(addr);
> > int error;
> > error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
> >  _addr, sizeof(be_addr));
> > if (!error)
> > error = raydium_i2c_send(client, addr & 0xff, data, len);
> Change as:
>   error = raydium_i2c_send(client, (be_addr >> 24) & 0xff,
>   data, len);

Same here.

> 
> 
> >static int raydium_i2c_fastboot(struct i2c_client *client)
> >{
>   /*FIXME;Correct, direct access mode is word alignment*/
> > u8 buf[4];
> > int error;
> >
> > error = raydium_i2c_read_message(client, RM_FASTBOOT_MSG_ADDR,
> >  buf, sizeof(buf));
> 
> >static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> >{
> > struct i2c_client *client = ts->client;
> > static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
> > static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
> > u8 buf[4];
> > int error;
> >
> > error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
> > if (!error) {
> > // XXX FIXME: why do we compare only 1st bytes? Do we even
> > // need 4-byte constants?
> > if (buf[0] == bl_area[0])
> > ts->boot_mode = RAYDIUM_TS_BLDR;
> > else if (buf[0] == main_area[0])
> > ts->boot_mode = RAYDIUM_TS_MAIN;
> > return 0;
> > }
> >
> > return error;
> >}
> Change as below,
> static int raydium_i2c_check_fw_status(struct raydium_data *ts)
> {
>   struct i2c_client *client = ts->client;
>   static const u8 bl_ack = 0x62;
>   static const u8 main_ack = 0x66;
>   u8 buf[4];
>   int error;
> 
>   error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
>   if (!error) {
>   /*FIXME, changed as one byte comparison*/
>   if (buf[0] == bl_ack)
>   ts->boot_mode = RAYDIUM_TS_BLDR;
>   else if (buf[0] == main_ack)
>   ts->boot_mode = RAYDIUM_TS_MAIN;
>   return 0;
>   }
> 
>   return error;
> }
> 
> >static int raydium_i2c_fw_write_page(struct i2c_client *client,
> >  u8 page_idx, void *data, size_t len)
> >{
> > u8 buf[RM_BL_WRT_LEN];
> > u8 pkg_idx = 1;
> > size_t xfer_len;
> > int error;
> >
> > while (len) {
> > xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> >
> > buf[BL_HEADER] = 0x0b;
> > // XXX FIXME: is this correct? Do we really want all pages
> > // after 1st to have 0xff? Should it be a counter?
> > // Why do we need both pages and packages within pages?
> > buf[BL_PAGE_STR] = 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread jeffrey.lin
>static int raydium_i2c_do_update_firmware(struct raydium_data *ts,
>const struct firmware *fw)
>{
>   struct i2c_client *client = ts->client;
>   const void *data;
>   size_t data_len;
>   size_t len;
>   int page_nr;
>   int i;
>   int error;
>   u16 fw_checksum;
>
>   if (fw->size == 0) {
additional protect.
if (fw->size == 0 || fw->size > RM_MAX_FW_SIZE) {
>   dev_err(>dev, "Invalid firmware length\n");
>   return -EINVAL;
>   }
>
>   error = raydium_i2c_check_fw_status(ts);
>   if (error) {
>   dev_err(>dev, "Unable to access IC %d\n", error);
>   return error;
>   }
>
>   if (ts->boot_mode == RAYDIUM_TS_MAIN) {
>   for (i = 0; i < RM_MAX_RETRIES; i++) {
>   error = raydium_i2c_enter_bl(client);
>   if (!error) {
>   error = raydium_i2c_check_fw_status(ts);
>   if (error) {
>   dev_err(>dev,
>   "unable to access IC: %d\n",
>   error);
>   return error;
>   }
>
>   if (ts->boot_mode == RAYDIUM_TS_BLDR)
>   break;
>   }
>   }
>
>   if (ts->boot_mode == RAYDIUM_TS_MAIN) {
>   dev_err(>dev,
>   "failied to jump to boot loader: %d\n",
>   error);
>   return -EIO;
>   }
>   }
>
>   error = raydium_i2c_disable_watch_dog(client);
>   if (error)
>   return error;
>
>   error = raydium_i2c_check_path(client);
>   if (error)
>   return error;
>
>   error = raydium_i2c_boot_trigger(client);
>   if (error) {
>   dev_err(>dev, "send boot trigger fail: %d\n", error);
>   return error;
>   }
additonal delay for safe
msleep(RM_BOOT_DELAY_MS);
>
>   data = fw->data;
>   data_len = fw->size;
>   page_nr = 0;
>
>   while (data_len) {
>   len = min_t(size_t, data_len, RM_FW_PAGE_SIZE);
>
>   error = raydium_i2c_fw_write_page(client, page_nr++, data, len);
>   if (error)
>   return error;
>
>   // XXX FIXME: we already sleep in raydium_i2c_fw_write_page(),
>   // do we really need to sleep here as well?
/*FIXME, remove delay in raydium_i2c_fw_write_page()*/
>   msleep(20);
>
>   data += len;
>   data_len -= len;
>   }



Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread jeffrey.lin
>static int raydium_i2c_do_update_firmware(struct raydium_data *ts,
>const struct firmware *fw)
>{
>   struct i2c_client *client = ts->client;
>   const void *data;
>   size_t data_len;
>   size_t len;
>   int page_nr;
>   int i;
>   int error;
>   u16 fw_checksum;
>
>   if (fw->size == 0) {
additional protect.
if (fw->size == 0 || fw->size > RM_MAX_FW_SIZE) {
>   dev_err(>dev, "Invalid firmware length\n");
>   return -EINVAL;
>   }
>
>   error = raydium_i2c_check_fw_status(ts);
>   if (error) {
>   dev_err(>dev, "Unable to access IC %d\n", error);
>   return error;
>   }
>
>   if (ts->boot_mode == RAYDIUM_TS_MAIN) {
>   for (i = 0; i < RM_MAX_RETRIES; i++) {
>   error = raydium_i2c_enter_bl(client);
>   if (!error) {
>   error = raydium_i2c_check_fw_status(ts);
>   if (error) {
>   dev_err(>dev,
>   "unable to access IC: %d\n",
>   error);
>   return error;
>   }
>
>   if (ts->boot_mode == RAYDIUM_TS_BLDR)
>   break;
>   }
>   }
>
>   if (ts->boot_mode == RAYDIUM_TS_MAIN) {
>   dev_err(>dev,
>   "failied to jump to boot loader: %d\n",
>   error);
>   return -EIO;
>   }
>   }
>
>   error = raydium_i2c_disable_watch_dog(client);
>   if (error)
>   return error;
>
>   error = raydium_i2c_check_path(client);
>   if (error)
>   return error;
>
>   error = raydium_i2c_boot_trigger(client);
>   if (error) {
>   dev_err(>dev, "send boot trigger fail: %d\n", error);
>   return error;
>   }
additonal delay for safe
msleep(RM_BOOT_DELAY_MS);
>
>   data = fw->data;
>   data_len = fw->size;
>   page_nr = 0;
>
>   while (data_len) {
>   len = min_t(size_t, data_len, RM_FW_PAGE_SIZE);
>
>   error = raydium_i2c_fw_write_page(client, page_nr++, data, len);
>   if (error)
>   return error;
>
>   // XXX FIXME: we already sleep in raydium_i2c_fw_write_page(),
>   // do we really need to sleep here as well?
/*FIXME, remove delay in raydium_i2c_fw_write_page()*/
>   msleep(20);
>
>   data += len;
>   data_len -= len;
>   }



Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread jeffrey.lin
Hi Dmitry:
I've finished issues under the format you suggested as below.

>#define RM_RESET_MSG_ADDR  0x4004
>#define RM_FASTBOOT_MSG_ADDR   0x5620

>#define RM_MAX_READ_SIZE   63
change maximum read size to 56 bytes
#define RM_MAX_READ_SIZE56

>#define RM_CONTACT_X_POS   1
>#define RM_CONTACT_Y_POS   3
>#define RM_CONTACT_PRESSURE_POS5 // XXX - check - original was 4
#define RM_CONTACT_PRESSURE_POS 5   /*FIXME, correct 5*/

>#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
>#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
>#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
>#define RM_FW_PAGE_SIZE128
>#define RM_MAX_FW_RETRIES  30
additional maximum firmware size for protection
#define RM_MAX_FW_SIZE  (0xD000)/*define max firmware size*/

>static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
>{
>   __be32 be_addr;
>   size_t xfer_len;
>   int error;
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>
>   be_addr = cpu_to_be32(addr);
>
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(be_addr));
>   if (!error)
>   error = raydium_i2c_read(client, addr & 0xff,
>data, xfer_len);
Change as:
if (!error)
error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
 data, xfer_len);

>static int raydium_i2c_send_message(struct i2c_client *client,
>   u32 addr, const void *data, size_t len)
>{
>   __be32 be_addr = cpu_to_be32(addr);
>   int error;
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(be_addr));
>   if (!error)
>   error = raydium_i2c_send(client, addr & 0xff, data, len);
Change as:
error = raydium_i2c_send(client, (be_addr >> 24) & 0xff,
data, len);


>static int raydium_i2c_fastboot(struct i2c_client *client)
>{
/*FIXME;Correct, direct access mode is word alignment*/
>   u8 buf[4];
>   int error;
>
>   error = raydium_i2c_read_message(client, RM_FASTBOOT_MSG_ADDR,
>buf, sizeof(buf));

>static int raydium_i2c_check_fw_status(struct raydium_data *ts)
>{
>   struct i2c_client *client = ts->client;
>   static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
>   static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
>   u8 buf[4];
>   int error;
>
>   error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
>   if (!error) {
>   // XXX FIXME: why do we compare only 1st bytes? Do we even
>   // need 4-byte constants?
>   if (buf[0] == bl_area[0])
>   ts->boot_mode = RAYDIUM_TS_BLDR;
>   else if (buf[0] == main_area[0])
>   ts->boot_mode = RAYDIUM_TS_MAIN;
>   return 0;
>   }
>
>   return error;
>}
Change as below,
static int raydium_i2c_check_fw_status(struct raydium_data *ts)
{
struct i2c_client *client = ts->client;
static const u8 bl_ack = 0x62;
static const u8 main_ack = 0x66;
u8 buf[4];
int error;

error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
if (!error) {
/*FIXME, changed as one byte comparison*/
if (buf[0] == bl_ack)
ts->boot_mode = RAYDIUM_TS_BLDR;
else if (buf[0] == main_ack)
ts->boot_mode = RAYDIUM_TS_MAIN;
return 0;
}

return error;
}

>static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u8 page_idx, void *data, size_t len)
>{
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   size_t xfer_len;
>   int error;
>
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>
>   buf[BL_HEADER] = 0x0b;
>   // XXX FIXME: is this correct? Do we really want all pages
>   // after 1st to have 0xff? Should it be a counter?
>   // Why do we need both pages and packages within pages?
>   buf[BL_PAGE_STR] = page_idx ? 0 : 0xff;
>   buf[BL_PKG_IDX] = pkg_idx;
>   memcpy([BL_DATA_STR], data, xfer_len);
>
>   error = raydium_i2c_write_object(client, buf, xfer_len,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-16 Thread jeffrey.lin
Hi Dmitry:
I've finished issues under the format you suggested as below.

>#define RM_RESET_MSG_ADDR  0x4004
>#define RM_FASTBOOT_MSG_ADDR   0x5620

>#define RM_MAX_READ_SIZE   63
change maximum read size to 56 bytes
#define RM_MAX_READ_SIZE56

>#define RM_CONTACT_X_POS   1
>#define RM_CONTACT_Y_POS   3
>#define RM_CONTACT_PRESSURE_POS5 // XXX - check - original was 4
#define RM_CONTACT_PRESSURE_POS 5   /*FIXME, correct 5*/

>#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
>#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
>#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
>#define RM_FW_PAGE_SIZE128
>#define RM_MAX_FW_RETRIES  30
additional maximum firmware size for protection
#define RM_MAX_FW_SIZE  (0xD000)/*define max firmware size*/

>static int raydium_i2c_read_message(struct i2c_client *client,
>   u32 addr, void *data, size_t len)
>{
>   __be32 be_addr;
>   size_t xfer_len;
>   int error;
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_MAX_READ_SIZE);
>
>   be_addr = cpu_to_be32(addr);
>
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(be_addr));
>   if (!error)
>   error = raydium_i2c_read(client, addr & 0xff,
>data, xfer_len);
Change as:
if (!error)
error = raydium_i2c_read(client, (be_addr >> 24) & 0xff,
 data, xfer_len);

>static int raydium_i2c_send_message(struct i2c_client *client,
>   u32 addr, const void *data, size_t len)
>{
>   __be32 be_addr = cpu_to_be32(addr);
>   int error;
>   error = raydium_i2c_send(client, RM_CMD_BANK_SWITCH,
>_addr, sizeof(be_addr));
>   if (!error)
>   error = raydium_i2c_send(client, addr & 0xff, data, len);
Change as:
error = raydium_i2c_send(client, (be_addr >> 24) & 0xff,
data, len);


>static int raydium_i2c_fastboot(struct i2c_client *client)
>{
/*FIXME;Correct, direct access mode is word alignment*/
>   u8 buf[4];
>   int error;
>
>   error = raydium_i2c_read_message(client, RM_FASTBOOT_MSG_ADDR,
>buf, sizeof(buf));

>static int raydium_i2c_check_fw_status(struct raydium_data *ts)
>{
>   struct i2c_client *client = ts->client;
>   static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
>   static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
>   u8 buf[4];
>   int error;
>
>   error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
>   if (!error) {
>   // XXX FIXME: why do we compare only 1st bytes? Do we even
>   // need 4-byte constants?
>   if (buf[0] == bl_area[0])
>   ts->boot_mode = RAYDIUM_TS_BLDR;
>   else if (buf[0] == main_area[0])
>   ts->boot_mode = RAYDIUM_TS_MAIN;
>   return 0;
>   }
>
>   return error;
>}
Change as below,
static int raydium_i2c_check_fw_status(struct raydium_data *ts)
{
struct i2c_client *client = ts->client;
static const u8 bl_ack = 0x62;
static const u8 main_ack = 0x66;
u8 buf[4];
int error;

error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
if (!error) {
/*FIXME, changed as one byte comparison*/
if (buf[0] == bl_ack)
ts->boot_mode = RAYDIUM_TS_BLDR;
else if (buf[0] == main_ack)
ts->boot_mode = RAYDIUM_TS_MAIN;
return 0;
}

return error;
}

>static int raydium_i2c_fw_write_page(struct i2c_client *client,
>u8 page_idx, void *data, size_t len)
>{
>   u8 buf[RM_BL_WRT_LEN];
>   u8 pkg_idx = 1;
>   size_t xfer_len;
>   int error;
>
>   while (len) {
>   xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
>
>   buf[BL_HEADER] = 0x0b;
>   // XXX FIXME: is this correct? Do we really want all pages
>   // after 1st to have 0xff? Should it be a counter?
>   // Why do we need both pages and packages within pages?
>   buf[BL_PAGE_STR] = page_idx ? 0 : 0xff;
>   buf[BL_PKG_IDX] = pkg_idx;
>   memcpy([BL_DATA_STR], data, xfer_len);
>
>   error = raydium_i2c_write_object(client, buf, xfer_len,
>RAYDIUM_WAIT_READY);
>   if (error) {
>   dev_err(>dev,
>   "page write command 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-13 Thread jeffrey.lin
Hi Dmitry:
This patch you submitted had some problems. I still debug in progress. Should I 
comment the issues in this patch or create a new patch if I finish the issues?

 >static int raydium_i2c_fastboot(struct i2c_client *client)
 > {
 >- static const u8 boot_cmd[] = { 0x50, 0x00, 0x06, 0x20 };
 >- u8 buf[HEADER_SIZE];
 >+ u8 buf[4]; // XXX FIXME why size 4 and not 1?
Correct.Raydium direct access mode is word alignment, so that 4 bytes reading 
is correct but only lower bytes show the message I need.

 >static int raydium_i2c_check_fw_status(struct raydium_data *ts)
 >{
 >  struct i2c_client *client = ts->client;
 >- static const u8 bl_area[] = {0x62, 0x6f, 0x6f, 0x74};
 >- static const u8 main_area[] = {0x66, 0x69, 0x72, 0x6d};
 >- u8 buf[HEADER_SIZE];
 >+ static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
 >+ static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
 >+ u8 buf[4];
 >  int error;
 > 
 >- error = raydium_i2c_read(client, CMD_BOOT_READ, HEADER_SIZE,
 >- (void *)buf);
 >+ error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
 >  if (!error) {
 >+ // XXX FIXME: why do we compare only 1st bytes? Do we even
 >+ // need 4-byte constants?
One bytes comparison is fine. I'll change as below:

static int raydium_i2c_check_fw_status(struct raydium_data *ts)
{
struct i2c_client *client = ts->client;
static const u8 bl_ack = 0x62;
static const u8 main_ack = 0x66;
u8 buf[4];
int error;

error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
if (!error) {
// XXX FIXME: why do we compare only 1st bytes? Do we even
// need 4-byte constants?
if (buf[0] == bl_ack)
ts->boot_mode = RAYDIUM_TS_BLDR;
else if (buf[0] == main_ack)
ts->boot_mode = RAYDIUM_TS_MAIN;
return 0;

>+  while (len) {
>+  xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> 
>-  memcpy([DATA_STR], page + DATA_STR +
>-  u8_idx*RAYDIUM_TRANS_BUFSIZE,
>-  RAYDIUM_TRANS_BUFSIZE);
>+  buf[BL_HEADER] = 0x0b;
>+  // XXX FIXME: is this correct? Do we really want all pages
>+  // after 1st to have 0xff? Should it be a counter?
>+  // Why do we need both pages and packages within pages?
>+  buf[BL_PAGE_STR] = page_idx ? 0 : 0xff;
This is correct. Touch MCU need this index as start page.
>+  buf[BL_PKG_IDX] = pkg_idx;
This should be:
buf[BL_PKG_IDX] = pkg_idx++;
>+  memcpy([BL_DATA_STR], data, xfer_len);



Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-13 Thread jeffrey.lin
Hi Dmitry:
This patch you submitted had some problems. I still debug in progress. Should I 
comment the issues in this patch or create a new patch if I finish the issues?

 >static int raydium_i2c_fastboot(struct i2c_client *client)
 > {
 >- static const u8 boot_cmd[] = { 0x50, 0x00, 0x06, 0x20 };
 >- u8 buf[HEADER_SIZE];
 >+ u8 buf[4]; // XXX FIXME why size 4 and not 1?
Correct.Raydium direct access mode is word alignment, so that 4 bytes reading 
is correct but only lower bytes show the message I need.

 >static int raydium_i2c_check_fw_status(struct raydium_data *ts)
 >{
 >  struct i2c_client *client = ts->client;
 >- static const u8 bl_area[] = {0x62, 0x6f, 0x6f, 0x74};
 >- static const u8 main_area[] = {0x66, 0x69, 0x72, 0x6d};
 >- u8 buf[HEADER_SIZE];
 >+ static const u8 bl_area[] = { 0x62, 0x6f, 0x6f, 0x74 };
 >+ static const u8 main_area[] = { 0x66, 0x69, 0x72, 0x6d };
 >+ u8 buf[4];
 >  int error;
 > 
 >- error = raydium_i2c_read(client, CMD_BOOT_READ, HEADER_SIZE,
 >- (void *)buf);
 >+ error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
 >  if (!error) {
 >+ // XXX FIXME: why do we compare only 1st bytes? Do we even
 >+ // need 4-byte constants?
One bytes comparison is fine. I'll change as below:

static int raydium_i2c_check_fw_status(struct raydium_data *ts)
{
struct i2c_client *client = ts->client;
static const u8 bl_ack = 0x62;
static const u8 main_ack = 0x66;
u8 buf[4];
int error;

error = raydium_i2c_read(client, RM_CMD_BOOT_READ, buf, sizeof(buf));
if (!error) {
// XXX FIXME: why do we compare only 1st bytes? Do we even
// need 4-byte constants?
if (buf[0] == bl_ack)
ts->boot_mode = RAYDIUM_TS_BLDR;
else if (buf[0] == main_ack)
ts->boot_mode = RAYDIUM_TS_MAIN;
return 0;

>+  while (len) {
>+  xfer_len = min_t(size_t, len, RM_BL_WRT_PKG_SIZE);
> 
>-  memcpy([DATA_STR], page + DATA_STR +
>-  u8_idx*RAYDIUM_TRANS_BUFSIZE,
>-  RAYDIUM_TRANS_BUFSIZE);
>+  buf[BL_HEADER] = 0x0b;
>+  // XXX FIXME: is this correct? Do we really want all pages
>+  // after 1st to have 0xff? Should it be a counter?
>+  // Why do we need both pages and packages within pages?
>+  buf[BL_PAGE_STR] = page_idx ? 0 : 0xff;
This is correct. Touch MCU need this index as start page.
>+  buf[BL_PKG_IDX] = pkg_idx;
This should be:
buf[BL_PKG_IDX] = pkg_idx++;
>+  memcpy([BL_DATA_STR], data, xfer_len);



Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-12 Thread Dmitry Torokhov
Hi Jeffrey,
On Fri, Apr 29, 2016 at 05:45:13PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 

I was looking at the driver and there were a few issues (buffer
overflows, forgetting releasing firmware, general flow, etc), that I
tried correcting in the attached patch. Please try incorporating it into
yours (it should apply to this version of Raydium driver) and let me
know if it still works. There are a few questionable points that I
marked with "XXX FIXME" in the code, please respond to them by either
confirming that they are correct or fixing them.

Thanks.

-- 
Dmitry


Input: raydium misc changes

From: Dmitry Torokhov 

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/touchscreen/raydium_i2c_ts.c |  941 ++--
 1 file changed, 482 insertions(+), 459 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
index cee46e8..1e4e3de 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -20,107 +20,105 @@
  * Contact Raydium Semiconductor Corporation at www.rad-ic.com
  */
 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
+#include 
 #include 
-#include 
 
-/* Device, Driver information */
-#define DEVICE_NAME"raydium_i2c"
-
-/* Slave I2C mode*/
-#define RM_BOOT_BLDR   0x02
-#define RM_BOOT_MAIN   0x03
-
-/*I2C bl command */
-#define CMD_BOOT_PAGE_WRT  0x0B/*send bl page write*/
-#define CMD_BOOT_WRT   0x11/*send bl write*/
-#define CMD_BOOT_ACK   0x22/*send ack*/
-#define CMD_BOOT_CHK   0x33/*send data check*/
-#define CMD_BOOT_READ  0x44/*send wait bl data ready*/
-#define BOOT_RDY   0xFF/*bl data ready*/
-/*I2C main command*/
-#define CMD_QUERY_BANK 0x2B
-#define CMD_DATA_BANK  0x4D
-#define CMD_ENTER_SLEEP0x4E
-#define CMD_BANK_SWITCH0xAA
+/* Slave I2C mode */
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
 
-/* Touch relative info */
-#define MAX_RETRIES3
-#define MAX_TOUCH_NUM  10
-#define MAX_PkG_SIZE   50
-#define BOOT_DELAY_MS  100
+/* I2C bootoloader commands */
+#define RM_CMD_BOOT_PAGE_WRT   0x0B/* send bl page write */
+#define RM_CMD_BOOT_WRT0x11/* send bl write */
+#define RM_CMD_BOOT_ACK0x22/* send ack*/
+#define RM_CMD_BOOT_CHK0x33/* send data check */
+#define RM_CMD_BOOT_READ   0x44/* send wait bl data ready*/
 
-/*Bootloader relative info */
-#define CMD_BOOT_HEADER_LEN3   /*bl flash wrt cmd size*/
-#define RAYDIUM_TRANS_BUFSIZE  32  /*bl wrt pkg size*/
-#define MAX_BOOT_WRT_LEN   (RAYDIUM_TRANS_BUFSIZE + CMD_BOOT_HEADER_LEN)
-#define MAX_FW_UPDATE_RETRIES  30
+#define RM_BOOT_RDY0xFF/* bl data ready */
+
+/* I2C main commands */
+#define RM_CMD_QUERY_BANK  0x2B
+#define RM_CMD_DATA_BANK   0x4D
+#define RM_CMD_ENTER_SLEEP 0x4E
+#define RM_CMD_BANK_SWITCH 0xAA
+
+#define RM_RESET_MSG_ADDR  0x4004
+#define RM_FASTBOOT_MSG_ADDR   0x5620
+
+#define RM_MAX_READ_SIZE   63
+
+/* Touch relative info */
+#define RM_MAX_RETRIES 3
+#define RM_MAX_TOUCH_NUM   10
+#define RM_BOOT_DELAY_MS   100
+
+/* Offsets in contact data */
+#define RM_CONTACT_STATE_POS   0
+#define RM_CONTACT_X_POS   1
+#define RM_CONTACT_Y_POS   3
+#define RM_CONTACT_PRESSURE_POS5 // XXX - check - original was 4
+#define RM_CONTACT_WIDTH_X_POS 6
+#define RM_CONTACT_WIDTH_Y_POS 7
+
+/* Bootloader relative info */
+#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
+#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
+#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
+#define RM_FW_PAGE_SIZE128
+#define RM_MAX_FW_RETRIES  30
+
+#define RM_POWERON_DELAY_USEC  500
+#define RM_RESET_DELAY_MSEC50
 
 enum raydium_bl_cmd {
-   HEADER = 0,
-   PAGE_STR,
-   PKG_IDX,
-   DATA_STR,
+   BL_HEADER = 0,
+   BL_PAGE_STR,
+   BL_PKG_IDX,
+   BL_DATA_STR,
 };
 
 enum raydium_bl_ack {
-   ACK_NULL = 0,
-   WAIT_READY,
-   PATH_READY,
+   RAYDIUM_ACK_NULL = 0,
+   RAYDIUM_WAIT_READY,
+   RAYDIUM_PATH_READY,
 };
 
-#define RAYDIUM_PAGE_SIZE  128
-#define RAYDIUM_POWERON_DELAY_USEC 500
-#define RAYDIUM_RESET_DELAY_MSEC   50
-
-#define ADDR_INDEX 0x03
-#define DATA_INDEX 0x04
-
-#define HEADER_SIZE4
-
 enum raydium_boot_mode {

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-12 Thread Dmitry Torokhov
Hi Jeffrey,
On Fri, Apr 29, 2016 at 05:45:13PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 

I was looking at the driver and there were a few issues (buffer
overflows, forgetting releasing firmware, general flow, etc), that I
tried correcting in the attached patch. Please try incorporating it into
yours (it should apply to this version of Raydium driver) and let me
know if it still works. There are a few questionable points that I
marked with "XXX FIXME" in the code, please respond to them by either
confirming that they are correct or fixing them.

Thanks.

-- 
Dmitry


Input: raydium misc changes

From: Dmitry Torokhov 

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/touchscreen/raydium_i2c_ts.c |  941 ++--
 1 file changed, 482 insertions(+), 459 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
index cee46e8..1e4e3de 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -20,107 +20,105 @@
  * Contact Raydium Semiconductor Corporation at www.rad-ic.com
  */
 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
+#include 
 #include 
-#include 
 
-/* Device, Driver information */
-#define DEVICE_NAME"raydium_i2c"
-
-/* Slave I2C mode*/
-#define RM_BOOT_BLDR   0x02
-#define RM_BOOT_MAIN   0x03
-
-/*I2C bl command */
-#define CMD_BOOT_PAGE_WRT  0x0B/*send bl page write*/
-#define CMD_BOOT_WRT   0x11/*send bl write*/
-#define CMD_BOOT_ACK   0x22/*send ack*/
-#define CMD_BOOT_CHK   0x33/*send data check*/
-#define CMD_BOOT_READ  0x44/*send wait bl data ready*/
-#define BOOT_RDY   0xFF/*bl data ready*/
-/*I2C main command*/
-#define CMD_QUERY_BANK 0x2B
-#define CMD_DATA_BANK  0x4D
-#define CMD_ENTER_SLEEP0x4E
-#define CMD_BANK_SWITCH0xAA
+/* Slave I2C mode */
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
 
-/* Touch relative info */
-#define MAX_RETRIES3
-#define MAX_TOUCH_NUM  10
-#define MAX_PkG_SIZE   50
-#define BOOT_DELAY_MS  100
+/* I2C bootoloader commands */
+#define RM_CMD_BOOT_PAGE_WRT   0x0B/* send bl page write */
+#define RM_CMD_BOOT_WRT0x11/* send bl write */
+#define RM_CMD_BOOT_ACK0x22/* send ack*/
+#define RM_CMD_BOOT_CHK0x33/* send data check */
+#define RM_CMD_BOOT_READ   0x44/* send wait bl data ready*/
 
-/*Bootloader relative info */
-#define CMD_BOOT_HEADER_LEN3   /*bl flash wrt cmd size*/
-#define RAYDIUM_TRANS_BUFSIZE  32  /*bl wrt pkg size*/
-#define MAX_BOOT_WRT_LEN   (RAYDIUM_TRANS_BUFSIZE + CMD_BOOT_HEADER_LEN)
-#define MAX_FW_UPDATE_RETRIES  30
+#define RM_BOOT_RDY0xFF/* bl data ready */
+
+/* I2C main commands */
+#define RM_CMD_QUERY_BANK  0x2B
+#define RM_CMD_DATA_BANK   0x4D
+#define RM_CMD_ENTER_SLEEP 0x4E
+#define RM_CMD_BANK_SWITCH 0xAA
+
+#define RM_RESET_MSG_ADDR  0x4004
+#define RM_FASTBOOT_MSG_ADDR   0x5620
+
+#define RM_MAX_READ_SIZE   63
+
+/* Touch relative info */
+#define RM_MAX_RETRIES 3
+#define RM_MAX_TOUCH_NUM   10
+#define RM_BOOT_DELAY_MS   100
+
+/* Offsets in contact data */
+#define RM_CONTACT_STATE_POS   0
+#define RM_CONTACT_X_POS   1
+#define RM_CONTACT_Y_POS   3
+#define RM_CONTACT_PRESSURE_POS5 // XXX - check - original was 4
+#define RM_CONTACT_WIDTH_X_POS 6
+#define RM_CONTACT_WIDTH_Y_POS 7
+
+/* Bootloader relative info */
+#define RM_BL_WRT_CMD_SIZE 3   /* bl flash wrt cmd size */
+#define RM_BL_WRT_PKG_SIZE 32  /* bl wrt pkg size */
+#define RM_BL_WRT_LEN  (RM_BL_WRT_PKG_SIZE + RM_BL_WRT_CMD_SIZE)
+#define RM_FW_PAGE_SIZE128
+#define RM_MAX_FW_RETRIES  30
+
+#define RM_POWERON_DELAY_USEC  500
+#define RM_RESET_DELAY_MSEC50
 
 enum raydium_bl_cmd {
-   HEADER = 0,
-   PAGE_STR,
-   PKG_IDX,
-   DATA_STR,
+   BL_HEADER = 0,
+   BL_PAGE_STR,
+   BL_PKG_IDX,
+   BL_DATA_STR,
 };
 
 enum raydium_bl_ack {
-   ACK_NULL = 0,
-   WAIT_READY,
-   PATH_READY,
+   RAYDIUM_ACK_NULL = 0,
+   RAYDIUM_WAIT_READY,
+   RAYDIUM_PATH_READY,
 };
 
-#define RAYDIUM_PAGE_SIZE  128
-#define RAYDIUM_POWERON_DELAY_USEC 500
-#define RAYDIUM_RESET_DELAY_MSEC   50
-
-#define ADDR_INDEX 0x03
-#define DATA_INDEX 0x04
-
-#define HEADER_SIZE4
-
 enum raydium_boot_mode {
RAYDIUM_TS_MAIN = 0,
RAYDIUM_TS_BLDR,
 };
 
-enum raydium_abs_idx {
-   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-11 Thread jeffrey.lin
Hi Dmitry:

I've made a mistake as touch points data over "MAX_PKG_SIZE".This mistake will 
result in memory overwrite, so that I update a new patch to upstream. 
New patch I assign a new definition "MAX_RD_PKG_LEN" for maxinum I2C read 
command to prevent touch points data package over I2C bus buffer size. If I2C 
read command package over than MAX_RD_PKG_LEN, I’ll split this read command two 
or more to make sure all data are read.

Please review my new patch and give me some comments. Many thanks.


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-11 Thread jeffrey.lin
Hi Dmitry:

I've made a mistake as touch points data over "MAX_PKG_SIZE".This mistake will 
result in memory overwrite, so that I update a new patch to upstream. 
New patch I assign a new definition "MAX_RD_PKG_LEN" for maxinum I2C read 
command to prevent touch points data package over I2C bus buffer size. If I2C 
read command package over than MAX_RD_PKG_LEN, I’ll split this read command two 
or more to make sure all data are read.

Please review my new patch and give me some comments. Many thanks.


[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-11 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1208 
 3 files changed, 1221 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..6491920
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1208 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C bl command */
+#define CMD_BOOT_PAGE_WRT  0x0B/*send bl page write*/
+#define CMD_BOOT_WRT   0x11/*send bl write*/
+#define CMD_BOOT_ACK   0x22/*send ack*/
+#define CMD_BOOT_CHK   0x33/*send data check*/
+#define CMD_BOOT_READ  0x44/*send wait bl data ready*/
+#define BOOT_RDY   0xFF/*bl data ready*/
+/*I2C main command*/
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_TOUCH_NUM  10
+#define MAX_PKG_SIZE   128
+#define MAX_RD_PKG_LEN 48
+#define BOOT_DELAY_MS  100
+
+/*Bootloader relative info */
+#define CMD_BOOT_HEADER_LEN3   /*bl flash wrt cmd size*/
+#define RAYDIUM_TRANS_BUFSIZE  32  /*bl wrt pkg size*/
+#define MAX_BOOT_WRT_LEN   (RAYDIUM_TRANS_BUFSIZE + CMD_BOOT_HEADER_LEN)
+#define MAX_FW_UPDATE_RETRIES  30
+
+enum raydium_bl_cmd {
+   HEADER = 0,
+   PAGE_STR,
+   PKG_IDX,
+   DATA_STR,
+};
+
+enum raydium_bl_ack {
+   ACK_NULL = 0,
+   WAIT_READY,
+   PATH_READY,
+};
+
+#define RAYDIUM_PAGE_SIZE  128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-11 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1208 
 3 files changed, 1221 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..6491920
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1208 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C bl command */
+#define CMD_BOOT_PAGE_WRT  0x0B/*send bl page write*/
+#define CMD_BOOT_WRT   0x11/*send bl write*/
+#define CMD_BOOT_ACK   0x22/*send ack*/
+#define CMD_BOOT_CHK   0x33/*send data check*/
+#define CMD_BOOT_READ  0x44/*send wait bl data ready*/
+#define BOOT_RDY   0xFF/*bl data ready*/
+/*I2C main command*/
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_TOUCH_NUM  10
+#define MAX_PKG_SIZE   128
+#define MAX_RD_PKG_LEN 48
+#define BOOT_DELAY_MS  100
+
+/*Bootloader relative info */
+#define CMD_BOOT_HEADER_LEN3   /*bl flash wrt cmd size*/
+#define RAYDIUM_TRANS_BUFSIZE  32  /*bl wrt pkg size*/
+#define MAX_BOOT_WRT_LEN   (RAYDIUM_TRANS_BUFSIZE + CMD_BOOT_HEADER_LEN)
+#define MAX_FW_UPDATE_RETRIES  30
+
+enum raydium_bl_cmd {
+   HEADER = 0,
+   PAGE_STR,
+   PKG_IDX,
+   DATA_STR,
+};
+
+enum raydium_bl_ack {
+   ACK_NULL = 0,
+   WAIT_READY,
+   PATH_READY,
+};
+
+#define RAYDIUM_PAGE_SIZE  128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-06 Thread jeffrey.lin
Hi Dmitry:

About question "In my previous e-mail I requested you to enumerate changes that 
are made to the driver, compared to the previous version(s). There were also a 
few questions that I did not get answer for."

In order to improve flash read/write security of boot loader. We increase 
handshake flow and command sequence complexity. Our previous flash write 
functions are single side action. New version we increase more handshake flow 
to check data accuracy. Firmware update flow increases as below:

1.Check firmware file size, if file size is null, return fail.
2.Check touch MCU run on main firmware or boot loader. Both cases have 
different return values. In case of flash write function, if touch MCU work on 
main code, touch driver need issue enter boot loader command to touch MCU and 
wait for MCU boot mode ready.
3.Turn off touch MCU watchdog function to prevent interference.
4.Check boot loader write state path ready.
5.Send boot mode trigger command to unlock flash-write-protection.
6.Execute page write command. Each write command will wait touch MCU 
acknowledge and then execute next step.
7.Leave boot loader to check firmware work.
8.Raydium touch driver check touch MCU work on main firmware or not. If 
touch MCU work on main firmware and return correct acknowledge to kernel, this 
means flash write command success.
9.Write checksum information to flash.

Every touch driver flash write command accompany write command, acknowledge 
byte and wait for acknowledge command. Different sequences have different write 
commands and different state to return ack.

Previous version as below :

1.Get firmware data
2.Force jump to boot loader by soft reset command
3.Wait for boot loader acknowledge
4.Flash page write data directly
5.Force jump to main firmware if page write data finish.

 
New flow increase more acknowledges for each I2C command to make sure boot 
loader got the message and finish the actions. After finish flash write data, 
new flow will le touch MCU jump to main firmware and check main code work well. 
Then write the total checksum to flash and check the consistence of flash code 
in every boot time.
 
New flash write flow is very different form previous version, but more safe. 
The difference is big. Sorry make you confuse.

The question "I still can't figure out the logic in read/write mesage handling. 
Here we see that device is supposedly reporting data_bank_addr as LE integer, 
but query_bank_info is returned in native CPU endianness. With fastboot command 
we assume that we are dealing with BE-encoded data and convert it to 
CPU-endianness before using it.
 
However in raydium_i2c_read_message() we convert from CPU endianness to BE and 
this comfuses me (does the device really return data in one endianness but 
accepts in another endianness?"

Raydium MCU support direct access mode by I2C bus to access register or 
physical buffer directly. In this direct access mode, our touch MCU use BE 
integer by using commands of raydium_i2c_read_message/ 
raydium_i2c_send_message. Otherwise, raydum I2C normal mode use LE integer. By 
the way, the command buffer of soft_rst_cmd[] is upside down.

The question "By the way, why do you have raydium_i2c_read_message() handle 
reads above MAX_PKG_SIZE? There are no callers that want it."

Generally, I2C bus has maximum packet size but total touch report points maybe 
exceed this size. Unfortunately my experimental chromebook device exceed this 
size. So that I’ll split this read command two or more to make sure all data 
are read.


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-06 Thread jeffrey.lin
Hi Dmitry:

About question "In my previous e-mail I requested you to enumerate changes that 
are made to the driver, compared to the previous version(s). There were also a 
few questions that I did not get answer for."

In order to improve flash read/write security of boot loader. We increase 
handshake flow and command sequence complexity. Our previous flash write 
functions are single side action. New version we increase more handshake flow 
to check data accuracy. Firmware update flow increases as below:

1.Check firmware file size, if file size is null, return fail.
2.Check touch MCU run on main firmware or boot loader. Both cases have 
different return values. In case of flash write function, if touch MCU work on 
main code, touch driver need issue enter boot loader command to touch MCU and 
wait for MCU boot mode ready.
3.Turn off touch MCU watchdog function to prevent interference.
4.Check boot loader write state path ready.
5.Send boot mode trigger command to unlock flash-write-protection.
6.Execute page write command. Each write command will wait touch MCU 
acknowledge and then execute next step.
7.Leave boot loader to check firmware work.
8.Raydium touch driver check touch MCU work on main firmware or not. If 
touch MCU work on main firmware and return correct acknowledge to kernel, this 
means flash write command success.
9.Write checksum information to flash.

Every touch driver flash write command accompany write command, acknowledge 
byte and wait for acknowledge command. Different sequences have different write 
commands and different state to return ack.

Previous version as below :

1.Get firmware data
2.Force jump to boot loader by soft reset command
3.Wait for boot loader acknowledge
4.Flash page write data directly
5.Force jump to main firmware if page write data finish.

 
New flow increase more acknowledges for each I2C command to make sure boot 
loader got the message and finish the actions. After finish flash write data, 
new flow will le touch MCU jump to main firmware and check main code work well. 
Then write the total checksum to flash and check the consistence of flash code 
in every boot time.
 
New flash write flow is very different form previous version, but more safe. 
The difference is big. Sorry make you confuse.

The question "I still can't figure out the logic in read/write mesage handling. 
Here we see that device is supposedly reporting data_bank_addr as LE integer, 
but query_bank_info is returned in native CPU endianness. With fastboot command 
we assume that we are dealing with BE-encoded data and convert it to 
CPU-endianness before using it.
 
However in raydium_i2c_read_message() we convert from CPU endianness to BE and 
this comfuses me (does the device really return data in one endianness but 
accepts in another endianness?"

Raydium MCU support direct access mode by I2C bus to access register or 
physical buffer directly. In this direct access mode, our touch MCU use BE 
integer by using commands of raydium_i2c_read_message/ 
raydium_i2c_send_message. Otherwise, raydum I2C normal mode use LE integer. By 
the way, the command buffer of soft_rst_cmd[] is upside down.

The question "By the way, why do you have raydium_i2c_read_message() handle 
reads above MAX_PKG_SIZE? There are no callers that want it."

Generally, I2C bus has maximum packet size but total touch report points maybe 
exceed this size. Unfortunately my experimental chromebook device exceed this 
size. So that I’ll split this read command two or more to make sure all data 
are read.


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-04 Thread Dmitry Torokhov
Hi Jeffrey,

On Fri, Apr 29, 2016 at 05:45:13PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 

In my previous e-mail I requested you to enumerate changes that are made
to the driver, compared to the previous version(s). There were also a
few questions that I did not get answer for.

Also:

> +static int raydium_i2c_query_ts_info(struct raydium_data *ts)
> +{
> + struct i2c_client *client = ts->client;
> + int error, retry_cnt;
> +
> + for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
> + error = raydium_i2c_read(client, CMD_DATA_BANK,
> + sizeof(ts->obj), (void *)>obj);
> + ts->obj.data_bank_addr =
> + get_unaligned_le32(>obj.data_bank_addr);
> +
> + if (!error) {
> + error = raydium_i2c_read(client, CMD_QUERY_BANK,
> + sizeof(ts->query_bank_info),
> + (void *)>query_bank_info);
> + if (!error) {
> + error = raydium_i2c_read_message(client,
> + ts->query_bank_info, sizeof(ts->info),
> + (void *)>info);
> +
> + ts->info.hw_ver =
> + get_unaligned_le32(>info.hw_ver);
> + ts->info.ft_ver =
> + get_unaligned_le16(>info.ft_ver);
> + ts->info.x_max =
> + get_unaligned_le16(>info.x_max);
> + ts->info.y_max =
> + get_unaligned_le16(>info.y_max);
> + return 0;
> + }
> + }
> + }
> + dev_err(>dev, "Get touch data failed: %d\n", error);
> +
> + return -EINVAL;
> +}
> +
> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> + static const u8 boot_cmd[] = { 0x50, 0x00, 0x06, 0x20 };
> + u8 buf[HEADER_SIZE];
> + int error;
> +
> + error = raydium_i2c_read_message(client,
> + get_unaligned_be32(boot_cmd),
> + sizeof(boot_cmd), buf);

I still can't figure out the logic in read/write mesage handling. Here
we see that device is supposedly reporting data_bank_addr as LE integer,
but query_bank_info is returned in native CPU endianness. With fastboot
command we assume that we are dealing with BE-encoded data and convert
it to CPU-endianness before using it.

However in raydium_i2c_read_message() we convert from CPU endianness to
BE and this comfuses me (does the device really return data in one
endianness but accepts in another endianness?

By the way, why do you have raydium_i2c_read_message() handle reads
above MAX_PKG_SIZE? There are no callers that want it.

Thanks.

-- 
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-05-04 Thread Dmitry Torokhov
Hi Jeffrey,

On Fri, Apr 29, 2016 at 05:45:13PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 

In my previous e-mail I requested you to enumerate changes that are made
to the driver, compared to the previous version(s). There were also a
few questions that I did not get answer for.

Also:

> +static int raydium_i2c_query_ts_info(struct raydium_data *ts)
> +{
> + struct i2c_client *client = ts->client;
> + int error, retry_cnt;
> +
> + for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
> + error = raydium_i2c_read(client, CMD_DATA_BANK,
> + sizeof(ts->obj), (void *)>obj);
> + ts->obj.data_bank_addr =
> + get_unaligned_le32(>obj.data_bank_addr);
> +
> + if (!error) {
> + error = raydium_i2c_read(client, CMD_QUERY_BANK,
> + sizeof(ts->query_bank_info),
> + (void *)>query_bank_info);
> + if (!error) {
> + error = raydium_i2c_read_message(client,
> + ts->query_bank_info, sizeof(ts->info),
> + (void *)>info);
> +
> + ts->info.hw_ver =
> + get_unaligned_le32(>info.hw_ver);
> + ts->info.ft_ver =
> + get_unaligned_le16(>info.ft_ver);
> + ts->info.x_max =
> + get_unaligned_le16(>info.x_max);
> + ts->info.y_max =
> + get_unaligned_le16(>info.y_max);
> + return 0;
> + }
> + }
> + }
> + dev_err(>dev, "Get touch data failed: %d\n", error);
> +
> + return -EINVAL;
> +}
> +
> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> + static const u8 boot_cmd[] = { 0x50, 0x00, 0x06, 0x20 };
> + u8 buf[HEADER_SIZE];
> + int error;
> +
> + error = raydium_i2c_read_message(client,
> + get_unaligned_be32(boot_cmd),
> + sizeof(boot_cmd), buf);

I still can't figure out the logic in read/write mesage handling. Here
we see that device is supposedly reporting data_bank_addr as LE integer,
but query_bank_info is returned in native CPU endianness. With fastboot
command we assume that we are dealing with BE-encoded data and convert
it to CPU-endianness before using it.

However in raydium_i2c_read_message() we convert from CPU endianness to
BE and this comfuses me (does the device really return data in one
endianness but accepts in another endianness?

By the way, why do you have raydium_i2c_read_message() handle reads
above MAX_PKG_SIZE? There are no callers that want it.

Thanks.

-- 
Dmitry


[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-29 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1207 
 3 files changed, 1220 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..cee46e8
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1207 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C bl command */
+#define CMD_BOOT_PAGE_WRT  0x0B/*send bl page write*/
+#define CMD_BOOT_WRT   0x11/*send bl write*/
+#define CMD_BOOT_ACK   0x22/*send ack*/
+#define CMD_BOOT_CHK   0x33/*send data check*/
+#define CMD_BOOT_READ  0x44/*send wait bl data ready*/
+#define BOOT_RDY   0xFF/*bl data ready*/
+/*I2C main command*/
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_TOUCH_NUM  10
+#define MAX_PkG_SIZE   50
+#define BOOT_DELAY_MS  100
+
+/*Bootloader relative info */
+#define CMD_BOOT_HEADER_LEN3   /*bl flash wrt cmd size*/
+#define RAYDIUM_TRANS_BUFSIZE  32  /*bl wrt pkg size*/
+#define MAX_BOOT_WRT_LEN   (RAYDIUM_TRANS_BUFSIZE + CMD_BOOT_HEADER_LEN)
+#define MAX_FW_UPDATE_RETRIES  30
+
+enum raydium_bl_cmd {
+   HEADER = 0,
+   PAGE_STR,
+   PKG_IDX,
+   DATA_STR,
+};
+
+enum raydium_bl_ack {
+   ACK_NULL = 0,
+   WAIT_READY,
+   PATH_READY,
+};
+
+#define RAYDIUM_PAGE_SIZE  128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-29 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1207 
 3 files changed, 1220 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..cee46e8
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1207 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C bl command */
+#define CMD_BOOT_PAGE_WRT  0x0B/*send bl page write*/
+#define CMD_BOOT_WRT   0x11/*send bl write*/
+#define CMD_BOOT_ACK   0x22/*send ack*/
+#define CMD_BOOT_CHK   0x33/*send data check*/
+#define CMD_BOOT_READ  0x44/*send wait bl data ready*/
+#define BOOT_RDY   0xFF/*bl data ready*/
+/*I2C main command*/
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_TOUCH_NUM  10
+#define MAX_PkG_SIZE   50
+#define BOOT_DELAY_MS  100
+
+/*Bootloader relative info */
+#define CMD_BOOT_HEADER_LEN3   /*bl flash wrt cmd size*/
+#define RAYDIUM_TRANS_BUFSIZE  32  /*bl wrt pkg size*/
+#define MAX_BOOT_WRT_LEN   (RAYDIUM_TRANS_BUFSIZE + CMD_BOOT_HEADER_LEN)
+#define MAX_FW_UPDATE_RETRIES  30
+
+enum raydium_bl_cmd {
+   HEADER = 0,
+   PAGE_STR,
+   PKG_IDX,
+   DATA_STR,
+};
+
+enum raydium_bl_ack {
+   ACK_NULL = 0,
+   WAIT_READY,
+   PATH_READY,
+};
+
+#define RAYDIUM_PAGE_SIZE  128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-22 Thread Dmitry Torokhov
Hi Dan,

On Fri, Apr 22, 2016 at 06:01:08PM +0800, dan.huang wrote:
> From: "jeffrey.lin" 
> 
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 

When you are sending a patch over you need to add your sign-off to it.

Also I am still getting compile errors/warnings:

  CC [M]  drivers/input/touchscreen/raydium_i2c_ts.o
drivers/input/touchscreen/raydium_i2c_ts.c: In function
‘raydium_i2c_probe’:
drivers/input/touchscreen/raydium_i2c_ts.c:1036:35: warning: ‘irqflags’
may be used uninitialized in this function [-Wmaybe-uninitialized]
  error = devm_request_threaded_irq(>dev, client->irq,

Also please mention what is changed between previous and new version so
I do not need to hunt for surprises.

> +/*I2C command */
> +#define CMD_BOOT_WRT 0x11
> +#define CMD_BOOT_ACK 0x22
> +#define CMD_BOOT_CHK 0x33
> +#define CMD_BOOT_READ0x44
> +#define CMD_BOOT_WAIT_READY  0x1A
> +#define CMD_BOOT_PATH_READY  0x1B

I see that in this version the command codes are completely redone. Why
is this? I think there is general confusion as to the encoding of the
"header" for the command message little endian vs big endian) and
position of the register in the header.

Would you mind spelling out the format of command message, please?

> +#define BOOT_RDY 0xFF
> +#define CMD_QUERY_BANK   0x2B
> +#define CMD_DATA_BANK0x4D
> +#define CMD_ENTER_SLEEP  0x4E
> +#define CMD_BANK_SWITCH  0xAA
> +
> +/* Touch relative info */
> +#define MAX_RETRIES  3
> +#define MAX_FW_UPDATE_RETRIES30
> +#define MAX_TOUCH_NUM10
> +#define MAX_PACKET_SIZE  32
> +#define BOOT_DELAY_MS100
> +
> +#define RAYDIUM_FW_PAGESIZE  128
> +#define RAYDIUM_POWERON_DELAY_USEC   500
> +#define RAYDIUM_RESET_DELAY_MSEC 50
> +
> +#define ADDR_INDEX   0x03
> +#define DATA_INDEX   0x04
> +
> +#define HEADER_SIZE  4
> +
> +enum raydium_boot_mode {
> + RAYDIUM_TS_MAIN = 0,
> + RAYDIUM_TS_BLDR,
> +};
> +
> +enum raydium_abs_idx {
> + POS_STATE = 0,/*1:touch, 0:no touch*/
> + POS_X,
> + POS_Y = 3,
> + POS_PRESSURE,
> + WIDTH_X,
> + WIDTH_Y,
> +};
> +
> +struct raydium_info {
> + u32 hw_ver; /*device ver, __le32*/
> + u8 main_ver;
> + u8 sub_ver;
> + u16 ft_ver; /*test ver, __le16*/
> + u8 x_num;
> + u8 y_num;
> + u16 x_max;  /*disp reso, __le16*/
> + u16 y_max;  /*disp reso, __le16*/
> + u8 x_res;   /* units/mm */
> + u8 y_res;   /* units/mm */
> +};
> +
> +struct raydium_object {
> + u32 data_bank_addr;
> + u8 pkg_size;
> + u8 tp_info_size;
> +};
> +
> +/* struct raydium_data - represents state of Raydium touchscreen device */
> +struct raydium_data {
> + struct i2c_client *client;
> + struct input_dev *input;
> +
> + struct regulator *avdd;
> + struct regulator *vccio;
> + struct gpio_desc *reset_gpio;
> +
> + u32 query_bank_info;
> +
> + struct raydium_info info;
> + struct raydium_object obj;
> + enum raydium_boot_mode boot_mode;
> +
> + struct mutex sysfs_mutex;
> + struct completion cmd_done;
> +
> + bool wake_irq_enabled;
> +};
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1], idx_i;
> + u16 pkg_len, use_len;
> + int tries = 0;
> +
> + buf[0] = addr;
> + use_len = len;
> + use_len = 0;
> +
> + while (use_len) {
> + pkg_len = (use_len < MAX_PACKET_SIZE) ?
> + use_len : MAX_PACKET_SIZE;
> + memcpy([1], data + idx_i*MAX_PACKET_SIZE, pkg_len);
> +
> + tries = 0;
> + do {
> + if (i2c_master_send(client, buf, pkg_len + 1)
> + == (pkg_len + 1))
> + break;
> + msleep(20);
> + } while (++tries < MAX_RETRIES);
> + idx_i++;
> + use_len = (use_len < MAX_PACKET_SIZE) ?
> + 0 : (use_len - MAX_PACKET_SIZE);
> + }
> +
> + dev_err(>dev, "%s: i2c send failed\n", __func__);
> +
> + return -EIO;
> +}
> +
> +static int raydium_i2c_read(struct i2c_client *client,
> + u8 addr, size_t len, void *data)
> +{
> + struct i2c_msg xfer[2];
> + int ret;
> +
> + /* Write register */
> + xfer[0].addr = client->addr;
> + xfer[0].flags = 0;
> + xfer[0].len = 1;
> + xfer[0].buf = 
> +
> + /* Read data */
> + xfer[1].addr = client->addr;
> + xfer[1].flags = I2C_M_RD;
> + xfer[1].len = len;
> + xfer[1].buf = data;
> +
> + ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer));
> + if (ret < 0)
> + return ret;
> +
> + if (ret != ARRAY_SIZE(xfer))
> + return 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-22 Thread Dmitry Torokhov
Hi Dan,

On Fri, Apr 22, 2016 at 06:01:08PM +0800, dan.huang wrote:
> From: "jeffrey.lin" 
> 
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 

When you are sending a patch over you need to add your sign-off to it.

Also I am still getting compile errors/warnings:

  CC [M]  drivers/input/touchscreen/raydium_i2c_ts.o
drivers/input/touchscreen/raydium_i2c_ts.c: In function
‘raydium_i2c_probe’:
drivers/input/touchscreen/raydium_i2c_ts.c:1036:35: warning: ‘irqflags’
may be used uninitialized in this function [-Wmaybe-uninitialized]
  error = devm_request_threaded_irq(>dev, client->irq,

Also please mention what is changed between previous and new version so
I do not need to hunt for surprises.

> +/*I2C command */
> +#define CMD_BOOT_WRT 0x11
> +#define CMD_BOOT_ACK 0x22
> +#define CMD_BOOT_CHK 0x33
> +#define CMD_BOOT_READ0x44
> +#define CMD_BOOT_WAIT_READY  0x1A
> +#define CMD_BOOT_PATH_READY  0x1B

I see that in this version the command codes are completely redone. Why
is this? I think there is general confusion as to the encoding of the
"header" for the command message little endian vs big endian) and
position of the register in the header.

Would you mind spelling out the format of command message, please?

> +#define BOOT_RDY 0xFF
> +#define CMD_QUERY_BANK   0x2B
> +#define CMD_DATA_BANK0x4D
> +#define CMD_ENTER_SLEEP  0x4E
> +#define CMD_BANK_SWITCH  0xAA
> +
> +/* Touch relative info */
> +#define MAX_RETRIES  3
> +#define MAX_FW_UPDATE_RETRIES30
> +#define MAX_TOUCH_NUM10
> +#define MAX_PACKET_SIZE  32
> +#define BOOT_DELAY_MS100
> +
> +#define RAYDIUM_FW_PAGESIZE  128
> +#define RAYDIUM_POWERON_DELAY_USEC   500
> +#define RAYDIUM_RESET_DELAY_MSEC 50
> +
> +#define ADDR_INDEX   0x03
> +#define DATA_INDEX   0x04
> +
> +#define HEADER_SIZE  4
> +
> +enum raydium_boot_mode {
> + RAYDIUM_TS_MAIN = 0,
> + RAYDIUM_TS_BLDR,
> +};
> +
> +enum raydium_abs_idx {
> + POS_STATE = 0,/*1:touch, 0:no touch*/
> + POS_X,
> + POS_Y = 3,
> + POS_PRESSURE,
> + WIDTH_X,
> + WIDTH_Y,
> +};
> +
> +struct raydium_info {
> + u32 hw_ver; /*device ver, __le32*/
> + u8 main_ver;
> + u8 sub_ver;
> + u16 ft_ver; /*test ver, __le16*/
> + u8 x_num;
> + u8 y_num;
> + u16 x_max;  /*disp reso, __le16*/
> + u16 y_max;  /*disp reso, __le16*/
> + u8 x_res;   /* units/mm */
> + u8 y_res;   /* units/mm */
> +};
> +
> +struct raydium_object {
> + u32 data_bank_addr;
> + u8 pkg_size;
> + u8 tp_info_size;
> +};
> +
> +/* struct raydium_data - represents state of Raydium touchscreen device */
> +struct raydium_data {
> + struct i2c_client *client;
> + struct input_dev *input;
> +
> + struct regulator *avdd;
> + struct regulator *vccio;
> + struct gpio_desc *reset_gpio;
> +
> + u32 query_bank_info;
> +
> + struct raydium_info info;
> + struct raydium_object obj;
> + enum raydium_boot_mode boot_mode;
> +
> + struct mutex sysfs_mutex;
> + struct completion cmd_done;
> +
> + bool wake_irq_enabled;
> +};
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1], idx_i;
> + u16 pkg_len, use_len;
> + int tries = 0;
> +
> + buf[0] = addr;
> + use_len = len;
> + use_len = 0;
> +
> + while (use_len) {
> + pkg_len = (use_len < MAX_PACKET_SIZE) ?
> + use_len : MAX_PACKET_SIZE;
> + memcpy([1], data + idx_i*MAX_PACKET_SIZE, pkg_len);
> +
> + tries = 0;
> + do {
> + if (i2c_master_send(client, buf, pkg_len + 1)
> + == (pkg_len + 1))
> + break;
> + msleep(20);
> + } while (++tries < MAX_RETRIES);
> + idx_i++;
> + use_len = (use_len < MAX_PACKET_SIZE) ?
> + 0 : (use_len - MAX_PACKET_SIZE);
> + }
> +
> + dev_err(>dev, "%s: i2c send failed\n", __func__);
> +
> + return -EIO;
> +}
> +
> +static int raydium_i2c_read(struct i2c_client *client,
> + u8 addr, size_t len, void *data)
> +{
> + struct i2c_msg xfer[2];
> + int ret;
> +
> + /* Write register */
> + xfer[0].addr = client->addr;
> + xfer[0].flags = 0;
> + xfer[0].len = 1;
> + xfer[0].buf = 
> +
> + /* Read data */
> + xfer[1].addr = client->addr;
> + xfer[1].flags = I2C_M_RD;
> + xfer[1].len = len;
> + xfer[1].buf = data;
> +
> + ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer));
> + if (ret < 0)
> + return ret;
> +
> + if (ret != ARRAY_SIZE(xfer))
> + return -EIO;
> +
> + return 0;
> +}
> +
> +static int 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-22 Thread dan.huang
From: "jeffrey.lin" 

Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1172 
 3 files changed, 1185 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..140970c
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1172 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_BOOT_WRT   0x11
+#define CMD_BOOT_ACK   0x22
+#define CMD_BOOT_CHK   0x33
+#define CMD_BOOT_READ  0x44
+#define CMD_BOOT_WAIT_READY0x1A
+#define CMD_BOOT_PATH_READY0x1B
+#define BOOT_RDY   0xFF
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE32
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+
+struct raydium_info {
+   u32 hw_ver; /*device ver, __le32*/
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver; /*test ver, __le16*/
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;  /*disp reso, __le16*/
+   u16 y_max;  /*disp reso, __le16*/
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+   u8 tp_info_size;
+};
+
+/* struct raydium_data - represents state of 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-22 Thread dan.huang
From: "jeffrey.lin" 

Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |   12 +
 drivers/input/touchscreen/Makefile |1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 1172 
 3 files changed, 1185 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..140970c
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,1172 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_BOOT_WRT   0x11
+#define CMD_BOOT_ACK   0x22
+#define CMD_BOOT_CHK   0x33
+#define CMD_BOOT_READ  0x44
+#define CMD_BOOT_WAIT_READY0x1A
+#define CMD_BOOT_PATH_READY0x1B
+#define BOOT_RDY   0xFF
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE32
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+
+struct raydium_info {
+   u32 hw_ver; /*device ver, __le32*/
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver; /*test ver, __le16*/
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;  /*disp reso, __le16*/
+   u16 y_max;  /*disp reso, __le16*/
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+   u8 tp_info_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data 

RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-14 Thread 林義章
Hi Dmitry:
Our new submission now is in progress. Do you have any further suggestions for 
my submission and when can I submit my new update?

Thank you.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Jeffrey Lin (林義章) 
Sent: Monday, April 11, 2016 5:57 PM
To: 'Dmitry Torokhov'; jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Roger Yang (楊鎮瑋); 
KP Li (李昆倍); Albert Shieh (謝欣瑋); linux-kernel@vger.kernel.org; 
linux-in...@vger.kernel.org; devicet...@vger.kernel.org
Subject: RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Dmitry:
Thank you for your response.
Actually, we didn't implement FW update function on the chromeos 
device, we just copy function from our previous android device. I'll fix that 
on the next version. Raydium controller doesn't have access bytes limit, but my 
previous android experimental device had 60 bytes limit.

About reformatting command structure, do you want me to reform all my commands 
as you said in the mail or just in case of fw update function? If not just in 
case of FW update, it's better to meet maximum buffer size, like 
"MAX_PACKET_SIZE".


Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] 
Sent: Monday, April 11, 2016 4:24 PM
To: jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); 
Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Jeffrey,

On Fri, Mar 25, 2016 at 01:21:09PM +0800, jeffrey.lin wrote:
> +#define MAX_PACKET_SIZE  60
...
> +#define RAYDIUM_FW_PAGESIZE  128
...
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
...
> +static int raydium_i2c_fw_write_page(struct i2c_client *client,
> + const void *page)
> +{
> + static const u8 ack_ok[] = { 0x55, 0xAA };
> + u8 buf[2];
> + int retry;
> + int error;
> +
> + for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
> + error = raydium_i2c_send(client, CMD_BOOT_WRT,
> + (u8 *)page, RAYDIUM_FW_PAGESIZE);
> + if (error) {
> + dev_err(>dev,
> + "BLDR Write Page failed: %d\n", error);
> + continue;
> + }

Given the above definitions of MAX_PACKET_SIZE and RAYDIUM_FW_PAGESIZE I do not 
believe that firmware update is working.
What is the biggest buffer that can be sent to the device? Maybe we should 
allocate it dynamically?

I am also wondering about formatting command structure as byte sequence.
Would it be better to define it as:

struct raidium_cmd {
u32 bank;
int len;
u8 cmd[RAIDIUM_MAX_CMD_LEN];
}

What is the longest command that the controller supports?

(Do not resubmit the driver yet, let's discuss first).

Thanks.

--
Dmitry


RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-14 Thread 林義章
Hi Dmitry:
Our new submission now is in progress. Do you have any further suggestions for 
my submission and when can I submit my new update?

Thank you.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Jeffrey Lin (林義章) 
Sent: Monday, April 11, 2016 5:57 PM
To: 'Dmitry Torokhov'; jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Roger Yang (楊鎮瑋); 
KP Li (李昆倍); Albert Shieh (謝欣瑋); linux-kernel@vger.kernel.org; 
linux-in...@vger.kernel.org; devicet...@vger.kernel.org
Subject: RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Dmitry:
Thank you for your response.
Actually, we didn't implement FW update function on the chromeos 
device, we just copy function from our previous android device. I'll fix that 
on the next version. Raydium controller doesn't have access bytes limit, but my 
previous android experimental device had 60 bytes limit.

About reformatting command structure, do you want me to reform all my commands 
as you said in the mail or just in case of fw update function? If not just in 
case of FW update, it's better to meet maximum buffer size, like 
"MAX_PACKET_SIZE".


Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] 
Sent: Monday, April 11, 2016 4:24 PM
To: jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); 
Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Jeffrey,

On Fri, Mar 25, 2016 at 01:21:09PM +0800, jeffrey.lin wrote:
> +#define MAX_PACKET_SIZE  60
...
> +#define RAYDIUM_FW_PAGESIZE  128
...
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
...
> +static int raydium_i2c_fw_write_page(struct i2c_client *client,
> + const void *page)
> +{
> + static const u8 ack_ok[] = { 0x55, 0xAA };
> + u8 buf[2];
> + int retry;
> + int error;
> +
> + for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
> + error = raydium_i2c_send(client, CMD_BOOT_WRT,
> + (u8 *)page, RAYDIUM_FW_PAGESIZE);
> + if (error) {
> + dev_err(>dev,
> + "BLDR Write Page failed: %d\n", error);
> + continue;
> + }

Given the above definitions of MAX_PACKET_SIZE and RAYDIUM_FW_PAGESIZE I do not 
believe that firmware update is working.
What is the biggest buffer that can be sent to the device? Maybe we should 
allocate it dynamically?

I am also wondering about formatting command structure as byte sequence.
Would it be better to define it as:

struct raidium_cmd {
u32 bank;
int len;
u8 cmd[RAIDIUM_MAX_CMD_LEN];
}

What is the longest command that the controller supports?

(Do not resubmit the driver yet, let's discuss first).

Thanks.

--
Dmitry


RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-11 Thread 林義章
Hi Dmitry:
Thank you for your response.
Actually, we didn't implement FW update function on the chromeos 
device, we just copy function from our previous android device. I'll fix that 
on the next version. Raydium controller doesn't have access bytes limit, but my 
previous android experimental device had 60 bytes limit.

About reformatting command structure, do you want me to reform all my commands 
as you said in the mail or just in case of fw update function? If not just in 
case of FW update, it's better to meet maximum buffer size, like 
"MAX_PACKET_SIZE".


Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] 
Sent: Monday, April 11, 2016 4:24 PM
To: jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); 
Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Jeffrey,

On Fri, Mar 25, 2016 at 01:21:09PM +0800, jeffrey.lin wrote:
> +#define MAX_PACKET_SIZE  60
...
> +#define RAYDIUM_FW_PAGESIZE  128
...
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
...
> +static int raydium_i2c_fw_write_page(struct i2c_client *client,
> + const void *page)
> +{
> + static const u8 ack_ok[] = { 0x55, 0xAA };
> + u8 buf[2];
> + int retry;
> + int error;
> +
> + for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
> + error = raydium_i2c_send(client, CMD_BOOT_WRT,
> + (u8 *)page, RAYDIUM_FW_PAGESIZE);
> + if (error) {
> + dev_err(>dev,
> + "BLDR Write Page failed: %d\n", error);
> + continue;
> + }

Given the above definitions of MAX_PACKET_SIZE and RAYDIUM_FW_PAGESIZE I do not 
believe that firmware update is working.
What is the biggest buffer that can be sent to the device? Maybe we should 
allocate it dynamically?

I am also wondering about formatting command structure as byte sequence.
Would it be better to define it as:

struct raidium_cmd {
u32 bank;
int len;
u8 cmd[RAIDIUM_MAX_CMD_LEN];
}

What is the longest command that the controller supports?

(Do not resubmit the driver yet, let's discuss first).

Thanks.

--
Dmitry


RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-11 Thread 林義章
Hi Dmitry:
Thank you for your response.
Actually, we didn't implement FW update function on the chromeos 
device, we just copy function from our previous android device. I'll fix that 
on the next version. Raydium controller doesn't have access bytes limit, but my 
previous android experimental device had 60 bytes limit.

About reformatting command structure, do you want me to reform all my commands 
as you said in the mail or just in case of fw update function? If not just in 
case of FW update, it's better to meet maximum buffer size, like 
"MAX_PACKET_SIZE".


Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] 
Sent: Monday, April 11, 2016 4:24 PM
To: jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); 
Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Jeffrey,

On Fri, Mar 25, 2016 at 01:21:09PM +0800, jeffrey.lin wrote:
> +#define MAX_PACKET_SIZE  60
...
> +#define RAYDIUM_FW_PAGESIZE  128
...
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
...
> +static int raydium_i2c_fw_write_page(struct i2c_client *client,
> + const void *page)
> +{
> + static const u8 ack_ok[] = { 0x55, 0xAA };
> + u8 buf[2];
> + int retry;
> + int error;
> +
> + for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
> + error = raydium_i2c_send(client, CMD_BOOT_WRT,
> + (u8 *)page, RAYDIUM_FW_PAGESIZE);
> + if (error) {
> + dev_err(>dev,
> + "BLDR Write Page failed: %d\n", error);
> + continue;
> + }

Given the above definitions of MAX_PACKET_SIZE and RAYDIUM_FW_PAGESIZE I do not 
believe that firmware update is working.
What is the biggest buffer that can be sent to the device? Maybe we should 
allocate it dynamically?

I am also wondering about formatting command structure as byte sequence.
Would it be better to define it as:

struct raidium_cmd {
u32 bank;
int len;
u8 cmd[RAIDIUM_MAX_CMD_LEN];
}

What is the longest command that the controller supports?

(Do not resubmit the driver yet, let's discuss first).

Thanks.

--
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-11 Thread Dmitry Torokhov
Hi Jeffrey,

On Fri, Mar 25, 2016 at 01:21:09PM +0800, jeffrey.lin wrote:
> +#define MAX_PACKET_SIZE  60
...
> +#define RAYDIUM_FW_PAGESIZE  128
...
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
...
> +static int raydium_i2c_fw_write_page(struct i2c_client *client,
> + const void *page)
> +{
> + static const u8 ack_ok[] = { 0x55, 0xAA };
> + u8 buf[2];
> + int retry;
> + int error;
> +
> + for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
> + error = raydium_i2c_send(client, CMD_BOOT_WRT,
> + (u8 *)page, RAYDIUM_FW_PAGESIZE);
> + if (error) {
> + dev_err(>dev,
> + "BLDR Write Page failed: %d\n", error);
> + continue;
> + }

Given the above definitions of MAX_PACKET_SIZE and
RAYDIUM_FW_PAGESIZE I do not believe that firmware update is working.
What is the biggest buffer that can be sent to the device? Maybe we
should allocate it dynamically?

I am also wondering about formatting command structure as byte sequence.
Would it be better to define it as:

struct raidium_cmd {
u32 bank;
int len;
u8 cmd[RAIDIUM_MAX_CMD_LEN];
}

What is the longest command that the controller supports?

(Do not resubmit the driver yet, let's discuss first).

Thanks.

-- 
Dmitry


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-04-11 Thread Dmitry Torokhov
Hi Jeffrey,

On Fri, Mar 25, 2016 at 01:21:09PM +0800, jeffrey.lin wrote:
> +#define MAX_PACKET_SIZE  60
...
> +#define RAYDIUM_FW_PAGESIZE  128
...
> +
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
...
> +static int raydium_i2c_fw_write_page(struct i2c_client *client,
> + const void *page)
> +{
> + static const u8 ack_ok[] = { 0x55, 0xAA };
> + u8 buf[2];
> + int retry;
> + int error;
> +
> + for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
> + error = raydium_i2c_send(client, CMD_BOOT_WRT,
> + (u8 *)page, RAYDIUM_FW_PAGESIZE);
> + if (error) {
> + dev_err(>dev,
> + "BLDR Write Page failed: %d\n", error);
> + continue;
> + }

Given the above definitions of MAX_PACKET_SIZE and
RAYDIUM_FW_PAGESIZE I do not believe that firmware update is working.
What is the biggest buffer that can be sent to the device? Maybe we
should allocate it dynamically?

I am also wondering about formatting command structure as byte sequence.
Would it be better to define it as:

struct raidium_cmd {
u32 bank;
int len;
u8 cmd[RAIDIUM_MAX_CMD_LEN];
}

What is the longest command that the controller supports?

(Do not resubmit the driver yet, let's discuss first).

Thanks.

-- 
Dmitry


[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-24 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 932 +
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..e1ff49a
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,932 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"rm_ts"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+
+struct raydium_info {
+   u32 hw_ver; /*device ver, __le32*/
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver; /*test ver, __le16*/
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;  /*disp reso, __le16*/
+   u16 y_max;  /*disp reso, __le16*/
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+   u8 tp_info_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *avdd;
+   struct regulator *vccio;
+   struct gpio_desc 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-24 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 932 +
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..df0e2ed 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM32380,connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..e1ff49a
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,932 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"rm_ts"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+
+struct raydium_info {
+   u32 hw_ver; /*device ver, __le32*/
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver; /*test ver, __le16*/
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;  /*disp reso, __le16*/
+   u16 y_max;  /*disp reso, __le16*/
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+   u8 tp_info_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *avdd;
+   struct regulator *vccio;
+   struct gpio_desc *reset_gpio;
+
+   u32 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-22 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  13 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 932 +
 3 files changed, 946 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..9adacf6 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..d4184e2
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,932 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"rm3"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+
+struct raydium_info {
+   u32 hw_ver; /*device ver, __le32*/
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver; /*test ver, __le16*/
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;  /*disp reso, __le16*/
+   u16 y_max;  /*disp reso, __le16*/
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+   u8 tp_info_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *avdd;
+   struct regulator *vccio;
+   struct 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-22 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  13 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 932 +
 3 files changed, 946 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..9adacf6 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..d4184e2
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,932 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"rm3"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define DATA_INDEX 0x04
+
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN = 0,
+   RAYDIUM_TS_BLDR,
+};
+
+enum raydium_abs_idx {
+   POS_STATE = 0,/*1:touch, 0:no touch*/
+   POS_X,
+   POS_Y = 3,
+   POS_PRESSURE,
+   WIDTH_X,
+   WIDTH_Y,
+};
+
+struct raydium_info {
+   u32 hw_ver; /*device ver, __le32*/
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver; /*test ver, __le16*/
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;  /*disp reso, __le16*/
+   u16 y_max;  /*disp reso, __le16*/
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+   u8 tp_info_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *avdd;
+   struct regulator *vccio;
+   struct gpio_desc *reset_gpio;
+
+ 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-19 Thread Rob Herring
On Tue, Mar 15, 2016 at 04:44:17PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 
> ---
>  .../devicetree/bindings/input/raydium_i2c_ts.txt   |  23 +
>  .../devicetree/bindings/vendor-prefixes.txt|   1 +

It is generally preferred to split bindings from driver changes.

>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/raydium_i2c_ts.c | 932 
> +
>  5 files changed, 969 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
>  create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c
> 
> diff --git a/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt 
> b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
> new file mode 100644
> index 000..329864d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
> @@ -0,0 +1,23 @@
> +Raydium I2C touchscreen
> +
> +Required properties:
> +- compatible:
> +"raydium,rm31100"
> +
> +- reg: The I2C address of the device
> +- interrupts: interrupt to which the chip is connected
> +See ../interrupt-controller/interrupts.txt
> +Optional property:
> + - avdd-supply   : Analog power supply needed to power device
> + - vccio-supply: IO Power source
> +
> +Example:
> +
> + raydium_i2c@0x39 {

touchscreen@39

Otherwise,

Acked-by: Rob Herring 


> + compatible = "raydium,rm31100";
> + avdd-supply = <_l19>;
> + vccio-supply = <_lvs1>;
> + reg = <0x39>;
> + interrupt-parent = <>;
> + interrupts = <0x0 IRQ_TYPE_EDGE_FALLING>;
> + };
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index af49e0f..5b6224b 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -126,6 +126,7 @@ radxa Radxa
>  raidsonicRaidSonic Technology GmbH
>  ralink   Mediatek/Ralink Technology Corp.
>  ramtron  Ramtron International
> +raydium Raydium Semiconductor Corp.
>  realtek Realtek Semiconductor Corp.
>  renesas  Renesas Electronics Corporation
>  ricohRicoh Co. Ltd.



Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-19 Thread Rob Herring
On Tue, Mar 15, 2016 at 04:44:17PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 
> ---
>  .../devicetree/bindings/input/raydium_i2c_ts.txt   |  23 +
>  .../devicetree/bindings/vendor-prefixes.txt|   1 +

It is generally preferred to split bindings from driver changes.

>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/raydium_i2c_ts.c | 932 
> +
>  5 files changed, 969 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
>  create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c
> 
> diff --git a/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt 
> b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
> new file mode 100644
> index 000..329864d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
> @@ -0,0 +1,23 @@
> +Raydium I2C touchscreen
> +
> +Required properties:
> +- compatible:
> +"raydium,rm31100"
> +
> +- reg: The I2C address of the device
> +- interrupts: interrupt to which the chip is connected
> +See ../interrupt-controller/interrupts.txt
> +Optional property:
> + - avdd-supply   : Analog power supply needed to power device
> + - vccio-supply: IO Power source
> +
> +Example:
> +
> + raydium_i2c@0x39 {

touchscreen@39

Otherwise,

Acked-by: Rob Herring 


> + compatible = "raydium,rm31100";
> + avdd-supply = <_l19>;
> + vccio-supply = <_lvs1>;
> + reg = <0x39>;
> + interrupt-parent = <>;
> + interrupts = <0x0 IRQ_TYPE_EDGE_FALLING>;
> + };
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index af49e0f..5b6224b 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -126,6 +126,7 @@ radxa Radxa
>  raidsonicRaidSonic Technology GmbH
>  ralink   Mediatek/Ralink Technology Corp.
>  ramtron  Ramtron International
> +raydium Raydium Semiconductor Corp.
>  realtek Realtek Semiconductor Corp.
>  renesas  Renesas Electronics Corporation
>  ricohRicoh Co. Ltd.



[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-15 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 .../devicetree/bindings/input/raydium_i2c_ts.txt   |  23 +
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 932 +
 5 files changed, 969 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt 
b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
new file mode 100644
index 000..329864d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
@@ -0,0 +1,23 @@
+Raydium I2C touchscreen
+
+Required properties:
+- compatible:
+"raydium,rm31100"
+
+- reg: The I2C address of the device
+- interrupts: interrupt to which the chip is connected
+See ../interrupt-controller/interrupts.txt
+Optional property:
+ - avdd-supply : Analog power supply needed to power device
+ - vccio-supply: IO Power source
+
+Example:
+
+   raydium_i2c@0x39 {
+   compatible = "raydium,rm31100";
+   avdd-supply = <_l19>;
+   vccio-supply = <_lvs1>;
+   reg = <0x39>;
+   interrupt-parent = <>;
+   interrupts = <0x0 IRQ_TYPE_EDGE_FALLING>;
+   };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index af49e0f..5b6224b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -126,6 +126,7 @@ radxa   Radxa
 raidsonic  RaidSonic Technology GmbH
 ralink Mediatek/Ralink Technology Corp.
 ramtronRamtron International
+raydium Raydium Semiconductor Corp.
 realtek Realtek Semiconductor Corp.
 renesasRenesas Electronics Corporation
 ricoh  Ricoh Co. Ltd.
diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..69a0388
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,932 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"rm31100"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-15 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 .../devicetree/bindings/input/raydium_i2c_ts.txt   |  23 +
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 932 +
 5 files changed, 969 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt 
b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
new file mode 100644
index 000..329864d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/raydium_i2c_ts.txt
@@ -0,0 +1,23 @@
+Raydium I2C touchscreen
+
+Required properties:
+- compatible:
+"raydium,rm31100"
+
+- reg: The I2C address of the device
+- interrupts: interrupt to which the chip is connected
+See ../interrupt-controller/interrupts.txt
+Optional property:
+ - avdd-supply : Analog power supply needed to power device
+ - vccio-supply: IO Power source
+
+Example:
+
+   raydium_i2c@0x39 {
+   compatible = "raydium,rm31100";
+   avdd-supply = <_l19>;
+   vccio-supply = <_lvs1>;
+   reg = <0x39>;
+   interrupt-parent = <>;
+   interrupts = <0x0 IRQ_TYPE_EDGE_FALLING>;
+   };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index af49e0f..5b6224b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -126,6 +126,7 @@ radxa   Radxa
 raidsonic  RaidSonic Technology GmbH
 ralink Mediatek/Ralink Technology Corp.
 ramtronRamtron International
+raydium Raydium Semiconductor Corp.
 realtek Realtek Semiconductor Corp.
 renesasRenesas Electronics Corporation
 ricoh  Ricoh Co. Ltd.
diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..69a0388
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,932 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"rm31100"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define 

RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-10 Thread 林義章
Hi Dmitry:
Thanks for your response. I'll fixed issues you remarked in the mail.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] 
Sent: Friday, March 11, 2016 2:48 AM
To: jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); 
Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Jeffrey,

On Thu, Mar 03, 2016 at 02:42:11PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin <jeffrey@rad-ic.com>
> ---
>  drivers/input/touchscreen/Kconfig  |  13 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/raydium_i2c_ts.c | 953 
> +
>  3 files changed, 967 insertions(+)
>  create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 3f3f6ee..9adacf6 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
> To compile this driver as a module, choose M here: the
> module will be called pcap_ts.
>  
> +config TOUCHSCREEN_RM_TS

Can we call it TOUCHSCREEN_RAYDIUM_RM31100? Do you have other models?
Maybe RM31XXX or similar?

Or TOUCHSCREEN_RAYDIUM_I2C?

I just want to make a general i2c driver for our several raydium models. So I 
think TOUCHSCREEN_RAYDIUM_I2C be better.
> + tristate "Raydium I2C Touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have Raydium series I2C touchscreen,
> +   such as RM31100 , connected to your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called raydium_i2c_ts.
> +
> +

Extra empty line.

>  config TOUCHSCREEN_ST1232
>   tristate "Sitronix ST1232 touchscreen controllers"
>   depends on I2C
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 4941f2d..99e08cf 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += 
> usbtouchscreen.o
>  obj-$(CONFIG_TOUCHSCREEN_PCAP)   += pcap_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)   += penmount.o
>  obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_RM_TS)  += raydium_i2c_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_S3C2410)+= s3c2410_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
>  obj-$(CONFIG_TOUCHSCREEN_STMPE)  += stmpe-ts.o
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
> new file mode 100644
> index 000..7ba681e
> --- /dev/null
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -0,0 +1,953 @@
> +/*
> + * Raydium touchscreen I2C driver.
> + *
> + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, and only version 2, as published by the
> + * Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Raydium reserves the right to make changes without further notice
> + * to the materials described herein. Raydium does not assume any
> + * liability arising out of the application described herein.
> + *
> + * Contact Raydium Semiconductor Corporation at www.rad-ic.com  */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Why do you need this include?

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

I do not think you need this one.

> +#include  #include  
> +#include 
> +
> +/* Device, Driver information */
> +#define DEVICE_NAME  "raydium_i2c"
> +
> +/* Slave I2C mode*/
> +#define RM_BOOT_BLDR 0x02
> +#define RM_BOOT_MAIN 0x03

RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-10 Thread 林義章
Hi Dmitry:
Thanks for your response. I'll fixed issues you remarked in the mail.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] 
Sent: Friday, March 11, 2016 2:48 AM
To: jeffrey.lin
Cc: rydb...@euromail.se; grant.lik...@linaro.org; robh...@kernel.org; 
je...@melfas.com; ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); 
Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

Hi Jeffrey,

On Thu, Mar 03, 2016 at 02:42:11PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 
> ---
>  drivers/input/touchscreen/Kconfig  |  13 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/raydium_i2c_ts.c | 953 
> +
>  3 files changed, 967 insertions(+)
>  create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 3f3f6ee..9adacf6 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
> To compile this driver as a module, choose M here: the
> module will be called pcap_ts.
>  
> +config TOUCHSCREEN_RM_TS

Can we call it TOUCHSCREEN_RAYDIUM_RM31100? Do you have other models?
Maybe RM31XXX or similar?

Or TOUCHSCREEN_RAYDIUM_I2C?

I just want to make a general i2c driver for our several raydium models. So I 
think TOUCHSCREEN_RAYDIUM_I2C be better.
> + tristate "Raydium I2C Touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have Raydium series I2C touchscreen,
> +   such as RM31100 , connected to your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called raydium_i2c_ts.
> +
> +

Extra empty line.

>  config TOUCHSCREEN_ST1232
>   tristate "Sitronix ST1232 touchscreen controllers"
>   depends on I2C
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 4941f2d..99e08cf 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += 
> usbtouchscreen.o
>  obj-$(CONFIG_TOUCHSCREEN_PCAP)   += pcap_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)   += penmount.o
>  obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_RM_TS)  += raydium_i2c_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_S3C2410)+= s3c2410_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
>  obj-$(CONFIG_TOUCHSCREEN_STMPE)  += stmpe-ts.o
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
> new file mode 100644
> index 000..7ba681e
> --- /dev/null
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -0,0 +1,953 @@
> +/*
> + * Raydium touchscreen I2C driver.
> + *
> + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, and only version 2, as published by the
> + * Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Raydium reserves the right to make changes without further notice
> + * to the materials described herein. Raydium does not assume any
> + * liability arising out of the application described herein.
> + *
> + * Contact Raydium Semiconductor Corporation at www.rad-ic.com  */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Why do you need this include?

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

I do not think you need this one.

> +#include  #include  
> +#include 
> +
> +/* Device, Driver information */
> +#define DEVICE_NAME  "raydium_i2c"
> +
> +/* Slave I2C mode*/
> +#define RM_BOOT_BLDR 0x02
> +#define RM_BOOT_MAIN 0x03
> +
> +/*I2C comman

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-10 Thread Dmitry Torokhov
Hi Jeffrey,

On Thu, Mar 03, 2016 at 02:42:11PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 
> ---
>  drivers/input/touchscreen/Kconfig  |  13 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/raydium_i2c_ts.c | 953 
> +
>  3 files changed, 967 insertions(+)
>  create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 3f3f6ee..9adacf6 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
> To compile this driver as a module, choose M here: the
> module will be called pcap_ts.
>  
> +config TOUCHSCREEN_RM_TS

Can we call it TOUCHSCREEN_RAYDIUM_RM31100? Do you have other models?
Maybe RM31XXX or similar?

Or TOUCHSCREEN_RAYDIUM_I2C?

> + tristate "Raydium I2C Touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have Raydium series I2C touchscreen,
> +   such as RM31100 , connected to your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called raydium_i2c_ts.
> +
> +

Extra empty line.

>  config TOUCHSCREEN_ST1232
>   tristate "Sitronix ST1232 touchscreen controllers"
>   depends on I2C
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 4941f2d..99e08cf 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += 
> usbtouchscreen.o
>  obj-$(CONFIG_TOUCHSCREEN_PCAP)   += pcap_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)   += penmount.o
>  obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_RM_TS)  += raydium_i2c_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_S3C2410)+= s3c2410_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
>  obj-$(CONFIG_TOUCHSCREEN_STMPE)  += stmpe-ts.o
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
> new file mode 100644
> index 000..7ba681e
> --- /dev/null
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -0,0 +1,953 @@
> +/*
> + * Raydium touchscreen I2C driver.
> + *
> + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, and only version 2, as published by the
> + * Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Raydium reserves the right to make changes without further notice
> + * to the materials described herein. Raydium does not assume any
> + * liability arising out of the application described herein.
> + *
> + * Contact Raydium Semiconductor Corporation at www.rad-ic.com
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Why do you need this include?

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

I do not think you need this one.

> +#include 
> +#include 
> +#include 
> +
> +/* Device, Driver information */
> +#define DEVICE_NAME  "raydium_i2c"
> +
> +/* Slave I2C mode*/
> +#define RM_BOOT_BLDR 0x02
> +#define RM_BOOT_MAIN 0x03
> +
> +/*I2C command */
> +#define CMD_QUERY_BANK   0x2B
> +#define CMD_DATA_BANK0x4D
> +#define CMD_ENTER_SLEEP  0x4E
> +#define CMD_BOOT_ACK 0x0A
> +#define CMD_BOOT_WRT 0x5B
> +#define CMD_BOOT_CHK 0x0C
> +#define CMD_BANK_SWITCH  0xAA
> +
> +/* Touch relative info */
> +#define MAX_RETRIES  3
> +#define MAX_FW_UPDATE_RETRIES30
> +#define MAX_TOUCH_NUM10
> +#define MAX_PACKET_SIZE  60
> +#define BOOT_DELAY_MS100
> +
> +#define RAYDIUM_FW_PAGESIZE  128
> +#define RAYDIUM_POWERON_DELAY_USEC   500
> +#define RAYDIUM_RESET_DELAY_MSEC 50
> +
> +#define ADDR_INDEX   0x03
> +#define HEADER_SIZE  4
> +
> +enum raydium_boot_mode {
> + RAYDIUM_TS_MAIN,
> + RAYDIUM_TS_BLDR,
> +};
> +
> +struct raydium_info {
> + u32 hw_ver;

This seems to be coming directly form the wire, you need to annotate it
as little- or big-endian and use appropriate accessors to convert to CPU
endianness.

> + u8 main_ver;
> + u8 sub_ver;
> + u16 ft_ver;

Same here.

> + u8 x_num;
> + u8 y_num;
> + u16 x_max;
> + u16 y_max;

And here.

> + u8 x_res;   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-10 Thread Dmitry Torokhov
Hi Jeffrey,

On Thu, Mar 03, 2016 at 02:42:11PM +0800, jeffrey.lin wrote:
> Raydium I2C touch driver.
> 
> Signed-off-by: jeffrey.lin 
> ---
>  drivers/input/touchscreen/Kconfig  |  13 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/raydium_i2c_ts.c | 953 
> +
>  3 files changed, 967 insertions(+)
>  create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 3f3f6ee..9adacf6 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
> To compile this driver as a module, choose M here: the
> module will be called pcap_ts.
>  
> +config TOUCHSCREEN_RM_TS

Can we call it TOUCHSCREEN_RAYDIUM_RM31100? Do you have other models?
Maybe RM31XXX or similar?

Or TOUCHSCREEN_RAYDIUM_I2C?

> + tristate "Raydium I2C Touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have Raydium series I2C touchscreen,
> +   such as RM31100 , connected to your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called raydium_i2c_ts.
> +
> +

Extra empty line.

>  config TOUCHSCREEN_ST1232
>   tristate "Sitronix ST1232 touchscreen controllers"
>   depends on I2C
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 4941f2d..99e08cf 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += 
> usbtouchscreen.o
>  obj-$(CONFIG_TOUCHSCREEN_PCAP)   += pcap_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)   += penmount.o
>  obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_RM_TS)  += raydium_i2c_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_S3C2410)+= s3c2410_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
>  obj-$(CONFIG_TOUCHSCREEN_STMPE)  += stmpe-ts.o
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
> new file mode 100644
> index 000..7ba681e
> --- /dev/null
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -0,0 +1,953 @@
> +/*
> + * Raydium touchscreen I2C driver.
> + *
> + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, and only version 2, as published by the
> + * Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Raydium reserves the right to make changes without further notice
> + * to the materials described herein. Raydium does not assume any
> + * liability arising out of the application described herein.
> + *
> + * Contact Raydium Semiconductor Corporation at www.rad-ic.com
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Why do you need this include?

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

I do not think you need this one.

> +#include 
> +#include 
> +#include 
> +
> +/* Device, Driver information */
> +#define DEVICE_NAME  "raydium_i2c"
> +
> +/* Slave I2C mode*/
> +#define RM_BOOT_BLDR 0x02
> +#define RM_BOOT_MAIN 0x03
> +
> +/*I2C command */
> +#define CMD_QUERY_BANK   0x2B
> +#define CMD_DATA_BANK0x4D
> +#define CMD_ENTER_SLEEP  0x4E
> +#define CMD_BOOT_ACK 0x0A
> +#define CMD_BOOT_WRT 0x5B
> +#define CMD_BOOT_CHK 0x0C
> +#define CMD_BANK_SWITCH  0xAA
> +
> +/* Touch relative info */
> +#define MAX_RETRIES  3
> +#define MAX_FW_UPDATE_RETRIES30
> +#define MAX_TOUCH_NUM10
> +#define MAX_PACKET_SIZE  60
> +#define BOOT_DELAY_MS100
> +
> +#define RAYDIUM_FW_PAGESIZE  128
> +#define RAYDIUM_POWERON_DELAY_USEC   500
> +#define RAYDIUM_RESET_DELAY_MSEC 50
> +
> +#define ADDR_INDEX   0x03
> +#define HEADER_SIZE  4
> +
> +enum raydium_boot_mode {
> + RAYDIUM_TS_MAIN,
> + RAYDIUM_TS_BLDR,
> +};
> +
> +struct raydium_info {
> + u32 hw_ver;

This seems to be coming directly form the wire, you need to annotate it
as little- or big-endian and use appropriate accessors to convert to CPU
endianness.

> + u8 main_ver;
> + u8 sub_ver;
> + u16 ft_ver;

Same here.

> + u8 x_num;
> + u8 y_num;
> + u16 x_max;
> + u16 y_max;

And here.

> + u8 x_res;   /* units/mm */

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  13 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 953 +
 3 files changed, 967 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..9adacf6 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..7ba681e
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,953 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   struct regulator *vccio;
+   struct gpio_desc *reset_gpio;
+
+   u32 query_bank_info;
+
+   struct 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread jeffrey.lin
Raydium I2C touch driver.

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  13 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 953 +
 3 files changed, 967 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..9adacf6 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,19 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..7ba681e
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,953 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   struct regulator *vccio;
+   struct gpio_desc *reset_gpio;
+
+   u32 query_bank_info;
+
+   struct raydium_info info;
+   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread Joe Perches
On Thu, 2016-03-03 at 03:14 +, Jeffrey Lin (林義章) wrote:
> Hi Joe:
> Thank you for your response. I'll follow your comments in next version.

OK, btw: the below looks very odd

> > +static int raydium_i2c_send_message(struct i2c_client *client,
> > +   size_t len, void *data)
> > +{
> > +   int error;
> > +   u8 buf[HEADER_SIZE], ii;
> > +
> > +   for (ii = 0; ii < HEADER_SIZE; ii++)
> > +   buf[ii] = ((u8 *)data)[3 - ii];

It intermixes a #define of 4 with a hard declaration of 3
to reverse copy a byte array of length HEADER_SIZE.

Maybe use:
for (ii = 0; ii < HEADER_SIZE; ii++)
buf[ii] = ((u8 *)data)[HEADER_SIZE - 1 - ii]


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread Joe Perches
On Thu, 2016-03-03 at 03:14 +, Jeffrey Lin (林義章) wrote:
> Hi Joe:
> Thank you for your response. I'll follow your comments in next version.

OK, btw: the below looks very odd

> > +static int raydium_i2c_send_message(struct i2c_client *client,
> > +   size_t len, void *data)
> > +{
> > +   int error;
> > +   u8 buf[HEADER_SIZE], ii;
> > +
> > +   for (ii = 0; ii < HEADER_SIZE; ii++)
> > +   buf[ii] = ((u8 *)data)[3 - ii];

It intermixes a #define of 4 with a hard declaration of 3
to reverse copy a byte array of length HEADER_SIZE.

Maybe use:
for (ii = 0; ii < HEADER_SIZE; ii++)
buf[ii] = ((u8 *)data)[HEADER_SIZE - 1 - ii]


RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread 林義章
Hi Joe:
Thank you for your response. I'll follow your comments in next version.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Joe Perches [mailto:j...@perches.com] 
Sent: Thursday, March 03, 2016 10:44 AM
To: jeffrey.lin; dmitry.torok...@gmail.com; rydb...@euromail.se; 
grant.lik...@linaro.org; robh...@kernel.org; je...@melfas.com; 
ble...@chromium.org; scott@emc.com.tw
Cc: Jeffrey Lin (林義章); Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

On Thu, 2016-03-03 at 10:29 +0800, jeffrey.lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium 
> touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

trivial comments:

> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
[]
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int i, tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
> +
> + buf[0] = addr & 0xff;

Seems pointless to use & 0xff when both
buf and addr are u8

> + for (i = 0; i < len; i++)
> + buf[i + 1] = *data++;

memcpy.  Maybe:

buf[0] = addr;
memcpy([1], data, len);

> +static int raydium_i2c_send_message(struct i2c_client *client,
> + size_t len, void *data)
> +{
> + int error;
> + u8 buf[HEADER_SIZE], ii;
> +
> + for (ii = 0; ii < HEADER_SIZE; ii++)
> + buf[ii] = ((u8 *)data)[3 - ii];
> + /*set data bank*/
> + error = raydium_i2c_send(client, CMD_BANK_SWITCH,
> + (u8 *)buf, HEADER_SIZE);
> +
> + /*send messange*/

typo, message

> + if (!error)
> + error = raydium_i2c_send(client, buf[ADDR_INDEX], buf, len);
> +
> + return error;
> +}
> +
> +static int raydium_i2c_sw_reset(struct i2c_client *client)
> +{
> + const u8 soft_rst_cmd[] = { 0x01, 0x04, 0x00, 0x00, 0x40};

static

> + int error;
> +
> + error = raydium_i2c_send_message(client,
> + 1, (void *)soft_rst_cmd);

could be better on a single line

> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> + const u8 boot_cmd[] = { 0x20, 0x06, 0x00, 0x50 };
> + u8 buf[HEADER_SIZE];
> + int error;
> +
> + error = raydium_i2c_read_message(client,
> + get_unaligned_be32(boot_cmd),
> + sizeof(boot_cmd),
> + buf);
> +
> + if (error) {
> + dev_err(>dev, "boot failed: %d\n", error);
> + return error;
> + } else if (buf[0] == RM_BOOT_BLDR) {

unnecessary else

> + dev_dbg(>dev, "boot in fastboot mode\n");
> + return -EINVAL;
> + }
> +
> + dev_dbg(>dev, "boot success -- 0x%x\n", client->addr);
> + return 0;
> +}
> +
> +static int raydium_i2c_initialize(struct raydium_data *ts)
> +{
> + struct i2c_client *client = ts->client;
> + int error, retry_cnt;
> + const u8 recov_packet[] = { 0x04, 0x81 };

static and etc...

generally, it'd be nice to align to open parenthesis and
to more maximally fill lines to 80 chars instead of using
relatively short line lengths and multiple line statements.


RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread 林義章
Hi Joe:
Thank you for your response. I'll follow your comments in next version.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Joe Perches [mailto:j...@perches.com] 
Sent: Thursday, March 03, 2016 10:44 AM
To: jeffrey.lin; dmitry.torok...@gmail.com; rydb...@euromail.se; 
grant.lik...@linaro.org; robh...@kernel.org; je...@melfas.com; 
ble...@chromium.org; scott@emc.com.tw
Cc: Jeffrey Lin (林義章); Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); 
linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

On Thu, 2016-03-03 at 10:29 +0800, jeffrey.lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium 
> touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

trivial comments:

> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
[]
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int i, tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
> +
> + buf[0] = addr & 0xff;

Seems pointless to use & 0xff when both
buf and addr are u8

> + for (i = 0; i < len; i++)
> + buf[i + 1] = *data++;

memcpy.  Maybe:

buf[0] = addr;
memcpy([1], data, len);

> +static int raydium_i2c_send_message(struct i2c_client *client,
> + size_t len, void *data)
> +{
> + int error;
> + u8 buf[HEADER_SIZE], ii;
> +
> + for (ii = 0; ii < HEADER_SIZE; ii++)
> + buf[ii] = ((u8 *)data)[3 - ii];
> + /*set data bank*/
> + error = raydium_i2c_send(client, CMD_BANK_SWITCH,
> + (u8 *)buf, HEADER_SIZE);
> +
> + /*send messange*/

typo, message

> + if (!error)
> + error = raydium_i2c_send(client, buf[ADDR_INDEX], buf, len);
> +
> + return error;
> +}
> +
> +static int raydium_i2c_sw_reset(struct i2c_client *client)
> +{
> + const u8 soft_rst_cmd[] = { 0x01, 0x04, 0x00, 0x00, 0x40};

static

> + int error;
> +
> + error = raydium_i2c_send_message(client,
> + 1, (void *)soft_rst_cmd);

could be better on a single line

> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> + const u8 boot_cmd[] = { 0x20, 0x06, 0x00, 0x50 };
> + u8 buf[HEADER_SIZE];
> + int error;
> +
> + error = raydium_i2c_read_message(client,
> + get_unaligned_be32(boot_cmd),
> + sizeof(boot_cmd),
> + buf);
> +
> + if (error) {
> + dev_err(>dev, "boot failed: %d\n", error);
> + return error;
> + } else if (buf[0] == RM_BOOT_BLDR) {

unnecessary else

> + dev_dbg(>dev, "boot in fastboot mode\n");
> + return -EINVAL;
> + }
> +
> + dev_dbg(>dev, "boot success -- 0x%x\n", client->addr);
> + return 0;
> +}
> +
> +static int raydium_i2c_initialize(struct raydium_data *ts)
> +{
> + struct i2c_client *client = ts->client;
> + int error, retry_cnt;
> + const u8 recov_packet[] = { 0x04, 0x81 };

static and etc...

generally, it'd be nice to align to open parenthesis and
to more maximally fill lines to 80 chars instead of using
relatively short line lengths and multiple line statements.


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread Joe Perches
On Thu, 2016-03-03 at 10:29 +0800, jeffrey.lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium 
> touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

trivial comments:

> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
[]
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int i, tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
> +
> + buf[0] = addr & 0xff;

Seems pointless to use & 0xff when both
buf and addr are u8

> + for (i = 0; i < len; i++)
> + buf[i + 1] = *data++;

memcpy.  Maybe:

buf[0] = addr;
memcpy([1], data, len);

> +static int raydium_i2c_send_message(struct i2c_client *client,
> + size_t len, void *data)
> +{
> + int error;
> + u8 buf[HEADER_SIZE], ii;
> +
> + for (ii = 0; ii < HEADER_SIZE; ii++)
> + buf[ii] = ((u8 *)data)[3 - ii];
> + /*set data bank*/
> + error = raydium_i2c_send(client, CMD_BANK_SWITCH,
> + (u8 *)buf, HEADER_SIZE);
> +
> + /*send messange*/

typo, message

> + if (!error)
> + error = raydium_i2c_send(client, buf[ADDR_INDEX], buf, len);
> +
> + return error;
> +}
> +
> +static int raydium_i2c_sw_reset(struct i2c_client *client)
> +{
> + const u8 soft_rst_cmd[] = { 0x01, 0x04, 0x00, 0x00, 0x40};

static

> + int error;
> +
> + error = raydium_i2c_send_message(client,
> + 1, (void *)soft_rst_cmd);

could be better on a single line

> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> + const u8 boot_cmd[] = { 0x20, 0x06, 0x00, 0x50 };
> + u8 buf[HEADER_SIZE];
> + int error;
> +
> + error = raydium_i2c_read_message(client,
> + get_unaligned_be32(boot_cmd),
> + sizeof(boot_cmd),
> + buf);
> +
> + if (error) {
> + dev_err(>dev, "boot failed: %d\n", error);
> + return error;
> + } else if (buf[0] == RM_BOOT_BLDR) {

unnecessary else

> + dev_dbg(>dev, "boot in fastboot mode\n");
> + return -EINVAL;
> + }
> +
> + dev_dbg(>dev, "boot success -- 0x%x\n", client->addr);
> + return 0;
> +}
> +
> +static int raydium_i2c_initialize(struct raydium_data *ts)
> +{
> + struct i2c_client *client = ts->client;
> + int error, retry_cnt;
> + const u8 recov_packet[] = { 0x04, 0x81 };

static and etc...

generally, it'd be nice to align to open parenthesis and
to more maximally fill lines to 80 chars instead of using
relatively short line lengths and multiple line statements.


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread Joe Perches
On Thu, 2016-03-03 at 10:29 +0800, jeffrey.lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium 
> touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

trivial comments:

> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
> b/drivers/input/touchscreen/raydium_i2c_ts.c
[]
> +static int raydium_i2c_send(struct i2c_client *client,
> + u8 addr, u8 *data, size_t len)
> +{
> + u8 buf[MAX_PACKET_SIZE + 1];
> + int i, tries = 0;
> +
> + if (len > MAX_PACKET_SIZE)
> + return -EINVAL;
> +
> + buf[0] = addr & 0xff;

Seems pointless to use & 0xff when both
buf and addr are u8

> + for (i = 0; i < len; i++)
> + buf[i + 1] = *data++;

memcpy.  Maybe:

buf[0] = addr;
memcpy([1], data, len);

> +static int raydium_i2c_send_message(struct i2c_client *client,
> + size_t len, void *data)
> +{
> + int error;
> + u8 buf[HEADER_SIZE], ii;
> +
> + for (ii = 0; ii < HEADER_SIZE; ii++)
> + buf[ii] = ((u8 *)data)[3 - ii];
> + /*set data bank*/
> + error = raydium_i2c_send(client, CMD_BANK_SWITCH,
> + (u8 *)buf, HEADER_SIZE);
> +
> + /*send messange*/

typo, message

> + if (!error)
> + error = raydium_i2c_send(client, buf[ADDR_INDEX], buf, len);
> +
> + return error;
> +}
> +
> +static int raydium_i2c_sw_reset(struct i2c_client *client)
> +{
> + const u8 soft_rst_cmd[] = { 0x01, 0x04, 0x00, 0x00, 0x40};

static

> + int error;
> +
> + error = raydium_i2c_send_message(client,
> + 1, (void *)soft_rst_cmd);

could be better on a single line

> +static int raydium_i2c_fastboot(struct i2c_client *client)
> +{
> + const u8 boot_cmd[] = { 0x20, 0x06, 0x00, 0x50 };
> + u8 buf[HEADER_SIZE];
> + int error;
> +
> + error = raydium_i2c_read_message(client,
> + get_unaligned_be32(boot_cmd),
> + sizeof(boot_cmd),
> + buf);
> +
> + if (error) {
> + dev_err(>dev, "boot failed: %d\n", error);
> + return error;
> + } else if (buf[0] == RM_BOOT_BLDR) {

unnecessary else

> + dev_dbg(>dev, "boot in fastboot mode\n");
> + return -EINVAL;
> + }
> +
> + dev_dbg(>dev, "boot success -- 0x%x\n", client->addr);
> + return 0;
> +}
> +
> +static int raydium_i2c_initialize(struct raydium_data *ts)
> +{
> + struct i2c_client *client = ts->client;
> + int error, retry_cnt;
> + const u8 recov_packet[] = { 0x04, 0x81 };

static and etc...

generally, it'd be nice to align to open parenthesis and
to more maximally fill lines to 80 chars instead of using
relatively short line lengths and multiple line statements.


[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread jeffrey.lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 977 +
 3 files changed, 990 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..fa65c26
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,977 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-03-02 Thread jeffrey.lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 977 +
 3 files changed, 990 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..fa65c26
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,977 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   struct regulator *vccio;
+  

RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver file

2016-02-26 Thread 林義章
Julia:
Thanks for your response. I'll fix them in next version.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Julia Lawall [mailto:julia.law...@lip6.fr] 
Sent: Friday, February 26, 2016 4:53 PM
To: jeffrey.lin
Cc: kbuild-...@01.org; dmitry.torok...@gmail.com; rydb...@euromail.se; 
grant.lik...@linaro.org; robh...@kernel.org; je...@melfas.com; 
ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); Roger Yang (楊鎮瑋); 
KP Li (李昆倍); linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver 
file

Please adjust the indentation.

julia

On Fri, 26 Feb 2016, kbuild test robot wrote:

> Hi jeffrey.lin,
>
> [auto build test WARNING on input/next] [also build test WARNING on 
> v4.5-rc5 next-20160226] [if your patch is applied to the wrong git 
> tree, please drop us a note to help improving the system]
>
> url:
> https://github.com/0day-ci/linux/commits/jeffrey-lin/driver-input-touchscreen-add-Raydium-I2C-touch-driver-file/20160226-152542
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
> :: branch date: 64 minutes ago
> :: commit date: 64 minutes ago
>
> >> drivers/input/touchscreen/raydium_i2c_ts.c:536:3-12: code aligned 
> >> with following code on line 538
>
> git remote add linux-review https://github.com/0day-ci/linux git 
> remote update linux-review git checkout 
> 18ddd28567d08b114b576e801475d6d7209f76f5
> vim +536 drivers/input/touchscreen/raydium_i2c_ts.c
>
> 18ddd285 jeffrey.lin 2016-02-26  530
> 18ddd285 jeffrey.lin 2016-02-26  531  
> input_mt_slot(ts->input, i);
> 18ddd285 jeffrey.lin 2016-02-26  532  
> input_mt_report_slot_state(ts->input,
> 18ddd285 jeffrey.lin 2016-02-26  533  
> MT_TOOL_FINGER, f_state != 0);
> 18ddd285 jeffrey.lin 2016-02-26  534
> 18ddd285 jeffrey.lin 2016-02-26  535  if (!f_state)
> 18ddd285 jeffrey.lin 2016-02-26 @536  continue;
> 18ddd285 jeffrey.lin 2016-02-26  537
> 18ddd285 jeffrey.lin 2016-02-26 @538  x = 
> (data->x_pos_msb << 8) | (data->x_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  539  y = 
> (data->y_pos_msb << 8) | (data->y_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  540
> 18ddd285 jeffrey.lin 2016-02-26  541  
> input_report_key(ts->input,
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>


RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver file

2016-02-26 Thread 林義章
Julia:
Thanks for your response. I'll fix them in next version.

Best Regards
--
Jeffrey Lin,林義章
瑞鼎科技
Raydium Semiconductor Corporation
Tel:(03)666-1818 Ext.4163
Fax:(03)666-1919

-Original Message-
From: Julia Lawall [mailto:julia.law...@lip6.fr] 
Sent: Friday, February 26, 2016 4:53 PM
To: jeffrey.lin
Cc: kbuild-...@01.org; dmitry.torok...@gmail.com; rydb...@euromail.se; 
grant.lik...@linaro.org; robh...@kernel.org; je...@melfas.com; 
ble...@chromium.org; scott@emc.com.tw; Jeffrey Lin (林義章); Roger Yang (楊鎮瑋); 
KP Li (李昆倍); linux-kernel@vger.kernel.org; linux-in...@vger.kernel.org; 
devicet...@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver 
file

Please adjust the indentation.

julia

On Fri, 26 Feb 2016, kbuild test robot wrote:

> Hi jeffrey.lin,
>
> [auto build test WARNING on input/next] [also build test WARNING on 
> v4.5-rc5 next-20160226] [if your patch is applied to the wrong git 
> tree, please drop us a note to help improving the system]
>
> url:
> https://github.com/0day-ci/linux/commits/jeffrey-lin/driver-input-touchscreen-add-Raydium-I2C-touch-driver-file/20160226-152542
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
> :: branch date: 64 minutes ago
> :: commit date: 64 minutes ago
>
> >> drivers/input/touchscreen/raydium_i2c_ts.c:536:3-12: code aligned 
> >> with following code on line 538
>
> git remote add linux-review https://github.com/0day-ci/linux git 
> remote update linux-review git checkout 
> 18ddd28567d08b114b576e801475d6d7209f76f5
> vim +536 drivers/input/touchscreen/raydium_i2c_ts.c
>
> 18ddd285 jeffrey.lin 2016-02-26  530
> 18ddd285 jeffrey.lin 2016-02-26  531  
> input_mt_slot(ts->input, i);
> 18ddd285 jeffrey.lin 2016-02-26  532  
> input_mt_report_slot_state(ts->input,
> 18ddd285 jeffrey.lin 2016-02-26  533  
> MT_TOOL_FINGER, f_state != 0);
> 18ddd285 jeffrey.lin 2016-02-26  534
> 18ddd285 jeffrey.lin 2016-02-26  535  if (!f_state)
> 18ddd285 jeffrey.lin 2016-02-26 @536  continue;
> 18ddd285 jeffrey.lin 2016-02-26  537
> 18ddd285 jeffrey.lin 2016-02-26 @538  x = 
> (data->x_pos_msb << 8) | (data->x_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  539  y = 
> (data->y_pos_msb << 8) | (data->y_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  540
> 18ddd285 jeffrey.lin 2016-02-26  541  
> input_report_key(ts->input,
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver file

2016-02-26 Thread Julia Lawall
Please adjust the indentation.

julia

On Fri, 26 Feb 2016, kbuild test robot wrote:

> Hi jeffrey.lin,
>
> [auto build test WARNING on input/next]
> [also build test WARNING on v4.5-rc5 next-20160226]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
>
> url:
> https://github.com/0day-ci/linux/commits/jeffrey-lin/driver-input-touchscreen-add-Raydium-I2C-touch-driver-file/20160226-152542
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
> :: branch date: 64 minutes ago
> :: commit date: 64 minutes ago
>
> >> drivers/input/touchscreen/raydium_i2c_ts.c:536:3-12: code aligned with 
> >> following code on line 538
>
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 18ddd28567d08b114b576e801475d6d7209f76f5
> vim +536 drivers/input/touchscreen/raydium_i2c_ts.c
>
> 18ddd285 jeffrey.lin 2016-02-26  530
> 18ddd285 jeffrey.lin 2016-02-26  531  
> input_mt_slot(ts->input, i);
> 18ddd285 jeffrey.lin 2016-02-26  532  
> input_mt_report_slot_state(ts->input,
> 18ddd285 jeffrey.lin 2016-02-26  533  
> MT_TOOL_FINGER, f_state != 0);
> 18ddd285 jeffrey.lin 2016-02-26  534
> 18ddd285 jeffrey.lin 2016-02-26  535  if (!f_state)
> 18ddd285 jeffrey.lin 2016-02-26 @536  continue;
> 18ddd285 jeffrey.lin 2016-02-26  537
> 18ddd285 jeffrey.lin 2016-02-26 @538  x = 
> (data->x_pos_msb << 8) | (data->x_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  539  y = 
> (data->y_pos_msb << 8) | (data->y_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  540
> 18ddd285 jeffrey.lin 2016-02-26  541  
> input_report_key(ts->input,
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>


Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver file

2016-02-26 Thread Julia Lawall
Please adjust the indentation.

julia

On Fri, 26 Feb 2016, kbuild test robot wrote:

> Hi jeffrey.lin,
>
> [auto build test WARNING on input/next]
> [also build test WARNING on v4.5-rc5 next-20160226]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
>
> url:
> https://github.com/0day-ci/linux/commits/jeffrey-lin/driver-input-touchscreen-add-Raydium-I2C-touch-driver-file/20160226-152542
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
> :: branch date: 64 minutes ago
> :: commit date: 64 minutes ago
>
> >> drivers/input/touchscreen/raydium_i2c_ts.c:536:3-12: code aligned with 
> >> following code on line 538
>
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 18ddd28567d08b114b576e801475d6d7209f76f5
> vim +536 drivers/input/touchscreen/raydium_i2c_ts.c
>
> 18ddd285 jeffrey.lin 2016-02-26  530
> 18ddd285 jeffrey.lin 2016-02-26  531  
> input_mt_slot(ts->input, i);
> 18ddd285 jeffrey.lin 2016-02-26  532  
> input_mt_report_slot_state(ts->input,
> 18ddd285 jeffrey.lin 2016-02-26  533  
> MT_TOOL_FINGER, f_state != 0);
> 18ddd285 jeffrey.lin 2016-02-26  534
> 18ddd285 jeffrey.lin 2016-02-26  535  if (!f_state)
> 18ddd285 jeffrey.lin 2016-02-26 @536  continue;
> 18ddd285 jeffrey.lin 2016-02-26  537
> 18ddd285 jeffrey.lin 2016-02-26 @538  x = 
> (data->x_pos_msb << 8) | (data->x_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  539  y = 
> (data->y_pos_msb << 8) | (data->y_pos_lsb);
> 18ddd285 jeffrey.lin 2016-02-26  540
> 18ddd285 jeffrey.lin 2016-02-26  541  
> input_report_key(ts->input,
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>


[PATCH] driver: input :touchscreen : add Raydium I2C touch driver file

2016-02-25 Thread jeffrey.lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define

"CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 980 +
 3 files changed, 993 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..139f28a
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,980 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver file

2016-02-25 Thread jeffrey.lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define

"CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 980 +
 3 files changed, 993 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..139f28a
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,980 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE60
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   struct regulator *vccio;
+ 

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-02-23 Thread jeffrey.lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 973 +
 3 files changed, 986 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..738b2fd
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,973 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE128
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-02-23 Thread jeffrey.lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/raydium_i2c_ts.c | 973 +
 3 files changed, 986 insertions(+)
 create mode 100644 drivers/input/touchscreen/raydium_i2c_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3f3f6ee..ab28721 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -915,6 +915,18 @@ config TOUCHSCREEN_PCAP
  To compile this driver as a module, choose M here: the
  module will be called pcap_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called raydium_i2c_ts.
+
 config TOUCHSCREEN_ST1232
tristate "Sitronix ST1232 touchscreen controllers"
depends on I2C
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 4941f2d..99e08cf 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)   += 
usbtouchscreen.o
 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
 obj-$(CONFIG_TOUCHSCREEN_PIXCIR)   += pixcir_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= raydium_i2c_ts.o
 obj-$(CONFIG_TOUCHSCREEN_S3C2410)  += s3c2410_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ST1232)   += st1232.o
 obj-$(CONFIG_TOUCHSCREEN_STMPE)+= stmpe-ts.o
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c 
b/drivers/input/touchscreen/raydium_i2c_ts.c
new file mode 100644
index 000..738b2fd
--- /dev/null
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -0,0 +1,973 @@
+/*
+ * Raydium touchscreen I2C driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device, Driver information */
+#define DEVICE_NAME"raydium_i2c"
+
+/* Slave I2C mode*/
+#define RM_BOOT_BLDR   0x02
+#define RM_BOOT_MAIN   0x03
+
+/*I2C command */
+#define CMD_QUERY_BANK 0x2B
+#define CMD_DATA_BANK  0x4D
+#define CMD_ENTER_SLEEP0x4E
+#define CMD_BOOT_ACK   0x0A
+#define CMD_BOOT_WRT   0x5B
+#define CMD_BOOT_CHK   0x0C
+#define CMD_BANK_SWITCH0xAA
+
+/* Touch relative info */
+#define MAX_RETRIES3
+#define MAX_FW_UPDATE_RETRIES  30
+#define MAX_TOUCH_NUM  10
+#define MAX_PACKET_SIZE128
+#define BOOT_DELAY_MS  100
+
+#define RAYDIUM_FW_PAGESIZE128
+#define RAYDIUM_POWERON_DELAY_USEC 500
+#define RAYDIUM_RESET_DELAY_MSEC   50
+
+#define ADDR_INDEX 0x03
+#define HEADER_SIZE4
+
+enum raydium_boot_mode {
+   RAYDIUM_TS_MAIN,
+   RAYDIUM_TS_BLDR,
+};
+
+struct raydium_info {
+   u32 hw_ver;
+   u8 main_ver;
+   u8 sub_ver;
+   u16 ft_ver;
+   u8 x_num;
+   u8 y_num;
+   u16 x_max;
+   u16 y_max;
+   u8 x_res;   /* units/mm */
+   u8 y_res;   /* units/mm */
+};
+
+struct raydium_abs_info {
+   u8 state;/*1:touch, 0:no touch*/
+   u8 x_pos_lsb;
+   u8 x_pos_msb;
+   u8 y_pos_lsb;
+   u8 y_pos_msb;
+   u8 pressure;
+   u8 x_width;
+   u8 y_width;
+};
+
+struct raydium_object {
+   u32 data_bank_addr;
+   u8 pkg_size;
+};
+
+/* struct raydium_data - represents state of Raydium touchscreen device */
+struct raydium_data {
+   struct i2c_client *client;
+   struct input_dev *input;
+
+   struct regulator *vcc33;
+   struct regulator *vccio;
+ 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-01-21 Thread Dmitry Torokhov
Hi Jeffrey,

On Thu, Jan 21, 2016 at 12:02:58PM +0800, Jeffrey Lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium 
> touch driver by modifying define
> "CONFIG_TOUCHSCREEN_RM_TS".

Thank you for making changes, please see my comments below.

> 
> Signed-off-by: jeffrey.lin 
> ---
>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/rm31100_ts.c | 747 
> +
>  3 files changed, 760 insertions(+)
>  create mode 100644 drivers/input/touchscreen/rm31100_ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index c0659eb..ea7e259 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -974,4 +974,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
>  
> +config TOUCHSCREEN_RM_TS
> + tristate "Raydium I2C Touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have Raydium series I2C touchscreen,
> +   such as RM31100 , connected to your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called rm31100_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 944e5b3..1a11974 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -80,3 +80,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)   += 
> zylonite-wm97xx.o
>  obj-$(CONFIG_TOUCHSCREEN_W90X900)+= w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_RM_TS)  += rm31100_ts.o


Please add new entries to makefile in alphabetical order.

> diff --git a/drivers/input/touchscreen/rm31100_ts.c 
> b/drivers/input/touchscreen/rm31100_ts.c
> new file mode 100644
> index 000..b1b8087
> --- /dev/null
> +++ b/drivers/input/touchscreen/rm31100_ts.c
> @@ -0,0 +1,747 @@
> +/*
> + * Raydium RM31100_ts touchscreen driver.
> + *
> + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, and only version 2, as published by the
> + * Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Raydium reserves the right to make changes without further notice
> + * to the materials described herein. Raydium does not assume any
> + * liability arising out of the application described herein.
> + *
> + * Contact Raydium Semiconductor Corporation at www.rad-ic.com
> + *
> + */
> +#include 

You are not using this anymore.

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define rm31100  0x0
> +#define rm3110x  0x1
> +
> +#define INVALID_DATA 0xff
> +#define MAX_REPORT_TOUCHED_POINTS10
> +
> +#define I2C_CLIENT_ADDR 0x39
> +#define I2C_DMA_CLIENT_ADDR 0x5A
> +
> +struct rm31100_ts_data {
> + u8 x_index;
> + u8 y_index;
> + u8 z_index;
> + u8 id_index;
> + u8 touch_index;
> + u8 data_reg;
> + u8 status_reg;
> + u8 data_size;
> + u8 touch_bytes;
> + u8 update_data;
> + u8 touch_meta_data;
> + u8 finger_size;
> +};
> +
> +struct rm3110x_ts_platform_data {
> + u32 dis_min_x; /* display resoltion ABS min*/
> + u32 dis_max_x;/* display resoltion ABS max*/
> + u32 dis_min_y;
> + u32 dis_max_y;
> + u32 res_x; /* TS resolution unit*/
> + u32 res_y;
> + u32 swap_xy;
> + u8 nfingers;

I believe I already asked, why do we have number of fingers in platform
data?

> + bool wakeup;
> +};
> +
> +static struct rm31100_ts_data devices[] = {
> + [0] = {
> + .x_index = 2,
> + .y_index = 4,
> + .z_index = 6,
> + .id_index = 1,
> + .data_reg = 0x1,
> + .status_reg = 0,
> + .update_data = 0x0,
> + .touch_bytes = 6,
> + .touch_meta_data = 1,
> + .finger_size = 70,
> + },
> + [1] = {
> + .x_index = 2,
> + .y_index = 4,
> + .z_index = 6,
> + .id_index = 1,
> + .data_reg = 0x0,
> + .status_reg = 0,
> + .update_data = 0x0,
> + .touch_bytes = 6,
> + .touch_meta_data = 1,
> + .finger_size 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-01-21 Thread Dmitry Torokhov
Hi Jeffrey,

On Thu, Jan 21, 2016 at 12:02:58PM +0800, Jeffrey Lin wrote:
> This patch is porting Raydium I2C touch driver. Developer can enable raydium 
> touch driver by modifying define
> "CONFIG_TOUCHSCREEN_RM_TS".

Thank you for making changes, please see my comments below.

> 
> Signed-off-by: jeffrey.lin 
> ---
>  drivers/input/touchscreen/Kconfig  |  12 +
>  drivers/input/touchscreen/Makefile |   1 +
>  drivers/input/touchscreen/rm31100_ts.c | 747 
> +
>  3 files changed, 760 insertions(+)
>  create mode 100644 drivers/input/touchscreen/rm31100_ts.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index c0659eb..ea7e259 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -974,4 +974,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
>  
> +config TOUCHSCREEN_RM_TS
> + tristate "Raydium I2C Touchscreen"
> + depends on I2C
> + help
> +   Say Y here if you have Raydium series I2C touchscreen,
> +   such as RM31100 , connected to your system.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called rm31100_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 944e5b3..1a11974 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -80,3 +80,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)   += 
> zylonite-wm97xx.o
>  obj-$(CONFIG_TOUCHSCREEN_W90X900)+= w90p910_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_TPS6507X)   += tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
> +obj-$(CONFIG_TOUCHSCREEN_RM_TS)  += rm31100_ts.o


Please add new entries to makefile in alphabetical order.

> diff --git a/drivers/input/touchscreen/rm31100_ts.c 
> b/drivers/input/touchscreen/rm31100_ts.c
> new file mode 100644
> index 000..b1b8087
> --- /dev/null
> +++ b/drivers/input/touchscreen/rm31100_ts.c
> @@ -0,0 +1,747 @@
> +/*
> + * Raydium RM31100_ts touchscreen driver.
> + *
> + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, and only version 2, as published by the
> + * Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Raydium reserves the right to make changes without further notice
> + * to the materials described herein. Raydium does not assume any
> + * liability arising out of the application described herein.
> + *
> + * Contact Raydium Semiconductor Corporation at www.rad-ic.com
> + *
> + */
> +#include 

You are not using this anymore.

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define rm31100  0x0
> +#define rm3110x  0x1
> +
> +#define INVALID_DATA 0xff
> +#define MAX_REPORT_TOUCHED_POINTS10
> +
> +#define I2C_CLIENT_ADDR 0x39
> +#define I2C_DMA_CLIENT_ADDR 0x5A
> +
> +struct rm31100_ts_data {
> + u8 x_index;
> + u8 y_index;
> + u8 z_index;
> + u8 id_index;
> + u8 touch_index;
> + u8 data_reg;
> + u8 status_reg;
> + u8 data_size;
> + u8 touch_bytes;
> + u8 update_data;
> + u8 touch_meta_data;
> + u8 finger_size;
> +};
> +
> +struct rm3110x_ts_platform_data {
> + u32 dis_min_x; /* display resoltion ABS min*/
> + u32 dis_max_x;/* display resoltion ABS max*/
> + u32 dis_min_y;
> + u32 dis_max_y;
> + u32 res_x; /* TS resolution unit*/
> + u32 res_y;
> + u32 swap_xy;
> + u8 nfingers;

I believe I already asked, why do we have number of fingers in platform
data?

> + bool wakeup;
> +};
> +
> +static struct rm31100_ts_data devices[] = {
> + [0] = {
> + .x_index = 2,
> + .y_index = 4,
> + .z_index = 6,
> + .id_index = 1,
> + .data_reg = 0x1,
> + .status_reg = 0,
> + .update_data = 0x0,
> + .touch_bytes = 6,
> + .touch_meta_data = 1,
> + .finger_size = 70,
> + },
> + [1] = {
> + .x_index = 2,
> + .y_index = 4,
> + .z_index = 6,
> + .id_index = 1,
> + .data_reg = 0x0,
> + .status_reg = 0,
> + .update_data = 0x0,
> + .touch_bytes = 6,
> + .touch_meta_data = 1,
> +   

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-01-20 Thread Jeffrey Lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define
"CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/rm31100_ts.c | 747 +
 3 files changed, 760 insertions(+)
 create mode 100644 drivers/input/touchscreen/rm31100_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index c0659eb..ea7e259 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -974,4 +974,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 944e5b3..1a11974 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -80,3 +80,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
diff --git a/drivers/input/touchscreen/rm31100_ts.c 
b/drivers/input/touchscreen/rm31100_ts.c
new file mode 100644
index 000..b1b8087
--- /dev/null
+++ b/drivers/input/touchscreen/rm31100_ts.c
@@ -0,0 +1,747 @@
+/*
+ * Raydium RM31100_ts touchscreen driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define rm311000x0
+#define rm3110x0x1
+
+#define INVALID_DATA   0xff
+#define MAX_REPORT_TOUCHED_POINTS  10
+
+#define I2C_CLIENT_ADDR 0x39
+#define I2C_DMA_CLIENT_ADDR 0x5A
+
+struct rm31100_ts_data {
+   u8 x_index;
+   u8 y_index;
+   u8 z_index;
+   u8 id_index;
+   u8 touch_index;
+   u8 data_reg;
+   u8 status_reg;
+   u8 data_size;
+   u8 touch_bytes;
+   u8 update_data;
+   u8 touch_meta_data;
+   u8 finger_size;
+};
+
+struct rm3110x_ts_platform_data {
+   u32 dis_min_x; /* display resoltion ABS min*/
+   u32 dis_max_x;/* display resoltion ABS max*/
+   u32 dis_min_y;
+   u32 dis_max_y;
+   u32 res_x; /* TS resolution unit*/
+   u32 res_y;
+   u32 swap_xy;
+   u8 nfingers;
+   bool wakeup;
+};
+
+static struct rm31100_ts_data devices[] = {
+   [0] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x1,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   .finger_size = 70,
+   },
+   [1] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x0,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   .finger_size = 70,
+   },
+};
+
+struct rm31100_ts {
+   struct i2c_client *client;
+   struct input_dev *input;
+   struct regulator *dvdd;
+   struct regulator *avdd;
+   struct gpio_desc *resout_gpio;
+   struct rm3110x_ts_platform_data *pdata;
+   struct rm31100_ts_data *dd;
+   u8 *touch_data;
+   u8 device_id;
+   bool is_suspended;
+   struct mutex access_lock;
+   u32 pen_irq;
+   u8 fw_version;
+   u8 u8_sub_version;
+};
+

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2016-01-20 Thread Jeffrey Lin
This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define
"CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey.lin 
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/rm31100_ts.c | 747 +
 3 files changed, 760 insertions(+)
 create mode 100644 drivers/input/touchscreen/rm31100_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index c0659eb..ea7e259 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -974,4 +974,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 944e5b3..1a11974 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -80,3 +80,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
diff --git a/drivers/input/touchscreen/rm31100_ts.c 
b/drivers/input/touchscreen/rm31100_ts.c
new file mode 100644
index 000..b1b8087
--- /dev/null
+++ b/drivers/input/touchscreen/rm31100_ts.c
@@ -0,0 +1,747 @@
+/*
+ * Raydium RM31100_ts touchscreen driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define rm311000x0
+#define rm3110x0x1
+
+#define INVALID_DATA   0xff
+#define MAX_REPORT_TOUCHED_POINTS  10
+
+#define I2C_CLIENT_ADDR 0x39
+#define I2C_DMA_CLIENT_ADDR 0x5A
+
+struct rm31100_ts_data {
+   u8 x_index;
+   u8 y_index;
+   u8 z_index;
+   u8 id_index;
+   u8 touch_index;
+   u8 data_reg;
+   u8 status_reg;
+   u8 data_size;
+   u8 touch_bytes;
+   u8 update_data;
+   u8 touch_meta_data;
+   u8 finger_size;
+};
+
+struct rm3110x_ts_platform_data {
+   u32 dis_min_x; /* display resoltion ABS min*/
+   u32 dis_max_x;/* display resoltion ABS max*/
+   u32 dis_min_y;
+   u32 dis_max_y;
+   u32 res_x; /* TS resolution unit*/
+   u32 res_y;
+   u32 swap_xy;
+   u8 nfingers;
+   bool wakeup;
+};
+
+static struct rm31100_ts_data devices[] = {
+   [0] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x1,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   .finger_size = 70,
+   },
+   [1] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x0,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   .finger_size = 70,
+   },
+};
+
+struct rm31100_ts {
+   struct i2c_client *client;
+   struct input_dev *input;
+   struct regulator *dvdd;
+   struct regulator *avdd;
+   struct gpio_desc *resout_gpio;
+   struct rm3110x_ts_platform_data *pdata;
+   struct rm31100_ts_data *dd;
+   u8 *touch_data;
+   u8 device_id;
+   bool is_suspended;
+   struct mutex access_lock;
+   u32 pen_irq;
+   u8 fw_version;
+   u8 

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2015-01-06 Thread Dmitry Torokhov
On Tue, Jan 06, 2015 at 11:43:54AM -0800, Jeremiah Mahler wrote:
> On Tue, Jan 06, 2015 at 05:25:50PM +0800, jeffrey.lin wrote:
> > From: "jeffrey.lin" 
> > 
> > This patch is porting Raydium I2C touch driver. Developer can enable
> >  raydium touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".
> > 
> > Signed-off-by: jeffrey@rad-ic.com
> 
> You need your full legal name in your Signed-off-by:

Also, there was feedback provided earlier and I still see it not being
addresses (the presence of custom char dev interface for example). It
would also be helpful if refreshed mentioned what was change from the
previos version.

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] driver: input :touchscreen : add Raydium I2C touch driver

2015-01-06 Thread Jeremiah Mahler
On Tue, Jan 06, 2015 at 05:25:50PM +0800, jeffrey.lin wrote:
> From: "jeffrey.lin" 
> 
> This patch is porting Raydium I2C touch driver. Developer can enable
>  raydium touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".
> 
> Signed-off-by: jeffrey@rad-ic.com

You need your full legal name in your Signed-off-by:

-- 
- Jeremiah Mahler
--
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] driver: input :touchscreen : add Raydium I2C touch driver

2015-01-06 Thread jeffrey.lin
From: "jeffrey.lin" 

This patch is porting Raydium I2C touch driver. Developer can enable
 raydium touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/rm31100_ts.c | 846 +
 3 files changed, 859 insertions(+)
 create mode 100644 drivers/input/touchscreen/rm31100_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
diff --git a/drivers/input/touchscreen/rm31100_ts.c 
b/drivers/input/touchscreen/rm31100_ts.c
new file mode 100644
index 000..997dc0c
--- /dev/null
+++ b/drivers/input/touchscreen/rm31100_ts.c
@@ -0,0 +1,846 @@
+/*
+ * Raydium RM31100_ts touchscreen driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ *
+ * History:
+ * (C) 2012 Raydium - Update for GPL distribution
+ * (C) 2009 Enea - Original prototype
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifdef CONFIG_MISC_DEV
+#include 
+#endif
+#include 
+#include 
+#include 
+
+#define rm311000x0
+#define rm3110x0x1
+
+#define INVALID_DATA   0xff
+#define MAX_REPORT_TOUCHED_POINTS  10
+
+#define I2C_CLIENT_ADDR 0x39
+#define I2C_DMA_CLIENT_ADDR 0x5A
+
+struct rm31100_ts_data {
+   u8 x_index;
+   u8 y_index;
+   u8 z_index;
+   u8 id_index;
+   u8 touch_index;
+   u8 data_reg;
+   u8 status_reg;
+   u8 data_size;
+   u8 touch_bytes;
+   u8 update_data;
+   u8 touch_meta_data;
+   u8 finger_size;
+};
+
+struct rm3110x_ts_platform_data {
+   int (*power_on)(int on);
+   int (*dev_setup)(bool on);
+   const char *ts_name;
+   u32 dis_min_x; /* display resoltion ABS min*/
+   u32 dis_max_x;/* display resoltion ABS max*/
+   u32 dis_min_y;
+   u32 dis_max_y;
+   u32 min_touch; /* no.of touches supported */
+   u32 max_touch;
+   u32 min_tid; /* track id */
+   u32 max_tid;
+   u32 min_width;/* size of the finger */
+   u32 max_width;
+   u32 res_x; /* TS resolution unit*/
+   u32 res_y;
+   u32 swap_xy;
+   u8 nfingers;
+   u32 irq_gpio;
+   int resout_gpio;
+   bool wakeup;
+   u32 irq_cfg;
+};
+
+static struct rm31100_ts_data devices[] = {
+   [0] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x1,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   .finger_size = 70,
+   },
+};
+
+struct rm31100_ts {
+   struct i2c_client *client;
+   struct input_dev *input;
+   struct rm3110x_ts_platform_data *pdata;
+   struct rm31100_ts_data *dd;
+   u8 *touch_data;
+   u8 device_id;
+  

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2015-01-06 Thread jeffrey.lin
From: jeffrey.lin jeffrey@rad-ic.com

This patch is porting Raydium I2C touch driver. Developer can enable
 raydium touch driver by modifying define CONFIG_TOUCHSCREEN_RM_TS.

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/rm31100_ts.c | 846 +
 3 files changed, 859 insertions(+)
 create mode 100644 drivers/input/touchscreen/rm31100_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate Raydium I2C Touchscreen
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
diff --git a/drivers/input/touchscreen/rm31100_ts.c 
b/drivers/input/touchscreen/rm31100_ts.c
new file mode 100644
index 000..997dc0c
--- /dev/null
+++ b/drivers/input/touchscreen/rm31100_ts.c
@@ -0,0 +1,846 @@
+/*
+ * Raydium RM31100_ts touchscreen driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ *
+ * History:
+ * (C) 2012 Raydium - Update for GPL distribution
+ * (C) 2009 Enea - Original prototype
+ *
+ */
+#include linux/async.h
+#include linux/init.h
+#include linux/module.h
+#include linux/i2c.h
+#include linux/input.h
+#include linux/slab.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/gpio.h
+#include linux/mutex.h
+#include linux/delay.h
+#include linux/pm.h
+#include linux/pm_runtime.h
+#ifdef CONFIG_MISC_DEV
+#include linux/miscdevice.h
+#endif
+#include linux/uaccess.h
+#include asm/unaligned.h
+#include linux/input/mt.h
+
+#define rm311000x0
+#define rm3110x0x1
+
+#define INVALID_DATA   0xff
+#define MAX_REPORT_TOUCHED_POINTS  10
+
+#define I2C_CLIENT_ADDR 0x39
+#define I2C_DMA_CLIENT_ADDR 0x5A
+
+struct rm31100_ts_data {
+   u8 x_index;
+   u8 y_index;
+   u8 z_index;
+   u8 id_index;
+   u8 touch_index;
+   u8 data_reg;
+   u8 status_reg;
+   u8 data_size;
+   u8 touch_bytes;
+   u8 update_data;
+   u8 touch_meta_data;
+   u8 finger_size;
+};
+
+struct rm3110x_ts_platform_data {
+   int (*power_on)(int on);
+   int (*dev_setup)(bool on);
+   const char *ts_name;
+   u32 dis_min_x; /* display resoltion ABS min*/
+   u32 dis_max_x;/* display resoltion ABS max*/
+   u32 dis_min_y;
+   u32 dis_max_y;
+   u32 min_touch; /* no.of touches supported */
+   u32 max_touch;
+   u32 min_tid; /* track id */
+   u32 max_tid;
+   u32 min_width;/* size of the finger */
+   u32 max_width;
+   u32 res_x; /* TS resolution unit*/
+   u32 res_y;
+   u32 swap_xy;
+   u8 nfingers;
+   u32 irq_gpio;
+   int resout_gpio;
+   bool wakeup;
+   u32 irq_cfg;
+};
+
+static struct rm31100_ts_data devices[] = {
+   [0] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x1,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2015-01-06 Thread Jeremiah Mahler
On Tue, Jan 06, 2015 at 05:25:50PM +0800, jeffrey.lin wrote:
 From: jeffrey.lin jeffrey@rad-ic.com
 
 This patch is porting Raydium I2C touch driver. Developer can enable
  raydium touch driver by modifying define CONFIG_TOUCHSCREEN_RM_TS.
 
 Signed-off-by: jeffrey@rad-ic.com

You need your full legal name in your Signed-off-by:

-- 
- Jeremiah Mahler
--
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] driver: input :touchscreen : add Raydium I2C touch driver

2015-01-06 Thread Dmitry Torokhov
On Tue, Jan 06, 2015 at 11:43:54AM -0800, Jeremiah Mahler wrote:
 On Tue, Jan 06, 2015 at 05:25:50PM +0800, jeffrey.lin wrote:
  From: jeffrey.lin jeffrey@rad-ic.com
  
  This patch is porting Raydium I2C touch driver. Developer can enable
   raydium touch driver by modifying define CONFIG_TOUCHSCREEN_RM_TS.
  
  Signed-off-by: jeffrey@rad-ic.com
 
 You need your full legal name in your Signed-off-by:

Also, there was feedback provided earlier and I still see it not being
addresses (the presence of custom char dev interface for example). It
would also be helpful if refreshed mentioned what was change from the
previos version.

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] driver: input :touchscreen : add Raydium I2C touch driver

2014-12-07 Thread jeffrey.lin
From: "jeffrey.lin" 

This patch is porting Raydium I2C touch driver. Developer can enable
 raydium touch driver by modifying define "CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/rm31100_ts.c | 846 +
 3 files changed, 859 insertions(+)
 create mode 100644 drivers/input/touchscreen/rm31100_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
diff --git a/drivers/input/touchscreen/rm31100_ts.c 
b/drivers/input/touchscreen/rm31100_ts.c
new file mode 100644
index 000..997dc0c
--- /dev/null
+++ b/drivers/input/touchscreen/rm31100_ts.c
@@ -0,0 +1,846 @@
+/*
+ * Raydium RM31100_ts touchscreen driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ *
+ * History:
+ * (C) 2012 Raydium - Update for GPL distribution
+ * (C) 2009 Enea - Original prototype
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifdef CONFIG_MISC_DEV
+#include 
+#endif
+#include 
+#include 
+#include 
+
+#define rm311000x0
+#define rm3110x0x1
+
+#define INVALID_DATA   0xff
+#define MAX_REPORT_TOUCHED_POINTS  10
+
+#define I2C_CLIENT_ADDR 0x39
+#define I2C_DMA_CLIENT_ADDR 0x5A
+
+struct rm31100_ts_data {
+   u8 x_index;
+   u8 y_index;
+   u8 z_index;
+   u8 id_index;
+   u8 touch_index;
+   u8 data_reg;
+   u8 status_reg;
+   u8 data_size;
+   u8 touch_bytes;
+   u8 update_data;
+   u8 touch_meta_data;
+   u8 finger_size;
+};
+
+struct rm3110x_ts_platform_data {
+   int (*power_on)(int on);
+   int (*dev_setup)(bool on);
+   const char *ts_name;
+   u32 dis_min_x; /* display resoltion ABS min*/
+   u32 dis_max_x;/* display resoltion ABS max*/
+   u32 dis_min_y;
+   u32 dis_max_y;
+   u32 min_touch; /* no.of touches supported */
+   u32 max_touch;
+   u32 min_tid; /* track id */
+   u32 max_tid;
+   u32 min_width;/* size of the finger */
+   u32 max_width;
+   u32 res_x; /* TS resolution unit*/
+   u32 res_y;
+   u32 swap_xy;
+   u8 nfingers;
+   u32 irq_gpio;
+   int resout_gpio;
+   bool wakeup;
+   u32 irq_cfg;
+};
+
+static struct rm31100_ts_data devices[] = {
+   [0] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x1,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   .finger_size = 70,
+   },
+};
+
+struct rm31100_ts {
+   struct i2c_client *client;
+   struct input_dev *input;
+   struct rm3110x_ts_platform_data *pdata;
+   struct rm31100_ts_data *dd;
+   u8 *touch_data;
+   u8 device_id;
+  

[PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2014-12-07 Thread jeffrey.lin
From: jeffrey.lin jeffrey@rad-ic.com

This patch is porting Raydium I2C touch driver. Developer can enable
 raydium touch driver by modifying define CONFIG_TOUCHSCREEN_RM_TS.

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  |  12 +
 drivers/input/touchscreen/Makefile |   1 +
 drivers/input/touchscreen/rm31100_ts.c | 846 +
 3 files changed, 859 insertions(+)
 create mode 100644 drivers/input/touchscreen/rm31100_ts.c

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate Raydium I2C Touchscreen
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
diff --git a/drivers/input/touchscreen/rm31100_ts.c 
b/drivers/input/touchscreen/rm31100_ts.c
new file mode 100644
index 000..997dc0c
--- /dev/null
+++ b/drivers/input/touchscreen/rm31100_ts.c
@@ -0,0 +1,846 @@
+/*
+ * Raydium RM31100_ts touchscreen driver.
+ *
+ * Copyright (C) 2012-2014, Raydium Semiconductor Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Raydium reserves the right to make changes without further notice
+ * to the materials described herein. Raydium does not assume any
+ * liability arising out of the application described herein.
+ *
+ * Contact Raydium Semiconductor Corporation at www.rad-ic.com
+ *
+ * History:
+ * (C) 2012 Raydium - Update for GPL distribution
+ * (C) 2009 Enea - Original prototype
+ *
+ */
+#include linux/async.h
+#include linux/init.h
+#include linux/module.h
+#include linux/i2c.h
+#include linux/input.h
+#include linux/slab.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/gpio.h
+#include linux/mutex.h
+#include linux/delay.h
+#include linux/pm.h
+#include linux/pm_runtime.h
+#ifdef CONFIG_MISC_DEV
+#include linux/miscdevice.h
+#endif
+#include linux/uaccess.h
+#include asm/unaligned.h
+#include linux/input/mt.h
+
+#define rm311000x0
+#define rm3110x0x1
+
+#define INVALID_DATA   0xff
+#define MAX_REPORT_TOUCHED_POINTS  10
+
+#define I2C_CLIENT_ADDR 0x39
+#define I2C_DMA_CLIENT_ADDR 0x5A
+
+struct rm31100_ts_data {
+   u8 x_index;
+   u8 y_index;
+   u8 z_index;
+   u8 id_index;
+   u8 touch_index;
+   u8 data_reg;
+   u8 status_reg;
+   u8 data_size;
+   u8 touch_bytes;
+   u8 update_data;
+   u8 touch_meta_data;
+   u8 finger_size;
+};
+
+struct rm3110x_ts_platform_data {
+   int (*power_on)(int on);
+   int (*dev_setup)(bool on);
+   const char *ts_name;
+   u32 dis_min_x; /* display resoltion ABS min*/
+   u32 dis_max_x;/* display resoltion ABS max*/
+   u32 dis_min_y;
+   u32 dis_max_y;
+   u32 min_touch; /* no.of touches supported */
+   u32 max_touch;
+   u32 min_tid; /* track id */
+   u32 max_tid;
+   u32 min_width;/* size of the finger */
+   u32 max_width;
+   u32 res_x; /* TS resolution unit*/
+   u32 res_y;
+   u32 swap_xy;
+   u8 nfingers;
+   u32 irq_gpio;
+   int resout_gpio;
+   bool wakeup;
+   u32 irq_cfg;
+};
+
+static struct rm31100_ts_data devices[] = {
+   [0] = {
+   .x_index = 2,
+   .y_index = 4,
+   .z_index = 6,
+   .id_index = 1,
+   .data_reg = 0x1,
+   .status_reg = 0,
+   .update_data = 0x0,
+   .touch_bytes = 6,
+   .touch_meta_data = 1,
+   

Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver

2014-12-05 Thread Dmitry Torokhov
Hi Jeffrey,

On December 5, 2014 12:15:01 AM PST, "jeffrey.lin"  wrote:
>From: "jeffrey.lin" 
>
>This patch is porting Raydium I2C touch driver. Developer can enable
>raydium touch driver by modifying define
>"CONFIG_TOUCHSCREEN_RM_TS".
>
>Signed-off-by: jeffrey@rad-ic.com
>---
> drivers/input/touchscreen/Kconfig  | 12 
> drivers/input/touchscreen/Makefile |  1 +
> 2 files changed, 13 insertions(+)
>
>diff --git a/drivers/input/touchscreen/Kconfig
>b/drivers/input/touchscreen/Kconfig
>index 3ce9181..d0324d2 100644
>--- a/drivers/input/touchscreen/Kconfig
>+++ b/drivers/input/touchscreen/Kconfig
>@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
> To compile this driver as a module, choose M here: the
> module will be called zforce_ts.
> 
>+config TOUCHSCREEN_RM_TS
>+  tristate "Raydium I2C Touchscreen"
>+  depends on I2C
>+  help
>+Say Y here if you have Raydium series I2C touchscreen,
>+such as RM31100 , connected to your system.
>+
>+If unsure, say N.
>+
>+To compile this driver as a module, choose M here: the
>+module will be called rm31100_ts.
>+
> endif
>diff --git a/drivers/input/touchscreen/Makefile
>b/drivers/input/touchscreen/Makefile
>index 687d5a7..3220f66 100644
>--- a/drivers/input/touchscreen/Makefile
>+++ b/drivers/input/touchscreen/Makefile
>@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)+=
>zylonite-wm97xx.o
> obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o
> obj-$(CONFIG_TOUCHSCREEN_TPS6507X)+= tps6507x-ts.o
> obj-$(CONFIG_TOUCHSCREEN_ZFORCE)  += zforce_ts.o
>+obj-$(CONFIG_TOUCHSCREEN_RM_TS)   += rm31100_ts.o

The source to the driver itself is missing, you only sent make file and kconfig 
changes.


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] driver: input :touchscreen : add Raydium I2C touch driver

2014-12-05 Thread jeffrey.lin
From: "jeffrey.lin" 

This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define
"CONFIG_TOUCHSCREEN_RM_TS".

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  | 12 
 drivers/input/touchscreen/Makefile |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate "Raydium I2C Touchscreen"
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
-- 
2.1.2

--
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] driver: input :touchscreen : add Raydium I2C touch driver

2014-12-05 Thread jeffrey.lin
From: jeffrey.lin jeffrey@rad-ic.com

This patch is porting Raydium I2C touch driver. Developer can enable raydium 
touch driver by modifying define
CONFIG_TOUCHSCREEN_RM_TS.

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  | 12 
 drivers/input/touchscreen/Makefile |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/input/touchscreen/Kconfig 
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
  To compile this driver as a module, choose M here: the
  module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+   tristate Raydium I2C Touchscreen
+   depends on I2C
+   help
+ Say Y here if you have Raydium series I2C touchscreen,
+ such as RM31100 , connected to your system.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile 
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += 
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)  += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)   += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)+= rm31100_ts.o
-- 
2.1.2

--
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] driver: input :touchscreen : add Raydium I2C touch driver

2014-12-05 Thread Dmitry Torokhov
Hi Jeffrey,

On December 5, 2014 12:15:01 AM PST, jeffrey.lin yaj...@gmail.com wrote:
From: jeffrey.lin jeffrey@rad-ic.com

This patch is porting Raydium I2C touch driver. Developer can enable
raydium touch driver by modifying define
CONFIG_TOUCHSCREEN_RM_TS.

Signed-off-by: jeffrey@rad-ic.com
---
 drivers/input/touchscreen/Kconfig  | 12 
 drivers/input/touchscreen/Makefile |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/input/touchscreen/Kconfig
b/drivers/input/touchscreen/Kconfig
index 3ce9181..d0324d2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -955,4 +955,16 @@ config TOUCHSCREEN_ZFORCE
 To compile this driver as a module, choose M here: the
 module will be called zforce_ts.
 
+config TOUCHSCREEN_RM_TS
+  tristate Raydium I2C Touchscreen
+  depends on I2C
+  help
+Say Y here if you have Raydium series I2C touchscreen,
+such as RM31100 , connected to your system.
+
+If unsure, say N.
+
+To compile this driver as a module, choose M here: the
+module will be called rm31100_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile
b/drivers/input/touchscreen/Makefile
index 687d5a7..3220f66 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)+=
zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X)+= tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)  += zforce_ts.o
+obj-$(CONFIG_TOUCHSCREEN_RM_TS)   += rm31100_ts.o

The source to the driver itself is missing, you only sent make file and kconfig 
changes.


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/


  1   2   >