PM: wakeup: Add routine to help fetch wakeup source object.
Subsystems (6)
PATCH v3 1/3 PM: wakeup: Add routine to help fetch wakeup source object.
Some user might want to go through all registered wakeup sources and doing things accordingly. For example, SoC PM driver might need to do HW programming to prevent powering down specific IP which wakeup source depending on. And is user's responsibility to identify if this wakeup source he is interested in.
---
Change in v3:
- Adjust indentation of *attached_dev;.
Change in v2:
- None.
drivers/base/power/wakeup.c | 18 ++++++++++++++++++ include/linux/pm_wakeup.h | 3 +++ 2 files changed, 21 insertions(+), 0 deletions(-)
drivers/base/power/wakeup.c +18 -0
@@ -14,6 +14,7 @@#include <linux/suspend.h> #include <linux/seq_file.h> #include <linux/debugfs.h> +#include <linux/of_device.h> #include <linux/pm_wakeirq.h> #include <trace/events/power.h>
@@ -226,6 +227,22 @@ void wakeup_source_unregister(struct wakeup_source *ws) } }EXPORT_SYMBOL_GPL (wakeup_source_unregister); +/** +* wakeup_source_get_next - Get next wakeup source from the list +* @ws: Previous wakeup source object, null means caller want first one. +*/ +struct wakeup_source *wakeup_source_get_next (struct wakeup_source *ws) +{ +struct list_head *ws_head = &wakeup_sources; + +if (ws) +return list_next_or_null_rcu (ws_head, &ws->entry, + struct wakeup_source, entry); +else +return list_entry_rcu (ws_head->next, + struct wakeup_source, entry); +} +EXPORT_SYMBOL_GPL (wakeup_source_get_next);/** * device_wakeup_attach - Attach a wakeup source object to a device object.
@@ -242,6 +259,7 @@ static int device_wakeup_attach(struct device *dev, struct wakeup_source *ws)return -EEXIST ; } dev->power.wakeup = ws; + ws->attached_dev = dev;if (dev->power.wakeirq)device_wakeup_attach_irq (dev, dev->power.wakeirq);spin_unlock_irq (&dev->power.lock);
include/linux/pm_wakeup.h +3 -0
@@ -50,6 +50,7 @@* @wakeup_count: Number of times the wakeup source might abort suspend. * @active: Status of the wakeup source. * @has_timeout: The wakeup source has been activated with a timeout. +* @attached_dev: The device it attached to */ struct wakeup_source {const char *name;
@@ -70,6 +71,7 @@ struct wakeup_source {unsigned long wakeup_count; bool active:1; bool autosleep_enabled:1; +struct device *attached_dev; };#ifdef CONFIG_PM_SLEEP
@@ -101,6 +103,7 @@ static inline void device_set_wakeup_path(struct device *dev)extern void wakeup_source_remove (struct wakeup_source *ws);extern struct wakeup_source *wakeup_source_register (const char *name);extern void wakeup_source_unregister (struct wakeup_source *ws); +extern struct wakeup_source *wakeup_source_get_next (struct wakeup_source *ws);extern int device_wakeup_enable (struct device *dev);extern int device_wakeup_disable (struct device *dev);extern void device_set_wakeup_capable (struct device *dev,bool capable);
Signature · 1 line
1.7.1
PATCH v3 2/3 Documentation: dt: binding: fsl: Add 'little-endian' and update Chassis define
By default, QorIQ SoC's RCPM register block is Big Endian. But there are some exceptions, such as LS1088A and LS2088A, are Little Endian. So add this optional property to help identify them.
Actually LS2021A and other Layerscapes won't totally follow Chassis 2.1, so separate them from powerpc SoC.
---
Change in v3:
- None.
Change in v2:
- None.
Documentation/devicetree/bindings/soc/fsl/rcpm.txt | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
Documentation/devicetree/bindings/soc/fsl/rcpm.txt +7 -1
@@ -20,6 +20,7 @@ Required properites: * "fsl,qoriq-rcpm-1.0": for chassis 1.0 rcpm * "fsl,qoriq-rcpm-2.0": for chassis 2.0 rcpm * "fsl,qoriq-rcpm-2.1": for chassis 2.1 rcpm + * "fsl,qoriq-rcpm-2.1+": for chassis 2.1+ rcpm All references to "1.0" and "2.0" refer to the QorIQ chassis version to which the chip complies.
@@ -27,7 +28,12 @@ Chassis Version Example Chips --------------- ------------------------------- 1.0 p4080, p5020, p5040, p2041, p3041 2.0 t4240, b4860, b4420 -2.1 t1040, ls1021 +2.1 t1040, +2.1+ ls1021a, ls1012a, ls1043a, ls1046a + +Optional properties: + - little-endian : RCPM register block is Little Endian. Without it RCPM + will be Big Endian (default case). Example: The RCPM node for T4240:
Signature · 1 line
1.7.1
PATCH v3 3/3 soc: fsl: add RCPM driver
In reply to Ran WangThe NXP's QorIQ Processors based on ARM Core have RCPM module (Run Control and Power Management), which performs all device-level tasks associated with power management such as wakeup source control.
This driver depends on PM wakeup source framework which help to collect wake information.
---
Change in v3:
- Some whitespace ajdustment.
Change in v2:
- Rebase Kconfig and Makefile update to latest mainline.
drivers/soc/fsl/Kconfig | 8 +++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/rcpm.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 0 deletions(-) create mode 100644 drivers/soc/fsl/rcpm.c
drivers/soc/fsl/Kconfig +8 -0
@@ -29,4 +29,12 @@ config FSL_MC_DPIO other DPAA2 objects. This driver does not expose the DPIO objects individually, but groups them under a service layer API. + +config FSL_RCPM + bool "Freescale RCPM support" + depends on PM_SLEEP + help + The NXP's QorIQ Processors based on ARM Core have RCPM module + (Run Control and Power Management), which performs all device-level + tasks associated with power management, such as wakeup source control. endmenu
drivers/soc/fsl/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE) += qe/ obj-$(CONFIG_CPM) += qe/ obj-$(CONFIG_FSL_GUTS) += guts.o obj-$(CONFIG_FSL_MC_DPIO) += dpio/ +obj-$(CONFIG_FSL_RCPM) += rcpm.o
drivers/soc/fsl/rcpm.c new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH v3 3/3] soc: fsl: add RCPM driver
Hi!
drivers/soc/fsl/rcpm.c line 7
Quoted 12 lines
The NXP's QorIQ Processors based on ARM Core have RCPM module (Run Control and Power Management), which performs all device-level tasks associated with power management such as wakeup source control.
This driver depends on PM wakeup source framework which help to collect wake information.
Signed-off-by Ran Wang <[email protected]>drivers/soc/fsl/rcpm.c new file +3
-0+// Copyright 2019 NXP +// +// Author: Ran Wang <[email protected]>,
extra ,
drivers/soc/fsl/rcpm.c line 39
Quoted 7 lines
drivers/soc/fsl/rcpm.c new file +7
-0+ rcpm =dev_get_drvdata (dev); +if (!rcpm) +return -EINVAL ; + +/* Begin with first registered wakeup source */ + ws =wakeup_source_get_next (NULL ); +while (ws) {
while (ws = wakeup_source_get_next(NULL))
?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
RE: [PATCH v3 3/3] soc: fsl: add RCPM driver
Hi Pavel,
Quoted 10 lines · On Monday, May 20, 2019 15:27: Pavel Machek wrote:
Hi!
Quoted 7 lines
The NXP's QorIQ Processors based on ARM Core have RCPM module (Run Control and Power Management), which performs all device-level tasks associated with power management such as wakeup source control.
This driver depends on PM wakeup source framework which help to collect wake information.
Quoted 7 lines
drivers/soc/fsl/rcpm.c line 7
Quoted 5 lines
Signed-off-by Ran Wang <[email protected]>drivers/soc/fsl/rcpm.c new file +3
-0+// Copyright 2019 NXP +// +// Author: Ran Wang <[email protected]>, extra ,
OK, will update.
Quoted 11 lines
drivers/soc/fsl/rcpm.c line 39
Quoted 7 lines
drivers/soc/fsl/rcpm.c new file +7
-0+ rcpm =dev_get_drvdata (dev); +if (!rcpm) +return -EINVAL ; + +/* Begin with first registered wakeup source */ + ws =wakeup_source_get_next (NULL ); +while (ws) {while (ws =
wakeup_source_get_next(NULL))?
I just answered this in v2 mail thread:
"Actually, we only pass NULL to wakeup_source_get_next() at very first call to get 1st wakeup source. Then in the while loop, we will fetch next source but not 1st, that's different. I am afraid your suggestion is not quite correct."
Regards
Ran