Skip to content

Commit 55190f8

Browse files
committed
powerpc: Add skeleton PowerNV platform
This adds a skeletton for the new Power "Non Virtualized" platform which will be used by machines supporting running without an hypervisor, for example in order to run KVM. These machines will be using a new firmware called OPAL for which the support will be provided by later patches. The PowerNV platform is intended to be also usable under the BML environment used internally for early CPU bringup which is why the code also supports using RTAS instead of OPAL in various places. Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent e550592 commit 55190f8

File tree

8 files changed

+262
-0
lines changed

8 files changed

+262
-0
lines changed

arch/powerpc/boot/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ quiet_cmd_wrap = WRAP $@
171171
$(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
172172

173173
image-$(CONFIG_PPC_PSERIES) += zImage.pseries
174+
image-$(CONFIG_PPC_POWERNV) += zImage.pseries
174175
image-$(CONFIG_PPC_MAPLE) += zImage.maple
175176
image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
176177
image-$(CONFIG_PPC_PS3) += dtbImage.ps3

arch/powerpc/platforms/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
menu "Platform support"
22

3+
source "arch/powerpc/platforms/powernv/Kconfig"
34
source "arch/powerpc/platforms/pseries/Kconfig"
45
source "arch/powerpc/platforms/iseries/Kconfig"
56
source "arch/powerpc/platforms/chrp/Kconfig"

arch/powerpc/platforms/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj-$(CONFIG_PPC_82xx) += 82xx/
1414
obj-$(CONFIG_PPC_83xx) += 83xx/
1515
obj-$(CONFIG_FSL_SOC_BOOKE) += 85xx/
1616
obj-$(CONFIG_PPC_86xx) += 86xx/
17+
obj-$(CONFIG_PPC_POWERNV) += powernv/
1718
obj-$(CONFIG_PPC_PSERIES) += pseries/
1819
obj-$(CONFIG_PPC_ISERIES) += iseries/
1920
obj-$(CONFIG_PPC_MAPLE) += maple/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
config PPC_POWERNV
2+
depends on PPC64 && PPC_BOOK3S
3+
bool "IBM PowerNV (Non-Virtualized) platform support"
4+
select PPC_RTAS
5+
select PPC_NATIVE
6+
select PPC_XICS
7+
select PPC_ICP_NATIVE
8+
select PPC_ICS_RTAS
9+
select PPC_P7_NAP
10+
select PPC_PCI_CHOICE if EMBEDDED
11+
default y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
obj-y += setup.o
2+
obj-$(CONFIG_SMP) += smp.o
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef _POWERNV_H
2+
#define _POWERNV_H
3+
4+
#ifdef CONFIG_SMP
5+
extern void pnv_smp_init(void);
6+
#else
7+
static inline void pnv_smp_init(void) { }
8+
#endif
9+
10+
#endif /* _POWERNV_H */
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
* PowerNV setup code.
3+
*
4+
* Copyright 2011 IBM Corp.
5+
*
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.
10+
*/
11+
12+
#undef DEBUG
13+
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>
28+
29+
#include <asm/machdep.h>
30+
#include <asm/firmware.h>
31+
#include <asm/xics.h>
32+
33+
#include "powernv.h"
34+
35+
static void __init pnv_setup_arch(void)
36+
{
37+
/* Force console to hvc for now until we have sorted out the
38+
* real console situation for the platform. This will make
39+
* hvc_udbg work at least.
40+
*/
41+
add_preferred_console("hvc", 0, NULL);
42+
43+
/* Initialize SMP */
44+
pnv_smp_init();
45+
46+
/* XXX PCI */
47+
48+
/* XXX NVRAM */
49+
50+
/* Enable NAP mode */
51+
powersave_nap = 1;
52+
53+
/* XXX PMCS */
54+
}
55+
56+
static void __init pnv_init_early(void)
57+
{
58+
/* XXX IOMMU */
59+
}
60+
61+
static void __init pnv_init_IRQ(void)
62+
{
63+
xics_init();
64+
65+
WARN_ON(!ppc_md.get_irq);
66+
}
67+
68+
static void pnv_show_cpuinfo(struct seq_file *m)
69+
{
70+
struct device_node *root;
71+
const char *model = "";
72+
73+
root = of_find_node_by_path("/");
74+
if (root)
75+
model = of_get_property(root, "model", NULL);
76+
seq_printf(m, "machine\t\t: PowerNV %s\n", model);
77+
of_node_put(root);
78+
}
79+
80+
static void pnv_restart(char *cmd)
81+
{
82+
for (;;);
83+
}
84+
85+
static void pnv_power_off(void)
86+
{
87+
for (;;);
88+
}
89+
90+
static void pnv_halt(void)
91+
{
92+
for (;;);
93+
}
94+
95+
static unsigned long __init pnv_get_boot_time(void)
96+
{
97+
return 0;
98+
}
99+
100+
static void pnv_get_rtc_time(struct rtc_time *rtc_tm)
101+
{
102+
}
103+
104+
static int pnv_set_rtc_time(struct rtc_time *tm)
105+
{
106+
return 0;
107+
}
108+
109+
static void pnv_progress(char *s, unsigned short hex)
110+
{
111+
}
112+
113+
#ifdef CONFIG_KEXEC
114+
static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
115+
{
116+
xics_kexec_teardown_cpu(secondary);
117+
}
118+
#endif /* CONFIG_KEXEC */
119+
120+
static int __init pnv_probe(void)
121+
{
122+
unsigned long root = of_get_flat_dt_root();
123+
124+
if (!of_flat_dt_is_compatible(root, "ibm,powernv"))
125+
return 0;
126+
127+
hpte_init_native();
128+
129+
pr_debug("PowerNV detected !\n");
130+
131+
return 1;
132+
}
133+
134+
define_machine(powernv) {
135+
.name = "PowerNV",
136+
.probe = pnv_probe,
137+
.setup_arch = pnv_setup_arch,
138+
.init_early = pnv_init_early,
139+
.init_IRQ = pnv_init_IRQ,
140+
.show_cpuinfo = pnv_show_cpuinfo,
141+
.restart = pnv_restart,
142+
.power_off = pnv_power_off,
143+
.halt = pnv_halt,
144+
.get_boot_time = pnv_get_boot_time,
145+
.get_rtc_time = pnv_get_rtc_time,
146+
.set_rtc_time = pnv_set_rtc_time,
147+
.progress = pnv_progress,
148+
.power_save = power7_idle,
149+
.calibrate_decr = generic_calibrate_decr,
150+
#ifdef CONFIG_KEXEC
151+
.kexec_cpu_down = pnv_kexec_cpu_down,
152+
#endif
153+
};

arch/powerpc/platforms/powernv/smp.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* SMP support for PowerNV machines.
3+
*
4+
* Copyright 2011 IBM Corp.
5+
*
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.
10+
*/
11+
12+
#include <linux/kernel.h>
13+
#include <linux/module.h>
14+
#include <linux/sched.h>
15+
#include <linux/smp.h>
16+
#include <linux/interrupt.h>
17+
#include <linux/delay.h>
18+
#include <linux/init.h>
19+
#include <linux/spinlock.h>
20+
#include <linux/cpu.h>
21+
22+
#include <asm/irq.h>
23+
#include <asm/smp.h>
24+
#include <asm/paca.h>
25+
#include <asm/machdep.h>
26+
#include <asm/cputable.h>
27+
#include <asm/firmware.h>
28+
#include <asm/system.h>
29+
#include <asm/rtas.h>
30+
#include <asm/vdso_datapage.h>
31+
#include <asm/cputhreads.h>
32+
#include <asm/xics.h>
33+
34+
#include "powernv.h"
35+
36+
static void __devinit pnv_smp_setup_cpu(int cpu)
37+
{
38+
if (cpu != boot_cpuid)
39+
xics_setup_cpu();
40+
}
41+
42+
static int pnv_smp_cpu_bootable(unsigned int nr)
43+
{
44+
/* Special case - we inhibit secondary thread startup
45+
* during boot if the user requests it.
46+
*/
47+
if (system_state < SYSTEM_RUNNING && cpu_has_feature(CPU_FTR_SMT)) {
48+
if (!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0)
49+
return 0;
50+
if (smt_enabled_at_boot
51+
&& cpu_thread_in_core(nr) >= smt_enabled_at_boot)
52+
return 0;
53+
}
54+
55+
return 1;
56+
}
57+
58+
static struct smp_ops_t pnv_smp_ops = {
59+
.message_pass = smp_muxed_ipi_message_pass,
60+
.cause_ipi = NULL, /* Filled at runtime by xics_smp_probe() */
61+
.probe = xics_smp_probe,
62+
.kick_cpu = smp_generic_kick_cpu,
63+
.setup_cpu = pnv_smp_setup_cpu,
64+
.cpu_bootable = pnv_smp_cpu_bootable,
65+
};
66+
67+
/* This is called very early during platform setup_arch */
68+
void __init pnv_smp_init(void)
69+
{
70+
smp_ops = &pnv_smp_ops;
71+
72+
/* XXX We don't yet have a proper entry point from HAL, for
73+
* now we rely on kexec-style entry from BML
74+
*/
75+
76+
#ifdef CONFIG_PPC_RTAS
77+
/* Non-lpar has additional take/give timebase */
78+
if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
79+
smp_ops->give_timebase = rtas_give_timebase;
80+
smp_ops->take_timebase = rtas_take_timebase;
81+
}
82+
#endif /* CONFIG_PPC_RTAS */
83+
}

0 commit comments

Comments
 (0)