diff options
author | Christopher Hudson <chris.hudson.comp.eng@gmail.com> | 2012-03-17 01:47:47 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-17 01:49:32 -0400 |
commit | 043916608c4b309e98a1650520ed4e88ec5e9123 (patch) | |
tree | dc6dadf7713315f77d13d07a00fd971f314c4ae2 | |
parent | 104594b01ce750c91a19e9f1d8fe6b24ea8f9a59 (diff) |
Input: kxtj9 - who_am_i check value and initial data rate fixes
Several fixes based on customer feedback:
* WHO_AM_I value has changed since preliminary parts used for initial
testing;
* Output of le16_to_cpu must be saved to memory before shifting to
preserve sign;
* Initial data rate was not extracted from data control register init.
This was causing the initial data rate to be set to maximum until
it was changed. To fix this problem, it made more sense to specify
initial data rate and extract the register mask from that.
Signed-off-by: Chris Hudson <chudson@kionix.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/misc/kxtj9.c | 22 | ||||
-rw-r--r-- | include/linux/input/kxtj9.h | 11 |
2 files changed, 18 insertions, 15 deletions
diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c index 783597a9a64a..21edaba489be 100644 --- a/drivers/input/misc/kxtj9.c +++ b/drivers/input/misc/kxtj9.c | |||
@@ -41,6 +41,14 @@ | |||
41 | #define PC1_ON (1 << 7) | 41 | #define PC1_ON (1 << 7) |
42 | /* Data ready funtion enable bit: set during probe if using irq mode */ | 42 | /* Data ready funtion enable bit: set during probe if using irq mode */ |
43 | #define DRDYE (1 << 5) | 43 | #define DRDYE (1 << 5) |
44 | /* DATA CONTROL REGISTER BITS */ | ||
45 | #define ODR12_5F 0 | ||
46 | #define ODR25F 1 | ||
47 | #define ODR50F 2 | ||
48 | #define ODR100F 3 | ||
49 | #define ODR200F 4 | ||
50 | #define ODR400F 5 | ||
51 | #define ODR800F 6 | ||
44 | /* INTERRUPT CONTROL REGISTER 1 BITS */ | 52 | /* INTERRUPT CONTROL REGISTER 1 BITS */ |
45 | /* Set these during probe if using irq mode */ | 53 | /* Set these during probe if using irq mode */ |
46 | #define KXTJ9_IEL (1 << 3) | 54 | #define KXTJ9_IEL (1 << 3) |
@@ -116,9 +124,13 @@ static void kxtj9_report_acceleration_data(struct kxtj9_data *tj9) | |||
116 | if (err < 0) | 124 | if (err < 0) |
117 | dev_err(&tj9->client->dev, "accelerometer data read failed\n"); | 125 | dev_err(&tj9->client->dev, "accelerometer data read failed\n"); |
118 | 126 | ||
119 | x = le16_to_cpu(acc_data[tj9->pdata.axis_map_x]) >> tj9->shift; | 127 | x = le16_to_cpu(acc_data[tj9->pdata.axis_map_x]); |
120 | y = le16_to_cpu(acc_data[tj9->pdata.axis_map_y]) >> tj9->shift; | 128 | y = le16_to_cpu(acc_data[tj9->pdata.axis_map_y]); |
121 | z = le16_to_cpu(acc_data[tj9->pdata.axis_map_z]) >> tj9->shift; | 129 | z = le16_to_cpu(acc_data[tj9->pdata.axis_map_z]); |
130 | |||
131 | x >>= tj9->shift; | ||
132 | y >>= tj9->shift; | ||
133 | z >>= tj9->shift; | ||
122 | 134 | ||
123 | input_report_abs(tj9->input_dev, ABS_X, tj9->pdata.negate_x ? -x : x); | 135 | input_report_abs(tj9->input_dev, ABS_X, tj9->pdata.negate_x ? -x : x); |
124 | input_report_abs(tj9->input_dev, ABS_Y, tj9->pdata.negate_y ? -y : y); | 136 | input_report_abs(tj9->input_dev, ABS_Y, tj9->pdata.negate_y ? -y : y); |
@@ -487,7 +499,7 @@ static int __devinit kxtj9_verify(struct kxtj9_data *tj9) | |||
487 | goto out; | 499 | goto out; |
488 | } | 500 | } |
489 | 501 | ||
490 | retval = retval != 0x06 ? -EIO : 0; | 502 | retval = (retval != 0x07 && retval != 0x08) ? -EIO : 0; |
491 | 503 | ||
492 | out: | 504 | out: |
493 | kxtj9_device_power_off(tj9); | 505 | kxtj9_device_power_off(tj9); |
@@ -537,7 +549,7 @@ static int __devinit kxtj9_probe(struct i2c_client *client, | |||
537 | i2c_set_clientdata(client, tj9); | 549 | i2c_set_clientdata(client, tj9); |
538 | 550 | ||
539 | tj9->ctrl_reg1 = tj9->pdata.res_12bit | tj9->pdata.g_range; | 551 | tj9->ctrl_reg1 = tj9->pdata.res_12bit | tj9->pdata.g_range; |
540 | tj9->data_ctrl = tj9->pdata.data_odr_init; | 552 | tj9->last_poll_interval = tj9->pdata.init_interval; |
541 | 553 | ||
542 | if (client->irq) { | 554 | if (client->irq) { |
543 | /* If in irq mode, populate INT_CTRL_REG1 and enable DRDY. */ | 555 | /* If in irq mode, populate INT_CTRL_REG1 and enable DRDY. */ |
diff --git a/include/linux/input/kxtj9.h b/include/linux/input/kxtj9.h index f6bac89537b8..d415579b56fe 100644 --- a/include/linux/input/kxtj9.h +++ b/include/linux/input/kxtj9.h | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | struct kxtj9_platform_data { | 25 | struct kxtj9_platform_data { |
26 | unsigned int min_interval; /* minimum poll interval (in milli-seconds) */ | 26 | unsigned int min_interval; /* minimum poll interval (in milli-seconds) */ |
27 | unsigned int init_interval; /* initial poll interval (in milli-seconds) */ | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * By default, x is axis 0, y is axis 1, z is axis 2; these can be | 30 | * By default, x is axis 0, y is axis 1, z is axis 2; these can be |
@@ -52,16 +53,6 @@ struct kxtj9_platform_data { | |||
52 | #define KXTJ9_G_8G (1 << 4) | 53 | #define KXTJ9_G_8G (1 << 4) |
53 | u8 g_range; | 54 | u8 g_range; |
54 | 55 | ||
55 | /* DATA_CTRL_REG: controls the output data rate of the part */ | ||
56 | #define ODR12_5F 0 | ||
57 | #define ODR25F 1 | ||
58 | #define ODR50F 2 | ||
59 | #define ODR100F 3 | ||
60 | #define ODR200F 4 | ||
61 | #define ODR400F 5 | ||
62 | #define ODR800F 6 | ||
63 | u8 data_odr_init; | ||
64 | |||
65 | int (*init)(void); | 56 | int (*init)(void); |
66 | void (*exit)(void); | 57 | void (*exit)(void); |
67 | int (*power_on)(void); | 58 | int (*power_on)(void); |