115-input-sun4i-ts-update-temp-curve.patch 3.1 KB

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