From patchwork Wed Mar 25 05:45:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaku Inami X-Patchwork-Id: 6088181 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5CE9DBF90F for ; Wed, 25 Mar 2015 05:51:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECD1C2034E for ; Wed, 25 Mar 2015 05:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37360202EB for ; Wed, 25 Mar 2015 05:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750868AbbCYFvH (ORCPT ); Wed, 25 Mar 2015 01:51:07 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:62957 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751912AbbCYFvG (ORCPT ); Wed, 25 Mar 2015 01:51:06 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 25 Mar 2015 14:51:04 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 62EDA47A5B; Wed, 25 Mar 2015 14:51:04 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 4871E480A4; Wed, 25 Mar 2015 14:51:04 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 4280A480A3; Wed, 25 Mar 2015 14:51:04 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id QBL05584; Wed, 25 Mar 2015 14:51:04 +0900 X-IronPort-AV: E=Sophos;i="5.11,463,1422889200"; d="scan'208";a="182698638" Received: from mail-sg1lp0090.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.90]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 25 Mar 2015 14:51:03 +0900 Received: from [10.164.207.238] (211.11.155.149) by HKXPR06MB0534.apcprd06.prod.outlook.com (25.161.137.23) with Microsoft SMTP Server (TLS) id 15.1.118.21; Wed, 25 Mar 2015 05:51:01 +0000 Message-ID: <55124B7F.3060103@bp.renesas.com> Date: Wed, 25 Mar 2015 14:45:35 +0900 From: Gaku Inami User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: CC: , , Subject: [RFC/PATCH] ARM: shmobile: Consolidate the smp code for R-Car Gen2 X-Originating-IP: [211.11.155.149] X-ClientProxiedBy: OS2PR01CA0011.jpnprd01.prod.outlook.com (25.161.74.149) To HKXPR06MB0534.apcprd06.prod.outlook.com (25.161.137.23) Authentication-Results: linux-m68k.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HKXPR06MB0534; X-Forefront-Antispam-Report: BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(6049001)(50986999)(65806001)(42186005)(122386002)(64126003)(110136001)(77096005)(33656002)(120846001)(46102003)(92566002)(65956001)(40100003)(66066001)(50466002)(62966003)(77156002)(2351001)(229853001)(83506001)(54356999)(86362001)(80316001)(575784001)(87266999)(87976001)(19580405001)(65816999)(19580395003)(99136001)(23736002)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:HKXPR06MB0534; H:[10.164.207.238]; FPR:; SPF:None; MLV:sfv; LANG:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:HKXPR06MB0534; BCL:0; PCL:0; RULEID:; SRVR:HKXPR06MB0534; X-Forefront-PRVS: 052670E5A4 X-OriginatorOrg: bp.renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2015 05:51:01.9208 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKXPR06MB0534 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The smp code for R-Car Gen2 is scatterd in each SoC. These files (smp-r8a7790.c/smp-r8a7791.c) have some overlap code. This change consolidate the smp code for R-Car Gen2 into one. Signed-off-by: Gaku Inami --- Based on : renesas-devel-20150324-v4.0-rc5 arch/arm/mach-shmobile/Makefile | 3 +- arch/arm/mach-shmobile/r8a7790.h | 6 -- arch/arm/mach-shmobile/r8a7791.h | 6 -- arch/arm/mach-shmobile/rcar-gen2.h | 2 + arch/arm/mach-shmobile/setup-r8a7790.c | 3 +- arch/arm/mach-shmobile/setup-r8a7791.c | 3 +- arch/arm/mach-shmobile/smp-r8a7790.c | 71 ------------------ arch/arm/mach-shmobile/smp-r8a7791.c | 65 ----------------- arch/arm/mach-shmobile/smp-rcar-gen2.c | 125 ++++++++++++++++++++++++++++++++ 9 files changed, 130 insertions(+), 154 deletions(-) delete mode 100644 arch/arm/mach-shmobile/r8a7790.h delete mode 100644 arch/arm/mach-shmobile/r8a7791.h delete mode 100644 arch/arm/mach-shmobile/smp-r8a7790.c delete mode 100644 arch/arm/mach-shmobile/smp-r8a7791.c create mode 100644 arch/arm/mach-shmobile/smp-rcar-gen2.c diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 89e463d..a5e42d6 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -39,9 +39,8 @@ obj-$(CONFIG_ARCH_R8A7791) += regulator-quirk-rcar-gen2.o smp-y := $(cpu-y) smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o headsmp-scu.o platsmp-scu.o smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o headsmp-scu.o platsmp-scu.o -smp-$(CONFIG_ARCH_R8A7790) += smp-r8a7790.o -smp-$(CONFIG_ARCH_R8A7791) += smp-r8a7791.o smp-$(CONFIG_ARCH_EMEV2) += smp-emev2.o headsmp-scu.o platsmp-scu.o +smp-$(CONFIG_ARCH_RCAR_GEN2) += smp-rcar-gen2.o # PM objects obj-$(CONFIG_SUSPEND) += suspend.o diff --git a/arch/arm/mach-shmobile/r8a7790.h b/arch/arm/mach-shmobile/r8a7790.h deleted file mode 100644 index 1a46d02..0000000 --- a/arch/arm/mach-shmobile/r8a7790.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __ASM_R8A7790_H__ -#define __ASM_R8A7790_H__ - -extern struct smp_operations r8a7790_smp_ops; - -#endif /* __ASM_R8A7790_H__ */ diff --git a/arch/arm/mach-shmobile/r8a7791.h b/arch/arm/mach-shmobile/r8a7791.h deleted file mode 100644 index 7ca0b7d..0000000 --- a/arch/arm/mach-shmobile/r8a7791.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __ASM_R8A7791_H__ -#define __ASM_R8A7791_H__ - -extern struct smp_operations r8a7791_smp_ops; - -#endif /* __ASM_R8A7791_H__ */ diff --git a/arch/arm/mach-shmobile/rcar-gen2.h b/arch/arm/mach-shmobile/rcar-gen2.h index 8a66b4a..a0b811f 100644 --- a/arch/arm/mach-shmobile/rcar-gen2.h +++ b/arch/arm/mach-shmobile/rcar-gen2.h @@ -7,4 +7,6 @@ u32 rcar_gen2_read_mode_pins(void); void rcar_gen2_reserve(void); void rcar_gen2_pm_init(void); +extern struct smp_operations rcar_gen2_smp_ops; + #endif /* __ASM_RCAR_GEN2_H__ */ diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c index 3a18af4..2e59dd2 100644 --- a/arch/arm/mach-shmobile/setup-r8a7790.c +++ b/arch/arm/mach-shmobile/setup-r8a7790.c @@ -19,7 +19,6 @@ #include #include "common.h" -#include "r8a7790.h" #include "rcar-gen2.h" static const char * const r8a7790_boards_compat_dt[] __initconst = { @@ -28,7 +27,7 @@ static const char * const r8a7790_boards_compat_dt[] __initconst = { }; DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)") - .smp = smp_ops(r8a7790_smp_ops), + .smp = smp_ops(rcar_gen2_smp_ops), .init_early = shmobile_init_delay, .init_time = rcar_gen2_timer_init, .init_late = shmobile_init_late, diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c index ef8eb3a..cd77d3b 100644 --- a/arch/arm/mach-shmobile/setup-r8a7791.c +++ b/arch/arm/mach-shmobile/setup-r8a7791.c @@ -20,7 +20,6 @@ #include #include "common.h" -#include "r8a7791.h" #include "rcar-gen2.h" static const char *r8a7791_boards_compat_dt[] __initdata = { @@ -29,7 +28,7 @@ static const char *r8a7791_boards_compat_dt[] __initdata = { }; DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)") - .smp = smp_ops(r8a7791_smp_ops), + .smp = smp_ops(rcar_gen2_smp_ops), .init_early = shmobile_init_delay, .init_time = rcar_gen2_timer_init, .init_late = shmobile_init_late, diff --git a/arch/arm/mach-shmobile/smp-r8a7790.c b/arch/arm/mach-shmobile/smp-r8a7790.c deleted file mode 100644 index 930f45c..0000000 --- a/arch/arm/mach-shmobile/smp-r8a7790.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SMP support for r8a7790 - * - * Copyright (C) 2012-2013 Renesas Solutions Corp. - * Copyright (C) 2012 Takashi Yoshii - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include - -#include - -#include "common.h" -#include "platsmp-apmu.h" -#include "pm-rcar.h" -#include "rcar-gen2.h" -#include "r8a7790.h" - -static struct rcar_sysc_ch r8a7790_ca15_scu = { - .chan_offs = 0x180, /* PWRSR5 .. PWRER5 */ - .isr_bit = 12, /* CA15-SCU */ -}; - -static struct rcar_sysc_ch r8a7790_ca7_scu = { - .chan_offs = 0x100, /* PWRSR3 .. PWRER3 */ - .isr_bit = 21, /* CA7-SCU */ -}; - -static struct rcar_apmu_config r8a7790_apmu_config[] = { - { - .iomem = DEFINE_RES_MEM(0xe6152000, 0x188), - .cpus = { 0, 1, 2, 3 }, - }, - { - .iomem = DEFINE_RES_MEM(0xe6151000, 0x188), - .cpus = { 0x100, 0x0101, 0x102, 0x103 }, - } -}; - -static void __init r8a7790_smp_prepare_cpus(unsigned int max_cpus) -{ - /* let APMU code install data related to shmobile_boot_vector */ - shmobile_smp_apmu_prepare_cpus(max_cpus, - r8a7790_apmu_config, - ARRAY_SIZE(r8a7790_apmu_config)); - - /* turn on power to SCU */ - rcar_gen2_pm_init(); - rcar_sysc_power_up(&r8a7790_ca15_scu); - rcar_sysc_power_up(&r8a7790_ca7_scu); -} - -struct smp_operations r8a7790_smp_ops __initdata = { - .smp_prepare_cpus = r8a7790_smp_prepare_cpus, - .smp_boot_secondary = shmobile_smp_apmu_boot_secondary, -#ifdef CONFIG_HOTPLUG_CPU - .cpu_disable = shmobile_smp_cpu_disable, - .cpu_die = shmobile_smp_apmu_cpu_die, - .cpu_kill = shmobile_smp_apmu_cpu_kill, -#endif -}; diff --git a/arch/arm/mach-shmobile/smp-r8a7791.c b/arch/arm/mach-shmobile/smp-r8a7791.c deleted file mode 100644 index 5e2d1db..0000000 --- a/arch/arm/mach-shmobile/smp-r8a7791.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SMP support for r8a7791 - * - * Copyright (C) 2013 Renesas Solutions Corp. - * Copyright (C) 2013 Magnus Damm - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include - -#include - -#include "common.h" -#include "platsmp-apmu.h" -#include "r8a7791.h" -#include "rcar-gen2.h" - -static struct rcar_apmu_config r8a7791_apmu_config[] = { - { - .iomem = DEFINE_RES_MEM(0xe6152000, 0x188), - .cpus = { 0, 1 }, - } -}; - -static void __init r8a7791_smp_prepare_cpus(unsigned int max_cpus) -{ - /* let APMU code install data related to shmobile_boot_vector */ - shmobile_smp_apmu_prepare_cpus(max_cpus, - r8a7791_apmu_config, - ARRAY_SIZE(r8a7791_apmu_config)); - - rcar_gen2_pm_init(); -} - -static int r8a7791_smp_boot_secondary(unsigned int cpu, - struct task_struct *idle) -{ - /* Error out when hardware debug mode is enabled */ - if (rcar_gen2_read_mode_pins() & BIT(21)) { - pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu); - return -ENOTSUPP; - } - - return shmobile_smp_apmu_boot_secondary(cpu, idle); -} - -struct smp_operations r8a7791_smp_ops __initdata = { - .smp_prepare_cpus = r8a7791_smp_prepare_cpus, - .smp_boot_secondary = r8a7791_smp_boot_secondary, -#ifdef CONFIG_HOTPLUG_CPU - .cpu_disable = shmobile_smp_cpu_disable, - .cpu_die = shmobile_smp_apmu_cpu_die, - .cpu_kill = shmobile_smp_apmu_cpu_kill, -#endif -}; diff --git a/arch/arm/mach-shmobile/smp-rcar-gen2.c b/arch/arm/mach-shmobile/smp-rcar-gen2.c new file mode 100644 index 0000000..fcf79f7 --- /dev/null +++ b/arch/arm/mach-shmobile/smp-rcar-gen2.c @@ -0,0 +1,125 @@ +/* + * R-Car Generation 2 SMP support + * + * Copyright (C) 2015 Renesas Electronics Corporation + * Copyright (C) 2013 Magnus Damm + * Copyright (C) 2012-2013 Renesas Solutions Corp. + * Copyright (C) 2012 Takashi Yoshii + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include + +#include +#include + +#include "common.h" +#include "platsmp-apmu.h" +#include "pm-rcar.h" +#include "rcar-gen2.h" + +static struct rcar_sysc_ch rcar_gen2_ca15_scu = { + .chan_offs = 0x180, /* PWRSR5 .. PWRER5 */ + .isr_bit = 12, /* CA15-SCU */ +}; + +static struct rcar_sysc_ch rcar_gen2_ca7_scu = { + .chan_offs = 0x100, /* PWRSR3 .. PWRER3 */ + .isr_bit = 21, /* CA7-SCU */ +}; + +static struct rcar_apmu_config r8a7790_apmu_config[] = { + { + .iomem = DEFINE_RES_MEM(0xe6152000, 0x188), + .cpus = { 0, 1, 2, 3 }, + }, + { + .iomem = DEFINE_RES_MEM(0xe6151000, 0x188), + .cpus = { 0x100, 0x0101, 0x102, 0x103 }, + } +}; + +static struct rcar_apmu_config r8a7791_apmu_config[] = { + { + .iomem = DEFINE_RES_MEM(0xe6152000, 0x188), + .cpus = { 0, 1 }, + } +}; + +static void __init rcar_gen2_smp_prepare_cpus(unsigned int max_cpus) +{ + struct device_node *np, *cpus; + bool has_a7 = false; + bool has_a15 = false; + u32 this_cluster; + struct rcar_apmu_config *rcar_gen2_apmu_config; + u32 rcar_apmu_config_size; + + cpus = of_find_node_by_path("/cpus"); + if (!cpus) + return; + + for_each_child_of_node(cpus, np) { + if (of_device_is_compatible(np, "arm,cortex-a15")) + has_a15 = true; + else if (of_device_is_compatible(np, "arm,cortex-a7")) + has_a7 = true; + } + + if (of_machine_is_compatible("renesas,r8a7790")) { + rcar_gen2_apmu_config = &r8a7790_apmu_config[0]; + rcar_apmu_config_size = ARRAY_SIZE(r8a7790_apmu_config); + } else if (of_machine_is_compatible("renesas,r8a7791")) { + rcar_gen2_apmu_config = &r8a7791_apmu_config[0]; + rcar_apmu_config_size = ARRAY_SIZE(r8a7791_apmu_config); + } + + /* let APMU code install data related to shmobile_boot_vector */ + shmobile_smp_apmu_prepare_cpus(max_cpus, + rcar_gen2_apmu_config, + rcar_apmu_config_size); + + rcar_gen2_pm_init(); + + /* turn on power to SCU of second cluster */ + if (has_a15 && has_a7) { + this_cluster = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 1); + if (this_cluster == 0) + rcar_sysc_power_up(&rcar_gen2_ca7_scu); + else + rcar_sysc_power_up(&rcar_gen2_ca15_scu); + } +} + +static int rcar_gen2_smp_boot_secondary(unsigned int cpu, + struct task_struct *idle) +{ + /* Error out when hardware debug mode is enabled */ + if (of_machine_is_compatible("renesas,r8a7791") && + rcar_gen2_read_mode_pins() & BIT(21)) { + pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu); + return -ENOTSUPP; + } + + return shmobile_smp_apmu_boot_secondary(cpu, idle); +} + +struct smp_operations rcar_gen2_smp_ops __initdata = { + .smp_prepare_cpus = rcar_gen2_smp_prepare_cpus, + .smp_boot_secondary = rcar_gen2_smp_boot_secondary, +#ifdef CONFIG_HOTPLUG_CPU + .cpu_disable = shmobile_smp_cpu_disable, + .cpu_die = shmobile_smp_apmu_cpu_die, + .cpu_kill = shmobile_smp_apmu_cpu_kill, +#endif +};