setup.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Celleb setup code
  3. *
  4. * (C) Copyright 2006-2007 TOSHIBA CORPORATION
  5. *
  6. * This code is based on arch/powerpc/platforms/cell/setup.c:
  7. * Copyright (C) 1995 Linus Torvalds
  8. * Adapted from 'alpha' version by Gary Thomas
  9. * Modified by Cort Dougan (cort@cs.nmt.edu)
  10. * Modified by PPC64 Team, IBM Corp
  11. * Modified by Cell Team, IBM Deutschland Entwicklung GmbH
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #undef DEBUG
  28. #include <linux/cpu.h>
  29. #include <linux/sched.h>
  30. #include <linux/kernel.h>
  31. #include <linux/mm.h>
  32. #include <linux/stddef.h>
  33. #include <linux/unistd.h>
  34. #include <linux/reboot.h>
  35. #include <linux/init.h>
  36. #include <linux/delay.h>
  37. #include <linux/irq.h>
  38. #include <linux/seq_file.h>
  39. #include <linux/root_dev.h>
  40. #include <linux/console.h>
  41. #include <asm/mmu.h>
  42. #include <asm/processor.h>
  43. #include <asm/io.h>
  44. #include <asm/kexec.h>
  45. #include <asm/prom.h>
  46. #include <asm/machdep.h>
  47. #include <asm/cputable.h>
  48. #include <asm/irq.h>
  49. #include <asm/spu_priv1.h>
  50. #include <asm/firmware.h>
  51. #include <asm/of_platform.h>
  52. #include "interrupt.h"
  53. #include "beat_wrapper.h"
  54. #include "beat.h"
  55. #include "pci.h"
  56. static char celleb_machine_type[128] = "Celleb";
  57. static void celleb_show_cpuinfo(struct seq_file *m)
  58. {
  59. struct device_node *root;
  60. const char *model = "";
  61. root = of_find_node_by_path("/");
  62. if (root)
  63. model = get_property(root, "model", NULL);
  64. /* using "CHRP" is to trick anaconda into installing FCx into Celleb */
  65. seq_printf(m, "machine\t\t: %s %s\n", celleb_machine_type, model);
  66. of_node_put(root);
  67. }
  68. static int celleb_machine_type_hack(char *ptr)
  69. {
  70. strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
  71. celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
  72. return 0;
  73. }
  74. __setup("celleb_machine_type_hack", celleb_machine_type_hack);
  75. static void celleb_progress(char *s, unsigned short hex)
  76. {
  77. printk("*** %04x : %s\n", hex, s ? s : "");
  78. }
  79. static void __init celleb_setup_arch(void)
  80. {
  81. #ifdef CONFIG_SPU_BASE
  82. spu_priv1_ops = &spu_priv1_beat_ops;
  83. spu_management_ops = &spu_management_of_ops;
  84. #endif
  85. #ifdef CONFIG_SMP
  86. smp_init_celleb();
  87. #endif
  88. /* init to some ~sane value until calibrate_delay() runs */
  89. loops_per_jiffy = 50000000;
  90. if (ROOT_DEV == 0) {
  91. printk("No ramdisk, default root is /dev/hda2\n");
  92. ROOT_DEV = Root_HDA2;
  93. }
  94. #ifdef CONFIG_DUMMY_CONSOLE
  95. conswitchp = &dummy_con;
  96. #endif
  97. }
  98. static void beat_power_save(void)
  99. {
  100. beat_pause(0);
  101. }
  102. static int __init celleb_probe(void)
  103. {
  104. unsigned long root = of_get_flat_dt_root();
  105. if (!of_flat_dt_is_compatible(root, "Beat"))
  106. return 0;
  107. powerpc_firmware_features |= FW_FEATURE_CELLEB_POSSIBLE;
  108. hpte_init_beat();
  109. return 1;
  110. }
  111. /*
  112. * Cell has no legacy IO; anything calling this function has to
  113. * fail or bad things will happen
  114. */
  115. static int celleb_check_legacy_ioport(unsigned int baseport)
  116. {
  117. return -ENODEV;
  118. }
  119. static void celleb_kexec_cpu_down(int crash, int secondary)
  120. {
  121. beatic_deinit_IRQ();
  122. }
  123. static struct of_device_id celleb_bus_ids[] = {
  124. { .type = "scc", },
  125. { .type = "ioif", }, /* old style */
  126. {},
  127. };
  128. static int __init celleb_publish_devices(void)
  129. {
  130. if (!machine_is(celleb))
  131. return 0;
  132. /* Publish OF platform devices for southbridge IOs */
  133. of_platform_bus_probe(NULL, celleb_bus_ids, NULL);
  134. return 0;
  135. }
  136. device_initcall(celleb_publish_devices);
  137. define_machine(celleb) {
  138. .name = "Cell Reference Set",
  139. .probe = celleb_probe,
  140. .setup_arch = celleb_setup_arch,
  141. .show_cpuinfo = celleb_show_cpuinfo,
  142. .restart = beat_restart,
  143. .power_off = beat_power_off,
  144. .halt = beat_halt,
  145. .get_rtc_time = beat_get_rtc_time,
  146. .set_rtc_time = beat_set_rtc_time,
  147. .calibrate_decr = generic_calibrate_decr,
  148. .check_legacy_ioport = celleb_check_legacy_ioport,
  149. .progress = celleb_progress,
  150. .power_save = beat_power_save,
  151. .nvram_size = beat_nvram_get_size,
  152. .nvram_read = beat_nvram_read,
  153. .nvram_write = beat_nvram_write,
  154. .set_dabr = beat_set_xdabr,
  155. .init_IRQ = beatic_init_IRQ,
  156. .get_irq = beatic_get_irq,
  157. .pci_probe_mode = celleb_pci_probe_mode,
  158. .pci_setup_phb = celleb_setup_phb,
  159. #ifdef CONFIG_KEXEC
  160. .kexec_cpu_down = celleb_kexec_cpu_down,
  161. .machine_kexec = default_machine_kexec,
  162. .machine_kexec_prepare = default_machine_kexec_prepare,
  163. .machine_crash_shutdown = default_machine_crash_shutdown,
  164. #endif
  165. };