x86, efi: Set runtime_version to the EFI spec revision
[linux/fpc-iii.git] / arch / powerpc / platforms / powernv / setup.c
blobdb1ad1c8f68fd1ed18a91fbc542a55c9e31d60b1
1 /*
2 * PowerNV setup code.
4 * Copyright 2011 IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #undef DEBUG
14 #include <linux/cpu.h>
15 #include <linux/errno.h>
16 #include <linux/sched.h>
17 #include <linux/kernel.h>
18 #include <linux/tty.h>
19 #include <linux/reboot.h>
20 #include <linux/init.h>
21 #include <linux/console.h>
22 #include <linux/delay.h>
23 #include <linux/irq.h>
24 #include <linux/seq_file.h>
25 #include <linux/of.h>
26 #include <linux/interrupt.h>
27 #include <linux/bug.h>
29 #include <asm/machdep.h>
30 #include <asm/firmware.h>
31 #include <asm/xics.h>
32 #include <asm/rtas.h>
33 #include <asm/opal.h>
35 #include "powernv.h"
37 static void __init pnv_setup_arch(void)
39 /* Initialize SMP */
40 pnv_smp_init();
42 /* Setup PCI */
43 pnv_pci_init();
45 /* Setup RTC and NVRAM callbacks */
46 if (firmware_has_feature(FW_FEATURE_OPAL))
47 opal_nvram_init();
49 /* Enable NAP mode */
50 powersave_nap = 1;
52 /* XXX PMCS */
55 static void __init pnv_init_early(void)
57 #ifdef CONFIG_HVC_OPAL
58 if (firmware_has_feature(FW_FEATURE_OPAL))
59 hvc_opal_init_early();
60 else
61 #endif
62 add_preferred_console("hvc", 0, NULL);
65 static void __init pnv_init_IRQ(void)
67 xics_init();
69 WARN_ON(!ppc_md.get_irq);
72 static void pnv_show_cpuinfo(struct seq_file *m)
74 struct device_node *root;
75 const char *model = "";
77 root = of_find_node_by_path("/");
78 if (root)
79 model = of_get_property(root, "model", NULL);
80 seq_printf(m, "machine\t\t: PowerNV %s\n", model);
81 if (firmware_has_feature(FW_FEATURE_OPALv2))
82 seq_printf(m, "firmware\t: OPAL v2\n");
83 else if (firmware_has_feature(FW_FEATURE_OPAL))
84 seq_printf(m, "firmware\t: OPAL v1\n");
85 else
86 seq_printf(m, "firmware\t: BML\n");
87 of_node_put(root);
90 static void __noreturn pnv_restart(char *cmd)
92 long rc = OPAL_BUSY;
94 while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
95 rc = opal_cec_reboot();
96 if (rc == OPAL_BUSY_EVENT)
97 opal_poll_events(NULL);
98 else
99 mdelay(10);
101 for (;;)
102 opal_poll_events(NULL);
105 static void __noreturn pnv_power_off(void)
107 long rc = OPAL_BUSY;
109 while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
110 rc = opal_cec_power_down(0);
111 if (rc == OPAL_BUSY_EVENT)
112 opal_poll_events(NULL);
113 else
114 mdelay(10);
116 for (;;)
117 opal_poll_events(NULL);
120 static void __noreturn pnv_halt(void)
122 pnv_power_off();
125 static void pnv_progress(char *s, unsigned short hex)
129 #ifdef CONFIG_KEXEC
130 static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
132 xics_kexec_teardown_cpu(secondary);
134 #endif /* CONFIG_KEXEC */
136 static void __init pnv_setup_machdep_opal(void)
138 ppc_md.get_boot_time = opal_get_boot_time;
139 ppc_md.get_rtc_time = opal_get_rtc_time;
140 ppc_md.set_rtc_time = opal_set_rtc_time;
141 ppc_md.restart = pnv_restart;
142 ppc_md.power_off = pnv_power_off;
143 ppc_md.halt = pnv_halt;
144 ppc_md.machine_check_exception = opal_machine_check;
147 #ifdef CONFIG_PPC_POWERNV_RTAS
148 static void __init pnv_setup_machdep_rtas(void)
150 if (rtas_token("get-time-of-day") != RTAS_UNKNOWN_SERVICE) {
151 ppc_md.get_boot_time = rtas_get_boot_time;
152 ppc_md.get_rtc_time = rtas_get_rtc_time;
153 ppc_md.set_rtc_time = rtas_set_rtc_time;
155 ppc_md.restart = rtas_restart;
156 ppc_md.power_off = rtas_power_off;
157 ppc_md.halt = rtas_halt;
159 #endif /* CONFIG_PPC_POWERNV_RTAS */
161 static int __init pnv_probe(void)
163 unsigned long root = of_get_flat_dt_root();
165 if (!of_flat_dt_is_compatible(root, "ibm,powernv"))
166 return 0;
168 hpte_init_native();
170 if (firmware_has_feature(FW_FEATURE_OPAL))
171 pnv_setup_machdep_opal();
172 #ifdef CONFIG_PPC_POWERNV_RTAS
173 else if (rtas.base)
174 pnv_setup_machdep_rtas();
175 #endif /* CONFIG_PPC_POWERNV_RTAS */
177 pr_debug("PowerNV detected !\n");
179 return 1;
182 define_machine(powernv) {
183 .name = "PowerNV",
184 .probe = pnv_probe,
185 .init_early = pnv_init_early,
186 .setup_arch = pnv_setup_arch,
187 .init_IRQ = pnv_init_IRQ,
188 .show_cpuinfo = pnv_show_cpuinfo,
189 .progress = pnv_progress,
190 .power_save = power7_idle,
191 .calibrate_decr = generic_calibrate_decr,
192 #ifdef CONFIG_KEXEC
193 .kexec_cpu_down = pnv_kexec_cpu_down,
194 #endif