Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 1 | /* |
| 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 King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 13 | #include <linux/smp.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 14 | #include <linux/io.h> |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 15 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 16 | #include <mach/hardware.h> |
Catalin Marinas | 7dd19e7 | 2008-02-04 17:39:00 +0100 | [diff] [blame] | 17 | #include <asm/mach-types.h> |
Russell King | 0462b44 | 2011-01-19 10:24:56 +0000 | [diff] [blame^] | 18 | #include <asm/smp_scu.h> |
Catalin Marinas | dff2ab1 | 2009-07-24 12:33:00 +0100 | [diff] [blame] | 19 | #include <asm/unified.h> |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 20 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 21 | #include <mach/board-eb.h> |
| 22 | #include <mach/board-pb11mp.h> |
Colin Tuckley | 1b504bb | 2009-05-30 13:56:12 +0100 | [diff] [blame] | 23 | #include <mach/board-pbx.h> |
Catalin Marinas | b7b0ba9 | 2008-04-18 22:43:08 +0100 | [diff] [blame] | 24 | |
Catalin Marinas | 1bbdf63 | 2008-12-01 14:54:58 +0000 | [diff] [blame] | 25 | #include "core.h" |
| 26 | |
Russell King | 0462b44 | 2011-01-19 10:24:56 +0000 | [diff] [blame^] | 27 | extern void versatile_secondary_startup(void); |
Russell King | 3705ff6 | 2010-12-18 10:53:12 +0000 | [diff] [blame] | 28 | |
Catalin Marinas | 1bbdf63 | 2008-12-01 14:54:58 +0000 | [diff] [blame] | 29 | static void __iomem *scu_base_addr(void) |
| 30 | { |
| 31 | if (machine_is_realview_eb_mp()) |
| 32 | return __io_address(REALVIEW_EB11MP_SCU_BASE); |
| 33 | else if (machine_is_realview_pb11mp()) |
| 34 | return __io_address(REALVIEW_TC11MP_SCU_BASE); |
Colin Tuckley | 1b504bb | 2009-05-30 13:56:12 +0100 | [diff] [blame] | 35 | else if (machine_is_realview_pbx() && |
| 36 | (core_tile_pbx11mp() || core_tile_pbxa9mp())) |
| 37 | return __io_address(REALVIEW_PBX_TILE_SCU_BASE); |
Catalin Marinas | 1bbdf63 | 2008-12-01 14:54:58 +0000 | [diff] [blame] | 38 | else |
| 39 | return (void __iomem *)0; |
| 40 | } |
| 41 | |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 42 | /* |
| 43 | * Initialise the CPU possible map early - this describes the CPUs |
| 44 | * which may be present or become present in the system. |
| 45 | */ |
| 46 | void __init smp_init_cpus(void) |
| 47 | { |
Russell King | fd778f0 | 2010-12-02 18:09:37 +0000 | [diff] [blame] | 48 | void __iomem *scu_base = scu_base_addr(); |
| 49 | unsigned int i, ncores; |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 50 | |
Russell King | fd778f0 | 2010-12-02 18:09:37 +0000 | [diff] [blame] | 51 | ncores = scu_base ? scu_get_core_count(scu_base) : 1; |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 52 | |
| 53 | /* sanity check */ |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 54 | if (ncores > NR_CPUS) { |
| 55 | printk(KERN_WARNING |
| 56 | "Realview: no. of cores (%d) greater than configured " |
| 57 | "maximum of %d - clipping\n", |
| 58 | ncores, NR_CPUS); |
| 59 | ncores = NR_CPUS; |
| 60 | } |
| 61 | |
Russell King | bbc3d14 | 2010-12-03 10:42:58 +0000 | [diff] [blame] | 62 | for (i = 0; i < ncores; i++) |
| 63 | set_cpu_possible(i, true); |
| 64 | } |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 65 | |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 66 | void __init platform_smp_prepare_cpus(unsigned int max_cpus) |
Russell King | bbc3d14 | 2010-12-03 10:42:58 +0000 | [diff] [blame] | 67 | { |
Russell King | bbc3d14 | 2010-12-03 10:42:58 +0000 | [diff] [blame] | 68 | int i; |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 69 | |
Russell King | 2a98beb | 2005-11-09 10:50:29 +0000 | [diff] [blame] | 70 | /* |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 71 | * Initialise the present map, which describes the set of CPUs |
| 72 | * actually populated at the present time. |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 73 | */ |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 74 | for (i = 0; i < max_cpus; i++) |
Russell King | e03cdad | 2009-05-28 14:16:52 +0100 | [diff] [blame] | 75 | set_cpu_present(i, true); |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 76 | |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 77 | scu_enable(scu_base_addr()); |
Russell King | bc28248 | 2009-05-17 18:58:34 +0100 | [diff] [blame] | 78 | |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 79 | /* |
| 80 | * Write the address of secondary startup into the |
| 81 | * system-wide flags register. The BootMonitor waits |
| 82 | * until it receives a soft interrupt, and then the |
| 83 | * secondary CPU branches to this address. |
| 84 | */ |
Russell King | 0462b44 | 2011-01-19 10:24:56 +0000 | [diff] [blame^] | 85 | __raw_writel(BSYM(virt_to_phys(versatile_secondary_startup)), |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 86 | __io_address(REALVIEW_SYS_FLAGSSET)); |
Russell King | 862184f | 2005-11-07 21:05:42 +0000 | [diff] [blame] | 87 | } |