smp.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/sched.h>
  20. #include <linux/smp.h>
  21. #include <asm/processor.h>
  22. #include "cfe_api.h"
  23. #include "cfe_error.h"
  24. /*
  25. * Use CFE to find out how many CPUs are available, setting up
  26. * phys_cpu_present_map and the logical/physical mappings.
  27. * XXXKW will the boot CPU ever not be physical 0?
  28. *
  29. * Common setup before any secondaries are started
  30. */
  31. void __init plat_smp_setup(void)
  32. {
  33. int i, num;
  34. cpus_clear(phys_cpu_present_map);
  35. cpu_set(0, phys_cpu_present_map);
  36. __cpu_number_map[0] = 0;
  37. __cpu_logical_map[0] = 0;
  38. for (i = 1, num = 0; i < NR_CPUS; i++) {
  39. if (cfe_cpu_stop(i) == 0) {
  40. cpu_set(i, phys_cpu_present_map);
  41. __cpu_number_map[i] = ++num;
  42. __cpu_logical_map[num] = i;
  43. }
  44. }
  45. printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num);
  46. }
  47. void __init plat_prepare_cpus(unsigned int max_cpus)
  48. {
  49. }
  50. /*
  51. * Setup the PC, SP, and GP of a secondary processor and start it
  52. * running!
  53. */
  54. void prom_boot_secondary(int cpu, struct task_struct *idle)
  55. {
  56. int retval;
  57. retval = cfe_cpu_start(cpu_logical_map(cpu), &smp_bootstrap,
  58. __KSTK_TOS(idle),
  59. (unsigned long)task_thread_info(idle), 0);
  60. if (retval != 0)
  61. printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval);
  62. }
  63. /*
  64. * Code to run on secondary just after probing the CPU
  65. */
  66. void prom_init_secondary(void)
  67. {
  68. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  69. extern void bcm1480_smp_init(void);
  70. bcm1480_smp_init();
  71. #elif defined(CONFIG_SIBYTE_SB1250)
  72. extern void sb1250_smp_init(void);
  73. sb1250_smp_init();
  74. #else
  75. #error invalid SMP configuration
  76. #endif
  77. }
  78. /*
  79. * Do any tidying up before marking online and running the idle
  80. * loop
  81. */
  82. void prom_smp_finish(void)
  83. {
  84. #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
  85. extern void bcm1480_smp_finish(void);
  86. bcm1480_smp_finish();
  87. #elif defined(CONFIG_SIBYTE_SB1250)
  88. extern void sb1250_smp_finish(void);
  89. sb1250_smp_finish();
  90. #else
  91. #error invalid SMP configuration
  92. #endif
  93. }
  94. /*
  95. * Final cleanup after all secondaries booted
  96. */
  97. void prom_cpus_done(void)
  98. {
  99. }