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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
  21. +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
  22. @@ -2,7 +2,7 @@ sun4i resistive touchscreen controller
  23. --------------------------------------
  24. Required properties:
  25. - - compatible: "allwinner,sun4i-a10-ts"
  26. + - compatible: "allwinner,sun4i-a10-ts" or "allwinner,sun5i-a13-ts"
  27. - reg: mmio address range of the chip
  28. - interrupts: interrupt to which the chip is connected
  29. --- a/drivers/input/touchscreen/sun4i-ts.c
  30. +++ b/drivers/input/touchscreen/sun4i-ts.c
  31. @@ -111,6 +111,8 @@ struct sun4i_ts_data {
  32. unsigned int irq;
  33. bool ignore_fifo_data;
  34. int temp_data;
  35. + int temp_offset;
  36. + int temp_step;
  37. };
  38. static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val)
  39. @@ -189,7 +191,8 @@ static ssize_t show_temp(struct device *
  40. if (ts->temp_data == -1)
  41. return -EAGAIN;
  42. - return sprintf(buf, "%d\n", (ts->temp_data - 1447) * 100);
  43. + return sprintf(buf, "%d\n",
  44. + (ts->temp_data - ts->temp_offset) * ts->temp_step);
  45. }
  46. static ssize_t show_temp_label(struct device *dev,
  47. @@ -224,6 +227,13 @@ static int sun4i_ts_probe(struct platfor
  48. ts->dev = dev;
  49. ts->ignore_fifo_data = true;
  50. ts->temp_data = -1;
  51. + if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) {
  52. + ts->temp_offset = 1900;
  53. + ts->temp_step = 100;
  54. + } else {
  55. + ts->temp_offset = 1447;
  56. + ts->temp_step = 100;
  57. + }
  58. ts_attached = of_property_read_bool(np, "allwinner,ts-attached");
  59. if (ts_attached) {
  60. @@ -318,6 +328,7 @@ static int sun4i_ts_remove(struct platfo
  61. static const struct of_device_id sun4i_ts_of_match[] = {
  62. { .compatible = "allwinner,sun4i-a10-ts", },
  63. + { .compatible = "allwinner,sun5i-a13-ts", },
  64. { /* sentinel */ }
  65. };
  66. MODULE_DEVICE_TABLE(of, sun4i_ts_of_match);