Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: loongson: clear TOY_MATCH0_REG in loongson_rtc_isr()

The TOY_MATCH0_REG should be cleared to 0 in the RTC interrupt handler,
otherwise the interrupt cannot be cleared, which will cause the
loongson_rtc_isr() to be triggered multiple times.

The previous code cleared TOY_MATCH0_REG in the loongson_rtc_handler(),
which is an ACPI interrupt. This did not prevent loongson_rtc_isr()
from being triggered multiple times.

This commit moves the clearing of TOY_MATCH0_REG to the
loongson_rtc_isr() to ensure that the interrupt is properly cleared.

Fixes: 1b733a9ebc3d ("rtc: Add rtc driver for the Loongson family chips")
Signed-off-by: Ming Wang <wangming01@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Reviewed-by: Keguang Zhang <keguang.zhang@gmail.com> # on LS1B
Tested-by: Keguang Zhang <keguang.zhang@gmail.com>
Link: https://lore.kernel.org/r/20241205114307.1891418-1-wangming01@loongson.cn
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Ming Wang and committed by
Alexandre Belloni
09471d8f 3ab8c5ed

+8 -5
+8 -5
drivers/rtc/rtc-loongson.c
··· 114 114 struct loongson_rtc_priv *priv = (struct loongson_rtc_priv *)id; 115 115 116 116 rtc_update_irq(priv->rtcdev, 1, RTC_AF | RTC_IRQF); 117 + 118 + /* 119 + * The TOY_MATCH0_REG should be cleared 0 here, 120 + * otherwise the interrupt cannot be cleared. 121 + */ 122 + regmap_write(priv->regmap, TOY_MATCH0_REG, 0); 123 + 117 124 return IRQ_HANDLED; 118 125 } 119 126 ··· 138 131 writel(RTC_STS, priv->pm_base + PM1_STS_REG); 139 132 spin_unlock(&priv->lock); 140 133 141 - /* 142 - * The TOY_MATCH0_REG should be cleared 0 here, 143 - * otherwise the interrupt cannot be cleared. 144 - */ 145 - return regmap_write(priv->regmap, TOY_MATCH0_REG, 0); 134 + return ACPI_INTERRUPT_HANDLED; 146 135 } 147 136 148 137 static int loongson_rtc_set_enabled(struct device *dev)