devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jeffrey Lin (林義章)" <Jeffrey.Lin@rad-ic.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	"jeffrey.lin" <yajohn@gmail.com>
Cc: "rydberg@euromail.se" <rydberg@euromail.se>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"jeesw@melfas.com" <jeesw@melfas.com>,
	"bleung@chromium.org" <bleung@chromium.org>,
	"Roger Yang (楊鎮瑋)" <Roger.Yang@rad-ic.com>,
	"KP Li (李昆倍)" <KP.Li@rad-ic.com>,
	"Albert Shieh (謝欣瑋)" <Albert.Shieh@rad-ic.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: RE: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver
Date: Thu, 5 May 2016 10:23:01 +0000	[thread overview]
Message-ID: <9BE4B49389AB2F41A64A32DFC844F1DF73F203AE@RADHCMS5.corp.rad-ic.com> (raw)
In-Reply-To: <20160504225846.GA17403@dtor-ws>

[-- Attachment #1: Type: text/plain, Size: 6292 bytes --]

Hi Dmitry:
Answer this mail as below.

From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com]
Sent: Thursday, May 05, 2016 6:59 AM
To: jeffrey.lin
Cc: rydberg@euromail.se; grant.likely@linaro.org; robh+dt@kernel.org; jeesw@melfas.com; bleung@chromium.org; Jeffrey Lin (林義章); Roger Yang (楊鎮瑋); KP Li (李昆倍); Albert Shieh (謝欣瑋); linux-kernel@vger.kernel.org; linux-input@vger.kernel.org; devicetree@vger.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver


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.
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.

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 *)&ts->obj);
> +                     ts->obj.data_bank_addr =
> +                             get_unaligned_le32(&ts->obj.data_bank_addr);
> +
> +             if (!error) {
> +                     error = raydium_i2c_read(client, CMD_QUERY_BANK,
> +                             sizeof(ts->query_bank_info),
> +                             (void *)&ts->query_bank_info);
> +                     if (!error) {
> +                             error = raydium_i2c_read_message(client,
> +                                     ts->query_bank_info, sizeof(ts->info),
> +                                     (void *)&ts->info);
> +
> +                             ts->info.hw_ver =
> +                                     get_unaligned_le32(&ts->info.hw_ver);
> +                             ts->info.ft_ver =
> +                                     get_unaligned_le16(&ts->info.ft_ver);
> +                             ts->info.x_max =
> +                                     get_unaligned_le16(&ts->info.x_max);
> +                             ts->info.y_max =
> +                                     get_unaligned_le16(&ts->info.y_max);
> +                             return 0;
> +                     }
> +             }
> +     }
> +     dev_err(&client->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?
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.

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.

Thanks.

--
Dmitry


Best Regards
Jeffrey Lin


[-- Attachment #2: Type: text/html, Size: 14693 bytes --]

  reply	other threads:[~2016-05-05 10:23 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29  9:45 [PATCH] driver: input :touchscreen : add Raydium I2C touch driver jeffrey.lin
2016-05-04 22:58 ` Dmitry Torokhov
2016-05-05 10:23   ` Jeffrey Lin (林義章) [this message]
2016-05-05 10:25   ` Jeffrey Lin (林義章)
2016-05-06  8:24 ` jeffrey.lin
2016-05-11 16:04 ` jeffrey.lin
     [not found] ` <1461923113-426-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-13  4:18   ` Dmitry Torokhov
2016-05-13 17:08     ` jeffrey.lin
2016-05-16 15:46     ` jeffrey.lin
     [not found]       ` <1463413611-367-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-16 16:41         ` Dmitry Torokhov
2016-05-16 16:43           ` Dmitry Torokhov
2016-05-16 15:57     ` jeffrey.lin
2016-05-17 16:07     ` jeffrey.lin
     [not found]       ` <1463501223-20723-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-21 18:18         ` Dmitry Torokhov
2016-05-22  9:32     ` jeffrey.lin
2016-05-22 22:37       ` Dmitry Torokhov
2016-05-22  9:35     ` jeffrey.lin
2016-05-23 14:43     ` jeffrey.lin
     [not found]       ` <1464014633-20829-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-23 16:27         ` Dmitry Torokhov
2016-05-24  9:31     ` jeffrey.lin
     [not found]       ` <1464082301-11539-1-git-send-email-jeffrey.lin-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-05-27 16:34         ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2016-05-24  9:05 jeffrey.lin
2016-05-17 15:34 jeffrey.lin
2016-05-11 13:51 jeffrey.lin
2016-04-22 10:01 dan.huang
     [not found] ` <1461319268-362-1-git-send-email-dan.huang-s3Ivl27awEzQT0dZR+AlfA@public.gmane.org>
2016-04-22 22:50   ` Dmitry Torokhov
2016-04-25  2:48     ` yajohn lin
2016-03-25  5:21 jeffrey.lin
2016-04-11  8:24 ` Dmitry Torokhov
2016-04-11  9:57   ` Jeffrey Lin (林義章)
2016-04-14  9:28   ` Jeffrey Lin (林義章)
2016-03-22  6:23 jeffrey.lin
2016-03-15  8:44 jeffrey.lin
2016-03-18 21:04 ` Rob Herring
2016-03-03  6:42 jeffrey.lin
2016-03-10 18:47 ` Dmitry Torokhov
2016-03-11  2:10   ` Jeffrey Lin (林義章)
2016-03-03  2:29 jeffrey.lin
2016-03-03  2:44 ` Joe Perches
2016-03-03  3:14   ` Jeffrey Lin (林義章)
2016-03-03  3:55     ` Joe Perches
2016-02-23  8:11 jeffrey.lin

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=9BE4B49389AB2F41A64A32DFC844F1DF73F203AE@RADHCMS5.corp.rad-ic.com \
    --to=jeffrey.lin@rad-ic.com \
    --cc=Albert.Shieh@rad-ic.com \
    --cc=KP.Li@rad-ic.com \
    --cc=Roger.Yang@rad-ic.com \
    --cc=bleung@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=jeesw@melfas.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=rydberg@euromail.se \
    --cc=yajohn@gmail.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).