blob: 7ce589ca54a4fbb8c3b9ea3c5c5235737e1947e7 [file] [log] [blame]
Lorenzo Pieralisid64f84f2014-07-17 10:30:07 +01001/*
2 * ARM64 CPU idle arch support
3 *
4 * Copyright (C) 2014 ARM Ltd.
5 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/of.h>
13#include <linux/of_device.h>
14
15#include <asm/cpuidle.h>
16#include <asm/cpu_ops.h>
17
Daniel Lezcanoc9d62162015-02-02 16:32:46 +010018int arm_cpuidle_init(unsigned int cpu)
Lorenzo Pieralisid64f84f2014-07-17 10:30:07 +010019{
20 int ret = -EOPNOTSUPP;
Lorenzo Pieralisid64f84f2014-07-17 10:30:07 +010021
22 if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_init_idle)
Lorenzo Pieralisi819a8822015-05-13 14:12:46 +010023 ret = cpu_ops[cpu]->cpu_init_idle(cpu);
Lorenzo Pieralisid64f84f2014-07-17 10:30:07 +010024
Lorenzo Pieralisid64f84f2014-07-17 10:30:07 +010025 return ret;
26}
Lorenzo Pieralisiaf3cfdb2015-01-26 18:33:44 +000027
28/**
29 * cpu_suspend() - function to enter a low-power idle state
30 * @arg: argument to pass to CPU suspend operations
31 *
32 * Return: 0 on success, -EOPNOTSUPP if CPU suspend hook not initialized, CPU
33 * operations back-end error code otherwise.
34 */
Sudeep Hollaaf391b12015-06-18 15:41:32 +010035int arm_cpuidle_suspend(int index)
Lorenzo Pieralisiaf3cfdb2015-01-26 18:33:44 +000036{
37 int cpu = smp_processor_id();
38
39 /*
40 * If cpu_ops have not been registered or suspend
41 * has not been initialized, cpu_suspend call fails early.
42 */
43 if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_suspend)
44 return -EOPNOTSUPP;
Sudeep Hollaaf391b12015-06-18 15:41:32 +010045 return cpu_ops[cpu]->cpu_suspend(index);
Lorenzo Pieralisiaf3cfdb2015-01-26 18:33:44 +000046}