From patchwork Fri May 10 09:18:56 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: 13661125 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 BAED0C25B4F for ; Fri, 10 May 2024 09:11:43 +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=cZXckJ7Mswh3oh/lJ11ItQS2XQKLjfO7thMt5cGlcAM=; b=iWZPeRUoalwjpOA04x5oAhwxwa Fq9+k8fGr0Ln1/RnKvG/cZrcUjxOT6JA1GlNEAZwn55HxcoaLSIGMoAyOfEXvxHLnvy6oStJyZ1bO Z2/dW1hDK2dkBzu9Ab+95kncNFfpDdlrwuMJMibqWcS1AEQM7NWdI/FqUb+OdZ96CuWvkFfyLgMMX uA7MccAUrtTFcmwemnsqoembo5jgEL0WC3DTc1qXdL26V7Dc+7hLbmz049OiLyAd3SNiDXYk3ssSo bmy9JfugOaHEsQXKj4xsHSeoHe2zHjMYCbbkJqRnDgPN0OpDwme7ZUbJ8K+OYaOLt6PIshhlAIaob cXCVv3aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5MHq-00000004cHV-0Cfv; Fri, 10 May 2024 09:11:30 +0000 Received: from mail-vi1eur02on20600.outbound.protection.outlook.com ([2a01:111:f403:2607::600] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5MHd-00000004c3U-2Uar for linux-arm-kernel@lists.infradead.org; Fri, 10 May 2024 09:11:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KDFUZBE9fS3znG/FFGcuAMhOS4wiPdS5XZ8Swo8na00YecuvbpduCcyLwfH28J6+52Ul6esjXrEvKuq6sF2T+5ql6XYf7Y6xhD9E69sgBuFS2dBC0/lJkD3lgEYq4rebfmLgEKCmOwCMXGZDs0j8iT5QUcdnOcq8oR3lZTcrCDfM5NOobAtthXcgL42jy75BpK9zB2SFREVN2Ij0aIi1LBYRY5PmcgBkwCLCf+m5FI1a2Co2/pBS8vVN7YZtLnN+9z0qwifaOk07iKLjybILug/Y5mSJFNkGVbqnaUoxhmamVTwGA5ECrXP4MjQ26NN8pfAJ0awFMPNAw4GZscvDVg== 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=wUBHObqX7+uXERJEHkjNWet6mkZy6+My8u8xzR/PX/E=; b=MQ8Y224dxHdYmiiCLd3zsT8/oihKnYpuMj5OGIhYQJcPxgCrZTnkAI2RlUwkfx9G8kSTOCehRXcHhsmCfdgRtvhNWoUAndRrFokGIvGBXoAav4GPDBfJlKzLq6wgwAB5SXHao4AIJG0u4L3uPrr0cRh5wZZ9Tzgig8O/4km+5hJeaBN1CYufCKP5SAOEjWmxJ1LJeMlG7mmb4pC9AwiwZdAUz+l8o1MxOutIzSCdEtF5ZkrunQhzGOo79bXICO8b98dtEgzWYoY9OsN/eqS6xWADlRmZ+EpjjyYbh/By1R8Ly+sA3VoZPHeiZgD3C8Rgn8Fn6RhZSWD32PTfDzMXIA== 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=wUBHObqX7+uXERJEHkjNWet6mkZy6+My8u8xzR/PX/E=; b=UzCRxHrwzW7BJ9ZSJYDguNwuo1dO+zYZ4qXWzi1ocg0RcihH0UPNeCnErNFgC0JBCqkYVjTBSzsBNpuhBIuUFSI96LZayKfpKCftEvvom/G6aQvxkOccwQ87Jh7MMU0BUr1qiuF0Klo2OCqE/tULDe5PcxLc4Ec88SF8p8JBzNA= 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 AM9PR04MB8065.eurprd04.prod.outlook.com (2603:10a6:20b:3ee::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.49; Fri, 10 May 2024 09:11:09 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7544.046; Fri, 10 May 2024 09:11:09 +0000 From: "Peng Fan (OSS)" Date: Fri, 10 May 2024 17:18:56 +0800 Subject: [PATCH v2 01/17] clk: imx: composite-8m: Enable gate clk with mcore_booted Message-Id: <20240510-imx-clk-v2-1-c998f315d29c@nxp.com> References: <20240510-imx-clk-v2-0-c998f315d29c@nxp.com> In-Reply-To: <20240510-imx-clk-v2-0-c998f315d29c@nxp.com> To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jacky Bai , Ye Li , Dong Aisheng Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Abel Vesa , Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715332748; l=3100; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=iITI+dk+sPkjkDWQwUetdnNFKtogLu9x+44sHjDOVUI=; b=0xANIgI2P2N15uUR/SSVlX0gFKuyAI8GiCGRvGZbUDqm9oZuocii25681OUiNVbJErPxgDdqR rY323O3kkLRDRkJMH4iKPuDmVflefzaXl3Fn9xOAwwUD3ZAbp+89iAv X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0008.apcprd02.prod.outlook.com (2603:1096:4:194::12) 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_|AM9PR04MB8065:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f577022-5d5f-4471-de57-08dc70d121ad X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|366007|1800799015|376005|7416005|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CcFoCMwfn49Hv5ILbi0CSY2N6HkkwVt?= =?utf-8?q?Hp3HsnOTu8fVrw2vCyav4pMNIZAZ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qbLiJKcMXAa0Vy2zEDX3qGZxL7IRwH8/6GxRfwqdgz3hL0zOv?= =?utf-8?q?wqob3dmeYZWsNHbTe99Vf2tE5secvXu0XRerhYoXcEA6tVL2VDn+yFG8T6l1DF6iY?= =?utf-8?q?w+j5COlvAYLx5iVC3ZqZ71ILH803MiFyQ3SURjdDZS2ZEbGiguLl3FMvbcymGJ/YK?= =?utf-8?q?zlWglDOHPW7pmdoJEs1yo14wSaVKoPhsKGhDNSVArlI/MGmWYP1E6sBl3/2L2XJan?= =?utf-8?q?GC7Oz71bzbjhAx0wkflzQtwcLWFaBxoJWee39c+KosFO0/Bt3V9RYyvC73k8qvUh6?= =?utf-8?q?jgrBxVhdaeSmjr63p7Llp8MnmcXaLL3TBH5+d2CCbtZkXxGpVxYY/DAF5/yO9/KeR?= =?utf-8?q?cnAXQq3hKd/mFzN0BLOz/bKd5wWcdPeaNMVFreo4/+1fNJIiUaDZKv/Q=3D?= 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)(52116005)(366007)(1800799015)(376005)(7416005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9G4v7wNkEZ0aYggQKEipBtzdxiRq?= =?utf-8?q?8dXr1iszJn31HDlGWsFRs+KswITtpzDGd7tzmQlm7L1a1lBOKuoDU08GbXRop/K39?= =?utf-8?q?h+xNgo9DY1zBwGX8SFTQ9UG6Rq0UJktrmu0pQ0qJv2CiYNj7z/+EOl+HmvLmTKRo3?= =?utf-8?q?CKBSENAzR4yQBz5JVvoTF4F7CWNUxXzevzOgTs+O6rKL8Gt4ilzUjr7qXSFQWy1JP?= =?utf-8?q?ChZRCBuNMoBSq8P29eUW5nKFudvuY3Y8ZDAOsuA/d+Jproso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-8?q?a6xIWRBeHkQIM+xy/RG+n5oo0JhE7SQd7QVtf7U5vjQlS42OPWpLWAnxEXPflIYeI?= =?utf-8?q?7jldP9oLaVLXPrKA+4Rs+cJ48OEgKkdVN3hb1U17A5IGwhEJv6Y3NIc6Oree04yph?= =?utf-8?q?1tu7mcorysm1bwRxmVbjFFpMRDHBzpEnl4xnl15dm6tUPH7FgVL0VNjwu2es/OhR+?= =?utf-8?q?Ux9B6EY24cz9yyRsLqN/0E2dg5X6hzlGdk3LQ2CaDkKJkytZKUmTc8JkiN3kll5v0?= =?utf-8?q?TrgG53U5Np/r1YucufQo08284kN1pStE1aG1EmqsCV5COeevxw9E58XeUTfRV1yLC?= =?utf-8?q?6oE6sGhAITFqfDcc+uG6kFRZuWhfxRpxU9MQGGDG2J+K7EucZZTLFI4z0tP/V3Afh?= =?utf-8?q?994f84EQgX3t?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f577022-5d5f-4471-de57-08dc70d121ad X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2024 09:11:09.7658 (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: fugmc0eBF0T9Cii/3fiHZV/ucar29+W6qW/e+sYfKxW2u1BcI0rUE0DE+T/+os7nyB2OIlE3kitq+WG6yWy0WA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8065 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240510_021118_039518_2FA90E40 X-CRM114-Status: GOOD ( 14.60 ) 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 Bootloader might disable some CCM ROOT Slices. So if mcore_booted set with display CCM ROOT disabled by Bootloader, kernel display BLK CTRL driver imx8m_blk_ctrl_driver_init may hang the system because the BUS clk is disabled. Add back gate ops, but with disable doing nothing, then the CCM ROOT will be enabled when used. Fixes: 489bbee0c983 ("clk: imx: composite-8m: Enable gate clk with mcore_booted") Reviewed-by: Ye Li Reviewed-by: Jacky Bai Signed-off-by: Peng Fan --- drivers/clk/imx/clk-composite-8m.c | 53 ++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c index 8cc07d056a83..f187582ba491 100644 --- a/drivers/clk/imx/clk-composite-8m.c +++ b/drivers/clk/imx/clk-composite-8m.c @@ -204,6 +204,34 @@ static const struct clk_ops imx8m_clk_composite_mux_ops = { .determine_rate = imx8m_clk_composite_mux_determine_rate, }; +static int imx8m_clk_composite_gate_enable(struct clk_hw *hw) +{ + struct clk_gate *gate = to_clk_gate(hw); + unsigned long flags; + u32 val; + + spin_lock_irqsave(gate->lock, flags); + + val = readl(gate->reg); + val |= BIT(gate->bit_idx); + writel(val, gate->reg); + + spin_unlock_irqrestore(gate->lock, flags); + + return 0; +} + +static void imx8m_clk_composite_gate_disable(struct clk_hw *hw) +{ + /* composite clk requires the disable hook */ +} + +static const struct clk_ops imx8m_clk_composite_gate_ops = { + .enable = imx8m_clk_composite_gate_enable, + .disable = imx8m_clk_composite_gate_disable, + .is_enabled = clk_gate_is_enabled, +}; + struct clk_hw *__imx8m_clk_hw_composite(const char *name, const char * const *parent_names, int num_parents, void __iomem *reg, @@ -217,6 +245,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, struct clk_mux *mux; const struct clk_ops *divider_ops; const struct clk_ops *mux_ops; + const struct clk_ops *gate_ops; mux = kzalloc(sizeof(*mux), GFP_KERNEL); if (!mux) @@ -257,20 +286,22 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, div->flags = CLK_DIVIDER_ROUND_CLOSEST; /* skip registering the gate ops if M4 is enabled */ - if (!mcore_booted) { - gate = kzalloc(sizeof(*gate), GFP_KERNEL); - if (!gate) - goto free_div; - - gate_hw = &gate->hw; - gate->reg = reg; - gate->bit_idx = PCG_CGC_SHIFT; - gate->lock = &imx_ccm_lock; - } + gate = kzalloc(sizeof(*gate), GFP_KERNEL); + if (!gate) + goto free_div; + + gate_hw = &gate->hw; + gate->reg = reg; + gate->bit_idx = PCG_CGC_SHIFT; + gate->lock = &imx_ccm_lock; + if (!mcore_booted) + gate_ops = &clk_gate_ops; + else + gate_ops = &imx8m_clk_composite_gate_ops; hw = clk_hw_register_composite(NULL, name, parent_names, num_parents, mux_hw, mux_ops, div_hw, - divider_ops, gate_hw, &clk_gate_ops, flags); + divider_ops, gate_hw, gate_ops, flags); if (IS_ERR(hw)) goto free_gate;