blob: e8485124b8fc903fda4b8768825f080ff19c5a5b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
19#include <linux/init.h>
20#include <linux/sched.h>
21#include <linux/smp.h>
22#include <asm/processor.h>
23
24#include "cfe_api.h"
25#include "cfe_error.h"
26
27/*
28 * Use CFE to find out how many CPUs are available, setting up
29 * phys_cpu_present_map and the logical/physical mappings.
30 * XXXKW will the boot CPU ever not be physical 0?
31 *
32 * Common setup before any secondaries are started
33 */
34void __init prom_prepare_cpus(unsigned int max_cpus)
35{
36 int i, num;
37
38 cpus_clear(phys_cpu_present_map);
39 cpu_set(0, phys_cpu_present_map);
40 __cpu_number_map[0] = 0;
41 __cpu_logical_map[0] = 0;
42
43 for (i=1, num=0; i<NR_CPUS; i++) {
44 if (cfe_cpu_stop(i) == 0) {
45 cpu_set(i, phys_cpu_present_map);
46 __cpu_number_map[i] = ++num;
47 __cpu_logical_map[num] = i;
48 }
49 }
50 printk("Detected %i available secondary CPU(s)\n", num);
51}
52
53/*
54 * Setup the PC, SP, and GP of a secondary processor and start it
55 * running!
56 */
57void prom_boot_secondary(int cpu, struct task_struct *idle)
58{
59 int retval;
Ralf Baechle42a3b4f2005-09-03 15:56:17 -070060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 retval = cfe_cpu_start(cpu_logical_map(cpu), &smp_bootstrap,
62 __KSTK_TOS(idle),
63 (unsigned long)idle->thread_info, 0);
64 if (retval != 0)
65 printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval);
66}
67
68/*
69 * Code to run on secondary just after probing the CPU
70 */
71void prom_init_secondary(void)
72{
Andrew Isaacsonf137e462005-10-19 23:56:38 -070073#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
74 extern void bcm1480_smp_init(void);
75 bcm1480_smp_init();
76#elif defined(CONFIG_SIBYTE_SB1250)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 extern void sb1250_smp_init(void);
78 sb1250_smp_init();
Andrew Isaacsonf137e462005-10-19 23:56:38 -070079#else
80#error invalid SMP configuration
81#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070082}
83
84/*
85 * Do any tidying up before marking online and running the idle
86 * loop
87 */
88void prom_smp_finish(void)
89{
Andrew Isaacsonf137e462005-10-19 23:56:38 -070090#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
91 extern void bcm1480_smp_finish(void);
92 bcm1480_smp_finish();
93#elif defined(CONFIG_SIBYTE_SB1250)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 extern void sb1250_smp_finish(void);
95 sb1250_smp_finish();
Andrew Isaacsonf137e462005-10-19 23:56:38 -070096#else
97#error invalid SMP configuration
98#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
101/*
102 * Final cleanup after all secondaries booted
103 */
104void prom_cpus_done(void)
105{
106}