blob: 18927023c2cc4afce07c46e9486f2b23c4d72e57 [file] [log] [blame]
Russell King59ac59f2010-02-11 21:56:07 +00001/*
2 * linux/arch/arm/mach-vexpress/platsmp.c
3 *
4 * Copyright (C) 2002 ARM Ltd.
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/init.h>
12#include <linux/errno.h>
Russell King59ac59f2010-02-11 21:56:07 +000013#include <linux/smp.h>
14#include <linux/io.h>
15
Russell King59ac59f2010-02-11 21:56:07 +000016#include <asm/smp_scu.h>
17#include <asm/unified.h>
18
19#include <mach/ct-ca9x4.h>
20#include <mach/motherboard.h>
21#define V2M_PA_CS7 0x10000000
22
23#include "core.h"
24
Russell King0462b442011-01-19 10:24:56 +000025extern void versatile_secondary_startup(void);
Russell King3705ff62010-12-18 10:53:12 +000026
Russell King59ac59f2010-02-11 21:56:07 +000027static void __iomem *scu_base_addr(void)
28{
29 return MMIO_P2V(A9_MPCORE_SCU);
30}
31
Russell King59ac59f2010-02-11 21:56:07 +000032/*
33 * Initialise the CPU possible map early - this describes the CPUs
34 * which may be present or become present in the system.
35 */
36void __init smp_init_cpus(void)
37{
38 void __iomem *scu_base = scu_base_addr();
39 unsigned int i, ncores;
40
41 ncores = scu_base ? scu_get_core_count(scu_base) : 1;
42
43 /* sanity check */
Russell King59ac59f2010-02-11 21:56:07 +000044 if (ncores > NR_CPUS) {
45 printk(KERN_WARNING
46 "vexpress: no. of cores (%d) greater than configured "
47 "maximum of %d - clipping\n",
48 ncores, NR_CPUS);
49 ncores = NR_CPUS;
50 }
51
52 for (i = 0; i < ncores; i++)
53 set_cpu_possible(i, true);
54}
55
Russell King05c74a62010-12-03 11:09:48 +000056void __init platform_smp_prepare_cpus(unsigned int max_cpus)
Russell King59ac59f2010-02-11 21:56:07 +000057{
Russell King59ac59f2010-02-11 21:56:07 +000058 int i;
59
Russell King59ac59f2010-02-11 21:56:07 +000060 /*
61 * Initialise the present map, which describes the set of CPUs
62 * actually populated at the present time.
63 */
64 for (i = 0; i < max_cpus; i++)
65 set_cpu_present(i, true);
66
Russell King05c74a62010-12-03 11:09:48 +000067 scu_enable(scu_base_addr());
68
Russell King59ac59f2010-02-11 21:56:07 +000069 /*
Russell King05c74a62010-12-03 11:09:48 +000070 * Write the address of secondary startup into the
71 * system-wide flags register. The boot monitor waits
72 * until it receives a soft interrupt, and then the
73 * secondary CPU branches to this address.
Russell King59ac59f2010-02-11 21:56:07 +000074 */
Russell King05c74a62010-12-03 11:09:48 +000075 writel(~0, MMIO_P2V(V2M_SYS_FLAGSCLR));
Russell King0462b442011-01-19 10:24:56 +000076 writel(BSYM(virt_to_phys(versatile_secondary_startup)),
Russell King05c74a62010-12-03 11:09:48 +000077 MMIO_P2V(V2M_SYS_FLAGSSET));
Russell King59ac59f2010-02-11 21:56:07 +000078}