Commit 55190f88789ab62a42c3ee050090406b0bcefff8

Authored by Benjamin Herrenschmidt
1 parent e550592e68

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>

Showing 8 changed files with 262 additions and 0 deletions Side-by-side Diff

arch/powerpc/boot/Makefile
... ... @@ -171,6 +171,7 @@
171 171 $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
172 172  
173 173 image-$(CONFIG_PPC_PSERIES) += zImage.pseries
  174 +image-$(CONFIG_PPC_POWERNV) += zImage.pseries
174 175 image-$(CONFIG_PPC_MAPLE) += zImage.maple
175 176 image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
176 177 image-$(CONFIG_PPC_PS3) += dtbImage.ps3
arch/powerpc/platforms/Kconfig
1 1 menu "Platform support"
2 2  
  3 +source "arch/powerpc/platforms/powernv/Kconfig"
3 4 source "arch/powerpc/platforms/pseries/Kconfig"
4 5 source "arch/powerpc/platforms/iseries/Kconfig"
5 6 source "arch/powerpc/platforms/chrp/Kconfig"
arch/powerpc/platforms/Makefile
... ... @@ -14,6 +14,7 @@
14 14 obj-$(CONFIG_PPC_83xx) += 83xx/
15 15 obj-$(CONFIG_FSL_SOC_BOOKE) += 85xx/
16 16 obj-$(CONFIG_PPC_86xx) += 86xx/
  17 +obj-$(CONFIG_PPC_POWERNV) += powernv/
17 18 obj-$(CONFIG_PPC_PSERIES) += pseries/
18 19 obj-$(CONFIG_PPC_ISERIES) += iseries/
19 20 obj-$(CONFIG_PPC_MAPLE) += maple/
arch/powerpc/platforms/powernv/Kconfig
  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
arch/powerpc/platforms/powernv/Makefile
  1 +obj-y += setup.o
  2 +obj-$(CONFIG_SMP) += smp.o
arch/powerpc/platforms/powernv/powernv.h
  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 */
arch/powerpc/platforms/powernv/setup.c
  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
  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 +}