Re: [PATCH v3 3/3] rtc: Add Qualcomm GIO RTC driver

From: Konrad Dybcio

Date: Thu Dec 03 2026 - 08:07:13 EST


On 11/19/26 7:55 AM, Fenglin Wu wrote:
> On the Glymur platform, the GIO (General I/O) interface communicates
> with the SoCCP battery-management firmware and provides a set of TAD
> (Time-Alarm-Device) registers for reading and writing RTC time. The
> platform also includes registers for configuring an alarm timer and
> initiating device boot-up into different power stages, such as:
> charging only or fully powered-on system, based on the applied power
> source (AC/DC). However, repurposing this alarm timer has very limited
> value for an RTC driver because it does not expose an interrupt when
> the timer expires.
>
> Add an auxiliary RTC driver that corresponds to the auxiliary device
> created by the GIO driver, "pmic_gio.rtc", which manages the RTC timer
> by accessing to the TAD real-time register block through the regmap
> interface exposed by the GIO device.
>
> Tested-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx> # Zenbook A16
> Signed-off-by: Fenglin Wu <fenglin.wu@xxxxxxxxxxxxxxxx>
> ---
> drivers/rtc/Kconfig | 11 +++
> drivers/rtc/Makefile | 1 +
> drivers/rtc/rtc-qcom-gio.c | 153 ++++++++++++++++++++++++++++++++++++++
> drivers/soc/qcom/pmic_glink_gio.c | 14 ++++
> 4 files changed, 179 insertions(+)
>
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 73ec9230edfd..a298f7ae68f9 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -1863,6 +1863,17 @@ config RTC_DRV_PM8XXX
> To compile this driver as a module, choose M here: the
> module will be called rtc-pm8xxx.
>
> +config RTC_DRV_QCOM_GIO
> + tristate "Qualcomm GIO RTC driver"
> + depends on QCOM_PMIC_GLINK_GIO

LLM suggests we can depend on QCOM_PMIC_GIO instead, which will allow
compile-testing with less dependencies


> +static int rtc_qcom_gio_probe(struct auxiliary_device *adev,
> + const struct auxiliary_device_id *id)
> +{
> + struct device *dev = &adev->dev;
> + struct rtc_qcom_gio *rtc;
> + int ret;
> +
> + rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
> + if (!rtc)
> + return -ENOMEM;
> +
> + rtc->regmap = dev_get_regmap(dev->parent, NULL);
> + if (!rtc->regmap)
> + return -ENODEV;
> +
> + dev_set_drvdata(dev, rtc);
> +
> + rtc->rtc = devm_rtc_allocate_device(dev);
> + if (IS_ERR(rtc->rtc))
> + return PTR_ERR(rtc->rtc);
> +
> + rtc->rtc->ops = &rtc_qcom_gio_ops;
> + rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> + rtc->rtc->range_max = RTC_TIMESTAMP_END_2099;
> +
> + ret = devm_rtc_register_device(rtc->rtc);
> + if (ret)
> + return ret;
> +
> + return 0;

return devm_rtc_....

[...]

> @@ -338,6 +340,18 @@ static void pmic_glink_gio_init_work(struct work_struct *work)
>
> pmic_gio_set_state(pgio->gio, PMIC_GIO_STATE_UP);
> }
> +
> + /*
> + * Create GIO consumers after PDR to ensure the transport
> + * is up before consumers use the GIO regmap device.
> + */
> + if (!pgio->rtc_aux) {
> + pgio->rtc_aux = devm_pmic_gio_add_consumer(pgio->gio, "rtc");
> + if (!pgio->rtc_aux) {
> + dev_err(pgio->dev, "failed to add RTC consumer\n");
> + return;
> + }
> + }

LLM:

There is a teardown race with pmic_glink_gio_remove(): if remove()
runs right after init_work releases pgio->lock, remove() sets
pgio->removing = true, transitions GIO to PMIC_GIO_STATE_DOWN, and
blocks on cancel_work_sync(&pgio->init_work), while init_work
proceeds to create and probe pmic_gio.rtc during parent removal
with the transport already down.

Konrad