Skip to content

Commit 015b70b

Browse files
fltoalexandrebelloni
authored andcommitted
rtc: pm8xxx: implement qcom,no-alarm flag for non-HLOS owned alarm
Qualcomm x1e80100 firmware sets the ownership of the RTC alarm to ADSP. Thus writing to RTC alarm registers and receiving alarm interrupts is not possible. Add a qcom,no-alarm flag to support RTC on this platform. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Link: https://lore.kernel.org/r/20241015004945.3676-2-jonathan@marek.ca [ johan: drop no_alarm flag and restructure probe() ] Tested-by: Jens Glathe <jens.glathe@oldschoolsolutions.biz> Tested-by: Steev Klimaszewski <steev@kali.org> Tested-by: Joel Stanley <joel@jms.id.au> Tested-by: Sebastian Reichel <sre@kernel.org> # Lenovo T14s Gen6 Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20250219134118.31017-5-johan+linaro@kernel.org Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent e853658 commit 015b70b

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

drivers/rtc/rtc-pm8xxx.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,11 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
606606
if (!rtc_dd->regmap)
607607
return -ENXIO;
608608

609-
rtc_dd->alarm_irq = platform_get_irq(pdev, 0);
610-
if (rtc_dd->alarm_irq < 0)
611-
return -ENXIO;
609+
if (!of_property_read_bool(pdev->dev.of_node, "qcom,no-alarm")) {
610+
rtc_dd->alarm_irq = platform_get_irq(pdev, 0);
611+
if (rtc_dd->alarm_irq < 0)
612+
return -ENXIO;
613+
}
612614

613615
rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node,
614616
"allow-set-time");
@@ -624,25 +626,29 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
624626

625627
platform_set_drvdata(pdev, rtc_dd);
626628

627-
devm_device_init_wakeup(&pdev->dev);
628-
629629
rtc_dd->rtc = devm_rtc_allocate_device(&pdev->dev);
630630
if (IS_ERR(rtc_dd->rtc))
631631
return PTR_ERR(rtc_dd->rtc);
632632

633633
rtc_dd->rtc->ops = &pm8xxx_rtc_ops;
634634
rtc_dd->rtc->range_max = U32_MAX;
635635

636-
rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq,
637-
pm8xxx_alarm_trigger,
638-
IRQF_TRIGGER_RISING,
639-
"pm8xxx_rtc_alarm", rtc_dd);
640-
if (rc < 0)
641-
return rc;
636+
if (rtc_dd->alarm_irq) {
637+
rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq,
638+
pm8xxx_alarm_trigger,
639+
IRQF_TRIGGER_RISING,
640+
"pm8xxx_rtc_alarm", rtc_dd);
641+
if (rc < 0)
642+
return rc;
642643

643-
rc = devm_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq);
644-
if (rc)
645-
return rc;
644+
rc = devm_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq);
645+
if (rc)
646+
return rc;
647+
648+
devm_device_init_wakeup(&pdev->dev);
649+
} else {
650+
clear_bit(RTC_FEATURE_ALARM, rtc_dd->rtc->features);
651+
}
646652

647653
return devm_rtc_register_device(rtc_dd->rtc);
648654
}

0 commit comments

Comments
 (0)