1 /* leon_pmc.c: LEON Power-down cpu_idle() handler
3 * Copyright (C) 2011 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB
6 #include <linux/init.h>
9 #include <asm/leon_amba.h>
12 /* List of Systems that need fixup instructions around power-down instruction */
13 unsigned int pmc_leon_fixup_ids
[] = {
20 int pmc_leon_need_fixup(void)
22 unsigned int systemid
= amba_system_id
>> 16;
25 id
= &pmc_leon_fixup_ids
[0];
36 * CPU idle callback function for systems that need some extra handling
37 * See .../arch/sparc/kernel/process.c
39 void pmc_leon_idle_fixup(void)
41 /* Prepare an address to a non-cachable region. APB is always
42 * none-cachable. One instruction is executed after the Sleep
43 * instruction, we make sure to read the bus and throw away the
44 * value by accessing a non-cachable area, also we make sure the
45 * MMU does not get a TLB miss here by using the MMU BYPASS ASI.
47 register unsigned int address
= (unsigned int)leon3_irqctrl_regs
;
48 __asm__
__volatile__ (
52 : "r"(address
), "i"(ASI_LEON_BYPASS
));
56 * CPU idle callback function
57 * See .../arch/sparc/kernel/process.c
59 void pmc_leon_idle(void)
61 /* For systems without power-down, this will be no-op */
62 __asm__
__volatile__ ("mov %g0, %asr19\n\t");
65 /* Install LEON Power Down function */
66 static int __init
leon_pmc_install(void)
68 /* Assign power management IDLE handler */
69 if (pmc_leon_need_fixup())
70 pm_idle
= pmc_leon_idle_fixup
;
72 pm_idle
= pmc_leon_idle
;
74 printk(KERN_INFO
"leon: power management initialized\n");
79 /* This driver is not critical to the boot process, don't care
80 * if initialized late.
82 late_initcall(leon_pmc_install
);