2 * CPU idle for DaVinci SoCs
4 * Copyright (C) 2009 Texas Instruments Incorporated. http://www.ti.com/
6 * Derived from Marvell Kirkwood CPU idle code
7 * (arch/arm/mach-kirkwood/cpuidle.c)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/cpuidle.h>
19 #include <linux/export.h>
20 #include <asm/cpuidle.h>
25 #define DAVINCI_CPUIDLE_MAX_STATES 2
27 static void __iomem
*ddr2_reg_base
;
28 static bool ddr2_pdown
;
30 static void davinci_save_ddr_power(int enter
, bool pdown
)
34 val
= __raw_readl(ddr2_reg_base
+ DDR2_SDRCR_OFFSET
);
40 val
&= ~DDR2_SRPD_BIT
;
41 val
|= DDR2_LPMODEN_BIT
;
43 val
&= ~(DDR2_SRPD_BIT
| DDR2_LPMODEN_BIT
);
46 __raw_writel(val
, ddr2_reg_base
+ DDR2_SDRCR_OFFSET
);
49 /* Actual code that puts the SoC in different idle states */
50 static int davinci_enter_idle(struct cpuidle_device
*dev
,
51 struct cpuidle_driver
*drv
, int index
)
53 davinci_save_ddr_power(1, ddr2_pdown
);
55 davinci_save_ddr_power(0, ddr2_pdown
);
60 static struct cpuidle_driver davinci_idle_driver
= {
61 .name
= "cpuidle-davinci",
63 .states
[0] = ARM_CPUIDLE_WFI_STATE
,
65 .enter
= davinci_enter_idle
,
67 .target_residency
= 10000,
69 .desc
= "WFI and DDR Self Refresh",
71 .state_count
= DAVINCI_CPUIDLE_MAX_STATES
,
74 static int __init
davinci_cpuidle_probe(struct platform_device
*pdev
)
76 struct davinci_cpuidle_config
*pdata
= pdev
->dev
.platform_data
;
79 dev_err(&pdev
->dev
, "cannot get platform data\n");
83 ddr2_reg_base
= pdata
->ddr2_ctlr_base
;
85 ddr2_pdown
= pdata
->ddr2_pdown
;
87 return cpuidle_register(&davinci_idle_driver
, NULL
);
90 static struct platform_driver davinci_cpuidle_driver
= {
92 .name
= "cpuidle-davinci",
96 static int __init
davinci_cpuidle_init(void)
98 return platform_driver_probe(&davinci_cpuidle_driver
,
99 davinci_cpuidle_probe
);
101 device_initcall(davinci_cpuidle_init
);