diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-03-08 17:12:41 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-03-08 17:16:59 -0400 |
commit | 91c68a7c1d92b48287f2f3111a9b09b26a263d3f (patch) | |
tree | 219463189e75cc61cf643e8606d1c1231078f7fc | |
parent | 973877477e2f1eecdf8ae4305cd6e030c7cf08db (diff) |
Input: sun4i-ts - A10 (sun4i) has a different temperature curve
Testing has revealed that the temperature in the rtp controller of the A10
(sun4i) SoC has a different curve then on the A13 (sun5i) and later models.
Add a new sun5i-a13-ts compatible to differentiate the newer models and
set the curve based on the compatible string.
The new curve is still not ideal on all A10-s, that seems to have to
do with there being a large spread between different A10-s out there,
the new curve us based on callibration results on 4 completely different
models:
raw min raw max temp min temp max stepsize offset
Tong Zhang's hackberry 2402 2680 45.0 80.0 0.125 -255.3
Hansg's Cubieboard 2207 2300 36.0 45.0 0.096 -175.8
Olliver's lime 1 (*): 2258 2537 48.3 87.1 0.139 -265.7
Olliver's lime 2 (*): 2222 2486 46.7 91.7 0.170 -331.0
*) from: http://linux-sunxi.org/Temperature_Calibration
Average all 4: 0.133 -257.0
Average without outliers (middle 2): 0.132 -261.0
Since it is better to slightly overreport the temperature this patch uses
the average of all 4 as curve.
This fixes the temperature reported on the A10 being much higher then
expected.
Reported-by: Tong Zhang <lovewilliam@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | Documentation/devicetree/bindings/input/touchscreen/sun4i.txt | 3 | ||||
-rw-r--r-- | drivers/input/touchscreen/sun4i-ts.c | 16 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt index 433332d3b2ba..d59d25281e9f 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt | |||
@@ -2,7 +2,8 @@ sun4i resistive touchscreen controller | |||
2 | -------------------------------------- | 2 | -------------------------------------- |
3 | 3 | ||
4 | Required properties: | 4 | Required properties: |
5 | - compatible: "allwinner,sun4i-a10-ts" or "allwinner,sun6i-a31-ts" | 5 | - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or |
6 | "allwinner,sun6i-a31-ts" | ||
6 | - reg: mmio address range of the chip | 7 | - reg: mmio address range of the chip |
7 | - interrupts: interrupt to which the chip is connected | 8 | - interrupts: interrupt to which the chip is connected |
8 | - #thermal-sensor-cells: shall be 0 | 9 | - #thermal-sensor-cells: shall be 0 |
diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c index b93a28b955fd..66ccd5af537d 100644 --- a/drivers/input/touchscreen/sun4i-ts.c +++ b/drivers/input/touchscreen/sun4i-ts.c | |||
@@ -258,6 +258,15 @@ static int sun4i_ts_probe(struct platform_device *pdev) | |||
258 | /* Allwinner SDK has temperature = -271 + (value / 6) (C) */ | 258 | /* Allwinner SDK has temperature = -271 + (value / 6) (C) */ |
259 | ts->temp_offset = 1626; | 259 | ts->temp_offset = 1626; |
260 | ts->temp_step = 167; | 260 | ts->temp_step = 167; |
261 | } else if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) { | ||
262 | /* | ||
263 | * The A10 temperature sensor has quite a wide spread, these | ||
264 | * parameters are based on the averaging of the calibration | ||
265 | * results of 4 completely different boards, with a spread of | ||
266 | * temp_step from 96 - 170 and temp_offset from 1758 - 3310. | ||
267 | */ | ||
268 | ts->temp_offset = 2570; | ||
269 | ts->temp_step = 133; | ||
261 | } else { | 270 | } else { |
262 | /* | 271 | /* |
263 | * The user manuals do not contain the formula for calculating | 272 | * The user manuals do not contain the formula for calculating |
@@ -330,10 +339,10 @@ static int sun4i_ts_probe(struct platform_device *pdev) | |||
330 | * finally enable tp mode. | 339 | * finally enable tp mode. |
331 | */ | 340 | */ |
332 | reg = STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1); | 341 | reg = STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1); |
333 | if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) | 342 | if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) |
334 | reg |= TP_MODE_EN(1); | ||
335 | else | ||
336 | reg |= SUN6I_TP_MODE_EN(1); | 343 | reg |= SUN6I_TP_MODE_EN(1); |
344 | else | ||
345 | reg |= TP_MODE_EN(1); | ||
337 | writel(reg, ts->base + TP_CTRL1); | 346 | writel(reg, ts->base + TP_CTRL1); |
338 | 347 | ||
339 | /* | 348 | /* |
@@ -383,6 +392,7 @@ static int sun4i_ts_remove(struct platform_device *pdev) | |||
383 | 392 | ||
384 | static const struct of_device_id sun4i_ts_of_match[] = { | 393 | static const struct of_device_id sun4i_ts_of_match[] = { |
385 | { .compatible = "allwinner,sun4i-a10-ts", }, | 394 | { .compatible = "allwinner,sun4i-a10-ts", }, |
395 | { .compatible = "allwinner,sun5i-a13-ts", }, | ||
386 | { .compatible = "allwinner,sun6i-a31-ts", }, | 396 | { .compatible = "allwinner,sun6i-a31-ts", }, |
387 | { /* sentinel */ } | 397 | { /* sentinel */ } |
388 | }; | 398 | }; |