• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  SMP Support for A2 platforms
3  *
4  *  Copyright 2007 Benjamin Herrenschmidt, 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  */
12 
13 #include <linux/cpumask.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/of.h>
17 #include <linux/smp.h>
18 
19 #include <asm/dbell.h>
20 #include <asm/machdep.h>
21 #include <asm/xics.h>
22 
23 #include "ics.h"
24 #include "wsp.h"
25 
smp_a2_setup_cpu(int cpu)26 static void __devinit smp_a2_setup_cpu(int cpu)
27 {
28 	doorbell_setup_this_cpu();
29 
30 	if (cpu != boot_cpuid)
31 		xics_setup_cpu();
32 }
33 
smp_a2_kick_cpu(int nr)34 int __devinit smp_a2_kick_cpu(int nr)
35 {
36 	const char *enable_method;
37 	struct device_node *np;
38 	int thr_idx;
39 
40 	if (nr < 0 || nr >= NR_CPUS)
41 		return -ENOENT;
42 
43 	np = of_get_cpu_node(nr, &thr_idx);
44 	if (!np)
45 		return -ENODEV;
46 
47 	enable_method = of_get_property(np, "enable-method", NULL);
48 	pr_devel("CPU%d has enable-method: \"%s\"\n", nr, enable_method);
49 
50 	if (!enable_method) {
51                 printk(KERN_ERR "CPU%d has no enable-method\n", nr);
52 		return -ENOENT;
53 	} else if (strcmp(enable_method, "ibm,a2-scom") == 0) {
54 		if (a2_scom_startup_cpu(nr, thr_idx, np))
55 			return -1;
56 	} else {
57 		printk(KERN_ERR "CPU%d: Don't understand enable-method \"%s\"\n",
58                        nr, enable_method);
59 		return -EINVAL;
60 	}
61 
62 	/*
63 	 * The processor is currently spinning, waiting for the
64 	 * cpu_start field to become non-zero After we set cpu_start,
65 	 * the processor will continue on to secondary_start
66 	 */
67 	paca[nr].cpu_start = 1;
68 
69 	return 0;
70 }
71 
smp_a2_probe(void)72 static int __init smp_a2_probe(void)
73 {
74 	return num_possible_cpus();
75 }
76 
77 static struct smp_ops_t a2_smp_ops = {
78 	.message_pass	= NULL,	/* Use smp_muxed_ipi_message_pass */
79 	.cause_ipi	= doorbell_cause_ipi,
80 	.probe		= smp_a2_probe,
81 	.kick_cpu	= smp_a2_kick_cpu,
82 	.setup_cpu	= smp_a2_setup_cpu,
83 };
84 
a2_setup_smp(void)85 void __init a2_setup_smp(void)
86 {
87 	smp_ops = &a2_smp_ops;
88 }
89