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>
10 #include <asm/cpu_type.h>
12 #include <asm/processor.h>
14 /* List of Systems that need fixup instructions around power-down instruction */
15 static unsigned int pmc_leon_fixup_ids
[] = {
22 static int pmc_leon_need_fixup(void)
24 unsigned int systemid
= amba_system_id
>> 16;
27 id
= &pmc_leon_fixup_ids
[0];
38 * CPU idle callback function for systems that need some extra handling
39 * See .../arch/sparc/kernel/process.c
41 static void pmc_leon_idle_fixup(void)
43 /* Prepare an address to a non-cachable region. APB is always
44 * none-cachable. One instruction is executed after the Sleep
45 * instruction, we make sure to read the bus and throw away the
46 * value by accessing a non-cachable area, also we make sure the
47 * MMU does not get a TLB miss here by using the MMU BYPASS ASI.
49 register unsigned int address
= (unsigned int)leon3_irqctrl_regs
;
51 /* Interrupts need to be enabled to not hang the CPU */
54 __asm__
__volatile__ (
58 : "r"(address
), "i"(ASI_LEON_BYPASS
));
62 * CPU idle callback function
63 * See .../arch/sparc/kernel/process.c
65 static void pmc_leon_idle(void)
67 /* Interrupts need to be enabled to not hang the CPU */
70 /* For systems without power-down, this will be no-op */
71 __asm__
__volatile__ ("wr %g0, %asr19\n\t");
74 /* Install LEON Power Down function */
75 static int __init
leon_pmc_install(void)
77 if (sparc_cpu_model
== sparc_leon
) {
78 /* Assign power management IDLE handler */
79 if (pmc_leon_need_fixup())
80 sparc_idle
= pmc_leon_idle_fixup
;
82 sparc_idle
= pmc_leon_idle
;
84 printk(KERN_INFO
"leon: power management initialized\n");
90 /* This driver is not critical to the boot process, don't care
91 * if initialized late.
93 late_initcall(leon_pmc_install
);