From patchwork Fri Jan 24 14:25:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13949373 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 C78DFC02181 for ; Fri, 24 Jan 2025 13:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: 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=ye8sSfk9ofc/Dbnv+JnFLi9NmOa59ddc2EFp+ux2Uc0=; b=wLEzNrdaPuQVeyLupDeWYRoprg 3o24Frtdxvr6SqfLlKtwId8WmYe/frIiW8le9clMhS70Y6DLefSYE7STl9JObGJHK7LGQP3tOBKcS vTO6Eyrjp4q4mmR+MZUTNBddZeSLWu1YbVuXSJ4J371aDVYMSxsea4hrlR8PTkZOy7nlQesOTIO6W gREl0HeXBO9hlbHwwKf09NLTCxP4MAINwFQm6kqDauLY403HXd104D8xbbJI9xJgk4ed7tzn2AiFM dQsPpTXFXLcUn2aXjQKO3THRiDr9GbHHfr7zJfiCvMwkdXE90NpfT9GlBqSC0ndaA5Zb/QmiXCH+V 4LDIdsiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tbJdB-0000000EjRQ-3Vyt; Fri, 24 Jan 2025 13:21:53 +0000 Received: from mail-am6eur05on20611.outbound.protection.outlook.com ([2a01:111:f403:2612::611] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tbJac-0000000Ej8G-0PyK for linux-arm-kernel@lists.infradead.org; Fri, 24 Jan 2025 13:19:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aIs3oS/0sm/YHgmqfyS/i7Tq9WronnHimngWbbbe3371nfMWWy12L5OuE4cfpNfafJlqFOxILc2+xb8+qLlX/Qat/u7NoztzTV7bme6b1LzbKn4UzngcAFdV/2lcMmNrhSIAxdjgHVHWZVFQPen7irn6SMtpRJG0VPTt4dNdlf/E+Q+85dgu1wu8Up9UxaO0y6VaaiZuCHJWAZqafLPrx4rfMvp/EBfny/dQhVOacjVixo+VLWg3PoDlBhJFRS7fEGJHX2oxoFEHw9PpcmFQFkhwd5ij64KT+FVTBjob8LNOZIFKxQ480OXOK4tqcVO0ikiY+bcGOj3BHOMJ1nKZEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ye8sSfk9ofc/Dbnv+JnFLi9NmOa59ddc2EFp+ux2Uc0=; b=f6ueN7t6xEvV6MUbm2iTTmZoISy6B9+eFYGAKGV2BNjyE5wIEAdXPWf5gbrIgHqWkoZMJpPudP1XgfBq8+sVf36WdeoO6hWIMwWQvEpPROAKvoBqMxbPkMMNLUbC0p6OEByyww2Q/j9YUmwCkNR8GlIC1ht0sajYIfVsnXiT0s1Z6nakR5BNXsxGJXLWrRelmidaIFQT+znreaAQETS3ZgbwPuuXLhAQv2YS9Vw5W414/E2MromHLbSt8/FKAnOQd68sfyZhGC8Q9P1b+6LiaDA1jkTOwt/BqGr0C03uikKFLWW02G+sV5y+ZgSIWNagPK3elGHH1Sw/3KpB+4j4Mw== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ye8sSfk9ofc/Dbnv+JnFLi9NmOa59ddc2EFp+ux2Uc0=; b=Y5SIqJ8JvzhVzWDFhwrGahLwQlPNVoMfRcWoBh+n4XjyKY194zGZwko/2D9mG8mSRwECbr0Q/9p1+0YXXFkD9taMEJZtEa4dM0kPgZJF7euKWRJK7jWjxokdQI1WyPs430WoLBi2pbnQwOzpGZYCobD3JvqUWO2xqQZFe2GreFX0+qKuUOxZEdyUWTZqaiUCMiRkOcr9ok0btg5M6GMI0ZKe4r8PpZ6IDSrZkqzG4nXsvJJDWNTBjL4B5P/bkGDiKsST/xMfG3OPFbaKSMqI3apC+U4ETv7rYlKEZiptHj7bpkSeqnV7UW7o21WsQ3uS9HAC7N0GlOpgLtYsjs4F9Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PAWPR04MB10007.eurprd04.prod.outlook.com (2603:10a6:102:387::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.18; Fri, 24 Jan 2025 13:19:08 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8377.009; Fri, 24 Jan 2025 13:19:07 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 Jan 2025 22:25:17 +0800 Subject: [PATCH 1/3] clk: Introduce clk_set_spread_spectrum Message-Id: <20250124-clk-ssc-v1-1-2d39f6baf2af@nxp.com> References: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com> In-Reply-To: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com> To: Michael Turquette , Stephen Boyd , Russell King , Sudeep Holla , Cristian Marussi Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rob Herring , Krzysztof Kozlowski , Dario Binacchi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , imx@lists.linux.dev, Peng Fan X-Mailer: b4 0.14.2 X-ClientProxiedBy: SG2PR02CA0127.apcprd02.prod.outlook.com (2603:1096:4:188::7) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PAWPR04MB10007:EE_ X-MS-Office365-Filtering-Correlation-Id: 3523efe9-91db-4dff-b357-08dd3c79aed0 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lM2SWV2xsHixHIj1PZZOtcdXfbSLCvo?= =?utf-8?q?V/B3Xvzje2rmfrmJ9ZV89BV/shr39mNoAjp2w1K/Z7dOpFUzxg38UB65pYrB232uW?= =?utf-8?q?dwmtIon45Ts7+TO745iPYl24cgxCIioYc3r8p6gVpHGf3av9HANRrv2R8tgL4EsFr?= =?utf-8?q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utf-8?q?LM9CjIszRimI5y0Gvur7pP11z+AwzCJGkQeXGyvtT2tnbLpS4nb6DjPc87yhcv9U5?= =?utf-8?q?FjhmcTr9ztu2VSjz/RprCSu3Evk25yxi1ez17/3RKOKCf6NnFPPMGf0nCTmZDQbr9?= =?utf-8?q?YvdbMus5iq29SlkY0x95tAhpb/1m7Op9QctYQEw6f3M/2T8Fb5A6RBjspsBRnjN86?= =?utf-8?q?BG9F5IL6unyNwsBNxJ55TH83rPgw8F3i6LV3/n6zxmTtu4ByJwAXS6AVdjlVY7NcP?= =?utf-8?q?yPInGTCzgxpWYll20Md08QAluDntZK0Z2invFvKT8bOYH0mPrzIKhYkae1hLg+ExU?= =?utf-8?q?AhsMWlZ89TItiw4YucnGA8/KNLtmhcA0qOYLiDF0lVtPeuuEz41VACaBCMGHfb3Lx?= =?utf-8?q?n1Xnbf3Lkp2?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?QWEMxsPDBMFh9DShWZuGiPdw9aCt?= =?utf-8?q?AXOzxbEk7tgVJsnoflQLXZcjsKMUG63JLzpUZrHWcuXxCi87F/GxmmiKYt9s14H15?= =?utf-8?q?CN2JLu8WTPtauT98z6EkuuUSHY222kR53dpSWhY97oSB6S9QqmmW8KqbZDumLjTYm?= =?utf-8?q?B3XrBcaOX99wa89gmuPtjtOAtpq5Ogz8YUBOHufnwSTATqRb0d+GPQsCmu2l0r84w?= =?utf-8?q?yYtQ2nNK9TwmZKXni/ZW26evkZtRiJGEDS7gScZ0nsHlEnccKU1pikfF40Sb18JnG?= =?utf-8?q?JxIpKydtDqcYParpaMZ9ohSR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WtvP7AS3t0bFD516fWzICmI3ViCjqA4+AP?= =?utf-8?q?8GxZEKqxJzn4CsnpjrB47n7IjCxxf0ldCmZZBCMtcvcGlQr/zF5SytwyRXBfqhaxH?= =?utf-8?q?fwFoFI+E3ehwC0IZPHOk91TSbybkX2YunQTMDfXWXxruakIhS+a7bxHhlqM4OdgwC?= =?utf-8?q?y3/+YYbIywR+DY7mRdTJCOseFYYs8J/dVnRzjXkErxM4rKzJmhigVoosgY+N7g2f4?= =?utf-8?q?k1kXiNhvTCLbS9iZKK0anGEk42APweT/aqHe2cqYhZDOtITiLfc4gSkptdyWRiq+b?= =?utf-8?q?1n9w6+19SD5+wF+azkY9EgEMurbpnBXcoq9mmbPijfMxo6IstsXYVxkPZgn9hn+Mv?= =?utf-8?q?9GGNlesZOmjl?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3523efe9-91db-4dff-b357-08dd3c79aed0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 13:19:07.9292 (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: wnjVm+OdhyY67Mdqs1R3UOB0aRZuGt4R8qBNjmXiZvi0iPKZyy22vFfMOyvl8pd/4hQz5x+0p4XBy5mMTk2BrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB10007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250124_051914_151257_7EB64C23 X-CRM114-Status: GOOD ( 17.68 ) 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 Add clk_set_spread_spectrum to configure a clock to enable spread spectrum feature. set_spread_spectrum ops is added for clk drivers to have their own hardware specific implementation. Signed-off-by: Peng Fan --- drivers/clk/clk.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 22 ++++++++++++++++++++++ include/linux/clk.h | 22 ++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index cf7720b9172ff223d86227aad144e15375ddfd86..a4fe4a60f839244b736e3c2751eeb38dc4577b1f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2790,6 +2790,45 @@ int clk_set_max_rate(struct clk *clk, unsigned long rate) } EXPORT_SYMBOL_GPL(clk_set_max_rate); +int clk_set_spread_spectrum(struct clk *clk, unsigned int modfreq, + unsigned int spreadpercent, unsigned int method, + bool enable) +{ + struct clk_spread_spectrum clk_ss; + struct clk_core *core; + int ret = 0; + + if (!clk || !clk->core) + return 0; + + clk_ss.modfreq = modfreq; + clk_ss.spreadpercent = spreadpercent; + clk_ss.method = method; + clk_ss.enable = enable; + + clk_prepare_lock(); + + core = clk->core; + + if (core->prepare_count) { + ret = -EBUSY; + goto fail; + } + + ret = clk_pm_runtime_get(core); + if (ret) + goto fail; + + if (core->ops->set_spread_spectrum) + ret = core->ops->set_spread_spectrum(core->hw, &clk_ss); + + clk_pm_runtime_put(core); + clk_prepare_unlock(); +fail: + return ret; +} +EXPORT_SYMBOL_GPL(clk_set_spread_spectrum); + /** * clk_get_parent - return the parent of a clk * @clk: the clk whose parent gets returned diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 2e6e603b749342931c0d0693c3e72b62c000791b..478005f4d53ed0698ea17331730c755e08ea7984 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -84,6 +84,21 @@ struct clk_duty { unsigned int den; }; +/** + * struct clk_spread_spectrum - Structure encoding spread spectrum of a clock + * + * @modfreq: Modulation frequency + * @spreadpercent: Modulation percent + * @method: Modulation method + * @enable: enable or disable modulation + */ +struct clk_spread_spectrum { + unsigned int modfreq; + unsigned int spreadpercent; + unsigned int method; + bool enable; +}; + /** * struct clk_ops - Callback operations for hardware clocks; these are to * be provided by the clock implementation, and will be called by drivers @@ -178,6 +193,11 @@ struct clk_duty { * separately via calls to .set_parent and .set_rate. * Returns 0 on success, -EERROR otherwise. * + * @set_spread_spectrum: Configure the modulation frequency, modulation percentage + * and method. This callback is optional for clocks that does not + * support spread spectrum feature or no need to enable this feature. + * Returns 0 on success, -EERROR otherwise. + * * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy * is expressed in ppb (parts per billion). The parent accuracy is * an input parameter. @@ -255,6 +275,8 @@ struct clk_ops { int (*set_rate_and_parent)(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate, u8 index); + int (*set_spread_spectrum)(struct clk_hw *hw, + struct clk_spread_spectrum *clk_ss); unsigned long (*recalc_accuracy)(struct clk_hw *hw, unsigned long parent_accuracy); int (*get_phase)(struct clk_hw *hw); diff --git a/include/linux/clk.h b/include/linux/clk.h index b607482ca77e987b9344c38f25ebb5c8d35c1d39..49a7f7eb8b03233e11cd3b92768896c4e45c4e7c 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -858,6 +858,21 @@ int clk_set_rate(struct clk *clk, unsigned long rate); */ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate); +/** + * clk_set_spread_spectrum - set the spread spectrum for a clock + * @clk: clock source + * @modfreq: modulation freq + * @spreadpercent: modulation percentage + * @method: down spread, up spread, center spread or else + * @enable: enable or disable + * + * Configure the spread spectrum parameters for a clock. + * + * Returns success (0) or negative errno. + */ +int clk_set_spread_spectrum(struct clk *clk, unsigned int modfreq, + unsigned int spreadpercent, unsigned int method, + bool enable); /** * clk_has_parent - check if a clock is a possible parent for another * @clk: clock source @@ -1088,6 +1103,13 @@ static inline int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) return 0; } +static inline int clk_set_spread_spectrum(struct clk *clk, unsigned int modfreq, + unsigned int spreadpercent, + unsigned int method, bool enable) +{ + return 0; +} + static inline long clk_round_rate(struct clk *clk, unsigned long rate) { return 0; From patchwork Fri Jan 24 14:25:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13949374 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 71A7DC02181 for ; Fri, 24 Jan 2025 13:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: 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=+ePnyDdKyIs8yCcON+kQ6iffv5+zA00+HvqYWQRtRm0=; b=CxvpyxD+zY2W2EqRLMcv//ikNq XY3ID7tpNNXy6fspR+ZeZOOImylW3CcRZUDx7V3VxGC0oKmnKdmO/iOmzj8brBw3uWZT1AFWP4o2r KsEoLOxx/zeB0CFClSBZvkCnVfBwjBv6elp9rhFR3RPcF6bN/CS6M1dDR5l5Bv67RQs1r9KsNPsl9 NZgFI6V69Q4dvt+VIChp4Mb2Vb81YpFIflUG9mZIcOPFY09DpOm2jmy6z6KAPxmvPk6Iycla9wsF1 6StD6u9YW65APT4x2ygUdPU+8d5litLYb8Fu+FiMuVjJ3uSoj8fEYo+5oPChFWRUq4/Cm0qEDFZ31 aPIZ72GA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tbJeT-0000000EjWF-26yL; Fri, 24 Jan 2025 13:23:13 +0000 Received: from mail-am6eur05on20611.outbound.protection.outlook.com ([2a01:111:f403:2612::611] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tbJad-0000000Ej8G-2IU5 for linux-arm-kernel@lists.infradead.org; Fri, 24 Jan 2025 13:19:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UNRgKmrmYlGR8QGKa9EMdUciYWOIOcaEGw3xh+WkKRHtKkes3oH2VmlyU/yjneaodWhBU1EZ997hc6BfSxqB0hAqJBnPBfTf65JRHQTY26robFFDRs9i6lgzBnlV1wIWZh0txCkA5ALyS3qfeqJQgtZG3H5zawLpGX8da3TMsnovPI/5ECYnBod0EKBup+qTer9/BNvwCsaVCKjVPHyyNGhJxi88mZ5T+jlEjlzaGmNwYNdb2HwCnvF6HAKwc2ABmJsFTdmKdmXijVTIb3ODF1D/hVduJOv5XbVggL1GicF1rjsI9L8W2vfxZPPzykP2JeqNF3g9+qdgL0g+tfM15g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+ePnyDdKyIs8yCcON+kQ6iffv5+zA00+HvqYWQRtRm0=; b=OsfMaURFSLJstSWbg9enHS5gMzGCc80nKNNpVKjFbMPK2a1b7XGsfn4olgrrv6vk3Svttflha9k8RRJfi7/7Z58jUu0PgMfX/M0aBI0J3EQq8Zh6Wcm6ZLSscJN6igyIzomoCfLO7uedeCvbp+blEkaej6WtfZVAqMppgggYkQn0K+/7jmiuaUWWVSr5xAOhFqHbxiQkqy8SsJmIO6NUQKz7Afb7el/H3zQT5DKn1UCXi8/OIXt3qDWmxeO/pBBTTjhkqfYTQu1x1BZchVXiVHmpywQI2raBqI0VIO3Y+8gU9Mv7mGAXHIE7qxgB0tJk7RMlsYaLzTRWEOuRIwaLrQ== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+ePnyDdKyIs8yCcON+kQ6iffv5+zA00+HvqYWQRtRm0=; b=Qk9+kpvMsGQEL57+357I8Eh0JFKf4GA/gVPDNF3nJhzRlWZKWd00xlbd8jXAAtj8i+Y37i82/A7nmFFiD30HKsyEH2P8vrO87ZS+uO4c+13sTuYnhSYE4FlfVmXz3wzxyYbEuV7E3rtpWPoiJZ3deDS+bM33HFYiceZ5/n924SdeY1OQYcnA4nEpxg8E8WUWVfR/Vw2h2wFluvxyLSBeXPZblJ3zAPSENZj+MK3pspQ9EEmR+51/wNEolpH5BHPSY+O4uSxpNPJxbbYdHd+ohQWxQyyQpxZM1240grg8pFLfeXC1teIvOy/CE8PsTypqIcyaI/xdxwaSy4EmgLPmhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PAWPR04MB10007.eurprd04.prod.outlook.com (2603:10a6:102:387::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.18; Fri, 24 Jan 2025 13:19:13 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8377.009; Fri, 24 Jan 2025 13:19:13 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 Jan 2025 22:25:18 +0800 Subject: [PATCH 2/3] clk: conf: Support assigned-clock-sscs Message-Id: <20250124-clk-ssc-v1-2-2d39f6baf2af@nxp.com> References: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com> In-Reply-To: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com> To: Michael Turquette , Stephen Boyd , Russell King , Sudeep Holla , Cristian Marussi Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rob Herring , Krzysztof Kozlowski , Dario Binacchi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , imx@lists.linux.dev, Peng Fan X-Mailer: b4 0.14.2 X-ClientProxiedBy: SG2PR02CA0127.apcprd02.prod.outlook.com (2603:1096:4:188::7) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PAWPR04MB10007:EE_ X-MS-Office365-Filtering-Correlation-Id: 31680041-489c-41b5-7699-08dd3c79b240 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?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Qr3WrrzWsMmNijMEQ+0ZWaKFU0Ozw?= =?utf-8?q?3olATv1YsTE/xftQlprm/sZa6YXJA7kkz4XnJ5HHW+FyoO/vmvcNZ3T9htBrXOCvI?= =?utf-8?q?faXWzkgxtGEbWRmbae0c+D4Gz/TrYqc8VBkE39Pghfj+vwhJcs4jQZmxs+UT6PjHV?= =?utf-8?q?nx9vcdzUKt/vkQn2VM9lJ54/dbuNmDtqKxKCDrQy9cxbC1f5ok2s2+cabbcvwSZNq?= =?utf-8?q?oAc2CCbQ0HXzFgCB7KzDzwGH5OR/yRir+EzlOC1IZSYLWuuIMke9rXifiOLf/xtKG?= =?utf-8?q?qwmRWvBHN2qCANhJPursV1EGU5aXG4IohPi6w6ernVdaRHG+ijTEGTqJHtbtbLjj3?= =?utf-8?q?VhhEd2Cy3YJ0L2iQPslmxFj3JPFQ9s8OyVcSwH1s0R6Apugkdu8rA2IJ+Tc3Yq/FY?= =?utf-8?q?b/pxmTzzIBOhV09FlV5hU9eNPX7GETtDRw4OxHGedcRFBwBVuO3n8Yie3g+u/G/ik?= =?utf-8?q?Zw3HnVG+aOvucYBd+yM1SqqoACCKR+ZbKe7YKkXp9rvIOLtkxLa9ERsrydEG8oDTU?= =?utf-8?q?LORL0iYfFf2?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3jYX7PAbHcEIkW416BZrIBu3Fyrr?= =?utf-8?q?/OgUO2DY0HYZjbLMbDocXmNurY8sO6TPnG6udunbR/48m1WVtKtLx1TohXkNIsXZA?= =?utf-8?q?zY5onmE73j3kBBHzkloNtJGHpgzlzFzb0MfeVlSA3XR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2Q+TE+J1R2KSI04D4lrZ8uNXs5TUlPv6ohu9O3gw?= =?utf-8?q?LfRcFz2pXaHftFqEXQw2JJbWoc86dDerbj1xZInGZHaPghRAxT6ZJKp+cSQ/MVgwA?= =?utf-8?q?7mO1P0E4W7jydCR6c7EkMrabayZMbMpz4oK7s9Bd7uaGfzpycbfFlQ/rez6fYyfcz?= =?utf-8?q?V6qXXSfNfB53Xqu8ZPAxgQjS7yGMNbolQ6GtoE4kSaTnzqum3kujDqAC7kus1sLP/?= =?utf-8?q?HQA7Ir3rF29N9rOE2lCqKWWWTYrjHqdJE5hBEgKgrxiB2F4mdT15h7G9uIrtxTR56?= =?utf-8?q?BKeJlg+zkxx9qd0aCgwg8NSUx203ZwHr9wgAwOBg7ZsxmUuozUx4JD66O8DkX5kKD?= =?utf-8?q?IBPtnZ0A+zHRPt17AgmQdLyLMqG5Qvz1TSbDNuY+mpiArDAWgDsANZs2hTnNGm/jF?= =?utf-8?q?6wATC7fssqIMwRfugrwmtC5vjdGZrIgqyZOIM7znUsE0+t5Ty6N/8glM1XBkOK3UD?= =?utf-8?q?hN4kpUTgIUoaUAIW+B99jccyUmNdlkN1Zgb4tCa1GKgT63vOajY1Pw/EyOCNKWbNW?= =?utf-8?q?R9ckTi/DuGC5?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31680041-489c-41b5-7699-08dd3c79b240 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 13:19:13.6902 (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: dE3GiPDH7+/OQJWbpvJ2dvW5KPlZP2m78Mk83T82QbQXbwEaFRnOmHHyHae8luvDBI1GzEqP0rDrzVG1szU1Ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB10007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250124_051915_595382_03AEDA0A X-CRM114-Status: GOOD ( 16.81 ) 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 Parse the Spread Spectrum Configuration(SSC) from device tree and configure them before using the clock. Each SSC is three u32 elements which means '', so assigned-clock-sscs is an array of multiple three u32 elements. Signed-off-by: Peng Fan --- drivers/clk/clk-conf.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index 303a0bb26e54a95655ce094a35b989c97ebc6fd8..1ca4222caa829223d65dd37c7a776d43dc421944 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -155,6 +155,70 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) return 0; } +static int __set_clk_spread_spectrum(struct device_node *node, bool clk_supplier) +{ + u32 *sscs __free(kfree) = NULL; + u32 elem_size = sizeof(u32) * 3; + struct of_phandle_args clkspec; + int rc, count, index; + struct clk *clk; + + /* modfreq, spreadPercent, modmethod */ + count = of_property_count_elems_of_size(node, "assigned-clock-sscs", elem_size); + if (count > 0) { + sscs = kcalloc(count, elem_size, GFP_KERNEL); + if (!sscs) + return -ENOMEM; + rc = of_property_read_u32_array(node, + "assigned-clock-sscs", + sscs, count * 3); + } else { + return 0; + } + + if (rc) + return rc; + + for (index = 0; index < count; index++) { + u32 modfreq = sscs[index * 3], spreadpercent = sscs[index * 3 + 1]; + u32 method = sscs[index * 3 + 2]; + + if (modfreq || spreadpercent || method) { + rc = of_parse_phandle_with_args(node, "assigned-clocks", + "#clock-cells", index, &clkspec); + if (rc < 0) { + /* skip empty (null) phandles */ + if (rc == -ENOENT) + continue; + else + return rc; + } + + if (clkspec.np == node && !clk_supplier) { + of_node_put(clkspec.np); + return 0; + } + + clk = of_clk_get_from_provider(&clkspec); + of_node_put(clkspec.np); + if (IS_ERR(clk)) { + if (PTR_ERR(clk) != -EPROBE_DEFER) + pr_warn("clk: couldn't get clock %d for %pOF\n", + index, node); + return PTR_ERR(clk); + } + + rc = clk_set_spread_spectrum(clk, modfreq, spreadpercent, method, true); + if (rc < 0) + pr_err("clk: couldn't set %s clk spread spectrum %u %u %u: %d\n", + __clk_get_name(clk), modfreq, spreadpercent, method, rc); + clk_put(clk); + } + } + + return 0; +} + /** * of_clk_set_defaults() - parse and set assigned clocks configuration * @node: device node to apply clock settings for @@ -174,6 +238,10 @@ int of_clk_set_defaults(struct device_node *node, bool clk_supplier) if (!node) return 0; + rc = __set_clk_spread_spectrum(node, clk_supplier); + if (rc < 0) + return rc; + rc = __set_clk_parents(node, clk_supplier); if (rc < 0) return rc; From patchwork Fri Jan 24 14:25:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13949379 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 38D51C02181 for ; Fri, 24 Jan 2025 13:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: 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=CnKZ8Mho43YDUCJkElKu7eTrlsMJP2Pw5ApKgJX2Kkg=; b=4GLn8C2gD5cMmEDkhGOvt4FSEb jLW0TBorkLB5XMsWA8CPisP7W72eOgcEcQiFF/QnjH077ZVpBkpLmA9Pm5GeYwvJwnH9jae0xjoaQ O2Dl4qovcyI9G3lC7kfxo15A0dAEl1afObX6VDt5dJwPtTLIzKlapDVKLlRcNiI6a126Q1VSYmZ8h cQGxOsAE966q6EtNXHniyZE0apyzav2hZGtDK+AjuSfJhPS/57Y5Z1b2ASG7+AqiBXiY8koOYyrGj aQtP/ahGlMxuCUti1HceTW9xZ2RKTPQXHZgF5F70iZnkKLj6ljNLQaeXaZKGXJa1R27C7mNNbco44 Ilu6qqHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tbJfm-0000000EjfN-0ZmZ; Fri, 24 Jan 2025 13:24:34 +0000 Received: from mail-vi1eur05on20612.outbound.protection.outlook.com ([2a01:111:f403:2613::612] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tbJal-0000000Ej9p-3rto for linux-arm-kernel@lists.infradead.org; Fri, 24 Jan 2025 13:19:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=opA61YvZI1pHtfrBZcxjpxvYB08DzCqc1nP8TqeBzz1hCE+oHVjCAv3HIgWG27ORbuSHhuS/GB2qvJ/FLbrBAK9/5eXdtenbsWVbo1GyKxuAKT06IbW1xXirb5NQKwADZFpa6TRcGcGJ6sA5sIJjKL2PkGImQuJ+I1B9HJi61yR4V1OGn/qX5UbAV0fftgOBFe8NOFB//n0wfEVnsPsH3DXmPI7bn0AhC6zA2JJN3IZf9eIpF1HY5RH0JOh1Q1sGWe32KHy84UzMyF5zTip/VhFt9m0Tr/0y4FlwFYE3TL73CiOXR6tJ/L2T8Rg0dcP5Br6VJ50yCyFyRtIHX/VNlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=CnKZ8Mho43YDUCJkElKu7eTrlsMJP2Pw5ApKgJX2Kkg=; b=lhcq1ZuC/3NnnZFKxjkkiYBTzhqA2A4d7S+zEM29msy4n/Yk7NlaVHB0TRTmp5ueXZ1UGekdoxK3uP5TdsGfA/QVZyuYehKUCrGNdBOt2YkVdj/dPvdWiJni8XD9sh1/bg3p7Q1QeAZUp2VDCDSqdvxsnN2ycN0VzMWvkeKBT5TaMHK79iKFZoEftRCFmdxuZcUvLXtcQFSpBRcfUfwROStTz4RZv+OHk8nrpIwBl+p8UiiBPhn0L47wzadj+h3RdHaREQ8Cmk1/meR7jej0IXifCFklNIO6M59+U/1WxyY36H3t/flawxM/Nv1oACEnvx+WZ6OAEGVm9TCfJ+S30g== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CnKZ8Mho43YDUCJkElKu7eTrlsMJP2Pw5ApKgJX2Kkg=; b=G6uHiSBMD+OUBGAmbyvUJrV7rffZm424EoPHhjqu0FZLEAMuFr+u0d69o6r3glyj+QnlGKGBqtA3+wtw4HmeWJoGba5vUKfP9HUNBNV8pJaq+XzhIcSoMEowN5S+uCPhMisk1aBS81ma2+vKeJPklz14S+IdtF/+KjsqIthJmblkV31YMaOoSwyn3XNp1Y4sd2btztMf+cNqFe+w4b1sKPWZPyP0vFmCaHcVW6Gv9QZ+9QC/g3qghPtj+QSykpQ+55ah0zwUT2p7ng5+W29BNrSpizV7sv3B7RIn8GBzPZSMchuEDq8rdddmxXZq1JgvQd9ztoj7lCg0VIRl3nf65A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PAWPR04MB10007.eurprd04.prod.outlook.com (2603:10a6:102:387::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.18; Fri, 24 Jan 2025 13:19:19 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8377.009; Fri, 24 Jan 2025 13:19:19 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 Jan 2025 22:25:19 +0800 Subject: [PATCH 3/3] clk: scmi: Support spread spectrum Message-Id: <20250124-clk-ssc-v1-3-2d39f6baf2af@nxp.com> References: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com> In-Reply-To: <20250124-clk-ssc-v1-0-2d39f6baf2af@nxp.com> To: Michael Turquette , Stephen Boyd , Russell King , Sudeep Holla , Cristian Marussi Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rob Herring , Krzysztof Kozlowski , Dario Binacchi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , imx@lists.linux.dev, Peng Fan X-Mailer: b4 0.14.2 X-ClientProxiedBy: SG2PR02CA0127.apcprd02.prod.outlook.com (2603:1096:4:188::7) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PAWPR04MB10007:EE_ X-MS-Office365-Filtering-Correlation-Id: 507e0d44-98b4-47e7-a067-08dd3c79b583 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?5sfAw7enAeV/NrEWipiJFlqgCh24ZuH?= =?utf-8?q?MxAk0Cap296bFDJLsNXBSubiOEEZ9VD85K/Bi6dvpOrnsU56efBIOEiP2xNBKMc43?= =?utf-8?q?ie0+U4JEcm42zIuNC8EWpkUyeZ6vEnUdUIZGv79PyF0epKSBuamMiajELv5PkNWlX?= =?utf-8?q?J/BM/7WbW626RjVaz3xnaLzGKPChAqaegtOLX/R1RQ1UsSOJDFsuM0kX5Y9/E+bHS?= =?utf-8?q?RgO1NcCCRGerp+n69wtFGg0XrSQYCqRbYxbLD0SP3HX9OHKx6HJTZUu+pKCL1fn9C?= =?utf-8?q?jUqGYpWqSAgo0ytborbs/DL7BMtgq/qdOZF4UfuTHTtpXYW5LCrzqmk9GrMkJV61I?= =?utf-8?q?rffDaj31Z5I+aem0k+so4dD6Rk/PcaDnr/QX/O3NKBKB//Jbh1Hn8zdd8EGLdYEWD?= =?utf-8?q?0oOcFBpvr813OxVjmJle4vbA9h5ZGsE4iXyRtDQcJqc2RUoE4UH66kx7nSfRHK6Tg?= =?utf-8?q?mdcaSidJCnB+v23Z8KM7kY4NcsGCZlVGGEWt+824fWjrLy5TBgC/kOk3hA24MWkCC?= =?utf-8?q?jAG62W8rYqrsxJ4kirrxZw7KevU+mFTezBd19R10ogLEoCuJdJ2CKg4efLUsFwxKl?= =?utf-8?q?beNI/Wzz70q0JfSXsAx0UYRh3EPDYZ+23vHrbei1E9ht7f5TuO11vpeLqu5ZNCwWi?= =?utf-8?q?AMUkefBhno7sYj+4AGSxkQbR4G6deSJwzsvzXJlOYiJyhL0izly3xA0cWHcbVudiU?= =?utf-8?q?s52soBzFPMdQ585ul89RW4oiz1wdLjrP12yEH7TbrHHRIfIkpxbXa6oK/Wg292ei0?= =?utf-8?q?3EojHM/sLg8hcKGRM7ZxUOlYrniQiQD87jnex+CGXevWnfChvckrPVwglx622o8sn?= =?utf-8?q?WQTWi97CGJmr34MAmKELQhZC8O76CWeggHGEXeXFvAHslhDXCkqcNPZPE0khOEOdZ?= =?utf-8?q?Vn8CmpSJCcjWCWpQF9dldBbb/h49o6bQ6UdDoD333zVWdFK/cS1iWh6b/wr4gi/+i?= =?utf-8?q?7NtIeiTlmFaGhvrM163iyW6yyHXsEk2n6OchVMc1rbcsl2sh7o14e+W2iTOMgZ1yH?= =?utf-8?q?sEsO8ZWsyh1jxlS921tBlyUf1I3uojt4d1vsqO+wSqdKo7rtDdf+Xo7H973mdgL7K?= =?utf-8?q?V1i5KxYSVkF3M49ck6H/OgREcFqnicGhGi1htTytgv5BelHtA23cXhd4lVx96CMKj?= =?utf-8?q?6o/692EVNZolt8+2x1XC6u8wRFk7cLgxmySdQbk29coLpGcripVRiSaJp0QdhqB5I?= =?utf-8?q?cfrMU5ACRoWfosVnnAl12svE3jGoytv9LRl2o2TxjFerDB9brBBTb33hF1UUyTq7h?= =?utf-8?q?wnxFtUowzgckvVF/mckzDivt368ZIRoMTRSFP6TImLLshCV8ALRkF4C3gFC4KJS2w?= =?utf-8?q?LSwefqQ6w858YaLNTe56oTMHUxyn+XA+n3UMM68aJo2fluDK55yvjI8nCBAyHeHi3?= =?utf-8?q?qVkf8lJ/6LQ?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0yc5O/4VnOukqZRf75ydqfqklrUN?= =?utf-8?q?MLVXp2VkHbkAzys+jR7NrWUCF9bLcgIXhL6sypNaFKF5HE5PfLr1M96t6+TV0F7yf?= =?utf-8?q?vfaSoK3RvHuhHNA+0UpqiMez0DvTAWy5+XDOO3N71jgCrCNZzyxKa5O4q928osydX?= =?utf-8?q?6R320PU5NQOieJSfF+oZqnJTmanPiaMUO1ns5Q2jlHd6iCeDmvZMGGuRALOu8HJng?= =?utf-8?q?bwhBRN9796blDh7/bOgzsaOlUk/x4XnwQ/dw27cmjDxeb03jToPWgKMIas+LeewgP?= =?utf-8?q?ut53TcaxnCyqelX6vy4T90uqByoF9EyLsH4tyUioTl4hIgmHwdEjXSaqBhn1G4L41?= =?utf-8?q?MdL4foHa34SBP+HmaKfTQDyBOJOx94AO26ONOwM3LsJbhYEQC9CwTNXZTqXNg3CqJ?= =?utf-8?q?n6UVJQbG1J14ClWsPX9oLxeT90NGjayJT7x7wbjvBamfy2woCC49h4nxhWJpKx/Zn?= =?utf-8?q?mMZYdipICChlk+/PA563adNko/FfbHD908+h3PrCltLtWHuX4WFUD8/RN3nzB833U?= =?utf-8?q?1xRqbN1ACjsqH7kRJxrEHbI4yJN+QN206qa96ySFwOELF8ytUwzLAds9N0vxVyy3T?= =?utf-8?q?nzNBixs/D6DI98NLSFnXgO/UqZqyr6dMzl2XebPA1eQoNbs2oJhFQNe+qfyOn9HAm?= =?utf-8?q?bnHgVFWi960uhig9d2I9k/mhlbReOKJCfzTzeaRapmSwZ5qwEA+1I9SGGca4RYuOr?= =?utf-8?q?KFqbfOPBfpjjj/bmIW4who5v2WHP1vB0Ol2mi2vPw8klQry402PzESpLajQLSPsfA?= =?utf-8?q?g/pHHhS27Ciiut6zkn183fPXysSGUk27qprfGPo19jHJOVelfRuPEW1lsBfs9KTz8?= =?utf-8?q?rJURTX7/3stTjxUlJ8SMfmzy0CRXEox1HmEJjk2H0fL8buBS8LIZducLb33AFLlo+?= =?utf-8?q?zsetM/tFPCPg5lKvyLvwsTAEX//e0APmSPMbqUNzrZ+GO+S1WPPrMpHcpmGmhg6+/?= =?utf-8?q?eM/wOPOunLTsMzRLJbHNOk+Yw41nlafKfgsHEBZVutGgWv3NXAShluGsB9wmnnbLP?= =?utf-8?q?uic3lQnk6c2bSkxnPp4xE0pFTjou3v71zpDFffobHSdIyih9CNdwSVEseLnSdpWlS?= =?utf-8?q?J4TDKEVtXuHz2yXTg5qStlGJq6C3+foOAtNZZJDRw+Qln0smtKp2AJZBAeoD8/LC1?= =?utf-8?q?W/xUktY9tcKOE2F2jX8GvsTS6nxH91qwDI9aBVEfrOjiDsMoMcu+CwP/+QyiVAxek?= =?utf-8?q?DSNQIiugjX+cxc6C2P9JgWn+WQlqcn7n26Ylgu773U0UWwZnmOAiEEhiRFl9XMLet?= =?utf-8?q?3rcel+ItMin924wWklzF0mNpG/esBBcDY7CXyzPpk3ki+vsc5sBGhgcQmJxGsGNMD?= =?utf-8?q?RL0fiT/oSAF+SxP4SIPuPUVOj2c42t/6dGke5j5VOkPzkUOhnOlVjK/tkwq5r+3bc?= =?utf-8?q?sT5aD4HG/noqpaDOy7wMvMNvc15QD3haPivhqQWxmTE1iuCjzqj0BXPWJzxEnyM2V?= =?utf-8?q?uLv5quM4dXXerLuZWdaeTt6Va9ThGPctspt15oWpzGnOirB+NJ5S3ExyAIGDbGQJh?= =?utf-8?q?rn+AfT/1mYdd?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 507e0d44-98b4-47e7-a067-08dd3c79b583 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 13:19:19.1751 (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: s9Ts1lxfmfpt5eDuUMuybtPNobJybquBhF+OVMWcuQoZn8C0MhDDyq7vHP+QqtMSyykAHdZF6A0sIjjEV+7toA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB10007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250124_051923_974434_D11DF9C0 X-CRM114-Status: GOOD ( 13.32 ) 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 Support Spread Spectrum for i.MX95 with adding scmi_clk_set_spread_spectrum_imx Signed-off-by: Peng Fan --- drivers/clk/clk-scmi.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index 15510c2ff21c0335f5cb30677343bd4ef59c0738..e43902aea6bee3633f8328acddcf54eef907b640 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -98,6 +98,35 @@ static int scmi_clk_set_parent(struct clk_hw *hw, u8 parent_index) return scmi_proto_clk_ops->parent_set(clk->ph, clk->id, parent_index); } +static int scmi_clk_set_spread_spectrum_imx(struct clk_hw *hw, + struct clk_spread_spectrum *clk_ss) +{ + struct scmi_clk *clk = to_scmi_clk(hw); + int ret; + u32 val; + + /* SCMI OEM Duty Cycle is expressed as a percentage */ + /* + * extConfigValue[7:0] - spread percentage (%) + * extConfigValue[23:8] - Modulation Frequency (KHz) + * extConfigValue[24] - Enable/Disable + * extConfigValue[31:25] - Reserved + */ + val = FIELD_PREP(IMX_CLOCK_EXT_SS_PERCENTAGE_MASK, clk_ss->spreadpercent); + val |= FIELD_PREP(IMX_CLOCK_EXT_SS_MOD_FREQ_MASK, clk_ss->modfreq); + val |= IMX_CLOCK_EXT_SS_ENABLE_MASK; + ret = scmi_proto_clk_ops->config_oem_set(clk->ph, clk->id, + SCMI_CLOCK_CFG_NXP_IMX_SSC, + val, false); + if (ret) + dev_warn(clk->dev, + "Failed to set spread spectrum(%u,%u,%u) for clock ID %d\n", + clk_ss->modfreq, clk_ss->spreadpercent, clk_ss->method, + clk->id); + + return ret; +} + static u8 scmi_clk_get_parent(struct clk_hw *hw) { struct scmi_clk *clk = to_scmi_clk(hw); @@ -266,6 +295,11 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk, * Return: A pointer to the allocated and configured clk_ops on success, * or NULL on allocation failure. */ +static const char * const scmi_clk_ssc_allowlist[] = { + "fsl,imx95", + NULL +}; + static const struct clk_ops * scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key) { @@ -316,6 +350,9 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key) ops->set_duty_cycle = scmi_clk_set_duty_cycle; } + if (of_machine_compatible_match(scmi_clk_ssc_allowlist)) + ops->set_spread_spectrum = scmi_clk_set_spread_spectrum_imx; + return ops; } diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 688466a0e816247d24704f7ba109667a14226b67..7012d5efef00eb7b52f17d0f3d8d69f3d0063557 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -80,9 +80,14 @@ enum scmi_clock_oem_config { SCMI_CLOCK_CFG_DUTY_CYCLE = 0x1, SCMI_CLOCK_CFG_PHASE, SCMI_CLOCK_CFG_OEM_START = 0x80, + SCMI_CLOCK_CFG_NXP_IMX_SSC = 0x80, SCMI_CLOCK_CFG_OEM_END = 0xFF, }; +#define IMX_CLOCK_EXT_SS_PERCENTAGE_MASK GENMASK(7, 0) +#define IMX_CLOCK_EXT_SS_MOD_FREQ_MASK GENMASK(23, 8) +#define IMX_CLOCK_EXT_SS_ENABLE_MASK BIT(24) + /** * struct scmi_clk_proto_ops - represents the various operations provided * by SCMI Clock Protocol