34 #include <linux/kernel.h>
41 #include <asm/machdep.h>
47 #define CPM_IDLE_WAIT 0
48 #define CPM_IDLE_DOZE 1
72 static unsigned int cpm_set(
unsigned int cpm_reg,
unsigned int mask)
90 static void cpm_idle_wait(
void)
92 unsigned long msr_save;
99 mtmsr(msr_save|MSR_WE|
MSR_EE|MSR_CE|MSR_DE);
106 static void cpm_idle_sleep(
unsigned int mask)
108 unsigned int er_save;
111 er_save = cpm_set(
CPM_ER, mask);
120 static void cpm_idle_doze(
void)
125 static void cpm_idle_config(
int mode)
133 idle_mode[i].enabled = 0;
145 if (idle_mode[i].enabled)
158 const char *buf,
size_t n)
165 len = p ? p - buf :
n;
178 __ATTR(
idle, 0644, cpm_idle_show, cpm_idle_store);
180 static void cpm_idle_config_sysfs(
void)
188 &cpm_idle_attr.
attr);
191 "cpm: failed to create idle sysfs entry\n");
194 static void cpm_idle(
void)
214 static void cpm_suspend_standby(
unsigned int mask)
216 unsigned long tcr_save;
219 tcr_save =
mfspr(SPRN_TCR);
220 mtspr(SPRN_TCR, tcr_save & ~TCR_DIE);
223 cpm_idle_sleep(mask);
226 mtspr(SPRN_TCR, tcr_save);
244 .valid = cpm_suspend_valid,
245 .enter = cpm_suspend_enter,
248 static int cpm_get_uint_property(
struct device_node *np,
254 if (prop ==
NULL || len <
sizeof(
u32))
260 static int __init cpm_init(
void)
263 int dcr_base, dcr_len;
268 ppc_md.power_save = &cpm_idle;
280 if (dcr_base == 0 || dcr_len == 0) {
302 if (cpm_get_uint_property(np,
"er-offset") == 0) {
314 cpm.
unused = cpm_get_uint_property(np,
"unused-units");
316 cpm.
standby = cpm_get_uint_property(np,
"standby");
317 cpm.
suspend = cpm_get_uint_property(np,
"suspend");
329 cpm_idle_config_sysfs();
341 static int __init cpm_powersave_off(
char *
arg)
346 __setup(
"powersave=off", cpm_powersave_off);