aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-09-19 13:44:52 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-09-20 01:53:25 -0400
commit55190f88789ab62a42c3ee050090406b0bcefff8 (patch)
tree6f26ff975551bf81446249bdf37a818f43e08418 /arch/powerpc
parente550592e689cf8d682937f356497f989f3d88292 (diff)
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 <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/boot/Makefile1
-rw-r--r--arch/powerpc/platforms/Kconfig1
-rw-r--r--arch/powerpc/platforms/Makefile1
-rw-r--r--arch/powerpc/platforms/powernv/Kconfig11
-rw-r--r--arch/powerpc/platforms/powernv/Makefile2
-rw-r--r--arch/powerpc/platforms/powernv/powernv.h10
-rw-r--r--arch/powerpc/platforms/powernv/setup.c153
-rw-r--r--arch/powerpc/platforms/powernv/smp.c83
8 files changed, 262 insertions, 0 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index ac6705e75711..72ee8c1fba48 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -171,6 +171,7 @@ quiet_cmd_wrap = WRAP $@
171 $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux 171 $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
172 172
173image-$(CONFIG_PPC_PSERIES) += zImage.pseries 173image-$(CONFIG_PPC_PSERIES) += zImage.pseries
174image-$(CONFIG_PPC_POWERNV) += zImage.pseries
174image-$(CONFIG_PPC_MAPLE) += zImage.maple 175image-$(CONFIG_PPC_MAPLE) += zImage.maple
175image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries 176image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
176image-$(CONFIG_PPC_PS3) += dtbImage.ps3 177image-$(CONFIG_PPC_PS3) += dtbImage.ps3
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index b9ba86191aed..6de27d275728 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -1,5 +1,6 @@
1menu "Platform support" 1menu "Platform support"
2 2
3source "arch/powerpc/platforms/powernv/Kconfig"
3source "arch/powerpc/platforms/pseries/Kconfig" 4source "arch/powerpc/platforms/pseries/Kconfig"
4source "arch/powerpc/platforms/iseries/Kconfig" 5source "arch/powerpc/platforms/iseries/Kconfig"
5source "arch/powerpc/platforms/chrp/Kconfig" 6source "arch/powerpc/platforms/chrp/Kconfig"
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 73e2116cfeed..2635a22bade2 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_PPC_82xx) += 82xx/
14obj-$(CONFIG_PPC_83xx) += 83xx/ 14obj-$(CONFIG_PPC_83xx) += 83xx/
15obj-$(CONFIG_FSL_SOC_BOOKE) += 85xx/ 15obj-$(CONFIG_FSL_SOC_BOOKE) += 85xx/
16obj-$(CONFIG_PPC_86xx) += 86xx/ 16obj-$(CONFIG_PPC_86xx) += 86xx/
17obj-$(CONFIG_PPC_POWERNV) += powernv/
17obj-$(CONFIG_PPC_PSERIES) += pseries/ 18obj-$(CONFIG_PPC_PSERIES) += pseries/
18obj-$(CONFIG_PPC_ISERIES) += iseries/ 19obj-$(CONFIG_PPC_ISERIES) += iseries/
19obj-$(CONFIG_PPC_MAPLE) += maple/ 20obj-$(CONFIG_PPC_MAPLE) += maple/
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
new file mode 100644
index 000000000000..24700e8df19c
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -0,0 +1,11 @@
1config 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
diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile
new file mode 100644
index 000000000000..1c4325056b85
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -0,0 +1,2 @@
1obj-y += setup.o
2obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/powerpc/platforms/powernv/powernv.h b/arch/powerpc/platforms/powernv/powernv.h
new file mode 100644
index 000000000000..35b716008cd3
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/powernv.h
@@ -0,0 +1,10 @@
1#ifndef _POWERNV_H
2#define _POWERNV_H
3
4#ifdef CONFIG_SMP
5extern void pnv_smp_init(void);
6#else
7static inline void pnv_smp_init(void) { }
8#endif
9
10#endif /* _POWERNV_H */
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
new file mode 100644
index 000000000000..569f9cc4eb04
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -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
35static 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
56static void __init pnv_init_early(void)
57{
58 /* XXX IOMMU */
59}
60
61static void __init pnv_init_IRQ(void)
62{
63 xics_init();
64
65 WARN_ON(!ppc_md.get_irq);
66}
67
68static 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
80static void pnv_restart(char *cmd)
81{
82 for (;;);
83}
84
85static void pnv_power_off(void)
86{
87 for (;;);
88}
89
90static void pnv_halt(void)
91{
92 for (;;);
93}
94
95static unsigned long __init pnv_get_boot_time(void)
96{
97 return 0;
98}
99
100static void pnv_get_rtc_time(struct rtc_time *rtc_tm)
101{
102}
103
104static int pnv_set_rtc_time(struct rtc_time *tm)
105{
106 return 0;
107}
108
109static void pnv_progress(char *s, unsigned short hex)
110{
111}
112
113#ifdef CONFIG_KEXEC
114static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
115{
116 xics_kexec_teardown_cpu(secondary);
117}
118#endif /* CONFIG_KEXEC */
119
120static 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
134define_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};
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
new file mode 100644
index 000000000000..36c715102c58
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -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
36static void __devinit pnv_smp_setup_cpu(int cpu)
37{
38 if (cpu != boot_cpuid)
39 xics_setup_cpu();
40}
41
42static 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
58static 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 */
68void __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}