linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "simba.hsu" <simba.hsu@raydium.corp-partner.google.com>
Cc: simba.hsu@rad-ic.com, furquan@google.com, seanpaul@chromium.org,
	rrangle@chromium.org, evgreen@chromium.org,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	KP.li@rad-ic.com, jeffrey.lin@rad-ic.com
Subject: Re: [PATCH] driver:input:touchscreen: improve the mechanism of auto-update
Date: Tue, 1 Jun 2021 22:03:06 -0700	[thread overview]
Message-ID: <YLcRCl23ksfYTmN6@google.com> (raw)
In-Reply-To: <20210510083536.41925-1-simba.hsu@rad-ic.com>

Hi,

On Mon, May 10, 2021 at 04:35:36PM +0800, simba.hsu wrote:
> From: "simba.hsu" <simba.hsu@raydium.corp-partner.google.com>
> 
> Once auto-update has been interrupted, touch IC will be stuck in
> recovery mode forever and it will lead to touch malfunction.
> This patch makes auto-update available when touch IC is in
> recovery mode to avoid touch malfunction.
> 
> Signed-off-by: simba.hsu <simba.hsu@rad-ic.com>
> ---
>  drivers/input/touchscreen/raydium_i2c_ts.c | 53 ++++++++++++++++++----
>  1 file changed, 45 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
> index 4d2d22a86977..50f6fbbe4775 100644
> --- a/drivers/input/touchscreen/raydium_i2c_ts.c
> +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
> @@ -36,7 +36,8 @@
>  #define RM_CMD_BOOT_CHK		0x33		/* send data check */
>  #define RM_CMD_BOOT_READ	0x44		/* send wait bl data ready*/
>  
> -#define RM_BOOT_RDY		0xFF		/* bl data ready */
> +#define RM_BOOT_RDY		0xFF			/* bl data ready */
> +#define RM_BOOT_CMD_READHWID	0x0E	/* read hwid */
>  
>  /* I2C main commands */
>  #define RM_CMD_QUERY_BANK	0x2B
> @@ -155,6 +156,7 @@ static int raydium_i2c_xfer(struct i2c_client *client, u32 addr,
>  	 * sent first. Else, skip the header i.e. xfer[0].
>  	 */
>  	int xfer_start_idx = (addr > 0xff) ? 0 : 1;
> +
>  	xfer_count -= xfer_start_idx;
>  
>  	ret = i2c_transfer(client->adapter, &xfer[xfer_start_idx], xfer_count);
> @@ -289,6 +291,44 @@ static int raydium_i2c_sw_reset(struct i2c_client *client)
>  
>  	return 0;
>  }
> +static int raydium_i2c_query_ts_BL_info(struct raydium_data *ts)
> +{
> +	struct i2c_client *client = ts->client;
> +	static const u8 get_hwid[7] = {RM_BOOT_CMD_READHWID,
> +					 0x10, 0xc0, 0x01, 0x00, 0x04, 0x00};
> +	int error;
> +	u8 rbuf[5] = {0, 0, 0, 0, 0};
> +	u32 tmpdata = 0;
> +
> +	error = raydium_i2c_send(client,
> +				 RM_CMD_BOOT_WRT, get_hwid, sizeof(get_hwid));
> +	if (error) {
> +		dev_err(&client->dev, "WRT HWID command failed: %d\n", error);
> +		return error;
> +	}
> +
> +	error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, rbuf, 1);
> +	if (error) {
> +		dev_err(&client->dev, "Ack HWID command failed: %d\n", error);
> +		return error;
> +	}
> +
> +	error = raydium_i2c_read(client,
> +				 RM_CMD_BOOT_CHK, rbuf, sizeof(rbuf));
> +	if (!error) {
> +		tmpdata = (rbuf[1]<<24|rbuf[2]<<16|rbuf[3]<<8|rbuf[4]);

This looks like a big-endian data. Is this correct? If so, could you
please see if the version of the patch below still works for you?

Thanks!

-- 
Dmitry

Input: raydium_i2c_ts - read device version in bootloader mode

From: simba.hsu <simba.hsu@rad-ic.com>

Add support reading device ID when controller is in bootloader mode, which
may happen if firmware update has been interrupted.

Signed-off-by: simba.hsu <simba.hsu@rad-ic.com>
Link: https://lore.kernel.org/r/20210510083536.41925-1-simba.hsu@rad-ic.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/raydium_i2c_ts.c |   52 ++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index 4d2d22a86977..c7bf0c5360c9 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -36,7 +36,8 @@
 #define RM_CMD_BOOT_CHK		0x33		/* send data check */
 #define RM_CMD_BOOT_READ	0x44		/* send wait bl data ready*/
 
-#define RM_BOOT_RDY		0xFF		/* bl data ready */
+#define RM_BOOT_RDY		0xFF			/* bl data ready */
+#define RM_BOOT_CMD_READHWID	0x0E	/* read hwid */
 
 /* I2C main commands */
 #define RM_CMD_QUERY_BANK	0x2B
@@ -290,6 +291,44 @@ static int raydium_i2c_sw_reset(struct i2c_client *client)
 	return 0;
 }
 
