kernel: update 3.18 to 3.18.14
[openwrt/svn-archive/archive.git] / target / linux / sunxi / patches-3.18 / 115-input-sun4i-ts-update-temp-curve.patch
1 From 2e2493cd07405dfa88e53199b47bdbbb5336fdce Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Mon, 16 Jun 2014 20:01:12 +0200
4 Subject: [PATCH] touchscreen: sun4i-ts: A10 (sun4i) has a different
5 temperature curve
6
7 Testing has revealed that the temperature in the rtp controller of the A10
8 (sun4i) SoC has a different curve then on the A13 (sun5i) and later models.
9
10 Add a new sun5i-a13-ts compatible to differentiate the newer models and
11 set the curve based on the compatible string.
12
13 This fixes the temperature reported on the A10 being much higher then
14 expected.
15
16 Note the new curve is still not ideal on all A10-s, that seems to have to
17 do with there being a large spread between different A10-s out there.
18
19 Reported-by: Tong Zhang <lovewilliam@gmail.com>
20 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
21 ---
22 .../devicetree/bindings/input/touchscreen/sun4i.txt | 2 +-
23 drivers/input/touchscreen/sun4i-ts.c | 13 ++++++++++++-
24 2 files changed, 13 insertions(+), 2 deletions(-)
25
26 --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
27 +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
28 @@ -2,7 +2,7 @@ sun4i resistive touchscreen controller
29 --------------------------------------
30
31 Required properties:
32 - - compatible: "allwinner,sun4i-a10-ts"
33 + - compatible: "allwinner,sun4i-a10-ts" or "allwinner,sun5i-a13-ts"
34 - reg: mmio address range of the chip
35 - interrupts: interrupt to which the chip is connected
36
37 --- a/drivers/input/touchscreen/sun4i-ts.c
38 +++ b/drivers/input/touchscreen/sun4i-ts.c
39 @@ -111,6 +111,8 @@ struct sun4i_ts_data {
40 unsigned int irq;
41 bool ignore_fifo_data;
42 int temp_data;
43 + int temp_offset;
44 + int temp_step;
45 };
46
47 static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val)
48 @@ -189,7 +191,8 @@ static ssize_t show_temp(struct device *
49 if (ts->temp_data == -1)
50 return -EAGAIN;
51
52 - return sprintf(buf, "%d\n", (ts->temp_data - 1447) * 100);
53 + return sprintf(buf, "%d\n",
54 + (ts->temp_data - ts->temp_offset) * ts->temp_step);
55 }
56
57 static ssize_t show_temp_label(struct device *dev,
58 @@ -224,6 +227,13 @@ static int sun4i_ts_probe(struct platfor
59 ts->dev = dev;
60 ts->ignore_fifo_data = true;
61 ts->temp_data = -1;
62 + if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) {
63 + ts->temp_offset = 1900;
64 + ts->temp_step = 100;
65 + } else {
66 + ts->temp_offset = 1447;
67 + ts->temp_step = 100;
68 + }
69
70 ts_attached = of_property_read_bool(np, "allwinner,ts-attached");
71 if (ts_attached) {
72 @@ -318,6 +328,7 @@ static int sun4i_ts_remove(struct platfo
73
74 static const struct of_device_id sun4i_ts_of_match[] = {
75 { .compatible = "allwinner,sun4i-a10-ts", },
76 + { .compatible = "allwinner,sun5i-a13-ts", },
77 { /* sentinel */ }
78 };
79 MODULE_DEVICE_TABLE(of, sun4i_ts_of_match);