0014-rtc.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. From 55aabf536ba74a27665aa48413ff958be42cb8eb Mon Sep 17 00:00:00 2001
  2. From: "Bart Groeneveld | GPX Solutions B.V" <bart@gpxbv.nl>
  3. Date: Mon, 5 Dec 2022 16:08:46 +0100
  4. Subject: [PATCH] acpi: allow usage of acpi_tad on HW-reduced platforms
  5. The specification [1] allows so-called HW-reduced platforms,
  6. which do not implement everything, especially the wakeup related stuff.
  7. In that case, it is still usable as a RTC. This is helpful for [2]
  8. and [3], which is about a device with no other working RTC,
  9. but it does have an HW-reduced TAD, which can be used as a RTC instead.
  10. [1]: https://uefi.org/specs/ACPI/6.5/09_ACPI_Defined_Devices_and_Device_Specific_Objects.html#time-and-alarm-device
  11. [2]: https://bugzilla.kernel.org/show_bug.cgi?id=212313
  12. [3]: https://github.com/linux-surface/linux-surface/issues/415
  13. Signed-off-by: Bart Groeneveld | GPX Solutions B.V. <bart@gpxbv.nl>
  14. Patchset: rtc
  15. ---
  16. drivers/acpi/acpi_tad.c | 36 ++++++++++++++++++++++++------------
  17. 1 file changed, 24 insertions(+), 12 deletions(-)
  18. diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
  19. index 33c3b16af556b..900445d06623d 100644
  20. --- a/drivers/acpi/acpi_tad.c
  21. +++ b/drivers/acpi/acpi_tad.c
  22. @@ -432,6 +432,14 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
  23. static DEVICE_ATTR_RO(caps);
  24. +static struct attribute *acpi_tad_attrs[] = {
  25. + &dev_attr_caps.attr,
  26. + NULL,
  27. +};
  28. +static const struct attribute_group acpi_tad_attr_group = {
  29. + .attrs = acpi_tad_attrs,
  30. +};
  31. +
  32. static ssize_t ac_alarm_store(struct device *dev, struct device_attribute *attr,
  33. const char *buf, size_t count)
  34. {
  35. @@ -480,15 +488,14 @@ static ssize_t ac_status_show(struct device *dev, struct device_attribute *attr,
  36. static DEVICE_ATTR_RW(ac_status);
  37. -static struct attribute *acpi_tad_attrs[] = {
  38. - &dev_attr_caps.attr,
  39. +static struct attribute *acpi_tad_ac_attrs[] = {
  40. &dev_attr_ac_alarm.attr,
  41. &dev_attr_ac_policy.attr,
  42. &dev_attr_ac_status.attr,
  43. NULL,
  44. };
  45. -static const struct attribute_group acpi_tad_attr_group = {
  46. - .attrs = acpi_tad_attrs,
  47. +static const struct attribute_group acpi_tad_ac_attr_group = {
  48. + .attrs = acpi_tad_ac_attrs,
  49. };
  50. static ssize_t dc_alarm_store(struct device *dev, struct device_attribute *attr,
  51. @@ -564,13 +571,18 @@ static int acpi_tad_remove(struct platform_device *pdev)
  52. pm_runtime_get_sync(dev);
  53. + if (dd->capabilities & ACPI_TAD_AC_WAKE)
  54. + sysfs_remove_group(&dev->kobj, &acpi_tad_ac_attr_group);
  55. +
  56. if (dd->capabilities & ACPI_TAD_DC_WAKE)
  57. sysfs_remove_group(&dev->kobj, &acpi_tad_dc_attr_group);
  58. sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group);
  59. - acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
  60. - acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
  61. + if (dd->capabilities & ACPI_TAD_AC_WAKE) {
  62. + acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
  63. + acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
  64. + }
  65. if (dd->capabilities & ACPI_TAD_DC_WAKE) {
  66. acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER);
  67. acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER);
  68. @@ -613,12 +625,6 @@ static int acpi_tad_probe(struct platform_device *pdev)
  69. goto remove_handler;
  70. }
  71. - if (!acpi_has_method(handle, "_PRW")) {
  72. - dev_info(dev, "Missing _PRW\n");
  73. - ret = -ENODEV;
  74. - goto remove_handler;
  75. - }
  76. -
  77. dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL);
  78. if (!dd) {
  79. ret = -ENOMEM;
  80. @@ -649,6 +655,12 @@ static int acpi_tad_probe(struct platform_device *pdev)
  81. if (ret)
  82. goto fail;
  83. + if (caps & ACPI_TAD_AC_WAKE) {
  84. + ret = sysfs_create_group(&dev->kobj, &acpi_tad_ac_attr_group);
  85. + if (ret)
  86. + goto fail;
  87. + }
  88. +
  89. if (caps & ACPI_TAD_DC_WAKE) {
  90. ret = sysfs_create_group(&dev->kobj, &acpi_tad_dc_attr_group);
  91. if (ret)
  92. --
  93. 2.43.0