Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 1 | /* |
| 2 | * SMP support for R-Mobile / SH-Mobile - sh73a0 portion |
| 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * Copyright (C) 2010 Takashi Yoshii |
| 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 as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 15 | */ |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/smp.h> |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 19 | #include <linux/io.h> |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 20 | #include <linux/delay.h> |
Geert Uytterhoeven | ded59d6 | 2014-06-20 18:53:09 +0200 | [diff] [blame] | 21 | |
Magnus Damm | 352e57a | 2013-07-31 16:07:59 +0900 | [diff] [blame] | 22 | #include <asm/smp_plat.h> |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 23 | #include <asm/smp_twd.h> |
Geert Uytterhoeven | ded59d6 | 2014-06-20 18:53:09 +0200 | [diff] [blame] | 24 | |
Magnus Damm | fd44aa5 | 2014-06-17 16:47:37 +0900 | [diff] [blame] | 25 | #include "common.h" |
Geert Uytterhoeven | ded59d6 | 2014-06-20 18:53:09 +0200 | [diff] [blame] | 26 | #include "sh73a0.h" |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 27 | |
Rob Herring | a2a47ca | 2012-03-09 17:16:40 -0600 | [diff] [blame] | 28 | #define WUPCR IOMEM(0xe6151010) |
| 29 | #define SRESCR IOMEM(0xe6151018) |
| 30 | #define PSTR IOMEM(0xe6151040) |
| 31 | #define SBAR IOMEM(0xe6180020) |
| 32 | #define APARMBAREA IOMEM(0xe6f10020) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 33 | |
Magnus Damm | 7685350 | 2013-02-18 22:47:07 +0900 | [diff] [blame] | 34 | #define SH73A0_SCU_BASE 0xf0000000 |
Magnus Damm | aa8d3bb | 2013-02-13 22:46:38 +0900 | [diff] [blame] | 35 | |
Paul Gortmaker | 8bd26e3 | 2013-06-17 15:43:14 -0400 | [diff] [blame] | 36 | static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 37 | { |
Magnus Damm | 12eb847 | 2013-07-31 16:07:21 +0900 | [diff] [blame] | 38 | unsigned int lcpu = cpu_logical_map(cpu); |
Magnus Damm | 12eb847 | 2013-07-31 16:07:21 +0900 | [diff] [blame] | 39 | |
| 40 | if (((__raw_readl(PSTR) >> (4 * lcpu)) & 3) == 3) |
| 41 | __raw_writel(1 << lcpu, WUPCR); /* wake up */ |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 42 | else |
Magnus Damm | 12eb847 | 2013-07-31 16:07:21 +0900 | [diff] [blame] | 43 | __raw_writel(1 << lcpu, SRESCR); /* reset */ |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 48 | static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus) |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 49 | { |
Magnus Damm | 12eb847 | 2013-07-31 16:07:21 +0900 | [diff] [blame] | 50 | /* Map the reset vector (in headsmp.S) */ |
Rob Herring | a2a47ca | 2012-03-09 17:16:40 -0600 | [diff] [blame] | 51 | __raw_writel(0, APARMBAREA); /* 4k */ |
Magnus Damm | abfa04e | 2013-06-10 18:20:06 +0900 | [diff] [blame] | 52 | __raw_writel(__pa(shmobile_boot_vector), SBAR); |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 53 | |
Magnus Damm | 12eb847 | 2013-07-31 16:07:21 +0900 | [diff] [blame] | 54 | /* setup sh73a0 specific SCU bits */ |
| 55 | shmobile_scu_base = IOMEM(SH73A0_SCU_BASE); |
| 56 | shmobile_smp_scu_prepare_cpus(max_cpus); |
Magnus Damm | 72f4d57 | 2010-12-14 16:57:11 +0900 | [diff] [blame] | 57 | } |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 58 | |
Masahiro Yamada | 7530527 | 2015-11-15 10:39:53 +0900 | [diff] [blame] | 59 | const struct smp_operations sh73a0_smp_ops __initconst = { |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 60 | .smp_prepare_cpus = sh73a0_smp_prepare_cpus, |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 61 | .smp_boot_secondary = sh73a0_boot_secondary, |
| 62 | #ifdef CONFIG_HOTPLUG_CPU |
Stephen Boyd | 787047e | 2015-07-29 00:34:48 +0100 | [diff] [blame] | 63 | .cpu_can_disable = shmobile_smp_cpu_can_disable, |
Magnus Damm | 352e57a | 2013-07-31 16:07:59 +0900 | [diff] [blame] | 64 | .cpu_die = shmobile_smp_scu_cpu_die, |
| 65 | .cpu_kill = shmobile_smp_scu_cpu_kill, |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 66 | #endif |
| 67 | }; |