]> rtime.felk.cvut.cz Git - linux-imx.git/blob - arch/sparc/kernel/leon_pmc.c
ACPI / EC: Add HP Folio 13 to ec_dmi_table in order to skip DSDT scan
[linux-imx.git] / arch / sparc / kernel / leon_pmc.c
1 /* leon_pmc.c: LEON Power-down cpu_idle() handler
2  *
3  * Copyright (C) 2011 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB
4  */
5
6 #include <linux/init.h>
7 #include <linux/pm.h>
8
9 #include <asm/leon_amba.h>
10 #include <asm/cpu_type.h>
11 #include <asm/leon.h>
12 #include <asm/processor.h>
13
14 /* List of Systems that need fixup instructions around power-down instruction */
15 unsigned int pmc_leon_fixup_ids[] = {
16         AEROFLEX_UT699,
17         GAISLER_GR712RC,
18         LEON4_NEXTREME1,
19         0
20 };
21
22 int pmc_leon_need_fixup(void)
23 {
24         unsigned int systemid = amba_system_id >> 16;
25         unsigned int *id;
26
27         id = &pmc_leon_fixup_ids[0];
28         while (*id != 0) {
29                 if (*id == systemid)
30                         return 1;
31                 id++;
32         }
33
34         return 0;
35 }
36
37 /*
38  * CPU idle callback function for systems that need some extra handling
39  * See .../arch/sparc/kernel/process.c
40  */
41 void pmc_leon_idle_fixup(void)
42 {
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.
48          */
49         register unsigned int address = (unsigned int)leon3_irqctrl_regs;
50         __asm__ __volatile__ (
51                 "wr     %%g0, %%asr19\n"
52                 "lda    [%0] %1, %%g0\n"
53                 :
54                 : "r"(address), "i"(ASI_LEON_BYPASS));
55 }
56
57 /*
58  * CPU idle callback function
59  * See .../arch/sparc/kernel/process.c
60  */
61 void pmc_leon_idle(void)
62 {
63         /* For systems without power-down, this will be no-op */
64         __asm__ __volatile__ ("wr       %g0, %asr19\n\t");
65 }
66
67 /* Install LEON Power Down function */
68 static int __init leon_pmc_install(void)
69 {
70         if (sparc_cpu_model == sparc_leon) {
71                 /* Assign power management IDLE handler */
72                 if (pmc_leon_need_fixup())
73                         sparc_idle = pmc_leon_idle_fixup;
74                 else
75                         sparc_idle = pmc_leon_idle;
76
77                 printk(KERN_INFO "leon: power management initialized\n");
78         }
79
80         return 0;
81 }
82
83 /* This driver is not critical to the boot process, don't care
84  * if initialized late.
85  */
86 late_initcall(leon_pmc_install);