Commit 90226f6b authored by Doug Berger's avatar Doug Berger Committed by Alexandre Belloni

rtc: brcmstb-waketimer: introduce WKTMR_ALARM_EVENT flag

This commit defines bit 0 as the bit of interest within the
BRCMSTB_WKTMR_EVENT register to make the implementation more
readable.
Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230120190147.718976-2-opendmb@gmail.comSigned-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 4cd0ca1f
...@@ -34,6 +34,7 @@ struct brcmstb_waketmr { ...@@ -34,6 +34,7 @@ struct brcmstb_waketmr {
}; };
#define BRCMSTB_WKTMR_EVENT 0x00 #define BRCMSTB_WKTMR_EVENT 0x00
#define WKTMR_ALARM_EVENT BIT(0)
#define BRCMSTB_WKTMR_COUNTER 0x04 #define BRCMSTB_WKTMR_COUNTER 0x04
#define BRCMSTB_WKTMR_ALARM 0x08 #define BRCMSTB_WKTMR_ALARM 0x08
#define BRCMSTB_WKTMR_PRESCALER 0x0C #define BRCMSTB_WKTMR_PRESCALER 0x0C
...@@ -41,9 +42,17 @@ struct brcmstb_waketmr { ...@@ -41,9 +42,17 @@ struct brcmstb_waketmr {
#define BRCMSTB_WKTMR_DEFAULT_FREQ 27000000 #define BRCMSTB_WKTMR_DEFAULT_FREQ 27000000
static inline bool brcmstb_waketmr_is_pending(struct brcmstb_waketmr *timer)
{
u32 reg;
reg = readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT);
return !!(reg & WKTMR_ALARM_EVENT);
}
static inline void brcmstb_waketmr_clear_alarm(struct brcmstb_waketmr *timer) static inline void brcmstb_waketmr_clear_alarm(struct brcmstb_waketmr *timer)
{ {
writel_relaxed(1, timer->base + BRCMSTB_WKTMR_EVENT); writel_relaxed(WKTMR_ALARM_EVENT, timer->base + BRCMSTB_WKTMR_EVENT);
(void)readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT); (void)readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT);
} }
...@@ -147,7 +156,6 @@ static int brcmstb_waketmr_getalarm(struct device *dev, ...@@ -147,7 +156,6 @@ static int brcmstb_waketmr_getalarm(struct device *dev,
{ {
struct brcmstb_waketmr *timer = dev_get_drvdata(dev); struct brcmstb_waketmr *timer = dev_get_drvdata(dev);
time64_t sec; time64_t sec;
u32 reg;
sec = readl_relaxed(timer->base + BRCMSTB_WKTMR_ALARM); sec = readl_relaxed(timer->base + BRCMSTB_WKTMR_ALARM);
if (sec != 0) { if (sec != 0) {
...@@ -156,8 +164,7 @@ static int brcmstb_waketmr_getalarm(struct device *dev, ...@@ -156,8 +164,7 @@ static int brcmstb_waketmr_getalarm(struct device *dev,
rtc_time64_to_tm(sec, &alarm->time); rtc_time64_to_tm(sec, &alarm->time);
} }
reg = readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT); alarm->pending = brcmstb_waketmr_is_pending(timer);
alarm->pending = !!(reg & 1);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment