From patchwork Mon Nov 30 13:10:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Palmer X-Patchwork-Id: 11940437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03C24C64E8A for ; Mon, 30 Nov 2020 13:15:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E25720708 for ; Mon, 30 Nov 2020 13:15:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eGyPCyqm"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=0x0f.com header.i=@0x0f.com header.b="NOERfF7e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E25720708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=0x0f.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dBmSKMQ7EMtN9+9kqAZfmJeUSVXrQdAG85PEpfhJVFM=; b=eGyPCyqmDttdxbMCYg7oiqypN 6zxFcNh0oVP6o6EQ+o2aHrXhV4PpY76zmQQJu4zS9fJN9wfBOvhwHO8BiNy1pTf+bhLhTe6ppjWjn IA7nzMwfxLslHWpDX4ySS5/kDAe9hW9qgYFxMWrxJgaIUQEqIxbpi6bCWg6AMrIo6HkRiapZp8Las dd4Z2xjGJumrt7IwXykBkM90SAAg49R3IBlbKmm2MqYc4ALJXgvtzx0UgyXoBamtnxNdlymgHnQuy b44q+ZU4lP7QccDGG8i1/iHyY3Q3arToegBy0JWs8VmMMFCNa2Fh8y7Ogldj3QB9l0ZUVwYeqWv6t xGbMuUGXg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjiyK-0005Pz-Vq; Mon, 30 Nov 2020 13:12:05 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjixe-0005CO-1u for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2020 13:11:24 +0000 Received: by mail-pj1-x1044.google.com with SMTP id r9so1305026pjl.5 for ; Mon, 30 Nov 2020 05:11:21 -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=F4b6Mz+meeIOWiwdpvVizNGtENxtsbORSHHjjSCrlas=; b=NOERfF7egowMV6omqbGCYcnTmO++yhypJfIN0zzFCBLOwPjW5dSmvG0jSgPxeAESWL 9acj1SCmIXtpuCB2Z1uvcFa6v6k8VO8nec0r6OsyQX4L1rUrsewKlJ9uuqivdPfvvo5v MCSexCFH5DnPtbgd0TfpUvYMix7Q0BxgQoAjg= 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=F4b6Mz+meeIOWiwdpvVizNGtENxtsbORSHHjjSCrlas=; b=F+fp9/ycCoec/T6XTmg6EIcQDcX7Bp3NxyIdhCqHAh/OriWJFK2WcbgvG8zJUq8G9J JLLCuZU9/FRioQ09lJ8k0hlcGwFG8d9QmK4ytGT0weRw5Ic2336QdU/xV4BXYDml9eY6 x4DB5RdyfR/EUApPm8juaukhBbXEfWQSnxNjr1jcnalREeBFuBmnkMH5P5Ly+pEWVnZG xDdY0BS9UE8A55tAzT/VCADqFxBgrwMeOUSyIrX6f5bCmJdnTGv+Ah0GMK6nIpBMSshJ TO8a2Oq+Dc+PD9WBEwkS6dtAAc9B8wNsMVuRBsMl8b4S/KTc3qjPShRuZl9BeuOgvIIA yM1w== X-Gm-Message-State: AOAM5323vNyy++wG5UMOVKPcpEuQeTwGMs6yBN5rp1G3hi/+tWFwbLtu JhoHQccNI5Vcg0TuQnMMqHoNLTYlOCirqQ== X-Google-Smtp-Source: ABdhPJytNtiSFjUBa/8hP6fMqYnvCTlKseq0Z9MVhm7I5h2NQTR5XgRtzFuTCSl6si+IwlkEQh6IOw== X-Received: by 2002:a17:90a:940c:: with SMTP id r12mr25793348pjo.201.1606741879985; Mon, 30 Nov 2020 05:11:19 -0800 (PST) Received: from shiro.work (p1268123-ipngn200803sizuokaden.shizuoka.ocn.ne.jp. [118.13.124.123]) by smtp.googlemail.com with ESMTPSA id a4sm41757578pjq.0.2020.11.30.05.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 05:11:19 -0800 (PST) From: Daniel Palmer To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 9/9] ARM: mstar: SMP support Date: Mon, 30 Nov 2020 22:10:47 +0900 Message-Id: <20201130131047.2648960-10-daniel@0x0f.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130131047.2648960-1-daniel@0x0f.com> References: <20201130131047.2648960-1-daniel@0x0f.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201130_081122_266315_983AF257 X-CRM114-Status: GOOD ( 21.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, daniel@0x0f.com, linux-kernel@vger.kernel.org, arnd@arndb.de, w@1wt.eu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/arch/arm/mach-mstar/mstarv7.c b/arch/arm/mach-mstar/mstarv7.c index 1aa748fa006e..23fe47a8f1a5 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 = 0; + + /* + * 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; +} + +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,7 @@ 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, +#ifdef CONFIG_SMP + .smp = smp_ops(mstarv7_smp_ops), +#endif MACHINE_END