Broadcom STB wake-timer support
cover Broadcom STB wake-timer support
Hi Alexandre,
This patch series adds support for the Broadcom STB wake-timer. This is a 27Mhz timer which allows the system to exit S2/S3/S5 sleep states when configured.
The wake-timer has has a long history within our internal/downstream tree, and Brian authored it in the first place, then Markus added the rtc bits, and then I cleaned it up for upstream.
Thanks!
Brian Norris (1):
rtc: brcmstb-waketimer: Add Broadcom STB wake-timer
Florian Fainelli (1):
dt-bindings: Document the Broadcom STB wake-up timer node
.../bindings/rtc/brcm,brcmstb-waketimer.txt | 22 ++ drivers/rtc/Kconfig | 11 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-brcmstb-waketimer.c | 345 +++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.txt create mode 100644 drivers/rtc/rtc-brcmstb-waketimer.c
Signature · 1 line
2.9.3
PATCH 1/2 dt-bindings: Document the Broadcom STB wake-up timer node
Document the binding for the Broadcom STB SoCs wake-up timer node allowing the system to generate alarms and exit low power states.
--- .../bindings/rtc/brcm,brcmstb-waketimer.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.txt
Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.txt new file +22 -0
@@ -0,0 +1,22 @@ +Broadcom STB wake-up Timer + +The Broadcom STB wake-up timer provides a 27Mhz resolution timer, with the +ability to wake up the system from low-power suspend/standby modes. + +Required properties: +- compatible : should contain "brcm,brcmstb-waketimer" +- reg : the register start and length for the WKTMR block +- interrupts : The TIMER interrupt +- interrupt-parent: The phandle to the Always-On (AON) Power Management (PM) L2 + interrupt controller node +- clocks : The phandle to the UPG fixed clock (27Mhz domain) + +Example: + +waketimer at f0411580 { + compatible = "brcm,brcmstb-waketimer"; + reg = <0xf0411580 0x14>; + interrupts = <0x3>; + interrupt-parent = <&aon_pm_l2_intc>; + clocks = <&upg_fixed>; +};
Signature · 1 line
2.9.3
Re: [PATCH 1/2] dt-bindings: Document the Broadcom STB wake-up timer node
Quoted 8 lines · Florian Fainelli
Document the binding for the Broadcom STB SoCs wake-up timer node allowing the system to generate alarms and exit low power states.
Signed-off-by Florian Fainelli <[email protected]>--- .../bindings/rtc/brcm,brcmstb-waketimer.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.txt
PATCH 2/2 rtc: brcmstb-waketimer: Add Broadcom STB wake-timer
In reply to Florian FainelliFrom: Brian Norris <[email protected]>
This adds support for the Broadcom STB wake-timer which is a timer in the chip's 27Mhz clock domain that offers the ability to wake the system (wake-up source) from suspend states (S2, S3, S5). It is supported using the rtc framework allowing us to configure alarms for system wake-up.
--- drivers/rtc/Kconfig | 11 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-brcmstb-waketimer.c | 345 ++++++++++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 drivers/rtc/rtc-brcmstb-waketimer.c
drivers/rtc/Kconfig +11 -0
@@ -197,6 +197,17 @@ config RTC_DRV_AC100 This driver can also be built as a module. If so, the module will be called rtc-ac100. +config RTC_DRV_BRCMSTB + tristate "Broadcom STB wake-timer" + depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST + default ARCH_BRCMSTB || BMIPS_GENERIC + help + If you say yes here you get support for the wake-timer found on + Broadcom STB SoCs (BCM7xxx). + + This driver can also be built as a module. If so, the module will + be called rtc-brcmstb-waketimer. + config RTC_DRV_AS3722 tristate "ams AS3722 RTC driver" depends on MFD_AS3722
drivers/rtc/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o +obj-$(CONFIG_RTC_DRV_BRCMSTB) += rtc-brcmstb-waketimer.o obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
drivers/rtc/rtc-brcmstb-waketimer.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [PATCH 2/2] rtc: brcmstb-waketimer: Add Broadcom STB wake-timer
Hi,
This seems mostly good.
drivers/rtc/rtc-brcmstb-waketimer.c line 84
Quoted 5 lines · Florian Fainelli
drivers/rtc/rtc-brcmstb-waketimer.c new file +5
-0+static void wktmr_read (struct brcmstb_waketmr *timer, +struct wktmr_time *t) +{ +u32 tmp; +
To be sure, is this IP always 32bit, even on 64bit platforms?
Quoted 8 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +8
-0+do { + t->sec =readl_relaxed (timer->base +BRCMSTB_WKTMR_COUNTER ); + tmp =readl_relaxed (timer->base +BRCMSTB_WKTMR_PRESCALER_VAL ); + }while (tmp >= timer->rate); + + t->pre = timer->rate - tmp; +} +
[...]
drivers/rtc/rtc-brcmstb-waketimer.c line 148
Quoted 11 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +11
-0+static int brcmstb_waketmr_settime (struct device *dev, +struct rtc_time *tm) +{ +struct brcmstb_waketmr *timer =dev_get_drvdata (dev); +unsigned long sec; +int ret; + + ret =rtc_valid_tm (tm); +if (ret) +return ret; +
There is no way this function can be called without a valid tm. The only caller checks before calling.
Quoted 15 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +15
-0+rtc_tm_to_time (tm, &sec); + +dev_dbg (dev,"%s: sec=%ld\n" , __func__, sec); +writel_relaxed (sec, timer->base +BRCMSTB_WKTMR_COUNTER ); + +return 0 ; +} + +static int brcmstb_waketmr_getalarm (struct device *dev, +struct rtc_wkalrm *alarm) +{ +struct brcmstb_waketmr *timer =dev_get_drvdata (dev); +unsigned long sec; +u32 reg; +
drivers/rtc/rtc-brcmstb-waketimer.c line 173
Quoted 10 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +10
-0+ sec =readl_relaxed (timer->base +BRCMSTB_WKTMR_ALARM ); +if (sec ==0 ) { +/* Alarm is disabled */ + alarm->enabled =0 ; + alarm->time.tm_mon =-1 ; + alarm->time.tm_mday =-1 ; + alarm->time.tm_year =-1 ; + alarm->time.tm_hour =-1 ; + alarm->time.tm_min =-1 ; + alarm->time.tm_sec =-1 ;
This is not needed since d68778b80dd7
Quoted 14 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +14
-0+dev_dbg (dev,"%s: alarm is disabled\n" , __func__); + }else { +/* Alarm is enabled */ + alarm->enabled =1 ; +rtc_time_to_tm (sec, &alarm->time); +dev_dbg (dev,"%s: alarm is enabled\n" , __func__); + } + + reg =readl_relaxed (timer->base +BRCMSTB_WKTMR_EVENT ); + alarm->pending = !!(reg &1 ); +dev_dbg (dev,"%s: alarm pending=%d\n" , __func__, alarm->pending); + +return 0 ; +}
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] rtc: brcmstb-waketimer: Add Broadcom STB wake-timer
Quoted 4 lines · Alexandre Belloni
Hi,
This seems mostly good.
Quoted 8 lines
drivers/rtc/rtc-brcmstb-waketimer.c line 84
Quoted 5 lines · Florian Fainelli
drivers/rtc/rtc-brcmstb-waketimer.c new file +5
-0+static void wktmr_read (struct brcmstb_waketmr *timer, +struct wktmr_time *t) +{ +u32 tmp; +To be sure, is this IP always 32bit, even on 64bit platforms?
Correct, it's only 32-bit capable (saw the recent discussions about the 2038yr "problem"...).
Quoted 12 lines
Quoted 9 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +8
-0+do { + t->sec =readl_relaxed (timer->base +BRCMSTB_WKTMR_COUNTER ); + tmp =readl_relaxed (timer->base +BRCMSTB_WKTMR_PRESCALER_VAL ); + }while (tmp >= timer->rate); + + t->pre = timer->rate - tmp; +} +[...]
Quoted 14 lines
drivers/rtc/rtc-brcmstb-waketimer.c line 148
Quoted 11 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +11
-0+static int brcmstb_waketmr_settime (struct device *dev, +struct rtc_time *tm) +{ +struct brcmstb_waketmr *timer =dev_get_drvdata (dev); +unsigned long sec; +int ret; + + ret =rtc_valid_tm (tm); +if (ret) +return ret; +There is no way this function can be called without a valid tm. The only caller checks before calling.
OK.
Quoted 20 lines
Quoted 20 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +19
-0+rtc_tm_to_time (tm, &sec); + +dev_dbg (dev,"%s: sec=%ld\n" , __func__, sec); +writel_relaxed (sec, timer->base +BRCMSTB_WKTMR_COUNTER ); + +return 0 ; +} + +static int brcmstb_waketmr_getalarm (struct device *dev, +struct rtc_wkalrm *alarm) +{ +struct brcmstb_waketmr *timer =dev_get_drvdata (dev); +unsigned long sec; +u32 reg; + + sec =readl_relaxed (timer->base +BRCMSTB_WKTMR_ALARM ); +if (sec ==0 ) { +/* Alarm is disabled */ + alarm->enabled =0 ;
Quoted 8 lines
drivers/rtc/rtc-brcmstb-waketimer.c line 173
Quoted 6 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +6
-0+ alarm->time.tm_mon =-1 ; + alarm->time.tm_mday =-1 ; + alarm->time.tm_year =-1 ; + alarm->time.tm_hour =-1 ; + alarm->time.tm_min =-1 ; + alarm->time.tm_sec =-1 ;This is not needed since
d68778b80dd7
Great, I will take that out.
Do you care whether some dev_dbg() prints are left in the driver or should I remove those in v2?
Quoted 16 lines
Quoted 15 lines
drivers/rtc/rtc-brcmstb-waketimer.c new file +14
-0+dev_dbg (dev,"%s: alarm is disabled\n" , __func__); + }else { +/* Alarm is enabled */ + alarm->enabled =1 ; +rtc_time_to_tm (sec, &alarm->time); +dev_dbg (dev,"%s: alarm is enabled\n" , __func__); + } + + reg =readl_relaxed (timer->base +BRCMSTB_WKTMR_EVENT ); + alarm->pending = !!(reg &1 ); +dev_dbg (dev,"%s: alarm pending=%d\n" , __func__, alarm->pending); + +return 0 ; +}
Signature · 1 line
Florian
Re: [PATCH 2/2] rtc: brcmstb-waketimer: Add Broadcom STB wake-timer
Quoted 7 lines · Florian Fainelli
Quoted 1 line
This is not needed since
d68778b80dd7Great, I will take that out.
Do you care whether some
dev_dbg()prints are left in the driver or should I remove those in v2?
It could have stayed but it seems you removed it from v2.
I'll applay that but it is ok if you change your mind.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] rtc: brcmstb-waketimer: Add Broadcom STB wake-timer
Quoted 5 lines · Alexandre Belloni
Quoted 4 lines · Florian Fainelli
Quoted 1 line
This is not needed since
d68778b80dd7Great, I will take that out.
Quoted 7 lines
Quoted 3 lines
Do you care whether some
dev_dbg()prints are left in the driver or should I remove those in v2?It could have stayed but it seems you removed it from v2.
I'll applay that but it is ok if you change your mind.
No, I think they don't really belong in the driver anymore, thanks!
Signature · 1 line
Florian