aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-19 19:31:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-19 19:31:54 -0400
commitde06dbfa7861c9019eedefc0c356ba86e5098f1b (patch)
tree69986680dc2c500f8c090e8a8c0b17dd7c5c8cbb /drivers/firmware
parentb31a3bc3dbd2f42b61674d37de7f46022e1f6846 (diff)
parent1b3bf847977c2e5974012ddd4b25fef50967d785 (diff)
Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm
Pull ARM updates from Russell King: "Another mixture of changes this time around: - Split XIP linker file from main linker file to make it more maintainable, and various XIP fixes, and clean up a resulting macro. - Decompressor cleanups from Masahiro Yamada - Avoid printing an error for a missing L2 cache - Remove some duplicated symbols in System.map, and move vectors/stubs back into kernel VMA - Various low priority fixes from Arnd - Updates to allow bus match functions to return negative errno values, touching some drivers and the driver core. Greg has acked these changes. - Virtualisation platform udpates form Jean-Philippe Brucker. - Security enhancements from Kees Cook - Rework some Kconfig dependencies and move PSCI idle management code out of arch/arm into drivers/firmware/psci.c - ARM DMA mapping updates, touching media, acked by Mauro. - Fix places in ARM code which should be using virt_to_idmap() so that Keystone2 can work. - Fix Marvell Tauros2 to work again with non-DT boots. - Provide a delay timer for ARM Orion platforms" * 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm: (45 commits) ARM: 8546/1: dma-mapping: refactor to fix coherent+cma+gfp=0 ARM: 8547/1: dma-mapping: store buffer information ARM: 8543/1: decompressor: rename suffix_y to compress-y ARM: 8542/1: decompressor: merge piggy.*.S and simplify Makefile ARM: 8541/1: decompressor: drop redundant FORCE in Makefile ARM: 8540/1: decompressor: use clean-files instead of extra-y to clean files ARM: 8539/1: decompressor: drop more unneeded assignments to "targets" ARM: 8538/1: decompressor: drop unneeded assignments to "targets" ARM: 8532/1: uncompress: mark putc as inline ARM: 8531/1: turn init_new_context into an inline function ARM: 8530/1: remove VIRT_TO_BUS ARM: 8537/1: drop unused DEBUG_RODATA from XIP_KERNEL ARM: 8536/1: mm: hide __start_rodata_section_aligned for non-debug builds ARM: 8535/1: mm: DEBUG_RODATA makes no sense with XIP_KERNEL ARM: 8534/1: virt: fix hyp-stub build for pre-ARMv7 CPUs ARM: make the physical-relative calculation more obvious ARM: 8512/1: proc-v7.S: Adjust stack address when XIP_KERNEL ARM: 8411/1: Add default SPARSEMEM settings ARM: 8503/1: clk_register_clkdev: remove format string interface ARM: 8529/1: remove 'i' and 'zi' targets ...
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/psci.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index f25cd79c8a79..11bfee8b79a9 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -14,6 +14,7 @@
14#define pr_fmt(fmt) "psci: " fmt 14#define pr_fmt(fmt) "psci: " fmt
15 15
16#include <linux/arm-smccc.h> 16#include <linux/arm-smccc.h>
17#include <linux/cpuidle.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
18#include <linux/linkage.h> 19#include <linux/linkage.h>
19#include <linux/of.h> 20#include <linux/of.h>
@@ -21,10 +22,12 @@
21#include <linux/printk.h> 22#include <linux/printk.h>
22#include <linux/psci.h> 23#include <linux/psci.h>
23#include <linux/reboot.h> 24#include <linux/reboot.h>
25#include <linux/slab.h>
24#include <linux/suspend.h> 26#include <linux/suspend.h>
25 27
26#include <uapi/linux/psci.h> 28#include <uapi/linux/psci.h>
27 29
30#include <asm/cpuidle.h>
28#include <asm/cputype.h> 31#include <asm/cputype.h>
29#include <asm/system_misc.h> 32#include <asm/system_misc.h>
30#include <asm/smp_plat.h> 33#include <asm/smp_plat.h>
@@ -244,6 +247,123 @@ static int __init psci_features(u32 psci_func_id)
244 psci_func_id, 0, 0); 247 psci_func_id, 0, 0);
245} 248}
246 249
250#ifdef CONFIG_CPU_IDLE
251static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state);
252
253static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)
254{
255 int i, ret, count = 0;
256 u32 *psci_states;
257 struct device_node *state_node;
258
259 /*
260 * If the PSCI cpu_suspend function hook has not been initialized
261 * idle states must not be enabled, so bail out
262 */
263 if (!psci_ops.cpu_suspend)
264 return -EOPNOTSUPP;
265
266 /* Count idle states */
267 while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states",
268 count))) {
269 count++;
270 of_node_put(state_node);
271 }
272
273 if (!count)
274 return -ENODEV;
275
276 psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL);
277 if (!psci_states)
278 return -ENOMEM;
279
280 for (i = 0; i < count; i++) {
281 u32 state;
282
283 state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i);
284
285 ret = of_property_read_u32(state_node,
286 "arm,psci-suspend-param",
287 &state);
288 if (ret) {
289 pr_warn(" * %s missing arm,psci-suspend-param property\n",
290 state_node->full_name);
291 of_node_put(state_node);
292 goto free_mem;
293 }
294
295 of_node_put(state_node);
296 pr_debug("psci-power-state %#x index %d\n", state, i);
297 if (!psci_power_state_is_valid(state)) {
298 pr_warn("Invalid PSCI power state %#x\n", state);
299 ret = -EINVAL;
300 goto free_mem;
301 }
302 psci_states[i] = state;
303 }
304 /* Idle states parsed correctly, initialize per-cpu pointer */
305 per_cpu(psci_power_state, cpu) = psci_states;
306 return 0;
307
308free_mem:
309 kfree(psci_states);
310 return ret;
311}
312
313int psci_cpu_init_idle(unsigned int cpu)
314{
315 struct device_node *cpu_node;
316 int ret;
317
318 cpu_node = of_get_cpu_node(cpu, NULL);
319 if (!cpu_node)
320 return -ENODEV;
321
322 ret = psci_dt_cpu_init_idle(cpu_node, cpu);
323
324 of_node_put(cpu_node);
325
326 return ret;
327}
328
329static int psci_suspend_finisher(unsigned long index)
330{
331 u32 *state = __this_cpu_read(psci_power_state);
332
333 return psci_ops.cpu_suspend(state[index - 1],
334 virt_to_phys(cpu_resume));
335}
336
337int psci_cpu_suspend_enter(unsigned long index)
338{
339 int ret;
340 u32 *state = __this_cpu_read(psci_power_state);
341 /*
342 * idle state index 0 corresponds to wfi, should never be called
343 * from the cpu_suspend operations
344 */
345 if (WARN_ON_ONCE(!index))
346 return -EINVAL;
347
348 if (!psci_power_state_loses_context(state[index - 1]))
349 ret = psci_ops.cpu_suspend(state[index - 1], 0);
350 else
351 ret = cpu_suspend(index, psci_suspend_finisher);
352
353 return ret;
354}
355
356/* ARM specific CPU idle operations */
357#ifdef CONFIG_ARM
358static struct cpuidle_ops psci_cpuidle_ops __initdata = {
359 .suspend = psci_cpu_suspend_enter,
360 .init = psci_dt_cpu_init_idle,
361};
362
363CPUIDLE_METHOD_OF_DECLARE(psci, "arm,psci", &psci_cpuidle_ops);
364#endif
365#endif
366
247static int psci_system_suspend(unsigned long unused) 367static int psci_system_suspend(unsigned long unused)
248{ 368{
249 return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND), 369 return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND),