0001
0002
0003
0004
0005
0006
0007 #include <linux/init.h>
0008 #include <linux/pm.h>
0009
0010 #include <asm/leon_amba.h>
0011 #include <asm/cpu_type.h>
0012 #include <asm/leon.h>
0013 #include <asm/processor.h>
0014
0015
0016 static unsigned int pmc_leon_fixup_ids[] = {
0017 AEROFLEX_UT699,
0018 GAISLER_GR712RC,
0019 LEON4_NEXTREME1,
0020 0
0021 };
0022
0023 static int pmc_leon_need_fixup(void)
0024 {
0025 unsigned int systemid = amba_system_id >> 16;
0026 unsigned int *id;
0027
0028 id = &pmc_leon_fixup_ids[0];
0029 while (*id != 0) {
0030 if (*id == systemid)
0031 return 1;
0032 id++;
0033 }
0034
0035 return 0;
0036 }
0037
0038
0039
0040
0041
0042 static void pmc_leon_idle_fixup(void)
0043 {
0044
0045
0046
0047
0048
0049
0050 register unsigned int address = (unsigned int)leon3_irqctrl_regs;
0051
0052
0053 raw_local_irq_enable();
0054
0055 __asm__ __volatile__ (
0056 "wr %%g0, %%asr19\n"
0057 "lda [%0] %1, %%g0\n"
0058 :
0059 : "r"(address), "i"(ASI_LEON_BYPASS));
0060 }
0061
0062
0063
0064
0065
0066 static void pmc_leon_idle(void)
0067 {
0068
0069 raw_local_irq_enable();
0070
0071
0072 __asm__ __volatile__ ("wr %g0, %asr19\n\t");
0073 }
0074
0075
0076 static int __init leon_pmc_install(void)
0077 {
0078 if (sparc_cpu_model == sparc_leon) {
0079
0080 if (pmc_leon_need_fixup())
0081 sparc_idle = pmc_leon_idle_fixup;
0082 else
0083 sparc_idle = pmc_leon_idle;
0084
0085 printk(KERN_INFO "leon: power management initialized\n");
0086 }
0087
0088 return 0;
0089 }
0090
0091
0092
0093
0094 late_initcall(leon_pmc_install);