From: Dhatrisri Anumula <dhatrisri.anumula@mediatek.com>
To: <matthias.bgg@gmail.com>, <angelogioacchino.delregno@collabora.com>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
Shunxi Zhang <ot_shunxi.zhang@mediatek.com>,
Dhatrisri Anumula <dhatrisri.anumula@mediatek.com>
Subject: [PATCH] rtc: mt6397: Add BBPU alarm status reset and shutdown handling
Date: Tue, 26 May 2026 15:42:09 +0800 [thread overview]
Message-ID: <20260526074210.1969655-2-dhatrisri.anumula@mediatek.com> (raw)
In-Reply-To: <20260526074210.1969655-1-dhatrisri.anumula@mediatek.com>
From: Shunxi Zhang <ot_shunxi.zhang@mediatek.com>
This patch introduces a new function, mtk_rtc_reset_bbpu_alarm_status,
to reset the BBPU alarm status in the MT6397 RTC driver. This function
writes the necessary bits to the RTC_BBPU register to clear the alarm
status and ensure proper operation.
Additionally, the mtk_rtc_shutdown function is added to handle RTC
shutdown events. It resets the BBPU alarm status and updates the
RTC_IRQ_EN register to disable the one-shot alarm interrupt,
ensuring a clean shutdown process.
Signed-off-by: Shunxi Zhang <ot_shunxi.zhang@mediatek.com>
Signed-off-by: Dhatrisri Anumula <dhatrisri.anumula@mediatek.com>
---
diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index 692c00f..063bd39 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -37,6 +37,21 @@ static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)
return ret;
}
+static void mtk_rtc_reset_bbpu_alarm_status(struct mt6397_rtc *rtc)
+{
+ u32 bbpu = RTC_BBPU_KEY | RTC_BBPU_PWREN | RTC_BBPU_RESET_AL;
+ int ret;
+
+ ret = regmap_write(rtc->regmap, rtc->addr_base + RTC_BBPU, bbpu);
+ if (ret < 0) {
+ dev_err(rtc->rtc_dev->dev.parent, "%s: write rtc bbpu error\n",
+ __func__);
+ return;
+ }
+
+ mtk_rtc_write_trigger(rtc);
+}
+
static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)
{
struct mt6397_rtc *rtc = data;
@@ -51,6 +66,8 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)
if (regmap_write(rtc->regmap, rtc->addr_base + RTC_IRQ_EN,
irqen) == 0)
mtk_rtc_write_trigger(rtc);
+
+ mtk_rtc_reset_bbpu_alarm_status(rtc);
mutex_unlock(&rtc->lock);
return IRQ_HANDLED;
@@ -297,6 +314,22 @@ static int mtk_rtc_probe(struct platform_device *pdev)
return devm_rtc_register_device(rtc->rtc_dev);
}
+static void mtk_rtc_shutdown(struct platform_device *pdev)
+{
+ struct mt6397_rtc *rtc = platform_get_drvdata(pdev);
+ int ret = 0;
+
+ mtk_rtc_reset_bbpu_alarm_status(rtc);
+
+ ret = regmap_update_bits(rtc->regmap,
+ rtc->addr_base + RTC_IRQ_EN,
+ RTC_IRQ_EN_ONESHOT_AL, 0);
+ if (ret < 0)
+ return;
+
+ mtk_rtc_write_trigger(rtc);
+}
+
#ifdef CONFIG_PM_SLEEP
static int mt6397_rtc_suspend(struct device *dev)
{
@@ -345,7 +378,8 @@ static struct platform_driver mtk_rtc_driver = {
.of_match_table = mt6397_rtc_of_match,
.pm = &mt6397_pm_ops,
},
- .probe = mtk_rtc_probe,
+ .probe = mtk_rtc_probe,
+ .shutdown = mtk_rtc_shutdown,
};
module_platform_driver(mtk_rtc_driver);
next prev parent reply other threads:[~2026-05-26 7:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 7:42 [PATCH v3 0/4] rtc: mt6397: Enhance RTC driver with BBPU alarm status handling Dhatrisri Anumula
2026-05-26 7:42 ` Dhatrisri Anumula [this message]
2026-05-26 7:42 ` [PATCH] mfd: mt6397: Add new bit definitions for RTC_BBPU register Dhatrisri Anumula
-- strict thread matches above, loose matches on Subject: below --
2026-05-25 9:14 [PATCH v3 0/4] rtc: mt6397: Enhance RTC driver with BBPU alarm status handling mtk34418
2026-05-25 9:14 ` [PATCH] rtc: mt6397: Add BBPU alarm status reset and shutdown handling mtk34418
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260526074210.1969655-2-dhatrisri.anumula@mediatek.com \
--to=dhatrisri.anumula@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=ot_shunxi.zhang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®