+static int raydium_i2c_query_ts_bootloader_info(struct raydium_data *ts)
+{
+	struct i2c_client *client = ts->client;
+	static const u8 get_hwid[] = { RM_BOOT_CMD_READHWID,
+				       0x10, 0xc0, 0x01, 0x00, 0x04, 0x00 };
+	u8 rbuf[5] = { 0 };
+	u32 hw_ver;
+	int error;
+
+	error = raydium_i2c_send(client, RM_CMD_BOOT_WRT,
+				 get_hwid, sizeof(get_hwid));
+	if (error) {
+		dev_err(&client->dev, "WRT HWID command failed: %d\n", error);
+		return error;
+	}
+
+	error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, rbuf, 1);
+	if (error) {
+		dev_err(&client->dev, "Ack HWID command failed: %d\n", error);
+		return error;
+	}
+
+	error = raydium_i2c_read(client, RM_CMD_BOOT_CHK, rbuf, sizeof(rbuf));
+	if (error) {
+		dev_err(&client->dev, "Read HWID command failed: %d (%4ph)\n",
+			error, rbuf + 1);
+		hw_ver = 0xffffffffUL;
+	} else {
+		hw_ver = get_unaligned_be32(rbuf + 1);
+	}
+
+	ts->info.hw_ver = cpu_to_le32(hw_ver);
+	ts->info.main_ver = 0xff;
+	ts->info.sub_ver = 0xff;
+
+	return error;
+}
+
 static int raydium_i2c_query_ts_info(struct raydium_data *ts)
 {
 	struct i2c_client *client = ts->client;
@@ -388,13 +427,10 @@ static int raydium_i2c_initialize(struct raydium_data *ts)
 	if (error)
 		ts->boot_mode = RAYDIUM_TS_BLDR;
 
-	if (ts->boot_mode == RAYDIUM_TS_BLDR) {
-		ts->info.hw_ver = cpu_to_le32(0xffffffffUL);
-		ts->info.main_ver = 0xff;
-		ts->info.sub_ver = 0xff;
-	} else {
+	if (ts->boot_mode == RAYDIUM_TS_BLDR)
+		raydium_i2c_query_ts_bootloader_info(ts);
+	else
 		raydium_i2c_query_ts_info(ts);
-	}
 
 	return error;
 }
@@ -1218,7 +1254,7 @@ static SIMPLE_DEV_PM_OPS(raydium_i2c_pm_ops,
 			 raydium_i2c_suspend, raydium_i2c_resume);
 
 static const struct i2c_device_id raydium_i2c_id[] = {
-	{ "raydium_i2c" , 0 },
+	{ "raydium_i2c", 0 },
 	{ "rm32380", 0 },
 	{ /* sentinel */ }
 };

  reply	other threads:[~2021-06-02  5:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10  8:35 [PATCH] driver:input:touchscreen: improve the mechanism of auto-update simba.hsu
2021-06-02  5:03 ` Dmitry Torokhov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-05-26  2:53 simba.hsu
2021-05-10  8:27 simba.hsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YLcRCl23ksfYTmN6@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=KP.li@rad-ic.com \
    --cc=evgreen@chromium.org \
    --cc=furquan@google.com \
    --cc=jeffrey.lin@rad-ic.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rrangle@chromium.org \
    --cc=seanpaul@chromium.org \
    --cc=simba.hsu@rad-ic.com \
    --cc=simba.hsu@raydium.corp-partner.google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).