Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 09/14 v3] Input: atmel_mxt_ts - refactor get info

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


djkurtz at chromium

Apr 18, 2012, 6:21 AM

Post #1 of 3 (87 views)
Permalink
[PATCH 09/14 v3] Input: atmel_mxt_ts - refactor get info

Read whole info block in one i2c transaction.
And then re-read the matrix size after applying pdata config, since
it may have changed.
Note, however, that the matrix x & y size are just displayed for
information purposes. They aren't actually used by the driver itself.

Also, parse and info print the firmware major and minor version numbers.

Signed-off-by: Daniel Kurtz <djkurtz [at] chromium>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 65 +++++------------------------
1 files changed, 12 insertions(+), 53 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 1da814b..13ecbb4 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -36,6 +36,7 @@
#define MXT_FW_NAME "maxtouch.fw"

/* Registers */
+#define MXT_INFO 0x00
#define MXT_FAMILY_ID 0x00
#define MXT_VARIANT_ID 0x01
#define MXT_VERSION 0x02
@@ -738,41 +739,6 @@ static void mxt_handle_pdata(struct mxt_data *data)
}
}

-static int mxt_get_info(struct mxt_data *data)
-{
- struct i2c_client *client = data->client;
- struct mxt_info *info = &data->info;
- int error;
- u8 val;
-
- error = mxt_read_reg(client, MXT_FAMILY_ID, 1, &val);
- if (error)
- return error;
- info->family_id = val;
-
- error = mxt_read_reg(client, MXT_VARIANT_ID, 1, &val);
- if (error)
- return error;
- info->variant_id = val;
-
- error = mxt_read_reg(client, MXT_VERSION, 1, &val);
- if (error)
- return error;
- info->version = val;
-
- error = mxt_read_reg(client, MXT_BUILD, 1, &val);
- if (error)
- return error;
- info->build = val;
-
- error = mxt_read_reg(client, MXT_OBJECT_NUM, 1, &val);
- if (error)
- return error;
- info->object_num = val;
-
- return 0;
-}
-
static int mxt_get_object_table(struct mxt_data *data)
{
int error;
@@ -808,11 +774,12 @@ static int mxt_get_object_table(struct mxt_data *data)
static int mxt_initialize(struct mxt_data *data)
{
struct i2c_client *client = data->client;
+ struct device *dev = &client->dev;
struct mxt_info *info = &data->info;
int error;
- u8 val;

- error = mxt_get_info(data);
+ /* Read 7-byte info block starting at address 0 */
+ error = mxt_read_reg(client, MXT_INFO, sizeof(*info), info);
if (error)
return error;

@@ -847,26 +814,18 @@ static int mxt_initialize(struct mxt_data *data)
MXT_COMMAND_RESET, 1);
msleep(MXT_RESET_TIME);

- /* Update matrix size at info struct */
- error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, 1, &val);
- if (error)
- return error;
- info->matrix_xsize = val;
-
- error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, 1, &val);
+ /* Update matrix size, since it may have been modified by pdata */
+ error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, 2,
+ &info->matrix_xsize);
if (error)
return error;
- info->matrix_ysize = val;

- dev_info(&client->dev,
- "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
- info->family_id, info->variant_id, info->version,
- info->build);
+ dev_info(dev, "Family ID: %d Variant ID: %d Major.Minor.Build: %d.%d.%d\n",
+ info->family_id, info->variant_id, info->version >> 4,
+ info->version & 0xf, info->build);

- dev_info(&client->dev,
- "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
- info->matrix_xsize, info->matrix_ysize,
- info->object_num);
+ dev_info(dev, "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
+ info->matrix_xsize, info->matrix_ysize, info->object_num);

return 0;
}
--
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


nick.dyer at itdev

May 5, 2012, 10:41 AM

Post #2 of 3 (89 views)
Permalink
Re: [PATCH 09/14 v3] Input: atmel_mxt_ts - refactor get info [In reply to]

Hi Daniel-

Daniel Kurtz wrote:
> - dev_info(&client->dev,
> - "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
> - info->family_id, info->variant_id, info->version,
> - info->build);
> + dev_info(dev, "Family ID: %d Variant ID: %d Major.Minor.Build: %d.%d.%d\n",
> + info->family_id, info->variant_id, info->version >> 4,
> + info->version & 0xf, info->build);

The canonical format for the Atmel firmware versions has the build number
in hex, eg. 2.0.AA

So it should be %d.%d.%02X

cheers

Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


djkurtz at chromium

May 5, 2012, 7:43 PM

Post #3 of 3 (88 views)
Permalink
Re: [PATCH 09/14 v3] Input: atmel_mxt_ts - refactor get info [In reply to]

On Sun, May 6, 2012 at 1:41 AM, Nick Dyer <nick.dyer [at] itdev> wrote:
> Hi Daniel-
>
> Daniel Kurtz wrote:
>> -     dev_info(&client->dev,
>> -                     "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
>> -                     info->family_id, info->variant_id, info->version,
>> -                     info->build);
>> +     dev_info(dev, "Family ID: %d Variant ID: %d Major.Minor.Build: %d.%d.%d\n",
>> +              info->family_id, info->variant_id, info->version >> 4,
>> +              info->version & 0xf, info->build);
>
> The canonical format for the Atmel firmware versions has the build number
> in hex, eg. 2.0.AA
>
> So it should be %d.%d.%02X

Nick,
Thanks! Will update. Or perhaps %u.%u.%02X ?
-Daniel

>
> cheers
>
> Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.