From patchwork Thu Jan 18 17:43:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 863029 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="twATFXZB"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zMrtc6LzCz9s7g for ; Fri, 19 Jan 2018 04:44:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=XSpYhqUAzb9oYvizzzaCJbzZfvPCwNDpp7xqVBtBe0E=; b=twATFXZB30e5PFe2/bMz6lIlto BLbBLaFR366CkeCUmq+ekGPHN4nQWhPUeQOZGKjw001M6GRF5LUgxinwtnYzP9+xu/ZzW2DqgnrYS njiCoAy4iIRv5ABMBjjNrest58Mj0s2Hx13wPhE/7w60WjphaYUazlNod/7hbCwkZ0fDYKhmG28X6 yxmg/vfh3BaQUIVRx+4vkCxQ4bf4fuyZ9Ja4nh39VY/NdeLn8f6Dr6vTtlNNllf4AlwC0nkULhqhD 4apSQeOk8hxqtpR2PtxlzelkGzYatX0nLz28lg1P4Zg00v1VSM5dScBzPEOknqThWVUdPyrrV6Byz CzEJW0AQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ecEEe-000773-T0; Thu, 18 Jan 2018 17:44:20 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecEEM-0006XF-7p for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2018 17:44:04 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 7CB7F273AAB From: Sebastian Reichel To: Shawn Guo , Sascha Hauer , Fabio Estevam , Will Deacon , Mark Rutland Subject: [PATCH 2/3] ARM: imx53: add SoC specific PMU setup Date: Thu, 18 Jan 2018 18:43:44 +0100 Message-Id: <20180118174345.26620-3-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180118174345.26620-1-sebastian.reichel@collabora.co.uk> References: <20180118174345.26620-1-sebastian.reichel@collabora.co.uk> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, Ian Ray , Rob Herring , Nandor Han , Sebastian Reichel , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org From: Peter Senna Tschudin On i.MX53 it is necessary to set the DBG_EN bit in the platform GPC register to enable access to PMU counters other than the cycle counter. Signed-off-by: Martin Fuzzey Signed-off-by: Peter Senna Tschudin Signed-off-by: Sebastian Reichel --- arch/arm/mach-imx/mach-imx53.c | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c index 07c2e8dca494..da7c80371f32 100644 --- a/arch/arm/mach-imx/mach-imx53.c +++ b/arch/arm/mach-imx/mach-imx53.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -28,10 +29,77 @@ static void __init imx53_init_early(void) mxc_set_cpu_type(MXC_CPU_MX53); } +/* Hard code as this is i.Mx53 only file */ +#define MXC_CORTEXA8_PLAT_GPC 0x63fa0004 +#define GPC_DBG_EN (1 << 16) + +static void __iomem *imx53_pmu_get_gpc(void) +{ + static void __iomem *gpc; + + if (!gpc) { + gpc = ioremap(MXC_CORTEXA8_PLAT_GPC, 4); + if (!gpc) + printk_once(KERN_INFO "unable to map GPC to enable perf\n"); + } + + return gpc; +} + +static int imx53_pmu_reserve(struct arm_pmu *arm_pmu) +{ + void __iomem *gpc_reg; + u32 gpc; + + gpc_reg = imx53_pmu_get_gpc(); + if (!gpc_reg) + return 0; + + gpc = __raw_readl(gpc_reg); + if (gpc & GPC_DBG_EN) { + arm_pmu->reserved_hardware = false; + } else { + gpc |= GPC_DBG_EN; + __raw_writel(gpc, gpc_reg); + arm_pmu->reserved_hardware = true; + } + + return 0; +} + +static void imx53_pmu_release(struct arm_pmu *arm_pmu) +{ + void __iomem *gpc_reg; + u32 gpc; + + gpc_reg = imx53_pmu_get_gpc(); + if (!gpc_reg) + return; + + if (arm_pmu->reserved_hardware) { + gpc = __raw_readl(gpc_reg); + gpc &= ~GPC_DBG_EN; + __raw_writel(gpc, gpc_reg); + arm_pmu->reserved_hardware = false; + } +} + +static struct arm_pmu_platdata imx53_pmu_platdata = { + .reserve_hardware = imx53_pmu_reserve, + .release_hardware = imx53_pmu_release, +}; + +static struct of_dev_auxdata imx53_auxdata_lookup[] __initdata = { + OF_DEV_AUXDATA("arm,cortex-a8-pmu", 0, "arm-pmu", &imx53_pmu_platdata), + {} +}; + static void __init imx53_dt_init(void) { imx_src_init(); + of_platform_populate(NULL, of_default_bus_match_table, + imx53_auxdata_lookup, NULL); imx_aips_allow_unprivileged_access("fsl,imx53-aipstz"); }