sunxi: add initial 3.18 support
[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 diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
27 index aef5779..5106709 100644
28 --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
29 +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
30 @@ -2,7 +2,7 @@ sun4i resistive touchscreen controller
31 --------------------------------------
32
33 Required properties:
34 - - compatible: "allwinner,sun4i-a10-ts"
35 + - compatible: "allwinner,sun4i-a10-ts" or "allwinner,sun5i-a13-ts"
36 - reg: mmio address range of the chip
37 - interrupts: interrupt to which the chip is connected
38
39 diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
40 index 2ba8260..52b7114 100644
41 --- a/drivers/input/touchscreen/sun4i-ts.c
42 +++ b/drivers/input/touchscreen/sun4i-ts.c
43 @@ -111,6 +111,8 @@ struct sun4i_ts_data {
44 unsigned int irq;
45 bool ignore_fifo_data;
46 int temp_data;
47 + int temp_offset;
48 + int temp_step;
49 };
50
51 static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val)
52 @@ -189,7 +191,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
53 if (ts->temp_data == -1)
54 return -EAGAIN;
55
56 - return sprintf(buf, "%d\n", (ts->temp_data - 1447) * 100);
57 + return sprintf(buf, "%d\n",
58 + (ts->temp_data - ts->temp_offset) * ts->temp_step);
59 }
60
61 static ssize_t show_temp_label(struct device *dev,
62 @@ -224,6 +227,13 @@ static int sun4i_ts_probe(struct platform_device *pdev)
63 ts->dev = dev;
64 ts->ignore_fifo_data = true;
65 ts->temp_data = -1;
66 + if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) {
67 + ts->temp_offset = 1900;
68 + ts->temp_step = 100;
69 + } else {
70 + ts->temp_offset = 1447;
71 + ts->temp_step = 100;
72 + }
73
74 ts_attached = of_property_read_bool(np, "allwinner,ts-attached");
75 if (ts_attached) {
76 @@ -318,6 +328,7 @@ static int sun4i_ts_remove(struct platform_device *pdev)
77
78 static const struct of_device_id sun4i_ts_of_match[] = {
79 { .compatible = "allwinner,sun4i-a10-ts", },
80 + { .compatible = "allwinner,sun5i-a13-ts", },
81 { /* sentinel */ }
82 };
83 MODULE_DEVICE_TABLE(of, sun4i_ts_of_match);