2 * Copyright (C) 2012-2014 ROCKCHIP, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/cpuidle.h>
10 #include <linux/export.h>
11 #include <linux/suspend.h>
12 #include <linux/err.h>
13 #include <linux/irqchip/arm-gic.h>
14 #include <asm/cpuidle.h>
15 #include <asm/cputype.h>
18 #include <linux/of_address.h>
19 #include <linux/rockchip/cpu.h>
21 static void __iomem *gic_cpu_base;
23 static int rockchip_ca9_cpuidle_enter(struct cpuidle_device *dev,
24 struct cpuidle_driver *drv, int index)
28 } while (readl_relaxed(gic_cpu_base + GIC_CPU_HIGHPRI) == 0x3FF);
32 static struct cpuidle_driver rockchip_ca9_cpuidle_driver = {
33 .name = "rockchip_ca9_cpuidle",
35 .states[0] = ARM_CPUIDLE_WFI_STATE,
39 static int __init rockchip_ca9_cpuidle_init(void)
41 struct device_node *np;
44 if (!cpu_is_rockchip())
46 if (read_cpuid_part() != ARM_CPU_PART_CORTEX_A9)
48 np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic");
51 gic_cpu_base = of_iomap(np, 1);
53 pr_err("%s: failed to map gic cpu registers\n", __func__);
56 rockchip_ca9_cpuidle_driver.states[0].enter = rockchip_ca9_cpuidle_enter;
57 ret = cpuidle_register(&rockchip_ca9_cpuidle_driver, NULL);
59 pr_err("%s: failed to register cpuidle driver: %d\n", __func__, ret);
64 device_initcall(rockchip_ca9_cpuidle_init);