All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-08-31  3:52 ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-08-31  3:52 UTC (permalink / raw)
  To: Leo Li, Rob Herring, Mark Rutland
  Cc: linuxppc-dev, linux-arm-kernel, devicetree, linux-kernel, Ran Wang

This driver is to provide a independent framework for PM service
provider and consumer to configure system level wake up feature. For
example, RCPM driver could register a callback function on this
platform first, and Flex timer driver who want to enable timer wake
up feature, will call generic API provided by this platform driver,
and then it will trigger RCPM driver to do it. The benefit is to
isolate the user and service, such as flex timer driver will not have
to know the implement details of wakeup function it require. Besides,
it is also easy for service side to upgrade its logic when design is
changed and remain user side unchanged.

Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 drivers/soc/fsl/Kconfig   |   14 +++++
 drivers/soc/fsl/Makefile  |    1 +
 drivers/soc/fsl/plat_pm.c |  144 +++++++++++++++++++++++++++++++++++++++++++++
 include/soc/fsl/plat_pm.h |   22 +++++++
 4 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100644 drivers/soc/fsl/plat_pm.c
 create mode 100644 include/soc/fsl/plat_pm.h

diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
index 7a9fb9b..6517412 100644
--- a/drivers/soc/fsl/Kconfig
+++ b/drivers/soc/fsl/Kconfig
@@ -16,3 +16,17 @@ config FSL_GUTS
 	  Initially only reading SVR and registering soc device are supported.
 	  Other guts accesses, such as reading RCW, should eventually be moved
 	  into this driver as well.
+
+config FSL_PLAT_PM
+	bool "Freescale platform PM framework"
+	help
+	  This driver is to provide a independent framework for PM service
+	  provider and consumer to configure system level wake up feature. For
+	  example, RCPM driver could register a callback function on this
+	  platform first, and Flex timer driver who want to enable timer wake
+	  up feature, will call generic API provided by this platform driver,
+	  and then it will trigger RCPM driver to do it. The benefit is to
+	  isolate the user and service, such as  flex timer driver will not
+	  have to know the implement details of wakeup function it require.
+	  Besides, it is also easy for service side to upgrade its logic when
+	  design changed and remain user side unchanged.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 44b3beb..8f9db23 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
 obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
 obj-$(CONFIG_FSL_GUTS)			+= guts.o
+obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
new file mode 100644
index 0000000..19ea14e
--- /dev/null
+++ b/drivers/soc/fsl/plat_pm.c
@@ -0,0 +1,144 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// plat_pm.c - Freescale platform PM framework
+//
+// Copyright 2018 NXP
+//
+// Author: Ran Wang <ran.wang_1@nxp.com>,
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <soc/fsl/plat_pm.h>
+
+
+struct plat_pm_t {
+	struct list_head node;
+	fsl_plat_pm_handle handle;
+	void *handle_priv;
+	spinlock_t	lock;
+};
+
+static struct plat_pm_t plat_pm;
+
+// register_fsl_platform_wakeup_source - Register callback function to plat_pm
+// @handle: Pointer to handle PM feature requirement
+// @handle_priv: Handler specific data struct
+//
+// Return 0 on success other negative errno
+int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
+		void *handle_priv)
+{
+	struct plat_pm_t *p;
+	unsigned long	flags;
+
+	if (!handle) {
+		pr_err("FSL plat_pm: Handler invalid, reject\n");
+		return -EINVAL;
+	}
+
+	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	p->handle = handle;
+	p->handle_priv = handle_priv;
+
+	spin_lock_irqsave(&plat_pm.lock, flags);
+	list_add_tail(&p->node, &plat_pm.node);
+	spin_unlock_irqrestore(&plat_pm.lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
+
+// Deregister_fsl_platform_wakeup_source - deregister callback function
+// @handle_priv: Handler specific data struct
+//
+// Return 0 on success other negative errno
+int deregister_fsl_platform_wakeup_source(void *handle_priv)
+{
+	struct plat_pm_t *p, *tmp;
+	unsigned long	flags;
+
+	spin_lock_irqsave(&plat_pm.lock, flags);
+	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
+		if (p->handle_priv == handle_priv) {
+			list_del(&p->node);
+			kfree(p);
+		}
+	}
+	spin_unlock_irqrestore(&plat_pm.lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
+
+// fsl_platform_wakeup_config - Configure wakeup source by calling handlers
+// @dev: pointer to user's device struct
+// @flag: to tell enable or disable wakeup source
+//
+// Return 0 on success other negative errno
+int fsl_platform_wakeup_config(struct device *dev, bool flag)
+{
+	struct plat_pm_t *p;
+	int ret;
+	bool success_handled;
+	unsigned long	flags;
+
+	success_handled = false;
+
+	// Will consider success if at least one callback return 0.
+	// Also, rest handles still get oppertunity to be executed
+	spin_lock_irqsave(&plat_pm.lock, flags);
+	list_for_each_entry(p, &plat_pm.node, node) {
+		if (p->handle) {
+			ret = p->handle(dev, flag, p->handle_priv);
+			if (!ret)
+				success_handled = true;
+			else if (ret != -ENODEV) {
+				pr_err("FSL plat_pm: Failed to config wakeup source:%d\n", ret);
+				return ret;
+			}
+		} else
+			pr_warn("FSL plat_pm: Invalid handler detected, skip\n");
+	}
+	spin_unlock_irqrestore(&plat_pm.lock, flags);
+
+	if (success_handled == false) {
+		pr_err("FSL plat_pm: Cannot find the matchhed handler for wakeup source config\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+// fsl_platform_wakeup_enable - Enable wakeup source
+// @dev: pointer to user's device struct
+//
+// Return 0 on success other negative errno
+int fsl_platform_wakeup_enable(struct device *dev)
+{
+	return fsl_platform_wakeup_config(dev, true);
+}
+EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
+
+// fsl_platform_wakeup_disable - Disable wakeup source
+// @dev: pointer to user's device struct
+//
+// Return 0 on success other negative errno
+int fsl_platform_wakeup_disable(struct device *dev)
+{
+	return fsl_platform_wakeup_config(dev, false);
+}
+EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
+
+static int __init fsl_plat_pm_init(void)
+{
+	spin_lock_init(&plat_pm.lock);
+	INIT_LIST_HEAD(&plat_pm.node);
+	return 0;
+}
+
+core_initcall(fsl_plat_pm_init);
diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
new file mode 100644
index 0000000..bbe151e
--- /dev/null
+++ b/include/soc/fsl/plat_pm.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// plat_pm.h - Freescale platform PM Header
+//
+// Copyright 2018 NXP
+//
+// Author: Ran Wang <ran.wang_1@nxp.com>,
+
+#ifndef __FSL_PLAT_PM_H
+#define __FSL_PLAT_PM_H
+
+typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
+		void *handle_priv);
+
+int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
+		void *handle_priv);
+int deregister_fsl_platform_wakeup_source(void *handle_priv);
+int fsl_platform_wakeup_config(struct device *dev, bool flag);
+int fsl_platform_wakeup_enable(struct device *dev);
+int fsl_platform_wakeup_disable(struct device *dev);
+
+#endif	// __FSL_PLAT_PM_H
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-08-31  3:52 ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-08-31  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

This driver is to provide a independent framework for PM service
provider and consumer to configure system level wake up feature. For
example, RCPM driver could register a callback function on this
platform first, and Flex timer driver who want to enable timer wake
up feature, will call generic API provided by this platform driver,
and then it will trigger RCPM driver to do it. The benefit is to
isolate the user and service, such as flex timer driver will not have
to know the implement details of wakeup function it require. Besides,
it is also easy for service side to upgrade its logic when design is
changed and remain user side unchanged.

Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 drivers/soc/fsl/Kconfig   |   14 +++++
 drivers/soc/fsl/Makefile  |    1 +
 drivers/soc/fsl/plat_pm.c |  144 +++++++++++++++++++++++++++++++++++++++++++++
 include/soc/fsl/plat_pm.h |   22 +++++++
 4 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100644 drivers/soc/fsl/plat_pm.c
 create mode 100644 include/soc/fsl/plat_pm.h

diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
index 7a9fb9b..6517412 100644
--- a/drivers/soc/fsl/Kconfig
+++ b/drivers/soc/fsl/Kconfig
@@ -16,3 +16,17 @@ config FSL_GUTS
 	  Initially only reading SVR and registering soc device are supported.
 	  Other guts accesses, such as reading RCW, should eventually be moved
 	  into this driver as well.
+
+config FSL_PLAT_PM
+	bool "Freescale platform PM framework"
+	help
+	  This driver is to provide a independent framework for PM service
+	  provider and consumer to configure system level wake up feature. For
+	  example, RCPM driver could register a callback function on this
+	  platform first, and Flex timer driver who want to enable timer wake
+	  up feature, will call generic API provided by this platform driver,
+	  and then it will trigger RCPM driver to do it. The benefit is to
+	  isolate the user and service, such as  flex timer driver will not
+	  have to know the implement details of wakeup function it require.
+	  Besides, it is also easy for service side to upgrade its logic when
+	  design changed and remain user side unchanged.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 44b3beb..8f9db23 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
 obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
 obj-$(CONFIG_FSL_GUTS)			+= guts.o
+obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
new file mode 100644
index 0000000..19ea14e
--- /dev/null
+++ b/drivers/soc/fsl/plat_pm.c
@@ -0,0 +1,144 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// plat_pm.c - Freescale platform PM framework
+//
+// Copyright 2018 NXP
+//
+// Author: Ran Wang <ran.wang_1@nxp.com>,
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <soc/fsl/plat_pm.h>
+
+
+struct plat_pm_t {
+	struct list_head node;
+	fsl_plat_pm_handle handle;
+	void *handle_priv;
+	spinlock_t	lock;
+};
+
+static struct plat_pm_t plat_pm;
+
+// register_fsl_platform_wakeup_source - Register callback function to plat_pm
+// @handle: Pointer to handle PM feature requirement
+// @handle_priv: Handler specific data struct
+//
+// Return 0 on success other negative errno
+int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
+		void *handle_priv)
+{
+	struct plat_pm_t *p;
+	unsigned long	flags;
+
+	if (!handle) {
+		pr_err("FSL plat_pm: Handler invalid, reject\n");
+		return -EINVAL;
+	}
+
+	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	p->handle = handle;
+	p->handle_priv = handle_priv;
+
+	spin_lock_irqsave(&plat_pm.lock, flags);
+	list_add_tail(&p->node, &plat_pm.node);
+	spin_unlock_irqrestore(&plat_pm.lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
+
+// Deregister_fsl_platform_wakeup_source - deregister callback function
+// @handle_priv: Handler specific data struct
+//
+// Return 0 on success other negative errno
+int deregister_fsl_platform_wakeup_source(void *handle_priv)
+{
+	struct plat_pm_t *p, *tmp;
+	unsigned long	flags;
+
+	spin_lock_irqsave(&plat_pm.lock, flags);
+	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
+		if (p->handle_priv == handle_priv) {
+			list_del(&p->node);
+			kfree(p);
+		}
+	}
+	spin_unlock_irqrestore(&plat_pm.lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
+
+// fsl_platform_wakeup_config - Configure wakeup source by calling handlers
+// @dev: pointer to user's device struct
+// @flag: to tell enable or disable wakeup source
+//
+// Return 0 on success other negative errno
+int fsl_platform_wakeup_config(struct device *dev, bool flag)
+{
+	struct plat_pm_t *p;
+	int ret;
+	bool success_handled;
+	unsigned long	flags;
+
+	success_handled = false;
+
+	// Will consider success if at least one callback return 0.
+	// Also, rest handles still get oppertunity to be executed
+	spin_lock_irqsave(&plat_pm.lock, flags);
+	list_for_each_entry(p, &plat_pm.node, node) {
+		if (p->handle) {
+			ret = p->handle(dev, flag, p->handle_priv);
+			if (!ret)
+				success_handled = true;
+			else if (ret != -ENODEV) {
+				pr_err("FSL plat_pm: Failed to config wakeup source:%d\n", ret);
+				return ret;
+			}
+		} else
+			pr_warn("FSL plat_pm: Invalid handler detected, skip\n");
+	}
+	spin_unlock_irqrestore(&plat_pm.lock, flags);
+
+	if (success_handled == false) {
+		pr_err("FSL plat_pm: Cannot find the matchhed handler for wakeup source config\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+// fsl_platform_wakeup_enable - Enable wakeup source
+// @dev: pointer to user's device struct
+//
+// Return 0 on success other negative errno
+int fsl_platform_wakeup_enable(struct device *dev)
+{
+	return fsl_platform_wakeup_config(dev, true);
+}
+EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
+
+// fsl_platform_wakeup_disable - Disable wakeup source
+// @dev: pointer to user's device struct
+//
+// Return 0 on success other negative errno
+int fsl_platform_wakeup_disable(struct device *dev)
+{
+	return fsl_platform_wakeup_config(dev, false);
+}
+EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
+
+static int __init fsl_plat_pm_init(void)
+{
+	spin_lock_init(&plat_pm.lock);
+	INIT_LIST_HEAD(&plat_pm.node);
+	return 0;
+}
+
+core_initcall(fsl_plat_pm_init);
diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
new file mode 100644
index 0000000..bbe151e
--- /dev/null
+++ b/include/soc/fsl/plat_pm.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// plat_pm.h - Freescale platform PM Header
+//
+// Copyright 2018 NXP
+//
+// Author: Ran Wang <ran.wang_1@nxp.com>,
+
+#ifndef __FSL_PLAT_PM_H
+#define __FSL_PLAT_PM_H
+
+typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
+		void *handle_priv);
+
+int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
+		void *handle_priv);
+int deregister_fsl_platform_wakeup_source(void *handle_priv);
+int fsl_platform_wakeup_config(struct device *dev, bool flag);
+int fsl_platform_wakeup_enable(struct device *dev);
+int fsl_platform_wakeup_disable(struct device *dev);
+
+#endif	// __FSL_PLAT_PM_H
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
  2018-08-31  3:52 ` Ran Wang
@ 2018-08-31  3:52   ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-08-31  3:52 UTC (permalink / raw)
  To: Leo Li, Rob Herring, Mark Rutland
  Cc: linuxppc-dev, linux-arm-kernel, devicetree, linux-kernel, Ran Wang

Add property 'big-endian' and supportted IP's configuration info.
Remove property 'fsl,#rcpm-wakeup-cell'.

Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-------------
 1 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/fsl/rcpm.txt b/Documentation/devicetree/bindings/soc/fsl/rcpm.txt
index e284e4e..7fc630a 100644
--- a/Documentation/devicetree/bindings/soc/fsl/rcpm.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/rcpm.txt
@@ -5,8 +5,6 @@ and power management.
 
 Required properites:
   - reg : Offset and length of the register set of the RCPM block.
-  - fsl,#rcpm-wakeup-cells : The number of IPPDEXPCR register cells in the
-	fsl,rcpm-wakeup property.
   - compatible : Must contain a chip-specific RCPM block compatible string
 	and (if applicable) may contain a chassis-version RCPM compatible
 	string. Chip-specific strings are of the form "fsl,<chip>-rcpm",
@@ -27,37 +25,23 @@ Chassis Version		Example Chips
 ---------------		-------------------------------
 1.0				p4080, p5020, p5040, p2041, p3041
 2.0				t4240, b4860, b4420
-2.1				t1040, ls1021
+2.1				t1040, ls1021, ls1012
+
+Optional properties:
+ - big-endian : Indicate RCPM registers is big-endian. A RCPM node
+   that doesn't have this property will be regarded as little-endian.
+ - <property 'compatible' string of consumer device> : This string
+   is referred by RCPM driver to judge if the consumer (such as flex timer)
+   is able to be regards as wakeup source or not, such as 'fsl,ls1012a-ftm'.
+   Further, this property will carry the bit mask info to control
+   coresponding wake up source.
 
 Example:
 The RCPM node for T4240:
 	rcpm: global-utilities@e2000 {
 		compatible = "fsl,t4240-rcpm", "fsl,qoriq-rcpm-2.0";
 		reg = <0xe2000 0x1000>;
-		fsl,#rcpm-wakeup-cells = <2>;
-	};
-
-* Freescale RCPM Wakeup Source Device Tree Bindings
--------------------------------------------
-Required fsl,rcpm-wakeup property should be added to a device node if the device
-can be used as a wakeup source.
-
-  - fsl,rcpm-wakeup: Consists of a phandle to the rcpm node and the IPPDEXPCR
-	register cells. The number of IPPDEXPCR register cells is defined in
-	"fsl,#rcpm-wakeup-cells" in the rcpm node. The first register cell is
-	the bit mask that should be set in IPPDEXPCR0, and the second register
-	cell is for IPPDEXPCR1, and so on.
-
-	Note: IPPDEXPCR(IP Powerdown Exception Control Register) provides a
-	mechanism for keeping certain blocks awake during STANDBY and MEM, in
-	order to use them as wake-up sources.
-
-Example:
-	lpuart0: serial@2950000 {
-		compatible = "fsl,ls1021a-lpuart";
-		reg = <0x0 0x2950000 0x0 0x1000>;
-		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
-		clocks = <&sysclk>;
-		clock-names = "ipg";
-		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
+		big-endian;
+		fsl,ls1012a-ftm = <0x20000>;
+		fsl,pfe = <0xf0000020>;
 	};
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-08-31  3:52   ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-08-31  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

Add property 'big-endian' and supportted IP's configuration info.
Remove property 'fsl,#rcpm-wakeup-cell'.

Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-------------
 1 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/fsl/rcpm.txt b/Documentation/devicetree/bindings/soc/fsl/rcpm.txt
index e284e4e..7fc630a 100644
--- a/Documentation/devicetree/bindings/soc/fsl/rcpm.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/rcpm.txt
@@ -5,8 +5,6 @@ and power management.
 
 Required properites:
   - reg : Offset and length of the register set of the RCPM block.
-  - fsl,#rcpm-wakeup-cells : The number of IPPDEXPCR register cells in the
-	fsl,rcpm-wakeup property.
   - compatible : Must contain a chip-specific RCPM block compatible string
 	and (if applicable) may contain a chassis-version RCPM compatible
 	string. Chip-specific strings are of the form "fsl,<chip>-rcpm",
@@ -27,37 +25,23 @@ Chassis Version		Example Chips
 ---------------		-------------------------------
 1.0				p4080, p5020, p5040, p2041, p3041
 2.0				t4240, b4860, b4420
-2.1				t1040, ls1021
+2.1				t1040, ls1021, ls1012
+
+Optional properties:
+ - big-endian : Indicate RCPM registers is big-endian. A RCPM node
+   that doesn't have this property will be regarded as little-endian.
+ - <property 'compatible' string of consumer device> : This string
+   is referred by RCPM driver to judge if the consumer (such as flex timer)
+   is able to be regards as wakeup source or not, such as 'fsl,ls1012a-ftm'.
+   Further, this property will carry the bit mask info to control
+   coresponding wake up source.
 
 Example:
 The RCPM node for T4240:
 	rcpm: global-utilities at e2000 {
 		compatible = "fsl,t4240-rcpm", "fsl,qoriq-rcpm-2.0";
 		reg = <0xe2000 0x1000>;
-		fsl,#rcpm-wakeup-cells = <2>;
-	};
-
-* Freescale RCPM Wakeup Source Device Tree Bindings
--------------------------------------------
-Required fsl,rcpm-wakeup property should be added to a device node if the device
-can be used as a wakeup source.
-
-  - fsl,rcpm-wakeup: Consists of a phandle to the rcpm node and the IPPDEXPCR
-	register cells. The number of IPPDEXPCR register cells is defined in
-	"fsl,#rcpm-wakeup-cells" in the rcpm node. The first register cell is
-	the bit mask that should be set in IPPDEXPCR0, and the second register
-	cell is for IPPDEXPCR1, and so on.
-
-	Note: IPPDEXPCR(IP Powerdown Exception Control Register) provides a
-	mechanism for keeping certain blocks awake during STANDBY and MEM, in
-	order to use them as wake-up sources.
-
-Example:
-	lpuart0: serial at 2950000 {
-		compatible = "fsl,ls1021a-lpuart";
-		reg = <0x0 0x2950000 0x0 0x1000>;
-		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
-		clocks = <&sysclk>;
-		clock-names = "ipg";
-		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
+		big-endian;
+		fsl,ls1012a-ftm = <0x20000>;
+		fsl,pfe = <0xf0000020>;
 	};
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
  2018-08-31  3:52 ` Ran Wang
@ 2018-08-31  3:52   ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-08-31  3:52 UTC (permalink / raw)
  To: Leo Li, Rob Herring, Mark Rutland
  Cc: linuxppc-dev, linux-arm-kernel, devicetree, linux-kernel, Ran Wang

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 FSL platform PM driver framework which help to
isolate user and PM service provider (such as RCPM driver).

Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 drivers/soc/fsl/Kconfig   |    6 ++
 drivers/soc/fsl/Makefile  |    1 +
 drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+), 0 deletions(-)
 create mode 100644 drivers/soc/fsl/ls-rcpm.c

diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
index 6517412..882330d 100644
--- a/drivers/soc/fsl/Kconfig
+++ b/drivers/soc/fsl/Kconfig
@@ -30,3 +30,9 @@ config FSL_PLAT_PM
 	  have to know the implement details of wakeup function it require.
 	  Besides, it is also easy for service side to upgrade its logic when
 	  design changed and remain user side unchanged.
+
+config LS_RCPM
+	bool "Freescale RCPM support"
+	depends on (FSL_PLAT_PM)
+	help
+	  This feature is to enable specified wakeup source for system sleep.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 8f9db23..43ff71a 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
 obj-$(CONFIG_FSL_GUTS)			+= guts.o
 obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
+obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
new file mode 100644
index 0000000..b0feb88
--- /dev/null
+++ b/drivers/soc/fsl/ls-rcpm.c
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// plat_pm.c - Freescale Layerscape RCPM driver
+//
+// Copyright 2018 NXP
+//
+// Author: Ran Wang <ran.wang_1@nxp.com>,
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of_address.h>
+#include <linux/slab.h>
+#include <soc/fsl/plat_pm.h>
+
+#define MAX_COMPATIBLE_NUM	10
+
+struct rcpm_t {
+	struct device *dev;
+	void __iomem *ippdexpcr_addr;
+	bool big_endian;	/* Big/Little endian of RCPM module */
+};
+
+// rcpm_handle - Configure RCPM reg according to wake up source request
+// @user_dev: pointer to user's device struct
+// @flag: to enable(true) or disable(false) wakeup source
+// @handle_priv: pointer to struct rcpm_t instance
+//
+// Return 0 on success other negative errno
+static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
+{
+	struct rcpm_t *rcpm;
+	bool big_endian;
+	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
+	void __iomem *ippdexpcr_addr;
+	u32 ippdexpcr;
+	u32 set_bit;
+	int ret, num, i;
+
+	rcpm = handle_priv;
+	big_endian = rcpm->big_endian;
+	ippdexpcr_addr = rcpm->ippdexpcr_addr;
+
+	num = device_property_read_string_array(user_dev, "compatible",
+			dev_compatible_array, MAX_COMPATIBLE_NUM);
+	if (num < 0)
+		return num;
+
+	for (i = 0; i < num; i++) {
+		if (!device_property_present(rcpm->dev,
+					dev_compatible_array[i]))
+			continue;
+		else {
+			ret = device_property_read_u32(rcpm->dev,
+					dev_compatible_array[i], &set_bit);
+			if (ret)
+				return ret;
+
+			if (!device_property_present(rcpm->dev,
+						dev_compatible_array[i]))
+				return -ENODEV;
+			else {
+				ret = device_property_read_u32(rcpm->dev,
+						dev_compatible_array[i], &set_bit);
+				if (ret)
+					return ret;
+
+				if (big_endian)
+					ippdexpcr = ioread32be(ippdexpcr_addr);
+				else
+					ippdexpcr = ioread32(ippdexpcr_addr);
+
+				if (flag)
+					ippdexpcr |= set_bit;
+				else
+					ippdexpcr &= ~set_bit;
+
+				if (big_endian) {
+					iowrite32be(ippdexpcr, ippdexpcr_addr);
+					ippdexpcr = ioread32be(ippdexpcr_addr);
+				} else
+					iowrite32(ippdexpcr, ippdexpcr_addr);
+
+				return 0;
+			}
+		}
+	}
+
+	return -ENODEV;
+}
+
+static int ls_rcpm_probe(struct platform_device *pdev)
+{
+	struct resource *r;
+	struct rcpm_t *rcpm;
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;
+
+	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
+	if (!rcpm)
+		return -ENOMEM;
+
+	rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
+
+	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(rcpm->ippdexpcr_addr))
+		return PTR_ERR(rcpm->ippdexpcr_addr);
+
+	rcpm->dev = &pdev->dev;
+	platform_set_drvdata(pdev, rcpm);
+
+	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
+}
+
+static int ls_rcpm_remove(struct platform_device *pdev)
+{
+	struct rcpm_t	*rcpm;
+
+	rcpm = platform_get_drvdata(pdev);
+	deregister_fsl_platform_wakeup_source(rcpm);
+	kfree(rcpm);
+
+	return 0;
+}
+
+static const struct of_device_id ls_rcpm_of_match[] = {
+	{ .compatible = "fsl,qoriq-rcpm-2.1", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
+
+static struct platform_driver ls_rcpm_driver = {
+	.driver = {
+		.name = "ls-rcpm",
+		.of_match_table = ls_rcpm_of_match,
+	},
+	.probe = ls_rcpm_probe,
+	.remove = ls_rcpm_remove,
+};
+
+static int __init ls_rcpm_init(void)
+{
+	return platform_driver_register(&ls_rcpm_driver);
+}
+subsys_initcall(ls_rcpm_init);
+
+static void __exit ls_rcpm_exit(void)
+{
+	platform_driver_unregister(&ls_rcpm_driver);
+}
+module_exit(ls_rcpm_exit);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-08-31  3:52   ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-08-31  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

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 FSL platform PM driver framework which help to
isolate user and PM service provider (such as RCPM driver).

Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 drivers/soc/fsl/Kconfig   |    6 ++
 drivers/soc/fsl/Makefile  |    1 +
 drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+), 0 deletions(-)
 create mode 100644 drivers/soc/fsl/ls-rcpm.c

diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
index 6517412..882330d 100644
--- a/drivers/soc/fsl/Kconfig
+++ b/drivers/soc/fsl/Kconfig
@@ -30,3 +30,9 @@ config FSL_PLAT_PM
 	  have to know the implement details of wakeup function it require.
 	  Besides, it is also easy for service side to upgrade its logic when
 	  design changed and remain user side unchanged.
+
+config LS_RCPM
+	bool "Freescale RCPM support"
+	depends on (FSL_PLAT_PM)
+	help
+	  This feature is to enable specified wakeup source for system sleep.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 8f9db23..43ff71a 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
 obj-$(CONFIG_FSL_GUTS)			+= guts.o
 obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
+obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
new file mode 100644
index 0000000..b0feb88
--- /dev/null
+++ b/drivers/soc/fsl/ls-rcpm.c
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// plat_pm.c - Freescale Layerscape RCPM driver
+//
+// Copyright 2018 NXP
+//
+// Author: Ran Wang <ran.wang_1@nxp.com>,
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of_address.h>
+#include <linux/slab.h>
+#include <soc/fsl/plat_pm.h>
+
+#define MAX_COMPATIBLE_NUM	10
+
+struct rcpm_t {
+	struct device *dev;
+	void __iomem *ippdexpcr_addr;
+	bool big_endian;	/* Big/Little endian of RCPM module */
+};
+
+// rcpm_handle - Configure RCPM reg according to wake up source request
+// @user_dev: pointer to user's device struct
+// @flag: to enable(true) or disable(false) wakeup source
+// @handle_priv: pointer to struct rcpm_t instance
+//
+// Return 0 on success other negative errno
+static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
+{
+	struct rcpm_t *rcpm;
+	bool big_endian;
+	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
+	void __iomem *ippdexpcr_addr;
+	u32 ippdexpcr;
+	u32 set_bit;
+	int ret, num, i;
+
+	rcpm = handle_priv;
+	big_endian = rcpm->big_endian;
+	ippdexpcr_addr = rcpm->ippdexpcr_addr;
+
+	num = device_property_read_string_array(user_dev, "compatible",
+			dev_compatible_array, MAX_COMPATIBLE_NUM);
+	if (num < 0)
+		return num;
+
+	for (i = 0; i < num; i++) {
+		if (!device_property_present(rcpm->dev,
+					dev_compatible_array[i]))
+			continue;
+		else {
+			ret = device_property_read_u32(rcpm->dev,
+					dev_compatible_array[i], &set_bit);
+			if (ret)
+				return ret;
+
+			if (!device_property_present(rcpm->dev,
+						dev_compatible_array[i]))
+				return -ENODEV;
+			else {
+				ret = device_property_read_u32(rcpm->dev,
+						dev_compatible_array[i], &set_bit);
+				if (ret)
+					return ret;
+
+				if (big_endian)
+					ippdexpcr = ioread32be(ippdexpcr_addr);
+				else
+					ippdexpcr = ioread32(ippdexpcr_addr);
+
+				if (flag)
+					ippdexpcr |= set_bit;
+				else
+					ippdexpcr &= ~set_bit;
+
+				if (big_endian) {
+					iowrite32be(ippdexpcr, ippdexpcr_addr);
+					ippdexpcr = ioread32be(ippdexpcr_addr);
+				} else
+					iowrite32(ippdexpcr, ippdexpcr_addr);
+
+				return 0;
+			}
+		}
+	}
+
+	return -ENODEV;
+}
+
+static int ls_rcpm_probe(struct platform_device *pdev)
+{
+	struct resource *r;
+	struct rcpm_t *rcpm;
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;
+
+	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
+	if (!rcpm)
+		return -ENOMEM;
+
+	rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
+
+	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(rcpm->ippdexpcr_addr))
+		return PTR_ERR(rcpm->ippdexpcr_addr);
+
+	rcpm->dev = &pdev->dev;
+	platform_set_drvdata(pdev, rcpm);
+
+	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
+}
+
+static int ls_rcpm_remove(struct platform_device *pdev)
+{
+	struct rcpm_t	*rcpm;
+
+	rcpm = platform_get_drvdata(pdev);
+	deregister_fsl_platform_wakeup_source(rcpm);
+	kfree(rcpm);
+
+	return 0;
+}
+
+static const struct of_device_id ls_rcpm_of_match[] = {
+	{ .compatible = "fsl,qoriq-rcpm-2.1", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
+
+static struct platform_driver ls_rcpm_driver = {
+	.driver = {
+		.name = "ls-rcpm",
+		.of_match_table = ls_rcpm_of_match,
+	},
+	.probe = ls_rcpm_probe,
+	.remove = ls_rcpm_remove,
+};
+
+static int __init ls_rcpm_init(void)
+{
+	return platform_driver_register(&ls_rcpm_driver);
+}
+subsys_initcall(ls_rcpm_init);
+
+static void __exit ls_rcpm_exit(void)
+{
+	platform_driver_unregister(&ls_rcpm_driver);
+}
+module_exit(ls_rcpm_exit);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 73+ messages in thread

* Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
  2018-08-31  3:52   ` Ran Wang
  (?)
@ 2018-09-04  1:25     ` Rob Herring
  -1 siblings, 0 replies; 73+ messages in thread
From: Rob Herring @ 2018-09-04  1:25 UTC (permalink / raw)
  To: Ran Wang
  Cc: Mark Rutland, devicetree, linux-kernel, Leo Li, linuxppc-dev,
	linux-arm-kernel

On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> Add property 'big-endian' and supportted IP's configuration info.
> Remove property 'fsl,#rcpm-wakeup-cell'.

"dt-bindings: soc: ..." for the subject

It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell. 
What is not obvious is why? The commit msg should answer that.

You also are mixing several things in this patch like adding ls1012 
which you don't mention. Please split.

> 
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-------------
>  1 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-04  1:25     ` Rob Herring
  0 siblings, 0 replies; 73+ messages in thread
From: Rob Herring @ 2018-09-04  1:25 UTC (permalink / raw)
  To: Ran Wang
  Cc: Leo Li, Mark Rutland, linuxppc-dev, linux-arm-kernel, devicetree,
	linux-kernel

On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> Add property 'big-endian' and supportted IP's configuration info.
> Remove property 'fsl,#rcpm-wakeup-cell'.

"dt-bindings: soc: ..." for the subject

It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell. 
What is not obvious is why? The commit msg should answer that.

You also are mixing several things in this patch like adding ls1012 
which you don't mention. Please split.

> 
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-------------
>  1 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-04  1:25     ` Rob Herring
  0 siblings, 0 replies; 73+ messages in thread
From: Rob Herring @ 2018-09-04  1:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> Add property 'big-endian' and supportted IP's configuration info.
> Remove property 'fsl,#rcpm-wakeup-cell'.

"dt-bindings: soc: ..." for the subject

It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell. 
What is not obvious is why? The commit msg should answer that.

You also are mixing several things in this patch like adding ls1012 
which you don't mention. Please split.

> 
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-------------
>  1 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
  2018-09-04  1:25     ` Rob Herring
  (?)
  (?)
@ 2018-09-05  2:22       ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-05  2:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Leo Li, Mark Rutland, linuxppc-dev, linux-arm-kernel, devicetree,
	linux-kernel

Hi Rob

> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Tuesday, September 04, 2018 09:25
> To: Ran Wang <ran.wang_1@nxp.com>
> Cc: Leo Li <leoyang.li@nxp.com>; Mark Rutland <mark.rutland@arm.com>;
> linuxppc-dev@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property
> description for RCPM
> 
> On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> > Add property 'big-endian' and supportted IP's configuration info.
> > Remove property 'fsl,#rcpm-wakeup-cell'.
> 
> "dt-bindings: soc: ..." for the subject
> 
> It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell.
> What is not obvious is why? The commit msg should answer that.

Sure, I will add this in next version patch.

> You also are mixing several things in this patch like adding ls1012 which you
> don't mention. Please split.

Got it, will split them and add more information in next version.
 
Ran
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-----------
> --
> >  1 files changed, 13 insertions(+), 29 deletions(-)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-05  2:22       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-05  2:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Leo Li, Mark Rutland, linuxppc-dev, linux-arm-kernel, devicetree,
	linux-kernel

Hi Rob

> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Tuesday, September 04, 2018 09:25
> To: Ran Wang <ran.wang_1@nxp.com>
> Cc: Leo Li <leoyang.li@nxp.com>; Mark Rutland <mark.rutland@arm.com>;
> linuxppc-dev@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property
> description for RCPM
> 
> On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> > Add property 'big-endian' and supportted IP's configuration info.
> > Remove property 'fsl,#rcpm-wakeup-cell'.
> 
> "dt-bindings: soc: ..." for the subject
> 
> It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell.
> What is not obvious is why? The commit msg should answer that.

Sure, I will add this in next version patch.

> You also are mixing several things in this patch like adding ls1012 which you
> don't mention. Please split.

Got it, will split them and add more information in next version.
 
Ran
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-----------
> --
> >  1 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-05  2:22       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-05  2:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Leo Li, Mark Rutland, linuxppc-dev, linux-arm-kernel, devicetree,
	linux-kernel

Hi Rob

> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Tuesday, September 04, 2018 09:25
> To: Ran Wang <ran.wang_1@nxp.com>
> Cc: Leo Li <leoyang.li@nxp.com>; Mark Rutland <mark.rutland@arm.com>;
> linuxppc-dev@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property
> description for RCPM
>=20
> On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> > Add property 'big-endian' and supportted IP's configuration info.
> > Remove property 'fsl,#rcpm-wakeup-cell'.
>=20
> "dt-bindings: soc: ..." for the subject
>=20
> It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell.
> What is not obvious is why? The commit msg should answer that.

Sure, I will add this in next version patch.

> You also are mixing several things in this patch like adding ls1012 which=
 you
> don't mention. Please split.

Got it, will split them and add more information in next version.
=20
Ran
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++------=
-----
> --
> >  1 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-05  2:22       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-05  2:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Rob

> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Tuesday, September 04, 2018 09:25
> To: Ran Wang <ran.wang_1@nxp.com>
> Cc: Leo Li <leoyang.li@nxp.com>; Mark Rutland <mark.rutland@arm.com>;
> linuxppc-dev at lists.ozlabs.org; linux-arm-kernel at lists.infradead.org;
> devicetree at vger.kernel.org; linux-kernel at vger.kernel.org
> Subject: Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property
> description for RCPM
> 
> On Fri, Aug 31, 2018 at 11:52:18AM +0800, Ran Wang wrote:
> > Add property 'big-endian' and supportted IP's configuration info.
> > Remove property 'fsl,#rcpm-wakeup-cell'.
> 
> "dt-bindings: soc: ..." for the subject
> 
> It is obvious reading the diff you are removing fsl,#rcpm-wakeup-cell.
> What is not obvious is why? The commit msg should answer that.

Sure, I will add this in next version patch.

> You also are mixing several things in this patch like adding ls1012 which you
> don't mention. Please split.

Got it, will split them and add more information in next version.
 
Ran
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  Documentation/devicetree/bindings/soc/fsl/rcpm.txt |   42 ++++++-----------
> --
> >  1 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-08-31  3:52   ` Ran Wang
  (?)
  (?)
@ 2018-09-05  2:57     ` Wang, Dongsheng
  -1 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  2:57 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Please change your comments style.

On 2018/8/31 11:56, Ran Wang wrote:
> 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 FSL platform PM driver framework which help to
> isolate user and PM service provider (such as RCPM driver).
>
> Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |    6 ++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 160 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/ls-rcpm.c
>
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 6517412..882330d 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -30,3 +30,9 @@ config FSL_PLAT_PM
>  	  have to know the implement details of wakeup function it require.
>  	  Besides, it is also easy for service side to upgrade its logic when
>  	  design changed and remain user side unchanged.
> +
> +config LS_RCPM
> +	bool "Freescale RCPM support"
> +	depends on (FSL_PLAT_PM)
> +	help
> +	  This feature is to enable specified wakeup source for system sleep.
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> index 8f9db23..43ff71a 100644
> --- a/drivers/soc/fsl/Makefile
> +++ b/drivers/soc/fsl/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>  obj-$(CONFIG_CPM)			+= qe/
>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
>  obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> +obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
> diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> new file mode 100644
> index 0000000..b0feb88
> --- /dev/null
> +++ b/drivers/soc/fsl/ls-rcpm.c
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.c - Freescale Layerscape RCPM driver
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of_address.h>
> +#include <linux/slab.h>
> +#include <soc/fsl/plat_pm.h>
> +
> +#define MAX_COMPATIBLE_NUM	10
> +
> +struct rcpm_t {
> +	struct device *dev;
> +	void __iomem *ippdexpcr_addr;
> +	bool big_endian;	/* Big/Little endian of RCPM module */
> +};
> +
> +// rcpm_handle - Configure RCPM reg according to wake up source request
> +// @user_dev: pointer to user's device struct
> +// @flag: to enable(true) or disable(false) wakeup source
> +// @handle_priv: pointer to struct rcpm_t instance
> +//
> +// Return 0 on success other negative errno
> +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
> +{
> +	struct rcpm_t *rcpm;
> +	bool big_endian;
> +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> +	void __iomem *ippdexpcr_addr;
> +	u32 ippdexpcr;
> +	u32 set_bit;
> +	int ret, num, i;
> +
> +	rcpm = handle_priv;
> +	big_endian = rcpm->big_endian;
> +	ippdexpcr_addr = rcpm->ippdexpcr_addr;
> +
> +	num = device_property_read_string_array(user_dev, "compatible",
> +			dev_compatible_array, MAX_COMPATIBLE_NUM);
> +	if (num < 0)
> +		return num;
> +
> +	for (i = 0; i < num; i++) {
> +		if (!device_property_present(rcpm->dev,
> +					dev_compatible_array[i]))
> +			continue;
> +		else {
Remove this else.
> +			ret = device_property_read_u32(rcpm->dev,
> +					dev_compatible_array[i], &set_bit);
> +			if (ret)
> +				return ret;
> +
> +			if (!device_property_present(rcpm->dev,
> +						dev_compatible_array[i]))
This has been checked. Continue ? or return ENODEV?
> +				return -ENODEV;
> +			else {
Remove this else.
> +				ret = device_property_read_u32(rcpm->dev,
> +						dev_compatible_array[i], &set_bit);
> +				if (ret)
> +					return ret;
> +
> +				if (big_endian)
> +					ippdexpcr = ioread32be(ippdexpcr_addr);
> +				else
> +					ippdexpcr = ioread32(ippdexpcr_addr);
> +
> +				if (flag)
> +					ippdexpcr |= set_bit;
> +				else
> +					ippdexpcr &= ~set_bit;
> +
> +				if (big_endian) {
> +					iowrite32be(ippdexpcr, ippdexpcr_addr);
> +					ippdexpcr = ioread32be(ippdexpcr_addr);
> +				} else
if (x) {
...
...
}  else {

}
> +					iowrite32(ippdexpcr, ippdexpcr_addr);
> +
> +				return 0;
> +			}
> +		}
> +	}
> +
> +	return -ENODEV;
> +}
> +
> +static int ls_rcpm_probe(struct platform_device *pdev)
> +{
> +	struct resource *r;
> +	struct rcpm_t *rcpm;
> +
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!r)
> +		return -ENODEV;
> +
> +	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
kzalloc is better.
> +	if (!rcpm)
> +		return -ENOMEM;
> +
> +	rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
> +
> +	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> +	if (IS_ERR(rcpm->ippdexpcr_addr))
> +		return PTR_ERR(rcpm->ippdexpcr_addr);
> +
> +	rcpm->dev = &pdev->dev;
> +	platform_set_drvdata(pdev, rcpm);
> +
> +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> +}
> +
> +static int ls_rcpm_remove(struct platform_device *pdev)
> +{
> +	struct rcpm_t	*rcpm;
Not need a table.

Cheers,
-Dongsheng

> +
> +	rcpm = platform_get_drvdata(pdev);
> +	deregister_fsl_platform_wakeup_source(rcpm);
> +	kfree(rcpm);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id ls_rcpm_of_match[] = {
> +	{ .compatible = "fsl,qoriq-rcpm-2.1", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> +
> +static struct platform_driver ls_rcpm_driver = {
> +	.driver = {
> +		.name = "ls-rcpm",
> +		.of_match_table = ls_rcpm_of_match,
> +	},
> +	.probe = ls_rcpm_probe,
> +	.remove = ls_rcpm_remove,
> +};
> +
> +static int __init ls_rcpm_init(void)
> +{
> +	return platform_driver_register(&ls_rcpm_driver);
> +}
> +subsys_initcall(ls_rcpm_init);
> +
> +static void __exit ls_rcpm_exit(void)
> +{
> +	platform_driver_unregister(&ls_rcpm_driver);
> +}
> +module_exit(ls_rcpm_exit);



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-05  2:57     ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  2:57 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Please change your comments style.

On 2018/8/31 11:56, Ran Wang wrote:
> 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 FSL platform PM driver framework which help to
> isolate user and PM service provider (such as RCPM driver).
>
> Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |    6 ++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 160 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/ls-rcpm.c
>
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 6517412..882330d 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -30,3 +30,9 @@ config FSL_PLAT_PM
>  	  have to know the implement details of wakeup function it require.
>  	  Besides, it is also easy for service side to upgrade its logic when
>  	  design changed and remain user side unchanged.
> +
> +config LS_RCPM
> +	bool "Freescale RCPM support"
> +	depends on (FSL_PLAT_PM)
> +	help
> +	  This feature is to enable specified wakeup source for system sleep.
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> index 8f9db23..43ff71a 100644
> --- a/drivers/soc/fsl/Makefile
> +++ b/drivers/soc/fsl/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>  obj-$(CONFIG_CPM)			+= qe/
>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
>  obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> +obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
> diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> new file mode 100644
> index 0000000..b0feb88
> --- /dev/null
> +++ b/drivers/soc/fsl/ls-rcpm.c
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.c - Freescale Layerscape RCPM driver
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of_address.h>
> +#include <linux/slab.h>
> +#include <soc/fsl/plat_pm.h>
> +
> +#define MAX_COMPATIBLE_NUM	10
> +
> +struct rcpm_t {
> +	struct device *dev;
> +	void __iomem *ippdexpcr_addr;
> +	bool big_endian;	/* Big/Little endian of RCPM module */
> +};
> +
> +// rcpm_handle - Configure RCPM reg according to wake up source request
> +// @user_dev: pointer to user's device struct
> +// @flag: to enable(true) or disable(false) wakeup source
> +// @handle_priv: pointer to struct rcpm_t instance
> +//
> +// Return 0 on success other negative errno
> +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
> +{
> +	struct rcpm_t *rcpm;
> +	bool big_endian;
> +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> +	void __iomem *ippdexpcr_addr;
> +	u32 ippdexpcr;
> +	u32 set_bit;
> +	int ret, num, i;
> +
> +	rcpm = handle_priv;
> +	big_endian = rcpm->big_endian;
> +	ippdexpcr_addr = rcpm->ippdexpcr_addr;
> +
> +	num = device_property_read_string_array(user_dev, "compatible",
> +			dev_compatible_array, MAX_COMPATIBLE_NUM);
> +	if (num < 0)
> +		return num;
> +
> +	for (i = 0; i < num; i++) {
> +		if (!device_property_present(rcpm->dev,
> +					dev_compatible_array[i]))
> +			continue;
> +		else {
Remove this else.
> +			ret = device_property_read_u32(rcpm->dev,
> +					dev_compatible_array[i], &set_bit);
> +			if (ret)
> +				return ret;
> +
> +			if (!device_property_present(rcpm->dev,
> +						dev_compatible_array[i]))
This has been checked. Continue ? or return ENODEV?
> +				return -ENODEV;
> +			else {
Remove this else.
> +				ret = device_property_read_u32(rcpm->dev,
> +						dev_compatible_array[i], &set_bit);
> +				if (ret)
> +					return ret;
> +
> +				if (big_endian)
> +					ippdexpcr = ioread32be(ippdexpcr_addr);
> +				else
> +					ippdexpcr = ioread32(ippdexpcr_addr);
> +
> +				if (flag)
> +					ippdexpcr |= set_bit;
> +				else
> +					ippdexpcr &= ~set_bit;
> +
> +				if (big_endian) {
> +					iowrite32be(ippdexpcr, ippdexpcr_addr);
> +					ippdexpcr = ioread32be(ippdexpcr_addr);
> +				} else
if (x) {
....
....
}  else {

}
> +					iowrite32(ippdexpcr, ippdexpcr_addr);
> +
> +				return 0;
> +			}
> +		}
> +	}
> +
> +	return -ENODEV;
> +}
> +
> +static int ls_rcpm_probe(struct platform_device *pdev)
> +{
> +	struct resource *r;
> +	struct rcpm_t *rcpm;
> +
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!r)
> +		return -ENODEV;
> +
> +	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
kzalloc is better.
> +	if (!rcpm)
> +		return -ENOMEM;
> +
> +	rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
> +
> +	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> +	if (IS_ERR(rcpm->ippdexpcr_addr))
> +		return PTR_ERR(rcpm->ippdexpcr_addr);
> +
> +	rcpm->dev = &pdev->dev;
> +	platform_set_drvdata(pdev, rcpm);
> +
> +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> +}
> +
> +static int ls_rcpm_remove(struct platform_device *pdev)
> +{
> +	struct rcpm_t	*rcpm;
Not need a table.

Cheers,
-Dongsheng

> +
> +	rcpm = platform_get_drvdata(pdev);
> +	deregister_fsl_platform_wakeup_source(rcpm);
> +	kfree(rcpm);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id ls_rcpm_of_match[] = {
> +	{ .compatible = "fsl,qoriq-rcpm-2.1", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> +
> +static struct platform_driver ls_rcpm_driver = {
> +	.driver = {
> +		.name = "ls-rcpm",
> +		.of_match_table = ls_rcpm_of_match,
> +	},
> +	.probe = ls_rcpm_probe,
> +	.remove = ls_rcpm_remove,
> +};
> +
> +static int __init ls_rcpm_init(void)
> +{
> +	return platform_driver_register(&ls_rcpm_driver);
> +}
> +subsys_initcall(ls_rcpm_init);
> +
> +static void __exit ls_rcpm_exit(void)
> +{
> +	platform_driver_unregister(&ls_rcpm_driver);
> +}
> +module_exit(ls_rcpm_exit);

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-05  2:57     ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  2:57 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Please change your comments style.=0A=
=0A=
On 2018/8/31 11:56, Ran Wang wrote:=0A=
> The NXP's QorIQ Processors based on ARM Core have RCPM module (Run=0A=
> Control and Power Management), which performs all device-level=0A=
> tasks associated with power management such as wakeup source control.=0A=
>=0A=
> This driver depends on FSL platform PM driver framework which help to=0A=
> isolate user and PM service provider (such as RCPM driver).=0A=
>=0A=
> Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>=0A=
> Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>=0A=
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>=0A=
> ---=0A=
>  drivers/soc/fsl/Kconfig   |    6 ++=0A=
>  drivers/soc/fsl/Makefile  |    1 +=0A=
>  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++=
++++++=0A=
>  3 files changed, 160 insertions(+), 0 deletions(-)=0A=
>  create mode 100644 drivers/soc/fsl/ls-rcpm.c=0A=
>=0A=
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig=0A=
> index 6517412..882330d 100644=0A=
> --- a/drivers/soc/fsl/Kconfig=0A=
> +++ b/drivers/soc/fsl/Kconfig=0A=
> @@ -30,3 +30,9 @@ config FSL_PLAT_PM=0A=
>  	  have to know the implement details of wakeup function it require.=0A=
>  	  Besides, it is also easy for service side to upgrade its logic when=
=0A=
>  	  design changed and remain user side unchanged.=0A=
> +=0A=
> +config LS_RCPM=0A=
> +	bool "Freescale RCPM support"=0A=
> +	depends on (FSL_PLAT_PM)=0A=
> +	help=0A=
> +	  This feature is to enable specified wakeup source for system sleep.=
=0A=
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile=0A=
> index 8f9db23..43ff71a 100644=0A=
> --- a/drivers/soc/fsl/Makefile=0A=
> +++ b/drivers/soc/fsl/Makefile=0A=
> @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+=3D qe/=0A=
>  obj-$(CONFIG_CPM)			+=3D qe/=0A=
>  obj-$(CONFIG_FSL_GUTS)			+=3D guts.o=0A=
>  obj-$(CONFIG_FSL_PLAT_PM)	+=3D plat_pm.o=0A=
> +obj-$(CONFIG_LS_RCPM)		+=3D ls-rcpm.o=0A=
> diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c=0A=
> new file mode 100644=0A=
> index 0000000..b0feb88=0A=
> --- /dev/null=0A=
> +++ b/drivers/soc/fsl/ls-rcpm.c=0A=
> @@ -0,0 +1,153 @@=0A=
> +// SPDX-License-Identifier: GPL-2.0=0A=
> +//=0A=
> +// plat_pm.c - Freescale Layerscape RCPM driver=0A=
> +//=0A=
> +// Copyright 2018 NXP=0A=
> +//=0A=
> +// Author: Ran Wang <ran.wang_1@nxp.com>,=0A=
> +=0A=
> +#include <linux/init.h>=0A=
> +#include <linux/module.h>=0A=
> +#include <linux/platform_device.h>=0A=
> +#include <linux/of_address.h>=0A=
> +#include <linux/slab.h>=0A=
> +#include <soc/fsl/plat_pm.h>=0A=
> +=0A=
> +#define MAX_COMPATIBLE_NUM	10=0A=
> +=0A=
> +struct rcpm_t {=0A=
> +	struct device *dev;=0A=
> +	void __iomem *ippdexpcr_addr;=0A=
> +	bool big_endian;	/* Big/Little endian of RCPM module */=0A=
> +};=0A=
> +=0A=
> +// rcpm_handle - Configure RCPM reg according to wake up source request=
=0A=
> +// @user_dev: pointer to user's device struct=0A=
> +// @flag: to enable(true) or disable(false) wakeup source=0A=
> +// @handle_priv: pointer to struct rcpm_t instance=0A=
> +//=0A=
> +// Return 0 on success other negative errno=0A=
> +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_=
priv)=0A=
> +{=0A=
> +	struct rcpm_t *rcpm;=0A=
> +	bool big_endian;=0A=
> +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];=0A=
> +	void __iomem *ippdexpcr_addr;=0A=
> +	u32 ippdexpcr;=0A=
> +	u32 set_bit;=0A=
> +	int ret, num, i;=0A=
> +=0A=
> +	rcpm =3D handle_priv;=0A=
> +	big_endian =3D rcpm->big_endian;=0A=
> +	ippdexpcr_addr =3D rcpm->ippdexpcr_addr;=0A=
> +=0A=
> +	num =3D device_property_read_string_array(user_dev, "compatible",=0A=
> +			dev_compatible_array, MAX_COMPATIBLE_NUM);=0A=
> +	if (num < 0)=0A=
> +		return num;=0A=
> +=0A=
> +	for (i =3D 0; i < num; i++) {=0A=
> +		if (!device_property_present(rcpm->dev,=0A=
> +					dev_compatible_array[i]))=0A=
> +			continue;=0A=
> +		else {=0A=
Remove this else.=0A=
> +			ret =3D device_property_read_u32(rcpm->dev,=0A=
> +					dev_compatible_array[i], &set_bit);=0A=
> +			if (ret)=0A=
> +				return ret;=0A=
> +=0A=
> +			if (!device_property_present(rcpm->dev,=0A=
> +						dev_compatible_array[i]))=0A=
This has been checked. Continue ? or return ENODEV=1B$B!)=1B(B=0A=
> +				return -ENODEV;=0A=
> +			else {=0A=
Remove this else.=0A=
> +				ret =3D device_property_read_u32(rcpm->dev,=0A=
> +						dev_compatible_array[i], &set_bit);=0A=
> +				if (ret)=0A=
> +					return ret;=0A=
> +=0A=
> +				if (big_endian)=0A=
> +					ippdexpcr =3D ioread32be(ippdexpcr_addr);=0A=
> +				else=0A=
> +					ippdexpcr =3D ioread32(ippdexpcr_addr);=0A=
> +=0A=
> +				if (flag)=0A=
> +					ippdexpcr |=3D set_bit;=0A=
> +				else=0A=
> +					ippdexpcr &=3D ~set_bit;=0A=
> +=0A=
> +				if (big_endian) {=0A=
> +					iowrite32be(ippdexpcr, ippdexpcr_addr);=0A=
> +					ippdexpcr =3D ioread32be(ippdexpcr_addr);=0A=
> +				} else=0A=
if (x) {=0A=
....=0A=
....=0A=
}  else {=0A=
=0A=
}=0A=
> +					iowrite32(ippdexpcr, ippdexpcr_addr);=0A=
> +=0A=
> +				return 0;=0A=
> +			}=0A=
> +		}=0A=
> +	}=0A=
> +=0A=
> +	return -ENODEV;=0A=
> +}=0A=
> +=0A=
> +static int ls_rcpm_probe(struct platform_device *pdev)=0A=
> +{=0A=
> +	struct resource *r;=0A=
> +	struct rcpm_t *rcpm;=0A=
> +=0A=
> +	r =3D platform_get_resource(pdev, IORESOURCE_MEM, 0);=0A=
> +	if (!r)=0A=
> +		return -ENODEV;=0A=
> +=0A=
> +	rcpm =3D kmalloc(sizeof(*rcpm), GFP_KERNEL);=0A=
kzalloc is better.=0A=
> +	if (!rcpm)=0A=
> +		return -ENOMEM;=0A=
> +=0A=
> +	rcpm->big_endian =3D device_property_read_bool(&pdev->dev, "big-endian"=
);=0A=
> +=0A=
> +	rcpm->ippdexpcr_addr =3D devm_ioremap_resource(&pdev->dev, r);=0A=
> +	if (IS_ERR(rcpm->ippdexpcr_addr))=0A=
> +		return PTR_ERR(rcpm->ippdexpcr_addr);=0A=
> +=0A=
> +	rcpm->dev =3D &pdev->dev;=0A=
> +	platform_set_drvdata(pdev, rcpm);=0A=
> +=0A=
> +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);=0A=
> +}=0A=
> +=0A=
> +static int ls_rcpm_remove(struct platform_device *pdev)=0A=
> +{=0A=
> +	struct rcpm_t	*rcpm;=0A=
Not need a table.=0A=
=0A=
Cheers,=0A=
-Dongsheng=0A=
=0A=
> +=0A=
> +	rcpm =3D platform_get_drvdata(pdev);=0A=
> +	deregister_fsl_platform_wakeup_source(rcpm);=0A=
> +	kfree(rcpm);=0A=
> +=0A=
> +	return 0;=0A=
> +}=0A=
> +=0A=
> +static const struct of_device_id ls_rcpm_of_match[] =3D {=0A=
> +	{ .compatible =3D "fsl,qoriq-rcpm-2.1", },=0A=
> +	{}=0A=
> +};=0A=
> +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);=0A=
> +=0A=
> +static struct platform_driver ls_rcpm_driver =3D {=0A=
> +	.driver =3D {=0A=
> +		.name =3D "ls-rcpm",=0A=
> +		.of_match_table =3D ls_rcpm_of_match,=0A=
> +	},=0A=
> +	.probe =3D ls_rcpm_probe,=0A=
> +	.remove =3D ls_rcpm_remove,=0A=
> +};=0A=
> +=0A=
> +static int __init ls_rcpm_init(void)=0A=
> +{=0A=
> +	return platform_driver_register(&ls_rcpm_driver);=0A=
> +}=0A=
> +subsys_initcall(ls_rcpm_init);=0A=
> +=0A=
> +static void __exit ls_rcpm_exit(void)=0A=
> +{=0A=
> +	platform_driver_unregister(&ls_rcpm_driver);=0A=
> +}=0A=
> +module_exit(ls_rcpm_exit);=0A=
=0A=
=0A=

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-05  2:57     ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  2:57 UTC (permalink / raw)
  To: linux-arm-kernel

Please change your comments style.

On 2018/8/31 11:56, Ran Wang wrote:
> 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 FSL platform PM driver framework which help to
> isolate user and PM service provider (such as RCPM driver).
>
> Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |    6 ++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 160 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/ls-rcpm.c
>
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 6517412..882330d 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -30,3 +30,9 @@ config FSL_PLAT_PM
>  	  have to know the implement details of wakeup function it require.
>  	  Besides, it is also easy for service side to upgrade its logic when
>  	  design changed and remain user side unchanged.
> +
> +config LS_RCPM
> +	bool "Freescale RCPM support"
> +	depends on (FSL_PLAT_PM)
> +	help
> +	  This feature is to enable specified wakeup source for system sleep.
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> index 8f9db23..43ff71a 100644
> --- a/drivers/soc/fsl/Makefile
> +++ b/drivers/soc/fsl/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>  obj-$(CONFIG_CPM)			+= qe/
>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
>  obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> +obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
> diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> new file mode 100644
> index 0000000..b0feb88
> --- /dev/null
> +++ b/drivers/soc/fsl/ls-rcpm.c
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.c - Freescale Layerscape RCPM driver
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of_address.h>
> +#include <linux/slab.h>
> +#include <soc/fsl/plat_pm.h>
> +
> +#define MAX_COMPATIBLE_NUM	10
> +
> +struct rcpm_t {
> +	struct device *dev;
> +	void __iomem *ippdexpcr_addr;
> +	bool big_endian;	/* Big/Little endian of RCPM module */
> +};
> +
> +// rcpm_handle - Configure RCPM reg according to wake up source request
> +// @user_dev: pointer to user's device struct
> +// @flag: to enable(true) or disable(false) wakeup source
> +// @handle_priv: pointer to struct rcpm_t instance
> +//
> +// Return 0 on success other negative errno
> +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
> +{
> +	struct rcpm_t *rcpm;
> +	bool big_endian;
> +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> +	void __iomem *ippdexpcr_addr;
> +	u32 ippdexpcr;
> +	u32 set_bit;
> +	int ret, num, i;
> +
> +	rcpm = handle_priv;
> +	big_endian = rcpm->big_endian;
> +	ippdexpcr_addr = rcpm->ippdexpcr_addr;
> +
> +	num = device_property_read_string_array(user_dev, "compatible",
> +			dev_compatible_array, MAX_COMPATIBLE_NUM);
> +	if (num < 0)
> +		return num;
> +
> +	for (i = 0; i < num; i++) {
> +		if (!device_property_present(rcpm->dev,
> +					dev_compatible_array[i]))
> +			continue;
> +		else {
Remove this else.
> +			ret = device_property_read_u32(rcpm->dev,
> +					dev_compatible_array[i], &set_bit);
> +			if (ret)
> +				return ret;
> +
> +			if (!device_property_present(rcpm->dev,
> +						dev_compatible_array[i]))
This has been checked. Continue ? or return ENODEV?
> +				return -ENODEV;
> +			else {
Remove this else.
> +				ret = device_property_read_u32(rcpm->dev,
> +						dev_compatible_array[i], &set_bit);
> +				if (ret)
> +					return ret;
> +
> +				if (big_endian)
> +					ippdexpcr = ioread32be(ippdexpcr_addr);
> +				else
> +					ippdexpcr = ioread32(ippdexpcr_addr);
> +
> +				if (flag)
> +					ippdexpcr |= set_bit;
> +				else
> +					ippdexpcr &= ~set_bit;
> +
> +				if (big_endian) {
> +					iowrite32be(ippdexpcr, ippdexpcr_addr);
> +					ippdexpcr = ioread32be(ippdexpcr_addr);
> +				} else
if (x) {
....
....
}  else {

}
> +					iowrite32(ippdexpcr, ippdexpcr_addr);
> +
> +				return 0;
> +			}
> +		}
> +	}
> +
> +	return -ENODEV;
> +}
> +
> +static int ls_rcpm_probe(struct platform_device *pdev)
> +{
> +	struct resource *r;
> +	struct rcpm_t *rcpm;
> +
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!r)
> +		return -ENODEV;
> +
> +	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
kzalloc is better.
> +	if (!rcpm)
> +		return -ENOMEM;
> +
> +	rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
> +
> +	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> +	if (IS_ERR(rcpm->ippdexpcr_addr))
> +		return PTR_ERR(rcpm->ippdexpcr_addr);
> +
> +	rcpm->dev = &pdev->dev;
> +	platform_set_drvdata(pdev, rcpm);
> +
> +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> +}
> +
> +static int ls_rcpm_remove(struct platform_device *pdev)
> +{
> +	struct rcpm_t	*rcpm;
Not need a table.

Cheers,
-Dongsheng

> +
> +	rcpm = platform_get_drvdata(pdev);
> +	deregister_fsl_platform_wakeup_source(rcpm);
> +	kfree(rcpm);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id ls_rcpm_of_match[] = {
> +	{ .compatible = "fsl,qoriq-rcpm-2.1", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> +
> +static struct platform_driver ls_rcpm_driver = {
> +	.driver = {
> +		.name = "ls-rcpm",
> +		.of_match_table = ls_rcpm_of_match,
> +	},
> +	.probe = ls_rcpm_probe,
> +	.remove = ls_rcpm_remove,
> +};
> +
> +static int __init ls_rcpm_init(void)
> +{
> +	return platform_driver_register(&ls_rcpm_driver);
> +}
> +subsys_initcall(ls_rcpm_init);
> +
> +static void __exit ls_rcpm_exit(void)
> +{
> +	platform_driver_unregister(&ls_rcpm_driver);
> +}
> +module_exit(ls_rcpm_exit);

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
  2018-08-31  3:52 ` Ran Wang
  (?)
  (?)
@ 2018-09-05  3:04   ` Wang, Dongsheng
  -1 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  3:04 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Please change your comments style.

On 2018/8/31 11:57, Ran Wang wrote:
> This driver is to provide a independent framework for PM service
> provider and consumer to configure system level wake up feature. For
> example, RCPM driver could register a callback function on this
> platform first, and Flex timer driver who want to enable timer wake
> up feature, will call generic API provided by this platform driver,
> and then it will trigger RCPM driver to do it. The benefit is to
> isolate the user and service, such as flex timer driver will not have
> to know the implement details of wakeup function it require. Besides,
> it is also easy for service side to upgrade its logic when design is
> changed and remain user side unchanged.
>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |   14 +++++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/plat_pm.c |  144 +++++++++++++++++++++++++++++++++++++++++++++
>  include/soc/fsl/plat_pm.h |   22 +++++++
>  4 files changed, 181 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/plat_pm.c
>  create mode 100644 include/soc/fsl/plat_pm.h
>
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 7a9fb9b..6517412 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -16,3 +16,17 @@ config FSL_GUTS
>  	  Initially only reading SVR and registering soc device are supported.
>  	  Other guts accesses, such as reading RCW, should eventually be moved
>  	  into this driver as well.
> +
> +config FSL_PLAT_PM
> +	bool "Freescale platform PM framework"
> +	help
> +	  This driver is to provide a independent framework for PM service
> +	  provider and consumer to configure system level wake up feature. For
> +	  example, RCPM driver could register a callback function on this
> +	  platform first, and Flex timer driver who want to enable timer wake
> +	  up feature, will call generic API provided by this platform driver,
> +	  and then it will trigger RCPM driver to do it. The benefit is to
> +	  isolate the user and service, such as  flex timer driver will not
> +	  have to know the implement details of wakeup function it require.
> +	  Besides, it is also easy for service side to upgrade its logic when
> +	  design changed and remain user side unchanged.
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> index 44b3beb..8f9db23 100644
> --- a/drivers/soc/fsl/Makefile
> +++ b/drivers/soc/fsl/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>  obj-$(CONFIG_CPM)			+= qe/
>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> new file mode 100644
> index 0000000..19ea14e
> --- /dev/null
> +++ b/drivers/soc/fsl/plat_pm.c
> @@ -0,0 +1,144 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.c - Freescale platform PM framework
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#include <linux/kernel.h>
> +#include <linux/device.h>
> +#include <linux/list.h>
> +#include <linux/slab.h>
> +#include <linux/err.h>
> +#include <soc/fsl/plat_pm.h>
> +
> +
> +struct plat_pm_t {
> +	struct list_head node;
> +	fsl_plat_pm_handle handle;
> +	void *handle_priv;
> +	spinlock_t	lock;
> +};
> +
> +static struct plat_pm_t plat_pm;
> +
> +// register_fsl_platform_wakeup_source - Register callback function to plat_pm
> +// @handle: Pointer to handle PM feature requirement
> +// @handle_priv: Handler specific data struct
> +//
> +// Return 0 on success other negative errno
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> +		void *handle_priv)
> +{
> +	struct plat_pm_t *p;
> +	unsigned long	flags;
> +
> +	if (!handle) {
> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> +		return -EINVAL;
> +	}
> +
> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> +	if (!p)
> +		return -ENOMEM;
> +
> +	p->handle = handle;
> +	p->handle_priv = handle_priv;
> +
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_add_tail(&p->node, &plat_pm.node);
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> +
> +// Deregister_fsl_platform_wakeup_source - deregister callback function
> +// @handle_priv: Handler specific data struct
> +//
> +// Return 0 on success other negative errno
> +int deregister_fsl_platform_wakeup_source(void *handle_priv)
> +{
> +	struct plat_pm_t *p, *tmp;
> +	unsigned long	flags;
> +
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> +		if (p->handle_priv == handle_priv) {
> +			list_del(&p->node);
> +			kfree(p);
> +		}
> +	}
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> +
> +// fsl_platform_wakeup_config - Configure wakeup source by calling handlers
> +// @dev: pointer to user's device struct
> +// @flag: to tell enable or disable wakeup source
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_config(struct device *dev, bool flag)
> +{
> +	struct plat_pm_t *p;
> +	int ret;
> +	bool success_handled;
> +	unsigned long	flags;
> +
> +	success_handled = false;
> +
> +	// Will consider success if at least one callback return 0.
> +	// Also, rest handles still get oppertunity to be executed
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_for_each_entry(p, &plat_pm.node, node) {
> +		if (p->handle) {
> +			ret = p->handle(dev, flag, p->handle_priv);
> +			if (!ret)
> +				success_handled = true;
Miss a break?

> +			else if (ret != -ENODEV) {
> +				pr_err("FSL plat_pm: Failed to config wakeup source:%d\n", ret);
Please unlock before return.

> +				return ret;
> +			}
> +		} else
> +			pr_warn("FSL plat_pm: Invalid handler detected, skip\n");
> +	}
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +
> +	if (success_handled == false) {
> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for wakeup source config\n");
> +		return -ENODEV;
> +	}
Add this into the loop.
> +
> +	return 0;
> +}
> +
> +// fsl_platform_wakeup_enable - Enable wakeup source
> +// @dev: pointer to user's device struct
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_enable(struct device *dev)
> +{
> +	return fsl_platform_wakeup_config(dev, true);
> +}
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> +
> +// fsl_platform_wakeup_disable - Disable wakeup source
> +// @dev: pointer to user's device struct
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_disable(struct device *dev)
> +{
> +	return fsl_platform_wakeup_config(dev, false);
> +}
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> +
> +static int __init fsl_plat_pm_init(void)
> +{
> +	spin_lock_init(&plat_pm.lock);
> +	INIT_LIST_HEAD(&plat_pm.node);
> +	return 0;
> +}
> +
> +core_initcall(fsl_plat_pm_init);
> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> new file mode 100644
> index 0000000..bbe151e
> --- /dev/null
> +++ b/include/soc/fsl/plat_pm.h
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.h - Freescale platform PM Header
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#ifndef __FSL_PLAT_PM_H
> +#define __FSL_PLAT_PM_H
> +
> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> +		void *handle_priv);
> +
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> +		void *handle_priv);
> +int deregister_fsl_platform_wakeup_source(void *handle_priv);
> +int fsl_platform_wakeup_config(struct device *dev, bool flag);
> +int fsl_platform_wakeup_enable(struct device *dev);
> +int fsl_platform_wakeup_disable(struct device *dev);
> +
> +#endif	// __FSL_PLAT_PM_H



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-05  3:04   ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  3:04 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Please change your comments style.

On 2018/8/31 11:57, Ran Wang wrote:
> This driver is to provide a independent framework for PM service
> provider and consumer to configure system level wake up feature. For
> example, RCPM driver could register a callback function on this
> platform first, and Flex timer driver who want to enable timer wake
> up feature, will call generic API provided by this platform driver,
> and then it will trigger RCPM driver to do it. The benefit is to
> isolate the user and service, such as flex timer driver will not have
> to know the implement details of wakeup function it require. Besides,
> it is also easy for service side to upgrade its logic when design is
> changed and remain user side unchanged.
>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |   14 +++++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/plat_pm.c |  144 +++++++++++++++++++++++++++++++++++++++++++++
>  include/soc/fsl/plat_pm.h |   22 +++++++
>  4 files changed, 181 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/plat_pm.c
>  create mode 100644 include/soc/fsl/plat_pm.h
>
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 7a9fb9b..6517412 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -16,3 +16,17 @@ config FSL_GUTS
>  	  Initially only reading SVR and registering soc device are supported.
>  	  Other guts accesses, such as reading RCW, should eventually be moved
>  	  into this driver as well.
> +
> +config FSL_PLAT_PM
> +	bool "Freescale platform PM framework"
> +	help
> +	  This driver is to provide a independent framework for PM service
> +	  provider and consumer to configure system level wake up feature. For
> +	  example, RCPM driver could register a callback function on this
> +	  platform first, and Flex timer driver who want to enable timer wake
> +	  up feature, will call generic API provided by this platform driver,
> +	  and then it will trigger RCPM driver to do it. The benefit is to
> +	  isolate the user and service, such as  flex timer driver will not
> +	  have to know the implement details of wakeup function it require.
> +	  Besides, it is also easy for service side to upgrade its logic when
> +	  design changed and remain user side unchanged.
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> index 44b3beb..8f9db23 100644
> --- a/drivers/soc/fsl/Makefile
> +++ b/drivers/soc/fsl/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>  obj-$(CONFIG_CPM)			+= qe/
>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> new file mode 100644
> index 0000000..19ea14e
> --- /dev/null
> +++ b/drivers/soc/fsl/plat_pm.c
> @@ -0,0 +1,144 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.c - Freescale platform PM framework
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#include <linux/kernel.h>
> +#include <linux/device.h>
> +#include <linux/list.h>
> +#include <linux/slab.h>
> +#include <linux/err.h>
> +#include <soc/fsl/plat_pm.h>
> +
> +
> +struct plat_pm_t {
> +	struct list_head node;
> +	fsl_plat_pm_handle handle;
> +	void *handle_priv;
> +	spinlock_t	lock;
> +};
> +
> +static struct plat_pm_t plat_pm;
> +
> +// register_fsl_platform_wakeup_source - Register callback function to plat_pm
> +// @handle: Pointer to handle PM feature requirement
> +// @handle_priv: Handler specific data struct
> +//
> +// Return 0 on success other negative errno
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> +		void *handle_priv)
> +{
> +	struct plat_pm_t *p;
> +	unsigned long	flags;
> +
> +	if (!handle) {
> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> +		return -EINVAL;
> +	}
> +
> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> +	if (!p)
> +		return -ENOMEM;
> +
> +	p->handle = handle;
> +	p->handle_priv = handle_priv;
> +
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_add_tail(&p->node, &plat_pm.node);
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> +
> +// Deregister_fsl_platform_wakeup_source - deregister callback function
> +// @handle_priv: Handler specific data struct
> +//
> +// Return 0 on success other negative errno
> +int deregister_fsl_platform_wakeup_source(void *handle_priv)
> +{
> +	struct plat_pm_t *p, *tmp;
> +	unsigned long	flags;
> +
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> +		if (p->handle_priv == handle_priv) {
> +			list_del(&p->node);
> +			kfree(p);
> +		}
> +	}
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> +
> +// fsl_platform_wakeup_config - Configure wakeup source by calling handlers
> +// @dev: pointer to user's device struct
> +// @flag: to tell enable or disable wakeup source
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_config(struct device *dev, bool flag)
> +{
> +	struct plat_pm_t *p;
> +	int ret;
> +	bool success_handled;
> +	unsigned long	flags;
> +
> +	success_handled = false;
> +
> +	// Will consider success if at least one callback return 0.
> +	// Also, rest handles still get oppertunity to be executed
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_for_each_entry(p, &plat_pm.node, node) {
> +		if (p->handle) {
> +			ret = p->handle(dev, flag, p->handle_priv);
> +			if (!ret)
> +				success_handled = true;
Miss a break?

> +			else if (ret != -ENODEV) {
> +				pr_err("FSL plat_pm: Failed to config wakeup source:%d\n", ret);
Please unlock before return.

> +				return ret;
> +			}
> +		} else
> +			pr_warn("FSL plat_pm: Invalid handler detected, skip\n");
> +	}
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +
> +	if (success_handled == false) {
> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for wakeup source config\n");
> +		return -ENODEV;
> +	}
Add this into the loop.
> +
> +	return 0;
> +}
> +
> +// fsl_platform_wakeup_enable - Enable wakeup source
> +// @dev: pointer to user's device struct
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_enable(struct device *dev)
> +{
> +	return fsl_platform_wakeup_config(dev, true);
> +}
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> +
> +// fsl_platform_wakeup_disable - Disable wakeup source
> +// @dev: pointer to user's device struct
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_disable(struct device *dev)
> +{
> +	return fsl_platform_wakeup_config(dev, false);
> +}
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> +
> +static int __init fsl_plat_pm_init(void)
> +{
> +	spin_lock_init(&plat_pm.lock);
> +	INIT_LIST_HEAD(&plat_pm.node);
> +	return 0;
> +}
> +
> +core_initcall(fsl_plat_pm_init);
> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> new file mode 100644
> index 0000000..bbe151e
> --- /dev/null
> +++ b/include/soc/fsl/plat_pm.h
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.h - Freescale platform PM Header
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#ifndef __FSL_PLAT_PM_H
> +#define __FSL_PLAT_PM_H
> +
> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> +		void *handle_priv);
> +
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> +		void *handle_priv);
> +int deregister_fsl_platform_wakeup_source(void *handle_priv);
> +int fsl_platform_wakeup_config(struct device *dev, bool flag);
> +int fsl_platform_wakeup_enable(struct device *dev);
> +int fsl_platform_wakeup_disable(struct device *dev);
> +
> +#endif	// __FSL_PLAT_PM_H

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-05  3:04   ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  3:04 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Please change your comments style.=0A=
=0A=
On 2018/8/31 11:57, Ran Wang wrote:=0A=
> This driver is to provide a independent framework for PM service=0A=
> provider and consumer to configure system level wake up feature. For=0A=
> example, RCPM driver could register a callback function on this=0A=
> platform first, and Flex timer driver who want to enable timer wake=0A=
> up feature, will call generic API provided by this platform driver,=0A=
> and then it will trigger RCPM driver to do it. The benefit is to=0A=
> isolate the user and service, such as flex timer driver will not have=0A=
> to know the implement details of wakeup function it require. Besides,=0A=
> it is also easy for service side to upgrade its logic when design is=0A=
> changed and remain user side unchanged.=0A=
>=0A=
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>=0A=
> ---=0A=
>  drivers/soc/fsl/Kconfig   |   14 +++++=0A=
>  drivers/soc/fsl/Makefile  |    1 +=0A=
>  drivers/soc/fsl/plat_pm.c |  144 +++++++++++++++++++++++++++++++++++++++=
++++++=0A=
>  include/soc/fsl/plat_pm.h |   22 +++++++=0A=
>  4 files changed, 181 insertions(+), 0 deletions(-)=0A=
>  create mode 100644 drivers/soc/fsl/plat_pm.c=0A=
>  create mode 100644 include/soc/fsl/plat_pm.h=0A=
>=0A=
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig=0A=
> index 7a9fb9b..6517412 100644=0A=
> --- a/drivers/soc/fsl/Kconfig=0A=
> +++ b/drivers/soc/fsl/Kconfig=0A=
> @@ -16,3 +16,17 @@ config FSL_GUTS=0A=
>  	  Initially only reading SVR and registering soc device are supported.=
=0A=
>  	  Other guts accesses, such as reading RCW, should eventually be moved=
=0A=
>  	  into this driver as well.=0A=
> +=0A=
> +config FSL_PLAT_PM=0A=
> +	bool "Freescale platform PM framework"=0A=
> +	help=0A=
> +	  This driver is to provide a independent framework for PM service=0A=
> +	  provider and consumer to configure system level wake up feature. For=
=0A=
> +	  example, RCPM driver could register a callback function on this=0A=
> +	  platform first, and Flex timer driver who want to enable timer wake=
=0A=
> +	  up feature, will call generic API provided by this platform driver,=
=0A=
> +	  and then it will trigger RCPM driver to do it. The benefit is to=0A=
> +	  isolate the user and service, such as  flex timer driver will not=0A=
> +	  have to know the implement details of wakeup function it require.=0A=
> +	  Besides, it is also easy for service side to upgrade its logic when=
=0A=
> +	  design changed and remain user side unchanged.=0A=
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile=0A=
> index 44b3beb..8f9db23 100644=0A=
> --- a/drivers/soc/fsl/Makefile=0A=
> +++ b/drivers/soc/fsl/Makefile=0A=
> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 +=3D qbman/=0A=
>  obj-$(CONFIG_QUICC_ENGINE)		+=3D qe/=0A=
>  obj-$(CONFIG_CPM)			+=3D qe/=0A=
>  obj-$(CONFIG_FSL_GUTS)			+=3D guts.o=0A=
> +obj-$(CONFIG_FSL_PLAT_PM)	+=3D plat_pm.o=0A=
> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c=0A=
> new file mode 100644=0A=
> index 0000000..19ea14e=0A=
> --- /dev/null=0A=
> +++ b/drivers/soc/fsl/plat_pm.c=0A=
> @@ -0,0 +1,144 @@=0A=
> +// SPDX-License-Identifier: GPL-2.0=0A=
> +//=0A=
> +// plat_pm.c - Freescale platform PM framework=0A=
> +//=0A=
> +// Copyright 2018 NXP=0A=
> +//=0A=
> +// Author: Ran Wang <ran.wang_1@nxp.com>,=0A=
> +=0A=
> +#include <linux/kernel.h>=0A=
> +#include <linux/device.h>=0A=
> +#include <linux/list.h>=0A=
> +#include <linux/slab.h>=0A=
> +#include <linux/err.h>=0A=
> +#include <soc/fsl/plat_pm.h>=0A=
> +=0A=
> +=0A=
> +struct plat_pm_t {=0A=
> +	struct list_head node;=0A=
> +	fsl_plat_pm_handle handle;=0A=
> +	void *handle_priv;=0A=
> +	spinlock_t	lock;=0A=
> +};=0A=
> +=0A=
> +static struct plat_pm_t plat_pm;=0A=
> +=0A=
> +// register_fsl_platform_wakeup_source - Register callback function to p=
lat_pm=0A=
> +// @handle: Pointer to handle PM feature requirement=0A=
> +// @handle_priv: Handler specific data struct=0A=
> +//=0A=
> +// Return 0 on success other negative errno=0A=
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,=0A=
> +		void *handle_priv)=0A=
> +{=0A=
> +	struct plat_pm_t *p;=0A=
> +	unsigned long	flags;=0A=
> +=0A=
> +	if (!handle) {=0A=
> +		pr_err("FSL plat_pm: Handler invalid, reject\n");=0A=
> +		return -EINVAL;=0A=
> +	}=0A=
> +=0A=
> +	p =3D kmalloc(sizeof(*p), GFP_KERNEL);=0A=
> +	if (!p)=0A=
> +		return -ENOMEM;=0A=
> +=0A=
> +	p->handle =3D handle;=0A=
> +	p->handle_priv =3D handle_priv;=0A=
> +=0A=
> +	spin_lock_irqsave(&plat_pm.lock, flags);=0A=
> +	list_add_tail(&p->node, &plat_pm.node);=0A=
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);=0A=
> +=0A=
> +	return 0;=0A=
> +}=0A=
> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);=0A=
> +=0A=
> +// Deregister_fsl_platform_wakeup_source - deregister callback function=
=0A=
> +// @handle_priv: Handler specific data struct=0A=
> +//=0A=
> +// Return 0 on success other negative errno=0A=
> +int deregister_fsl_platform_wakeup_source(void *handle_priv)=0A=
> +{=0A=
> +	struct plat_pm_t *p, *tmp;=0A=
> +	unsigned long	flags;=0A=
> +=0A=
> +	spin_lock_irqsave(&plat_pm.lock, flags);=0A=
> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {=0A=
> +		if (p->handle_priv =3D=3D handle_priv) {=0A=
> +			list_del(&p->node);=0A=
> +			kfree(p);=0A=
> +		}=0A=
> +	}=0A=
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);=0A=
> +	return 0;=0A=
> +}=0A=
> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);=0A=
> +=0A=
> +// fsl_platform_wakeup_config - Configure wakeup source by calling handl=
ers=0A=
> +// @dev: pointer to user's device struct=0A=
> +// @flag: to tell enable or disable wakeup source=0A=
> +//=0A=
> +// Return 0 on success other negative errno=0A=
> +int fsl_platform_wakeup_config(struct device *dev, bool flag)=0A=
> +{=0A=
> +	struct plat_pm_t *p;=0A=
> +	int ret;=0A=
> +	bool success_handled;=0A=
> +	unsigned long	flags;=0A=
> +=0A=
> +	success_handled =3D false;=0A=
> +=0A=
> +	// Will consider success if at least one callback return 0.=0A=
> +	// Also, rest handles still get oppertunity to be executed=0A=
> +	spin_lock_irqsave(&plat_pm.lock, flags);=0A=
> +	list_for_each_entry(p, &plat_pm.node, node) {=0A=
> +		if (p->handle) {=0A=
> +			ret =3D p->handle(dev, flag, p->handle_priv);=0A=
> +			if (!ret)=0A=
> +				success_handled =3D true;=0A=
Miss a break?=0A=
=0A=
> +			else if (ret !=3D -ENODEV) {=0A=
> +				pr_err("FSL plat_pm: Failed to config wakeup source:%d\n", ret);=0A=
Please unlock before return.=0A=
=0A=
> +				return ret;=0A=
> +			}=0A=
> +		} else=0A=
> +			pr_warn("FSL plat_pm: Invalid handler detected, skip\n");=0A=
> +	}=0A=
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);=0A=
> +=0A=
> +	if (success_handled =3D=3D false) {=0A=
> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for wakeup sourc=
e config\n");=0A=
> +		return -ENODEV;=0A=
> +	}=0A=
Add this into the loop.=0A=
> +=0A=
> +	return 0;=0A=
> +}=0A=
> +=0A=
> +// fsl_platform_wakeup_enable - Enable wakeup source=0A=
> +// @dev: pointer to user's device struct=0A=
> +//=0A=
> +// Return 0 on success other negative errno=0A=
> +int fsl_platform_wakeup_enable(struct device *dev)=0A=
> +{=0A=
> +	return fsl_platform_wakeup_config(dev, true);=0A=
> +}=0A=
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);=0A=
> +=0A=
> +// fsl_platform_wakeup_disable - Disable wakeup source=0A=
> +// @dev: pointer to user's device struct=0A=
> +//=0A=
> +// Return 0 on success other negative errno=0A=
> +int fsl_platform_wakeup_disable(struct device *dev)=0A=
> +{=0A=
> +	return fsl_platform_wakeup_config(dev, false);=0A=
> +}=0A=
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);=0A=
> +=0A=
> +static int __init fsl_plat_pm_init(void)=0A=
> +{=0A=
> +	spin_lock_init(&plat_pm.lock);=0A=
> +	INIT_LIST_HEAD(&plat_pm.node);=0A=
> +	return 0;=0A=
> +}=0A=
> +=0A=
> +core_initcall(fsl_plat_pm_init);=0A=
> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h=0A=
> new file mode 100644=0A=
> index 0000000..bbe151e=0A=
> --- /dev/null=0A=
> +++ b/include/soc/fsl/plat_pm.h=0A=
> @@ -0,0 +1,22 @@=0A=
> +// SPDX-License-Identifier: GPL-2.0=0A=
> +//=0A=
> +// plat_pm.h - Freescale platform PM Header=0A=
> +//=0A=
> +// Copyright 2018 NXP=0A=
> +//=0A=
> +// Author: Ran Wang <ran.wang_1@nxp.com>,=0A=
> +=0A=
> +#ifndef __FSL_PLAT_PM_H=0A=
> +#define __FSL_PLAT_PM_H=0A=
> +=0A=
> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,=0A=
> +		void *handle_priv);=0A=
> +=0A=
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,=0A=
> +		void *handle_priv);=0A=
> +int deregister_fsl_platform_wakeup_source(void *handle_priv);=0A=
> +int fsl_platform_wakeup_config(struct device *dev, bool flag);=0A=
> +int fsl_platform_wakeup_enable(struct device *dev);=0A=
> +int fsl_platform_wakeup_disable(struct device *dev);=0A=
> +=0A=
> +#endif	// __FSL_PLAT_PM_H=0A=
=0A=
=0A=

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-05  3:04   ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-05  3:04 UTC (permalink / raw)
  To: linux-arm-kernel

Please change your comments style.

On 2018/8/31 11:57, Ran Wang wrote:
> This driver is to provide a independent framework for PM service
> provider and consumer to configure system level wake up feature. For
> example, RCPM driver could register a callback function on this
> platform first, and Flex timer driver who want to enable timer wake
> up feature, will call generic API provided by this platform driver,
> and then it will trigger RCPM driver to do it. The benefit is to
> isolate the user and service, such as flex timer driver will not have
> to know the implement details of wakeup function it require. Besides,
> it is also easy for service side to upgrade its logic when design is
> changed and remain user side unchanged.
>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |   14 +++++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/plat_pm.c |  144 +++++++++++++++++++++++++++++++++++++++++++++
>  include/soc/fsl/plat_pm.h |   22 +++++++
>  4 files changed, 181 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/plat_pm.c
>  create mode 100644 include/soc/fsl/plat_pm.h
>
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 7a9fb9b..6517412 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -16,3 +16,17 @@ config FSL_GUTS
>  	  Initially only reading SVR and registering soc device are supported.
>  	  Other guts accesses, such as reading RCW, should eventually be moved
>  	  into this driver as well.
> +
> +config FSL_PLAT_PM
> +	bool "Freescale platform PM framework"
> +	help
> +	  This driver is to provide a independent framework for PM service
> +	  provider and consumer to configure system level wake up feature. For
> +	  example, RCPM driver could register a callback function on this
> +	  platform first, and Flex timer driver who want to enable timer wake
> +	  up feature, will call generic API provided by this platform driver,
> +	  and then it will trigger RCPM driver to do it. The benefit is to
> +	  isolate the user and service, such as  flex timer driver will not
> +	  have to know the implement details of wakeup function it require.
> +	  Besides, it is also easy for service side to upgrade its logic when
> +	  design changed and remain user side unchanged.
> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> index 44b3beb..8f9db23 100644
> --- a/drivers/soc/fsl/Makefile
> +++ b/drivers/soc/fsl/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>  obj-$(CONFIG_CPM)			+= qe/
>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> new file mode 100644
> index 0000000..19ea14e
> --- /dev/null
> +++ b/drivers/soc/fsl/plat_pm.c
> @@ -0,0 +1,144 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.c - Freescale platform PM framework
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#include <linux/kernel.h>
> +#include <linux/device.h>
> +#include <linux/list.h>
> +#include <linux/slab.h>
> +#include <linux/err.h>
> +#include <soc/fsl/plat_pm.h>
> +
> +
> +struct plat_pm_t {
> +	struct list_head node;
> +	fsl_plat_pm_handle handle;
> +	void *handle_priv;
> +	spinlock_t	lock;
> +};
> +
> +static struct plat_pm_t plat_pm;
> +
> +// register_fsl_platform_wakeup_source - Register callback function to plat_pm
> +// @handle: Pointer to handle PM feature requirement
> +// @handle_priv: Handler specific data struct
> +//
> +// Return 0 on success other negative errno
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> +		void *handle_priv)
> +{
> +	struct plat_pm_t *p;
> +	unsigned long	flags;
> +
> +	if (!handle) {
> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> +		return -EINVAL;
> +	}
> +
> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> +	if (!p)
> +		return -ENOMEM;
> +
> +	p->handle = handle;
> +	p->handle_priv = handle_priv;
> +
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_add_tail(&p->node, &plat_pm.node);
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> +
> +// Deregister_fsl_platform_wakeup_source - deregister callback function
> +// @handle_priv: Handler specific data struct
> +//
> +// Return 0 on success other negative errno
> +int deregister_fsl_platform_wakeup_source(void *handle_priv)
> +{
> +	struct plat_pm_t *p, *tmp;
> +	unsigned long	flags;
> +
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> +		if (p->handle_priv == handle_priv) {
> +			list_del(&p->node);
> +			kfree(p);
> +		}
> +	}
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> +
> +// fsl_platform_wakeup_config - Configure wakeup source by calling handlers
> +// @dev: pointer to user's device struct
> +// @flag: to tell enable or disable wakeup source
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_config(struct device *dev, bool flag)
> +{
> +	struct plat_pm_t *p;
> +	int ret;
> +	bool success_handled;
> +	unsigned long	flags;
> +
> +	success_handled = false;
> +
> +	// Will consider success if at least one callback return 0.
> +	// Also, rest handles still get oppertunity to be executed
> +	spin_lock_irqsave(&plat_pm.lock, flags);
> +	list_for_each_entry(p, &plat_pm.node, node) {
> +		if (p->handle) {
> +			ret = p->handle(dev, flag, p->handle_priv);
> +			if (!ret)
> +				success_handled = true;
Miss a break?

> +			else if (ret != -ENODEV) {
> +				pr_err("FSL plat_pm: Failed to config wakeup source:%d\n", ret);
Please unlock before return.

> +				return ret;
> +			}
> +		} else
> +			pr_warn("FSL plat_pm: Invalid handler detected, skip\n");
> +	}
> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> +
> +	if (success_handled == false) {
> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for wakeup source config\n");
> +		return -ENODEV;
> +	}
Add this into the loop.
> +
> +	return 0;
> +}
> +
> +// fsl_platform_wakeup_enable - Enable wakeup source
> +// @dev: pointer to user's device struct
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_enable(struct device *dev)
> +{
> +	return fsl_platform_wakeup_config(dev, true);
> +}
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> +
> +// fsl_platform_wakeup_disable - Disable wakeup source
> +// @dev: pointer to user's device struct
> +//
> +// Return 0 on success other negative errno
> +int fsl_platform_wakeup_disable(struct device *dev)
> +{
> +	return fsl_platform_wakeup_config(dev, false);
> +}
> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> +
> +static int __init fsl_plat_pm_init(void)
> +{
> +	spin_lock_init(&plat_pm.lock);
> +	INIT_LIST_HEAD(&plat_pm.node);
> +	return 0;
> +}
> +
> +core_initcall(fsl_plat_pm_init);
> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> new file mode 100644
> index 0000000..bbe151e
> --- /dev/null
> +++ b/include/soc/fsl/plat_pm.h
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0
> +//
> +// plat_pm.h - Freescale platform PM Header
> +//
> +// Copyright 2018 NXP
> +//
> +// Author: Ran Wang <ran.wang_1@nxp.com>,
> +
> +#ifndef __FSL_PLAT_PM_H
> +#define __FSL_PLAT_PM_H
> +
> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> +		void *handle_priv);
> +
> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> +		void *handle_priv);
> +int deregister_fsl_platform_wakeup_source(void *handle_priv);
> +int fsl_platform_wakeup_config(struct device *dev, bool flag);
> +int fsl_platform_wakeup_enable(struct device *dev);
> +int fsl_platform_wakeup_disable(struct device *dev);
> +
> +#endif	// __FSL_PLAT_PM_H

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-09-05  2:57     ` Wang, Dongsheng
  (?)
  (?)
@ 2018-09-05  3:21       ` Li Yang
  -1 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-05  3:21 UTC (permalink / raw)
  To: dongsheng.wang
  Cc: Ran Wang, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
<dongsheng.wang@hxt-semitech.com> wrote:
>
> Please change your comments style.

Although this doesn't get into the Linux kernel coding style
documentation yet, Linus seems changed his mind to prefer // than /*
*/ comment style now.  https://lkml.org/lkml/2017/11/25/133   So the
// style should be acceptable for now.

>
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > index 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >         have to know the implement details of wakeup function it require.
> >         Besides, it is also easy for service side to upgrade its logic when
> >         design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +     bool "Freescale RCPM support"
> > +     depends on (FSL_PLAT_PM)
> > +     help
> > +       This feature is to enable specified wakeup source for system sleep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > index 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> >  obj-$(CONFIG_CPM)                    += qe/
> >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o

Probably use "_" instead of "-" for alignment.

> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > new file mode 100644
> > index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver

The file name here is not the same as the real file name.

> > +//
> > +// Copyright 2018 NXP
> > +//
> > +// Author: Ran Wang <ran.wang_1@nxp.com>,

Where do you need the comma in the end?

> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM   10
> > +
> > +struct rcpm_t {
> > +     struct device *dev;
> > +     void __iomem *ippdexpcr_addr;
> > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source request
> > +// @user_dev: pointer to user's device struct
> > +// @flag: to enable(true) or disable(false) wakeup source
> > +// @handle_priv: pointer to struct rcpm_t instance
> > +//
> > +// Return 0 on success other negative errno

Although Linus preferred this // comment style.  I'm not sure if this
will be handled correctly by the kernel-doc compiler.
https://www.kernel.org/doc/html/v4.18/doc-guide/kernel-doc.html

> > +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
> > +{
> > +     struct rcpm_t *rcpm;
> > +     bool big_endian;
> > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +     void __iomem *ippdexpcr_addr;
> > +     u32 ippdexpcr;
> > +     u32 set_bit;
> > +     int ret, num, i;
> > +
> > +     rcpm = handle_priv;
> > +     big_endian = rcpm->big_endian;
> > +     ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > +
> > +     num = device_property_read_string_array(user_dev, "compatible",
> > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +     if (num < 0)
> > +             return num;
> > +
> > +     for (i = 0; i < num; i++) {
> > +             if (!device_property_present(rcpm->dev,
> > +                                     dev_compatible_array[i]))
> > +                     continue;
> > +             else {
> Remove this else.
> > +                     ret = device_property_read_u32(rcpm->dev,
> > +                                     dev_compatible_array[i], &set_bit);
> > +                     if (ret)
> > +                             return ret;
> > +
> > +                     if (!device_property_present(rcpm->dev,
> > +                                             dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV?
> > +                             return -ENODEV;
> > +                     else {
> Remove this else.
> > +                             ret = device_property_read_u32(rcpm->dev,
> > +                                             dev_compatible_array[i], &set_bit);
> > +                             if (ret)
> > +                                     return ret;
> > +
> > +                             if (big_endian)
> > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > +                             else
> > +                                     ippdexpcr = ioread32(ippdexpcr_addr);
> > +
> > +                             if (flag)
> > +                                     ippdexpcr |= set_bit;
> > +                             else
> > +                                     ippdexpcr &= ~set_bit;
> > +
> > +                             if (big_endian) {
> > +                                     iowrite32be(ippdexpcr, ippdexpcr_addr);
> > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > +                             } else
> if (x) {
> ....
> ....
> }  else {
>
> }
> > +                                     iowrite32(ippdexpcr, ippdexpcr_addr);
> > +
> > +                             return 0;
> > +                     }
> > +             }
> > +     }
> > +
> > +     return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev)
> > +{
> > +     struct resource *r;
> > +     struct rcpm_t *rcpm;
> > +
> > +     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +     if (!r)
> > +             return -ENODEV;
> > +
> > +     rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.
> > +     if (!rcpm)
> > +             return -ENOMEM;
> > +
> > +     rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
> > +
> > +     rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +     rcpm->dev = &pdev->dev;
> > +     platform_set_drvdata(pdev, rcpm);
> > +
> > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > +}
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev)
> > +{
> > +     struct rcpm_t   *rcpm;
> Not need a table.
>
> Cheers,
> -Dongsheng
>
> > +
> > +     rcpm = platform_get_drvdata(pdev);
> > +     deregister_fsl_platform_wakeup_source(rcpm);
> > +     kfree(rcpm);
> > +
> > +     return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] = {
> > +     { .compatible = "fsl,qoriq-rcpm-2.1", },
> > +     {}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver = {
> > +     .driver = {
> > +             .name = "ls-rcpm",
> > +             .of_match_table = ls_rcpm_of_match,
> > +     },
> > +     .probe = ls_rcpm_probe,
> > +     .remove = ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +     return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void)
> > +{
> > +     platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
>
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-05  3:21       ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-05  3:21 UTC (permalink / raw)
  To: dongsheng.wang
  Cc: Ran Wang, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
<dongsheng.wang@hxt-semitech.com> wrote:
>
> Please change your comments style.

Although this doesn't get into the Linux kernel coding style
documentation yet, Linus seems changed his mind to prefer // than /*
*/ comment style now.  https://lkml.org/lkml/2017/11/25/133   So the
// style should be acceptable for now.

>
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > index 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >         have to know the implement details of wakeup function it require.
> >         Besides, it is also easy for service side to upgrade its logic when
> >         design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +     bool "Freescale RCPM support"
> > +     depends on (FSL_PLAT_PM)
> > +     help
> > +       This feature is to enable specified wakeup source for system sleep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > index 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> >  obj-$(CONFIG_CPM)                    += qe/
> >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o

Probably use "_" instead of "-" for alignment.

> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > new file mode 100644
> > index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver

The file name here is not the same as the real file name.

> > +//
> > +// Copyright 2018 NXP
> > +//
> > +// Author: Ran Wang <ran.wang_1@nxp.com>,

Where do you need the comma in the end?

> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM   10
> > +
> > +struct rcpm_t {
> > +     struct device *dev;
> > +     void __iomem *ippdexpcr_addr;
> > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source request
> > +// @user_dev: pointer to user's device struct
> > +// @flag: to enable(true) or disable(false) wakeup source
> > +// @handle_priv: pointer to struct rcpm_t instance
> > +//
> > +// Return 0 on success other negative errno

Although Linus preferred this // comment style.  I'm not sure if this
will be handled correctly by the kernel-doc compiler.
https://www.kernel.org/doc/html/v4.18/doc-guide/kernel-doc.html

> > +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
> > +{
> > +     struct rcpm_t *rcpm;
> > +     bool big_endian;
> > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +     void __iomem *ippdexpcr_addr;
> > +     u32 ippdexpcr;
> > +     u32 set_bit;
> > +     int ret, num, i;
> > +
> > +     rcpm = handle_priv;
> > +     big_endian = rcpm->big_endian;
> > +     ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > +
> > +     num = device_property_read_string_array(user_dev, "compatible",
> > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +     if (num < 0)
> > +             return num;
> > +
> > +     for (i = 0; i < num; i++) {
> > +             if (!device_property_present(rcpm->dev,
> > +                                     dev_compatible_array[i]))
> > +                     continue;
> > +             else {
> Remove this else.
> > +                     ret = device_property_read_u32(rcpm->dev,
> > +                                     dev_compatible_array[i], &set_bit);
> > +                     if (ret)
> > +                             return ret;
> > +
> > +                     if (!device_property_present(rcpm->dev,
> > +                                             dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV?
> > +                             return -ENODEV;
> > +                     else {
> Remove this else.
> > +                             ret = device_property_read_u32(rcpm->dev,
> > +                                             dev_compatible_array[i], &set_bit);
> > +                             if (ret)
> > +                                     return ret;
> > +
> > +                             if (big_endian)
> > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > +                             else
> > +                                     ippdexpcr = ioread32(ippdexpcr_addr);
> > +
> > +                             if (flag)
> > +                                     ippdexpcr |= set_bit;
> > +                             else
> > +                                     ippdexpcr &= ~set_bit;
> > +
> > +                             if (big_endian) {
> > +                                     iowrite32be(ippdexpcr, ippdexpcr_addr);
> > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > +                             } else
> if (x) {
> ....
> ....
> }  else {
>
> }
> > +                                     iowrite32(ippdexpcr, ippdexpcr_addr);
> > +
> > +                             return 0;
> > +                     }
> > +             }
> > +     }
> > +
> > +     return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev)
> > +{
> > +     struct resource *r;
> > +     struct rcpm_t *rcpm;
> > +
> > +     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +     if (!r)
> > +             return -ENODEV;
> > +
> > +     rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.
> > +     if (!rcpm)
> > +             return -ENOMEM;
> > +
> > +     rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
> > +
> > +     rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +     rcpm->dev = &pdev->dev;
> > +     platform_set_drvdata(pdev, rcpm);
> > +
> > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > +}
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev)
> > +{
> > +     struct rcpm_t   *rcpm;
> Not need a table.
>
> Cheers,
> -Dongsheng
>
> > +
> > +     rcpm = platform_get_drvdata(pdev);
> > +     deregister_fsl_platform_wakeup_source(rcpm);
> > +     kfree(rcpm);
> > +
> > +     return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] = {
> > +     { .compatible = "fsl,qoriq-rcpm-2.1", },
> > +     {}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver = {
> > +     .driver = {
> > +             .name = "ls-rcpm",
> > +             .of_match_table = ls_rcpm_of_match,
> > +     },
> > +     .probe = ls_rcpm_probe,
> > +     .remove = ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +     return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void)
> > +{
> > +     platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
>
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-05  3:21       ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-05  3:21 UTC (permalink / raw)
  To: dongsheng.wang
  Cc: Ran Wang, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
<dongsheng.wang@hxt-semitech.com> wrote:
>
> Please change your comments style.

Although this doesn't get into the Linux kernel coding style
documentation yet, Linus seems changed his mind to prefer // than /*
*/ comment style now.  https://lkml.org/lkml/2017/11/25/133   So the
// style should be acceptable for now.

>
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++=
++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > index 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >         have to know the implement details of wakeup function it requir=
e.
> >         Besides, it is also easy for service side to upgrade its logic =
when
> >         design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +     bool "Freescale RCPM support"
> > +     depends on (FSL_PLAT_PM)
> > +     help
> > +       This feature is to enable specified wakeup source for system sl=
eep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > index 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            +=3D qe/
> >  obj-$(CONFIG_CPM)                    +=3D qe/
> >  obj-$(CONFIG_FSL_GUTS)                       +=3D guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)    +=3D plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)                +=3D ls-rcpm.o

Probably use "_" instead of "-" for alignment.

> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > new file mode 100644
> > index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver

The file name here is not the same as the real file name.

> > +//
> > +// Copyright 2018 NXP
> > +//
> > +// Author: Ran Wang <ran.wang_1@nxp.com>,

Where do you need the comma in the end?

> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM   10
> > +
> > +struct rcpm_t {
> > +     struct device *dev;
> > +     void __iomem *ippdexpcr_addr;
> > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source reques=
t
> > +// @user_dev: pointer to user's device struct
> > +// @flag: to enable(true) or disable(false) wakeup source
> > +// @handle_priv: pointer to struct rcpm_t instance
> > +//
> > +// Return 0 on success other negative errno

Although Linus preferred this // comment style.  I'm not sure if this
will be handled correctly by the kernel-doc compiler.
https://www.kernel.org/doc/html/v4.18/doc-guide/kernel-doc.html

> > +static int rcpm_handle(struct device *user_dev, bool flag, void *handl=
e_priv)
> > +{
> > +     struct rcpm_t *rcpm;
> > +     bool big_endian;
> > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +     void __iomem *ippdexpcr_addr;
> > +     u32 ippdexpcr;
> > +     u32 set_bit;
> > +     int ret, num, i;
> > +
> > +     rcpm =3D handle_priv;
> > +     big_endian =3D rcpm->big_endian;
> > +     ippdexpcr_addr =3D rcpm->ippdexpcr_addr;
> > +
> > +     num =3D device_property_read_string_array(user_dev, "compatible",
> > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +     if (num < 0)
> > +             return num;
> > +
> > +     for (i =3D 0; i < num; i++) {
> > +             if (!device_property_present(rcpm->dev,
> > +                                     dev_compatible_array[i]))
> > +                     continue;
> > +             else {
> Remove this else.
> > +                     ret =3D device_property_read_u32(rcpm->dev,
> > +                                     dev_compatible_array[i], &set_bit=
);
> > +                     if (ret)
> > +                             return ret;
> > +
> > +                     if (!device_property_present(rcpm->dev,
> > +                                             dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV=EF=BC=9F
> > +                             return -ENODEV;
> > +                     else {
> Remove this else.
> > +                             ret =3D device_property_read_u32(rcpm->de=
v,
> > +                                             dev_compatible_array[i], =
&set_bit);
> > +                             if (ret)
> > +                                     return ret;
> > +
> > +                             if (big_endian)
> > +                                     ippdexpcr =3D ioread32be(ippdexpc=
r_addr);
> > +                             else
> > +                                     ippdexpcr =3D ioread32(ippdexpcr_=
addr);
> > +
> > +                             if (flag)
> > +                                     ippdexpcr |=3D set_bit;
> > +                             else
> > +                                     ippdexpcr &=3D ~set_bit;
> > +
> > +                             if (big_endian) {
> > +                                     iowrite32be(ippdexpcr, ippdexpcr_=
addr);
> > +                                     ippdexpcr =3D ioread32be(ippdexpc=
r_addr);
> > +                             } else
> if (x) {
> ....
> ....
> }  else {
>
> }
> > +                                     iowrite32(ippdexpcr, ippdexpcr_ad=
dr);
> > +
> > +                             return 0;
> > +                     }
> > +             }
> > +     }
> > +
> > +     return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev)
> > +{
> > +     struct resource *r;
> > +     struct rcpm_t *rcpm;
> > +
> > +     r =3D platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +     if (!r)
> > +             return -ENODEV;
> > +
> > +     rcpm =3D kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.
> > +     if (!rcpm)
> > +             return -ENOMEM;
> > +
> > +     rcpm->big_endian =3D device_property_read_bool(&pdev->dev, "big-e=
ndian");
> > +
> > +     rcpm->ippdexpcr_addr =3D devm_ioremap_resource(&pdev->dev, r);
> > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +     rcpm->dev =3D &pdev->dev;
> > +     platform_set_drvdata(pdev, rcpm);
> > +
> > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > +}
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev)
> > +{
> > +     struct rcpm_t   *rcpm;
> Not need a table.
>
> Cheers,
> -Dongsheng
>
> > +
> > +     rcpm =3D platform_get_drvdata(pdev);
> > +     deregister_fsl_platform_wakeup_source(rcpm);
> > +     kfree(rcpm);
> > +
> > +     return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] =3D {
> > +     { .compatible =3D "fsl,qoriq-rcpm-2.1", },
> > +     {}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver =3D {
> > +     .driver =3D {
> > +             .name =3D "ls-rcpm",
> > +             .of_match_table =3D ls_rcpm_of_match,
> > +     },
> > +     .probe =3D ls_rcpm_probe,
> > +     .remove =3D ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +     return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void)
> > +{
> > +     platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
>
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-05  3:21       ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-05  3:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
<dongsheng.wang@hxt-semitech.com> wrote:
>
> Please change your comments style.

Although this doesn't get into the Linux kernel coding style
documentation yet, Linus seems changed his mind to prefer // than /*
*/ comment style now.  https://lkml.org/lkml/2017/11/25/133   So the
// style should be acceptable for now.

>
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153 +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > index 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >         have to know the implement details of wakeup function it require.
> >         Besides, it is also easy for service side to upgrade its logic when
> >         design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +     bool "Freescale RCPM support"
> > +     depends on (FSL_PLAT_PM)
> > +     help
> > +       This feature is to enable specified wakeup source for system sleep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > index 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> >  obj-$(CONFIG_CPM)                    += qe/
> >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o

Probably use "_" instead of "-" for alignment.

> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > new file mode 100644
> > index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver

The file name here is not the same as the real file name.

> > +//
> > +// Copyright 2018 NXP
> > +//
> > +// Author: Ran Wang <ran.wang_1@nxp.com>,

Where do you need the comma in the end?

> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM   10
> > +
> > +struct rcpm_t {
> > +     struct device *dev;
> > +     void __iomem *ippdexpcr_addr;
> > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source request
> > +// @user_dev: pointer to user's device struct
> > +// @flag: to enable(true) or disable(false) wakeup source
> > +// @handle_priv: pointer to struct rcpm_t instance
> > +//
> > +// Return 0 on success other negative errno

Although Linus preferred this // comment style.  I'm not sure if this
will be handled correctly by the kernel-doc compiler.
https://www.kernel.org/doc/html/v4.18/doc-guide/kernel-doc.html

> > +static int rcpm_handle(struct device *user_dev, bool flag, void *handle_priv)
> > +{
> > +     struct rcpm_t *rcpm;
> > +     bool big_endian;
> > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +     void __iomem *ippdexpcr_addr;
> > +     u32 ippdexpcr;
> > +     u32 set_bit;
> > +     int ret, num, i;
> > +
> > +     rcpm = handle_priv;
> > +     big_endian = rcpm->big_endian;
> > +     ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > +
> > +     num = device_property_read_string_array(user_dev, "compatible",
> > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +     if (num < 0)
> > +             return num;
> > +
> > +     for (i = 0; i < num; i++) {
> > +             if (!device_property_present(rcpm->dev,
> > +                                     dev_compatible_array[i]))
> > +                     continue;
> > +             else {
> Remove this else.
> > +                     ret = device_property_read_u32(rcpm->dev,
> > +                                     dev_compatible_array[i], &set_bit);
> > +                     if (ret)
> > +                             return ret;
> > +
> > +                     if (!device_property_present(rcpm->dev,
> > +                                             dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV?
> > +                             return -ENODEV;
> > +                     else {
> Remove this else.
> > +                             ret = device_property_read_u32(rcpm->dev,
> > +                                             dev_compatible_array[i], &set_bit);
> > +                             if (ret)
> > +                                     return ret;
> > +
> > +                             if (big_endian)
> > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > +                             else
> > +                                     ippdexpcr = ioread32(ippdexpcr_addr);
> > +
> > +                             if (flag)
> > +                                     ippdexpcr |= set_bit;
> > +                             else
> > +                                     ippdexpcr &= ~set_bit;
> > +
> > +                             if (big_endian) {
> > +                                     iowrite32be(ippdexpcr, ippdexpcr_addr);
> > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > +                             } else
> if (x) {
> ....
> ....
> }  else {
>
> }
> > +                                     iowrite32(ippdexpcr, ippdexpcr_addr);
> > +
> > +                             return 0;
> > +                     }
> > +             }
> > +     }
> > +
> > +     return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev)
> > +{
> > +     struct resource *r;
> > +     struct rcpm_t *rcpm;
> > +
> > +     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +     if (!r)
> > +             return -ENODEV;
> > +
> > +     rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.
> > +     if (!rcpm)
> > +             return -ENOMEM;
> > +
> > +     rcpm->big_endian = device_property_read_bool(&pdev->dev, "big-endian");
> > +
> > +     rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +     rcpm->dev = &pdev->dev;
> > +     platform_set_drvdata(pdev, rcpm);
> > +
> > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > +}
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev)
> > +{
> > +     struct rcpm_t   *rcpm;
> Not need a table.
>
> Cheers,
> -Dongsheng
>
> > +
> > +     rcpm = platform_get_drvdata(pdev);
> > +     deregister_fsl_platform_wakeup_source(rcpm);
> > +     kfree(rcpm);
> > +
> > +     return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] = {
> > +     { .compatible = "fsl,qoriq-rcpm-2.1", },
> > +     {}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver = {
> > +     .driver = {
> > +             .name = "ls-rcpm",
> > +             .of_match_table = ls_rcpm_of_match,
> > +     },
> > +     .probe = ls_rcpm_probe,
> > +     .remove = ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +     return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void)
> > +{
> > +     platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
>
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
  2018-09-05  3:04   ` Wang, Dongsheng
  (?)
  (?)
@ 2018-09-07  8:41     ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  8:41 UTC (permalink / raw)
  To: Wang, Dongsheng
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland

Hi Dongsheng

> On 2018/9/5 11:05, Dongsheng Wang wrote:
> 
> Please change your comments style.
> 
> On 2018/8/31 11:57, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are supported.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> moved
> >  	  into this driver as well.
> > +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> > +	help
> > +	  This driver is to provide a independent framework for PM service
> > +	  provider and consumer to configure system level wake up feature.
> For
> > +	  example, RCPM driver could register a callback function on this
> > +	  platform first, and Flex timer driver who want to enable timer wake
> > +	  up feature, will call generic API provided by this platform driver,
> > +	  and then it will trigger RCPM driver to do it. The benefit is to
> > +	  isolate the user and service, such as  flex timer driver will not
> > +	  have to know the implement details of wakeup function it require.
> > +	  Besides, it is also easy for service side to upgrade its logic when
> > +	  design changed and remain user side unchanged.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 44b3beb..8f9db23 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
> >  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >  obj-$(CONFIG_CPM)			+= qe/
> >  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> > +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> > diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
> > file mode 100644 index 0000000..19ea14e
> > --- /dev/null
> > +++ b/drivers/soc/fsl/plat_pm.c
> > @@ -0,0 +1,144 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/device.h>
> > +#include <linux/list.h>
> > +#include <linux/slab.h>
> > +#include <linux/err.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +
> > +struct plat_pm_t {
> > +	struct list_head node;
> > +	fsl_plat_pm_handle handle;
> > +	void *handle_priv;
> > +	spinlock_t	lock;
> > +};
> > +
> > +static struct plat_pm_t plat_pm;
> > +
> > +// register_fsl_platform_wakeup_source - Register callback function
> > +to plat_pm // @handle: Pointer to handle PM feature requirement //
> > +@handle_priv: Handler specific data struct // // Return 0 on success
> > +other negative errno int
> > +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv)
> > +{
> > +	struct plat_pm_t *p;
> > +	unsigned long	flags;
> > +
> > +	if (!handle) {
> > +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> > +	if (!p)
> > +		return -ENOMEM;
> > +
> > +	p->handle = handle;
> > +	p->handle_priv = handle_priv;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_add_tail(&p->node, &plat_pm.node);
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> > +
> > +// Deregister_fsl_platform_wakeup_source - deregister callback
> > +function // @handle_priv: Handler specific data struct // // Return 0
> > +on success other negative errno int
> > +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> > +	struct plat_pm_t *p, *tmp;
> > +	unsigned long	flags;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> > +		if (p->handle_priv == handle_priv) {
> > +			list_del(&p->node);
> > +			kfree(p);
> > +		}
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> > +
> > +// fsl_platform_wakeup_config - Configure wakeup source by calling
> > +handlers // @dev: pointer to user's device struct // @flag: to tell
> > +enable or disable wakeup source // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_config(struct device *dev,
> > +bool flag) {
> > +	struct plat_pm_t *p;
> > +	int ret;
> > +	bool success_handled;
> > +	unsigned long	flags;
> > +
> > +	success_handled = false;
> > +
> > +	// Will consider success if at least one callback return 0.
> > +	// Also, rest handles still get oppertunity to be executed
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry(p, &plat_pm.node, node) {
> > +		if (p->handle) {
> > +			ret = p->handle(dev, flag, p->handle_priv);
> > +			if (!ret)
> > +				success_handled = true;
> Miss a break?

Actually my idea is to allow more than one registered handler to handle this
request, so I define a flag rather than return to indicated if there is at least one handler successfully
do it. This design might give more flexibility to framework when running.

> > +			else if (ret != -ENODEV) {
> > +				pr_err("FSL plat_pm: Failed to config wakeup
> source:%d\n", ret);
> Please unlock before return.

Yes, will fix it in next version, thanks for pointing out!

> > +				return ret;
> > +			}
> > +		} else
> > +			pr_warn("FSL plat_pm: Invalid handler detected,
> skip\n");
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	if (success_handled == false) {
> > +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> wakeup source config\n");
> > +		return -ENODEV;
> > +	}
> Add this into the loop.

My design is that if the 1st handler return -ENODEV to indicated this device it doesn't support, 
then the framework will continue try 2nd handler...

So I think it is needed to place this checking out of loop, what do you say?

Regards,
Ran
> > +
> > +	return 0;
> > +}
> > +
> > +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
> > +to user's device struct // // Return 0 on success other negative
> > +errno int fsl_platform_wakeup_enable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, true); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> > +
> > +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> > +pointer to user's device struct // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, false); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> > +
> > +static int __init fsl_plat_pm_init(void) {
> > +	spin_lock_init(&plat_pm.lock);
> > +	INIT_LIST_HEAD(&plat_pm.node);
> > +	return 0;
> > +}
> > +
> > +core_initcall(fsl_plat_pm_init);
> > diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
> > file mode 100644 index 0000000..bbe151e
> > --- /dev/null
> > +++ b/include/soc/fsl/plat_pm.h
> > @@ -0,0 +1,22 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
> > +// // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#ifndef __FSL_PLAT_PM_H
> > +#define __FSL_PLAT_PM_H
> > +
> > +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> > +		void *handle_priv);
> > +
> > +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv);
> > +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> > +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> > +fsl_platform_wakeup_enable(struct device *dev); int
> > +fsl_platform_wakeup_disable(struct device *dev);
> > +
> > +#endif	// __FSL_PLAT_PM_H
> 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07  8:41     ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  8:41 UTC (permalink / raw)
  To: Wang, Dongsheng
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland

Hi Dongsheng

> On 2018/9/5 11:05, Dongsheng Wang wrote:
> 
> Please change your comments style.
> 
> On 2018/8/31 11:57, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are supported.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> moved
> >  	  into this driver as well.
> > +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> > +	help
> > +	  This driver is to provide a independent framework for PM service
> > +	  provider and consumer to configure system level wake up feature.
> For
> > +	  example, RCPM driver could register a callback function on this
> > +	  platform first, and Flex timer driver who want to enable timer wake
> > +	  up feature, will call generic API provided by this platform driver,
> > +	  and then it will trigger RCPM driver to do it. The benefit is to
> > +	  isolate the user and service, such as  flex timer driver will not
> > +	  have to know the implement details of wakeup function it require.
> > +	  Besides, it is also easy for service side to upgrade its logic when
> > +	  design changed and remain user side unchanged.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 44b3beb..8f9db23 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
> >  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >  obj-$(CONFIG_CPM)			+= qe/
> >  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> > +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> > diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
> > file mode 100644 index 0000000..19ea14e
> > --- /dev/null
> > +++ b/drivers/soc/fsl/plat_pm.c
> > @@ -0,0 +1,144 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/device.h>
> > +#include <linux/list.h>
> > +#include <linux/slab.h>
> > +#include <linux/err.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +
> > +struct plat_pm_t {
> > +	struct list_head node;
> > +	fsl_plat_pm_handle handle;
> > +	void *handle_priv;
> > +	spinlock_t	lock;
> > +};
> > +
> > +static struct plat_pm_t plat_pm;
> > +
> > +// register_fsl_platform_wakeup_source - Register callback function
> > +to plat_pm // @handle: Pointer to handle PM feature requirement //
> > +@handle_priv: Handler specific data struct // // Return 0 on success
> > +other negative errno int
> > +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv)
> > +{
> > +	struct plat_pm_t *p;
> > +	unsigned long	flags;
> > +
> > +	if (!handle) {
> > +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> > +	if (!p)
> > +		return -ENOMEM;
> > +
> > +	p->handle = handle;
> > +	p->handle_priv = handle_priv;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_add_tail(&p->node, &plat_pm.node);
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> > +
> > +// Deregister_fsl_platform_wakeup_source - deregister callback
> > +function // @handle_priv: Handler specific data struct // // Return 0
> > +on success other negative errno int
> > +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> > +	struct plat_pm_t *p, *tmp;
> > +	unsigned long	flags;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> > +		if (p->handle_priv == handle_priv) {
> > +			list_del(&p->node);
> > +			kfree(p);
> > +		}
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> > +
> > +// fsl_platform_wakeup_config - Configure wakeup source by calling
> > +handlers // @dev: pointer to user's device struct // @flag: to tell
> > +enable or disable wakeup source // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_config(struct device *dev,
> > +bool flag) {
> > +	struct plat_pm_t *p;
> > +	int ret;
> > +	bool success_handled;
> > +	unsigned long	flags;
> > +
> > +	success_handled = false;
> > +
> > +	// Will consider success if at least one callback return 0.
> > +	// Also, rest handles still get oppertunity to be executed
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry(p, &plat_pm.node, node) {
> > +		if (p->handle) {
> > +			ret = p->handle(dev, flag, p->handle_priv);
> > +			if (!ret)
> > +				success_handled = true;
> Miss a break?

Actually my idea is to allow more than one registered handler to handle this
request, so I define a flag rather than return to indicated if there is at least one handler successfully
do it. This design might give more flexibility to framework when running.

> > +			else if (ret != -ENODEV) {
> > +				pr_err("FSL plat_pm: Failed to config wakeup
> source:%d\n", ret);
> Please unlock before return.

Yes, will fix it in next version, thanks for pointing out!

> > +				return ret;
> > +			}
> > +		} else
> > +			pr_warn("FSL plat_pm: Invalid handler detected,
> skip\n");
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	if (success_handled == false) {
> > +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> wakeup source config\n");
> > +		return -ENODEV;
> > +	}
> Add this into the loop.

My design is that if the 1st handler return -ENODEV to indicated this device it doesn't support, 
then the framework will continue try 2nd handler...

So I think it is needed to place this checking out of loop, what do you say?

Regards,
Ran
> > +
> > +	return 0;
> > +}
> > +
> > +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
> > +to user's device struct // // Return 0 on success other negative
> > +errno int fsl_platform_wakeup_enable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, true); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> > +
> > +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> > +pointer to user's device struct // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, false); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> > +
> > +static int __init fsl_plat_pm_init(void) {
> > +	spin_lock_init(&plat_pm.lock);
> > +	INIT_LIST_HEAD(&plat_pm.node);
> > +	return 0;
> > +}
> > +
> > +core_initcall(fsl_plat_pm_init);
> > diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
> > file mode 100644 index 0000000..bbe151e
> > --- /dev/null
> > +++ b/include/soc/fsl/plat_pm.h
> > @@ -0,0 +1,22 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
> > +// // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#ifndef __FSL_PLAT_PM_H
> > +#define __FSL_PLAT_PM_H
> > +
> > +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> > +		void *handle_priv);
> > +
> > +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv);
> > +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> > +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> > +fsl_platform_wakeup_enable(struct device *dev); int
> > +fsl_platform_wakeup_disable(struct device *dev);
> > +
> > +#endif	// __FSL_PLAT_PM_H
> 

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07  8:41     ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  8:41 UTC (permalink / raw)
  To: Wang, Dongsheng
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland

Hi Dongsheng

> On 2018/9/5 11:05, Dongsheng Wang wrote:
>=20
> Please change your comments style.
>=20
> On 2018/8/31 11:57, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are supported=
.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> moved
> >  	  into this driver as well.
> > +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> > +	help
> > +	  This driver is to provide a independent framework for PM service
> > +	  provider and consumer to configure system level wake up feature.
> For
> > +	  example, RCPM driver could register a callback function on this
> > +	  platform first, and Flex timer driver who want to enable timer wake
> > +	  up feature, will call generic API provided by this platform driver,
> > +	  and then it will trigger RCPM driver to do it. The benefit is to
> > +	  isolate the user and service, such as  flex timer driver will not
> > +	  have to know the implement details of wakeup function it require.
> > +	  Besides, it is also easy for service side to upgrade its logic when
> > +	  design changed and remain user side unchanged.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 44b3beb..8f9db23 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 +=3D qbman/
> >  obj-$(CONFIG_QUICC_ENGINE)		+=3D qe/
> >  obj-$(CONFIG_CPM)			+=3D qe/
> >  obj-$(CONFIG_FSL_GUTS)			+=3D guts.o
> > +obj-$(CONFIG_FSL_PLAT_PM)	+=3D plat_pm.o
> > diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
> > file mode 100644 index 0000000..19ea14e
> > --- /dev/null
> > +++ b/drivers/soc/fsl/plat_pm.c
> > @@ -0,0 +1,144 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/device.h>
> > +#include <linux/list.h>
> > +#include <linux/slab.h>
> > +#include <linux/err.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +
> > +struct plat_pm_t {
> > +	struct list_head node;
> > +	fsl_plat_pm_handle handle;
> > +	void *handle_priv;
> > +	spinlock_t	lock;
> > +};
> > +
> > +static struct plat_pm_t plat_pm;
> > +
> > +// register_fsl_platform_wakeup_source - Register callback function
> > +to plat_pm // @handle: Pointer to handle PM feature requirement //
> > +@handle_priv: Handler specific data struct // // Return 0 on success
> > +other negative errno int
> > +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv)
> > +{
> > +	struct plat_pm_t *p;
> > +	unsigned long	flags;
> > +
> > +	if (!handle) {
> > +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	p =3D kmalloc(sizeof(*p), GFP_KERNEL);
> > +	if (!p)
> > +		return -ENOMEM;
> > +
> > +	p->handle =3D handle;
> > +	p->handle_priv =3D handle_priv;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_add_tail(&p->node, &plat_pm.node);
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> > +
> > +// Deregister_fsl_platform_wakeup_source - deregister callback
> > +function // @handle_priv: Handler specific data struct // // Return 0
> > +on success other negative errno int
> > +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> > +	struct plat_pm_t *p, *tmp;
> > +	unsigned long	flags;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> > +		if (p->handle_priv =3D=3D handle_priv) {
> > +			list_del(&p->node);
> > +			kfree(p);
> > +		}
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> > +
> > +// fsl_platform_wakeup_config - Configure wakeup source by calling
> > +handlers // @dev: pointer to user's device struct // @flag: to tell
> > +enable or disable wakeup source // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_config(struct device *dev,
> > +bool flag) {
> > +	struct plat_pm_t *p;
> > +	int ret;
> > +	bool success_handled;
> > +	unsigned long	flags;
> > +
> > +	success_handled =3D false;
> > +
> > +	// Will consider success if at least one callback return 0.
> > +	// Also, rest handles still get oppertunity to be executed
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry(p, &plat_pm.node, node) {
> > +		if (p->handle) {
> > +			ret =3D p->handle(dev, flag, p->handle_priv);
> > +			if (!ret)
> > +				success_handled =3D true;
> Miss a break?

Actually my idea is to allow more than one registered handler to handle thi=
s
request, so I define a flag rather than return to indicated if there is at =
least one handler successfully
do it. This design might give more flexibility to framework when running.

> > +			else if (ret !=3D -ENODEV) {
> > +				pr_err("FSL plat_pm: Failed to config wakeup
> source:%d\n", ret);
> Please unlock before return.

Yes, will fix it in next version, thanks for pointing out!

> > +				return ret;
> > +			}
> > +		} else
> > +			pr_warn("FSL plat_pm: Invalid handler detected,
> skip\n");
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	if (success_handled =3D=3D false) {
> > +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> wakeup source config\n");
> > +		return -ENODEV;
> > +	}
> Add this into the loop.

My design is that if the 1st handler return -ENODEV to indicated this devic=
e it doesn't support,=20
then the framework will continue try 2nd handler...

So I think it is needed to place this checking out of loop, what do you say=
?

Regards,
Ran
> > +
> > +	return 0;
> > +}
> > +
> > +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
> > +to user's device struct // // Return 0 on success other negative
> > +errno int fsl_platform_wakeup_enable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, true); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> > +
> > +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> > +pointer to user's device struct // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, false); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> > +
> > +static int __init fsl_plat_pm_init(void) {
> > +	spin_lock_init(&plat_pm.lock);
> > +	INIT_LIST_HEAD(&plat_pm.node);
> > +	return 0;
> > +}
> > +
> > +core_initcall(fsl_plat_pm_init);
> > diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
> > file mode 100644 index 0000000..bbe151e
> > --- /dev/null
> > +++ b/include/soc/fsl/plat_pm.h
> > @@ -0,0 +1,22 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
> > +// // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#ifndef __FSL_PLAT_PM_H
> > +#define __FSL_PLAT_PM_H
> > +
> > +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> > +		void *handle_priv);
> > +
> > +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv);
> > +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> > +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> > +fsl_platform_wakeup_enable(struct device *dev); int
> > +fsl_platform_wakeup_disable(struct device *dev);
> > +
> > +#endif	// __FSL_PLAT_PM_H
>=20

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07  8:41     ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  8:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Dongsheng

> On 2018/9/5 11:05, Dongsheng Wang wrote:
> 
> Please change your comments style.
> 
> On 2018/8/31 11:57, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are supported.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> moved
> >  	  into this driver as well.
> > +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> > +	help
> > +	  This driver is to provide a independent framework for PM service
> > +	  provider and consumer to configure system level wake up feature.
> For
> > +	  example, RCPM driver could register a callback function on this
> > +	  platform first, and Flex timer driver who want to enable timer wake
> > +	  up feature, will call generic API provided by this platform driver,
> > +	  and then it will trigger RCPM driver to do it. The benefit is to
> > +	  isolate the user and service, such as  flex timer driver will not
> > +	  have to know the implement details of wakeup function it require.
> > +	  Besides, it is also easy for service side to upgrade its logic when
> > +	  design changed and remain user side unchanged.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 44b3beb..8f9db23 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
> >  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >  obj-$(CONFIG_CPM)			+= qe/
> >  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> > +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> > diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
> > file mode 100644 index 0000000..19ea14e
> > --- /dev/null
> > +++ b/drivers/soc/fsl/plat_pm.c
> > @@ -0,0 +1,144 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/device.h>
> > +#include <linux/list.h>
> > +#include <linux/slab.h>
> > +#include <linux/err.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +
> > +struct plat_pm_t {
> > +	struct list_head node;
> > +	fsl_plat_pm_handle handle;
> > +	void *handle_priv;
> > +	spinlock_t	lock;
> > +};
> > +
> > +static struct plat_pm_t plat_pm;
> > +
> > +// register_fsl_platform_wakeup_source - Register callback function
> > +to plat_pm // @handle: Pointer to handle PM feature requirement //
> > + at handle_priv: Handler specific data struct // // Return 0 on success
> > +other negative errno int
> > +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv)
> > +{
> > +	struct plat_pm_t *p;
> > +	unsigned long	flags;
> > +
> > +	if (!handle) {
> > +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> > +	if (!p)
> > +		return -ENOMEM;
> > +
> > +	p->handle = handle;
> > +	p->handle_priv = handle_priv;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_add_tail(&p->node, &plat_pm.node);
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> > +
> > +// Deregister_fsl_platform_wakeup_source - deregister callback
> > +function // @handle_priv: Handler specific data struct // // Return 0
> > +on success other negative errno int
> > +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> > +	struct plat_pm_t *p, *tmp;
> > +	unsigned long	flags;
> > +
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> > +		if (p->handle_priv == handle_priv) {
> > +			list_del(&p->node);
> > +			kfree(p);
> > +		}
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> > +
> > +// fsl_platform_wakeup_config - Configure wakeup source by calling
> > +handlers // @dev: pointer to user's device struct // @flag: to tell
> > +enable or disable wakeup source // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_config(struct device *dev,
> > +bool flag) {
> > +	struct plat_pm_t *p;
> > +	int ret;
> > +	bool success_handled;
> > +	unsigned long	flags;
> > +
> > +	success_handled = false;
> > +
> > +	// Will consider success if at least one callback return 0.
> > +	// Also, rest handles still get oppertunity to be executed
> > +	spin_lock_irqsave(&plat_pm.lock, flags);
> > +	list_for_each_entry(p, &plat_pm.node, node) {
> > +		if (p->handle) {
> > +			ret = p->handle(dev, flag, p->handle_priv);
> > +			if (!ret)
> > +				success_handled = true;
> Miss a break?

Actually my idea is to allow more than one registered handler to handle this
request, so I define a flag rather than return to indicated if there is at least one handler successfully
do it. This design might give more flexibility to framework when running.

> > +			else if (ret != -ENODEV) {
> > +				pr_err("FSL plat_pm: Failed to config wakeup
> source:%d\n", ret);
> Please unlock before return.

Yes, will fix it in next version, thanks for pointing out!

> > +				return ret;
> > +			}
> > +		} else
> > +			pr_warn("FSL plat_pm: Invalid handler detected,
> skip\n");
> > +	}
> > +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> > +
> > +	if (success_handled == false) {
> > +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> wakeup source config\n");
> > +		return -ENODEV;
> > +	}
> Add this into the loop.

My design is that if the 1st handler return -ENODEV to indicated this device it doesn't support, 
then the framework will continue try 2nd handler...

So I think it is needed to place this checking out of loop, what do you say?

Regards,
Ran
> > +
> > +	return 0;
> > +}
> > +
> > +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
> > +to user's device struct // // Return 0 on success other negative
> > +errno int fsl_platform_wakeup_enable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, true); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> > +
> > +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> > +pointer to user's device struct // // Return 0 on success other
> > +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> > +	return fsl_platform_wakeup_config(dev, false); }
> > +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> > +
> > +static int __init fsl_plat_pm_init(void) {
> > +	spin_lock_init(&plat_pm.lock);
> > +	INIT_LIST_HEAD(&plat_pm.node);
> > +	return 0;
> > +}
> > +
> > +core_initcall(fsl_plat_pm_init);
> > diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
> > file mode 100644 index 0000000..bbe151e
> > --- /dev/null
> > +++ b/include/soc/fsl/plat_pm.h
> > @@ -0,0 +1,22 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
> > +// // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#ifndef __FSL_PLAT_PM_H
> > +#define __FSL_PLAT_PM_H
> > +
> > +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> > +		void *handle_priv);
> > +
> > +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> > +		void *handle_priv);
> > +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> > +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> > +fsl_platform_wakeup_enable(struct device *dev); int
> > +fsl_platform_wakeup_disable(struct device *dev);
> > +
> > +#endif	// __FSL_PLAT_PM_H
> 

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-09-05  2:57     ` Wang, Dongsheng
  (?)
  (?)
@ 2018-09-07  9:32       ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:32 UTC (permalink / raw)
  To: Wang, Dongsheng, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Hi Dongsheng,

On 2018/9/5 10:58, Dongsheng Wang wrote:
> 
> Please change your comments style.
> 
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >  	  have to know the implement details of wakeup function it require.
> >  	  Besides, it is also easy for service side to upgrade its logic when
> >  	  design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +	bool "Freescale RCPM support"
> > +	depends on (FSL_PLAT_PM)
> > +	help
> > +	  This feature is to enable specified wakeup source for system sleep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >  obj-$(CONFIG_CPM)			+= qe/
> >  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c new
> > file mode 100644 index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM	10
> > +
> > +struct rcpm_t {
> > +	struct device *dev;
> > +	void __iomem *ippdexpcr_addr;
> > +	bool big_endian;	/* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source
> > +request // @user_dev: pointer to user's device struct // @flag: to
> > +enable(true) or disable(false) wakeup source // @handle_priv: pointer
> > +to struct rcpm_t instance // // Return 0 on success other negative
> > +errno static int rcpm_handle(struct device *user_dev, bool flag, void
> > +*handle_priv) {
> > +	struct rcpm_t *rcpm;
> > +	bool big_endian;
> > +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +	void __iomem *ippdexpcr_addr;
> > +	u32 ippdexpcr;
> > +	u32 set_bit;
> > +	int ret, num, i;
> > +
> > +	rcpm = handle_priv;
> > +	big_endian = rcpm->big_endian;
> > +	ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > +
> > +	num = device_property_read_string_array(user_dev, "compatible",
> > +			dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +	if (num < 0)
> > +		return num;
> > +
> > +	for (i = 0; i < num; i++) {
> > +		if (!device_property_present(rcpm->dev,
> > +					dev_compatible_array[i]))
> > +			continue;
> > +		else {
> Remove this else.

Got it! Will update in next version.

> > +			ret = device_property_read_u32(rcpm->dev,
> > +					dev_compatible_array[i], &set_bit);
> > +			if (ret)
> > +				return ret;
> > +
> > +			if (!device_property_present(rcpm->dev,
> > +						dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV?

Yes, this checking is not necessary, will remove in next version

> > +				return -ENODEV;
> > +			else {
> Remove this else.

OK

> > +				ret = device_property_read_u32(rcpm->dev,
> > +						dev_compatible_array[i],
> &set_bit);
> > +				if (ret)
> > +					return ret;
> > +
> > +				if (big_endian)
> > +					ippdexpcr =
> ioread32be(ippdexpcr_addr);
> > +				else
> > +					ippdexpcr =
> ioread32(ippdexpcr_addr);
> > +
> > +				if (flag)
> > +					ippdexpcr |= set_bit;
> > +				else
> > +					ippdexpcr &= ~set_bit;
> > +
> > +				if (big_endian) {
> > +					iowrite32be(ippdexpcr,
> ippdexpcr_addr);
> > +					ippdexpcr =
> ioread32be(ippdexpcr_addr);
> > +				} else
> if (x) {
> ....
> ....
> }  else {
> 
> }

Got it!

> > +					iowrite32(ippdexpcr, ippdexpcr_addr);
> > +
> > +				return 0;
> > +			}
> > +		}
> > +	}
> > +
> > +	return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev) {
> > +	struct resource *r;
> > +	struct rcpm_t *rcpm;
> > +
> > +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	if (!r)
> > +		return -ENODEV;
> > +
> > +	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.

OK

> > +	if (!rcpm)
> > +		return -ENOMEM;
> > +
> > +	rcpm->big_endian = device_property_read_bool(&pdev->dev,
> > +"big-endian");
> > +
> > +	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > +	if (IS_ERR(rcpm->ippdexpcr_addr))
> > +		return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +	rcpm->dev = &pdev->dev;
> > +	platform_set_drvdata(pdev, rcpm);
> > +
> > +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm); }
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev) {
> > +	struct rcpm_t	*rcpm;
> Not need a table.

OK, thanks for your careful review.

Regards,
Ran
 

> Cheers,
> -Dongsheng
> 
> > +
> > +	rcpm = platform_get_drvdata(pdev);
> > +	deregister_fsl_platform_wakeup_source(rcpm);
> > +	kfree(rcpm);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] = {
> > +	{ .compatible = "fsl,qoriq-rcpm-2.1", },
> > +	{}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver = {
> > +	.driver = {
> > +		.name = "ls-rcpm",
> > +		.of_match_table = ls_rcpm_of_match,
> > +	},
> > +	.probe = ls_rcpm_probe,
> > +	.remove = ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +	return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void) {
> > +	platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
> 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07  9:32       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:32 UTC (permalink / raw)
  To: Wang, Dongsheng, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

Hi Dongsheng,

On 2018/9/5 10:58, Dongsheng Wang wrote:
> 
> Please change your comments style.
> 
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >  	  have to know the implement details of wakeup function it require.
> >  	  Besides, it is also easy for service side to upgrade its logic when
> >  	  design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +	bool "Freescale RCPM support"
> > +	depends on (FSL_PLAT_PM)
> > +	help
> > +	  This feature is to enable specified wakeup source for system sleep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >  obj-$(CONFIG_CPM)			+= qe/
> >  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c new
> > file mode 100644 index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM	10
> > +
> > +struct rcpm_t {
> > +	struct device *dev;
> > +	void __iomem *ippdexpcr_addr;
> > +	bool big_endian;	/* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source
> > +request // @user_dev: pointer to user's device struct // @flag: to
> > +enable(true) or disable(false) wakeup source // @handle_priv: pointer
> > +to struct rcpm_t instance // // Return 0 on success other negative
> > +errno static int rcpm_handle(struct device *user_dev, bool flag, void
> > +*handle_priv) {
> > +	struct rcpm_t *rcpm;
> > +	bool big_endian;
> > +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +	void __iomem *ippdexpcr_addr;
> > +	u32 ippdexpcr;
> > +	u32 set_bit;
> > +	int ret, num, i;
> > +
> > +	rcpm = handle_priv;
> > +	big_endian = rcpm->big_endian;
> > +	ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > +
> > +	num = device_property_read_string_array(user_dev, "compatible",
> > +			dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +	if (num < 0)
> > +		return num;
> > +
> > +	for (i = 0; i < num; i++) {
> > +		if (!device_property_present(rcpm->dev,
> > +					dev_compatible_array[i]))
> > +			continue;
> > +		else {
> Remove this else.

Got it! Will update in next version.

> > +			ret = device_property_read_u32(rcpm->dev,
> > +					dev_compatible_array[i], &set_bit);
> > +			if (ret)
> > +				return ret;
> > +
> > +			if (!device_property_present(rcpm->dev,
> > +						dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV?

Yes, this checking is not necessary, will remove in next version

> > +				return -ENODEV;
> > +			else {
> Remove this else.

OK

> > +				ret = device_property_read_u32(rcpm->dev,
> > +						dev_compatible_array[i],
> &set_bit);
> > +				if (ret)
> > +					return ret;
> > +
> > +				if (big_endian)
> > +					ippdexpcr =
> ioread32be(ippdexpcr_addr);
> > +				else
> > +					ippdexpcr =
> ioread32(ippdexpcr_addr);
> > +
> > +				if (flag)
> > +					ippdexpcr |= set_bit;
> > +				else
> > +					ippdexpcr &= ~set_bit;
> > +
> > +				if (big_endian) {
> > +					iowrite32be(ippdexpcr,
> ippdexpcr_addr);
> > +					ippdexpcr =
> ioread32be(ippdexpcr_addr);
> > +				} else
> if (x) {
> ....
> ....
> }  else {
> 
> }

Got it!

> > +					iowrite32(ippdexpcr, ippdexpcr_addr);
> > +
> > +				return 0;
> > +			}
> > +		}
> > +	}
> > +
> > +	return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev) {
> > +	struct resource *r;
> > +	struct rcpm_t *rcpm;
> > +
> > +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	if (!r)
> > +		return -ENODEV;
> > +
> > +	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.

OK

> > +	if (!rcpm)
> > +		return -ENOMEM;
> > +
> > +	rcpm->big_endian = device_property_read_bool(&pdev->dev,
> > +"big-endian");
> > +
> > +	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > +	if (IS_ERR(rcpm->ippdexpcr_addr))
> > +		return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +	rcpm->dev = &pdev->dev;
> > +	platform_set_drvdata(pdev, rcpm);
> > +
> > +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm); }
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev) {
> > +	struct rcpm_t	*rcpm;
> Not need a table.

OK, thanks for your careful review.

Regards,
Ran
 

> Cheers,
> -Dongsheng
> 
> > +
> > +	rcpm = platform_get_drvdata(pdev);
> > +	deregister_fsl_platform_wakeup_source(rcpm);
> > +	kfree(rcpm);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] = {
> > +	{ .compatible = "fsl,qoriq-rcpm-2.1", },
> > +	{}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver = {
> > +	.driver = {
> > +		.name = "ls-rcpm",
> > +		.of_match_table = ls_rcpm_of_match,
> > +	},
> > +	.probe = ls_rcpm_probe,
> > +	.remove = ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +	return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void) {
> > +	platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
> 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07  9:32       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:32 UTC (permalink / raw)
  To: Wang, Dongsheng, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

SGkgRG9uZ3NoZW5nLA0KDQpPbiAyMDE4LzkvNSAxMDo1OCwgRG9uZ3NoZW5nIFdhbmcgd3JvdGU6
DQo+IA0KPiBQbGVhc2UgY2hhbmdlIHlvdXIgY29tbWVudH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jEiLCB9LA0KPiA+ICsJe30NCj4gPiArfTsNCj4gPiArTU9EVUxFX0RF
VklDRV9UQUJMRShvZiwgbHNfcmNwbV9vZl9tYXRjaCk7DQo+ID4gKw0KPiA+ICtzdGF0aWMgc3Ry
dWN0IHBsYXRmb3JtX2RyaXZlciBsc19yY3BtX2RyaXZlciA9IHsNCj4gPiArCS5kcml2ZXIgPSB7
DQo+ID4gKwkJLm5hbWUgPSAibHMtcmNwbSIsDQo+ID4gKwkJLm9mX21hdGNoX3RhYmxlID0gbHNf
cmNwbV9vZl9tYXRjaCwNCj4gPiArCX0sDQo+ID4gKwkucHJvYmUgPSBsc19yY3BtX3Byb2JlLA0K
PiA+ICsJLnJlbW92ZSA9IGxzX3JjcG1fcmVtb3ZlLA0KPiA+ICt9Ow0KPiA+ICsNCj4gPiArc3Rh
dGljIGludCBfX2luaXQgbHNfcmNwbV9pbml0KHZvaWQpDQo+ID4gK3sNCj4gPiArCXJldHVybiBw
bGF0Zm9ybV9kcml2ZXJfcmVnaXN0ZXIoJmxzX3JjcG1fZHJpdmVyKTsNCj4gPiArfQ0KPiA+ICtz
dWJzeXNfaW5pdGNhbGwobHNfcmNwbV9pbml0KTsNCj4gPiArDQo+ID4gK3N0YXRpYyB2b2lkIF9f
ZXhpdCBsc19yY3BtX2V4aXQodm9pZCkgew0KPiA+ICsJcGxhdGZvcm1fZHJpdmVyX3VucmVnaXN0
ZXIoJmxzX3JjcG1fZHJpdmVyKTsNCj4gPiArfQ0KPiA+ICttb2R1bGVfZXhpdChsc19yY3BtX2V4
aXQpOw0KPiANCg0K

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07  9:32       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Dongsheng,

On 2018/9/5 10:58, Dongsheng Wang wrote:
> 
> Please change your comments style.
> 
> On 2018/8/31 11:56, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/ls-rcpm.c
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >  	  have to know the implement details of wakeup function it require.
> >  	  Besides, it is also easy for service side to upgrade its logic when
> >  	  design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +	bool "Freescale RCPM support"
> > +	depends on (FSL_PLAT_PM)
> > +	help
> > +	  This feature is to enable specified wakeup source for system sleep.
> > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
> > 8f9db23..43ff71a 100644
> > --- a/drivers/soc/fsl/Makefile
> > +++ b/drivers/soc/fsl/Makefile
> > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >  obj-$(CONFIG_CPM)			+= qe/
> >  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> >  obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> > +obj-$(CONFIG_LS_RCPM)		+= ls-rcpm.o
> > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c new
> > file mode 100644 index 0000000..b0feb88
> > --- /dev/null
> > +++ b/drivers/soc/fsl/ls-rcpm.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// plat_pm.c - Freescale Layerscape RCPM driver // // Copyright 2018
> > +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/of_address.h>
> > +#include <linux/slab.h>
> > +#include <soc/fsl/plat_pm.h>
> > +
> > +#define MAX_COMPATIBLE_NUM	10
> > +
> > +struct rcpm_t {
> > +	struct device *dev;
> > +	void __iomem *ippdexpcr_addr;
> > +	bool big_endian;	/* Big/Little endian of RCPM module */
> > +};
> > +
> > +// rcpm_handle - Configure RCPM reg according to wake up source
> > +request // @user_dev: pointer to user's device struct // @flag: to
> > +enable(true) or disable(false) wakeup source // @handle_priv: pointer
> > +to struct rcpm_t instance // // Return 0 on success other negative
> > +errno static int rcpm_handle(struct device *user_dev, bool flag, void
> > +*handle_priv) {
> > +	struct rcpm_t *rcpm;
> > +	bool big_endian;
> > +	const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > +	void __iomem *ippdexpcr_addr;
> > +	u32 ippdexpcr;
> > +	u32 set_bit;
> > +	int ret, num, i;
> > +
> > +	rcpm = handle_priv;
> > +	big_endian = rcpm->big_endian;
> > +	ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > +
> > +	num = device_property_read_string_array(user_dev, "compatible",
> > +			dev_compatible_array, MAX_COMPATIBLE_NUM);
> > +	if (num < 0)
> > +		return num;
> > +
> > +	for (i = 0; i < num; i++) {
> > +		if (!device_property_present(rcpm->dev,
> > +					dev_compatible_array[i]))
> > +			continue;
> > +		else {
> Remove this else.

Got it! Will update in next version.

> > +			ret = device_property_read_u32(rcpm->dev,
> > +					dev_compatible_array[i], &set_bit);
> > +			if (ret)
> > +				return ret;
> > +
> > +			if (!device_property_present(rcpm->dev,
> > +						dev_compatible_array[i]))
> This has been checked. Continue ? or return ENODEV?

Yes, this checking is not necessary, will remove in next version

> > +				return -ENODEV;
> > +			else {
> Remove this else.

OK

> > +				ret = device_property_read_u32(rcpm->dev,
> > +						dev_compatible_array[i],
> &set_bit);
> > +				if (ret)
> > +					return ret;
> > +
> > +				if (big_endian)
> > +					ippdexpcr =
> ioread32be(ippdexpcr_addr);
> > +				else
> > +					ippdexpcr =
> ioread32(ippdexpcr_addr);
> > +
> > +				if (flag)
> > +					ippdexpcr |= set_bit;
> > +				else
> > +					ippdexpcr &= ~set_bit;
> > +
> > +				if (big_endian) {
> > +					iowrite32be(ippdexpcr,
> ippdexpcr_addr);
> > +					ippdexpcr =
> ioread32be(ippdexpcr_addr);
> > +				} else
> if (x) {
> ....
> ....
> }  else {
> 
> }

Got it!

> > +					iowrite32(ippdexpcr, ippdexpcr_addr);
> > +
> > +				return 0;
> > +			}
> > +		}
> > +	}
> > +
> > +	return -ENODEV;
> > +}
> > +
> > +static int ls_rcpm_probe(struct platform_device *pdev) {
> > +	struct resource *r;
> > +	struct rcpm_t *rcpm;
> > +
> > +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	if (!r)
> > +		return -ENODEV;
> > +
> > +	rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> kzalloc is better.

OK

> > +	if (!rcpm)
> > +		return -ENOMEM;
> > +
> > +	rcpm->big_endian = device_property_read_bool(&pdev->dev,
> > +"big-endian");
> > +
> > +	rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > +	if (IS_ERR(rcpm->ippdexpcr_addr))
> > +		return PTR_ERR(rcpm->ippdexpcr_addr);
> > +
> > +	rcpm->dev = &pdev->dev;
> > +	platform_set_drvdata(pdev, rcpm);
> > +
> > +	return register_fsl_platform_wakeup_source(rcpm_handle, rcpm); }
> > +
> > +static int ls_rcpm_remove(struct platform_device *pdev) {
> > +	struct rcpm_t	*rcpm;
> Not need a table.

OK, thanks for your careful review.

Regards,
Ran
 

> Cheers,
> -Dongsheng
> 
> > +
> > +	rcpm = platform_get_drvdata(pdev);
> > +	deregister_fsl_platform_wakeup_source(rcpm);
> > +	kfree(rcpm);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct of_device_id ls_rcpm_of_match[] = {
> > +	{ .compatible = "fsl,qoriq-rcpm-2.1", },
> > +	{}
> > +};
> > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > +
> > +static struct platform_driver ls_rcpm_driver = {
> > +	.driver = {
> > +		.name = "ls-rcpm",
> > +		.of_match_table = ls_rcpm_of_match,
> > +	},
> > +	.probe = ls_rcpm_probe,
> > +	.remove = ls_rcpm_remove,
> > +};
> > +
> > +static int __init ls_rcpm_init(void)
> > +{
> > +	return platform_driver_register(&ls_rcpm_driver);
> > +}
> > +subsys_initcall(ls_rcpm_init);
> > +
> > +static void __exit ls_rcpm_exit(void) {
> > +	platform_driver_unregister(&ls_rcpm_driver);
> > +}
> > +module_exit(ls_rcpm_exit);
> 

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-09-05  3:21       ` Li Yang
  (?)
  (?)
@ 2018-09-07  9:48         ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:48 UTC (permalink / raw)
  To: Leo Li
  Cc: dongsheng.wang, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Hi Leo,

On September 05, 2018 at 11:22 Yang Li wrote:
> -----Original Message-----
> From: Li Yang <leoyang.li@nxp.com>
> Sent: Wednesday, September 05, 2018 11:22
> To: dongsheng.wang@hxt-semitech.com
> Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring <robh+dt@kernel.org>;
> Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; linuxppc-
> dev <linuxppc-dev@lists.ozlabs.org>; lkml <linux-kernel@vger.kernel.org>;
> moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm-
> kernel@lists.infradead.org>
> Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> 
> On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng <dongsheng.wang@hxt-
> semitech.com> wrote:
> >
> > Please change your comments style.
> 
> Although this doesn't get into the Linux kernel coding style documentation
> yet, Linus seems changed his mind to prefer // than /*
> */ comment style now.
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.wang_
> 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> So the
> // style should be acceptable for now.
> 
> >
> > On 2018/8/31 11:56, Ran Wang wrote:
> > > 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 FSL platform PM driver framework which help
> > > to isolate user and PM service provider (such as RCPM driver).
> > >
> > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > ---
> > >  drivers/soc/fsl/Kconfig   |    6 ++
> > >  drivers/soc/fsl/Makefile  |    1 +
> > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > +++++++++++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > 100644 drivers/soc/fsl/ls-rcpm.c
> > >
> > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > > 6517412..882330d 100644
> > > --- a/drivers/soc/fsl/Kconfig
> > > +++ b/drivers/soc/fsl/Kconfig
> > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > >         have to know the implement details of wakeup function it require.
> > >         Besides, it is also easy for service side to upgrade its logic when
> > >         design changed and remain user side unchanged.
> > > +
> > > +config LS_RCPM
> > > +     bool "Freescale RCPM support"
> > > +     depends on (FSL_PLAT_PM)
> > > +     help
> > > +       This feature is to enable specified wakeup source for system sleep.
> > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > index 8f9db23..43ff71a 100644
> > > --- a/drivers/soc/fsl/Makefile
> > > +++ b/drivers/soc/fsl/Makefile
> > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > >  obj-$(CONFIG_CPM)                    += qe/
> > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> 
> Probably use "_" instead of "-" for alignment.

OK, will update in next version

> > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > > new file mode 100644 index 0000000..b0feb88
> > > --- /dev/null
> > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > @@ -0,0 +1,153 @@
> > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > +Layerscape RCPM driver
> 
> The file name here is not the same as the real file name.

Got it, will correct it.

> > > +//
> > > +// Copyright 2018 NXP
> > > +//
> > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> 
> Where do you need the comma in the end?

My bad, will remove comma in next version.

> > > +
> > > +#include <linux/init.h>
> > > +#include <linux/module.h>
> > > +#include <linux/platform_device.h>
> > > +#include <linux/of_address.h>
> > > +#include <linux/slab.h>
> > > +#include <soc/fsl/plat_pm.h>
> > > +
> > > +#define MAX_COMPATIBLE_NUM   10
> > > +
> > > +struct rcpm_t {
> > > +     struct device *dev;
> > > +     void __iomem *ippdexpcr_addr;
> > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > +};
> > > +
> > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > +request // @user_dev: pointer to user's device struct // @flag: to
> > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > +pointer to struct rcpm_t instance // // Return 0 on success other
> > > +negative errno
> 
> Although Linus preferred this // comment style.  I'm not sure if this will be
> handled correctly by the kernel-doc compiler.
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHCbO9
> %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0

So, do you think I need to change all comment style back to '/* ... */' ?
Actually I feel a little bit confused here.

Regards,
Ran

> > > +static int rcpm_handle(struct device *user_dev, bool flag, void
> > > +*handle_priv) {
> > > +     struct rcpm_t *rcpm;
> > > +     bool big_endian;
> > > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > > +     void __iomem *ippdexpcr_addr;
> > > +     u32 ippdexpcr;
> > > +     u32 set_bit;
> > > +     int ret, num, i;
> > > +
> > > +     rcpm = handle_priv;
> > > +     big_endian = rcpm->big_endian;
> > > +     ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > > +
> > > +     num = device_property_read_string_array(user_dev, "compatible",
> > > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > > +     if (num < 0)
> > > +             return num;
> > > +
> > > +     for (i = 0; i < num; i++) {
> > > +             if (!device_property_present(rcpm->dev,
> > > +                                     dev_compatible_array[i]))
> > > +                     continue;
> > > +             else {
> > Remove this else.
> > > +                     ret = device_property_read_u32(rcpm->dev,
> > > +                                     dev_compatible_array[i], &set_bit);
> > > +                     if (ret)
> > > +                             return ret;
> > > +
> > > +                     if (!device_property_present(rcpm->dev,
> > > +
> > > + dev_compatible_array[i]))
> > This has been checked. Continue ? or return ENODEV?
> > > +                             return -ENODEV;
> > > +                     else {
> > Remove this else.
> > > +                             ret = device_property_read_u32(rcpm->dev,
> > > +                                             dev_compatible_array[i], &set_bit);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +
> > > +                             if (big_endian)
> > > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > > +                             else
> > > +                                     ippdexpcr =
> > > + ioread32(ippdexpcr_addr);
> > > +
> > > +                             if (flag)
> > > +                                     ippdexpcr |= set_bit;
> > > +                             else
> > > +                                     ippdexpcr &= ~set_bit;
> > > +
> > > +                             if (big_endian) {
> > > +                                     iowrite32be(ippdexpcr, ippdexpcr_addr);
> > > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > > +                             } else
> > if (x) {
> > ....
> > ....
> > }  else {
> >
> > }
> > > +                                     iowrite32(ippdexpcr,
> > > + ippdexpcr_addr);
> > > +
> > > +                             return 0;
> > > +                     }
> > > +             }
> > > +     }
> > > +
> > > +     return -ENODEV;
> > > +}
> > > +
> > > +static int ls_rcpm_probe(struct platform_device *pdev) {
> > > +     struct resource *r;
> > > +     struct rcpm_t *rcpm;
> > > +
> > > +     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > +     if (!r)
> > > +             return -ENODEV;
> > > +
> > > +     rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> > kzalloc is better.
> > > +     if (!rcpm)
> > > +             return -ENOMEM;
> > > +
> > > +     rcpm->big_endian = device_property_read_bool(&pdev->dev,
> > > + "big-endian");
> > > +
> > > +     rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > > +
> > > +     rcpm->dev = &pdev->dev;
> > > +     platform_set_drvdata(pdev, rcpm);
> > > +
> > > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > > +}
> > > +
> > > +static int ls_rcpm_remove(struct platform_device *pdev) {
> > > +     struct rcpm_t   *rcpm;
> > Not need a table.
> >
> > Cheers,
> > -Dongsheng
> >
> > > +
> > > +     rcpm = platform_get_drvdata(pdev);
> > > +     deregister_fsl_platform_wakeup_source(rcpm);
> > > +     kfree(rcpm);
> > > +
> > > +     return 0;
> > > +}
> > > +
> > > +static const struct of_device_id ls_rcpm_of_match[] = {
> > > +     { .compatible = "fsl,qoriq-rcpm-2.1", },
> > > +     {}
> > > +};
> > > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > > +
> > > +static struct platform_driver ls_rcpm_driver = {
> > > +     .driver = {
> > > +             .name = "ls-rcpm",
> > > +             .of_match_table = ls_rcpm_of_match,
> > > +     },
> > > +     .probe = ls_rcpm_probe,
> > > +     .remove = ls_rcpm_remove,
> > > +};
> > > +
> > > +static int __init ls_rcpm_init(void) {
> > > +     return platform_driver_register(&ls_rcpm_driver);
> > > +}
> > > +subsys_initcall(ls_rcpm_init);
> > > +
> > > +static void __exit ls_rcpm_exit(void) {
> > > +     platform_driver_unregister(&ls_rcpm_driver);
> > > +}
> > > +module_exit(ls_rcpm_exit);
> >
> >

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07  9:48         ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:48 UTC (permalink / raw)
  To: Leo Li
  Cc: dongsheng.wang, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Hi Leo,

On September 05, 2018 at 11:22 Yang Li wrote:
> -----Original Message-----
> From: Li Yang <leoyang.li@nxp.com>
> Sent: Wednesday, September 05, 2018 11:22
> To: dongsheng.wang@hxt-semitech.com
> Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring <robh+dt@kernel.org>;
> Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; linuxppc-
> dev <linuxppc-dev@lists.ozlabs.org>; lkml <linux-kernel@vger.kernel.org>;
> moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm-
> kernel@lists.infradead.org>
> Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> 
> On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng <dongsheng.wang@hxt-
> semitech.com> wrote:
> >
> > Please change your comments style.
> 
> Although this doesn't get into the Linux kernel coding style documentation
> yet, Linus seems changed his mind to prefer // than /*
> */ comment style now.
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.wang_
> 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> So the
> // style should be acceptable for now.
> 
> >
> > On 2018/8/31 11:56, Ran Wang wrote:
> > > 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 FSL platform PM driver framework which help
> > > to isolate user and PM service provider (such as RCPM driver).
> > >
> > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > ---
> > >  drivers/soc/fsl/Kconfig   |    6 ++
> > >  drivers/soc/fsl/Makefile  |    1 +
> > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > +++++++++++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > 100644 drivers/soc/fsl/ls-rcpm.c
> > >
> > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > > 6517412..882330d 100644
> > > --- a/drivers/soc/fsl/Kconfig
> > > +++ b/drivers/soc/fsl/Kconfig
> > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > >         have to know the implement details of wakeup function it require.
> > >         Besides, it is also easy for service side to upgrade its logic when
> > >         design changed and remain user side unchanged.
> > > +
> > > +config LS_RCPM
> > > +     bool "Freescale RCPM support"
> > > +     depends on (FSL_PLAT_PM)
> > > +     help
> > > +       This feature is to enable specified wakeup source for system sleep.
> > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > index 8f9db23..43ff71a 100644
> > > --- a/drivers/soc/fsl/Makefile
> > > +++ b/drivers/soc/fsl/Makefile
> > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > >  obj-$(CONFIG_CPM)                    += qe/
> > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> 
> Probably use "_" instead of "-" for alignment.

OK, will update in next version

> > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > > new file mode 100644 index 0000000..b0feb88
> > > --- /dev/null
> > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > @@ -0,0 +1,153 @@
> > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > +Layerscape RCPM driver
> 
> The file name here is not the same as the real file name.

Got it, will correct it.

> > > +//
> > > +// Copyright 2018 NXP
> > > +//
> > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> 
> Where do you need the comma in the end?

My bad, will remove comma in next version.

> > > +
> > > +#include <linux/init.h>
> > > +#include <linux/module.h>
> > > +#include <linux/platform_device.h>
> > > +#include <linux/of_address.h>
> > > +#include <linux/slab.h>
> > > +#include <soc/fsl/plat_pm.h>
> > > +
> > > +#define MAX_COMPATIBLE_NUM   10
> > > +
> > > +struct rcpm_t {
> > > +     struct device *dev;
> > > +     void __iomem *ippdexpcr_addr;
> > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > +};
> > > +
> > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > +request // @user_dev: pointer to user's device struct // @flag: to
> > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > +pointer to struct rcpm_t instance // // Return 0 on success other
> > > +negative errno
> 
> Although Linus preferred this // comment style.  I'm not sure if this will be
> handled correctly by the kernel-doc compiler.
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHCbO9
> %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0

So, do you think I need to change all comment style back to '/* ... */' ?
Actually I feel a little bit confused here.

Regards,
Ran

> > > +static int rcpm_handle(struct device *user_dev, bool flag, void
> > > +*handle_priv) {
> > > +     struct rcpm_t *rcpm;
> > > +     bool big_endian;
> > > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > > +     void __iomem *ippdexpcr_addr;
> > > +     u32 ippdexpcr;
> > > +     u32 set_bit;
> > > +     int ret, num, i;
> > > +
> > > +     rcpm = handle_priv;
> > > +     big_endian = rcpm->big_endian;
> > > +     ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > > +
> > > +     num = device_property_read_string_array(user_dev, "compatible",
> > > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > > +     if (num < 0)
> > > +             return num;
> > > +
> > > +     for (i = 0; i < num; i++) {
> > > +             if (!device_property_present(rcpm->dev,
> > > +                                     dev_compatible_array[i]))
> > > +                     continue;
> > > +             else {
> > Remove this else.
> > > +                     ret = device_property_read_u32(rcpm->dev,
> > > +                                     dev_compatible_array[i], &set_bit);
> > > +                     if (ret)
> > > +                             return ret;
> > > +
> > > +                     if (!device_property_present(rcpm->dev,
> > > +
> > > + dev_compatible_array[i]))
> > This has been checked. Continue ? or return ENODEV?
> > > +                             return -ENODEV;
> > > +                     else {
> > Remove this else.
> > > +                             ret = device_property_read_u32(rcpm->dev,
> > > +                                             dev_compatible_array[i], &set_bit);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +
> > > +                             if (big_endian)
> > > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > > +                             else
> > > +                                     ippdexpcr =
> > > + ioread32(ippdexpcr_addr);
> > > +
> > > +                             if (flag)
> > > +                                     ippdexpcr |= set_bit;
> > > +                             else
> > > +                                     ippdexpcr &= ~set_bit;
> > > +
> > > +                             if (big_endian) {
> > > +                                     iowrite32be(ippdexpcr, ippdexpcr_addr);
> > > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > > +                             } else
> > if (x) {
> > ....
> > ....
> > }  else {
> >
> > }
> > > +                                     iowrite32(ippdexpcr,
> > > + ippdexpcr_addr);
> > > +
> > > +                             return 0;
> > > +                     }
> > > +             }
> > > +     }
> > > +
> > > +     return -ENODEV;
> > > +}
> > > +
> > > +static int ls_rcpm_probe(struct platform_device *pdev) {
> > > +     struct resource *r;
> > > +     struct rcpm_t *rcpm;
> > > +
> > > +     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > +     if (!r)
> > > +             return -ENODEV;
> > > +
> > > +     rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> > kzalloc is better.
> > > +     if (!rcpm)
> > > +             return -ENOMEM;
> > > +
> > > +     rcpm->big_endian = device_property_read_bool(&pdev->dev,
> > > + "big-endian");
> > > +
> > > +     rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > > +
> > > +     rcpm->dev = &pdev->dev;
> > > +     platform_set_drvdata(pdev, rcpm);
> > > +
> > > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > > +}
> > > +
> > > +static int ls_rcpm_remove(struct platform_device *pdev) {
> > > +     struct rcpm_t   *rcpm;
> > Not need a table.
> >
> > Cheers,
> > -Dongsheng
> >
> > > +
> > > +     rcpm = platform_get_drvdata(pdev);
> > > +     deregister_fsl_platform_wakeup_source(rcpm);
> > > +     kfree(rcpm);
> > > +
> > > +     return 0;
> > > +}
> > > +
> > > +static const struct of_device_id ls_rcpm_of_match[] = {
> > > +     { .compatible = "fsl,qoriq-rcpm-2.1", },
> > > +     {}
> > > +};
> > > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > > +
> > > +static struct platform_driver ls_rcpm_driver = {
> > > +     .driver = {
> > > +             .name = "ls-rcpm",
> > > +             .of_match_table = ls_rcpm_of_match,
> > > +     },
> > > +     .probe = ls_rcpm_probe,
> > > +     .remove = ls_rcpm_remove,
> > > +};
> > > +
> > > +static int __init ls_rcpm_init(void) {
> > > +     return platform_driver_register(&ls_rcpm_driver);
> > > +}
> > > +subsys_initcall(ls_rcpm_init);
> > > +
> > > +static void __exit ls_rcpm_exit(void) {
> > > +     platform_driver_unregister(&ls_rcpm_driver);
> > > +}
> > > +module_exit(ls_rcpm_exit);
> >
> >

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07  9:48         ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:48 UTC (permalink / raw)
  To: Leo Li
  Cc: dongsheng.wang, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

SGkgTGVvLA0KDQpPbiBTZXB0ZW1iZXIgMDUsIDIwMTggYXQgMTE6MjIgWWFuZyBMaSB3cm90ZToN
Cj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogTGkgWWFuZyA8bGVveWFuZy5s
aUBueHAuY29tPg0KPiBTZW50OiBXZWRuZXNkYXksIFNlcHRlbWJlciAwNSwgMjAxOCAxMToyMg0K
PiBUbzogZG9uZ3NoZW5nLndhbmdAaHh0LXNlbWl0ZWNoLmNvbQ0KPiBDYzogUmFuIFdhbmcgPHJh
bi53YW5nXzFAbnhwLmNvbT47IFJvYiBIZXJyaW5nIDxyb2JoK2R0QGtlcm5lbC5vcmc+Ow0KPiBN
YXJrIFJ1dGxhbmQgPG1hcmsucnV0bGFuZEBhcm0uY29tPjsgb3BlbiBsaXN0Ok9QRU4gRklSTVdB
UkUgQU5EDQo+IEZMQVRURU5FRCBERVZJQ0UgVFJFRSBCSU5ESU5HUyA8ZGV2aWNldHJlZUB2Z2Vy
Lmtlcm5lbC5vcmc+OyBsaW51eHBwYy0NCj4gZGV2IDxsaW51eHBwYy1kZXZAbGlzdHMub3psYWJz
Lm9yZz47IGxrbWwgPGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+Ow0KPiBtb2RlcmF0ZWQg
bGlzdDpBUk0vRlJFRVNDQUxFIElNWCAvIE1YQyBBUk0gQVJDSElURUNUVVJFIDxsaW51eC1hcm0t
DQo+IGtlcm5lbEBsaXN0cy5pbmZyYWRlYWQub3JnPg0KPiBTdWJqZWN0OiBSZTogW1BBVENIIDMv
M10gc29jOiBmc2w6IGFkZC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gICBkZXZf
Y29tcGF0aWJsZV9hcnJheSwgTUFYX0NPTVBBVElCTEVfTlVNKTsNCj4gPiA+ICsgICAgIGlmIChu
dW0gPCAwKQ0KPiA+ID4gKyAgICAgICAgICAgICByZXR1cm4gbnVtOw0KPiA+ID4gKw0KPiA+ID4g
KyAgICAgZm9yIChpID0gMDsgaSA8IG51bTsgaSsrKSB7DQo+ID4gPiArICAgICAgICAgICAgIGlm
ICghZGV2aWNlX3Byb3BlcnR5X3ByZXNlbnQocmNwbS0+ZGV2LA0KPiA+ID4gKyAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICBkZXZfY29tcGF0aWJsZV9hcnJheVtpXSkpDQo+ID4g
PiArICAgICAgICAgICAgICAgICAgICAgY29udGludWU7DQo+ID4gPiArICAgICAgICAgICAgIGVs
c2Ugew0KPiA+IFJlbW92ZSB0aGlzIGVsc2UuDQo+ID4gPiArICAgICAgICAgICAgICAgICAgICAg
cmV0ID0gZGV2aWNlX3Byb3BlcnR5X3JlYWRfdTMyKHJjcG0tPmRldiwNCj4gPiA+ICsgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2X2NvbXBhdGlibGVfYXJyYXlbaV0sICZz
ZXRfYml0KTsNCj4gPiA+ICsgICAgICAgICAgICAgICAgICAgICBpZiAocmV0KQ0KPiA+ID4gKyAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldDsNCj4gPiA+ICsNCj4gPiA+ICsg
ICAgICAgICAgICAgICAgICAgICBpZiAoIWRldmljZV9wcm9wZXJ0eV9wcmVzZW50KHJjcG0tPmRl
diwNCj4gPiA+ICsNCj4gPiA+ICsgZGV2X2NvbXBhdGlibGVfYXJyYXlbaV0pKQ0KPiA+IFRoaXMg
aGFzIGJlZW4gY2hlY2tlZC4gQ29udGludWUgPyBvciByZXR1cm4gRU5PREVW77yfDQo+ID4gPiAr
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gLUVOT0RFVjsNCj4gPiA+ICsgICAg
ICAgICAgICAgICAgICAgICBlbHNlIHsNCj4gPiBSZW1vdmUgdGhpcyBlbHNlLg0KPiA+ID4gKyAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0ID0gZGV2aWNlX3Byb3BlcnR5X3JlYWRfdTMy
KHJjcG0tPmRldiwNCj4gPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICBkZXZfY29tcGF0aWJsZV9hcnJheVtpXSwgJnNldF9iaXQpOw0KPiA+ID4gKyAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJldCkNCj4gPiA+ICsgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldDsNCj4gPiA+ICsNCj4gPiA+ICsgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIGlmIChiaWdfZW5kaWFuKQ0KPiA+ID4gKyAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICBpcHBkZXhwY3IgPSBpb3JlYWQzMmJlKGlwcGRleHBj
cl9hZGRyKTsNCj4gPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UNCj4gPiA+
ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXBwZGV4cGNyID0NCj4gPiA+
ICsgaW9yZWFkMzIoaXBwZGV4cGNyX2FkZHIpOw0KPiA+ID4gKw0KPiA+ID4gKyAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgaWYgKGZsYWcpDQo+ID4gPiArICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIGlwcGRleHBjciB8PSBzZXRfYml0Ow0KPiA+ID4gKyAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgZWxzZQ0KPiA+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICBpcHBkZXhwY3IgJj0gfnNldF9iaXQ7DQo+ID4gP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PiArICAgICByZXR1cm4gcGxhdGZvcm1fZHJpdmVyX3JlZ2lzdGVyKCZsc19yY3BtX2RyaXZl
cik7DQo+ID4gPiArfQ0KPiA+ID4gK3N1YnN5c19pbml0Y2FsbChsc19yY3BtX2luaXQpOw0KPiA+
ID4gKw0KPiA+ID4gK3N0YXRpYyB2b2lkIF9fZXhpdCBsc19yY3BtX2V4aXQodm9pZCkgew0KPiA+
ID4gKyAgICAgcGxhdGZvcm1fZHJpdmVyX3VucmVnaXN0ZXIoJmxzX3JjcG1fZHJpdmVyKTsNCj4g
PiA+ICt9DQo+ID4gPiArbW9kdWxlX2V4aXQobHNfcmNwbV9leGl0KTsNCj4gPg0KPiA+DQo=

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07  9:48         ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-07  9:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Leo,

On September 05, 2018 at 11:22 Yang Li wrote:
> -----Original Message-----
> From: Li Yang <leoyang.li@nxp.com>
> Sent: Wednesday, September 05, 2018 11:22
> To: dongsheng.wang at hxt-semitech.com
> Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring <robh+dt@kernel.org>;
> Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; linuxppc-
> dev <linuxppc-dev@lists.ozlabs.org>; lkml <linux-kernel@vger.kernel.org>;
> moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm-
> kernel at lists.infradead.org>
> Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> 
> On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng <dongsheng.wang@hxt-
> semitech.com> wrote:
> >
> > Please change your comments style.
> 
> Although this doesn't get into the Linux kernel coding style documentation
> yet, Linus seems changed his mind to prefer // than /*
> */ comment style now.
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.wang_
> 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> So the
> // style should be acceptable for now.
> 
> >
> > On 2018/8/31 11:56, Ran Wang wrote:
> > > 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 FSL platform PM driver framework which help
> > > to isolate user and PM service provider (such as RCPM driver).
> > >
> > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > ---
> > >  drivers/soc/fsl/Kconfig   |    6 ++
> > >  drivers/soc/fsl/Makefile  |    1 +
> > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > +++++++++++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > 100644 drivers/soc/fsl/ls-rcpm.c
> > >
> > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > > 6517412..882330d 100644
> > > --- a/drivers/soc/fsl/Kconfig
> > > +++ b/drivers/soc/fsl/Kconfig
> > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > >         have to know the implement details of wakeup function it require.
> > >         Besides, it is also easy for service side to upgrade its logic when
> > >         design changed and remain user side unchanged.
> > > +
> > > +config LS_RCPM
> > > +     bool "Freescale RCPM support"
> > > +     depends on (FSL_PLAT_PM)
> > > +     help
> > > +       This feature is to enable specified wakeup source for system sleep.
> > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > index 8f9db23..43ff71a 100644
> > > --- a/drivers/soc/fsl/Makefile
> > > +++ b/drivers/soc/fsl/Makefile
> > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > >  obj-$(CONFIG_CPM)                    += qe/
> > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> 
> Probably use "_" instead of "-" for alignment.

OK, will update in next version

> > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > > new file mode 100644 index 0000000..b0feb88
> > > --- /dev/null
> > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > @@ -0,0 +1,153 @@
> > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > +Layerscape RCPM driver
> 
> The file name here is not the same as the real file name.

Got it, will correct it.

> > > +//
> > > +// Copyright 2018 NXP
> > > +//
> > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> 
> Where do you need the comma in the end?

My bad, will remove comma in next version.

> > > +
> > > +#include <linux/init.h>
> > > +#include <linux/module.h>
> > > +#include <linux/platform_device.h>
> > > +#include <linux/of_address.h>
> > > +#include <linux/slab.h>
> > > +#include <soc/fsl/plat_pm.h>
> > > +
> > > +#define MAX_COMPATIBLE_NUM   10
> > > +
> > > +struct rcpm_t {
> > > +     struct device *dev;
> > > +     void __iomem *ippdexpcr_addr;
> > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > +};
> > > +
> > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > +request // @user_dev: pointer to user's device struct // @flag: to
> > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > +pointer to struct rcpm_t instance // // Return 0 on success other
> > > +negative errno
> 
> Although Linus preferred this // comment style.  I'm not sure if this will be
> handled correctly by the kernel-doc compiler.
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHCbO9
> %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0

So, do you think I need to change all comment style back to '/* ... */' ?
Actually I feel a little bit confused here.

Regards,
Ran

> > > +static int rcpm_handle(struct device *user_dev, bool flag, void
> > > +*handle_priv) {
> > > +     struct rcpm_t *rcpm;
> > > +     bool big_endian;
> > > +     const char  *dev_compatible_array[MAX_COMPATIBLE_NUM];
> > > +     void __iomem *ippdexpcr_addr;
> > > +     u32 ippdexpcr;
> > > +     u32 set_bit;
> > > +     int ret, num, i;
> > > +
> > > +     rcpm = handle_priv;
> > > +     big_endian = rcpm->big_endian;
> > > +     ippdexpcr_addr = rcpm->ippdexpcr_addr;
> > > +
> > > +     num = device_property_read_string_array(user_dev, "compatible",
> > > +                     dev_compatible_array, MAX_COMPATIBLE_NUM);
> > > +     if (num < 0)
> > > +             return num;
> > > +
> > > +     for (i = 0; i < num; i++) {
> > > +             if (!device_property_present(rcpm->dev,
> > > +                                     dev_compatible_array[i]))
> > > +                     continue;
> > > +             else {
> > Remove this else.
> > > +                     ret = device_property_read_u32(rcpm->dev,
> > > +                                     dev_compatible_array[i], &set_bit);
> > > +                     if (ret)
> > > +                             return ret;
> > > +
> > > +                     if (!device_property_present(rcpm->dev,
> > > +
> > > + dev_compatible_array[i]))
> > This has been checked. Continue ? or return ENODEV?
> > > +                             return -ENODEV;
> > > +                     else {
> > Remove this else.
> > > +                             ret = device_property_read_u32(rcpm->dev,
> > > +                                             dev_compatible_array[i], &set_bit);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +
> > > +                             if (big_endian)
> > > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > > +                             else
> > > +                                     ippdexpcr =
> > > + ioread32(ippdexpcr_addr);
> > > +
> > > +                             if (flag)
> > > +                                     ippdexpcr |= set_bit;
> > > +                             else
> > > +                                     ippdexpcr &= ~set_bit;
> > > +
> > > +                             if (big_endian) {
> > > +                                     iowrite32be(ippdexpcr, ippdexpcr_addr);
> > > +                                     ippdexpcr = ioread32be(ippdexpcr_addr);
> > > +                             } else
> > if (x) {
> > ....
> > ....
> > }  else {
> >
> > }
> > > +                                     iowrite32(ippdexpcr,
> > > + ippdexpcr_addr);
> > > +
> > > +                             return 0;
> > > +                     }
> > > +             }
> > > +     }
> > > +
> > > +     return -ENODEV;
> > > +}
> > > +
> > > +static int ls_rcpm_probe(struct platform_device *pdev) {
> > > +     struct resource *r;
> > > +     struct rcpm_t *rcpm;
> > > +
> > > +     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > +     if (!r)
> > > +             return -ENODEV;
> > > +
> > > +     rcpm = kmalloc(sizeof(*rcpm), GFP_KERNEL);
> > kzalloc is better.
> > > +     if (!rcpm)
> > > +             return -ENOMEM;
> > > +
> > > +     rcpm->big_endian = device_property_read_bool(&pdev->dev,
> > > + "big-endian");
> > > +
> > > +     rcpm->ippdexpcr_addr = devm_ioremap_resource(&pdev->dev, r);
> > > +     if (IS_ERR(rcpm->ippdexpcr_addr))
> > > +             return PTR_ERR(rcpm->ippdexpcr_addr);
> > > +
> > > +     rcpm->dev = &pdev->dev;
> > > +     platform_set_drvdata(pdev, rcpm);
> > > +
> > > +     return register_fsl_platform_wakeup_source(rcpm_handle, rcpm);
> > > +}
> > > +
> > > +static int ls_rcpm_remove(struct platform_device *pdev) {
> > > +     struct rcpm_t   *rcpm;
> > Not need a table.
> >
> > Cheers,
> > -Dongsheng
> >
> > > +
> > > +     rcpm = platform_get_drvdata(pdev);
> > > +     deregister_fsl_platform_wakeup_source(rcpm);
> > > +     kfree(rcpm);
> > > +
> > > +     return 0;
> > > +}
> > > +
> > > +static const struct of_device_id ls_rcpm_of_match[] = {
> > > +     { .compatible = "fsl,qoriq-rcpm-2.1", },
> > > +     {}
> > > +};
> > > +MODULE_DEVICE_TABLE(of, ls_rcpm_of_match);
> > > +
> > > +static struct platform_driver ls_rcpm_driver = {
> > > +     .driver = {
> > > +             .name = "ls-rcpm",
> > > +             .of_match_table = ls_rcpm_of_match,
> > > +     },
> > > +     .probe = ls_rcpm_probe,
> > > +     .remove = ls_rcpm_remove,
> > > +};
> > > +
> > > +static int __init ls_rcpm_init(void) {
> > > +     return platform_driver_register(&ls_rcpm_driver);
> > > +}
> > > +subsys_initcall(ls_rcpm_init);
> > > +
> > > +static void __exit ls_rcpm_exit(void) {
> > > +     platform_driver_unregister(&ls_rcpm_driver);
> > > +}
> > > +module_exit(ls_rcpm_exit);
> >
> >

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
  2018-09-07  8:41     ` Ran Wang
  (?)
  (?)
@ 2018-09-07 10:15       ` Wang, Dongsheng
  -1 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-07 10:15 UTC (permalink / raw)
  To: Ran Wang
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland

On 2018/9/7 16:49, Ran Wang wrote:
> Hi Dongsheng
>
>> On 2018/9/5 11:05, Dongsheng Wang wrote:
>>
>> Please change your comments style.
>>
>> On 2018/8/31 11:57, Ran Wang wrote:
>>> This driver is to provide a independent framework for PM service
>>> provider and consumer to configure system level wake up feature. For
>>> example, RCPM driver could register a callback function on this
>>> platform first, and Flex timer driver who want to enable timer wake up
>>> feature, will call generic API provided by this platform driver, and
>>> then it will trigger RCPM driver to do it. The benefit is to isolate
>>> the user and service, such as flex timer driver will not have to know
>>> the implement details of wakeup function it require. Besides, it is
>>> also easy for service side to upgrade its logic when design is changed
>>> and remain user side unchanged.
>>>
>>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
>>> ---
>>>  drivers/soc/fsl/Kconfig   |   14 +++++
>>>  drivers/soc/fsl/Makefile  |    1 +
>>>  drivers/soc/fsl/plat_pm.c |  144
>> +++++++++++++++++++++++++++++++++++++++++++++
>>>  include/soc/fsl/plat_pm.h |   22 +++++++
>>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
>>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
>>> include/soc/fsl/plat_pm.h
>>>
>>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
>>> 7a9fb9b..6517412 100644
>>> --- a/drivers/soc/fsl/Kconfig
>>> +++ b/drivers/soc/fsl/Kconfig
>>> @@ -16,3 +16,17 @@ config FSL_GUTS
>>>  	  Initially only reading SVR and registering soc device are supported.
>>>  	  Other guts accesses, such as reading RCW, should eventually be
>> moved
>>>  	  into this driver as well.
>>> +
>>> +config FSL_PLAT_PM
>>> +	bool "Freescale platform PM framework"
>>> +	help
>>> +	  This driver is to provide a independent framework for PM service
>>> +	  provider and consumer to configure system level wake up feature.
>> For
>>> +	  example, RCPM driver could register a callback function on this
>>> +	  platform first, and Flex timer driver who want to enable timer wake
>>> +	  up feature, will call generic API provided by this platform driver,
>>> +	  and then it will trigger RCPM driver to do it. The benefit is to
>>> +	  isolate the user and service, such as  flex timer driver will not
>>> +	  have to know the implement details of wakeup function it require.
>>> +	  Besides, it is also easy for service side to upgrade its logic when
>>> +	  design changed and remain user side unchanged.
>>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
>>> 44b3beb..8f9db23 100644
>>> --- a/drivers/soc/fsl/Makefile
>>> +++ b/drivers/soc/fsl/Makefile
>>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
>>>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>>>  obj-$(CONFIG_CPM)			+= qe/
>>>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
>>> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
>>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
>>> file mode 100644 index 0000000..19ea14e
>>> --- /dev/null
>>> +++ b/drivers/soc/fsl/plat_pm.c
>>> @@ -0,0 +1,144 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
>>> +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/device.h>
>>> +#include <linux/list.h>
>>> +#include <linux/slab.h>
>>> +#include <linux/err.h>
>>> +#include <soc/fsl/plat_pm.h>
>>> +
>>> +
>>> +struct plat_pm_t {
>>> +	struct list_head node;
>>> +	fsl_plat_pm_handle handle;
>>> +	void *handle_priv;
>>> +	spinlock_t	lock;
>>> +};
>>> +
>>> +static struct plat_pm_t plat_pm;
>>> +
>>> +// register_fsl_platform_wakeup_source - Register callback function
>>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
>>> +@handle_priv: Handler specific data struct // // Return 0 on success
>>> +other negative errno int
>>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
>>> +		void *handle_priv)
>>> +{
>>> +	struct plat_pm_t *p;
>>> +	unsigned long	flags;
>>> +
>>> +	if (!handle) {
>>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
>>> +	if (!p)
>>> +		return -ENOMEM;
>>> +
>>> +	p->handle = handle;
>>> +	p->handle_priv = handle_priv;
>>> +
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_add_tail(&p->node, &plat_pm.node);
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
>>> +
>>> +// Deregister_fsl_platform_wakeup_source - deregister callback
>>> +function // @handle_priv: Handler specific data struct // // Return 0
>>> +on success other negative errno int
>>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
>>> +	struct plat_pm_t *p, *tmp;
>>> +	unsigned long	flags;
>>> +
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
>>> +		if (p->handle_priv == handle_priv) {
>>> +			list_del(&p->node);
>>> +			kfree(p);
>>> +		}
>>> +	}
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
>>> +
>>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
>>> +handlers // @dev: pointer to user's device struct // @flag: to tell
>>> +enable or disable wakeup source // // Return 0 on success other
>>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
>>> +bool flag) {
>>> +	struct plat_pm_t *p;
>>> +	int ret;
>>> +	bool success_handled;
>>> +	unsigned long	flags;
>>> +
>>> +	success_handled = false;
>>> +
>>> +	// Will consider success if at least one callback return 0.
>>> +	// Also, rest handles still get oppertunity to be executed
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_for_each_entry(p, &plat_pm.node, node) {
>>> +		if (p->handle) {
>>> +			ret = p->handle(dev, flag, p->handle_priv);
>>> +			if (!ret)
>>> +				success_handled = true;
>> Miss a break?
> Actually my idea is to allow more than one registered handler to handle this
> request, so I define a flag rather than return to indicated if there is at least one handler successfully
> do it. This design might give more flexibility to framework when running.
There is only one flag(success_handled) here, how did know which handler
failed?

BTW, I don't think we need this flag. We can only use the return value.

Cheers,
Dongsheng

>>> +			else if (ret != -ENODEV) {
>>> +				pr_err("FSL plat_pm: Failed to config wakeup
>> source:%d\n", ret);
>> Please unlock before return.
> Yes, will fix it in next version, thanks for pointing out!
>
>>> +				return ret;
>>> +			}
>>> +		} else
>>> +			pr_warn("FSL plat_pm: Invalid handler detected,
>> skip\n");
>>> +	}
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +
>>> +	if (success_handled == false) {
>>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
>> wakeup source config\n");
>>> +		return -ENODEV;
>>> +	}
>> Add this into the loop.
> My design is that if the 1st handler return -ENODEV to indicated this device it doesn't support, 
> then the framework will continue try 2nd handler...
>
> So I think it is needed to place this checking out of loop, what do you say?
>
> Regards,
> Ran
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
>>> +to user's device struct // // Return 0 on success other negative
>>> +errno int fsl_platform_wakeup_enable(struct device *dev) {
>>> +	return fsl_platform_wakeup_config(dev, true); }
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
>>> +
>>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
>>> +pointer to user's device struct // // Return 0 on success other
>>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
>>> +	return fsl_platform_wakeup_config(dev, false); }
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
>>> +
>>> +static int __init fsl_plat_pm_init(void) {
>>> +	spin_lock_init(&plat_pm.lock);
>>> +	INIT_LIST_HEAD(&plat_pm.node);
>>> +	return 0;
>>> +}
>>> +
>>> +core_initcall(fsl_plat_pm_init);
>>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
>>> file mode 100644 index 0000000..bbe151e
>>> --- /dev/null
>>> +++ b/include/soc/fsl/plat_pm.h
>>> @@ -0,0 +1,22 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
>>> +// // Author: Ran Wang <ran.wang_1@nxp.com>,
>>> +
>>> +#ifndef __FSL_PLAT_PM_H
>>> +#define __FSL_PLAT_PM_H
>>> +
>>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
>>> +		void *handle_priv);
>>> +
>>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
>>> +		void *handle_priv);
>>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
>>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
>>> +fsl_platform_wakeup_enable(struct device *dev); int
>>> +fsl_platform_wakeup_disable(struct device *dev);
>>> +
>>> +#endif	// __FSL_PLAT_PM_H
>


^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07 10:15       ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-07 10:15 UTC (permalink / raw)
  To: Ran Wang
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland

On 2018/9/7 16:49, Ran Wang wrote:
> Hi Dongsheng
>
>> On 2018/9/5 11:05, Dongsheng Wang wrote:
>>
>> Please change your comments style.
>>
>> On 2018/8/31 11:57, Ran Wang wrote:
>>> This driver is to provide a independent framework for PM service
>>> provider and consumer to configure system level wake up feature. For
>>> example, RCPM driver could register a callback function on this
>>> platform first, and Flex timer driver who want to enable timer wake up
>>> feature, will call generic API provided by this platform driver, and
>>> then it will trigger RCPM driver to do it. The benefit is to isolate
>>> the user and service, such as flex timer driver will not have to know
>>> the implement details of wakeup function it require. Besides, it is
>>> also easy for service side to upgrade its logic when design is changed
>>> and remain user side unchanged.
>>>
>>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
>>> ---
>>>  drivers/soc/fsl/Kconfig   |   14 +++++
>>>  drivers/soc/fsl/Makefile  |    1 +
>>>  drivers/soc/fsl/plat_pm.c |  144
>> +++++++++++++++++++++++++++++++++++++++++++++
>>>  include/soc/fsl/plat_pm.h |   22 +++++++
>>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
>>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
>>> include/soc/fsl/plat_pm.h
>>>
>>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
>>> 7a9fb9b..6517412 100644
>>> --- a/drivers/soc/fsl/Kconfig
>>> +++ b/drivers/soc/fsl/Kconfig
>>> @@ -16,3 +16,17 @@ config FSL_GUTS
>>>  	  Initially only reading SVR and registering soc device are supported.
>>>  	  Other guts accesses, such as reading RCW, should eventually be
>> moved
>>>  	  into this driver as well.
>>> +
>>> +config FSL_PLAT_PM
>>> +	bool "Freescale platform PM framework"
>>> +	help
>>> +	  This driver is to provide a independent framework for PM service
>>> +	  provider and consumer to configure system level wake up feature.
>> For
>>> +	  example, RCPM driver could register a callback function on this
>>> +	  platform first, and Flex timer driver who want to enable timer wake
>>> +	  up feature, will call generic API provided by this platform driver,
>>> +	  and then it will trigger RCPM driver to do it. The benefit is to
>>> +	  isolate the user and service, such as  flex timer driver will not
>>> +	  have to know the implement details of wakeup function it require.
>>> +	  Besides, it is also easy for service side to upgrade its logic when
>>> +	  design changed and remain user side unchanged.
>>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
>>> 44b3beb..8f9db23 100644
>>> --- a/drivers/soc/fsl/Makefile
>>> +++ b/drivers/soc/fsl/Makefile
>>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
>>>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>>>  obj-$(CONFIG_CPM)			+= qe/
>>>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
>>> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
>>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
>>> file mode 100644 index 0000000..19ea14e
>>> --- /dev/null
>>> +++ b/drivers/soc/fsl/plat_pm.c
>>> @@ -0,0 +1,144 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
>>> +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/device.h>
>>> +#include <linux/list.h>
>>> +#include <linux/slab.h>
>>> +#include <linux/err.h>
>>> +#include <soc/fsl/plat_pm.h>
>>> +
>>> +
>>> +struct plat_pm_t {
>>> +	struct list_head node;
>>> +	fsl_plat_pm_handle handle;
>>> +	void *handle_priv;
>>> +	spinlock_t	lock;
>>> +};
>>> +
>>> +static struct plat_pm_t plat_pm;
>>> +
>>> +// register_fsl_platform_wakeup_source - Register callback function
>>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
>>> +@handle_priv: Handler specific data struct // // Return 0 on success
>>> +other negative errno int
>>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
>>> +		void *handle_priv)
>>> +{
>>> +	struct plat_pm_t *p;
>>> +	unsigned long	flags;
>>> +
>>> +	if (!handle) {
>>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
>>> +	if (!p)
>>> +		return -ENOMEM;
>>> +
>>> +	p->handle = handle;
>>> +	p->handle_priv = handle_priv;
>>> +
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_add_tail(&p->node, &plat_pm.node);
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
>>> +
>>> +// Deregister_fsl_platform_wakeup_source - deregister callback
>>> +function // @handle_priv: Handler specific data struct // // Return 0
>>> +on success other negative errno int
>>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
>>> +	struct plat_pm_t *p, *tmp;
>>> +	unsigned long	flags;
>>> +
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
>>> +		if (p->handle_priv == handle_priv) {
>>> +			list_del(&p->node);
>>> +			kfree(p);
>>> +		}
>>> +	}
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
>>> +
>>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
>>> +handlers // @dev: pointer to user's device struct // @flag: to tell
>>> +enable or disable wakeup source // // Return 0 on success other
>>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
>>> +bool flag) {
>>> +	struct plat_pm_t *p;
>>> +	int ret;
>>> +	bool success_handled;
>>> +	unsigned long	flags;
>>> +
>>> +	success_handled = false;
>>> +
>>> +	// Will consider success if at least one callback return 0.
>>> +	// Also, rest handles still get oppertunity to be executed
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_for_each_entry(p, &plat_pm.node, node) {
>>> +		if (p->handle) {
>>> +			ret = p->handle(dev, flag, p->handle_priv);
>>> +			if (!ret)
>>> +				success_handled = true;
>> Miss a break?
> Actually my idea is to allow more than one registered handler to handle this
> request, so I define a flag rather than return to indicated if there is at least one handler successfully
> do it. This design might give more flexibility to framework when running.
There is only one flag(success_handled) here, how did know which handler
failed?

BTW, I don't think we need this flag. We can only use the return value.

Cheers,
Dongsheng

>>> +			else if (ret != -ENODEV) {
>>> +				pr_err("FSL plat_pm: Failed to config wakeup
>> source:%d\n", ret);
>> Please unlock before return.
> Yes, will fix it in next version, thanks for pointing out!
>
>>> +				return ret;
>>> +			}
>>> +		} else
>>> +			pr_warn("FSL plat_pm: Invalid handler detected,
>> skip\n");
>>> +	}
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +
>>> +	if (success_handled == false) {
>>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
>> wakeup source config\n");
>>> +		return -ENODEV;
>>> +	}
>> Add this into the loop.
> My design is that if the 1st handler return -ENODEV to indicated this device it doesn't support, 
> then the framework will continue try 2nd handler...
>
> So I think it is needed to place this checking out of loop, what do you say?
>
> Regards,
> Ran
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
>>> +to user's device struct // // Return 0 on success other negative
>>> +errno int fsl_platform_wakeup_enable(struct device *dev) {
>>> +	return fsl_platform_wakeup_config(dev, true); }
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
>>> +
>>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
>>> +pointer to user's device struct // // Return 0 on success other
>>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
>>> +	return fsl_platform_wakeup_config(dev, false); }
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
>>> +
>>> +static int __init fsl_plat_pm_init(void) {
>>> +	spin_lock_init(&plat_pm.lock);
>>> +	INIT_LIST_HEAD(&plat_pm.node);
>>> +	return 0;
>>> +}
>>> +
>>> +core_initcall(fsl_plat_pm_init);
>>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
>>> file mode 100644 index 0000000..bbe151e
>>> --- /dev/null
>>> +++ b/include/soc/fsl/plat_pm.h
>>> @@ -0,0 +1,22 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
>>> +// // Author: Ran Wang <ran.wang_1@nxp.com>,
>>> +
>>> +#ifndef __FSL_PLAT_PM_H
>>> +#define __FSL_PLAT_PM_H
>>> +
>>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
>>> +		void *handle_priv);
>>> +
>>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
>>> +		void *handle_priv);
>>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
>>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
>>> +fsl_platform_wakeup_enable(struct device *dev); int
>>> +fsl_platform_wakeup_disable(struct device *dev);
>>> +
>>> +#endif	// __FSL_PLAT_PM_H
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07 10:15       ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-07 10:15 UTC (permalink / raw)
  To: Ran Wang
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland

On 2018/9/7 16:49, Ran Wang wrote:=0A=
> Hi Dongsheng=0A=
>=0A=
>> On 2018/9/5 11:05, Dongsheng Wang wrote:=0A=
>>=0A=
>> Please change your comments style.=0A=
>>=0A=
>> On 2018/8/31 11:57, Ran Wang wrote:=0A=
>>> This driver is to provide a independent framework for PM service=0A=
>>> provider and consumer to configure system level wake up feature. For=0A=
>>> example, RCPM driver could register a callback function on this=0A=
>>> platform first, and Flex timer driver who want to enable timer wake up=
=0A=
>>> feature, will call generic API provided by this platform driver, and=0A=
>>> then it will trigger RCPM driver to do it. The benefit is to isolate=0A=
>>> the user and service, such as flex timer driver will not have to know=
=0A=
>>> the implement details of wakeup function it require. Besides, it is=0A=
>>> also easy for service side to upgrade its logic when design is changed=
=0A=
>>> and remain user side unchanged.=0A=
>>>=0A=
>>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>=0A=
>>> ---=0A=
>>>  drivers/soc/fsl/Kconfig   |   14 +++++=0A=
>>>  drivers/soc/fsl/Makefile  |    1 +=0A=
>>>  drivers/soc/fsl/plat_pm.c |  144=0A=
>> +++++++++++++++++++++++++++++++++++++++++++++=0A=
>>>  include/soc/fsl/plat_pm.h |   22 +++++++=0A=
>>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode=0A=
>>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644=0A=
>>> include/soc/fsl/plat_pm.h=0A=
>>>=0A=
>>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index=0A=
>>> 7a9fb9b..6517412 100644=0A=
>>> --- a/drivers/soc/fsl/Kconfig=0A=
>>> +++ b/drivers/soc/fsl/Kconfig=0A=
>>> @@ -16,3 +16,17 @@ config FSL_GUTS=0A=
>>>  	  Initially only reading SVR and registering soc device are supported=
.=0A=
>>>  	  Other guts accesses, such as reading RCW, should eventually be=0A=
>> moved=0A=
>>>  	  into this driver as well.=0A=
>>> +=0A=
>>> +config FSL_PLAT_PM=0A=
>>> +	bool "Freescale platform PM framework"=0A=
>>> +	help=0A=
>>> +	  This driver is to provide a independent framework for PM service=0A=
>>> +	  provider and consumer to configure system level wake up feature.=0A=
>> For=0A=
>>> +	  example, RCPM driver could register a callback function on this=0A=
>>> +	  platform first, and Flex timer driver who want to enable timer wake=
=0A=
>>> +	  up feature, will call generic API provided by this platform driver,=
=0A=
>>> +	  and then it will trigger RCPM driver to do it. The benefit is to=0A=
>>> +	  isolate the user and service, such as  flex timer driver will not=
=0A=
>>> +	  have to know the implement details of wakeup function it require.=
=0A=
>>> +	  Besides, it is also easy for service side to upgrade its logic when=
=0A=
>>> +	  design changed and remain user side unchanged.=0A=
>>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index=
=0A=
>>> 44b3beb..8f9db23 100644=0A=
>>> --- a/drivers/soc/fsl/Makefile=0A=
>>> +++ b/drivers/soc/fsl/Makefile=0A=
>>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 +=3D qbman/=0A=
>>>  obj-$(CONFIG_QUICC_ENGINE)		+=3D qe/=0A=
>>>  obj-$(CONFIG_CPM)			+=3D qe/=0A=
>>>  obj-$(CONFIG_FSL_GUTS)			+=3D guts.o=0A=
>>> +obj-$(CONFIG_FSL_PLAT_PM)	+=3D plat_pm.o=0A=
>>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new=
=0A=
>>> file mode 100644 index 0000000..19ea14e=0A=
>>> --- /dev/null=0A=
>>> +++ b/drivers/soc/fsl/plat_pm.c=0A=
>>> @@ -0,0 +1,144 @@=0A=
>>> +// SPDX-License-Identifier: GPL-2.0=0A=
>>> +//=0A=
>>> +// plat_pm.c - Freescale platform PM framework // // Copyright 2018=0A=
>>> +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,=0A=
>>> +=0A=
>>> +#include <linux/kernel.h>=0A=
>>> +#include <linux/device.h>=0A=
>>> +#include <linux/list.h>=0A=
>>> +#include <linux/slab.h>=0A=
>>> +#include <linux/err.h>=0A=
>>> +#include <soc/fsl/plat_pm.h>=0A=
>>> +=0A=
>>> +=0A=
>>> +struct plat_pm_t {=0A=
>>> +	struct list_head node;=0A=
>>> +	fsl_plat_pm_handle handle;=0A=
>>> +	void *handle_priv;=0A=
>>> +	spinlock_t	lock;=0A=
>>> +};=0A=
>>> +=0A=
>>> +static struct plat_pm_t plat_pm;=0A=
>>> +=0A=
>>> +// register_fsl_platform_wakeup_source - Register callback function=0A=
>>> +to plat_pm // @handle: Pointer to handle PM feature requirement //=0A=
>>> +@handle_priv: Handler specific data struct // // Return 0 on success=
=0A=
>>> +other negative errno int=0A=
>>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,=0A=
>>> +		void *handle_priv)=0A=
>>> +{=0A=
>>> +	struct plat_pm_t *p;=0A=
>>> +	unsigned long	flags;=0A=
>>> +=0A=
>>> +	if (!handle) {=0A=
>>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");=0A=
>>> +		return -EINVAL;=0A=
>>> +	}=0A=
>>> +=0A=
>>> +	p =3D kmalloc(sizeof(*p), GFP_KERNEL);=0A=
>>> +	if (!p)=0A=
>>> +		return -ENOMEM;=0A=
>>> +=0A=
>>> +	p->handle =3D handle;=0A=
>>> +	p->handle_priv =3D handle_priv;=0A=
>>> +=0A=
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);=0A=
>>> +	list_add_tail(&p->node, &plat_pm.node);=0A=
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);=0A=
>>> +=0A=
>>> +	return 0;=0A=
>>> +}=0A=
>>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);=0A=
>>> +=0A=
>>> +// Deregister_fsl_platform_wakeup_source - deregister callback=0A=
>>> +function // @handle_priv: Handler specific data struct // // Return 0=
=0A=
>>> +on success other negative errno int=0A=
>>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {=0A=
>>> +	struct plat_pm_t *p, *tmp;=0A=
>>> +	unsigned long	flags;=0A=
>>> +=0A=
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);=0A=
>>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {=0A=
>>> +		if (p->handle_priv =3D=3D handle_priv) {=0A=
>>> +			list_del(&p->node);=0A=
>>> +			kfree(p);=0A=
>>> +		}=0A=
>>> +	}=0A=
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);=0A=
>>> +	return 0;=0A=
>>> +}=0A=
>>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);=0A=
>>> +=0A=
>>> +// fsl_platform_wakeup_config - Configure wakeup source by calling=0A=
>>> +handlers // @dev: pointer to user's device struct // @flag: to tell=0A=
>>> +enable or disable wakeup source // // Return 0 on success other=0A=
>>> +negative errno int fsl_platform_wakeup_config(struct device *dev,=0A=
>>> +bool flag) {=0A=
>>> +	struct plat_pm_t *p;=0A=
>>> +	int ret;=0A=
>>> +	bool success_handled;=0A=
>>> +	unsigned long	flags;=0A=
>>> +=0A=
>>> +	success_handled =3D false;=0A=
>>> +=0A=
>>> +	// Will consider success if at least one callback return 0.=0A=
>>> +	// Also, rest handles still get oppertunity to be executed=0A=
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);=0A=
>>> +	list_for_each_entry(p, &plat_pm.node, node) {=0A=
>>> +		if (p->handle) {=0A=
>>> +			ret =3D p->handle(dev, flag, p->handle_priv);=0A=
>>> +			if (!ret)=0A=
>>> +				success_handled =3D true;=0A=
>> Miss a break?=0A=
> Actually my idea is to allow more than one registered handler to handle t=
his=0A=
> request, so I define a flag rather than return to indicated if there is a=
t least one handler successfully=0A=
> do it. This design might give more flexibility to framework when running.=
=0A=
There is only one flag(success_handled) here, how did know which handler=0A=
failed?=0A=
=0A=
BTW, I don't think we need this flag. We can only use the return value.=0A=
=0A=
Cheers,=0A=
Dongsheng=0A=
=0A=
>>> +			else if (ret !=3D -ENODEV) {=0A=
>>> +				pr_err("FSL plat_pm: Failed to config wakeup=0A=
>> source:%d\n", ret);=0A=
>> Please unlock before return.=0A=
> Yes, will fix it in next version, thanks for pointing out!=0A=
>=0A=
>>> +				return ret;=0A=
>>> +			}=0A=
>>> +		} else=0A=
>>> +			pr_warn("FSL plat_pm: Invalid handler detected,=0A=
>> skip\n");=0A=
>>> +	}=0A=
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);=0A=
>>> +=0A=
>>> +	if (success_handled =3D=3D false) {=0A=
>>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for=0A=
>> wakeup source config\n");=0A=
>>> +		return -ENODEV;=0A=
>>> +	}=0A=
>> Add this into the loop.=0A=
> My design is that if the 1st handler return -ENODEV to indicated this dev=
ice it doesn't support, =0A=
> then the framework will continue try 2nd handler...=0A=
>=0A=
> So I think it is needed to place this checking out of loop, what do you s=
ay?=0A=
>=0A=
> Regards,=0A=
> Ran=0A=
>>> +=0A=
>>> +	return 0;=0A=
>>> +}=0A=
>>> +=0A=
>>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer=
=0A=
>>> +to user's device struct // // Return 0 on success other negative=0A=
>>> +errno int fsl_platform_wakeup_enable(struct device *dev) {=0A=
>>> +	return fsl_platform_wakeup_config(dev, true); }=0A=
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);=0A=
>>> +=0A=
>>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:=0A=
>>> +pointer to user's device struct // // Return 0 on success other=0A=
>>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {=
=0A=
>>> +	return fsl_platform_wakeup_config(dev, false); }=0A=
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);=0A=
>>> +=0A=
>>> +static int __init fsl_plat_pm_init(void) {=0A=
>>> +	spin_lock_init(&plat_pm.lock);=0A=
>>> +	INIT_LIST_HEAD(&plat_pm.node);=0A=
>>> +	return 0;=0A=
>>> +}=0A=
>>> +=0A=
>>> +core_initcall(fsl_plat_pm_init);=0A=
>>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new=
=0A=
>>> file mode 100644 index 0000000..bbe151e=0A=
>>> --- /dev/null=0A=
>>> +++ b/include/soc/fsl/plat_pm.h=0A=
>>> @@ -0,0 +1,22 @@=0A=
>>> +// SPDX-License-Identifier: GPL-2.0=0A=
>>> +//=0A=
>>> +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP=
=0A=
>>> +// // Author: Ran Wang <ran.wang_1@nxp.com>,=0A=
>>> +=0A=
>>> +#ifndef __FSL_PLAT_PM_H=0A=
>>> +#define __FSL_PLAT_PM_H=0A=
>>> +=0A=
>>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,=0A=
>>> +		void *handle_priv);=0A=
>>> +=0A=
>>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,=0A=
>>> +		void *handle_priv);=0A=
>>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int=0A=
>>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int=0A=
>>> +fsl_platform_wakeup_enable(struct device *dev); int=0A=
>>> +fsl_platform_wakeup_disable(struct device *dev);=0A=
>>> +=0A=
>>> +#endif	// __FSL_PLAT_PM_H=0A=
>=0A=
=0A=

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07 10:15       ` Wang, Dongsheng
  0 siblings, 0 replies; 73+ messages in thread
From: Wang, Dongsheng @ 2018-09-07 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

On 2018/9/7 16:49, Ran Wang wrote:
> Hi Dongsheng
>
>> On 2018/9/5 11:05, Dongsheng Wang wrote:
>>
>> Please change your comments style.
>>
>> On 2018/8/31 11:57, Ran Wang wrote:
>>> This driver is to provide a independent framework for PM service
>>> provider and consumer to configure system level wake up feature. For
>>> example, RCPM driver could register a callback function on this
>>> platform first, and Flex timer driver who want to enable timer wake up
>>> feature, will call generic API provided by this platform driver, and
>>> then it will trigger RCPM driver to do it. The benefit is to isolate
>>> the user and service, such as flex timer driver will not have to know
>>> the implement details of wakeup function it require. Besides, it is
>>> also easy for service side to upgrade its logic when design is changed
>>> and remain user side unchanged.
>>>
>>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
>>> ---
>>>  drivers/soc/fsl/Kconfig   |   14 +++++
>>>  drivers/soc/fsl/Makefile  |    1 +
>>>  drivers/soc/fsl/plat_pm.c |  144
>> +++++++++++++++++++++++++++++++++++++++++++++
>>>  include/soc/fsl/plat_pm.h |   22 +++++++
>>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
>>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
>>> include/soc/fsl/plat_pm.h
>>>
>>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
>>> 7a9fb9b..6517412 100644
>>> --- a/drivers/soc/fsl/Kconfig
>>> +++ b/drivers/soc/fsl/Kconfig
>>> @@ -16,3 +16,17 @@ config FSL_GUTS
>>>  	  Initially only reading SVR and registering soc device are supported.
>>>  	  Other guts accesses, such as reading RCW, should eventually be
>> moved
>>>  	  into this driver as well.
>>> +
>>> +config FSL_PLAT_PM
>>> +	bool "Freescale platform PM framework"
>>> +	help
>>> +	  This driver is to provide a independent framework for PM service
>>> +	  provider and consumer to configure system level wake up feature.
>> For
>>> +	  example, RCPM driver could register a callback function on this
>>> +	  platform first, and Flex timer driver who want to enable timer wake
>>> +	  up feature, will call generic API provided by this platform driver,
>>> +	  and then it will trigger RCPM driver to do it. The benefit is to
>>> +	  isolate the user and service, such as  flex timer driver will not
>>> +	  have to know the implement details of wakeup function it require.
>>> +	  Besides, it is also easy for service side to upgrade its logic when
>>> +	  design changed and remain user side unchanged.
>>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index
>>> 44b3beb..8f9db23 100644
>>> --- a/drivers/soc/fsl/Makefile
>>> +++ b/drivers/soc/fsl/Makefile
>>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
>>>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
>>>  obj-$(CONFIG_CPM)			+= qe/
>>>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
>>> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
>>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c new
>>> file mode 100644 index 0000000..19ea14e
>>> --- /dev/null
>>> +++ b/drivers/soc/fsl/plat_pm.c
>>> @@ -0,0 +1,144 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// plat_pm.c - Freescale platform PM framework // // Copyright 2018
>>> +NXP // // Author: Ran Wang <ran.wang_1@nxp.com>,
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/device.h>
>>> +#include <linux/list.h>
>>> +#include <linux/slab.h>
>>> +#include <linux/err.h>
>>> +#include <soc/fsl/plat_pm.h>
>>> +
>>> +
>>> +struct plat_pm_t {
>>> +	struct list_head node;
>>> +	fsl_plat_pm_handle handle;
>>> +	void *handle_priv;
>>> +	spinlock_t	lock;
>>> +};
>>> +
>>> +static struct plat_pm_t plat_pm;
>>> +
>>> +// register_fsl_platform_wakeup_source - Register callback function
>>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
>>> + at handle_priv: Handler specific data struct // // Return 0 on success
>>> +other negative errno int
>>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
>>> +		void *handle_priv)
>>> +{
>>> +	struct plat_pm_t *p;
>>> +	unsigned long	flags;
>>> +
>>> +	if (!handle) {
>>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
>>> +	if (!p)
>>> +		return -ENOMEM;
>>> +
>>> +	p->handle = handle;
>>> +	p->handle_priv = handle_priv;
>>> +
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_add_tail(&p->node, &plat_pm.node);
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
>>> +
>>> +// Deregister_fsl_platform_wakeup_source - deregister callback
>>> +function // @handle_priv: Handler specific data struct // // Return 0
>>> +on success other negative errno int
>>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
>>> +	struct plat_pm_t *p, *tmp;
>>> +	unsigned long	flags;
>>> +
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
>>> +		if (p->handle_priv == handle_priv) {
>>> +			list_del(&p->node);
>>> +			kfree(p);
>>> +		}
>>> +	}
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
>>> +
>>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
>>> +handlers // @dev: pointer to user's device struct // @flag: to tell
>>> +enable or disable wakeup source // // Return 0 on success other
>>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
>>> +bool flag) {
>>> +	struct plat_pm_t *p;
>>> +	int ret;
>>> +	bool success_handled;
>>> +	unsigned long	flags;
>>> +
>>> +	success_handled = false;
>>> +
>>> +	// Will consider success if at least one callback return 0.
>>> +	// Also, rest handles still get oppertunity to be executed
>>> +	spin_lock_irqsave(&plat_pm.lock, flags);
>>> +	list_for_each_entry(p, &plat_pm.node, node) {
>>> +		if (p->handle) {
>>> +			ret = p->handle(dev, flag, p->handle_priv);
>>> +			if (!ret)
>>> +				success_handled = true;
>> Miss a break?
> Actually my idea is to allow more than one registered handler to handle this
> request, so I define a flag rather than return to indicated if there is at least one handler successfully
> do it. This design might give more flexibility to framework when running.
There is only one flag(success_handled) here, how did know which handler
failed?

BTW, I don't think we need this flag. We can only use the return value.

Cheers,
Dongsheng

>>> +			else if (ret != -ENODEV) {
>>> +				pr_err("FSL plat_pm: Failed to config wakeup
>> source:%d\n", ret);
>> Please unlock before return.
> Yes, will fix it in next version, thanks for pointing out!
>
>>> +				return ret;
>>> +			}
>>> +		} else
>>> +			pr_warn("FSL plat_pm: Invalid handler detected,
>> skip\n");
>>> +	}
>>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
>>> +
>>> +	if (success_handled == false) {
>>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
>> wakeup source config\n");
>>> +		return -ENODEV;
>>> +	}
>> Add this into the loop.
> My design is that if the 1st handler return -ENODEV to indicated this device it doesn't support, 
> then the framework will continue try 2nd handler...
>
> So I think it is needed to place this checking out of loop, what do you say?
>
> Regards,
> Ran
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev: pointer
>>> +to user's device struct // // Return 0 on success other negative
>>> +errno int fsl_platform_wakeup_enable(struct device *dev) {
>>> +	return fsl_platform_wakeup_config(dev, true); }
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
>>> +
>>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
>>> +pointer to user's device struct // // Return 0 on success other
>>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
>>> +	return fsl_platform_wakeup_config(dev, false); }
>>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
>>> +
>>> +static int __init fsl_plat_pm_init(void) {
>>> +	spin_lock_init(&plat_pm.lock);
>>> +	INIT_LIST_HEAD(&plat_pm.node);
>>> +	return 0;
>>> +}
>>> +
>>> +core_initcall(fsl_plat_pm_init);
>>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h new
>>> file mode 100644 index 0000000..bbe151e
>>> --- /dev/null
>>> +++ b/include/soc/fsl/plat_pm.h
>>> @@ -0,0 +1,22 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +//
>>> +// plat_pm.h - Freescale platform PM Header // // Copyright 2018 NXP
>>> +// // Author: Ran Wang <ran.wang_1@nxp.com>,
>>> +
>>> +#ifndef __FSL_PLAT_PM_H
>>> +#define __FSL_PLAT_PM_H
>>> +
>>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
>>> +		void *handle_priv);
>>> +
>>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
>>> +		void *handle_priv);
>>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
>>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
>>> +fsl_platform_wakeup_enable(struct device *dev); int
>>> +fsl_platform_wakeup_disable(struct device *dev);
>>> +
>>> +#endif	// __FSL_PLAT_PM_H
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-09-07  9:48         ` Ran Wang
  (?)
@ 2018-09-07 18:56           ` Li Yang
  -1 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-07 18:56 UTC (permalink / raw)
  To: Ran Wang
  Cc: Mark Rutland, dongsheng.wang,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, lkml,
	Rob Herring, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Fri, Sep 7, 2018 at 4:51 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Hi Leo,
>
> On September 05, 2018 at 11:22 Yang Li wrote:
> > -----Original Message-----
> > From: Li Yang <leoyang.li@nxp.com>
> > Sent: Wednesday, September 05, 2018 11:22
> > To: dongsheng.wang@hxt-semitech.com
> > Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring <robh+dt@kernel.org>;
> > Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; linuxppc-
> > dev <linuxppc-dev@lists.ozlabs.org>; lkml <linux-kernel@vger.kernel.org>;
> > moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm-
> > kernel@lists.infradead.org>
> > Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> >
> > On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng <dongsheng.wang@hxt-
> > semitech.com> wrote:
> > >
> > > Please change your comments style.
> >
> > Although this doesn't get into the Linux kernel coding style documentation
> > yet, Linus seems changed his mind to prefer // than /*
> > */ comment style now.
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> > .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.wang_
> > 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> > 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> > WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> > So the
> > // style should be acceptable for now.
> >
> > >
> > > On 2018/8/31 11:56, Ran Wang wrote:
> > > > 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 FSL platform PM driver framework which help
> > > > to isolate user and PM service provider (such as RCPM driver).
> > > >
> > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > > ---
> > > >  drivers/soc/fsl/Kconfig   |    6 ++
> > > >  drivers/soc/fsl/Makefile  |    1 +
> > > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > > 100644 drivers/soc/fsl/ls-rcpm.c
> > > >
> > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > > > 6517412..882330d 100644
> > > > --- a/drivers/soc/fsl/Kconfig
> > > > +++ b/drivers/soc/fsl/Kconfig
> > > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > > >         have to know the implement details of wakeup function it require.
> > > >         Besides, it is also easy for service side to upgrade its logic when
> > > >         design changed and remain user side unchanged.
> > > > +
> > > > +config LS_RCPM
> > > > +     bool "Freescale RCPM support"
> > > > +     depends on (FSL_PLAT_PM)
> > > > +     help
> > > > +       This feature is to enable specified wakeup source for system sleep.
> > > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > > index 8f9db23..43ff71a 100644
> > > > --- a/drivers/soc/fsl/Makefile
> > > > +++ b/drivers/soc/fsl/Makefile
> > > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > > >  obj-$(CONFIG_CPM)                    += qe/
> > > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> >
> > Probably use "_" instead of "-" for alignment.
>
> OK, will update in next version
>
> > > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > > > new file mode 100644 index 0000000..b0feb88
> > > > --- /dev/null
> > > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > > @@ -0,0 +1,153 @@
> > > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > > +Layerscape RCPM driver
> >
> > The file name here is not the same as the real file name.
>
> Got it, will correct it.
>
> > > > +//
> > > > +// Copyright 2018 NXP
> > > > +//
> > > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> >
> > Where do you need the comma in the end?
>
> My bad, will remove comma in next version.
>
> > > > +
> > > > +#include <linux/init.h>
> > > > +#include <linux/module.h>
> > > > +#include <linux/platform_device.h>
> > > > +#include <linux/of_address.h>
> > > > +#include <linux/slab.h>
> > > > +#include <soc/fsl/plat_pm.h>
> > > > +
> > > > +#define MAX_COMPATIBLE_NUM   10
> > > > +
> > > > +struct rcpm_t {
> > > > +     struct device *dev;
> > > > +     void __iomem *ippdexpcr_addr;
> > > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > > +};
> > > > +
> > > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > > +request // @user_dev: pointer to user's device struct // @flag: to
> > > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > > +pointer to struct rcpm_t instance // // Return 0 on success other
> > > > +negative errno
> >
> > Although Linus preferred this // comment style.  I'm not sure if this will be
> > handled correctly by the kernel-doc compiler.
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> > w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> > doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> > 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> > %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHCbO9
> > %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0
>
> So, do you think I need to change all comment style back to '/* ... */' ?
> Actually I feel a little bit confused here.

I think Linus's comment about // comment style applies to normal code
comment.  But kernel-doc comment is a special kind of code comment
that needs to meet certain requirements.  People can use the
scripts/kernel-doc tool to generate readable API documents from the
source code.  It looks like you wanted to make the function
description aligned with the kernel-doc format, but kernel-doc
specifically requires to use the /* */ style(at least for now).

Regards,
Leo

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07 18:56           ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-07 18:56 UTC (permalink / raw)
  To: Ran Wang
  Cc: Mark Rutland, dongsheng.wang,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, lkml,
	Rob Herring, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Fri, Sep 7, 2018 at 4:51 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Hi Leo,
>
> On September 05, 2018 at 11:22 Yang Li wrote:
> > -----Original Message-----
> > From: Li Yang <leoyang.li@nxp.com>
> > Sent: Wednesday, September 05, 2018 11:22
> > To: dongsheng.wang@hxt-semitech.com
> > Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring <robh+dt@kernel.org>;
> > Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; linuxppc-
> > dev <linuxppc-dev@lists.ozlabs.org>; lkml <linux-kernel@vger.kernel.org>;
> > moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm-
> > kernel@lists.infradead.org>
> > Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> >
> > On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng <dongsheng.wang@hxt-
> > semitech.com> wrote:
> > >
> > > Please change your comments style.
> >
> > Although this doesn't get into the Linux kernel coding style documentation
> > yet, Linus seems changed his mind to prefer // than /*
> > */ comment style now.
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> > .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.wang_
> > 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> > 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> > WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> > So the
> > // style should be acceptable for now.
> >
> > >
> > > On 2018/8/31 11:56, Ran Wang wrote:
> > > > 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 FSL platform PM driver framework which help
> > > > to isolate user and PM service provider (such as RCPM driver).
> > > >
> > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > > ---
> > > >  drivers/soc/fsl/Kconfig   |    6 ++
> > > >  drivers/soc/fsl/Makefile  |    1 +
> > > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > > 100644 drivers/soc/fsl/ls-rcpm.c
> > > >
> > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > > > 6517412..882330d 100644
> > > > --- a/drivers/soc/fsl/Kconfig
> > > > +++ b/drivers/soc/fsl/Kconfig
> > > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > > >         have to know the implement details of wakeup function it require.
> > > >         Besides, it is also easy for service side to upgrade its logic when
> > > >         design changed and remain user side unchanged.
> > > > +
> > > > +config LS_RCPM
> > > > +     bool "Freescale RCPM support"
> > > > +     depends on (FSL_PLAT_PM)
> > > > +     help
> > > > +       This feature is to enable specified wakeup source for system sleep.
> > > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > > index 8f9db23..43ff71a 100644
> > > > --- a/drivers/soc/fsl/Makefile
> > > > +++ b/drivers/soc/fsl/Makefile
> > > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > > >  obj-$(CONFIG_CPM)                    += qe/
> > > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> >
> > Probably use "_" instead of "-" for alignment.
>
> OK, will update in next version
>
> > > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > > > new file mode 100644 index 0000000..b0feb88
> > > > --- /dev/null
> > > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > > @@ -0,0 +1,153 @@
> > > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > > +Layerscape RCPM driver
> >
> > The file name here is not the same as the real file name.
>
> Got it, will correct it.
>
> > > > +//
> > > > +// Copyright 2018 NXP
> > > > +//
> > > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> >
> > Where do you need the comma in the end?
>
> My bad, will remove comma in next version.
>
> > > > +
> > > > +#include <linux/init.h>
> > > > +#include <linux/module.h>
> > > > +#include <linux/platform_device.h>
> > > > +#include <linux/of_address.h>
> > > > +#include <linux/slab.h>
> > > > +#include <soc/fsl/plat_pm.h>
> > > > +
> > > > +#define MAX_COMPATIBLE_NUM   10
> > > > +
> > > > +struct rcpm_t {
> > > > +     struct device *dev;
> > > > +     void __iomem *ippdexpcr_addr;
> > > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > > +};
> > > > +
> > > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > > +request // @user_dev: pointer to user's device struct // @flag: to
> > > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > > +pointer to struct rcpm_t instance // // Return 0 on success other
> > > > +negative errno
> >
> > Although Linus preferred this // comment style.  I'm not sure if this will be
> > handled correctly by the kernel-doc compiler.
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> > w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> > doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> > 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> > %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHCbO9
> > %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0
>
> So, do you think I need to change all comment style back to '/* ... */' ?
> Actually I feel a little bit confused here.

I think Linus's comment about // comment style applies to normal code
comment.  But kernel-doc comment is a special kind of code comment
that needs to meet certain requirements.  People can use the
scripts/kernel-doc tool to generate readable API documents from the
source code.  It looks like you wanted to make the function
description aligned with the kernel-doc format, but kernel-doc
specifically requires to use the /* */ style(at least for now).

Regards,
Leo

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07 18:56           ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-07 18:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 7, 2018 at 4:51 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Hi Leo,
>
> On September 05, 2018 at 11:22 Yang Li wrote:
> > -----Original Message-----
> > From: Li Yang <leoyang.li@nxp.com>
> > Sent: Wednesday, September 05, 2018 11:22
> > To: dongsheng.wang at hxt-semitech.com
> > Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring <robh+dt@kernel.org>;
> > Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; linuxppc-
> > dev <linuxppc-dev@lists.ozlabs.org>; lkml <linux-kernel@vger.kernel.org>;
> > moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm-
> > kernel at lists.infradead.org>
> > Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> >
> > On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng <dongsheng.wang@hxt-
> > semitech.com> wrote:
> > >
> > > Please change your comments style.
> >
> > Although this doesn't get into the Linux kernel coding style documentation
> > yet, Linus seems changed his mind to prefer // than /*
> > */ comment style now.
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> > .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.wang_
> > 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> > 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> > WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> > So the
> > // style should be acceptable for now.
> >
> > >
> > > On 2018/8/31 11:56, Ran Wang wrote:
> > > > 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 FSL platform PM driver framework which help
> > > > to isolate user and PM service provider (such as RCPM driver).
> > > >
> > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > > ---
> > > >  drivers/soc/fsl/Kconfig   |    6 ++
> > > >  drivers/soc/fsl/Makefile  |    1 +
> > > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > > 100644 drivers/soc/fsl/ls-rcpm.c
> > > >
> > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > > > 6517412..882330d 100644
> > > > --- a/drivers/soc/fsl/Kconfig
> > > > +++ b/drivers/soc/fsl/Kconfig
> > > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > > >         have to know the implement details of wakeup function it require.
> > > >         Besides, it is also easy for service side to upgrade its logic when
> > > >         design changed and remain user side unchanged.
> > > > +
> > > > +config LS_RCPM
> > > > +     bool "Freescale RCPM support"
> > > > +     depends on (FSL_PLAT_PM)
> > > > +     help
> > > > +       This feature is to enable specified wakeup source for system sleep.
> > > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > > index 8f9db23..43ff71a 100644
> > > > --- a/drivers/soc/fsl/Makefile
> > > > +++ b/drivers/soc/fsl/Makefile
> > > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > > >  obj-$(CONFIG_CPM)                    += qe/
> > > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> >
> > Probably use "_" instead of "-" for alignment.
>
> OK, will update in next version
>
> > > > diff --git a/drivers/soc/fsl/ls-rcpm.c b/drivers/soc/fsl/ls-rcpm.c
> > > > new file mode 100644 index 0000000..b0feb88
> > > > --- /dev/null
> > > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > > @@ -0,0 +1,153 @@
> > > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > > +Layerscape RCPM driver
> >
> > The file name here is not the same as the real file name.
>
> Got it, will correct it.
>
> > > > +//
> > > > +// Copyright 2018 NXP
> > > > +//
> > > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> >
> > Where do you need the comma in the end?
>
> My bad, will remove comma in next version.
>
> > > > +
> > > > +#include <linux/init.h>
> > > > +#include <linux/module.h>
> > > > +#include <linux/platform_device.h>
> > > > +#include <linux/of_address.h>
> > > > +#include <linux/slab.h>
> > > > +#include <soc/fsl/plat_pm.h>
> > > > +
> > > > +#define MAX_COMPATIBLE_NUM   10
> > > > +
> > > > +struct rcpm_t {
> > > > +     struct device *dev;
> > > > +     void __iomem *ippdexpcr_addr;
> > > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > > +};
> > > > +
> > > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > > +request // @user_dev: pointer to user's device struct // @flag: to
> > > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > > +pointer to struct rcpm_t instance // // Return 0 on success other
> > > > +negative errno
> >
> > Although Linus preferred this // comment style.  I'm not sure if this will be
> > handled correctly by the kernel-doc compiler.
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> > w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> > doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> > 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> > %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHCbO9
> > %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0
>
> So, do you think I need to change all comment style back to '/* ... */' ?
> Actually I feel a little bit confused here.

I think Linus's comment about // comment style applies to normal code
comment.  But kernel-doc comment is a special kind of code comment
that needs to meet certain requirements.  People can use the
scripts/kernel-doc tool to generate readable API documents from the
source code.  It looks like you wanted to make the function
description aligned with the kernel-doc format, but kernel-doc
specifically requires to use the /* */ style(at least for now).

Regards,
Leo

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
  2018-08-31  3:52   ` Ran Wang
@ 2018-09-07 20:22     ` Scott Wood
  -1 siblings, 0 replies; 73+ messages in thread
From: Scott Wood @ 2018-09-07 20:22 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> +Optional properties:
> + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> +   that doesn't have this property will be regarded as little-endian.

You've just broken all the existing powerpc device trees that are big-endian
and have no big-endian property.

> + - <property 'compatible' string of consumer device> : This string
> +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> +   is able to be regards as wakeup source or not, such as 'fsl,ls1012a-
> ftm'.
> +   Further, this property will carry the bit mask info to control
> +   coresponding wake up source.

What will you do if there are multiple instances of a device with the same
compatible, and different wakeup bits?  Plus, it's an awkward design in
general, and you don't describe what the value actually means (bits in which
register?).  What was wrong with the existing binding?  Alternatively, use the
clock bindings.

> -
> -Example:
> -	lpuart0: serial@2950000 {
> -		compatible = "fsl,ls1021a-lpuart";
> -		reg = <0x0 0x2950000 0x0 0x1000>;
> -		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> -		clocks = <&sysclk>;
> -		clock-names = "ipg";
> -		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> +		big-endian;
> +		fsl,ls1012a-ftm = <0x20000>;
> +		fsl,pfe = <0xf0000020>;

fsl,pfe is not documented.

-Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-07 20:22     ` Scott Wood
  0 siblings, 0 replies; 73+ messages in thread
From: Scott Wood @ 2018-09-07 20:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> +Optional properties:
> + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> +   that doesn't have this property will be regarded as little-endian.

You've just broken all the existing powerpc device trees that are big-endian
and have no big-endian property.

> + - <property 'compatible' string of consumer device> : This string
> +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> +   is able to be regards as wakeup source or not, such as 'fsl,ls1012a-
> ftm'.
> +   Further, this property will carry the bit mask info to control
> +   coresponding wake up source.

What will you do if there are multiple instances of a device with the same
compatible, and different wakeup bits?  Plus, it's an awkward design in
general, and you don't describe what the value actually means (bits in which
register?).  What was wrong with the existing binding?  Alternatively, use the
clock bindings.

> -
> -Example:
> -	lpuart0: serial at 2950000 {
> -		compatible = "fsl,ls1021a-lpuart";
> -		reg = <0x0 0x2950000 0x0 0x1000>;
> -		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> -		clocks = <&sysclk>;
> -		clock-names = "ipg";
> -		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> +		big-endian;
> +		fsl,ls1012a-ftm = <0x20000>;
> +		fsl,pfe = <0xf0000020>;

fsl,pfe is not documented.

-Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-08-31  3:52   ` Ran Wang
@ 2018-09-07 20:25     ` Scott Wood
  -1 siblings, 0 replies; 73+ messages in thread
From: Scott Wood @ 2018-09-07 20:25 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> 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 FSL platform PM driver framework which help to
> isolate user and PM service provider (such as RCPM driver).
> 
> Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |    6 ++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/ls-rcpm.c |  153
> +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 160 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/ls-rcpm.c

Is there a reason why this is LS-specific, or could it be used with PPC RCPM
blocks?

> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 6517412..882330d 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -30,3 +30,9 @@ config FSL_PLAT_PM
>  	  have to know the implement details of wakeup function it require.
>  	  Besides, it is also easy for service side to upgrade its logic
> when
>  	  design changed and remain user side unchanged.
> +
> +config LS_RCPM
> +	bool "Freescale RCPM support"
> +	depends on (FSL_PLAT_PM)

Why is this parenthesized?

-Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-07 20:25     ` Scott Wood
  0 siblings, 0 replies; 73+ messages in thread
From: Scott Wood @ 2018-09-07 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> 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 FSL platform PM driver framework which help to
> isolate user and PM service provider (such as RCPM driver).
> 
> Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |    6 ++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/ls-rcpm.c |  153
> +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 160 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/ls-rcpm.c

Is there a reason why this is LS-specific, or could it be used with PPC RCPM
blocks?

> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 6517412..882330d 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -30,3 +30,9 @@ config FSL_PLAT_PM
>  	  have to know the implement details of wakeup function it require.
>  	  Besides, it is also easy for service side to upgrade its logic
> when
>  	  design changed and remain user side unchanged.
> +
> +config LS_RCPM
> +	bool "Freescale RCPM support"
> +	depends on (FSL_PLAT_PM)

Why is this parenthesized?

-Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
  2018-08-31  3:52 ` Ran Wang
@ 2018-09-07 20:35   ` Scott Wood
  -1 siblings, 0 replies; 73+ messages in thread
From: Scott Wood @ 2018-09-07 20:35 UTC (permalink / raw)
  To: Ran Wang, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel

On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> This driver is to provide a independent framework for PM service
> provider and consumer to configure system level wake up feature. For
> example, RCPM driver could register a callback function on this
> platform first, and Flex timer driver who want to enable timer wake
> up feature, will call generic API provided by this platform driver,
> and then it will trigger RCPM driver to do it. The benefit is to
> isolate the user and service, such as flex timer driver will not have
> to know the implement details of wakeup function it require. Besides,
> it is also easy for service side to upgrade its logic when design is
> changed and remain user side unchanged.
> 
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |   14 +++++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/plat_pm.c |  144
> +++++++++++++++++++++++++++++++++++++++++++++
>  include/soc/fsl/plat_pm.h |   22 +++++++
>  4 files changed, 181 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/plat_pm.c
>  create mode 100644 include/soc/fsl/plat_pm.h
> 
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 7a9fb9b..6517412 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -16,3 +16,17 @@ config FSL_GUTS
>  	  Initially only reading SVR and registering soc device are
> supported.
>  	  Other guts accesses, such as reading RCW, should eventually be
> moved
>  	  into this driver as well.
+
> +config FSL_PLAT_PM
> +	bool "Freescale platform PM framework"

This name seems to be simultaneously too generic (for something that is likely
intended only for use with certain Freescale/NXP chip families) and too
specific (for something that seems to be general infrastructure with no real
hardware dependencies).

What specific problems with Linux's generic wakeup infrastructure is this
trying to solve, and why would those problems not be better solved there?

Also, you should CC linux-pm on these patches.

-Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-07 20:35   ` Scott Wood
  0 siblings, 0 replies; 73+ messages in thread
From: Scott Wood @ 2018-09-07 20:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> This driver is to provide a independent framework for PM service
> provider and consumer to configure system level wake up feature. For
> example, RCPM driver could register a callback function on this
> platform first, and Flex timer driver who want to enable timer wake
> up feature, will call generic API provided by this platform driver,
> and then it will trigger RCPM driver to do it. The benefit is to
> isolate the user and service, such as flex timer driver will not have
> to know the implement details of wakeup function it require. Besides,
> it is also easy for service side to upgrade its logic when design is
> changed and remain user side unchanged.
> 
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/soc/fsl/Kconfig   |   14 +++++
>  drivers/soc/fsl/Makefile  |    1 +
>  drivers/soc/fsl/plat_pm.c |  144
> +++++++++++++++++++++++++++++++++++++++++++++
>  include/soc/fsl/plat_pm.h |   22 +++++++
>  4 files changed, 181 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/soc/fsl/plat_pm.c
>  create mode 100644 include/soc/fsl/plat_pm.h
> 
> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> index 7a9fb9b..6517412 100644
> --- a/drivers/soc/fsl/Kconfig
> +++ b/drivers/soc/fsl/Kconfig
> @@ -16,3 +16,17 @@ config FSL_GUTS
>  	  Initially only reading SVR and registering soc device are
> supported.
>  	  Other guts accesses, such as reading RCW, should eventually be
> moved
>  	  into this driver as well.
+
> +config FSL_PLAT_PM
> +	bool "Freescale platform PM framework"

This name seems to be simultaneously too generic (for something that is likely
intended only for use with certain Freescale/NXP chip families) and too
specific (for something that seems to be general infrastructure with no real
hardware dependencies).

What specific problems with Linux's generic wakeup infrastructure is this
trying to solve, and why would those problems not be better solved there?

Also, you should CC linux-pm on these patches.

-Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
  2018-09-07 10:15       ` Wang, Dongsheng
  (?)
  (?)
@ 2018-09-10  3:27         ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:27 UTC (permalink / raw)
  To: Wang, Dongsheng
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland, linux-pm

Hi Dongsheng,

On 2018/9/7 18:16, Dongsheng Wang wrote:
> 
> On 2018/9/7 16:49, Ran Wang wrote:
> > Hi Dongsheng
> >
> >> On 2018/9/5 11:05, Dongsheng Wang wrote:
> >>
> >> Please change your comments style.
> >>
> >> On 2018/8/31 11:57, Ran Wang wrote:
> >>> This driver is to provide a independent framework for PM service
> >>> provider and consumer to configure system level wake up feature. For
> >>> example, RCPM driver could register a callback function on this
> >>> platform first, and Flex timer driver who want to enable timer wake
> >>> up feature, will call generic API provided by this platform driver,
> >>> and then it will trigger RCPM driver to do it. The benefit is to
> >>> isolate the user and service, such as flex timer driver will not
> >>> have to know the implement details of wakeup function it require.
> >>> Besides, it is also easy for service side to upgrade its logic when
> >>> design is changed and remain user side unchanged.
> >>>
> >>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> >>> ---
> >>>  drivers/soc/fsl/Kconfig   |   14 +++++
> >>>  drivers/soc/fsl/Makefile  |    1 +
> >>>  drivers/soc/fsl/plat_pm.c |  144
> >> +++++++++++++++++++++++++++++++++++++++++++++
> >>>  include/soc/fsl/plat_pm.h |   22 +++++++
> >>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> >>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> >>> include/soc/fsl/plat_pm.h
> >>>
> >>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> >>> 7a9fb9b..6517412 100644
> >>> --- a/drivers/soc/fsl/Kconfig
> >>> +++ b/drivers/soc/fsl/Kconfig
> >>> @@ -16,3 +16,17 @@ config FSL_GUTS
> >>>  	  Initially only reading SVR and registering soc device are supported.
> >>>  	  Other guts accesses, such as reading RCW, should eventually be
> >> moved
> >>>  	  into this driver as well.
> >>> +
> >>> +config FSL_PLAT_PM
> >>> +	bool "Freescale platform PM framework"
> >>> +	help
> >>> +	  This driver is to provide a independent framework for PM service
> >>> +	  provider and consumer to configure system level wake up feature.
> >> For
> >>> +	  example, RCPM driver could register a callback function on this
> >>> +	  platform first, and Flex timer driver who want to enable timer wake
> >>> +	  up feature, will call generic API provided by this platform driver,
> >>> +	  and then it will trigger RCPM driver to do it. The benefit is to
> >>> +	  isolate the user and service, such as  flex timer driver will not
> >>> +	  have to know the implement details of wakeup function it require.
> >>> +	  Besides, it is also easy for service side to upgrade its logic when
> >>> +	  design changed and remain user side unchanged.
> >>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> >>> index
> >>> 44b3beb..8f9db23 100644
> >>> --- a/drivers/soc/fsl/Makefile
> >>> +++ b/drivers/soc/fsl/Makefile
> >>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
> >>>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >>>  obj-$(CONFIG_CPM)			+= qe/
> >>>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> >>> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> >>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> >>> new file mode 100644 index 0000000..19ea14e
> >>> --- /dev/null
> >>> +++ b/drivers/soc/fsl/plat_pm.c
> >>> @@ -0,0 +1,144 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> >>> +platform PM framework // // Copyright 2018 NXP // // Author: Ran
> >>> +Wang <ran.wang_1@nxp.com>,
> >>> +
> >>> +#include <linux/kernel.h>
> >>> +#include <linux/device.h>
> >>> +#include <linux/list.h>
> >>> +#include <linux/slab.h>
> >>> +#include <linux/err.h>
> >>> +#include <soc/fsl/plat_pm.h>
> >>> +
> >>> +
> >>> +struct plat_pm_t {
> >>> +	struct list_head node;
> >>> +	fsl_plat_pm_handle handle;
> >>> +	void *handle_priv;
> >>> +	spinlock_t	lock;
> >>> +};
> >>> +
> >>> +static struct plat_pm_t plat_pm;
> >>> +
> >>> +// register_fsl_platform_wakeup_source - Register callback function
> >>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
> >>> +@handle_priv: Handler specific data struct // // Return 0 on
> >>> +success other negative errno int
> >>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv)
> >>> +{
> >>> +	struct plat_pm_t *p;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	if (!handle) {
> >>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> >>> +		return -EINVAL;
> >>> +	}
> >>> +
> >>> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> >>> +	if (!p)
> >>> +		return -ENOMEM;
> >>> +
> >>> +	p->handle = handle;
> >>> +	p->handle_priv = handle_priv;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_add_tail(&p->node, &plat_pm.node);
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> >>> +
> >>> +// Deregister_fsl_platform_wakeup_source - deregister callback
> >>> +function // @handle_priv: Handler specific data struct // // Return
> >>> +0 on success other negative errno int
> >>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> >>> +	struct plat_pm_t *p, *tmp;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> >>> +		if (p->handle_priv == handle_priv) {
> >>> +			list_del(&p->node);
> >>> +			kfree(p);
> >>> +		}
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> >>> +
> >>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
> >>> +handlers // @dev: pointer to user's device struct // @flag: to tell
> >>> +enable or disable wakeup source // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
> >>> +bool flag) {
> >>> +	struct plat_pm_t *p;
> >>> +	int ret;
> >>> +	bool success_handled;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	success_handled = false;
> >>> +
> >>> +	// Will consider success if at least one callback return 0.
> >>> +	// Also, rest handles still get oppertunity to be executed
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry(p, &plat_pm.node, node) {
> >>> +		if (p->handle) {
> >>> +			ret = p->handle(dev, flag, p->handle_priv);
> >>> +			if (!ret)
> >>> +				success_handled = true;
> >> Miss a break?
> > Actually my idea is to allow more than one registered handler to
> > handle this request, so I define a flag rather than return to
> > indicated if there is at least one handler successfully do it. This design
> might give more flexibility to framework when running.
> There is only one flag(success_handled) here, how did know which handler
> failed?
> 
> BTW, I don't think we need this flag. We can only use the return value.

Well, the plat_pm driver will not handle most errors returned by registered
handlers, except -NODEV. For -NODEV, plat_pm driver consider that handler
cannot support this request and will go to call next one. 

Besides, actually it doesn't restrict that request can be served by only one 
handler. So I add that flag to cover the case of more than one handler can 
successfully support and others might return -NODEV.

Regards,
Ran

> Cheers,
> Dongsheng
> 
> >>> +			else if (ret != -ENODEV) {
> >>> +				pr_err("FSL plat_pm: Failed to config wakeup
> >> source:%d\n", ret);
> >> Please unlock before return.
> > Yes, will fix it in next version, thanks for pointing out!
> >
> >>> +				return ret;
> >>> +			}
> >>> +		} else
> >>> +			pr_warn("FSL plat_pm: Invalid handler detected,
> >> skip\n");
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	if (success_handled == false) {
> >>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> >> wakeup source config\n");
> >>> +		return -ENODEV;
> >>> +	}
> >> Add this into the loop.
> > My design is that if the 1st handler return -ENODEV to indicated this
> > device it doesn't support, then the framework will continue try 2nd
> handler...
> >
> > So I think it is needed to place this checking out of loop, what do you say?
> >
> > Regards,
> > Ran
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_enable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, true); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> >>> +
> >>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, false); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> >>> +
> >>> +static int __init fsl_plat_pm_init(void) {
> >>> +	spin_lock_init(&plat_pm.lock);
> >>> +	INIT_LIST_HEAD(&plat_pm.node);
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +core_initcall(fsl_plat_pm_init);
> >>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> >>> new file mode 100644 index 0000000..bbe151e
> >>> --- /dev/null
> >>> +++ b/include/soc/fsl/plat_pm.h
> >>> @@ -0,0 +1,22 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.h - Freescale
> >>> +platform PM Header // // Copyright 2018 NXP // // Author: Ran Wang
> >>> +<ran.wang_1@nxp.com>,
> >>> +
> >>> +#ifndef __FSL_PLAT_PM_H
> >>> +#define __FSL_PLAT_PM_H
> >>> +
> >>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> >>> +		void *handle_priv);
> >>> +
> >>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv);
> >>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> >>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> >>> +fsl_platform_wakeup_enable(struct device *dev); int
> >>> +fsl_platform_wakeup_disable(struct device *dev);
> >>> +
> >>> +#endif	// __FSL_PLAT_PM_H
> >


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-10  3:27         ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:27 UTC (permalink / raw)
  To: Wang, Dongsheng
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland, linux-pm

Hi Dongsheng,

On 2018/9/7 18:16, Dongsheng Wang wrote:
> 
> On 2018/9/7 16:49, Ran Wang wrote:
> > Hi Dongsheng
> >
> >> On 2018/9/5 11:05, Dongsheng Wang wrote:
> >>
> >> Please change your comments style.
> >>
> >> On 2018/8/31 11:57, Ran Wang wrote:
> >>> This driver is to provide a independent framework for PM service
> >>> provider and consumer to configure system level wake up feature. For
> >>> example, RCPM driver could register a callback function on this
> >>> platform first, and Flex timer driver who want to enable timer wake
> >>> up feature, will call generic API provided by this platform driver,
> >>> and then it will trigger RCPM driver to do it. The benefit is to
> >>> isolate the user and service, such as flex timer driver will not
> >>> have to know the implement details of wakeup function it require.
> >>> Besides, it is also easy for service side to upgrade its logic when
> >>> design is changed and remain user side unchanged.
> >>>
> >>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> >>> ---
> >>>  drivers/soc/fsl/Kconfig   |   14 +++++
> >>>  drivers/soc/fsl/Makefile  |    1 +
> >>>  drivers/soc/fsl/plat_pm.c |  144
> >> +++++++++++++++++++++++++++++++++++++++++++++
> >>>  include/soc/fsl/plat_pm.h |   22 +++++++
> >>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> >>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> >>> include/soc/fsl/plat_pm.h
> >>>
> >>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> >>> 7a9fb9b..6517412 100644
> >>> --- a/drivers/soc/fsl/Kconfig
> >>> +++ b/drivers/soc/fsl/Kconfig
> >>> @@ -16,3 +16,17 @@ config FSL_GUTS
> >>>  	  Initially only reading SVR and registering soc device are supported.
> >>>  	  Other guts accesses, such as reading RCW, should eventually be
> >> moved
> >>>  	  into this driver as well.
> >>> +
> >>> +config FSL_PLAT_PM
> >>> +	bool "Freescale platform PM framework"
> >>> +	help
> >>> +	  This driver is to provide a independent framework for PM service
> >>> +	  provider and consumer to configure system level wake up feature.
> >> For
> >>> +	  example, RCPM driver could register a callback function on this
> >>> +	  platform first, and Flex timer driver who want to enable timer wake
> >>> +	  up feature, will call generic API provided by this platform driver,
> >>> +	  and then it will trigger RCPM driver to do it. The benefit is to
> >>> +	  isolate the user and service, such as  flex timer driver will not
> >>> +	  have to know the implement details of wakeup function it require.
> >>> +	  Besides, it is also easy for service side to upgrade its logic when
> >>> +	  design changed and remain user side unchanged.
> >>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> >>> index
> >>> 44b3beb..8f9db23 100644
> >>> --- a/drivers/soc/fsl/Makefile
> >>> +++ b/drivers/soc/fsl/Makefile
> >>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
> >>>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >>>  obj-$(CONFIG_CPM)			+= qe/
> >>>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> >>> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> >>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> >>> new file mode 100644 index 0000000..19ea14e
> >>> --- /dev/null
> >>> +++ b/drivers/soc/fsl/plat_pm.c
> >>> @@ -0,0 +1,144 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> >>> +platform PM framework // // Copyright 2018 NXP // // Author: Ran
> >>> +Wang <ran.wang_1@nxp.com>,
> >>> +
> >>> +#include <linux/kernel.h>
> >>> +#include <linux/device.h>
> >>> +#include <linux/list.h>
> >>> +#include <linux/slab.h>
> >>> +#include <linux/err.h>
> >>> +#include <soc/fsl/plat_pm.h>
> >>> +
> >>> +
> >>> +struct plat_pm_t {
> >>> +	struct list_head node;
> >>> +	fsl_plat_pm_handle handle;
> >>> +	void *handle_priv;
> >>> +	spinlock_t	lock;
> >>> +};
> >>> +
> >>> +static struct plat_pm_t plat_pm;
> >>> +
> >>> +// register_fsl_platform_wakeup_source - Register callback function
> >>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
> >>> +@handle_priv: Handler specific data struct // // Return 0 on
> >>> +success other negative errno int
> >>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv)
> >>> +{
> >>> +	struct plat_pm_t *p;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	if (!handle) {
> >>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> >>> +		return -EINVAL;
> >>> +	}
> >>> +
> >>> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> >>> +	if (!p)
> >>> +		return -ENOMEM;
> >>> +
> >>> +	p->handle = handle;
> >>> +	p->handle_priv = handle_priv;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_add_tail(&p->node, &plat_pm.node);
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> >>> +
> >>> +// Deregister_fsl_platform_wakeup_source - deregister callback
> >>> +function // @handle_priv: Handler specific data struct // // Return
> >>> +0 on success other negative errno int
> >>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> >>> +	struct plat_pm_t *p, *tmp;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> >>> +		if (p->handle_priv == handle_priv) {
> >>> +			list_del(&p->node);
> >>> +			kfree(p);
> >>> +		}
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> >>> +
> >>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
> >>> +handlers // @dev: pointer to user's device struct // @flag: to tell
> >>> +enable or disable wakeup source // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
> >>> +bool flag) {
> >>> +	struct plat_pm_t *p;
> >>> +	int ret;
> >>> +	bool success_handled;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	success_handled = false;
> >>> +
> >>> +	// Will consider success if at least one callback return 0.
> >>> +	// Also, rest handles still get oppertunity to be executed
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry(p, &plat_pm.node, node) {
> >>> +		if (p->handle) {
> >>> +			ret = p->handle(dev, flag, p->handle_priv);
> >>> +			if (!ret)
> >>> +				success_handled = true;
> >> Miss a break?
> > Actually my idea is to allow more than one registered handler to
> > handle this request, so I define a flag rather than return to
> > indicated if there is at least one handler successfully do it. This design
> might give more flexibility to framework when running.
> There is only one flag(success_handled) here, how did know which handler
> failed?
> 
> BTW, I don't think we need this flag. We can only use the return value.

Well, the plat_pm driver will not handle most errors returned by registered
handlers, except -NODEV. For -NODEV, plat_pm driver consider that handler
cannot support this request and will go to call next one. 

Besides, actually it doesn't restrict that request can be served by only one 
handler. So I add that flag to cover the case of more than one handler can 
successfully support and others might return -NODEV.

Regards,
Ran

> Cheers,
> Dongsheng
> 
> >>> +			else if (ret != -ENODEV) {
> >>> +				pr_err("FSL plat_pm: Failed to config wakeup
> >> source:%d\n", ret);
> >> Please unlock before return.
> > Yes, will fix it in next version, thanks for pointing out!
> >
> >>> +				return ret;
> >>> +			}
> >>> +		} else
> >>> +			pr_warn("FSL plat_pm: Invalid handler detected,
> >> skip\n");
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	if (success_handled == false) {
> >>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> >> wakeup source config\n");
> >>> +		return -ENODEV;
> >>> +	}
> >> Add this into the loop.
> > My design is that if the 1st handler return -ENODEV to indicated this
> > device it doesn't support, then the framework will continue try 2nd
> handler...
> >
> > So I think it is needed to place this checking out of loop, what do you say?
> >
> > Regards,
> > Ran
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_enable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, true); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> >>> +
> >>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, false); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> >>> +
> >>> +static int __init fsl_plat_pm_init(void) {
> >>> +	spin_lock_init(&plat_pm.lock);
> >>> +	INIT_LIST_HEAD(&plat_pm.node);
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +core_initcall(fsl_plat_pm_init);
> >>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> >>> new file mode 100644 index 0000000..bbe151e
> >>> --- /dev/null
> >>> +++ b/include/soc/fsl/plat_pm.h
> >>> @@ -0,0 +1,22 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.h - Freescale
> >>> +platform PM Header // // Copyright 2018 NXP // // Author: Ran Wang
> >>> +<ran.wang_1@nxp.com>,
> >>> +
> >>> +#ifndef __FSL_PLAT_PM_H
> >>> +#define __FSL_PLAT_PM_H
> >>> +
> >>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> >>> +		void *handle_priv);
> >>> +
> >>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv);
> >>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> >>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> >>> +fsl_platform_wakeup_enable(struct device *dev); int
> >>> +fsl_platform_wakeup_disable(struct device *dev);
> >>> +
> >>> +#endif	// __FSL_PLAT_PM_H
> >

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-10  3:27         ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:27 UTC (permalink / raw)
  To: Wang, Dongsheng
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, Leo Li,
	Rob Herring, Mark Rutland, linux-pm

Hi Dongsheng,

On 2018/9/7 18:16, Dongsheng Wang wrote:
>=20
> On 2018/9/7 16:49, Ran Wang wrote:
> > Hi Dongsheng
> >
> >> On 2018/9/5 11:05, Dongsheng Wang wrote:
> >>
> >> Please change your comments style.
> >>
> >> On 2018/8/31 11:57, Ran Wang wrote:
> >>> This driver is to provide a independent framework for PM service
> >>> provider and consumer to configure system level wake up feature. For
> >>> example, RCPM driver could register a callback function on this
> >>> platform first, and Flex timer driver who want to enable timer wake
> >>> up feature, will call generic API provided by this platform driver,
> >>> and then it will trigger RCPM driver to do it. The benefit is to
> >>> isolate the user and service, such as flex timer driver will not
> >>> have to know the implement details of wakeup function it require.
> >>> Besides, it is also easy for service side to upgrade its logic when
> >>> design is changed and remain user side unchanged.
> >>>
> >>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> >>> ---
> >>>  drivers/soc/fsl/Kconfig   |   14 +++++
> >>>  drivers/soc/fsl/Makefile  |    1 +
> >>>  drivers/soc/fsl/plat_pm.c |  144
> >> +++++++++++++++++++++++++++++++++++++++++++++
> >>>  include/soc/fsl/plat_pm.h |   22 +++++++
> >>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> >>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> >>> include/soc/fsl/plat_pm.h
> >>>
> >>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> >>> 7a9fb9b..6517412 100644
> >>> --- a/drivers/soc/fsl/Kconfig
> >>> +++ b/drivers/soc/fsl/Kconfig
> >>> @@ -16,3 +16,17 @@ config FSL_GUTS
> >>>  	  Initially only reading SVR and registering soc device are support=
ed.
> >>>  	  Other guts accesses, such as reading RCW, should eventually be
> >> moved
> >>>  	  into this driver as well.
> >>> +
> >>> +config FSL_PLAT_PM
> >>> +	bool "Freescale platform PM framework"
> >>> +	help
> >>> +	  This driver is to provide a independent framework for PM service
> >>> +	  provider and consumer to configure system level wake up feature.
> >> For
> >>> +	  example, RCPM driver could register a callback function on this
> >>> +	  platform first, and Flex timer driver who want to enable timer wa=
ke
> >>> +	  up feature, will call generic API provided by this platform drive=
r,
> >>> +	  and then it will trigger RCPM driver to do it. The benefit is to
> >>> +	  isolate the user and service, such as  flex timer driver will not
> >>> +	  have to know the implement details of wakeup function it require.
> >>> +	  Besides, it is also easy for service side to upgrade its logic wh=
en
> >>> +	  design changed and remain user side unchanged.
> >>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> >>> index
> >>> 44b3beb..8f9db23 100644
> >>> --- a/drivers/soc/fsl/Makefile
> >>> +++ b/drivers/soc/fsl/Makefile
> >>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 +=3D qbman/
> >>>  obj-$(CONFIG_QUICC_ENGINE)		+=3D qe/
> >>>  obj-$(CONFIG_CPM)			+=3D qe/
> >>>  obj-$(CONFIG_FSL_GUTS)			+=3D guts.o
> >>> +obj-$(CONFIG_FSL_PLAT_PM)	+=3D plat_pm.o
> >>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> >>> new file mode 100644 index 0000000..19ea14e
> >>> --- /dev/null
> >>> +++ b/drivers/soc/fsl/plat_pm.c
> >>> @@ -0,0 +1,144 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> >>> +platform PM framework // // Copyright 2018 NXP // // Author: Ran
> >>> +Wang <ran.wang_1@nxp.com>,
> >>> +
> >>> +#include <linux/kernel.h>
> >>> +#include <linux/device.h>
> >>> +#include <linux/list.h>
> >>> +#include <linux/slab.h>
> >>> +#include <linux/err.h>
> >>> +#include <soc/fsl/plat_pm.h>
> >>> +
> >>> +
> >>> +struct plat_pm_t {
> >>> +	struct list_head node;
> >>> +	fsl_plat_pm_handle handle;
> >>> +	void *handle_priv;
> >>> +	spinlock_t	lock;
> >>> +};
> >>> +
> >>> +static struct plat_pm_t plat_pm;
> >>> +
> >>> +// register_fsl_platform_wakeup_source - Register callback function
> >>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
> >>> +@handle_priv: Handler specific data struct // // Return 0 on
> >>> +success other negative errno int
> >>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv)
> >>> +{
> >>> +	struct plat_pm_t *p;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	if (!handle) {
> >>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> >>> +		return -EINVAL;
> >>> +	}
> >>> +
> >>> +	p =3D kmalloc(sizeof(*p), GFP_KERNEL);
> >>> +	if (!p)
> >>> +		return -ENOMEM;
> >>> +
> >>> +	p->handle =3D handle;
> >>> +	p->handle_priv =3D handle_priv;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_add_tail(&p->node, &plat_pm.node);
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> >>> +
> >>> +// Deregister_fsl_platform_wakeup_source - deregister callback
> >>> +function // @handle_priv: Handler specific data struct // // Return
> >>> +0 on success other negative errno int
> >>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> >>> +	struct plat_pm_t *p, *tmp;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> >>> +		if (p->handle_priv =3D=3D handle_priv) {
> >>> +			list_del(&p->node);
> >>> +			kfree(p);
> >>> +		}
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> >>> +
> >>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
> >>> +handlers // @dev: pointer to user's device struct // @flag: to tell
> >>> +enable or disable wakeup source // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
> >>> +bool flag) {
> >>> +	struct plat_pm_t *p;
> >>> +	int ret;
> >>> +	bool success_handled;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	success_handled =3D false;
> >>> +
> >>> +	// Will consider success if at least one callback return 0.
> >>> +	// Also, rest handles still get oppertunity to be executed
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry(p, &plat_pm.node, node) {
> >>> +		if (p->handle) {
> >>> +			ret =3D p->handle(dev, flag, p->handle_priv);
> >>> +			if (!ret)
> >>> +				success_handled =3D true;
> >> Miss a break?
> > Actually my idea is to allow more than one registered handler to
> > handle this request, so I define a flag rather than return to
> > indicated if there is at least one handler successfully do it. This des=
ign
> might give more flexibility to framework when running.
> There is only one flag(success_handled) here, how did know which handler
> failed?
>=20
> BTW, I don't think we need this flag. We can only use the return value.

Well, the plat_pm driver will not handle most errors returned by registered
handlers, except -NODEV. For -NODEV, plat_pm driver consider that handler
cannot support this request and will go to call next one.=20

Besides, actually it doesn't restrict that request can be served by only on=
e=20
handler. So I add that flag to cover the case of more than one handler can=
=20
successfully support and others might return -NODEV.

Regards,
Ran

> Cheers,
> Dongsheng
>=20
> >>> +			else if (ret !=3D -ENODEV) {
> >>> +				pr_err("FSL plat_pm: Failed to config wakeup
> >> source:%d\n", ret);
> >> Please unlock before return.
> > Yes, will fix it in next version, thanks for pointing out!
> >
> >>> +				return ret;
> >>> +			}
> >>> +		} else
> >>> +			pr_warn("FSL plat_pm: Invalid handler detected,
> >> skip\n");
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	if (success_handled =3D=3D false) {
> >>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> >> wakeup source config\n");
> >>> +		return -ENODEV;
> >>> +	}
> >> Add this into the loop.
> > My design is that if the 1st handler return -ENODEV to indicated this
> > device it doesn't support, then the framework will continue try 2nd
> handler...
> >
> > So I think it is needed to place this checking out of loop, what do you=
 say?
> >
> > Regards,
> > Ran
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_enable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, true); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> >>> +
> >>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, false); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> >>> +
> >>> +static int __init fsl_plat_pm_init(void) {
> >>> +	spin_lock_init(&plat_pm.lock);
> >>> +	INIT_LIST_HEAD(&plat_pm.node);
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +core_initcall(fsl_plat_pm_init);
> >>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> >>> new file mode 100644 index 0000000..bbe151e
> >>> --- /dev/null
> >>> +++ b/include/soc/fsl/plat_pm.h
> >>> @@ -0,0 +1,22 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.h - Freescale
> >>> +platform PM Header // // Copyright 2018 NXP // // Author: Ran Wang
> >>> +<ran.wang_1@nxp.com>,
> >>> +
> >>> +#ifndef __FSL_PLAT_PM_H
> >>> +#define __FSL_PLAT_PM_H
> >>> +
> >>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> >>> +		void *handle_priv);
> >>> +
> >>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv);
> >>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> >>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> >>> +fsl_platform_wakeup_enable(struct device *dev); int
> >>> +fsl_platform_wakeup_disable(struct device *dev);
> >>> +
> >>> +#endif	// __FSL_PLAT_PM_H
> >

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-10  3:27         ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Dongsheng,

On 2018/9/7 18:16, Dongsheng Wang wrote:
> 
> On 2018/9/7 16:49, Ran Wang wrote:
> > Hi Dongsheng
> >
> >> On 2018/9/5 11:05, Dongsheng Wang wrote:
> >>
> >> Please change your comments style.
> >>
> >> On 2018/8/31 11:57, Ran Wang wrote:
> >>> This driver is to provide a independent framework for PM service
> >>> provider and consumer to configure system level wake up feature. For
> >>> example, RCPM driver could register a callback function on this
> >>> platform first, and Flex timer driver who want to enable timer wake
> >>> up feature, will call generic API provided by this platform driver,
> >>> and then it will trigger RCPM driver to do it. The benefit is to
> >>> isolate the user and service, such as flex timer driver will not
> >>> have to know the implement details of wakeup function it require.
> >>> Besides, it is also easy for service side to upgrade its logic when
> >>> design is changed and remain user side unchanged.
> >>>
> >>> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> >>> ---
> >>>  drivers/soc/fsl/Kconfig   |   14 +++++
> >>>  drivers/soc/fsl/Makefile  |    1 +
> >>>  drivers/soc/fsl/plat_pm.c |  144
> >> +++++++++++++++++++++++++++++++++++++++++++++
> >>>  include/soc/fsl/plat_pm.h |   22 +++++++
> >>>  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> >>> 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> >>> include/soc/fsl/plat_pm.h
> >>>
> >>> diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> >>> 7a9fb9b..6517412 100644
> >>> --- a/drivers/soc/fsl/Kconfig
> >>> +++ b/drivers/soc/fsl/Kconfig
> >>> @@ -16,3 +16,17 @@ config FSL_GUTS
> >>>  	  Initially only reading SVR and registering soc device are supported.
> >>>  	  Other guts accesses, such as reading RCW, should eventually be
> >> moved
> >>>  	  into this driver as well.
> >>> +
> >>> +config FSL_PLAT_PM
> >>> +	bool "Freescale platform PM framework"
> >>> +	help
> >>> +	  This driver is to provide a independent framework for PM service
> >>> +	  provider and consumer to configure system level wake up feature.
> >> For
> >>> +	  example, RCPM driver could register a callback function on this
> >>> +	  platform first, and Flex timer driver who want to enable timer wake
> >>> +	  up feature, will call generic API provided by this platform driver,
> >>> +	  and then it will trigger RCPM driver to do it. The benefit is to
> >>> +	  isolate the user and service, such as  flex timer driver will not
> >>> +	  have to know the implement details of wakeup function it require.
> >>> +	  Besides, it is also easy for service side to upgrade its logic when
> >>> +	  design changed and remain user side unchanged.
> >>> diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> >>> index
> >>> 44b3beb..8f9db23 100644
> >>> --- a/drivers/soc/fsl/Makefile
> >>> +++ b/drivers/soc/fsl/Makefile
> >>> @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
> >>>  obj-$(CONFIG_QUICC_ENGINE)		+= qe/
> >>>  obj-$(CONFIG_CPM)			+= qe/
> >>>  obj-$(CONFIG_FSL_GUTS)			+= guts.o
> >>> +obj-$(CONFIG_FSL_PLAT_PM)	+= plat_pm.o
> >>> diff --git a/drivers/soc/fsl/plat_pm.c b/drivers/soc/fsl/plat_pm.c
> >>> new file mode 100644 index 0000000..19ea14e
> >>> --- /dev/null
> >>> +++ b/drivers/soc/fsl/plat_pm.c
> >>> @@ -0,0 +1,144 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> >>> +platform PM framework // // Copyright 2018 NXP // // Author: Ran
> >>> +Wang <ran.wang_1@nxp.com>,
> >>> +
> >>> +#include <linux/kernel.h>
> >>> +#include <linux/device.h>
> >>> +#include <linux/list.h>
> >>> +#include <linux/slab.h>
> >>> +#include <linux/err.h>
> >>> +#include <soc/fsl/plat_pm.h>
> >>> +
> >>> +
> >>> +struct plat_pm_t {
> >>> +	struct list_head node;
> >>> +	fsl_plat_pm_handle handle;
> >>> +	void *handle_priv;
> >>> +	spinlock_t	lock;
> >>> +};
> >>> +
> >>> +static struct plat_pm_t plat_pm;
> >>> +
> >>> +// register_fsl_platform_wakeup_source - Register callback function
> >>> +to plat_pm // @handle: Pointer to handle PM feature requirement //
> >>> + at handle_priv: Handler specific data struct // // Return 0 on
> >>> +success other negative errno int
> >>> +register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv)
> >>> +{
> >>> +	struct plat_pm_t *p;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	if (!handle) {
> >>> +		pr_err("FSL plat_pm: Handler invalid, reject\n");
> >>> +		return -EINVAL;
> >>> +	}
> >>> +
> >>> +	p = kmalloc(sizeof(*p), GFP_KERNEL);
> >>> +	if (!p)
> >>> +		return -ENOMEM;
> >>> +
> >>> +	p->handle = handle;
> >>> +	p->handle_priv = handle_priv;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_add_tail(&p->node, &plat_pm.node);
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(register_fsl_platform_wakeup_source);
> >>> +
> >>> +// Deregister_fsl_platform_wakeup_source - deregister callback
> >>> +function // @handle_priv: Handler specific data struct // // Return
> >>> +0 on success other negative errno int
> >>> +deregister_fsl_platform_wakeup_source(void *handle_priv) {
> >>> +	struct plat_pm_t *p, *tmp;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry_safe(p, tmp, &plat_pm.node, node) {
> >>> +		if (p->handle_priv == handle_priv) {
> >>> +			list_del(&p->node);
> >>> +			kfree(p);
> >>> +		}
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +	return 0;
> >>> +}
> >>> +EXPORT_SYMBOL_GPL(deregister_fsl_platform_wakeup_source);
> >>> +
> >>> +// fsl_platform_wakeup_config - Configure wakeup source by calling
> >>> +handlers // @dev: pointer to user's device struct // @flag: to tell
> >>> +enable or disable wakeup source // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_config(struct device *dev,
> >>> +bool flag) {
> >>> +	struct plat_pm_t *p;
> >>> +	int ret;
> >>> +	bool success_handled;
> >>> +	unsigned long	flags;
> >>> +
> >>> +	success_handled = false;
> >>> +
> >>> +	// Will consider success if at least one callback return 0.
> >>> +	// Also, rest handles still get oppertunity to be executed
> >>> +	spin_lock_irqsave(&plat_pm.lock, flags);
> >>> +	list_for_each_entry(p, &plat_pm.node, node) {
> >>> +		if (p->handle) {
> >>> +			ret = p->handle(dev, flag, p->handle_priv);
> >>> +			if (!ret)
> >>> +				success_handled = true;
> >> Miss a break?
> > Actually my idea is to allow more than one registered handler to
> > handle this request, so I define a flag rather than return to
> > indicated if there is at least one handler successfully do it. This design
> might give more flexibility to framework when running.
> There is only one flag(success_handled) here, how did know which handler
> failed?
> 
> BTW, I don't think we need this flag. We can only use the return value.

Well, the plat_pm driver will not handle most errors returned by registered
handlers, except -NODEV. For -NODEV, plat_pm driver consider that handler
cannot support this request and will go to call next one. 

Besides, actually it doesn't restrict that request can be served by only one 
handler. So I add that flag to cover the case of more than one handler can 
successfully support and others might return -NODEV.

Regards,
Ran

> Cheers,
> Dongsheng
> 
> >>> +			else if (ret != -ENODEV) {
> >>> +				pr_err("FSL plat_pm: Failed to config wakeup
> >> source:%d\n", ret);
> >> Please unlock before return.
> > Yes, will fix it in next version, thanks for pointing out!
> >
> >>> +				return ret;
> >>> +			}
> >>> +		} else
> >>> +			pr_warn("FSL plat_pm: Invalid handler detected,
> >> skip\n");
> >>> +	}
> >>> +	spin_unlock_irqrestore(&plat_pm.lock, flags);
> >>> +
> >>> +	if (success_handled == false) {
> >>> +		pr_err("FSL plat_pm: Cannot find the matchhed handler for
> >> wakeup source config\n");
> >>> +		return -ENODEV;
> >>> +	}
> >> Add this into the loop.
> > My design is that if the 1st handler return -ENODEV to indicated this
> > device it doesn't support, then the framework will continue try 2nd
> handler...
> >
> > So I think it is needed to place this checking out of loop, what do you say?
> >
> > Regards,
> > Ran
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +// fsl_platform_wakeup_enable - Enable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_enable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, true); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_enable);
> >>> +
> >>> +// fsl_platform_wakeup_disable - Disable wakeup source // @dev:
> >>> +pointer to user's device struct // // Return 0 on success other
> >>> +negative errno int fsl_platform_wakeup_disable(struct device *dev) {
> >>> +	return fsl_platform_wakeup_config(dev, false); }
> >>> +EXPORT_SYMBOL_GPL(fsl_platform_wakeup_disable);
> >>> +
> >>> +static int __init fsl_plat_pm_init(void) {
> >>> +	spin_lock_init(&plat_pm.lock);
> >>> +	INIT_LIST_HEAD(&plat_pm.node);
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +core_initcall(fsl_plat_pm_init);
> >>> diff --git a/include/soc/fsl/plat_pm.h b/include/soc/fsl/plat_pm.h
> >>> new file mode 100644 index 0000000..bbe151e
> >>> --- /dev/null
> >>> +++ b/include/soc/fsl/plat_pm.h
> >>> @@ -0,0 +1,22 @@
> >>> +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.h - Freescale
> >>> +platform PM Header // // Copyright 2018 NXP // // Author: Ran Wang
> >>> +<ran.wang_1@nxp.com>,
> >>> +
> >>> +#ifndef __FSL_PLAT_PM_H
> >>> +#define __FSL_PLAT_PM_H
> >>> +
> >>> +typedef int (*fsl_plat_pm_handle)(struct device *dev, bool flag,
> >>> +		void *handle_priv);
> >>> +
> >>> +int register_fsl_platform_wakeup_source(fsl_plat_pm_handle handle,
> >>> +		void *handle_priv);
> >>> +int deregister_fsl_platform_wakeup_source(void *handle_priv); int
> >>> +fsl_platform_wakeup_config(struct device *dev, bool flag); int
> >>> +fsl_platform_wakeup_enable(struct device *dev); int
> >>> +fsl_platform_wakeup_disable(struct device *dev);
> >>> +
> >>> +#endif	// __FSL_PLAT_PM_H
> >

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-09-07 18:56           ` Li Yang
  (?)
  (?)
@ 2018-09-10  3:31             ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:31 UTC (permalink / raw)
  To: Leo Li
  Cc: Mark Rutland, dongsheng.wang,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, lkml,
	Rob Herring, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Hi Leo,

On 2018/9/7 4:51, Yang Li wrote:
> 
> On Fri, Sep 7, 2018 at 4:51 AM Ran Wang <ran.wang_1@nxp.com> wrote:
> >
> > Hi Leo,
> >
> > On September 05, 2018 at 11:22 Yang Li wrote:
> > > -----Original Message-----
> > > From: Li Yang <leoyang.li@nxp.com>
> > > Sent: Wednesday, September 05, 2018 11:22
> > > To: dongsheng.wang@hxt-semitech.com
> > > Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring
> <robh+dt@kernel.org>;
> > > Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> > > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>;
> > > linuxppc- dev <linuxppc-dev@lists.ozlabs.org>; lkml
> > > <linux-kernel@vger.kernel.org>; moderated list:ARM/FREESCALE IMX /
> > > MXC ARM ARCHITECTURE <linux-arm- kernel@lists.infradead.org>
> > > Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> > >
> > > On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
> <dongsheng.wang@hxt-
> > > semitech.com> wrote:
> > > >
> > > > Please change your comments style.
> > >
> > > Although this doesn't get into the Linux kernel coding style
> > > documentation yet, Linus seems changed his mind to prefer // than /*
> > > */ comment style now.
> > > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fl
> > >
> kml .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.w
> ang_
> > >
> 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> > >
> 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> > >
> WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> > > So the
> > > // style should be acceptable for now.
> > >
> > > >
> > > > On 2018/8/31 11:56, Ran Wang wrote:
> > > > > 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 FSL platform PM driver framework which
> > > > > help to isolate user and PM service provider (such as RCPM driver).
> > > > >
> > > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > > > ---
> > > > >  drivers/soc/fsl/Kconfig   |    6 ++
> > > > >  drivers/soc/fsl/Makefile  |    1 +
> > > > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > > > 100644 drivers/soc/fsl/ls-rcpm.c
> > > > >
> > > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > > > > index 6517412..882330d 100644
> > > > > --- a/drivers/soc/fsl/Kconfig
> > > > > +++ b/drivers/soc/fsl/Kconfig
> > > > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > > > >         have to know the implement details of wakeup function it
> require.
> > > > >         Besides, it is also easy for service side to upgrade its logic when
> > > > >         design changed and remain user side unchanged.
> > > > > +
> > > > > +config LS_RCPM
> > > > > +     bool "Freescale RCPM support"
> > > > > +     depends on (FSL_PLAT_PM)
> > > > > +     help
> > > > > +       This feature is to enable specified wakeup source for system
> sleep.
> > > > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > > > index 8f9db23..43ff71a 100644
> > > > > --- a/drivers/soc/fsl/Makefile
> > > > > +++ b/drivers/soc/fsl/Makefile
> > > > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > > > >  obj-$(CONFIG_CPM)                    += qe/
> > > > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > > > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> > >
> > > Probably use "_" instead of "-" for alignment.
> >
> > OK, will update in next version
> >
> > > > > diff --git a/drivers/soc/fsl/ls-rcpm.c
> > > > > b/drivers/soc/fsl/ls-rcpm.c new file mode 100644 index
> > > > > 0000000..b0feb88
> > > > > --- /dev/null
> > > > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > > > @@ -0,0 +1,153 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > > > +Layerscape RCPM driver
> > >
> > > The file name here is not the same as the real file name.
> >
> > Got it, will correct it.
> >
> > > > > +//
> > > > > +// Copyright 2018 NXP
> > > > > +//
> > > > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> > >
> > > Where do you need the comma in the end?
> >
> > My bad, will remove comma in next version.
> >
> > > > > +
> > > > > +#include <linux/init.h>
> > > > > +#include <linux/module.h>
> > > > > +#include <linux/platform_device.h> #include
> > > > > +<linux/of_address.h> #include <linux/slab.h> #include
> > > > > +<soc/fsl/plat_pm.h>
> > > > > +
> > > > > +#define MAX_COMPATIBLE_NUM   10
> > > > > +
> > > > > +struct rcpm_t {
> > > > > +     struct device *dev;
> > > > > +     void __iomem *ippdexpcr_addr;
> > > > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > > > +};
> > > > > +
> > > > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > > > +request // @user_dev: pointer to user's device struct // @flag:
> > > > > +to
> > > > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > > > +pointer to struct rcpm_t instance // // Return 0 on success
> > > > > +other negative errno
> > >
> > > Although Linus preferred this // comment style.  I'm not sure if
> > > this will be handled correctly by the kernel-doc compiler.
> > >
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fw
> > > w
> > > w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> > >
> doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> > >
> 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> > > %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHC
> bO9
> > > %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0
> >
> > So, do you think I need to change all comment style back to '/* ... */' ?
> > Actually I feel a little bit confused here.
> 
> I think Linus's comment about // comment style applies to normal code
> comment.  But kernel-doc comment is a special kind of code comment that
> needs to meet certain requirements.  People can use the scripts/kernel-doc
> tool to generate readable API documents from the source code.  It looks like
> you wanted to make the function description aligned with the kernel-doc
> format, but kernel-doc specifically requires to use the /* */ style(at least for
> now).

OK, will change style back to /* */.

Regards,
Ran

> Regards,
> Leo

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-10  3:31             ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:31 UTC (permalink / raw)
  To: Leo Li
  Cc: Mark Rutland, dongsheng.wang,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, lkml,
	Rob Herring, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Hi Leo,

On 2018/9/7 4:51, Yang Li wrote:
> 
> On Fri, Sep 7, 2018 at 4:51 AM Ran Wang <ran.wang_1@nxp.com> wrote:
> >
> > Hi Leo,
> >
> > On September 05, 2018 at 11:22 Yang Li wrote:
> > > -----Original Message-----
> > > From: Li Yang <leoyang.li@nxp.com>
> > > Sent: Wednesday, September 05, 2018 11:22
> > > To: dongsheng.wang@hxt-semitech.com
> > > Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring
> <robh+dt@kernel.org>;
> > > Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> > > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>;
> > > linuxppc- dev <linuxppc-dev@lists.ozlabs.org>; lkml
> > > <linux-kernel@vger.kernel.org>; moderated list:ARM/FREESCALE IMX /
> > > MXC ARM ARCHITECTURE <linux-arm- kernel@lists.infradead.org>
> > > Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> > >
> > > On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
> <dongsheng.wang@hxt-
> > > semitech.com> wrote:
> > > >
> > > > Please change your comments style.
> > >
> > > Although this doesn't get into the Linux kernel coding style
> > > documentation yet, Linus seems changed his mind to prefer // than /*
> > > */ comment style now.
> > > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fl
> > >
> kml .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.w
> ang_
> > >
> 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> > >
> 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> > >
> WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> > > So the
> > > // style should be acceptable for now.
> > >
> > > >
> > > > On 2018/8/31 11:56, Ran Wang wrote:
> > > > > 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 FSL platform PM driver framework which
> > > > > help to isolate user and PM service provider (such as RCPM driver).
> > > > >
> > > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > > > ---
> > > > >  drivers/soc/fsl/Kconfig   |    6 ++
> > > > >  drivers/soc/fsl/Makefile  |    1 +
> > > > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > > > 100644 drivers/soc/fsl/ls-rcpm.c
> > > > >
> > > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > > > > index 6517412..882330d 100644
> > > > > --- a/drivers/soc/fsl/Kconfig
> > > > > +++ b/drivers/soc/fsl/Kconfig
> > > > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > > > >         have to know the implement details of wakeup function it
> require.
> > > > >         Besides, it is also easy for service side to upgrade its logic when
> > > > >         design changed and remain user side unchanged.
> > > > > +
> > > > > +config LS_RCPM
> > > > > +     bool "Freescale RCPM support"
> > > > > +     depends on (FSL_PLAT_PM)
> > > > > +     help
> > > > > +       This feature is to enable specified wakeup source for system
> sleep.
> > > > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > > > index 8f9db23..43ff71a 100644
> > > > > --- a/drivers/soc/fsl/Makefile
> > > > > +++ b/drivers/soc/fsl/Makefile
> > > > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > > > >  obj-$(CONFIG_CPM)                    += qe/
> > > > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > > > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> > >
> > > Probably use "_" instead of "-" for alignment.
> >
> > OK, will update in next version
> >
> > > > > diff --git a/drivers/soc/fsl/ls-rcpm.c
> > > > > b/drivers/soc/fsl/ls-rcpm.c new file mode 100644 index
> > > > > 0000000..b0feb88
> > > > > --- /dev/null
> > > > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > > > @@ -0,0 +1,153 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > > > +Layerscape RCPM driver
> > >
> > > The file name here is not the same as the real file name.
> >
> > Got it, will correct it.
> >
> > > > > +//
> > > > > +// Copyright 2018 NXP
> > > > > +//
> > > > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> > >
> > > Where do you need the comma in the end?
> >
> > My bad, will remove comma in next version.
> >
> > > > > +
> > > > > +#include <linux/init.h>
> > > > > +#include <linux/module.h>
> > > > > +#include <linux/platform_device.h> #include
> > > > > +<linux/of_address.h> #include <linux/slab.h> #include
> > > > > +<soc/fsl/plat_pm.h>
> > > > > +
> > > > > +#define MAX_COMPATIBLE_NUM   10
> > > > > +
> > > > > +struct rcpm_t {
> > > > > +     struct device *dev;
> > > > > +     void __iomem *ippdexpcr_addr;
> > > > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > > > +};
> > > > > +
> > > > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > > > +request // @user_dev: pointer to user's device struct // @flag:
> > > > > +to
> > > > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > > > +pointer to struct rcpm_t instance // // Return 0 on success
> > > > > +other negative errno
> > >
> > > Although Linus preferred this // comment style.  I'm not sure if
> > > this will be handled correctly by the kernel-doc compiler.
> > >
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fw
> > > w
> > > w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> > >
> doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> > >
> 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> > > %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHC
> bO9
> > > %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0
> >
> > So, do you think I need to change all comment style back to '/* ... */' ?
> > Actually I feel a little bit confused here.
> 
> I think Linus's comment about // comment style applies to normal code
> comment.  But kernel-doc comment is a special kind of code comment that
> needs to meet certain requirements.  People can use the scripts/kernel-doc
> tool to generate readable API documents from the source code.  It looks like
> you wanted to make the function description aligned with the kernel-doc
> format, but kernel-doc specifically requires to use the /* */ style(at least for
> now).

OK, will change style back to /* */.

Regards,
Ran

> Regards,
> Leo

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-10  3:31             ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:31 UTC (permalink / raw)
  To: Leo Li
  Cc: Mark Rutland, dongsheng.wang,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, lkml,
	Rob Herring, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

SGkgTGVvLA0KDQpPbiAyMDE4LzkvNyA0OjUxLCBZYW5nIExpIHdyb3RlOg0KPiANCj4gT24gRnJp
LCBTZXAgNywgMjAxOCBhdCA0OjUxIEFNIFJhbiBXYW5nIDxyYW4ud2FuZ18xQG54cC5jb20+IHdy
b3RlOg0KPiA+DQo+ID4gSGkgTGVvLA0KPiA+DQo+ID4gT24gU2VwdGVtYmVyIDA1LCAyMDE4IGF0
IDExOjIyIFlhbmcgTGkgd3JvdGU6DQo+ID4gPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0K
PiA+ID4gRnJvbTogTGkgWWFuZyA8bGVveWFuZy5saUBueHAuY29tPg0KPiA+ID4gU2VudDogV2Vk
bmVzZGF5LCBTZXB0ZW1iZXIgMDUsIDIwMTggMTE6MjINCj4gPiA+IFRvOiBkb25nc2hlbmcud2Fu
Z0BoeHQtc2VtaXRlY2guY29tDQo+ID4gPiBDYzogUmFuIFdhbmcgPHJhbi53YW5nXzFAbnhwLmNv
bT47IFJvYiBIZXJyaW5nDQo+IDxyb2JoK2R0QGtlcm5lbC5vcmc+Ow0KPiA+ID4gTWFyayBSdXRs
YW5kIDxtYXJrLnJ1dGxhbmRAYXJtLmNvbT47IG9wZW4gbGlzdDpPUEVOIEZJUk1XQVJFIEFORA0K
PiA+ID4gRkxBVFRFTkVEIERFVklDRSBUUkVFIEJJTkRJTkdTIDxkZXZpY2V0cmVlQHZnZXIua2Vy
bmVsLm9yZz47DQo+ID4gPiBsaW51eHBwYy0gZGV2IDxsaW51eHBwYy1kZXZAbGlzdHM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Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  3:31 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Leo,

On 2018/9/7 4:51, Yang Li wrote:
> 
> On Fri, Sep 7, 2018 at 4:51 AM Ran Wang <ran.wang_1@nxp.com> wrote:
> >
> > Hi Leo,
> >
> > On September 05, 2018 at 11:22 Yang Li wrote:
> > > -----Original Message-----
> > > From: Li Yang <leoyang.li@nxp.com>
> > > Sent: Wednesday, September 05, 2018 11:22
> > > To: dongsheng.wang at hxt-semitech.com
> > > Cc: Ran Wang <ran.wang_1@nxp.com>; Rob Herring
> <robh+dt@kernel.org>;
> > > Mark Rutland <mark.rutland@arm.com>; open list:OPEN FIRMWARE AND
> > > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>;
> > > linuxppc- dev <linuxppc-dev@lists.ozlabs.org>; lkml
> > > <linux-kernel@vger.kernel.org>; moderated list:ARM/FREESCALE IMX /
> > > MXC ARM ARCHITECTURE <linux-arm- kernel@lists.infradead.org>
> > > Subject: Re: [PATCH 3/3] soc: fsl: add RCPM driver
> > >
> > > On Tue, Sep 4, 2018 at 9:58 PM Wang, Dongsheng
> <dongsheng.wang@hxt-
> > > semitech.com> wrote:
> > > >
> > > > Please change your comments style.
> > >
> > > Although this doesn't get into the Linux kernel coding style
> > > documentation yet, Linus seems changed his mind to prefer // than /*
> > > */ comment style now.
> > > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fl
> > >
> kml .org%2Flkml%2F2017%2F11%2F25%2F133&amp;data=02%7C01%7Cran.w
> ang_
> > >
> 1%40nxp.com%7Cc0d88e6690384e02b95108d612dec235%7C686ea1d3bc2b4c
> > >
> 6fa92cd99c5c301635%7C0%7C0%7C636717145285126200&amp;sdata=JIoCZp
> > >
> WhRyW76EqgSflfTDA1f0gMQGKa%2FcbvSc5CO%2Fw%3D&amp;reserved=0
> > > So the
> > > // style should be acceptable for now.
> > >
> > > >
> > > > On 2018/8/31 11:56, Ran Wang wrote:
> > > > > 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 FSL platform PM driver framework which
> > > > > help to isolate user and PM service provider (such as RCPM driver).
> > > > >
> > > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > > > > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > > > > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > > > > ---
> > > > >  drivers/soc/fsl/Kconfig   |    6 ++
> > > > >  drivers/soc/fsl/Makefile  |    1 +
> > > > >  drivers/soc/fsl/ls-rcpm.c |  153
> > > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > > >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > > > > 100644 drivers/soc/fsl/ls-rcpm.c
> > > > >
> > > > > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
> > > > > index 6517412..882330d 100644
> > > > > --- a/drivers/soc/fsl/Kconfig
> > > > > +++ b/drivers/soc/fsl/Kconfig
> > > > > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> > > > >         have to know the implement details of wakeup function it
> require.
> > > > >         Besides, it is also easy for service side to upgrade its logic when
> > > > >         design changed and remain user side unchanged.
> > > > > +
> > > > > +config LS_RCPM
> > > > > +     bool "Freescale RCPM support"
> > > > > +     depends on (FSL_PLAT_PM)
> > > > > +     help
> > > > > +       This feature is to enable specified wakeup source for system
> sleep.
> > > > > diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
> > > > > index 8f9db23..43ff71a 100644
> > > > > --- a/drivers/soc/fsl/Makefile
> > > > > +++ b/drivers/soc/fsl/Makefile
> > > > > @@ -7,3 +7,4 @@ obj-$(CONFIG_QUICC_ENGINE)            += qe/
> > > > >  obj-$(CONFIG_CPM)                    += qe/
> > > > >  obj-$(CONFIG_FSL_GUTS)                       += guts.o
> > > > >  obj-$(CONFIG_FSL_PLAT_PM)    += plat_pm.o
> > > > > +obj-$(CONFIG_LS_RCPM)                += ls-rcpm.o
> > >
> > > Probably use "_" instead of "-" for alignment.
> >
> > OK, will update in next version
> >
> > > > > diff --git a/drivers/soc/fsl/ls-rcpm.c
> > > > > b/drivers/soc/fsl/ls-rcpm.c new file mode 100644 index
> > > > > 0000000..b0feb88
> > > > > --- /dev/null
> > > > > +++ b/drivers/soc/fsl/ls-rcpm.c
> > > > > @@ -0,0 +1,153 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0 // // plat_pm.c - Freescale
> > > > > +Layerscape RCPM driver
> > >
> > > The file name here is not the same as the real file name.
> >
> > Got it, will correct it.
> >
> > > > > +//
> > > > > +// Copyright 2018 NXP
> > > > > +//
> > > > > +// Author: Ran Wang <ran.wang_1@nxp.com>,
> > >
> > > Where do you need the comma in the end?
> >
> > My bad, will remove comma in next version.
> >
> > > > > +
> > > > > +#include <linux/init.h>
> > > > > +#include <linux/module.h>
> > > > > +#include <linux/platform_device.h> #include
> > > > > +<linux/of_address.h> #include <linux/slab.h> #include
> > > > > +<soc/fsl/plat_pm.h>
> > > > > +
> > > > > +#define MAX_COMPATIBLE_NUM   10
> > > > > +
> > > > > +struct rcpm_t {
> > > > > +     struct device *dev;
> > > > > +     void __iomem *ippdexpcr_addr;
> > > > > +     bool big_endian;        /* Big/Little endian of RCPM module */
> > > > > +};
> > > > > +
> > > > > +// rcpm_handle - Configure RCPM reg according to wake up source
> > > > > +request // @user_dev: pointer to user's device struct // @flag:
> > > > > +to
> > > > > +enable(true) or disable(false) wakeup source // @handle_priv:
> > > > > +pointer to struct rcpm_t instance // // Return 0 on success
> > > > > +other negative errno
> > >
> > > Although Linus preferred this // comment style.  I'm not sure if
> > > this will be handled correctly by the kernel-doc compiler.
> > >
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fw
> > > w
> > > w.kernel.org%2Fdoc%2Fhtml%2Fv4.18%2Fdoc-guide%2Fkernel-
> > >
> doc.html&amp;data=02%7C01%7Cran.wang_1%40nxp.com%7Cc0d88e669038
> > >
> 4e02b95108d612dec235%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0
> > > %7C636717145285126200&amp;sdata=H7GkUNOLVG%2FCcZESzhtHBeHC
> bO9
> > > %2FK4k9EdH30Cxq2%2BM%3D&amp;reserved=0
> >
> > So, do you think I need to change all comment style back to '/* ... */' ?
> > Actually I feel a little bit confused here.
> 
> I think Linus's comment about // comment style applies to normal code
> comment.  But kernel-doc comment is a special kind of code comment that
> needs to meet certain requirements.  People can use the scripts/kernel-doc
> tool to generate readable API documents from the source code.  It looks like
> you wanted to make the function description aligned with the kernel-doc
> format, but kernel-doc specifically requires to use the /* */ style(at least for
> now).

OK, will change style back to /* */.

Regards,
Ran

> Regards,
> Leo

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
  2018-09-07 20:22     ` Scott Wood
  (?)
  (?)
@ 2018-09-10  8:44       ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  8:44 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

Hi Scott,

On 2018/9/8 4:23, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > +Optional properties:
> > + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> > +   that doesn't have this property will be regarded as little-endian.
> 
> You've just broken all the existing powerpc device trees that are big-endian
> and have no big-endian property.

Yes, powerpc RCPM driver (arch/powerpc/sysdev/fsl_rcpm.c) will not refer
to big-endian. However, I think if Layerscape RCPM driver use different compatible
id (such as ' fsl,qoriq-rcpm-2.2'), it might be safe. Is that OK?

> > + - <property 'compatible' string of consumer device> : This string
> > +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> > +   is able to be regards as wakeup source or not, such as
> > + 'fsl,ls1012a-
> > ftm'.
> > +   Further, this property will carry the bit mask info to control
> > +   coresponding wake up source.
> 
> What will you do if there are multiple instances of a device with the same
> compatible, and different wakeup bits?  

You got me! This is a problem in current version. Well, we have to decouple wake up
source IP and RCPM driver. That's why I add a plat_pm driver to prevent wake up IP
knowing any information of RCPM. So in current context, one idea come to me is to
redesign property ' fsl,ls1012a-ftm = <0x20000>;', change to 'fsl,ls1012a-ftm = <&ftm0 0x20000>;'
What do you say? And could you tell me which API I can use to check if that device's
name is ftm0 (for example we want to find a node ftm0: ftm@29d000)?

>Plus, it's an awkward design in
> general, and you don't describe what the value actually means (bits in which
> register?). 

Yes, I admit my design looks ugly and not flexible and extensible enough. However, for above reason, 
do you have any good idea, please? :)

As to the register information, I can explain here in details (will add to commit
message of next version): There is a RCPM HW block which has register named IPPDEXPCR.
It controls whether prevent certain IP (such as timer, usb, etc) from entering low
power mode when system suspended. So it's necessary to program it if we want one
of those IP work as a wakeup source. However, different Layerscape SoCs have different bit vs.
IP mapping  layout. So I have to record this information in device tree and fetched by RCPM driver
directly.

Do I need to list all SoC's mapping information in this binding doc for reference?

>What was wrong with the existing binding?  

There was one version of RCPM patch which requiring property 'fsl,#rcpm-wakeup-cells' but was not
accepted by upstream finally. Now we will no need it any longer due to new design allow case of multiple
RCPM devices existing case.

>Alternatively, use the clock bindings.

Sorry I didn't get your point.

> > -
> > -Example:
> > -	lpuart0: serial@2950000 {
> > -		compatible = "fsl,ls1021a-lpuart";
> > -		reg = <0x0 0x2950000 0x0 0x1000>;
> > -		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> > -		clocks = <&sysclk>;
> > -		clock-names = "ipg";
> > -		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> > +		big-endian;
> > +		fsl,ls1012a-ftm = <0x20000>;
> > +		fsl,pfe = <0xf0000020>;
> 
> fsl,pfe is not documented.

pfe patch is not upstream yet, will remove it.

Regards,
Ran

> -Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-10  8:44       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  8:44 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

Hi Scott,

On 2018/9/8 4:23, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > +Optional properties:
> > + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> > +   that doesn't have this property will be regarded as little-endian.
> 
> You've just broken all the existing powerpc device trees that are big-endian
> and have no big-endian property.

Yes, powerpc RCPM driver (arch/powerpc/sysdev/fsl_rcpm.c) will not refer
to big-endian. However, I think if Layerscape RCPM driver use different compatible
id (such as ' fsl,qoriq-rcpm-2.2'), it might be safe. Is that OK?

> > + - <property 'compatible' string of consumer device> : This string
> > +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> > +   is able to be regards as wakeup source or not, such as
> > + 'fsl,ls1012a-
> > ftm'.
> > +   Further, this property will carry the bit mask info to control
> > +   coresponding wake up source.
> 
> What will you do if there are multiple instances of a device with the same
> compatible, and different wakeup bits?  

You got me! This is a problem in current version. Well, we have to decouple wake up
source IP and RCPM driver. That's why I add a plat_pm driver to prevent wake up IP
knowing any information of RCPM. So in current context, one idea come to me is to
redesign property ' fsl,ls1012a-ftm = <0x20000>;', change to 'fsl,ls1012a-ftm = <&ftm0 0x20000>;'
What do you say? And could you tell me which API I can use to check if that device's
name is ftm0 (for example we want to find a node ftm0: ftm@29d000)?

>Plus, it's an awkward design in
> general, and you don't describe what the value actually means (bits in which
> register?). 

Yes, I admit my design looks ugly and not flexible and extensible enough. However, for above reason, 
do you have any good idea, please? :)

As to the register information, I can explain here in details (will add to commit
message of next version): There is a RCPM HW block which has register named IPPDEXPCR.
It controls whether prevent certain IP (such as timer, usb, etc) from entering low
power mode when system suspended. So it's necessary to program it if we want one
of those IP work as a wakeup source. However, different Layerscape SoCs have different bit vs.
IP mapping  layout. So I have to record this information in device tree and fetched by RCPM driver
directly.

Do I need to list all SoC's mapping information in this binding doc for reference?

>What was wrong with the existing binding?  

There was one version of RCPM patch which requiring property 'fsl,#rcpm-wakeup-cells' but was not
accepted by upstream finally. Now we will no need it any longer due to new design allow case of multiple
RCPM devices existing case.

>Alternatively, use the clock bindings.

Sorry I didn't get your point.

> > -
> > -Example:
> > -	lpuart0: serial@2950000 {
> > -		compatible = "fsl,ls1021a-lpuart";
> > -		reg = <0x0 0x2950000 0x0 0x1000>;
> > -		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> > -		clocks = <&sysclk>;
> > -		clock-names = "ipg";
> > -		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> > +		big-endian;
> > +		fsl,ls1012a-ftm = <0x20000>;
> > +		fsl,pfe = <0xf0000020>;
> 
> fsl,pfe is not documented.

pfe patch is not upstream yet, will remove it.

Regards,
Ran

> -Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-10  8:44       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  8:44 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

SGkgU2NvdHQsDQoNCk9uIDIwMTgvOS84IDQ6MjMsIFNjb3R0IFdvb2Qgd3JvdGU6DQo+IA0KPiBP
biBGcmksIDIwMTgtMDgtMzEgYXQgMTE6NTIgKzA4MDAsIFJhbiBXYW5nIHdyb3RlOg0KPiA+ICtP
cHRpb25hbCBwcm9wZXJ0aWVzOg0KPiA+ICsgLSBiaWctZW5kaWFuIDogSW5kaWNhdGUgUkNQT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yMD47DQo+IA0KPiBmc2wscGZlIGlz
IG5vdCBkb2N1bWVudGVkLg0KDQpwZmUgcGF0Y2ggaXMgbm90IHVwc3RyZWFtIHlldCwgd2lsbCBy
ZW1vdmUgaXQuDQoNClJlZ2FyZHMsDQpSYW4NCg0KPiAtU2NvdHQNCg0K

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-10  8:44       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  8:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Scott,

On 2018/9/8 4:23, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > +Optional properties:
> > + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> > +   that doesn't have this property will be regarded as little-endian.
> 
> You've just broken all the existing powerpc device trees that are big-endian
> and have no big-endian property.

Yes, powerpc RCPM driver (arch/powerpc/sysdev/fsl_rcpm.c) will not refer
to big-endian. However, I think if Layerscape RCPM driver use different compatible
id (such as ' fsl,qoriq-rcpm-2.2'), it might be safe. Is that OK?

> > + - <property 'compatible' string of consumer device> : This string
> > +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> > +   is able to be regards as wakeup source or not, such as
> > + 'fsl,ls1012a-
> > ftm'.
> > +   Further, this property will carry the bit mask info to control
> > +   coresponding wake up source.
> 
> What will you do if there are multiple instances of a device with the same
> compatible, and different wakeup bits?  

You got me! This is a problem in current version. Well, we have to decouple wake up
source IP and RCPM driver. That's why I add a plat_pm driver to prevent wake up IP
knowing any information of RCPM. So in current context, one idea come to me is to
redesign property ' fsl,ls1012a-ftm = <0x20000>;', change to 'fsl,ls1012a-ftm = <&ftm0 0x20000>;'
What do you say? And could you tell me which API I can use to check if that device's
name is ftm0 (for example we want to find a node ftm0: ftm at 29d000)?

>Plus, it's an awkward design in
> general, and you don't describe what the value actually means (bits in which
> register?). 

Yes, I admit my design looks ugly and not flexible and extensible enough. However, for above reason, 
do you have any good idea, please? :)

As to the register information, I can explain here in details (will add to commit
message of next version): There is a RCPM HW block which has register named IPPDEXPCR.
It controls whether prevent certain IP (such as timer, usb, etc) from entering low
power mode when system suspended. So it's necessary to program it if we want one
of those IP work as a wakeup source. However, different Layerscape SoCs have different bit vs.
IP mapping  layout. So I have to record this information in device tree and fetched by RCPM driver
directly.

Do I need to list all SoC's mapping information in this binding doc for reference?

>What was wrong with the existing binding?  

There was one version of RCPM patch which requiring property 'fsl,#rcpm-wakeup-cells' but was not
accepted by upstream finally. Now we will no need it any longer due to new design allow case of multiple
RCPM devices existing case.

>Alternatively, use the clock bindings.

Sorry I didn't get your point.

> > -
> > -Example:
> > -	lpuart0: serial at 2950000 {
> > -		compatible = "fsl,ls1021a-lpuart";
> > -		reg = <0x0 0x2950000 0x0 0x1000>;
> > -		interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> > -		clocks = <&sysclk>;
> > -		clock-names = "ipg";
> > -		fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> > +		big-endian;
> > +		fsl,ls1012a-ftm = <0x20000>;
> > +		fsl,pfe = <0xf0000020>;
> 
> fsl,pfe is not documented.

pfe patch is not upstream yet, will remove it.

Regards,
Ran

> -Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
  2018-09-07 20:25     ` Scott Wood
  (?)
  (?)
@ 2018-09-10  9:09       ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:09 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

Hi Scott,

On 2018/9/8 18:16, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/ls-rcpm.c
> 
> Is there a reason why this is LS-specific, or could it be used with PPC RCPM
> blocks?

They have different SW arch design on low power operation: PPC RCPM
driver has taken care of most things of suspend enter & exit. And LS RCPM driver
will only handle wakeup source configure and left rest work to system firmware
to do. So you might be aware that LS RCPM will only get call whenever plat_pm
driver API is called rather than system suspend begin where.

> 
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >  	  have to know the implement details of wakeup function it require.
> >  	  Besides, it is also easy for service side to upgrade its logic
> > when
> >  	  design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +	bool "Freescale RCPM support"
> > +	depends on (FSL_PLAT_PM)
> 
> Why is this parenthesized?

Because we'd like to decouple RCPM driver and its user.
Benefit is that will allow user doesn't have to know who will serve it for some PM
features (such as wake up source control), and provide some kind of flexibility when
either RCMP or user driver evolve in the future. So I add a plat_pm driver to prevent
wake up IP knowing any information of RCPM.

Regards,
Ran

> 
> -Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-10  9:09       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:09 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linux-pm, linuxppc-dev, linux-kernel, linux-arm-kernel

Hi Scott,

On 2018/9/8 18:16, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/ls-rcpm.c
> 
> Is there a reason why this is LS-specific, or could it be used with PPC RCPM
> blocks?

They have different SW arch design on low power operation: PPC RCPM
driver has taken care of most things of suspend enter & exit. And LS RCPM driver
will only handle wakeup source configure and left rest work to system firmware
to do. So you might be aware that LS RCPM will only get call whenever plat_pm
driver API is called rather than system suspend begin where.

> 
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >  	  have to know the implement details of wakeup function it require.
> >  	  Besides, it is also easy for service side to upgrade its logic
> > when
> >  	  design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +	bool "Freescale RCPM support"
> > +	depends on (FSL_PLAT_PM)
> 
> Why is this parenthesized?

Because we'd like to decouple RCPM driver and its user.
Benefit is that will allow user doesn't have to know who will serve it for some PM
features (such as wake up source control), and provide some kind of flexibility when
either RCMP or user driver evolve in the future. So I add a plat_pm driver to prevent
wake up IP knowing any information of RCPM.

Regards,
Ran

> 
> -Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-10  9:09       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:09 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

SGkgU2NvdHQsDQoNCk9uIDIwMTgvOS84IDE4OjE2LCBTY290dCBXb29kIHdyb3RlOg0KPiANCj4g
T24gRnJpLCAyMDE4LTA4LTMxIGF0IDExOjUyICswODAwLCBSYW4gV2FuZyB3cm90ZToNCj4gPiBU
aGUgTlhQJ3MgUW9ySVEgUHJvY2Vzc29ycyBiYXNlZCBvbiBBUk0gQ29yZSBoYXZlIFJDUE0gbW9k
dWxlIChSdW4NCj4gPiBDb250cm9sIGFuZCBQb3dlciBNYW5hZ2VtZW50KSwgd2hpY2ggcGVyZm9y
bXMgYWxsIGRldmljZS1sZXZlbCB0YXNrcw0KPiA+IGFzc29jaWF0ZWQgd2l0aCBwb3dlciBtYW5h
Z2VtZW50IHN1Y2ggYXMgd2FrZXVwIHNvdXJjZSBjb250cm9sLg0KPiA+DQo+ID4gVGhpcyBkcml2
ZXIgZGVwZW5kcyBvbiBGU0wgcGxhdGZvcm0gUE0gZHJpdmVyIGZyYW1ld29yayB3aGljaCBoZWxw
IHRvDQo+ID4gaXNvbGF0ZSB1c2VyIGFuZCBQTSBzZXJ2aWNlIHByb3ZpZGVyIChzdWNoIGFzIFJD
UE0gZHJpdmVyKS4NCj4gPg0KPiA+IFNpZ25lZC1vZmYtYnk6IENoZW5odWkgWmhhbyA8Y2hlbmh1
aS56aGFvQG54cC5jb20+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9yIHNvbWUgUE0NCmZlYXR1
cmVzIChzdWNoIGFzIHdha2UgdXAgc291cmNlIGNvbnRyb2wpLCBhbmQgcHJvdmlkZSBzb21lIGtp
bmQgb2YgZmxleGliaWxpdHkgd2hlbg0KZWl0aGVyIFJDTVAgb3IgdXNlciBkcml2ZXIgZXZvbHZl
IGluIHRoZSBmdXR1cmUuIFNvIEkgYWRkIGEgcGxhdF9wbSBkcml2ZXIgdG8gcHJldmVudA0Kd2Fr
ZSB1cCBJUCBrbm93aW5nIGFueSBpbmZvcm1hdGlvbiBvZiBSQ1BNLg0KDQpSZWdhcmRzLA0KUmFu
DQoNCj4gDQo+IC1TY290dA0KDQo=

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 3/3] soc: fsl: add RCPM driver
@ 2018-09-10  9:09       ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Scott,

On 2018/9/8 18:16, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > 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 FSL platform PM driver framework which help to
> > isolate user and PM service provider (such as RCPM driver).
> >
> > Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
> > Signed-off-by: Ying Zhang <ying.zhang22455@nxp.com>
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |    6 ++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/ls-rcpm.c |  153
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 160 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/ls-rcpm.c
> 
> Is there a reason why this is LS-specific, or could it be used with PPC RCPM
> blocks?

They have different SW arch design on low power operation: PPC RCPM
driver has taken care of most things of suspend enter & exit. And LS RCPM driver
will only handle wakeup source configure and left rest work to system firmware
to do. So you might be aware that LS RCPM will only get call whenever plat_pm
driver API is called rather than system suspend begin where.

> 
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 6517412..882330d 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -30,3 +30,9 @@ config FSL_PLAT_PM
> >  	  have to know the implement details of wakeup function it require.
> >  	  Besides, it is also easy for service side to upgrade its logic
> > when
> >  	  design changed and remain user side unchanged.
> > +
> > +config LS_RCPM
> > +	bool "Freescale RCPM support"
> > +	depends on (FSL_PLAT_PM)
> 
> Why is this parenthesized?

Because we'd like to decouple RCPM driver and its user.
Benefit is that will allow user doesn't have to know who will serve it for some PM
features (such as wake up source control), and provide some kind of flexibility when
either RCMP or user driver evolve in the future. So I add a plat_pm driver to prevent
wake up IP knowing any information of RCPM.

Regards,
Ran

> 
> -Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
  2018-09-07 20:35   ` Scott Wood
  (?)
  (?)
@ 2018-09-10  9:26     ` Ran Wang
  -1 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:26 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

Hi Scott,

On 2018/9/8 4:35, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are
> > supported.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> > moved
> >  	  into this driver as well.
> +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> 
> This name seems to be simultaneously too generic (for something that is
> likely intended only for use with certain Freescale/NXP chip families) and too
> specific (for something that seems to be general infrastructure with no real
> hardware dependencies).

Yes, this driver has no real HW dependencies at all. But we'd like to introduce it
to help providing more flexibility & generic on FSL PM feature configure (so far 
we have RCPM on system wakeup source control). I think it's good
for driver/IP porting among different SoC in the future. As to the name, do you
have better suggestion?

> What specific problems with Linux's generic wakeup infrastructure is this
> trying to solve, and why would those problems not be better solved there?

Actually, I am not sure if generic wakeup infrastructure have this kind of PM feature
(keep specific IP alive during system suspend, could you please show me?).
And I think it is not common requirement, so I decide to put it in FSL folder. 

> Also, you should CC linux-pm on these patches.

Yes, thanks for suggestion

Regards,
Ran

> -Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-10  9:26     ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:26 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

Hi Scott,

On 2018/9/8 4:35, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are
> > supported.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> > moved
> >  	  into this driver as well.
> +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> 
> This name seems to be simultaneously too generic (for something that is
> likely intended only for use with certain Freescale/NXP chip families) and too
> specific (for something that seems to be general infrastructure with no real
> hardware dependencies).

Yes, this driver has no real HW dependencies at all. But we'd like to introduce it
to help providing more flexibility & generic on FSL PM feature configure (so far 
we have RCPM on system wakeup source control). I think it's good
for driver/IP porting among different SoC in the future. As to the name, do you
have better suggestion?

> What specific problems with Linux's generic wakeup infrastructure is this
> trying to solve, and why would those problems not be better solved there?

Actually, I am not sure if generic wakeup infrastructure have this kind of PM feature
(keep specific IP alive during system suspend, could you please show me?).
And I think it is not common requirement, so I decide to put it in FSL folder. 

> Also, you should CC linux-pm on these patches.

Yes, thanks for suggestion

Regards,
Ran

> -Scott


^ permalink raw reply	[flat|nested] 73+ messages in thread

* RE: [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-10  9:26     ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:26 UTC (permalink / raw)
  To: Scott Wood, Leo Li, Rob Herring, Mark Rutland
  Cc: devicetree, linuxppc-dev, linux-kernel, linux-arm-kernel, linux-pm

SGkgU2NvdHQsDQoNCk9uIDIwMTgvOS84IDQ6MzUsIFNjb3R0IFdvb2Qgd3JvdGU6DQo+IA0KPiBP
biBGcmksIDIwMTgtMDgtMzEgYXQgMTE6NTIgKzA4MDAsIFJhbiBXYW5nIHdyb3RlOg0KPiA+IFRo
aXMgZHJpdmVyIGlzIHRvIHByb3ZpZGUgYSBpbmRlcGVuZGVudCBmcmFtZXdvcmsgZm9yIFBNIHNl
cnZpY2UNCj4gPiBwcm92aWRlciBhbmQgY29uc3VtZXIgdG8gY29uZmlndXJlIHN5c3RlbSBsZXZl
bCB3YWtlIHVwIGZlYXR1cmUuIEZvcg0KPiA+IGV4YW1wbGUsIFJDUE0gZHJpdmVyIGNvdWxkIHJl
Z2lzdGVyIGEgY2FsbGJhY2sgZnVuY3Rpb24gb24gdGhpcw0KPiA+IHBsYXRmb3JtIGZpcnN0LCBh
bmQgRmxleCB0aW1lciBkcml2ZXIgd2hvIHdhbnQgdG8gZW5hYmxlIHRpbWVyIHdha2UgdXANCj4g
PiBmZWF0dXJlLCB3aWxsIGNhbGwgZ2VuZXJpYyBBUEkgcHJvdmlkZWQgYnkgdGhpc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LCB5b3Ugc2hvdWxkIENDIGxpbnV4LXBtIG9u
IHRoZXNlIHBhdGNoZXMuDQoNClllcywgdGhhbmtzIGZvciBzdWdnZXN0aW9uDQoNClJlZ2FyZHMs
DQpSYW4NCg0KPiAtU2NvdHQNCg0K

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms
@ 2018-09-10  9:26     ` Ran Wang
  0 siblings, 0 replies; 73+ messages in thread
From: Ran Wang @ 2018-09-10  9:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Scott,

On 2018/9/8 4:35, Scott Wood wrote:
> 
> On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > This driver is to provide a independent framework for PM service
> > provider and consumer to configure system level wake up feature. For
> > example, RCPM driver could register a callback function on this
> > platform first, and Flex timer driver who want to enable timer wake up
> > feature, will call generic API provided by this platform driver, and
> > then it will trigger RCPM driver to do it. The benefit is to isolate
> > the user and service, such as flex timer driver will not have to know
> > the implement details of wakeup function it require. Besides, it is
> > also easy for service side to upgrade its logic when design is changed
> > and remain user side unchanged.
> >
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/soc/fsl/Kconfig   |   14 +++++
> >  drivers/soc/fsl/Makefile  |    1 +
> >  drivers/soc/fsl/plat_pm.c |  144
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  include/soc/fsl/plat_pm.h |   22 +++++++
> >  4 files changed, 181 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/soc/fsl/plat_pm.c  create mode 100644
> > include/soc/fsl/plat_pm.h
> >
> > diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index
> > 7a9fb9b..6517412 100644
> > --- a/drivers/soc/fsl/Kconfig
> > +++ b/drivers/soc/fsl/Kconfig
> > @@ -16,3 +16,17 @@ config FSL_GUTS
> >  	  Initially only reading SVR and registering soc device are
> > supported.
> >  	  Other guts accesses, such as reading RCW, should eventually be
> > moved
> >  	  into this driver as well.
> +
> > +config FSL_PLAT_PM
> > +	bool "Freescale platform PM framework"
> 
> This name seems to be simultaneously too generic (for something that is
> likely intended only for use with certain Freescale/NXP chip families) and too
> specific (for something that seems to be general infrastructure with no real
> hardware dependencies).

Yes, this driver has no real HW dependencies at all. But we'd like to introduce it
to help providing more flexibility & generic on FSL PM feature configure (so far 
we have RCPM on system wakeup source control). I think it's good
for driver/IP porting among different SoC in the future. As to the name, do you
have better suggestion?

> What specific problems with Linux's generic wakeup infrastructure is this
> trying to solve, and why would those problems not be better solved there?

Actually, I am not sure if generic wakeup infrastructure have this kind of PM feature
(keep specific IP alive during system suspend, could you please show me?).
And I think it is not common requirement, so I decide to put it in FSL folder. 

> Also, you should CC linux-pm on these patches.

Yes, thanks for suggestion

Regards,
Ran

> -Scott

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
  2018-09-10  8:44       ` Ran Wang
  (?)
@ 2018-09-11 22:42         ` Li Yang
  -1 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-11 22:42 UTC (permalink / raw)
  To: Ran Wang
  Cc: Scott Wood, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-pm

On Mon, Sep 10, 2018 at 3:46 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Hi Scott,
>
> On 2018/9/8 4:23, Scott Wood wrote:
> >
> > On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > > +Optional properties:
> > > + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> > > +   that doesn't have this property will be regarded as little-endian.
> >
> > You've just broken all the existing powerpc device trees that are big-endian
> > and have no big-endian property.
>
> Yes, powerpc RCPM driver (arch/powerpc/sysdev/fsl_rcpm.c) will not refer
> to big-endian. However, I think if Layerscape RCPM driver use different compatible
> id (such as ' fsl,qoriq-rcpm-2.2'), it might be safe. Is that OK?

For Layerscape Chassis(gen3) based chips, the Reference Manual named
the power management IP as COP_PMU instead of RCPM which makes sense
to me as the register map is also quite different from the reg map of
RCPM.  So I think it is reasonable to create a new binding and driver
for the Chassis Gen3 based PMU.  However, the
arch/powerpc/sysdev/fsl_rcpm.c driver probably should be moved to
drivers/soc/fsl, as the Gen2.x Chassis and RCPM IP are also used in
some non-PowerPC Layerscape SoCs.  From what I know, all the RCPM
based IP are all big endian, so there is no need to add this property
for the old binding.

>
> > > + - <property 'compatible' string of consumer device> : This string
> > > +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> > > +   is able to be regards as wakeup source or not, such as
> > > + 'fsl,ls1012a-
> > > ftm'.
> > > +   Further, this property will carry the bit mask info to control
> > > +   coresponding wake up source.
> >
> > What will you do if there are multiple instances of a device with the same
> > compatible, and different wakeup bits?
>
> You got me! This is a problem in current version. Well, we have to decouple wake up
> source IP and RCPM driver. That's why I add a plat_pm driver to prevent wake up IP
> knowing any information of RCPM. So in current context, one idea come to me is to
> redesign property ' fsl,ls1012a-ftm = <0x20000>;', change to 'fsl,ls1012a-ftm = <&ftm0 0x20000>;'
> What do you say? And could you tell me which API I can use to check if that device's
> name is ftm0 (for example we want to find a node ftm0: ftm@29d000)?
>
> >Plus, it's an awkward design in
> > general, and you don't describe what the value actually means (bits in which
> > register?).
>
> Yes, I admit my design looks ugly and not flexible and extensible enough. However, for above reason,
> do you have any good idea, please? :)

Why do you have to move the wakeup information from device nodes to
the RCPM/PMU node?  For information related to both on-chip device and
SoC integration, the information normally goes into the node of
on-chip device instead of the integration IP's device node.  Existing
example like: interrupt, clock, memory map, and etc.  It is much
cleaner than listing all the interrupts in the interrupt controller's
node, right?

>
> As to the register information, I can explain here in details (will add to commit
> message of next version): There is a RCPM HW block which has register named IPPDEXPCR.
> It controls whether prevent certain IP (such as timer, usb, etc) from entering low
> power mode when system suspended. So it's necessary to program it if we want one
> of those IP work as a wakeup source. However, different Layerscape SoCs have different bit vs.
> IP mapping  layout. So I have to record this information in device tree and fetched by RCPM driver
> directly.
>
> Do I need to list all SoC's mapping information in this binding doc for reference?
>
> >What was wrong with the existing binding?
>
> There was one version of RCPM patch which requiring property 'fsl,#rcpm-wakeup-cells' but was not
> accepted by upstream finally. Now we will no need it any longer due to new design allow case of multiple
> RCPM devices existing case.
>
> >Alternatively, use the clock bindings.
>
> Sorry I didn't get your point.
>
> > > -
> > > -Example:
> > > -   lpuart0: serial@2950000 {
> > > -           compatible = "fsl,ls1021a-lpuart";
> > > -           reg = <0x0 0x2950000 0x0 0x1000>;
> > > -           interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> > > -           clocks = <&sysclk>;
> > > -           clock-names = "ipg";
> > > -           fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> > > +           big-endian;
> > > +           fsl,ls1012a-ftm = <0x20000>;
> > > +           fsl,pfe = <0xf0000020>;
> >
> > fsl,pfe is not documented.
>
> pfe patch is not upstream yet, will remove it.
>
> Regards,
> Ran
>
> > -Scott
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-11 22:42         ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-11 22:42 UTC (permalink / raw)
  To: Ran Wang
  Cc: Scott Wood, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linuxppc-dev, lkml,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-pm

On Mon, Sep 10, 2018 at 3:46 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Hi Scott,
>
> On 2018/9/8 4:23, Scott Wood wrote:
> >
> > On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > > +Optional properties:
> > > + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> > > +   that doesn't have this property will be regarded as little-endian.
> >
> > You've just broken all the existing powerpc device trees that are big-endian
> > and have no big-endian property.
>
> Yes, powerpc RCPM driver (arch/powerpc/sysdev/fsl_rcpm.c) will not refer
> to big-endian. However, I think if Layerscape RCPM driver use different compatible
> id (such as ' fsl,qoriq-rcpm-2.2'), it might be safe. Is that OK?

For Layerscape Chassis(gen3) based chips, the Reference Manual named
the power management IP as COP_PMU instead of RCPM which makes sense
to me as the register map is also quite different from the reg map of
RCPM.  So I think it is reasonable to create a new binding and driver
for the Chassis Gen3 based PMU.  However, the
arch/powerpc/sysdev/fsl_rcpm.c driver probably should be moved to
drivers/soc/fsl, as the Gen2.x Chassis and RCPM IP are also used in
some non-PowerPC Layerscape SoCs.  From what I know, all the RCPM
based IP are all big endian, so there is no need to add this property
for the old binding.

>
> > > + - <property 'compatible' string of consumer device> : This string
> > > +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> > > +   is able to be regards as wakeup source or not, such as
> > > + 'fsl,ls1012a-
> > > ftm'.
> > > +   Further, this property will carry the bit mask info to control
> > > +   coresponding wake up source.
> >
> > What will you do if there are multiple instances of a device with the same
> > compatible, and different wakeup bits?
>
> You got me! This is a problem in current version. Well, we have to decouple wake up
> source IP and RCPM driver. That's why I add a plat_pm driver to prevent wake up IP
> knowing any information of RCPM. So in current context, one idea come to me is to
> redesign property ' fsl,ls1012a-ftm = <0x20000>;', change to 'fsl,ls1012a-ftm = <&ftm0 0x20000>;'
> What do you say? And could you tell me which API I can use to check if that device's
> name is ftm0 (for example we want to find a node ftm0: ftm@29d000)?
>
> >Plus, it's an awkward design in
> > general, and you don't describe what the value actually means (bits in which
> > register?).
>
> Yes, I admit my design looks ugly and not flexible and extensible enough. However, for above reason,
> do you have any good idea, please? :)

Why do you have to move the wakeup information from device nodes to
the RCPM/PMU node?  For information related to both on-chip device and
SoC integration, the information normally goes into the node of
on-chip device instead of the integration IP's device node.  Existing
example like: interrupt, clock, memory map, and etc.  It is much
cleaner than listing all the interrupts in the interrupt controller's
node, right?

>
> As to the register information, I can explain here in details (will add to commit
> message of next version): There is a RCPM HW block which has register named IPPDEXPCR.
> It controls whether prevent certain IP (such as timer, usb, etc) from entering low
> power mode when system suspended. So it's necessary to program it if we want one
> of those IP work as a wakeup source. However, different Layerscape SoCs have different bit vs.
> IP mapping  layout. So I have to record this information in device tree and fetched by RCPM driver
> directly.
>
> Do I need to list all SoC's mapping information in this binding doc for reference?
>
> >What was wrong with the existing binding?
>
> There was one version of RCPM patch which requiring property 'fsl,#rcpm-wakeup-cells' but was not
> accepted by upstream finally. Now we will no need it any longer due to new design allow case of multiple
> RCPM devices existing case.
>
> >Alternatively, use the clock bindings.
>
> Sorry I didn't get your point.
>
> > > -
> > > -Example:
> > > -   lpuart0: serial@2950000 {
> > > -           compatible = "fsl,ls1021a-lpuart";
> > > -           reg = <0x0 0x2950000 0x0 0x1000>;
> > > -           interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> > > -           clocks = <&sysclk>;
> > > -           clock-names = "ipg";
> > > -           fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> > > +           big-endian;
> > > +           fsl,ls1012a-ftm = <0x20000>;
> > > +           fsl,pfe = <0xf0000020>;
> >
> > fsl,pfe is not documented.
>
> pfe patch is not upstream yet, will remove it.
>
> Regards,
> Ran
>
> > -Scott
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

* [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM
@ 2018-09-11 22:42         ` Li Yang
  0 siblings, 0 replies; 73+ messages in thread
From: Li Yang @ 2018-09-11 22:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Sep 10, 2018 at 3:46 AM Ran Wang <ran.wang_1@nxp.com> wrote:
>
> Hi Scott,
>
> On 2018/9/8 4:23, Scott Wood wrote:
> >
> > On Fri, 2018-08-31 at 11:52 +0800, Ran Wang wrote:
> > > +Optional properties:
> > > + - big-endian : Indicate RCPM registers is big-endian. A RCPM node
> > > +   that doesn't have this property will be regarded as little-endian.
> >
> > You've just broken all the existing powerpc device trees that are big-endian
> > and have no big-endian property.
>
> Yes, powerpc RCPM driver (arch/powerpc/sysdev/fsl_rcpm.c) will not refer
> to big-endian. However, I think if Layerscape RCPM driver use different compatible
> id (such as ' fsl,qoriq-rcpm-2.2'), it might be safe. Is that OK?

For Layerscape Chassis(gen3) based chips, the Reference Manual named
the power management IP as COP_PMU instead of RCPM which makes sense
to me as the register map is also quite different from the reg map of
RCPM.  So I think it is reasonable to create a new binding and driver
for the Chassis Gen3 based PMU.  However, the
arch/powerpc/sysdev/fsl_rcpm.c driver probably should be moved to
drivers/soc/fsl, as the Gen2.x Chassis and RCPM IP are also used in
some non-PowerPC Layerscape SoCs.  From what I know, all the RCPM
based IP are all big endian, so there is no need to add this property
for the old binding.

>
> > > + - <property 'compatible' string of consumer device> : This string
> > > +   is referred by RCPM driver to judge if the consumer (such as flex timer)
> > > +   is able to be regards as wakeup source or not, such as
> > > + 'fsl,ls1012a-
> > > ftm'.
> > > +   Further, this property will carry the bit mask info to control
> > > +   coresponding wake up source.
> >
> > What will you do if there are multiple instances of a device with the same
> > compatible, and different wakeup bits?
>
> You got me! This is a problem in current version. Well, we have to decouple wake up
> source IP and RCPM driver. That's why I add a plat_pm driver to prevent wake up IP
> knowing any information of RCPM. So in current context, one idea come to me is to
> redesign property ' fsl,ls1012a-ftm = <0x20000>;', change to 'fsl,ls1012a-ftm = <&ftm0 0x20000>;'
> What do you say? And could you tell me which API I can use to check if that device's
> name is ftm0 (for example we want to find a node ftm0: ftm at 29d000)?
>
> >Plus, it's an awkward design in
> > general, and you don't describe what the value actually means (bits in which
> > register?).
>
> Yes, I admit my design looks ugly and not flexible and extensible enough. However, for above reason,
> do you have any good idea, please? :)

Why do you have to move the wakeup information from device nodes to
the RCPM/PMU node?  For information related to both on-chip device and
SoC integration, the information normally goes into the node of
on-chip device instead of the integration IP's device node.  Existing
example like: interrupt, clock, memory map, and etc.  It is much
cleaner than listing all the interrupts in the interrupt controller's
node, right?

>
> As to the register information, I can explain here in details (will add to commit
> message of next version): There is a RCPM HW block which has register named IPPDEXPCR.
> It controls whether prevent certain IP (such as timer, usb, etc) from entering low
> power mode when system suspended. So it's necessary to program it if we want one
> of those IP work as a wakeup source. However, different Layerscape SoCs have different bit vs.
> IP mapping  layout. So I have to record this information in device tree and fetched by RCPM driver
> directly.
>
> Do I need to list all SoC's mapping information in this binding doc for reference?
>
> >What was wrong with the existing binding?
>
> There was one version of RCPM patch which requiring property 'fsl,#rcpm-wakeup-cells' but was not
> accepted by upstream finally. Now we will no need it any longer due to new design allow case of multiple
> RCPM devices existing case.
>
> >Alternatively, use the clock bindings.
>
> Sorry I didn't get your point.
>
> > > -
> > > -Example:
> > > -   lpuart0: serial at 2950000 {
> > > -           compatible = "fsl,ls1021a-lpuart";
> > > -           reg = <0x0 0x2950000 0x0 0x1000>;
> > > -           interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
> > > -           clocks = <&sysclk>;
> > > -           clock-names = "ipg";
> > > -           fsl,rcpm-wakeup = <&rcpm 0x0 0x40000000>;
> > > +           big-endian;
> > > +           fsl,ls1012a-ftm = <0x20000>;
> > > +           fsl,pfe = <0xf0000020>;
> >
> > fsl,pfe is not documented.
>
> pfe patch is not upstream yet, will remove it.
>
> Regards,
> Ran
>
> > -Scott
>

^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2018-09-11 22:43 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31  3:52 [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms Ran Wang
2018-08-31  3:52 ` Ran Wang
2018-08-31  3:52 ` [PATCH 2/3] Documentation: dt: binding: fsl: update property description for RCPM Ran Wang
2018-08-31  3:52   ` Ran Wang
2018-09-04  1:25   ` Rob Herring
2018-09-04  1:25     ` Rob Herring
2018-09-04  1:25     ` Rob Herring
2018-09-05  2:22     ` Ran Wang
2018-09-05  2:22       ` Ran Wang
2018-09-05  2:22       ` Ran Wang
2018-09-05  2:22       ` Ran Wang
2018-09-07 20:22   ` Scott Wood
2018-09-07 20:22     ` Scott Wood
2018-09-10  8:44     ` Ran Wang
2018-09-10  8:44       ` Ran Wang
2018-09-10  8:44       ` Ran Wang
2018-09-10  8:44       ` Ran Wang
2018-09-11 22:42       ` Li Yang
2018-09-11 22:42         ` Li Yang
2018-09-11 22:42         ` Li Yang
2018-08-31  3:52 ` [PATCH 3/3] soc: fsl: add RCPM driver Ran Wang
2018-08-31  3:52   ` Ran Wang
2018-09-05  2:57   ` Wang, Dongsheng
2018-09-05  2:57     ` Wang, Dongsheng
2018-09-05  2:57     ` Wang, Dongsheng
2018-09-05  2:57     ` Wang, Dongsheng
2018-09-05  3:21     ` Li Yang
2018-09-05  3:21       ` Li Yang
2018-09-05  3:21       ` Li Yang
2018-09-05  3:21       ` Li Yang
2018-09-07  9:48       ` Ran Wang
2018-09-07  9:48         ` Ran Wang
2018-09-07  9:48         ` Ran Wang
2018-09-07  9:48         ` Ran Wang
2018-09-07 18:56         ` Li Yang
2018-09-07 18:56           ` Li Yang
2018-09-07 18:56           ` Li Yang
2018-09-10  3:31           ` Ran Wang
2018-09-10  3:31             ` Ran Wang
2018-09-10  3:31             ` Ran Wang
2018-09-10  3:31             ` Ran Wang
2018-09-07  9:32     ` Ran Wang
2018-09-07  9:32       ` Ran Wang
2018-09-07  9:32       ` Ran Wang
2018-09-07  9:32       ` Ran Wang
2018-09-07 20:25   ` Scott Wood
2018-09-07 20:25     ` Scott Wood
2018-09-10  9:09     ` Ran Wang
2018-09-10  9:09       ` Ran Wang
2018-09-10  9:09       ` Ran Wang
2018-09-10  9:09       ` Ran Wang
2018-09-05  3:04 ` [PATCH 1/3] soc: fsl: add Platform PM driver QorIQ platforms Wang, Dongsheng
2018-09-05  3:04   ` Wang, Dongsheng
2018-09-05  3:04   ` Wang, Dongsheng
2018-09-05  3:04   ` Wang, Dongsheng
2018-09-07  8:41   ` Ran Wang
2018-09-07  8:41     ` Ran Wang
2018-09-07  8:41     ` Ran Wang
2018-09-07  8:41     ` Ran Wang
2018-09-07 10:15     ` Wang, Dongsheng
2018-09-07 10:15       ` Wang, Dongsheng
2018-09-07 10:15       ` Wang, Dongsheng
2018-09-07 10:15       ` Wang, Dongsheng
2018-09-10  3:27       ` Ran Wang
2018-09-10  3:27         ` Ran Wang
2018-09-10  3:27         ` Ran Wang
2018-09-10  3:27         ` Ran Wang
2018-09-07 20:35 ` Scott Wood
2018-09-07 20:35   ` Scott Wood
2018-09-10  9:26   ` Ran Wang
2018-09-10  9:26     ` Ran Wang
2018-09-10  9:26     ` Ran Wang
2018-09-10  9:26     ` Ran Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.