From patchwork Wed Aug 7 22:55:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2840626 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB0D99F493 for ; Wed, 7 Aug 2013 22:55:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A73492050D for ; Wed, 7 Aug 2013 22:55:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E6992050C for ; Wed, 7 Aug 2013 22:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933540Ab3HGWza (ORCPT ); Wed, 7 Aug 2013 18:55:30 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:35228 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933451Ab3HGWz3 (ORCPT ); Wed, 7 Aug 2013 18:55:29 -0400 Received: by mail-pb0-f52.google.com with SMTP id wz12so2435978pbc.25 for ; Wed, 07 Aug 2013 15:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=llIIp91gZaZ21fxGGa5lSXAeK0HfclJ0PllMpDwznlU=; b=hN1I94Gcd590kftsk4Uj/lhYEXikmScBVZ/txZWIGCzRRhq577xZ+mJvNwdlGZBhd/ ZOkkiebTQq3Pt0KnNa78sYesKcnKuyOlRMA7RtzAQElfDvXySjrW3UQRO1rX3mGDwPzU x9TVCvYTIWSQMXtwv3Vd9nwQkQQPEyKCViC/VsZmVN5nDj/vnuQQ9wy7IT2yIQFRRxRp XP9yoaqYAUjN364j/ffgUKqXNKNPUg72tZUX8HHTmyPt6+q5MJYUpGqv2f+GUIMr5e9r k1V2hs02V2kFKD7EkZ56rxDnOxz6FTiVFxpt97RzX9eUR7Tc6vlTUgl/2l/423mUvg61 IwBw== X-Received: by 10.68.241.198 with SMTP id wk6mr2832249pbc.165.1375916129222; Wed, 07 Aug 2013 15:55:29 -0700 (PDT) Received: from [127.0.0.1] (ac230065.ppp.asahi-net.or.jp. [183.77.230.65]) by mx.google.com with ESMTPSA id oj6sm12677862pab.9.2013.08.07.15.55.26 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Aug 2013 15:55:27 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: olof@lixom.net, Magnus Damm , horms@verge.net.au, linux-arm-kernel@lists.infradead.org, arnd@arndb.de Date: Thu, 08 Aug 2013 07:55:40 +0900 Message-Id: <20130807225540.9856.67383.sendpatchset@w520> In-Reply-To: <20130807225531.9856.18974.sendpatchset@w520> References: <20130807225531.9856.18974.sendpatchset@w520> Subject: [PATCH 01/02] ARM: shmobile: Add r8a73a4 SMP support using APMU code 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Magnus Damm Add r8a73a4 SMP support using the shared APMU code. To enable SMP the r8a73a4 specific DTS needs to be updated to include CPU cores, and this is happening in a separate patch. Signed-off-by: Magnus Damm --- arch/arm/mach-shmobile/Makefile | 1 arch/arm/mach-shmobile/include/mach/r8a73a4.h | 1 arch/arm/mach-shmobile/setup-r8a73a4.c | 3 + arch/arm/mach-shmobile/smp-r8a73a4.c | 75 +++++++++++++++++++++++++ 4 files changed, 80 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/arch/arm/mach-shmobile/Makefile +++ work/arch/arm/mach-shmobile/Makefile 2013-08-07 20:07:31.000000000 +0900 @@ -33,6 +33,7 @@ endif # SMP objects smp-y := platsmp.o headsmp.o smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o headsmp-scu.o platsmp-scu.o +smp-$(CONFIG_ARCH_R8A73A4) += smp-r8a73a4.o platsmp-apmu.o smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o headsmp-scu.o platsmp-scu.o smp-$(CONFIG_ARCH_EMEV2) += smp-emev2.o headsmp-scu.o platsmp-scu.o --- 0008/arch/arm/mach-shmobile/include/mach/r8a73a4.h +++ work/arch/arm/mach-shmobile/include/mach/r8a73a4.h 2013-08-07 20:08:02.000000000 +0900 @@ -6,5 +6,6 @@ void r8a73a4_add_dt_devices(void); void r8a73a4_clock_init(void); void r8a73a4_pinmux_init(void); void r8a73a4_init_early(void); +extern struct smp_operations r8a73a4_smp_ops; #endif /* __ASM_R8A73A4_H__ */ --- 0008/arch/arm/mach-shmobile/setup-r8a73a4.c +++ work/arch/arm/mach-shmobile/setup-r8a73a4.c 2013-08-07 20:07:48.000000000 +0900 @@ -212,6 +212,9 @@ void __init r8a73a4_init_early(void) #ifndef CONFIG_ARM_ARCH_TIMER shmobile_setup_delay(1500, 2, 4); /* Cortex-A15 @ 1500MHz */ #endif +#ifdef CONFIG_SMP + smp_set_ops(&r8a73a4_smp_ops); +#endif } #ifdef CONFIG_USE_OF --- /dev/null +++ work/arch/arm/mach-shmobile/smp-r8a73a4.c 2013-08-07 20:09:10.000000000 +0900 @@ -0,0 +1,75 @@ +/* + * SMP support for r8a73a4 + * + * 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 + +#define SYSC 0xe6180000 +#define CA7BAR 0x4020 +#define CA15BAR 0x6020 +#define RESCNT 0x801c +#define MERAM 0xe8080000 +#define CCI_BASE 0xf0190000 +#define CCI_SLAVE3 0x4000 +#define CCI_SLAVE4 0x5000 +#define CCI_SNOOP 0x0000 +#define CCI_STATUS 0x000c + +static void __init r8a73a4_smp_prepare_cpus(unsigned int max_cpus) +{ + u32 bar; + void __iomem *p; + + /* let APMU code install data related to shmobile_boot_vector */ + shmobile_smp_apmu_prepare_cpus(max_cpus); + + /* MERAM for jump stub, because BAR requires 256KB aligned address */ + p = ioremap_nocache(MERAM, shmobile_boot_size); + memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size); + iounmap(p); + + /* setup reset vector and disable reset */ + p = ioremap_nocache(SYSC, 0x9000); + bar = (MERAM >> 8) & 0xfffffc00; + writel_relaxed(bar, p + CA15BAR); + writel_relaxed(bar, p + CA7BAR); + writel_relaxed(bar | 0x10, p + CA15BAR); + writel_relaxed(bar | 0x10, p + CA7BAR); + writel_relaxed(readl_relaxed(p + RESCNT) & ~(1 << 10), p + RESCNT); + writel_relaxed(readl_relaxed(p + RESCNT) & ~(1 << 9), p + RESCNT); + iounmap(p); + + /* enable snoop and DVM */ + p = ioremap_nocache(CCI_BASE, 0x8000); + writel_relaxed(3, p + CCI_SLAVE3 + CCI_SNOOP); /* CA15 */ + writel_relaxed(3, p + CCI_SLAVE4 + CCI_SNOOP); /* CA7 */ + while (readl_relaxed(p + CCI_STATUS)) + /* wait for pending bit low */; + iounmap(p); +} + +struct smp_operations r8a73a4_smp_ops __initdata = { + .smp_prepare_cpus = r8a73a4_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 +};