setup.c 3.1 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 "powernv.h"
  30. static void __init pnv_setup_arch(void)
  31. {
  32. /* Force console to hvc for now until we have sorted out the
  33. * real console situation for the platform. This will make
  34. * hvc_udbg work at least.
  35. */
  36. add_preferred_console("hvc", 0, NULL);
  37. /* Initialize SMP */
  38. pnv_smp_init();
  39. /* XXX PCI */
  40. /* XXX NVRAM */
  41. /* Enable NAP mode */
  42. powersave_nap = 1;
  43. /* XXX PMCS */
  44. }
  45. static void __init pnv_init_early(void)
  46. {
  47. /* XXX IOMMU */
  48. }
  49. static void __init pnv_init_IRQ(void)
  50. {
  51. xics_init();
  52. WARN_ON(!ppc_md.get_irq);
  53. }
  54. static void pnv_show_cpuinfo(struct seq_file *m)
  55. {
  56. struct device_node *root;
  57. const char *model = "";
  58. root = of_find_node_by_path("/");
  59. if (root)
  60. model = of_get_property(root, "model", NULL);
  61. seq_printf(m, "machine\t\t: PowerNV %s\n", model);
  62. if (firmware_has_feature(FW_FEATURE_OPALv2))
  63. seq_printf(m, "firmware\t: OPAL v2\n");
  64. else if (firmware_has_feature(FW_FEATURE_OPAL))
  65. seq_printf(m, "firmware\t: OPAL v1\n");
  66. else
  67. seq_printf(m, "firmware\t: BML\n");
  68. of_node_put(root);
  69. }
  70. static void pnv_restart(char *cmd)
  71. {
  72. for (;;);
  73. }
  74. static void pnv_power_off(void)
  75. {
  76. for (;;);
  77. }
  78. static void pnv_halt(void)
  79. {
  80. for (;;);
  81. }
  82. static unsigned long __init pnv_get_boot_time(void)
  83. {
  84. return 0;
  85. }
  86. static void pnv_get_rtc_time(struct rtc_time *rtc_tm)
  87. {
  88. }
  89. static int pnv_set_rtc_time(struct rtc_time *tm)
  90. {
  91. return 0;
  92. }
  93. static void pnv_progress(char *s, unsigned short hex)
  94. {
  95. }
  96. #ifdef CONFIG_KEXEC
  97. static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
  98. {
  99. xics_kexec_teardown_cpu(secondary);
  100. }
  101. #endif /* CONFIG_KEXEC */
  102. static int __init pnv_probe(void)
  103. {
  104. unsigned long root = of_get_flat_dt_root();
  105. if (!of_flat_dt_is_compatible(root, "ibm,powernv"))
  106. return 0;
  107. hpte_init_native();
  108. pr_debug("PowerNV detected !\n");
  109. return 1;
  110. }
  111. define_machine(powernv) {
  112. .name = "PowerNV",
  113. .probe = pnv_probe,
  114. .setup_arch = pnv_setup_arch,
  115. .init_early = pnv_init_early,
  116. .init_IRQ = pnv_init_IRQ,
  117. .show_cpuinfo = pnv_show_cpuinfo,
  118. .restart = pnv_restart,
  119. .power_off = pnv_power_off,
  120. .halt = pnv_halt,
  121. .get_boot_time = pnv_get_boot_time,
  122. .get_rtc_time = pnv_get_rtc_time,
  123. .set_rtc_time = pnv_set_rtc_time,
  124. .progress = pnv_progress,
  125. .power_save = power7_idle,
  126. .calibrate_decr = generic_calibrate_decr,
  127. #ifdef CONFIG_KEXEC
  128. .kexec_cpu_down = pnv_kexec_cpu_down,
  129. #endif
  130. };