blob: a79610e723b3e613b843e9b71d5752fbe967a437 [file] [log] [blame]
Thomas Gleixner9952f692019-05-28 10:10:04 -07001// SPDX-License-Identifier: GPL-2.0-only
Michal Simekbd2a3372013-06-04 07:17:39 +00002/*
3 * Copyright (C) 2012-2013 Xilinx
4 *
5 * CPU idle support for Xilinx Zynq
6 *
7 * based on arch/arm/mach-at91/cpuidle.c
8 *
Michal Simekbd2a3372013-06-04 07:17:39 +00009 * The cpu idle uses wait-for-interrupt and RAM self refresh in order
10 * to implement two idle states -
11 * #1 wait-for-interrupt
12 * #2 wait-for-interrupt and RAM self refresh
13 *
14 * Maintainer: Michal Simek <michal.simek@xilinx.com>
15 */
16
17#include <linux/init.h>
Michal Simekbd2a3372013-06-04 07:17:39 +000018#include <linux/cpuidle.h>
Daniel Lezcano3e8ceca2013-09-21 18:41:02 +020019#include <linux/platform_device.h>
Michal Simekbd2a3372013-06-04 07:17:39 +000020#include <asm/cpuidle.h>
21
22#define ZYNQ_MAX_STATES 2
23
24/* Actual code that puts the SoC in different idle states */
25static int zynq_enter_idle(struct cpuidle_device *dev,
26 struct cpuidle_driver *drv, int index)
27{
Michal Simekbd2a3372013-06-04 07:17:39 +000028 /* Add code for DDR self refresh start */
29 cpu_do_idle();
30
Michal Simekbd2a3372013-06-04 07:17:39 +000031 return index;
32}
33
34static struct cpuidle_driver zynq_idle_driver = {
35 .name = "zynq_idle",
36 .owner = THIS_MODULE,
37 .states = {
38 ARM_CPUIDLE_WFI_STATE,
39 {
40 .enter = zynq_enter_idle,
41 .exit_latency = 10,
42 .target_residency = 10000,
Michal Simekbd2a3372013-06-04 07:17:39 +000043 .name = "RAM_SR",
44 .desc = "WFI and RAM Self Refresh",
45 },
46 },
47 .safe_state_index = 0,
48 .state_count = ZYNQ_MAX_STATES,
49};
50
51/* Initialize CPU idle by registering the idle states */
Daniel Lezcano3e8ceca2013-09-21 18:41:02 +020052static int zynq_cpuidle_probe(struct platform_device *pdev)
Michal Simekbd2a3372013-06-04 07:17:39 +000053{
Michal Simekbd2a3372013-06-04 07:17:39 +000054 pr_info("Xilinx Zynq CpuIdle Driver started\n");
55
56 return cpuidle_register(&zynq_idle_driver, NULL);
57}
58
Daniel Lezcano3e8ceca2013-09-21 18:41:02 +020059static struct platform_driver zynq_cpuidle_driver = {
60 .driver = {
61 .name = "cpuidle-zynq",
Daniel Lezcano3e8ceca2013-09-21 18:41:02 +020062 },
63 .probe = zynq_cpuidle_probe,
64};
Paul Gortmaker090d1cf2015-05-01 20:10:57 -040065builtin_platform_driver(zynq_cpuidle_driver);