From patchwork Mon Jan 28 23:06:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Menefy X-Patchwork-Id: 10785069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C6B613B4 for ; Mon, 28 Jan 2019 23:07:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A3AE2B26C for ; Mon, 28 Jan 2019 23:07:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E9272B4D0; Mon, 28 Jan 2019 23:07:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E402B26C for ; Mon, 28 Jan 2019 23:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727082AbfA1XHT (ORCPT ); Mon, 28 Jan 2019 18:07:19 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35735 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfA1XHS (ORCPT ); Mon, 28 Jan 2019 18:07:18 -0500 Received: by mail-wm1-f67.google.com with SMTP id t200so15872646wmt.0 for ; Mon, 28 Jan 2019 15:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mathembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=Kb9pQ+h79DbIhkBlEZdRWcfEn3U4hspFZty4GNqWHX8=; b=sN+g+sglUFOx1rv5FnkyGc6b+3TVUirLEFZbKtwd6xi3gNIZOebnUzVQA80VR08WCH Jg8jg6OdeaSje3rkqhL+ilH1BXSeSOarIonmB+5/Q14sKa5QcP37Kt8Qg+S27uqqLlaX zwFDwjPno6Bi2hLUsGsdAclBNaXAuAGE7BGp/EdNySXglDZORFXnw3cFmdg91PVKmX0U iRrZYuOaS5vxhmzqU8sjn6fZBRlrln6X5oqq7JdLcgCh/+jTfk1FMEslaBsvbbx7ieGk bKOhBtqN1dK8zi7UiezrdqfURtXyU1saKNLT6Djk1L/0L0PycqVaT7gInQKQ6WXgLmVy 7mqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Kb9pQ+h79DbIhkBlEZdRWcfEn3U4hspFZty4GNqWHX8=; b=DX0leNlKpzupPC/1C+F9wc8mm8QrxGEW0um95Q36NkrI0Y+FwXZg+pBIKFUZiTdonO /8jKDqfkK3OkBt84RKLRPXtYX8tileGaQU9ETTkchNJeaJNTQ+FwgORoYm3Ao5oYEIxX YM6s6S1VavOoOM1z1EniCRd+ba9WyVPSGf+Ww28IcxQmLcHQFS8Cl1D8inQpYBWvQH8D o2k4x9iartBx7Hbx63M4LFlYPaATvJtrkys5FduiRt9dbAVD4tA/TpFhDtLcYfs0fPxc 0dyuEa6QSD++xTIfeOIpWvRFXUEFFVldTxL3wWtvNlLv8L/fkKYwwVdqPsXaJOXhW6rZ TZuQ== X-Gm-Message-State: AJcUukd/uLgGLHT0VjFjXbAGTbUYvaHjAvE8tUd7i4TwcWbCIXWD6NrO TXHcHf14nij5jSBLeY4/CVJCV1Cg5V4CpA== X-Google-Smtp-Source: ALg8bN4DpEEepEpkyzcB2RdcazO7A05+esIsZLjDbE5bdiETRdEYzToHeNoAJpl8bTDc6ZB0xppRZg== X-Received: by 2002:a1c:38c4:: with SMTP id f187mr18241860wma.90.1548716835967; Mon, 28 Jan 2019 15:07:15 -0800 (PST) Received: from diamond.mathembedded.com (host86-176-243-190.range86-176.btcentralplus.com. [86.176.243.190]) by smtp.gmail.com with ESMTPSA id o64sm506765wmo.47.2019.01.28.15.07.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 15:07:15 -0800 (PST) From: Stuart Menefy To: linux-samsung-soc@vger.kernel.org Subject: [PATCH 13/17] ARM: EXYNOS: Move cpunr calculation to a function Date: Mon, 28 Jan 2019 23:06:56 +0000 Message-Id: <20190128230700.7325-14-stuart.menefy@mathembedded.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190128230700.7325-1-stuart.menefy@mathembedded.com> References: <20190128230700.7325-1-stuart.menefy@mathembedded.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The generic MCPM code uses a [cpu,cluster] tuple to identify each core, so the Exynos specific code converts this into a single integer cpunr, which is then used as an offset to registers. Move the current 5420 specific calculations to a new function so we can change this for other devices. Signed-off-by: Stuart Menefy --- arch/arm/mach-exynos/mcpm-exynos.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-exynos/mcpm-exynos.c b/arch/arm/mach-exynos/mcpm-exynos.c index 72bc035bedbe..571349e1e02e 100644 --- a/arch/arm/mach-exynos/mcpm-exynos.c +++ b/arch/arm/mach-exynos/mcpm-exynos.c @@ -55,13 +55,21 @@ static void __iomem *ns_sram_base_addr __ro_after_init; : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ "r9", "r10", "lr", "memory") +static int exynos_cpunr(unsigned int cpu, unsigned int cluster) +{ + if (cpu >= EXYNOS5420_CPUS_PER_CLUSTER || + cluster >= EXYNOS5420_NR_CLUSTERS) + return -EINVAL; + return cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER); +} + static int exynos_cpu_powerup(unsigned int cpu, unsigned int cluster) { - unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER); + unsigned int cpunr; pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster); - if (cpu >= EXYNOS5420_CPUS_PER_CLUSTER || - cluster >= EXYNOS5420_NR_CLUSTERS) + cpunr = exynos_cpunr(cpu, cluster); + if (cpunr < 0) return -EINVAL; if (!exynos_cpu_power_state(cpunr)) { @@ -104,11 +112,10 @@ static int exynos_cluster_powerup(unsigned int cluster) static void exynos_cpu_powerdown_prepare(unsigned int cpu, unsigned int cluster) { - unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER); + unsigned int cpunr = exynos_cpunr(cpu, cluster); pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster); - BUG_ON(cpu >= EXYNOS5420_CPUS_PER_CLUSTER || - cluster >= EXYNOS5420_NR_CLUSTERS); + BUG_ON(cpunr < 0); exynos_cpu_power_down(cpunr); } @@ -152,11 +159,10 @@ static void exynos_cluster_cache_disable(void) static int exynos_wait_for_powerdown(unsigned int cpu, unsigned int cluster) { unsigned int tries = 100; - unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER); + unsigned int cpunr = exynos_cpunr(cpu, cluster); pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster); - BUG_ON(cpu >= EXYNOS5420_CPUS_PER_CLUSTER || - cluster >= EXYNOS5420_NR_CLUSTERS); + BUG_ON(cpunr < 0); /* Wait for the core state to be OFF */ while (tries--) {