0009-surface-battery.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. From 0f0c7c99159906bcdfdee9d318a40eb639a3fc15 Mon Sep 17 00:00:00 2001
  2. From: Werner Sembach <wse@tuxedocomputers.com>
  3. Date: Wed, 27 Apr 2022 17:40:53 +0200
  4. Subject: [PATCH] ACPI: battery: Make "not-charging" the default on no charging
  5. or full info
  6. When the battery is neither charging or discharging and is not full,
  7. "not-charging" is a useful status description for the case in general.
  8. Currently this state is set as "unknown" by default, expect when this is
  9. explicitly replaced with "not-charging" on a per device or per vendor
  10. basis.
  11. A lot of devices have this state without a BIOS specification available
  12. explicitly describing it. e.g. some current Clevo barebones have a BIOS
  13. setting to stop charging at a user defined battery level.
  14. Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
  15. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  16. Patchset: surface-battery
  17. ---
  18. drivers/acpi/battery.c | 24 +-----------------------
  19. 1 file changed, 1 insertion(+), 23 deletions(-)
  20. diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
  21. index dc208f5f5a1f..306513fec1e1 100644
  22. --- a/drivers/acpi/battery.c
  23. +++ b/drivers/acpi/battery.c
  24. @@ -52,7 +52,6 @@ static bool battery_driver_registered;
  25. static int battery_bix_broken_package;
  26. static int battery_notification_delay_ms;
  27. static int battery_ac_is_broken;
  28. -static int battery_quirk_notcharging;
  29. static unsigned int cache_time = 1000;
  30. module_param(cache_time, uint, 0644);
  31. MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
  32. @@ -216,10 +215,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
  33. val->intval = POWER_SUPPLY_STATUS_CHARGING;
  34. else if (acpi_battery_is_charged(battery))
  35. val->intval = POWER_SUPPLY_STATUS_FULL;
  36. - else if (battery_quirk_notcharging)
  37. - val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
  38. else
  39. - val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
  40. + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
  41. break;
  42. case POWER_SUPPLY_PROP_PRESENT:
  43. val->intval = acpi_battery_present(battery);
  44. @@ -1105,12 +1102,6 @@ battery_ac_is_broken_quirk(const struct dmi_system_id *d)
  45. return 0;
  46. }
  47. -static int __init battery_quirk_not_charging(const struct dmi_system_id *d)
  48. -{
  49. - battery_quirk_notcharging = 1;
  50. - return 0;
  51. -}
  52. -
  53. static const struct dmi_system_id bat_dmi_table[] __initconst = {
  54. {
  55. /* NEC LZ750/LS */
  56. @@ -1139,19 +1130,6 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
  57. DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
  58. },
  59. },
  60. - {
  61. - /*
  62. - * On Lenovo ThinkPads the BIOS specification defines
  63. - * a state when the bits for charging and discharging
  64. - * are both set to 0. That state is "Not Charging".
  65. - */
  66. - .callback = battery_quirk_not_charging,
  67. - .ident = "Lenovo ThinkPad",
  68. - .matches = {
  69. - DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  70. - DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"),
  71. - },
  72. - },
  73. {
  74. /* Microsoft Surface Go 3 */
  75. .callback = battery_notification_delay_quirk,
  76. --
  77. 2.36.1
  78. From 8d958ad7373a56e188dea9645cb75c261c9ae42d Mon Sep 17 00:00:00 2001
  79. From: Maximilian Luz <luzmaximilian@gmail.com>
  80. Date: Wed, 25 May 2022 14:20:10 +0200
  81. Subject: [PATCH] HID: hid-input: add Surface Go battery quirk
  82. Similar to the Surface Go (1), the (Elantech) touchscreen/digitizer in
  83. the Surface Go 2 mistakenly reports the battery of the stylus. Instead
  84. of over the touchsreen device, battery information is provided via
  85. bluetooth and the touchscreen device reports an empty battery.
  86. Apply the HID_BATTERY_QUIRK_IGNORE quirk to to ignore this battery and
  87. prevent the erroneous low battery warnings.
  88. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  89. Patchset: surface-battery
  90. ---
  91. drivers/hid/hid-ids.h | 1 +
  92. drivers/hid/hid-input.c | 2 ++
  93. 2 files changed, 3 insertions(+)
  94. diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
  95. index aca7909c726d..741e38477a91 100644
  96. --- a/drivers/hid/hid-ids.h
  97. +++ b/drivers/hid/hid-ids.h
  98. @@ -405,6 +405,7 @@
  99. #define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN 0x2544
  100. #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706
  101. #define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A
  102. +#define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN 0x2A1C
  103. #define USB_VENDOR_ID_ELECOM 0x056e
  104. #define USB_DEVICE_ID_ELECOM_BM084 0x0061
  105. diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
  106. index 56ec27398a00..263a977801bf 100644
  107. --- a/drivers/hid/hid-input.c
  108. +++ b/drivers/hid/hid-input.c
  109. @@ -336,6 +336,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
  110. HID_BATTERY_QUIRK_IGNORE },
  111. { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN),
  112. HID_BATTERY_QUIRK_IGNORE },
  113. + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN),
  114. + HID_BATTERY_QUIRK_IGNORE },
  115. {}
  116. };
  117. --
  118. 2.36.1