Message ID | 1441877796-32232-1-git-send-email-dongsheng.wang@freescale.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Sep 10, 2015 at 10:36:36AM +0100, Dongsheng Wang wrote: > From: Wang Dongsheng <dongsheng.wang@freescale.com> > > Based on PSCI framework, add system STANDBY implement for ls1021 platform. > > Signed-off-by: Chenhui Zhao <chenhui.zhao@freescale.com> > Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> > > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile > index fb689d8..d7a2d1d 100644 > --- a/arch/arm/mach-imx/Makefile > +++ b/arch/arm/mach-imx/Makefile > @@ -90,6 +90,7 @@ ifeq ($(CONFIG_SUSPEND),y) > AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a > obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o > obj-$(CONFIG_SOC_IMX53) += suspend-imx53.o > +obj-$(CONFIG_SOC_LS1021A) += pm-ls1.o > endif > obj-$(CONFIG_SOC_IMX6) += pm-imx6.o > > diff --git a/arch/arm/mach-imx/pm-ls1.c b/arch/arm/mach-imx/pm-ls1.c > new file mode 100644 > index 0000000..f80b24d > --- /dev/null > +++ b/arch/arm/mach-imx/pm-ls1.c > @@ -0,0 +1,222 @@ > +/* > + * Support Power Management Control for LS1 > + * > + * Copyright 2015 Freescale Semiconductor Inc. > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License as published by the > + * Free Software Foundation; either version 2 of the License, or (at your > + * option) any later version. > + */ > + > +#include <linux/io.h> > +#include <linux/kernel.h> > +#include <linux/of_platform.h> > +#include <linux/of_address.h> > +#include <linux/psci.h> > +#include <linux/suspend.h> > + > +#include <uapi/linux/psci.h> > + > +#include <asm/cacheflush.h> > +#include <asm/psci.h> NAK. No new platform code should be calling the PSCI functions directly; you should not need to include these files in platform code. Thanks, Mark.
Hi Mark, Thanks for your review. > -----Original Message----- > From: Mark Rutland [mailto:mark.rutland@arm.com] > Sent: Thursday, September 10, 2015 5:59 PM > To: Wang Dongsheng-B40534 > Cc: shawnguo@kernel.org; Catalin Marinas; Wang Huan-B18965; Zhao Chenhui-B35336; > Jin Zhengxiong-R64188; linux-arm-kernel@lists.infradead.org; linux- > kernel@vger.kernel.org > Subject: Re: [PATCH] arm/ls1021a: Add Sleep feature for ls1021 > > On Thu, Sep 10, 2015 at 10:36:36AM +0100, Dongsheng Wang wrote: > > From: Wang Dongsheng <dongsheng.wang@freescale.com> > > > > Based on PSCI framework, add system STANDBY implement for ls1021 platform. > > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@freescale.com> > > Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> > > > > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile > > index fb689d8..d7a2d1d 100644 > > --- a/arch/arm/mach-imx/Makefile > > +++ b/arch/arm/mach-imx/Makefile > > @@ -90,6 +90,7 @@ ifeq ($(CONFIG_SUSPEND),y) AFLAGS_suspend-imx6.o > > :=-Wa,-march=armv7-a > > obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o > > obj-$(CONFIG_SOC_IMX53) += suspend-imx53.o > > +obj-$(CONFIG_SOC_LS1021A) += pm-ls1.o > > endif > > obj-$(CONFIG_SOC_IMX6) += pm-imx6.o > > > > diff --git a/arch/arm/mach-imx/pm-ls1.c b/arch/arm/mach-imx/pm-ls1.c > > new file mode 100644 index 0000000..f80b24d > > --- /dev/null > > +++ b/arch/arm/mach-imx/pm-ls1.c > > @@ -0,0 +1,222 @@ > > +/* > > + * Support Power Management Control for LS1 > > + * > > + * Copyright 2015 Freescale Semiconductor Inc. > > + * > > + * This program is free software; you can redistribute it and/or modify it > > + * under the terms of the GNU General Public License as published by > the > > + * Free Software Foundation; either version 2 of the License, or > > +(at your > > + * option) any later version. > > + */ > > + > > +#include <linux/io.h> > > +#include <linux/kernel.h> > > +#include <linux/of_platform.h> > > +#include <linux/of_address.h> > > +#include <linux/psci.h> > > +#include <linux/suspend.h> > > + > > +#include <uapi/linux/psci.h> > > + > > +#include <asm/cacheflush.h> > > +#include <asm/psci.h> > > NAK. > > No new platform code should be calling the PSCI functions directly; you should > not need to include these files in platform code. PSCI 1.0 define SYSTEM_SUSPEND, and 0.2 and 0.1 not support this feature. I will drop psci-cpu_suspend to implement SYSTEM SUSPEND, and implement system suspend in platform code. Regards, -Dongsheng
Hi Mark, > -----Original Message----- > From: Wang Dongsheng-B40534 > Sent: Friday, September 11, 2015 11:42 AM > To: 'Mark Rutland' > Cc: shawnguo@kernel.org; Catalin Marinas; Wang Huan-B18965; Zhao Chenhui-B35336; > Jin Zhengxiong-R64188; linux-arm-kernel@lists.infradead.org; linux- > kernel@vger.kernel.org > Subject: RE: [PATCH] arm/ls1021a: Add Sleep feature for ls1021 > > Hi Mark, > > Thanks for your review. > > > -----Original Message----- > > From: Mark Rutland [mailto:mark.rutland@arm.com] > > Sent: Thursday, September 10, 2015 5:59 PM > > To: Wang Dongsheng-B40534 > > Cc: shawnguo@kernel.org; Catalin Marinas; Wang Huan-B18965; Zhao > > Chenhui-B35336; Jin Zhengxiong-R64188; > > linux-arm-kernel@lists.infradead.org; linux- kernel@vger.kernel.org > > Subject: Re: [PATCH] arm/ls1021a: Add Sleep feature for ls1021 > > > > On Thu, Sep 10, 2015 at 10:36:36AM +0100, Dongsheng Wang wrote: > > > From: Wang Dongsheng <dongsheng.wang@freescale.com> > > > > > > Based on PSCI framework, add system STANDBY implement for ls1021 platform. > > > > > > Signed-off-by: Chenhui Zhao <chenhui.zhao@freescale.com> > > > Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> > > > > > > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile > > > index fb689d8..d7a2d1d 100644 > > > --- a/arch/arm/mach-imx/Makefile > > > +++ b/arch/arm/mach-imx/Makefile > > > @@ -90,6 +90,7 @@ ifeq ($(CONFIG_SUSPEND),y) AFLAGS_suspend-imx6.o > > > :=-Wa,-march=armv7-a > > > obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o > > > obj-$(CONFIG_SOC_IMX53) += suspend-imx53.o > > > +obj-$(CONFIG_SOC_LS1021A) += pm-ls1.o > > > endif > > > obj-$(CONFIG_SOC_IMX6) += pm-imx6.o > > > > > > diff --git a/arch/arm/mach-imx/pm-ls1.c b/arch/arm/mach-imx/pm-ls1.c > > > new file mode 100644 index 0000000..f80b24d > > > --- /dev/null > > > +++ b/arch/arm/mach-imx/pm-ls1.c > > > @@ -0,0 +1,222 @@ > > > +/* > > > + * Support Power Management Control for LS1 > > > + * > > > + * Copyright 2015 Freescale Semiconductor Inc. > > > + * > > > + * This program is free software; you can redistribute it and/or modify it > > > + * under the terms of the GNU General Public License as > published by > > the > > > + * Free Software Foundation; either version 2 of the License, or > > > +(at your > > > + * option) any later version. > > > + */ > > > + > > > +#include <linux/io.h> > > > +#include <linux/kernel.h> > > > +#include <linux/of_platform.h> > > > +#include <linux/of_address.h> > > > +#include <linux/psci.h> > > > +#include <linux/suspend.h> > > > + > > > +#include <uapi/linux/psci.h> > > > + > > > +#include <asm/cacheflush.h> > > > +#include <asm/psci.h> > > > > NAK. > > > > No new platform code should be calling the PSCI functions directly; > > you should not need to include these files in platform code. > > PSCI 1.0 define SYSTEM_SUSPEND, and 0.2 and 0.1 not support this feature. > > I will drop psci-cpu_suspend to implement SYSTEM SUSPEND, and implement system > suspend in platform code. Now 0.1 and 0.2 not support SYSTEM SUSPEND, means if do system suspend we still need to use platform_suspend_ops to implement system suspend in platform code and cannot use PSCI interface to do it? How about PSCI 1.0 support, could you share some information about it? Regards, -Dongsheng
On Fri, Sep 11, 2015 at 04:53:04AM +0100, Wang Dongsheng wrote: > Hi Mark, Hi, > > > > diff --git a/arch/arm/mach-imx/pm-ls1.c b/arch/arm/mach-imx/pm-ls1.c > > > > new file mode 100644 index 0000000..f80b24d > > > > --- /dev/null > > > > +++ b/arch/arm/mach-imx/pm-ls1.c > > > > @@ -0,0 +1,222 @@ > > > > +/* > > > > + * Support Power Management Control for LS1 > > > > + * > > > > + * Copyright 2015 Freescale Semiconductor Inc. > > > > + * > > > > + * This program is free software; you can redistribute it and/or modify it > > > > + * under the terms of the GNU General Public License as > > published by > > > the > > > > + * Free Software Foundation; either version 2 of the License, or > > > > +(at your > > > > + * option) any later version. > > > > + */ > > > > + > > > > +#include <linux/io.h> > > > > +#include <linux/kernel.h> > > > > +#include <linux/of_platform.h> > > > > +#include <linux/of_address.h> > > > > +#include <linux/psci.h> > > > > +#include <linux/suspend.h> > > > > + > > > > +#include <uapi/linux/psci.h> > > > > + > > > > +#include <asm/cacheflush.h> > > > > +#include <asm/psci.h> > > > > > > NAK. > > > > > > No new platform code should be calling the PSCI functions directly; > > > you should not need to include these files in platform code. > > > > PSCI 1.0 define SYSTEM_SUSPEND, and 0.2 and 0.1 not support this feature. > > > > I will drop psci-cpu_suspend to implement SYSTEM SUSPEND, and implement system > > suspend in platform code. > > Now 0.1 and 0.2 not support SYSTEM SUSPEND, means if do system suspend we still > need to use platform_suspend_ops to implement system suspend in platform code and > cannot use PSCI interface to do it? As PSCI_SYSTEM_SUSPEND was introduced in PSCI 1.0, you would need a PSCI 1.0 implementation in order to use PSCI_SYSTEM_SUSPEND. Is there anything preventing implementing PSCI 1.0? > How about PSCI 1.0 support, could you share some information about it? Lorenzo has implemented basic PSCI 1.0 support [1,2], and Sudeep has been working on SYSTEM_SUSPEND [3], though I'm not immediately aware of the state of the world there. Do you have any specific questions? Thanks, Mark. [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/355098.html [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-September/369806.html [3] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-September/369804.html
Hi Mark, > -----Original Message----- > From: Mark Rutland [mailto:mark.rutland@arm.com] > Sent: Thursday, September 17, 2015 8:32 PM > To: Wang Dongsheng-B40534 > Cc: shawnguo@kernel.org; Catalin Marinas; Wang Huan-B18965; Zhao Chenhui-B35336; > Jin Zhengxiong-R64188; linux-arm-kernel@lists.infradead.org; linux- > kernel@vger.kernel.org; lorenzo.pieralisi@arm.com; sudeep.holla@arm.com > Subject: Re: [PATCH] arm/ls1021a: Add Sleep feature for ls1021 > > On Fri, Sep 11, 2015 at 04:53:04AM +0100, Wang Dongsheng wrote: > > Hi Mark, > > Hi, > > > > > > diff --git a/arch/arm/mach-imx/pm-ls1.c > > > > > b/arch/arm/mach-imx/pm-ls1.c new file mode 100644 index > > > > > 0000000..f80b24d > > > > > --- /dev/null > > > > > +++ b/arch/arm/mach-imx/pm-ls1.c > > > > > @@ -0,0 +1,222 @@ > > > > > +/* > > > > > + * Support Power Management Control for LS1 > > > > > + * > > > > > + * Copyright 2015 Freescale Semiconductor Inc. > > > > > + * > > > > > + * This program is free software; you can redistribute it and/or > modify it > > > > > + * under the terms of the GNU General Public License as > > > published by > > > > the > > > > > + * Free Software Foundation; either version 2 of the License, > > > > > +or (at your > > > > > + * option) any later version. > > > > > + */ > > > > > + > > > > > +#include <linux/io.h> > > > > > +#include <linux/kernel.h> > > > > > +#include <linux/of_platform.h> > > > > > +#include <linux/of_address.h> > > > > > +#include <linux/psci.h> > > > > > +#include <linux/suspend.h> > > > > > + > > > > > +#include <uapi/linux/psci.h> > > > > > + > > > > > +#include <asm/cacheflush.h> > > > > > +#include <asm/psci.h> > > > > > > > > NAK. > > > > > > > > No new platform code should be calling the PSCI functions > > > > directly; you should not need to include these files in platform code. > > > > > > PSCI 1.0 define SYSTEM_SUSPEND, and 0.2 and 0.1 not support this feature. > > > > > > I will drop psci-cpu_suspend to implement SYSTEM SUSPEND, and > > > implement system suspend in platform code. > > > > Now 0.1 and 0.2 not support SYSTEM SUSPEND, means if do system suspend > > we still need to use platform_suspend_ops to implement system suspend > > in platform code and cannot use PSCI interface to do it? > > As PSCI_SYSTEM_SUSPEND was introduced in PSCI 1.0, you would need a PSCI > 1.0 implementation in order to use PSCI_SYSTEM_SUSPEND. Is there anything > preventing implementing PSCI 1.0? > > > How about PSCI 1.0 support, could you share some information about it? > > Lorenzo has implemented basic PSCI 1.0 support [1,2], and Sudeep has been > working on SYSTEM_SUSPEND [3], though I'm not immediately aware of the state of > the world there. > > Do you have any specific questions? > There is no problem, I just want to use V1.0 to support our platform SYSTEM_SUSPEND, but 1.0 implementation is not in v4.3-rc1, so abandon this. Thanks for your help. Regards, -Dongsheng
On Fri, Sep 18, 2015 at 03:37:15AM +0100, Wang Dongsheng wrote: [...] > > > How about PSCI 1.0 support, could you share some information about it? > > > > Lorenzo has implemented basic PSCI 1.0 support [1,2], and Sudeep has been > > working on SYSTEM_SUSPEND [3], though I'm not immediately aware of the state of > > the world there. > > > > Do you have any specific questions? > > > > There is no problem, I just want to use V1.0 to support our platform SYSTEM_SUSPEND, > but 1.0 implementation is not in v4.3-rc1, so abandon this. It will be in v4.4, so you can drop this patch then. Thanks, Lorenzo
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index fb689d8..d7a2d1d 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -90,6 +90,7 @@ ifeq ($(CONFIG_SUSPEND),y) AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o obj-$(CONFIG_SOC_IMX53) += suspend-imx53.o +obj-$(CONFIG_SOC_LS1021A) += pm-ls1.o endif obj-$(CONFIG_SOC_IMX6) += pm-imx6.o diff --git a/arch/arm/mach-imx/pm-ls1.c b/arch/arm/mach-imx/pm-ls1.c new file mode 100644 index 0000000..f80b24d --- /dev/null +++ b/arch/arm/mach-imx/pm-ls1.c @@ -0,0 +1,222 @@ +/* + * Support Power Management Control for LS1 + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of_platform.h> +#include <linux/of_address.h> +#include <linux/psci.h> +#include <linux/suspend.h> + +#include <uapi/linux/psci.h> + +#include <asm/cacheflush.h> +#include <asm/psci.h> +#include <asm/suspend.h> + +#define FSL_SLEEP 0x1 +#define FSL_DEEP_SLEEP 0x2 + +#define CCSR_SCFG_CLUSTERPMCR 0x904 +#define CCSR_SCFG_CLUSTERPMCR_WFIL2EN 0x80000000 +#define CCSR_SCFG_CLUSTERPM_ENABLE 1 +#define CCSR_SCFG_CLUSTERPM_DISABLE 0 + +#define CCSR_RCPM_IPPDEXPCR0 0x140 +#define CCSR_RCPM_IPPDEXPCR1 0x144 +#define CCSR_RCPM_IPPDEXPCR1_OCRAM1 0x10000000 + +#define SLEEP_ARRAY_SIZE 3 + +#define LS1_SLEEP_PARAM \ + (PSCI_POWER_STATE_TYPE_STANDBY << PSCI_0_2_POWER_STATE_TYPE_SHIFT) + +static u32 ippdexpcr0, ippdexpcr1; + +struct ls1_pm_baseaddr { + void __iomem *rcpm; + void __iomem *scfg; +}; + +static struct ls1_pm_baseaddr ls1_pm_base; + +static int ls1_pm_iomap(suspend_state_t state) +{ + struct device_node *np; + void *base; + + np = of_find_compatible_node(NULL, NULL, "fsl,ls1021a-scfg"); + if (!np) { + pr_err("Missing SCFG node in the device tree\n"); + return -EINVAL; + } + + base = of_iomap(np, 0); + of_node_put(np); + if (!base) { + pr_err("Couldn't map SCFG registers\n"); + return -EINVAL; + } + + ls1_pm_base.scfg = base; + + return 0; +} + +static void ls1_pm_uniomap(suspend_state_t state) +{ + iounmap(ls1_pm_base.scfg); +} + +/* set IP powerdown exception, make them work during sleep/deep sleep */ +static void ls1_set_powerdown(void) +{ + iowrite32be(ippdexpcr0, ls1_pm_base.rcpm + CCSR_RCPM_IPPDEXPCR0); + iowrite32be(ippdexpcr1, ls1_pm_base.rcpm + CCSR_RCPM_IPPDEXPCR1); +} + +static void ls1_set_power_except(struct device *dev, int on) +{ + int ret; + u32 value[SLEEP_ARRAY_SIZE]; + + /* + * Get the values in the "rcpm-wakeup" property. There are three values. + * The first points to the RCPM node, the second is the value of + * the ippdexpcr0 register, and the third is the value of + * the ippdexpcr1 register. + */ + ret = of_property_read_u32_array(dev->of_node, "rcpm-wakeup", + value, SLEEP_ARRAY_SIZE); + if (ret) { + dev_err(dev, "%s: Can not find the \"sleep\" property.\n", + __func__); + return; + } + + ippdexpcr0 |= value[1]; + ippdexpcr1 |= value[2]; + + pr_debug("%s: set %s as a wakeup source", __func__, + dev->of_node->full_name); +} + +static void ls1_set_wakeup_device(struct device *dev, void *enable) +{ + /* set each device which can act as wakeup source */ + if (device_may_wakeup(dev)) + ls1_set_power_except(dev, *((int *)enable)); +} + +/* enable cluster to enter the PCL10 state */ +void ls1_set_clusterpm(int enable) +{ + u32 val = 0; + + if (enable) + val = CCSR_SCFG_CLUSTERPMCR_WFIL2EN; + + iowrite32be(val, ls1_pm_base.scfg + CCSR_SCFG_CLUSTERPMCR); +} + +static int ls1_suspend_enter(suspend_state_t state) +{ + int ret = -EINVAL; + u32 psci_state = 0; + + ls1_set_powerdown(); + ls1_set_clusterpm(CCSR_SCFG_CLUSTERPM_ENABLE); + + switch (state) { + case PM_SUSPEND_STANDBY: + psci_state |= LS1_SLEEP_PARAM; + + flush_cache_louis(); + if (psci_ops.cpu_suspend) + ret = psci_ops.cpu_suspend(psci_state, + __pa(secondary_startup)); + break; + case PM_SUSPEND_MEM: + default: + break; + } + + ls1_set_clusterpm(CCSR_SCFG_CLUSTERPM_DISABLE); + + return ret; +} + +static int ls1_suspend_valid(suspend_state_t state) +{ + if (state == PM_SUSPEND_STANDBY) + return 1; + + return 0; +} + +static int ls1_suspend_begin(suspend_state_t state) +{ + int res = -EINVAL; + + ippdexpcr0 = 0; + ippdexpcr1 = 0; + + if (state == PM_SUSPEND_STANDBY) + res = ls1_pm_iomap(state); + + if (!res) + dpm_for_each_dev(NULL, ls1_set_wakeup_device); + + return res; +} + +static void ls1_suspend_end(void) +{ + ls1_pm_uniomap(PM_SUSPEND_STANDBY); +} + +static const struct platform_suspend_ops ls1_suspend_ops = { + .valid = ls1_suspend_valid, + .enter = ls1_suspend_enter, + .begin = ls1_suspend_begin, + .end = ls1_suspend_end, +}; + +static const struct of_device_id rcpm_matches[] = { + { + .compatible = "fsl,ls1021a-rcpm", + }, + {} +}; + +static int __init ls1_pm_init(void) +{ + const struct of_device_id *match; + struct device_node *np; + + np = of_find_matching_node_and_match(NULL, rcpm_matches, &match); + if (!np) { + pr_err("%s: can't find the rcpm node.\n", __func__); + return -EINVAL; + } + + ls1_pm_base.rcpm = of_iomap(np, 0); + of_node_put(np); + if (!ls1_pm_base.rcpm) + return -ENOMEM; + + suspend_set_ops(&ls1_suspend_ops); + + pr_info("Freescale Power Management Control Registered\n"); + + return 0; +} +arch_initcall(ls1_pm_init);