1 // SPDX-License-Identifier: GPL-2.0
2 /* leon_pmc.c: LEON Power-down cpu_idle() handler
7 #include <linux/init.h>
10 #include <asm/leon_amba.h>
11 #include <asm/cpu_type.h>
13 #include <asm/processor.h>
15 /* List of Systems that need fixup instructions around power-down instruction */
16 static unsigned int pmc_leon_fixup_ids[] = {
23 static int pmc_leon_need_fixup(void)
25 unsigned int systemid = amba_system_id >> 16;
28 id = &pmc_leon_fixup_ids[0];
39 * CPU idle callback function for systems that need some extra handling
40 * See .../arch/sparc/kernel/process.c
42 static void pmc_leon_idle_fixup(void)
44 /* Prepare an address to a non-cachable region. APB is always
45 * none-cachable. One instruction is executed after the Sleep
46 * instruction, we make sure to read the bus and throw away the
47 * value by accessing a non-cachable area, also we make sure the
48 * MMU does not get a TLB miss here by using the MMU BYPASS ASI.
50 register unsigned int address = (unsigned int)leon3_irqctrl_regs;
52 /* Interrupts need to be enabled to not hang the CPU */
55 __asm__ __volatile__ (
59 : "r"(address), "i"(ASI_LEON_BYPASS));
63 * CPU idle callback function
64 * See .../arch/sparc/kernel/process.c
66 static void pmc_leon_idle(void)
68 /* Interrupts need to be enabled to not hang the CPU */
71 /* For systems without power-down, this will be no-op */
72 __asm__ __volatile__ ("wr %g0, %asr19\n\t");
75 /* Install LEON Power Down function */
76 static int __init leon_pmc_install(void)
78 if (sparc_cpu_model == sparc_leon) {
79 /* Assign power management IDLE handler */
80 if (pmc_leon_need_fixup())
81 sparc_idle = pmc_leon_idle_fixup;
83 sparc_idle = pmc_leon_idle;
85 printk(KERN_INFO "leon: power management initialized\n");
91 /* This driver is not critical to the boot process, don't care
92 * if initialized late.
94 late_initcall(leon_pmc_install);