20 #include <linux/errno.h>
21 #include <linux/sched.h>
22 #include <linux/kernel.h>
24 #include <linux/stddef.h>
27 #include <linux/tty.h>
30 #include <linux/reboot.h>
34 #include <linux/pci.h>
35 #include <linux/utsname.h>
36 #include <linux/adb.h>
37 #include <linux/export.h>
45 #include <asm/processor.h>
47 #include <asm/pgtable.h>
50 #include <asm/pci-bridge.h>
51 #include <asm/iommu.h>
53 #include <asm/machdep.h>
56 #include <asm/nvram.h>
61 #include <asm/i8259.h>
80 static void pSeries_show_cpuinfo(
struct seq_file *
m)
83 const char *
model =
"";
88 seq_printf(m,
"machine\t\t: CHRP %s\n", model);
95 static void __init fwnmi_init(
void)
97 unsigned long system_reset_addr, machine_check_addr;
99 int ibm_nmi_register =
rtas_token(
"ibm,nmi-register");
100 if (ibm_nmi_register == RTAS_UNKNOWN_SERVICE)
108 if (0 ==
rtas_call(ibm_nmi_register, 2, 1,
NULL, system_reset_addr,
113 static void pseries_8259_cascade(
unsigned int irq,
struct irq_desc *
desc)
118 if (cascade_irq !=
NO_IRQ)
124 static void __init pseries_setup_i8259_cascade(
void)
127 unsigned int cascade;
132 for_each_node_by_type(np,
"interrupt-controller") {
149 pr_debug(
"pic: cascade mapped to irq %d\n", cascade);
151 for (old = of_node_get(found); old !=
NULL ; old = np) {
162 intack = addrp[naddr-1];
164 intack |= ((
unsigned long)addrp[naddr-2]) << 32;
170 irq_set_chained_handler(cascade, pseries_8259_cascade);
173 static void __init pseries_mpic_init_IRQ(
void)
176 const unsigned int *opprop;
177 unsigned long openpic_addr = 0;
178 int naddr,
n,
i, opplen;
185 openpic_addr = of_read_number(opprop, naddr);
190 BUG_ON(openpic_addr == 0);
193 mpic =
mpic_alloc(pSeries_mpic_node, openpic_addr,
194 MPIC_NO_RESET, 16, 0,
" MPIC ");
198 opplen /=
sizeof(
u32);
199 for (n = 0, i = naddr; i < opplen; i += naddr, n++) {
200 unsigned long isuaddr = of_read_number(opprop + i, naddr);
211 pseries_setup_i8259_cascade();
214 static void __init pseries_xics_init_IRQ(
void)
217 pseries_setup_i8259_cascade();
220 static void pseries_lpar_enable_pmcs(
void)
222 unsigned long set,
reset;
226 plpar_hcall_norets(H_PERFMON,
set, reset);
229 static void __init pseries_discover_pic(
void)
235 "interrupt-controller"));) {
237 if (
strstr(typep,
"open-pic")) {
238 pSeries_mpic_node = of_node_get(np);
239 ppc_md.init_IRQ = pseries_mpic_init_IRQ;
243 }
else if (
strstr(typep,
"ppc-xicp")) {
244 ppc_md.init_IRQ = pseries_xics_init_IRQ;
251 " interrupt-controller\n");
261 case PSERIES_RECONFIG_ADD:
278 .notifier_call = pci_dn_reconfig_notifier,
283 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
289 static int alloc_dispatch_logs(
void)
292 struct paca_struct *
pp;
293 struct dtl_entry *
dtl;
295 if (!firmware_has_feature(FW_FEATURE_SPLPAR))
305 pr_warn(
"Failed to allocate dispatch trace log for cpu %d\n",
307 pr_warn(
"Stolen time statistics will be unreliable\n");
312 pp->dispatch_log = dtl;
313 pp->dispatch_log_end = dtl + N_DISPATCH_LOG;
318 dtl = get_paca()->dispatch_log;
319 get_paca()->dtl_ridx = 0;
320 get_paca()->dtl_curr = dtl;
321 get_paca()->lppaca_ptr->dtl_idx = 0;
324 dtl->enqueue_to_dispatch_time = DISPATCH_LOG_BYTES;
327 pr_err(
"WARNING: DTL registration of cpu %d (hw %d) failed "
330 get_paca()->lppaca_ptr->dtl_enable_mask = 2;
335 static inline int alloc_dispatch_logs(
void)
341 static int alloc_dispatch_log_kmem_cache(
void)
344 DISPATCH_LOG_BYTES, 0,
NULL);
346 pr_warn(
"Failed to create dispatch trace log buffer cache\n");
347 pr_warn(
"Stolen time statistics will be unreliable\n");
351 return alloc_dispatch_logs();
355 static void pSeries_idle(
void)
370 static void __init pSeries_setup_arch(
void)
375 pseries_discover_pic();
387 pci_add_flags(PCI_PROBE_ONLY);
396 if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
398 ppc_md.power_save = pSeries_idle;
401 if (firmware_has_feature(FW_FEATURE_LPAR))
402 ppc_md.enable_pmcs = pseries_lpar_enable_pmcs;
404 ppc_md.enable_pmcs = power4_enable_pmcs;
407 static int __init pSeries_init_panel(
void)
410 ppc_md.progress(
"Linux ppc64\n", 0);
417 static int pseries_set_dabr(
unsigned long dabr,
unsigned long dabrx)
419 return plpar_hcall_norets(H_SET_DABR, dabr);
422 static int pseries_set_xdabr(
unsigned long dabr,
unsigned long dabrx)
425 if (dabrx == 0 && dabr == 0)
428 dabrx &= DABRX_KERNEL | DABRX_USER;
430 return plpar_hcall_norets(H_SET_XDABR, dabr, dabrx);
433 #define CMO_CHARACTERISTICS_TOKEN 44
434 #define CMO_MAXLENGTH 1026
438 struct hvcall_mpp_x_data mpp_x_data;
440 if (firmware_has_feature(FW_FEATURE_CMO) && !
h_get_mpp_x(&mpp_x_data))
441 powerpc_firmware_features |= FW_FEATURE_XCMO;
443 powerpc_firmware_features &= ~FW_FEATURE_XCMO;
456 pr_debug(
" -> fw_cmo_feature_init()\n");
457 spin_lock(&rtas_data_buf_lock);
458 memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE);
465 if (call_status != 0) {
466 spin_unlock(&rtas_data_buf_lock);
468 pr_debug(
" <- fw_cmo_feature_init()\n");
473 ptr = rtas_data_buf + 2;
476 while (*ptr && (ptr <= end)) {
483 }
else if (ptr[0] ==
'\0' || ptr[0] ==
',') {
488 pr_debug(
"Malformed key/value pair\n");
493 if (0 ==
strcmp(key,
"CMOPageSize"))
495 else if (0 ==
strcmp(key,
"PrPSP"))
497 else if (0 ==
strcmp(key,
"SecPSP"))
499 value = key = ptr + 1;
514 powerpc_firmware_features |= FW_FEATURE_CMO;
519 spin_unlock(&rtas_data_buf_lock);
520 pr_debug(
" <- fw_cmo_feature_init()\n");
526 static void __init pSeries_init_early(
void)
528 pr_debug(
" -> pSeries_init_early()\n");
530 #ifdef CONFIG_HVC_CONSOLE
531 if (firmware_has_feature(FW_FEATURE_LPAR))
534 if (firmware_has_feature(FW_FEATURE_XDABR))
535 ppc_md.set_dabr = pseries_set_xdabr;
536 else if (firmware_has_feature(FW_FEATURE_DABR))
537 ppc_md.set_dabr = pseries_set_dabr;
542 pr_debug(
" <- pSeries_init_early()\n");
549 static int __init pSeries_probe_hypertas(
unsigned long node,
550 const char *uname,
int depth,
553 const char *hypertas;
557 (
strcmp(uname,
"rtas") != 0 &&
strcmp(uname,
"rtas@0") != 0))
560 hypertas = of_get_flat_dt_prop(node,
"ibm,hypertas-functions", &len);
564 powerpc_firmware_features |= FW_FEATURE_LPAR;
570 static int __init pSeries_probe(
void)
572 unsigned long root = of_get_flat_dt_root();
573 char *
dtype = of_get_flat_dt_prop(root,
"device_type",
NULL);
577 if (
strcmp(dtype,
"chrp"))
583 if (of_flat_dt_is_compatible(root,
"IBM,CPBW-1.0") ||
584 of_flat_dt_is_compatible(root,
"IBM,CBEA"))
587 pr_debug(
"pSeries detected, looking for LPAR capability...\n");
590 of_scan_flat_dt(pSeries_probe_hypertas,
NULL);
592 if (firmware_has_feature(FW_FEATURE_LPAR))
598 (powerpc_firmware_features & FW_FEATURE_LPAR) ?
"" :
" not");
603 static int pSeries_pci_probe_mode(
struct pci_bus *
bus)
605 if (firmware_has_feature(FW_FEATURE_LPAR))
606 return PCI_PROBE_DEVTREE;
607 return PCI_PROBE_NORMAL;
619 static void pSeries_power_off(
void)
622 int rtas_poweroff_ups_token =
rtas_token(
"ibm,power-off-ups");
628 rtas_poweroff_ups_token == RTAS_UNKNOWN_SERVICE) {
644 .probe = pSeries_probe,
645 .setup_arch = pSeries_setup_arch,
646 .init_early = pSeries_init_early,
647 .show_cpuinfo = pSeries_show_cpuinfo,
650 .pci_probe_mode = pSeries_pci_probe_mode,
652 .power_off = pSeries_power_off,