From patchwork Thu Jan 25 11:09:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13530852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8129FC48260 for ; Thu, 25 Jan 2024 13:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fFzgdnf+tYVGv6d3kV33wPHdsrzdtj7cBauSu+VRxdU=; b=OtWIjbHK8xwhgjWni+vyjC0JY8 zkCi53CMu+kPVFRsjTlGSc43sqPZzUvdT0GpMYJwOI6RTshE0U0IWmrWJP23bMT8t5vfdeK929t5r aH/qiy7TRozxY8NRW2sxxmrOQCVDqr7COpkzeOdIzyA5Lxr4ffw+GhQYRlKZ+sRV6gSZCYn1qSVMN v5gT3E4E6/vWK6W0mu4/6gPetmIZs0FOXXYeWvBXeahViOCzhSgkymP89vUxQ842cwy6dWEC5P4Dh imuN5RA4ZCWSM0Pa8zY45MlFQl3kS4c/9P04bcbvV8hlED7OSrzDuNOD7jkOY5RKTIkoyfdGYQgis 0lGO1Dvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0D3-00000000AAh-2R7B; Thu, 25 Jan 2024 13:56:01 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0D1-00000000A8z-35UK for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jan 2024 13:55:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=F1lUtjwppp5r6I2j8GSA70ZjQecm5QrSH07ZZ+SCFs0=; b=G3JC+fEtiBC//xXtcecwPtOVsK bXfXu9iiCXXe8xl2j0QZHYgCVdoy9tKr1JSyHKsS5Lphdk6uGj4liiz1WY8CaRbtaBakSxZkoAuaM y0XifzOJegL6dAufyHxSGXoP1oQLhAjR8+x4iIBZJMYNR0wUDjQhEv6TwjhfTn+UEzYPT0q2Csh7g jg6M9MHoseOEITCLFBsDWYo9je/liUFNlK4xsq3kYkEdb1/poezyTUllkUfSu3sCWLxv8MZf8C25/ 8WYxE0lpeLjSbF1dL1l6dxVViXtgu+jHotwiYkzzLFNj1hw5lOy+5YoYz3AhwlvenTrW36fvq/gio NcOsopcA==; Received: from mail-he1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:260f::601] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSxnD-00000005B5w-0Dpg for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 11:21:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gjaL1MFP0yWY+pIJEBDbzL1GApwU5CcOoaTfQbIF9ufEPf1xN0/jajxJphRTf62ownFwGpIKttwedpR8Rr8iLMLdyEuFe8zJesOBrkl2mYBVYNU95lmew2Asr7z3g+2w+owYJDX/qX1PNSF4l0JDorUzNPIPKKl1XVYZ/RjDFKaDJ56C1/VStV4C/1aMiZBnLIAU+nw+UMwPh76W6ai3udT/VJ7LaT71Lb/UQKUbkSqgDbgd6wC8q6O71MoPyZ5ZS2ei3p/l9nrhucS0l9UBTDwCAMvn1JWZV9PmSkR1sqwz5gv6UcyqUp4nF2/tnvnMumvwj2+vwL2rEKBInt9dQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F1lUtjwppp5r6I2j8GSA70ZjQecm5QrSH07ZZ+SCFs0=; b=VyGqE+WakaylFiWkBjv6XQXFsWwx6B18S+Huausu2Dqo6gIdFztOlQdIxVXQpjEjDxHOdNCSZntpebQQJ//tDA4tszS9CsqKvV13aAEzUwlT3DesVyM/+67fQshgpzHf8BoQiUSCEoJgr7oCFCqmPHJy2GVPVR0FFBYNyy53Ogjqd/0M23jcksvux0/3OO3vGbTRwWWnHG90D0Er3pWU6DsNIUlUwfcIjQ917zUAyeU29nUU0jOgBZ5f/EIpuHKVDdhgeZ6p+c4HgdsHNhgIvZliC4wqEN+vhBg9l+Q5demiAQOfjEVJDOysM4RGmXxPdF6zCj6ALXlKCZMa2MQVPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F1lUtjwppp5r6I2j8GSA70ZjQecm5QrSH07ZZ+SCFs0=; b=HzlLWHdE6FugOl5BFS96TJQvYxr/awsvhqvtn13SjVC5YANOc+R0qv5b3W0Uykn75ukIyOG362pPAGEYPXVKVUqH9rdwa0LmCgwKy8KQdikibQt5dA9mSynjIuren6LRtUR0nnFF8CBlSeYlN4x69fPUZ445XAEMbBVds7cldYI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB8013.eurprd04.prod.outlook.com (2603:10a6:102:c4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Thu, 25 Jan 2024 11:05:46 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7228.022; Thu, 25 Jan 2024 11:05:46 +0000 From: "Peng Fan (OSS)" Date: Thu, 25 Jan 2024 19:09:49 +0800 Subject: [PATCH v2 3/3] clocksource/drivers/imx-sysctr: support i.MX95 Message-Id: <20240125-imx-sysctr-v2-3-7332470cd7ae@nxp.com> References: <20240125-imx-sysctr-v2-0-7332470cd7ae@nxp.com> In-Reply-To: <20240125-imx-sysctr-v2-0-7332470cd7ae@nxp.com> To: Daniel Lezcano , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bai Ping , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Marco Felsch Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706180999; l=3432; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=o5T5BQKnKVPTSdGEy9mYdRRrgmMK7+tO3UEptrQOgLk=; b=FEsy12o6ILGS1hX1lH8QsgAY5uedRZp2M1mmWP6+s3XkZhWbMKRC/s3w+AGnYPWrxGGNgImFy nj0ChHfVJ90DlQyaU76EBMK7qvmBvi0wNTZGDYhafQwiUnlb4mQnaMg X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG3P274CA0022.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::34) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PA4PR04MB8013:EE_ X-MS-Office365-Filtering-Correlation-Id: 6dbe8eb3-51b2-4523-cb2e-08dc1d9594ec X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ji3JYLCtVMTgvY7umRPh4Dy+TTsIbbfG+MBkIyddiS6KCXtmn3zaMxBH9cV7VdZVa2nSd0QiacVvFzCpFEZ55oPW+XfFq7CEWFUAcEKB0NFk1qgqyloLGN5Z5J/ypAoX/6sZByB+jV+voQLeWNK2+vV2XhU4bSbi0oF6bpdAZoZruILrSbRaZMsMvaCkFXcbP/g+8TAgjXL6zXXMmK42BMbv01RlVcgRarAQZmBulxWXfK22N/OnBy6dUKbB6EfhnDAkZuaOm+bOd617hDZ5n2r8yUrlt/yeA+sjYBSOwm4QhUFmmR37+Qb+LaG00Hndgbwyv1Yx2NIvrzoeaUL/8PXBQHh9OwzmA/4x0xxQz7e8d59NlsfaR6KXjfF4v1DQQ0NfyQlmeCCzgc/UAbGM8LwApF944tL2UaLZ+PCiJ90+OZXQF+dxlj+/ow/xtzlJJWNRuxn+9ZWP31eIAGY/vrHPEH2Fl0QTeqsm4xg1sUW5jQYzvpXqEGwxTbTHS+k23DyB4Ab1ff6xPU+Wg+CCNOPsilf37lAC4P38+eQ2Q7ygB4lG4v/vUlzxUfd5Jw4rlG8nMd9pp2pYHCRINh+8Mws+lrtAk0nuAzT64VW7ux/G8NixWS/8ojf7aKJHTdnWvTvazyvOLU514mqL7+MHmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(39860400002)(366004)(376002)(346002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(4326008)(2906002)(8936002)(110136005)(7416002)(66476007)(8676002)(5660300002)(66946007)(83380400001)(26005)(38350700005)(86362001)(36756003)(66556008)(316002)(921011)(52116002)(6486002)(9686003)(6512007)(6506007)(478600001)(41300700001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qtQNDmoPi+OQ9X9bOKsJQi1Xedrc?= =?utf-8?q?JMkm5udcharWoUONlft4pzUmsk8mEu1Jy1oQOjFIOK8Rm2I1dq3VBumSpwDn8U2KW?= =?utf-8?q?o3zitI+65/SqniiGEXUEXkGL/++o66ybevZOiH09qbrZa6ln8pDCw7lUCcZhNZbiG?= =?utf-8?q?FmQop34jwxH/eX9BKX66PLv5qM1AYsmVJlDxyapls4eibHUUp7cTti2He+sgcv8w0?= =?utf-8?q?sanv6D8toDdpDJTJPYjBeQOO/7m6UGDUI4HP1XmjoS0pwQOUFx4nleRmwZTk5W34i?= =?utf-8?q?Ip0vhMXvW4OoLpMS6k6KP9R/cknwndpPGupVlyaRYFImQ1XiIQFwBCsWCO31H1eEy?= =?utf-8?q?U+tJ8iWt0BUXcI8nge7ZLwRHFQKHZong97KF8C0Ekska1gDyD2ydNlA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qcZNbVr16/9yJ?= =?utf-8?q?iG3clrYHNfbAC9vfDvU53TfvLm/Cn2r3J0Cq32yFnscZDPsikcPSEJSAegur70mJM?= =?utf-8?q?0Gl0khRKE57n0q0tMKmeHtz/tT9y0aL3kl1SkbRdTl/+Y9U3JvVGWIfAVWe83WKTU?= =?utf-8?q?0q7tgnDUSQNEP12r53vybrqoPjq6Wj72AbgDUqbiezBsEr3CKlXyqUcv+WNlJIctn?= =?utf-8?q?V+RpqM93F055I933IlLu74n6V6KGEydb50FOA6ckzPx5TCyr2zTlkJY2iNtroJYzN?= =?utf-8?q?KH20stQlJEMV?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6dbe8eb3-51b2-4523-cb2e-08dc1d9594ec X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 11:05:46.6599 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VsNe3H2XsZWR5yYB/im+o7UN+HXlCXIH2DuIDCkQfuLoTaOujpysbPVbDu6SqmTL12GJY5SYGynAkzekBkaFbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB8013 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_112111_193251_A0F4D1F8 X-CRM114-Status: GOOD ( 15.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan To i.MX95 System counter module, we use Read register space to get the counter, not the Control register space to get the counter, because System Manager firmware not allow Linux to read Control register space, so add a new TIMER_OF_DECLARE entry for i.MX95. Signed-off-by: Peng Fan --- drivers/clocksource/timer-imx-sysctr.c | 53 +++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/timer-imx-sysctr.c b/drivers/clocksource/timer-imx-sysctr.c index 8d5bfb8470fb..9b7c021c3b46 100644 --- a/drivers/clocksource/timer-imx-sysctr.c +++ b/drivers/clocksource/timer-imx-sysctr.c @@ -8,12 +8,15 @@ #include "timer-of.h" #define CMP_OFFSET 0x10000 +#define RD_OFFSET 0x20000 #define CNTCV_LO 0x8 #define CNTCV_HI 0xc #define CMPCV_LO (CMP_OFFSET + 0x20) #define CMPCV_HI (CMP_OFFSET + 0x24) #define CMPCR (CMP_OFFSET + 0x2c) +#define CNTCV_LO_IMX95 (RD_OFFSET + 0x8) +#define CNTCV_HI_IMX95 (RD_OFFSET + 0xc) #define SYS_CTR_EN 0x1 #define SYS_CTR_IRQ_MASK 0x2 @@ -22,6 +25,8 @@ struct sysctr_private { u32 cmpcr; + u32 lo_off; + u32 hi_off; }; static void sysctr_timer_enable(struct clock_event_device *evt, bool enable) @@ -46,13 +51,14 @@ static void sysctr_irq_acknowledge(struct clock_event_device *evt) static inline u64 sysctr_read_counter(struct clock_event_device *evt) { struct timer_of *to = to_timer_of(evt); + struct sysctr_private *priv = to->private_data; void __iomem *base = timer_of_base(to); u32 cnt_hi, tmp_hi, cnt_lo; do { - cnt_hi = readl_relaxed(base + CNTCV_HI); - cnt_lo = readl_relaxed(base + CNTCV_LO); - tmp_hi = readl_relaxed(base + CNTCV_HI); + cnt_hi = readl_relaxed(base + priv->hi_off); + cnt_lo = readl_relaxed(base + priv->lo_off); + tmp_hi = readl_relaxed(base + priv->hi_off); } while (tmp_hi != cnt_hi); return ((u64) cnt_hi << 32) | cnt_lo; @@ -126,7 +132,7 @@ static struct timer_of to_sysctr = { }, }; -static int __init sysctr_timer_init(struct device_node *np) +static int __init __sysctr_timer_init(struct device_node *np) { struct sysctr_private *priv; void __iomem *base; @@ -153,9 +159,48 @@ static int __init sysctr_timer_init(struct device_node *np) base = timer_of_base(&to_sysctr); priv->cmpcr = readl(base + CMPCR) & ~SYS_CTR_EN; + return 0; +} + +static int __init sysctr_timer_init(struct device_node *np) +{ + struct sysctr_private *priv; + int ret; + + ret = __sysctr_timer_init(np); + if (ret) + return ret; + + priv = to_sysctr.private_data; + priv->lo_off = CNTCV_LO; + priv->hi_off = CNTCV_HI; + clockevents_config_and_register(&to_sysctr.clkevt, timer_of_rate(&to_sysctr), 0xff, 0x7fffffff); + return 0; } + +static int __init sysctr_timer_imx95_init(struct device_node *np) +{ + struct sysctr_private *priv; + int ret; + + ret = __sysctr_timer_init(np); + if (ret) + return ret; + + priv = to_sysctr.private_data; + priv->lo_off = CNTCV_LO_IMX95; + priv->hi_off = CNTCV_HI_IMX95; + + clockevents_config_and_register(&to_sysctr.clkevt, + timer_of_rate(&to_sysctr), + 0xff, 0x7fffffff); + + return 0; +} + TIMER_OF_DECLARE(sysctr_timer, "nxp,sysctr-timer", sysctr_timer_init); +TIMER_OF_DECLARE(sysctr_timer_imx95, "nxp,imx95-sysctr-timer", sysctr_timer_imx95_init);