From patchwork Sat May 4 00:48:54 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: 13653703 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2041.outbound.protection.outlook.com [40.107.105.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CDB210D for ; Sat, 4 May 2024 00:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714783273; cv=fail; b=hlZvstDzCbYlJbcl47FfG8HH6is7OvWu55CUnIoCrZnEG14soHHlrDPArVXw5kCJnGJASQOs8ji9cbC7czMKQEGRUGxm9H13+E6IjvSVLmqfwkIG90zZrznHxUkt2LT+GZ15a+Ge4tPUniH+VfWhe5g/X/AsmWrjuKEMLKGK+2g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714783273; c=relaxed/simple; bh=rcCtVWuFJLRqXg+s+ZbKpx/twvYOuewRyu/zZTOc/H8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=IVTHjwXC5TyHG5rf/n8JYNqQyIT8DGPdLjsB8svP5NZhUgOxxNjPtwiL1XZzf23VWzjGNKracnIaNwKqP5PnVr5UG0XZleylD6Bz1zoWAaM83+Z6OhzUGkFjF2GQb5u0iyofICbkDKiDTBb0Xyewflzk1ZZzaUjx7BMrj2xxNO4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=LhAPvhcP; arc=fail smtp.client-ip=40.107.105.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="LhAPvhcP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYJXEvNMH7SQGqxvt6QDR0NkkyqZR3IGcC5xskJxIrKRRvrjJYHK/KGC4jsYO9pM2NzHhGtOx08x50m35B0UAeoKClzu8+thzLfaDmXz//waBtZlg+Ba4J9y4yjXTD2nJ+Fk1Sj88lb8QVJViBZdfAoaZIuM6PeTCx2EfhKUodZTC19sNm8YgI5m4cnmJ/aDz3r9h9S3Lt9THwL+NUuheEuC5wD5rt7cza8i7a4upQrR6QF9FGmQsDM5iceNbQLKIpe74GzZ1mYJ0aArmww5DpZoAqWiIocptREpPLAHyFz1Z6giMkK5XQ4bRNmsx8+Ab+JbGiABrEYo2UoCIMPlSQ== 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=nyrXLazplHUj+yJY03LDVDNDKGJlUv5SrLkX3tZ2AXVGNyfl/w6MSDOo8AkTflY68sIx388fK2G8vWvdg4yM4rf9KgyQTF5F6u9KtdynRgW7ALN6oJuk9m/a7xE6w9w6Qo+BuFv7/42wovl5xU7Fw5tyTuMpZur44mWmwbvO+2Bf3cYCpAzApA8EDlZdfHa0APV7uGwfZ6Ipd9GNXhsn6FQyOZHN+sTTo+uincYuDzD2SKrNwU7IPnNArDqv+7gf3GvISQrt8zVnz2VHJa5fFXGVQPIPgZj4KztiwsrcXPqUs+9IL9ekqc5AoVlAQRHxT5q/7vprNkr8ghSC/RHh1A== 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=LhAPvhcPvpq1h2TemYfpLaoC69lDJ1R3Q1DxgX8OoaL7nKkBB4d93H67/5NEPjYCLLccBqW1mq4QfPe4jZGebfYIULyxcXNOPsfPk7p0p9CWkO84F0mWNcXNHCRCnj/8+UemLxb8wTJdvj6AX+itn3JxhELpfRxckaXkj+0T0X8= 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 PA4PR04MB7726.eurprd04.prod.outlook.com (2603:10a6:102:ea::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Sat, 4 May 2024 00:41:07 +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.029; Sat, 4 May 2024 00:41:07 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 08:48:54 +0800 Subject: [PATCH 01/18] clk: imx: composite-8m: Enable gate clk with mcore_booted Message-Id: <20240504-imx-clk-v1-1-f7915489d58d@nxp.com> References: <20240504-imx-clk-v1-0-f7915489d58d@nxp.com> In-Reply-To: <20240504-imx-clk-v1-0-f7915489d58d@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=1714783747; l=3100; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=iITI+dk+sPkjkDWQwUetdnNFKtogLu9x+44sHjDOVUI=; b=fkSTsJHoRmvS36n4JKMR8N2wmEhRjewWymbpgLM/PXzcG7mlf0GshZKeSpwDWPopG+52na0ri 5nrrvS0cHR5Br/6BePM4dNt8xDGjresoSl72zQDPa5z8trdkrkn2e2S X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0055.apcprd02.prod.outlook.com (2603:1096:4:1f5::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PA4PR04MB7726:EE_ X-MS-Office365-Filtering-Correlation-Id: bf5dbd63-c734-4328-a905-08dc6bd2e314 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|7416005|52116005|366007|1800799015|376005|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?wZ8w4BkBCwXdLKXhLwoPqrsboAXk7cf?= =?utf-8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ibuQxVZCcUXargwgk8QHmqEefrWKapDmJR7dS3SpbxWjj9Jjr?= =?utf-8?q?D04hPRrDN9wOtE/KId8X6bh1kEK3L2cAmWJKKQohhqPyWNfaa0cZsroMuaWl9b5Q5?= =?utf-8?q?OljRKKjaLkwNP527WWVvkLlotQ8ZPUhPNwEXp90iasV08mgX7tH5l8baMgKA0oXlx?= =?utf-8?q?QH2Y6YQmUpd9oButU279pNnvwikt3WfP5gv15f7crY9KdZRB0iUS9OwO0jAAxFcG4?= =?utf-8?q?iuO9nvUYPp/kyRkDvmp5vQDWUb2lgCrNd7myU1ibhYqk5lDKDv0nDGQLY/3qyCyVv?= =?utf-8?q?3OTAE6dlUTLbUC1b0m3x2nb4LkGvl1/gHhhvakdTxU6QN/UByiR2+Cgt/SmeWR8Ht?= =?utf-8?q?MdL65669zGhG9PUevzHsm6FzlbIXvj+H+sdMLkR6ODceupn0aw4YgGzs=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)(7416005)(52116005)(366007)(1800799015)(376005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lK01ez+HI7+cq3v6rR/IB101rDFi?= =?utf-8?q?hnKYLKRlUpWwTpPZnFMLV4i4CDvg0kWRh/8R+/ABI27AgBkxPdjkuv9+blMQ5egZQ?= =?utf-8?q?oJzaofyG8BVqJrnFAdg/Sh783jc0zzxs5pdMPbT+YzOY+pb1yy76l4dE60TGe3295?= =?utf-8?q?c4ws3Yrt2A070r1Ri5l+MpTr+Q5QnUKb6JdvV5dt8wTdzzR79ZbYDGK++S+qMcoS5?= =?utf-8?q?NYegq3vR9P+OsG3YKjqiW+7yIcET7xi90/U7tJV1OqHxRFUDaQYzie6Ld7c9VSV6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f-8?q?ncBz1I4/O+86p6HeJg8gmYU+p6RhPUIGnE8qtVzHVIVh/KK92i6udtK0+g4/nboto?= =?utf-8?q?9cjPQR2MsVwF40MH3QApmwb8QqNzjFhR9e9Zdkm0MtzY39+klvmrEpGtO+SDVXNgM?= =?utf-8?q?cNF28pT75y+dFRmP+SHbSVjiJqbnDlCJ2IonqHLSW+Su6fHHF18ZDKxw4nUCF8HnT?= =?utf-8?q?atWIMW6XdwqzgGBe1GomznZVEIMiAK5jhOiDQU+FYt+V9CpThqjyQMNFfZGhOg5gm?= =?utf-8?q?U3tMsqWyz1Bd/Ytw9PV7CoBu9iZlm+u27NtCmLnOraYPBsaLbw7NpKNodz5A8+rRA?= =?utf-8?q?Wvq/n3MwHygBrAzxGkupvkvQxIhlTjSVNhL5HrQYewv55bMW1VhkzZb71tzxVcwd6?= =?utf-8?q?WDAhulI9ky6a?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf5dbd63-c734-4328-a905-08dc6bd2e314 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2024 00:41:07.7874 (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: 1CSe35Dopixa7e/iwt6n4cKl+rtZwbBirxi2n4WCfFXYuZHjR//RTFlYT7pZyIQX36YKYZd1NsDq7srhIlZAHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7726 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;