blob: 963bf0d8119aafb17ac3281f843820ff454d3886 [file] [log] [blame]
Russell King862184f2005-11-07 21:05:42 +00001/*
2 * linux/arch/arm/mach-realview/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 King862184f2005-11-07 21:05:42 +000013#include <linux/smp.h>
Russell Kingfced80c2008-09-06 12:10:45 +010014#include <linux/io.h>
Russell King862184f2005-11-07 21:05:42 +000015
Russell Kinga09e64f2008-08-05 16:14:15 +010016#include <mach/hardware.h>
Russell King0f7b3322011-04-03 13:01:30 +010017#include <asm/hardware/gic.h>
Catalin Marinas7dd19e72008-02-04 17:39:00 +010018#include <asm/mach-types.h>
Russell King0462b442011-01-19 10:24:56 +000019#include <asm/smp_scu.h>
Catalin Marinasdff2ab12009-07-24 12:33:00 +010020#include <asm/unified.h>
Russell King862184f2005-11-07 21:05:42 +000021
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/board-eb.h>
23#include <mach/board-pb11mp.h>
Colin Tuckley1b504bb2009-05-30 13:56:12 +010024#include <mach/board-pbx.h>
Catalin Marinasb7b0ba92008-04-18 22:43:08 +010025
Catalin Marinas1bbdf632008-12-01 14:54:58 +000026#include "core.h"
27
Russell King0462b442011-01-19 10:24:56 +000028extern void versatile_secondary_startup(void);
Russell King3705ff62010-12-18 10:53:12 +000029
Catalin Marinas1bbdf632008-12-01 14:54:58 +000030static void __iomem *scu_base_addr(void)
31{
32 if (machine_is_realview_eb_mp())
33 return __io_address(REALVIEW_EB11MP_SCU_BASE);
34 else if (machine_is_realview_pb11mp())
35 return __io_address(REALVIEW_TC11MP_SCU_BASE);
Colin Tuckley1b504bb2009-05-30 13:56:12 +010036 else if (machine_is_realview_pbx() &&
37 (core_tile_pbx11mp() || core_tile_pbxa9mp()))
38 return __io_address(REALVIEW_PBX_TILE_SCU_BASE);
Catalin Marinas1bbdf632008-12-01 14:54:58 +000039 else
40 return (void __iomem *)0;
41}
42
Russell King7bbb7942006-02-16 11:08:09 +000043/*
44 * Initialise the CPU possible map early - this describes the CPUs
45 * which may be present or become present in the system.
46 */
47void __init smp_init_cpus(void)
48{
Russell Kingfd778f02010-12-02 18:09:37 +000049 void __iomem *scu_base = scu_base_addr();
50 unsigned int i, ncores;
Russell King7bbb7942006-02-16 11:08:09 +000051
Russell Kingfd778f02010-12-02 18:09:37 +000052 ncores = scu_base ? scu_get_core_count(scu_base) : 1;
Russell King862184f2005-11-07 21:05:42 +000053
54 /* sanity check */
Russell King862184f2005-11-07 21:05:42 +000055 if (ncores > NR_CPUS) {
56 printk(KERN_WARNING
57 "Realview: no. of cores (%d) greater than configured "
58 "maximum of %d - clipping\n",
59 ncores, NR_CPUS);
60 ncores = NR_CPUS;
61 }
62
Russell Kingbbc3d14e92010-12-03 10:42:58 +000063 for (i = 0; i < ncores; i++)
64 set_cpu_possible(i, true);
Russell King0f7b3322011-04-03 13:01:30 +010065
66 set_smp_cross_call(gic_raise_softirq);
Russell Kingbbc3d14e92010-12-03 10:42:58 +000067}
Russell King862184f2005-11-07 21:05:42 +000068
Russell King05c74a62010-12-03 11:09:48 +000069void __init platform_smp_prepare_cpus(unsigned int max_cpus)
Russell Kingbbc3d14e92010-12-03 10:42:58 +000070{
Russell Kingbbc3d14e92010-12-03 10:42:58 +000071 int i;
Russell King862184f2005-11-07 21:05:42 +000072
Russell King2a98beb2005-11-09 10:50:29 +000073 /*
Russell King7bbb7942006-02-16 11:08:09 +000074 * Initialise the present map, which describes the set of CPUs
75 * actually populated at the present time.
Russell King862184f2005-11-07 21:05:42 +000076 */
Russell King7bbb7942006-02-16 11:08:09 +000077 for (i = 0; i < max_cpus; i++)
Russell Kinge03cdad2009-05-28 14:16:52 +010078 set_cpu_present(i, true);
Russell King862184f2005-11-07 21:05:42 +000079
Russell King05c74a62010-12-03 11:09:48 +000080 scu_enable(scu_base_addr());
Russell Kingbc282482009-05-17 18:58:34 +010081
Russell King05c74a62010-12-03 11:09:48 +000082 /*
83 * Write the address of secondary startup into the
84 * system-wide flags register. The BootMonitor waits
85 * until it receives a soft interrupt, and then the
86 * secondary CPU branches to this address.
87 */
Russell King0462b442011-01-19 10:24:56 +000088 __raw_writel(BSYM(virt_to_phys(versatile_secondary_startup)),
Russell King05c74a62010-12-03 11:09:48 +000089 __io_address(REALVIEW_SYS_FLAGSSET));
Russell King862184f2005-11-07 21:05:42 +000090}