Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 ARM Ltd. |
| 3 | * Copyright (C) 2008 STMicroelctronics. |
| 4 | * Copyright (C) 2009 ST-Ericsson. |
| 5 | * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> |
| 6 | * |
| 7 | * This file is based on arm realview platform |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/errno.h> |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/smp.h> |
| 18 | #include <linux/io.h> |
Linus Walleij | 5820203 | 2015-05-14 09:46:40 +0200 | [diff] [blame] | 19 | #include <linux/of.h> |
| 20 | #include <linux/of_address.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 21 | |
| 22 | #include <asm/cacheflush.h> |
Will Deacon | eb50439 | 2012-01-20 12:01:12 +0100 | [diff] [blame] | 23 | #include <asm/smp_plat.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 24 | #include <asm/smp_scu.h> |
Linus Walleij | 7a4f260 | 2012-09-19 19:31:19 +0200 | [diff] [blame] | 25 | |
Arnd Bergmann | e657bcf | 2013-03-21 22:51:12 +0100 | [diff] [blame] | 26 | #include "setup.h" |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 27 | |
Linus Walleij | 174e779 | 2013-03-19 15:41:55 +0100 | [diff] [blame] | 28 | #include "db8500-regs.h" |
Linus Walleij | 7a4f260 | 2012-09-19 19:31:19 +0200 | [diff] [blame] | 29 | |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 30 | /* Magic triggers in backup RAM */ |
| 31 | #define UX500_CPU1_JUMPADDR_OFFSET 0x1FF4 |
| 32 | #define UX500_CPU1_WAKEMAGIC_OFFSET 0x1FF0 |
Linus Walleij | 2d6dd17 | 2015-05-14 09:20:23 +0200 | [diff] [blame] | 33 | |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 34 | static void wakeup_secondary(void) |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 35 | { |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 36 | struct device_node *np; |
| 37 | static void __iomem *backupram; |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 38 | |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 39 | np = of_find_compatible_node(NULL, NULL, "ste,dbx500-backupram"); |
| 40 | if (!np) { |
| 41 | pr_err("No backupram base address\n"); |
| 42 | return; |
| 43 | } |
| 44 | backupram = of_iomap(np, 0); |
| 45 | of_node_put(np); |
| 46 | if (!backupram) { |
| 47 | pr_err("No backupram remap\n"); |
| 48 | return; |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | /* |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 52 | * write the address of secondary startup into the backup ram register |
| 53 | * at offset 0x1FF4, then write the magic number 0xA1FEED01 to the |
| 54 | * backup ram register at offset 0x1FF0, which is what boot rom code |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 55 | * is waiting for. This will wake up the secondary core from WFE. |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 56 | */ |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 57 | writel(virt_to_phys(secondary_startup), |
| 58 | backupram + UX500_CPU1_JUMPADDR_OFFSET); |
| 59 | writel(0xA1FEED01, |
| 60 | backupram + UX500_CPU1_WAKEMAGIC_OFFSET); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 61 | |
| 62 | /* make sure write buffer is drained */ |
| 63 | mb(); |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 64 | iounmap(backupram); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Marc Zyngier | 5ac21a9 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 67 | static void __init ux500_smp_prepare_cpus(unsigned int max_cpus) |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 68 | { |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 69 | struct device_node *np; |
| 70 | static void __iomem *scu_base; |
| 71 | unsigned int ncores; |
| 72 | int i; |
| 73 | |
| 74 | np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu"); |
| 75 | if (!np) { |
| 76 | pr_err("No SCU base address\n"); |
| 77 | return; |
| 78 | } |
| 79 | scu_base = of_iomap(np, 0); |
| 80 | of_node_put(np); |
| 81 | if (!scu_base) { |
| 82 | pr_err("No SCU remap\n"); |
| 83 | return; |
| 84 | } |
| 85 | |
Linus Walleij | 2d6dd17 | 2015-05-14 09:20:23 +0200 | [diff] [blame] | 86 | scu_enable(scu_base); |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 87 | ncores = scu_get_core_count(scu_base); |
| 88 | for (i = 0; i < ncores; i++) |
| 89 | set_cpu_possible(i, true); |
| 90 | iounmap(scu_base); |
| 91 | } |
| 92 | |
| 93 | static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 94 | { |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 95 | wakeup_secondary(); |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 96 | arch_send_wakeup_ipi_mask(cpumask_of(cpu)); |
| 97 | return 0; |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 98 | } |
Marc Zyngier | 5ac21a9 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 99 | |
Masahiro Yamada | 7530527 | 2015-11-15 10:39:53 +0900 | [diff] [blame] | 100 | static const struct smp_operations ux500_smp_ops __initconst = { |
Marc Zyngier | 5ac21a9 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 101 | .smp_prepare_cpus = ux500_smp_prepare_cpus, |
Marc Zyngier | 5ac21a9 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 102 | .smp_boot_secondary = ux500_boot_secondary, |
| 103 | #ifdef CONFIG_HOTPLUG_CPU |
| 104 | .cpu_die = ux500_cpu_die, |
| 105 | #endif |
| 106 | }; |
Linus Walleij | c00def7 | 2015-08-03 09:26:52 +0200 | [diff] [blame] | 107 | CPU_METHOD_OF_DECLARE(ux500_smp, "ste,dbx500-smp", &ux500_smp_ops); |