PM: wakeup: Add routine to help fetch wakeup source object.
Subsystems (6)
PATCH v2 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 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 v2 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 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 v2 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 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 V2 3/3] soc: fsl: add RCPM driver
Hi!
drivers/soc/fsl/rcpm.c line 23
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+ +struct rcpm { +unsigned int wakeup_cells; +void __iomem *ippdexpcr_base; +bool little_endian; +};
Inconsistent whitespace
Quoted 5 lines
drivers/soc/fsl/rcpm.c new file +5
-0+static int rcpm_pm_prepare (struct device *dev) +{ +struct device_node *np = dev->of_node; +struct wakeup_source *ws; +struct rcpm *rcpm;
drivers/soc/fsl/rcpm.c line 39
Quoted 10 lines
drivers/soc/fsl/rcpm.c new file +10
-0+u32 value[RCPM_WAKEUP_CELL_MAX_SIZE +1 ], tmp; +int i, ret; + + 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)) ?
drivers/soc/fsl/rcpm.c line 80
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+static int rcpm_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct resource *r; +struct rcpm *rcpm; +int ret;
Whitespace.
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 V2 3/3] soc: fsl: add RCPM driver
Hi Pavel,
Quoted 4 lines · Pavel Machek
Hi!
Quoted 8 lines
drivers/soc/fsl/rcpm.c line 23
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+ +struct rcpm { +unsigned int wakeup_cells; +void __iomem *ippdexpcr_base; +bool little_endian; +};Inconsistent whitespace
OK, will make them aligned.
Quoted 17 lines
Quoted 5 lines
drivers/soc/fsl/rcpm.c new file +4
-0+static int rcpm_pm_prepare (struct device *dev) { +struct device_node *np = dev->of_node; +struct wakeup_source *ws; +struct rcpm *rcpm;drivers/soc/fsl/rcpm.c line 39
Quoted 10 lines
drivers/soc/fsl/rcpm.c new file +10
-0+u32 value[RCPM_WAKEUP_CELL_MAX_SIZE +1 ], tmp; +int i, ret; + + 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)) ?
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.
Quoted 8 lines
drivers/soc/fsl/rcpm.c line 80
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +5
-0+static int rcpm_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev; +struct resource *r; +struct rcpm *rcpm; +int ret;Whitespace.
OK, will update, thanks for your review.
Regards,
Ran
Re: [PATCH V2 3/3] soc: fsl: add RCPM driver
Hi!
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/soc/fsl/rcpm.c new file +8
-0+static int rcpm_pm_prepare (struct device *dev) { +struct device_node *np = dev->of_node; +struct wakeup_source *ws; +struct rcpm *rcpm; +u32 value[RCPM_WAKEUP_CELL_MAX_SIZE +1 ], tmp; +int i, ret; + + rcpm =dev_get_drvdata (dev);Quoted 8 lines
drivers/soc/fsl/rcpm.c line 39
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+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)) ?
Quoted 4 lines
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.
Sorry, I seen your next version before seeing this explanation.
You are right, but the current code is "interesting". What about
ws = NULL;
while (ws = wakeup_source_get_next(NULL)) ...
then?
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
RE: [PATCH V2 3/3] soc: fsl: add RCPM driver
Hi Pavel,
Quoted 25 lines · Pavel Machek
Hi!
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/soc/fsl/rcpm.c new file +8
-0+static int rcpm_pm_prepare (struct device *dev) { +struct device_node *np = dev->of_node; +struct wakeup_source *ws; +struct rcpm *rcpm; +u32 value[RCPM_WAKEUP_CELL_MAX_SIZE +1 ], tmp; +int i, ret; + + rcpm =dev_get_drvdata (dev);Quoted 8 lines
drivers/soc/fsl/rcpm.c line 39
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+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)) ?Quoted 4 lines
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.
Quoted 8 lines
Sorry, I seen your next version before seeing this explanation.
You are right, but the current code is "interesting". What about
ws = NULL;
while (ws =wakeup_source_get_next(NULL)) ...then?
Did you mean:
ws = NULL;
while (ws = wakeup_source_get_next(ws)) ... Yes, that will be the same to my original logic, do you recommend to change
to this? :)
Regards,
Ran
Re: [PATCH V2 3/3] soc: fsl: add RCPM driver
Quoted 35 lines · Ran Wang
Hi Pavel,
Quoted 32 lines · Pavel Machek
Hi!
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/soc/fsl/rcpm.c new file +8
-0+static int rcpm_pm_prepare (struct device *dev) { +struct device_node *np = dev->of_node; +struct wakeup_source *ws; +struct rcpm *rcpm; +u32 value[RCPM_WAKEUP_CELL_MAX_SIZE +1 ], tmp; +int i, ret; + + rcpm =dev_get_drvdata (dev);Quoted 8 lines
drivers/soc/fsl/rcpm.c line 39
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+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)) ?Quoted 4 lines
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.Sorry, I seen your next version before seeing this explanation.
You are right, but the current code is "interesting". What about
ws = NULL;
while (ws =wakeup_source_get_next(NULL)) ...
Quoted 8 lines
Quoted 1 line
then?
Did you mean:
ws = NULL; while (ws = wakeup_source_get_next(ws)) ...Yes, that will be the same to my original logic, do you recommend to change
to this? :)
Yes please. It will be less confusing to the reader.
Thanks (and sorry for cross-talk),
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
RE: [PATCH V2 3/3] soc: fsl: add RCPM driver
Hi Pavel,
Quoted 33 lines · On Monday, May 20, 2019 17:08 Pavel Machek wrote:
Quoted 33 lines
Quoted 32 lines
Hi!
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/soc/fsl/rcpm.c new file +8
-0+static int rcpm_pm_prepare (struct device *dev) { +struct device_node *np = dev->of_node; +struct wakeup_source *ws; +struct rcpm *rcpm; +u32 value[RCPM_WAKEUP_CELL_MAX_SIZE +1 ], tmp; +int i, ret; + + rcpm =dev_get_drvdata (dev);Quoted 8 lines
drivers/soc/fsl/rcpm.c line 39
Quoted 6 lines
drivers/soc/fsl/rcpm.c new file +6
-0+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)) ?Quoted 4 lines
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.Sorry, I seen your next version before seeing this explanation.
You are right, but the current code is "interesting". What about
ws = NULL;
while (ws =wakeup_source_get_next(NULL)) ...then?
Quoted 8 lines
Quoted 6 lines
Did you mean:
ws = NULL; while (ws = wakeup_source_get_next(ws)) ...Yes, that will be the same to my original logic, do you recommend
to change to this? :)Yes please. It will be less confusing to the reader.
OK, if no other comment, I will work out v4, fix this and extra ','
Quoted 1 line
Thanks (and sorry for cross-talk),
That's OK, thanks for your time.
Regards,
Ran
Pavel Machek
Acked-byRe: [PATCH V2 3/3] soc: fsl: add RCPM driver
Hi!
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 6 lines
You are right, but the current code is "interesting". What about
ws = NULL;
while (ws =wakeup_source_get_next(NULL)) ...then?
Did you mean:
ws = NULL; while (ws = wakeup_source_get_next(ws)) ...Yes, that will be the same to my original logic, do you recommend
to change to this? :)
Quoted 7 lines
Quoted 1 line
Yes please. It will be less confusing to the reader.
OK, if no other comment, I will work out v4, fix this and extra ','
Quoted 1 line
Thanks (and sorry for cross-talk),
That's OK, thanks for your time.
You can add
to that version.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
include/linux/pm_wakeup.h struct wakeup_source { · line 77
Quoted 11 lines
---
a/include/linux/pm_wakeup.hinclude/linux/pm_wakeup.h +1
-0@@ -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
You might want to format this similary to the rest...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi Pavel,
Quoted 10 lines · Pavel Machek
Quoted 10 lines
---
a/include/linux/pm_wakeup.hinclude/linux/pm_wakeup.h +1
-0@@ -70,6 +71,7 @@ struct wakeup_source {unsigned long wakeup_count; bool active:1; bool autosleep_enabled:1; +struct device *attached_dev; };
Quoted 3 lines
include/linux/pm_wakeup.h struct wakeup_source { · line 77
Quoted 1 line
include/linux/pm_wakeup.h +0
-0#ifdef CONFIG_PM_SLEEP You might want to format this similary to the rest...
OK, will update, thanks.
Regards,
Ran