diff options
author | Daniel Hellstrom <daniel@gaisler.com> | 2011-01-26 20:26:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-16 21:19:04 -0400 |
commit | 7279b82cb1975ba4e337a549757f17418cfdffad (patch) | |
tree | be97311b59bf95471ab2aa6e303e92c9a4427ac9 /arch/sparc/kernel/leon_pmc.c | |
parent | 684151a75bf25f5aeb8a23010da91a34e17b7353 (diff) |
SPARC/LEON: power down instruction different of different LEONs
The way a LEON is powered down is implemented differently depending
on CHIP type. The AMBA Plug&Play system ID tells revision of GRLIB
and CHIP.
This is for example needed by the GR-LEON4-ITX board and the UT699.
Previously the power down support for LEON was limited to SMP, now
both SMP and UP systems use the instruction.
Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/leon_pmc.c')
-rw-r--r-- | arch/sparc/kernel/leon_pmc.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c new file mode 100644 index 000000000000..519ca923f59f --- /dev/null +++ b/arch/sparc/kernel/leon_pmc.c | |||
@@ -0,0 +1,82 @@ | |||
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/leon.h> | ||
11 | |||
12 | /* List of Systems that need fixup instructions around power-down instruction */ | ||
13 | unsigned int pmc_leon_fixup_ids[] = { | ||
14 | AEROFLEX_UT699, | ||
15 | GAISLER_GR712RC, | ||
16 | LEON4_NEXTREME1, | ||
17 | 0 | ||
18 | }; | ||
19 | |||
20 | int pmc_leon_need_fixup(void) | ||
21 | { | ||
22 | unsigned int systemid = amba_system_id >> 16; | ||
23 | unsigned int *id; | ||
24 | |||
25 | id = &pmc_leon_fixup_ids[0]; | ||
26 | while (*id != 0) { | ||
27 | if (*id == systemid) | ||
28 | return 1; | ||
29 | id++; | ||
30 | } | ||
31 | |||
32 | return 0; | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * CPU idle callback function for systems that need some extra handling | ||
37 | * See .../arch/sparc/kernel/process.c | ||
38 | */ | ||
39 | void pmc_leon_idle_fixup(void) | ||
40 | { | ||
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. | ||
46 | */ | ||
47 | register unsigned int address = (unsigned int)leon3_irqctrl_regs; | ||
48 | __asm__ __volatile__ ( | ||
49 | "mov %%g0, %%asr19\n" | ||
50 | "lda [%0] %1, %%g0\n" | ||
51 | : | ||
52 | : "r"(address), "i"(ASI_LEON_BYPASS)); | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * CPU idle callback function | ||
57 | * See .../arch/sparc/kernel/process.c | ||
58 | */ | ||
59 | void pmc_leon_idle(void) | ||
60 | { | ||
61 | /* For systems without power-down, this will be no-op */ | ||
62 | __asm__ __volatile__ ("mov %g0, %asr19\n\t"); | ||
63 | } | ||
64 | |||
65 | /* Install LEON Power Down function */ | ||
66 | static int __init leon_pmc_install(void) | ||
67 | { | ||
68 | /* Assign power management IDLE handler */ | ||
69 | if (pmc_leon_need_fixup()) | ||
70 | pm_idle = pmc_leon_idle_fixup; | ||
71 | else | ||
72 | pm_idle = pmc_leon_idle; | ||
73 | |||
74 | printk(KERN_INFO "leon: power management initialized\n"); | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | /* This driver is not critical to the boot process, don't care | ||
80 | * if initialized late. | ||
81 | */ | ||
82 | late_initcall(leon_pmc_install); | ||