Merge tag 'mm-nonmm-stable-2023-04-27-16-01' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / drivers / cpuidle / cpuidle-calxeda.c
CommitLineData
9952f691 1// SPDX-License-Identifier: GPL-2.0-only
be6a98d3
RH
2/*
3 * Copyright 2012 Calxeda, Inc.
4 *
a8e39c35 5 * Based on arch/arm/plat-mxc/cpuidle.c: #v3.7
be6a98d3
RH
6 * Copyright 2012 Freescale Semiconductor, Inc.
7 * Copyright 2012 Linaro Ltd.
8 *
a8e39c35 9 * Maintainer: Rob Herring <rob.herring@calxeda.com>
be6a98d3
RH
10 */
11
12#include <linux/cpuidle.h>
34a5eeb2 13#include <linux/cpu_pm.h>
be6a98d3 14#include <linux/init.h>
a410146c 15#include <linux/mm.h>
60a66e37 16#include <linux/platform_device.h>
be120397
MR
17#include <linux/psci.h>
18
be6a98d3 19#include <asm/cpuidle.h>
be6a98d3 20#include <asm/suspend.h>
be120397
MR
21
22#include <uapi/linux/psci.h>
23
24#define CALXEDA_IDLE_PARAM \
25 ((0 << PSCI_0_2_POWER_STATE_ID_SHIFT) | \
26 (0 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) | \
27 (PSCI_POWER_STATE_TYPE_POWER_DOWN << PSCI_0_2_POWER_STATE_TYPE_SHIFT))
be6a98d3
RH
28
29static int calxeda_idle_finish(unsigned long val)
30{
be120397 31 return psci_ops.cpu_suspend(CALXEDA_IDLE_PARAM, __pa(cpu_resume));
be6a98d3
RH
32}
33
34static int calxeda_pwrdown_idle(struct cpuidle_device *dev,
35 struct cpuidle_driver *drv,
36 int index)
37{
34a5eeb2 38 cpu_pm_enter();
be6a98d3 39 cpu_suspend(0, calxeda_idle_finish);
34a5eeb2
RH
40 cpu_pm_exit();
41
be6a98d3
RH
42 return index;
43}
44
be6a98d3
RH
45static struct cpuidle_driver calxeda_idle_driver = {
46 .name = "calxeda_idle",
be6a98d3
RH
47 .states = {
48 ARM_CPUIDLE_WFI_STATE,
49 {
50 .name = "PG",
51 .desc = "Power Gate",
be6a98d3
RH
52 .exit_latency = 30,
53 .power_usage = 50,
54 .target_residency = 200,
55 .enter = calxeda_pwrdown_idle,
56 },
57 },
58 .state_count = 2,
59};
60
5781532e 61static int calxeda_cpuidle_probe(struct platform_device *pdev)
be6a98d3 62{
0b210d96 63 return cpuidle_register(&calxeda_idle_driver, NULL);
be6a98d3 64}
60a66e37
DL
65
66static struct platform_driver calxeda_cpuidle_plat_driver = {
67 .driver = {
68 .name = "cpuidle-calxeda",
60a66e37
DL
69 },
70 .probe = calxeda_cpuidle_probe,
71};
090d1cf1 72builtin_platform_driver(calxeda_cpuidle_plat_driver);