setup.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. #undef DEBUG
  12. #include <linux/cpu.h>
  13. #include <linux/errno.h>
  14. #include <linux/sched.h>
  15. #include <linux/kernel.h>
  16. #include <linux/tty.h>
  17. #include <linux/reboot.h>
  18. #include <linux/init.h>
  19. #include <linux/console.h>
  20. #include <linux/delay.h>
  21. #include <linux/irq.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/of.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/bug.h>
  26. #include <asm/machdep.h>
  27. #include <asm/firmware.h>
  28. #include <asm/xics.h>
  29. #include <asm/opal.h>
  30. #include "powernv.h"
  31. static void __init pnv_setup_arch(void)
  32. {
  33. /* Initialize SMP */
  34. pnv_smp_init();
  35. /* XXX PCI */
  36. /* XXX NVRAM */
  37. /* Enable NAP mode */
  38. powersave_nap = 1;
  39. /* XXX PMCS */
  40. }
  41. static void __init pnv_init_early(void)
  42. {
  43. #ifdef CONFIG_HVC_OPAL
  44. if (firmware_has_feature(FW_FEATURE_OPAL))
  45. hvc_opal_init_early();
  46. else
  47. #endif
  48. add_preferred_console("hvc", 0, NULL);
  49. }
  50. static void __init pnv_init_IRQ(void)
  51. {
  52. xics_init();
  53. WARN_ON(!ppc_md.get_irq);
  54. }
  55. static void pnv_show_cpuinfo(struct seq_file *m)
  56. {
  57. struct device_node *root;
  58. const char *model = "";
  59. root = of_find_node_by_path("/");
  60. if (root)
  61. model = of_get_property(root, "model", NULL);
  62. seq_printf(m, "machine\t\t: PowerNV %s\n", model);
  63. if (firmware_has_feature(FW_FEATURE_OPALv2))
  64. seq_printf(m, "firmware\t: OPAL v2\n");
  65. else if (firmware_has_feature(FW_FEATURE_OPAL))
  66. seq_printf(m, "firmware\t: OPAL v1\n");
  67. else
  68. seq_printf(m, "firmware\t: BML\n");
  69. of_node_put(root);
  70. }
  71. static void pnv_restart(char *cmd)
  72. {
  73. for (;;);
  74. }
  75. static void pnv_power_off(void)
  76. {
  77. for (;;);
  78. }
  79. static void pnv_halt(void)
  80. {
  81. for (;;);
  82. }
  83. static unsigned long __init pnv_get_boot_time(void)
  84. {
  85. return 0;
  86. }
  87. static void pnv_get_rtc_time(struct rtc_time *rtc_tm)
  88. {
  89. }
  90. static int pnv_set_rtc_time(struct rtc_time *tm)
  91. {
  92. return 0;
  93. }
  94. static void pnv_progress(char *s, unsigned short hex)
  95. {
  96. }
  97. #ifdef CONFIG_KEXEC
  98. static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
  99. {
  100. xics_kexec_teardown_cpu(secondary);
  101. }
  102. #endif /* CONFIG_KEXEC */
  103. static int __init pnv_probe(void)
  104. {
  105. unsigned long root = of_get_flat_dt_root();
  106. if (!of_flat_dt_is_compatible(root, "ibm,powernv"))
  107. return 0;
  108. hpte_init_native();
  109. pr_debug("PowerNV detected !\n");
  110. return 1;
  111. }
  112. define_machine(powernv) {
  113. .name = "PowerNV",
  114. .probe = pnv_probe,
  115. .setup_arch = pnv_setup_arch,
  116. .init_early = pnv_init_early,
  117. .init_IRQ = pnv_init_IRQ,
  118. .show_cpuinfo = pnv_show_cpuinfo,
  119. .restart = pnv_restart,
  120. .power_off = pnv_power_off,
  121. .halt = pnv_halt,
  122. .get_boot_time = pnv_get_boot_time,
  123. .get_rtc_time = pnv_get_rtc_time,
  124. .set_rtc_time = pnv_set_rtc_time,
  125. .progress = pnv_progress,
  126. .power_save = power7_idle,
  127. .calibrate_decr = generic_calibrate_decr,
  128. #ifdef CONFIG_KEXEC
  129. .kexec_cpu_down = pnv_kexec_cpu_down,
  130. #endif
  131. };