Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp786550imm; Tue, 5 Jun 2018 04:35:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJKxxqq/R5k3N8Qxv/jOCPZVUIUDpceVng99FBwL6mmRk12sHcS/8v8Kiu8lbkmwBfoBhkd X-Received: by 2002:a65:404d:: with SMTP id h13-v6mr16532428pgp.62.1528198539387; Tue, 05 Jun 2018 04:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528198539; cv=none; d=google.com; s=arc-20160816; b=QLJC6NW7tcs0VIhZbwceFfd+h/PbJ/XNgjM7sYKZUivEDgk76uGS/ktaMi5VTldGE4 JC/3iTidcEJHjW23B99Cc3WNZAreWqi16SLYHby6Fe05bG82XwAz7ZzJFjDFH0KcMa6F wlv16HOg2Hy9MWY9KajwSu+BJ7F8rVK14elfBykZFRZsVTDMfSQbb8yD90IQC65+VNRr EzN/CcQanXGgVcb3IZWV3uQcSGKNqBzqX7TfEZIrIbeYq5O9a9S3qRvlPBqDvztTNEsX 4C5x6XUjSla7dBf5xLTdOX0N4EmHox8q/+dHQrs8oo1vk/F+mkgbOrsoTkqJ+D0f5q+a ssXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Jz6HSHmOLHwNtM+35j36YffKLmbZekQB41b9t+CnaCc=; b=r1C43ASRUPs4/gqwqi+3lgwsa6LIripTq0YGge2eCGVVIuXZU4WATcf39cvRztJlP0 cktKcC1TDDOPArU9LyqZmo0G4ZxpoMOyf6a1UsWRKq+G9ztWTgzl/XK3nhdc9O0EMQAf mdYxcSe2doOavhOJXTGUgnFATx018fwAT7AxhBV2LtJyL9/WRaYGlGia/P8wFIAa0EFp afRDb9kfqjEm/KozIcSorb89KnELqFyBGwXQOVd9RIvWBLHez1uJtZGLBMfvTRMsThV3 TA58IOwdJul6r1B7q8M7rBX4tMT9E9+XBk9ynwQItGxbKkM1yS89h1S5QqWQMwgtnZzv G9Dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si48030392plz.290.2018.06.05.04.35.24; Tue, 05 Jun 2018 04:35:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751844AbeFELek (ORCPT + 99 others); Tue, 5 Jun 2018 07:34:40 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:58304 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751534AbeFELei (ORCPT ); Tue, 5 Jun 2018 07:34:38 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 05 Jun 2018 20:34:37 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 2E9A2836C1; Tue, 5 Jun 2018 20:34:37 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.49,478,1520866800"; d="scan'208";a="283089225" Received: from unknown (HELO be1yocto.ree.adwin.renesas.com) ([172.29.43.62]) by relmlii2.idc.renesas.com with ESMTP; 05 Jun 2018 20:34:32 +0900 From: Michel Pollet To: linux-renesas-soc@vger.kernel.org, Simon Horman Cc: phil.edworthy@renesas.com, Michel Pollet , Michel Pollet , Rob Herring , Mark Rutland , Magnus Damm , Russell King , Florian Fainelli , Chen-Yu Tsai , Douglas Anderson , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Rajendra Nayak , Stefan Wahren , Frank Rowand , Carlo Caione , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/3] arm: shmobile: Add the R9A06G032 SMP enabler driver Date: Tue, 5 Jun 2018 12:28:47 +0100 Message-Id: <1528198148-23308-3-git-send-email-michel.pollet@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528198148-23308-1-git-send-email-michel.pollet@bp.renesas.com> References: <1528198148-23308-1-git-send-email-michel.pollet@bp.renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Renesas R9A06G032 second CA7 is parked in a ROM pen at boot time, it requires a special enable method to get it started. Signed-off-by: Michel Pollet --- arch/arm/mach-shmobile/Makefile | 1 + arch/arm/mach-shmobile/smp-r9a06g032.c | 79 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 arch/arm/mach-shmobile/smp-r9a06g032.c diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 1939f52..d7fc98f 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -34,6 +34,7 @@ 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_R9A06G032) += smp-r9a06g032.o smp-$(CONFIG_ARCH_EMEV2) += smp-emev2.o headsmp-scu.o platsmp-scu.o # PM objects diff --git a/arch/arm/mach-shmobile/smp-r9a06g032.c b/arch/arm/mach-shmobile/smp-r9a06g032.c new file mode 100644 index 0000000..cd40e6e --- /dev/null +++ b/arch/arm/mach-shmobile/smp-r9a06g032.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * R9A06G032 Second CA7 enabler. + * + * Copyright (C) 2018 Renesas Electronics Europe Limited + * + * Michel Pollet , + * Derived from action,s500-smp + */ + +#include +#include +#include +#include + +/* + * The second CPU is parked in ROM at boot time. It requires waking it after + * writing an address into the BOOTADDR register of sysctrl. + * + * So the default value of the "cpu-release-addr" corresponds to BOOTADDR... + * + * *However* the BOOTADDR register is not available when the kernel + * starts in NONSEC mode. + * + * So for NONSEC mode, the bootloader re-parks the second CPU into a pen + * in SRAM, and changes the "cpu-release-addr" of linux's DT to a SRAM address, + * which is not restricted. + */ + +static void __iomem *cpu_bootaddr; + +static DEFINE_SPINLOCK(cpu_lock); + +static int r9a06g032_smp_boot_secondary(unsigned int cpu, struct task_struct *idle) +{ + if (!cpu_bootaddr) + return -ENODEV; + + spin_lock(&cpu_lock); + + writel(__pa_symbol(secondary_startup), cpu_bootaddr); + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); + + spin_unlock(&cpu_lock); + + return 0; +} + +static void __init r9a06g032_smp_prepare_cpus(unsigned int max_cpus) +{ + struct device_node *dn; + int ret; + u32 bootaddr; + + dn = of_get_cpu_node(1, NULL); + if (!dn) { + pr_err("CPU#1: missing device tree node\n"); + return; + } + /* + * Determine the address from which the CPU is polling. + * The bootloader *does* change this property + */ + ret = of_property_read_u32(dn, "cpu-release-addr", &bootaddr); + of_node_put(dn); + if (ret) { + pr_err("CPU#1: invalid cpu-release-addr property\n"); + return; + } + pr_info("CPU#1: cpu-release-addr %08x\n", bootaddr); + + cpu_bootaddr = ioremap(bootaddr, sizeof(bootaddr)); +} + +static const struct smp_operations r9a06g032_smp_ops __initconst = { + .smp_prepare_cpus = r9a06g032_smp_prepare_cpus, + .smp_boot_secondary = r9a06g032_smp_boot_secondary, +}; +CPU_METHOD_OF_DECLARE(r9a06g032_smp, "renesas,r9a06g032-smp", &r9a06g032_smp_ops); -- 2.7.4