From 19e8c92bbe2e18c92cfa0d10b8c02db8e3ec18d5 Mon Sep 17 00:00:00 2001 From: Achin Gupta Date: Sun, 16 Dec 2012 21:46:10 +0000 Subject: ARM: psci: add constants to specify affinity levels This patch defines constants to allow callers of the psci 'suspend' & 'off' calls specify supported affinity levels. Signed-off-by: Achin Gupta Signed-off-by: Liviu Dudau --- arch/arm/include/asm/psci.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h index ce0dbe7c162..78ce38ff19f 100644 --- a/arch/arm/include/asm/psci.h +++ b/arch/arm/include/asm/psci.h @@ -16,6 +16,10 @@ #define PSCI_POWER_STATE_TYPE_STANDBY 0 #define PSCI_POWER_STATE_TYPE_POWER_DOWN 1 +#define PSCI_POWER_STATE_AFFINITY_LEVEL0 0 +#define PSCI_POWER_STATE_AFFINITY_LEVEL1 1 +#define PSCI_POWER_STATE_AFFINITY_LEVEL2 2 +#define PSCI_POWER_STATE_AFFINITY_LEVEL3 3 struct psci_power_state { u16 id; -- cgit v1.2.3 From 4085cd73587287185684f16cae616b115290347d Mon Sep 17 00:00:00 2001 From: Achin Gupta Date: Sun, 10 Mar 2013 21:31:29 +0000 Subject: ARM: psci: convert psci '-EALREADYON' error code to linux '-EAGAIN' This patch adds a possible error code of the cpu_on psci api. It indicates that the cpu specified in the cpu_on call is up and running (e.g. the firmware still has not seen the preceding cpu_off call). Signed-off-by: Achin Gupta Signed-off-by: Liviu Dudau --- arch/arm/kernel/psci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c index 36531643cc2..5211f18cd2b 100644 --- a/arch/arm/kernel/psci.c +++ b/arch/arm/kernel/psci.c @@ -42,6 +42,7 @@ static u32 psci_function_id[PSCI_FN_MAX]; #define PSCI_RET_EOPNOTSUPP -1 #define PSCI_RET_EINVAL -2 #define PSCI_RET_EPERM -3 +#define PSCI_RET_EALREADYON -4 static int psci_to_linux_errno(int errno) { @@ -54,6 +55,8 @@ static int psci_to_linux_errno(int errno) return -EINVAL; case PSCI_RET_EPERM: return -EPERM; + case PSCI_RET_EALREADYON: + return -EAGAIN; }; return -EINVAL; -- cgit v1.2.3 From 165e90de39107bc42493facb88aeab90d56b917e Mon Sep 17 00:00:00 2001 From: Achin Gupta Date: Sun, 16 Dec 2012 23:11:32 +0000 Subject: ARM: psci: add probe function to discover presence of a psci implementation This patch adds a probe function to check if the secure firmware has an implementation of the Power State Coordination Interface. 'bL_platform_power_ops' will be implemented by: a. a native backend when Linux runs in secure world b. a psci backend which relies on the secure firmware to implement the power ops presence of b. will be indicated by the psci device node in the device tree. The device node is expected to be populated by the secure firmware if it supports psci. If the native backend detects a psci node then it bails out allowing the psci backend to be registered. Also a dummy 'psci_probe' function is added for the case when psci support is not included. This prevents the build from breaking for tc2 and the rtsm platforms. Signed-off-by: Achin Gupta Signed-off-by: Liviu Dudau --- arch/arm/include/asm/psci.h | 8 ++++++++ arch/arm/kernel/psci.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h index 78ce38ff19f..a079cbee427 100644 --- a/arch/arm/include/asm/psci.h +++ b/arch/arm/include/asm/psci.h @@ -37,4 +37,12 @@ struct psci_operations { extern struct psci_operations psci_ops; +#ifdef CONFIG_ARM_PSCI +extern int __init psci_probe(void); +#else +static inline int psci_probe(void) +{ + return -ENODEV; +} +#endif #endif /* __ASM_ARM_PSCI_H */ diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c index 5211f18cd2b..03c10f65add 100644 --- a/arch/arm/kernel/psci.c +++ b/arch/arm/kernel/psci.c @@ -212,3 +212,16 @@ out_put_node: return 0; } early_initcall(psci_init); + +int __init psci_probe(void) +{ + struct device_node *np; + int ret = -ENODEV; + + np = of_find_matching_node(NULL, psci_of_match); + if (np) + ret = 0; + + of_node_put(np); + return ret; +} -- cgit v1.2.3 From e69ddf69e1d383cf0cd160c5e0d7c2d9993c5a1e Mon Sep 17 00:00:00 2001 From: Achin Gupta Date: Sun, 10 Mar 2013 22:04:29 +0000 Subject: ARM: psci: add cmdline option to enable use of psci This patch adds the 'psci' kernel command line option. Secure firmware cannot yet add a psci device node in the dt to indicate whether it supports psci or not. So in the current dt, the psci device node is present by default. The probe function will always indicate that the secure firmware implements psci irrespective of the address space linux runs in as the same device tree will be used in either case. Hence a kernel cmdline option is required to choose either the native or psci power api backend depending upon the address space linux is running in. Specifying 'psci=enable' in the cmdline will allow Linux running in the non-secure address space to use the same dt but use the psci backend instead of the native backend. It effectively overrides the presence of the native implementation by ensuring registration of the psci backend. Linux running in the secure address space will use the native backend for power management when 'psci=disable' in the cmdline (also the default value i.e. psci backend is disabled by default) or the psci node in the dt is absent. Signed-off-by: Achin Gupta Signed-off-by: Liviu Dudau --- arch/arm/kernel/psci.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c index 03c10f65add..1180801468d 100644 --- a/arch/arm/kernel/psci.c +++ b/arch/arm/kernel/psci.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -26,6 +27,11 @@ struct psci_operations psci_ops; +/* Type of psci support. Currently can only be enabled or disabled */ +#define PSCI_SUP_DISABLED 0 +#define PSCI_SUP_ENABLED 1 + +static unsigned int psci; static int (*invoke_psci_fn)(u32, u32, u32, u32); enum psci_function { @@ -167,6 +173,9 @@ static int __init psci_init(void) const char *method; u32 id; + if (psci == PSCI_SUP_DISABLED) + return 0; + np = of_find_matching_node(NULL, psci_of_match); if (!np) return 0; @@ -218,10 +227,27 @@ int __init psci_probe(void) struct device_node *np; int ret = -ENODEV; - np = of_find_matching_node(NULL, psci_of_match); - if (np) - ret = 0; + if (psci == PSCI_SUP_ENABLED) { + np = of_find_matching_node(NULL, psci_of_match); + if (np) + ret = 0; + } of_node_put(np); return ret; } + +static int __init early_psci(char *val) +{ + int ret = 0; + + if (strcmp(val, "enable") == 0) + psci = PSCI_SUP_ENABLED; + else if (strcmp(val, "disable") == 0) + psci = PSCI_SUP_DISABLED; + else + ret = -EINVAL; + + return ret; +} +early_param("psci", early_psci); -- cgit v1.2.3