Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp44609pxu; Tue, 1 Dec 2020 05:51:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5PRHKa1ox3r0HE/0YnK3Muycg3pFk3iS6sNqddYLiiie47FfqkMS7ImY/yLYgze/67dIy X-Received: by 2002:a50:fa92:: with SMTP id w18mr3139088edr.44.1606830710253; Tue, 01 Dec 2020 05:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606830710; cv=none; d=google.com; s=arc-20160816; b=MUfWglOEG6RM7avgbrQsZKbu759zBLIhIehUhflaKboyXXDmepymM5HrhgUXqskdbz TxX4ppriL/C9cHbQRx0tWZELG+x3IwpHxJ5L/0d6UL5j8AdvqoxgP/feAnvXGkNGNAtn 7BODTstUDXbW3BDVUn9JU2nusPwmRR58k4wdumEwrQDIzr6TVfSldkaiclMeOuaOYjY4 Mr5IjPAudrgCGC9Nq23X2dIKJxhWgAk1HKR0BZipsZmmXWVt6FdejnciMDMdYzhldXYx JwslHDFazr+LDoau4vl/hkSn19BndmhqZb/jMCwb6gG6i/r3rQSj/yggJkD6m4VGHwM+ uP8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hS2wM3FNHgJIyxJqyl8PuGsAWH0z3tsao6nHf2xVIB0=; b=DpTULu5NJXgh3/xDTLFEqWMjrwjA+qFqJ2j9KrZnSCdBwdOpu8yxjuNid29S5G3f9y lGF0hY+nq6JJBHNN5VJiNq7WYVrxo6GF5hkyaiuEoRmNM980Km7zRn2xsBK6ZS9jSos9 kOlhOsGLoUMMo94AHgqxRQeG7M6mUGRTaOHfR7aU8Jlen4zX9iV9LBrqK02uxdF6yafL YkpXJj1fBWvfYfo7K/lJHf3ikx6Op+1aljRedasivXAe8GZK+o+kOCQpfqUNYYg0ccEG V/ISKchi9VbnIEv3dP5AEXd5ZUrZikeQd5+iB/Dtz7ftep1FKP8DwjtIUlbmw4x65v52 R8lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@0x0f.com header.s=google header.b=nnfurCpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si1172526edn.152.2020.12.01.05.51.24; Tue, 01 Dec 2020 05:51:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@0x0f.com header.s=google header.b=nnfurCpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391272AbgLANph (ORCPT + 99 others); Tue, 1 Dec 2020 08:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387965AbgLANph (ORCPT ); Tue, 1 Dec 2020 08:45:37 -0500 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2CCC08C5F2 for ; Tue, 1 Dec 2020 05:44:06 -0800 (PST) Received: by mail-pj1-x1041.google.com with SMTP id v1so1249587pjr.2 for ; Tue, 01 Dec 2020 05:44:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hS2wM3FNHgJIyxJqyl8PuGsAWH0z3tsao6nHf2xVIB0=; b=nnfurCprKeYaMHdKwLLhAtc/7QpVAwGhPiDAysu4bgwUr0HPOE7DAtY2+DHE3HciSB qJwqpC+9ktJuXLvVQjVQh2XoVwielD3rNowfs4bNkzgY5SamuuXZAPkVrKYTncoBWhdL nPvmrVVHPUMiT7h//1NrmmPmFubTs8wcA+/QQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hS2wM3FNHgJIyxJqyl8PuGsAWH0z3tsao6nHf2xVIB0=; b=mHjn9RApKNYP5weyf5jvw+w32ky4EnIQewNeHP9PBgR2esAFI+FuEJftO4NlxBDNjn oKHDKs0SwO8jrrm5DScTLr7VuBTfhYgj6Cp5WtoVcTZmWuQSWmT5O02i3A31Fz9cp4Cv x0PpqzMS7YDvcnAeHJZvY2SyWtFhtDt2vystKFXQSG4UHuLz1uPfMA8cKTBD1AlCLpNx gYZSZVrExt+/YU+Fp1+p/2PqJHQ9vdPwM6F9R2C16pRiHY2DJYXHcW726k83gc0Yt/yR hQLgyd+l6PAs3lI4NyiOzpDjO0p12hiEyvSCAA8HVrF2AIn+GG4KU0Eo9JN1EVBr1hQz ztrw== X-Gm-Message-State: AOAM532IBtsrRhlVZ0nAvVZ418j/FFVX2bUxIDYSdDZ/tUSg3jVMvgNJ hOgQzp/BKvHfzdTQDTg9DYQdfQ== X-Received: by 2002:a17:902:9894:b029:da:5698:7f7b with SMTP id s20-20020a1709029894b02900da56987f7bmr2891979plp.78.1606830245846; Tue, 01 Dec 2020 05:44:05 -0800 (PST) Received: from shiro.work (p1268123-ipngn200803sizuokaden.shizuoka.ocn.ne.jp. [118.13.124.123]) by smtp.googlemail.com with ESMTPSA id g14sm2839248pji.32.2020.12.01.05.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 05:44:05 -0800 (PST) From: Daniel Palmer To: devicetree@vger.kernel.org, soc@kernel.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, olof@lixom.net, arnd@arndb.de, robh@kernel.org, w@1wt.eu, daniel@0x0f.com Subject: [PATCH v2 10/10] ARM: mstar: SMP support Date: Tue, 1 Dec 2020 22:43:30 +0900 Message-Id: <20201201134330.3037007-11-daniel@0x0f.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201134330.3037007-1-daniel@0x0f.com> References: <20201201134330.3037007-1-daniel@0x0f.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds SMP support for MStar/Sigmastar chips that have a second core like those in the infinity2m family. So far only single and dual core chips have been found so this does the bare minimum to boot the second core. From what I can tell not having the "holding pen" code to handle multiple cores is fine if there is only one core the will get booted. This might need to be reconsidered if chips with more cores turn up. Signed-off-by: Daniel Palmer --- arch/arm/mach-mstar/mstarv7.c | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/arm/mach-mstar/mstarv7.c b/arch/arm/mach-mstar/mstarv7.c index 1aa748fa006e..274c4f0df270 100644 --- a/arch/arm/mach-mstar/mstarv7.c +++ b/arch/arm/mach-mstar/mstarv7.c @@ -31,6 +31,13 @@ #define MSTARV7_L3BRIDGE_FLUSH_TRIGGER BIT(0) #define MSTARV7_L3BRIDGE_STATUS_DONE BIT(12) +#ifdef CONFIG_SMP +#define MSTARV7_CPU1_BOOT_ADDR_HIGH 0x4c +#define MSTARV7_CPU1_BOOT_ADDR_LOW 0x50 +#define MSTARV7_CPU1_UNLOCK 0x58 +#define MSTARV7_CPU1_UNLOCK_MAGIC 0xbabe +#endif + static void __iomem *l3bridge; static const char * const mstarv7_board_dt_compat[] __initconst = { @@ -63,6 +70,46 @@ static void mstarv7_mb(void) } } +#ifdef CONFIG_SMP +static int mstarv7_boot_secondary(unsigned int cpu, struct task_struct *idle) +{ + struct device_node *np; + u32 bootaddr = (u32) __pa_symbol(secondary_startup_arm); + void __iomem *smpctrl; + + /* + * right now we don't know how to boot anything except + * cpu 1. + */ + if (cpu != 1) + return -EINVAL; + + np = of_find_compatible_node(NULL, NULL, "mstar,smpctrl"); + smpctrl = of_iomap(np, 0); + + if (!smpctrl) + return -ENODEV; + + /* set the boot address for the second cpu */ + writew(bootaddr & 0xffff, smpctrl + MSTARV7_CPU1_BOOT_ADDR_LOW); + writew((bootaddr >> 16) & 0xffff, smpctrl + MSTARV7_CPU1_BOOT_ADDR_HIGH); + + /* unlock the second cpu */ + writew(MSTARV7_CPU1_UNLOCK_MAGIC, smpctrl + MSTARV7_CPU1_UNLOCK); + + /* and away we go...*/ + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); + + iounmap(smpctrl); + + return 0; +} + +static const struct smp_operations __initdata mstarv7_smp_ops = { + .smp_boot_secondary = mstarv7_boot_secondary, +}; +#endif + static void __init mstarv7_init(void) { struct device_node *np; @@ -78,4 +125,5 @@ static void __init mstarv7_init(void) DT_MACHINE_START(MSTARV7_DT, "MStar/Sigmastar Armv7 (Device Tree)") .dt_compat = mstarv7_board_dt_compat, .init_machine = mstarv7_init, + .smp = smp_ops(mstarv7_smp_ops), MACHINE_END -- 2.29.2