linux-surface / surface-pro-x

Tracking and meta repository for Surface Pro X support.
83 stars 6 forks source link

Support for Real-Time Clock via SAM #9

Open qzed opened 2 years ago

qzed commented 2 years ago

The Surface Pro X exposes a standard real-time clock ACPI interface (ACPI000E). This calls to the Surface Aggregator EC via the SAN interface. Add direct support for the RCT as SAM client device/driver combo. While not directly apparent in ACPI, there also seems to be a dedicated wake interrupt GPIO pin associated with the RTC.

qzed commented 2 years ago

Some notes:

qzed commented 2 years ago

There is indeed a qcom,pm8941-rtc present (code here), but that shows a date of 1971 on my SPX and can't be changed. We can set the allow-set-time property in DT, but then the set command stalls. So we should probably implement the SAM RTC as proper RTC device (unlike the ACPI TAD implementation), since it seems to be the only working RTC around.

More open questions:

qzed commented 2 years ago
  • _GWS accesses some system memory region in DSDT and is not implemented in via SAM. What provides this region and sets the wake status?

Clarification on this: The respective SAM request still works (provided one gives the index to the timer as payload, i.e. 0 or 1 as u32, see ACPI spec). So do we actually need to access system memory or can we rely on SAM here?

qzed commented 2 years ago

Very basic RTC support has been implemented in https://github.com/linux-surface/kernel/commit/6b289bf17375b2c98292cd56d20bde7278560c82. This does not support any kind of alarms yet. For testing wake alarms/interrupts properly, we may need to make suspend work first.

qzed commented 2 years ago

Discussion on the built-in Qualcomm RTC and why that doesn't allow setting time: https://discuss.96boards.org/t/how-to-enable-rtc-on-dragonboard-410c-with-linaro-15-07/188/19.

qzed commented 1 year ago

The RTC used by Qualcomm uses an offset stored as UEFI variable for correction (882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo). See https://lore.kernel.org/lkml/20230126142057.25715-20-johan+linaro@kernel.org/ for details.

A series to better support this RTC is being upstreamed: https://lore.kernel.org/lkml/20230202155448.6715-1-johan+linaro@kernel.org/ for details.