From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "jeffrey.lin" <yajohn@gmail.com>, bleung@chromium.org
Cc: jeffrey.lin@rad-ic.com, roger.yang@rad-ic.com, KP.li@rad-ic.com,
albert.shieh@rad-ic.com, 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
Date: Sun, 22 May 2016 15:37:29 -0700 [thread overview]
Message-ID: <9B72127B-A7F3-4FDD-968E-600C2D55CF9D@gmail.com> (raw)
In-Reply-To: <1463909579-316-1-git-send-email-jeffrey.lin@rad-ic.com>
On May 22, 2016 2:32:59 AM PDT, "jeffrey.lin" <yajohn@gmail.com> 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,
>+ &be_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,
> &shift_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(&buf[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
next prev parent reply other threads:[~2016-05-22 22:37 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 9:45 jeffrey.lin
2016-05-04 22:58 ` Dmitry Torokhov
2016-05-06 8:24 ` jeffrey.lin
2016-05-11 16:04 ` jeffrey.lin
2016-05-13 4:18 ` Dmitry Torokhov
2016-05-13 17:08 ` jeffrey.lin
2016-05-16 15:46 ` jeffrey.lin
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
2016-05-21 18:18 ` Dmitry Torokhov
2016-05-22 9:32 ` jeffrey.lin
2016-05-22 22:37 ` Dmitry Torokhov [this message]
2016-05-22 9:35 ` jeffrey.lin
2016-05-23 14:43 ` jeffrey.lin
2016-05-23 16:27 ` Dmitry Torokhov
2016-05-24 9:31 ` jeffrey.lin
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
2016-04-22 22:50 ` Dmitry Torokhov
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
2016-01-21 4:02 Jeffrey Lin
2016-01-21 9:37 ` Dmitry Torokhov
2016-01-15 3:30 Jeffrey Lin
2016-01-13 7:49 Jeffrey Lin
2016-01-13 8:31 ` Dmitry Torokhov
2016-01-13 19:14 ` Dmitry Torokhov
2016-01-13 6:23 Jeffrey Lin
2016-01-13 6:44 ` Dmitry Torokhov
2016-01-08 15:17 Jeffrey Lin
2016-01-09 19:20 ` Dmitry Torokhov
2015-01-06 9:25 jeffrey.lin
2015-01-06 19:43 ` Jeremiah Mahler
2015-01-07 0:40 ` Dmitry Torokhov
2014-12-08 3:42 jeffrey.lin
2014-12-05 8:15 jeffrey.lin
2014-12-05 15:04 ` Dmitry Torokhov
2014-11-14 7:19 jeffrey.lin
2014-11-14 17:43 ` Benson Leung
2014-11-14 18:00 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9B72127B-A7F3-4FDD-968E-600C2D55CF9D@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=KP.li@rad-ic.com \
--cc=albert.shieh@rad-ic.com \
--cc=bleung@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=jeffrey.lin@rad-ic.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roger.yang@rad-ic.com \
--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
Powered by JetHome