[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1463414248-422-1-git-send-email-jeffrey.lin@rad-ic.com>
Date: Mon, 16 May 2016 23:57:28 +0800
From: "jeffrey.lin" <yajohn@...il.com>
To: dmitry.torokhov@...il.com, rydberg@...omail.se,
grant.likely@...aro.org, robh+dt@...nel.org, jeesw@...fas.com,
bleung@...omium.org
Cc: jeffrey.lin@...-ic.com, roger.yang@...-ic.com, KP.li@...-ic.com,
albert.shieh@...-ic.com, linux-kernel@...r.kernel.org,
linux-input@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH] driver: input :touchscreen : add Raydium I2C touch driver
>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(&client->dev, "Invalid firmware length\n");
> return -EINVAL;
> }
>
> error = raydium_i2c_check_fw_status(ts);
> if (error) {
> dev_err(&client->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(&client->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(&client->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(&client->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;
> }
Powered by blists - more mailing lists