From patchwork Thu Sep 14 07:12:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13384708 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 047C6EDE988 for ; Thu, 14 Sep 2023 07:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235885AbjINHHt (ORCPT ); Thu, 14 Sep 2023 03:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235823AbjINHHr (ORCPT ); Thu, 14 Sep 2023 03:07:47 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2083.outbound.protection.outlook.com [40.107.22.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB3D5CF1; Thu, 14 Sep 2023 00:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jCay/xLTiyQJim7XlVBSc3zmxwyz1LF4QrvixYAI1G+EjWka63i2N9F3C+gKACZIsPsaYGTHvO0ep1yTvCvyR5sfg0Xg5Cq/8L1n+2g5Mgb6BZVZxa+Tyn56+FgR0+e/k7InVrMGHtGkFSr2aILiHnk2lStNbUvjc2WbIYbIi2RnDNETyNHmqWpH1DEMq8l9EvMp3IbpedgvxZooJ6fdj7K18Gepg/qbnMWm1WDugDVRLHPqeNsfy9kUvUhtFKxB7UqH2GBA8vA5hDfLilFDCx6c3xBMeq4YKHikpxzKgWlT6VHu+zfUKgml7aAgboj37Eyxp41YHczJkTWsZPVRlA== 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=w7GEJdMLv02qYPHlPu72P2aoCKLzhVJHSZH0rJYBNuo=; b=LVGuHXUmpfR+9xMkluuqTHsu/uYFn9xEjhJdvG0h98dvDcqNM6kd6X4ciOSP/784RnfOgDoGQ4cPq8wwbGfQv05hXlJxI743fF9pD830AHZOEzFWBrgW17ASR1j+iLemfBx4BV5uX0bdF8xXTLkeBPS8ERSrzY67wfAhVdWpIk0FvNCXN179Jkb010zt5q7XKNKzkqGH8hItQQjD3YpsT4MJN0mAVmfsQwgZ/KfrKmiqUwmcKgmCHjuLyGaWh4kYzpLO5rkcFQ0qTkU40FWUzUY/61CsuoUlNZ31wmgxARc3qOzZwIQ1FT/DCxGbzg8x+yqT6G/Gs3VSHm6RSejtdQ== 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=w7GEJdMLv02qYPHlPu72P2aoCKLzhVJHSZH0rJYBNuo=; b=NdfpAtKAyXUvzANEgxnpuexVNisvgEtknXLBSUwt1iyzjeuiL1EKv8+3zNl1LS8LH4J8+/hsCXvNvrF84qso9dNdvteOA8tyV3slm+SX2gekeZSOvvQnOzA4V13oIulXLR5vYAW6UQBjj2/41/61WvC0cQ2NlYhXoLGYiN5lsfI= 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 DBBPR04MB7628.eurprd04.prod.outlook.com (2603:10a6:10:204::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Thu, 14 Sep 2023 07:07:41 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b%3]) with mapi id 15.20.6768.029; Thu, 14 Sep 2023 07:07:41 +0000 From: "Peng Fan (OSS)" Date: Thu, 14 Sep 2023 15:12:12 +0800 Subject: [PATCH 2/2] clk: scmi: add set/get_parent support Message-Id: <20230914-scmi-clock-v1-2-bf8edfb0546e@nxp.com> References: <20230914-scmi-clock-v1-0-bf8edfb0546e@nxp.com> In-Reply-To: <20230914-scmi-clock-v1-0-bf8edfb0546e@nxp.com> To: Sudeep Holla , Cristian Marussi , Michael Turquette , Stephen Boyd Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Ranjani Vaidyanathan , Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694675547; l=3053; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=tW+XZs/tR9PEWaSz3puVeFpnietDoPGkVjeloq9GITw=; b=Ax+yBfSWa11SzVDs/heYDKiepBbFStf7urPfAE+rjkvm/stcdPlIeTc9SY8phyCutXXBVST6C U63AVGPPh0cCkKnJNC8LwrbcGbT0aS9pvLzXTMRTPTgKJhOt6Y1LdCA X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0041.apcprd02.prod.outlook.com (2603:1096:4:1f6::18) 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_|DBBPR04MB7628:EE_ X-MS-Office365-Filtering-Correlation-Id: f00893ca-e024-4ce1-2289-08dbb4f14928 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: d02kAO7Qvel8L+PNl9XR1xdsf3VCacsb3H4ZbfC5W4hN4/0Wa21JT/p0tkook7E/sfcaXd6laS8ZUOYw3n7K85cITWUrWe+Xq0plVFG0UMOx8hGgom2EcAOIi51UngqzzXcAXL0t+CpeHi63wsCBkmay3Hn1vpKm7h13fShL5g8rKX/s3PK0R61eYICz6igjLGXJ0n4dOu0FaLUqbS5w/t5plCO+sKfnoMFrHpWl/BS0DWSV6N1x1iozNpWTsKkPAonLh4T8hRcOC1BDmY3lEva4NbI2KmBe0onKJze8fZPMulUIJa+wBYjAH2RaFS8vuocl+LlzmzoWf0e1Tj+hWO15wgMa/XkSb6hEIyRS5HySJFb+yitYtrQKdR8G9hT2DHFkVmHcbbmr/6VEXNoB8XD84HkXu2S7TGAoEY9DlTkDpvQiZft5IO/hEzu2oMcbuPCpAotHDKDGm7zTl3wS+caAy+HzeywSoFE1IhT13l7d7KorCDU8MHqUYgep0kTxKcyKCJYxZmlcPApRZxklOP+81e+NkxCBIo+E9VjuSjd0eBaYidt0yMvGDHB+u57KtZycAUmLA9UWuZ/ASNB/wVO69vCztMmQyTlTqLPE+AXhtZMiemjyI5Q7Xk/P4hzl 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)(136003)(39860400002)(376002)(396003)(366004)(346002)(186009)(1800799009)(451199024)(316002)(54906003)(110136005)(66556008)(66946007)(66476007)(41300700001)(478600001)(38100700002)(38350700002)(86362001)(36756003)(2906002)(5660300002)(8936002)(8676002)(26005)(4326008)(83380400001)(6666004)(6506007)(6512007)(9686003)(52116002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OXgUfzIjo2TN8FlUFKtJeusNGxpQ?= =?utf-8?q?dzAVgXgiotAoaqnPhNOF96y5jpNzMEvoauncGL8mONs+NFdSl58vadpcy7DUUUDZV?= =?utf-8?q?3rqcMLMDWx6YwFrf//k7Omd9igu8y7/jPEl/gMraRS0kjT6xIVtsNWSIqAJK2Bxmz?= =?utf-8?q?qculfRm0Tg2JVrMa9x9zlEyIi6CMIY/rwFDZkSZnHilO+JXXptMx4g48OAraLq1ZG?= =?utf-8?q?aXeei2iwz5yYGoUrp9Mfx2aErY3m3QUzm+6h+IDNDitz3nSeg6nUaYxC5ns2vQmSe?= =?utf-8?q?cFTov3p124IDw5rbroHMEcMfC4KJnqtLKTJIVOSYYPJ01C7XRkrUUFN/stmkREFX9?= =?utf-8?q?viUAgz+9YHOGnBk3qej3o8v6EhEiGC+XKPLRc0cYCR2Kgm49GkUbqzax0uVeb9q7H?= =?utf-8?q?rHpUfNkjNh4MRrC6hbVxHq1TNPX3jNv/6m8YEo4r8ptA8a800HOYjBZNMwWvOsFlp?= =?utf-8?q?ZB6lzmKfFv+N6KQeGlsp/uRa1I7VkP0jjqMk0bl6MIkfoDZYRT7EGsGXxp9xyZFDj?= =?utf-8?q?nXkFcr5q1dRYYcWTJEgguLpAXi/UkQ2XpRHsXrrvfHgVCvzs6/ACzllLh9ZELbaD6?= =?utf-8?q?tQ8yUvy2ihxxm16E/MfyHRvm7fDIL81Dcz8TG9X5KAQPLgA9Z5Ncm/NIcVCsPcaN7?= =?utf-8?q?4X8bqdVyn+eHaDYI3A8MfdpfWomtj6POBn0SmOem+9TbiOq1fdvi4brEeGTbYbqVB?= =?utf-8?q?SCX7xASgvYZEqOr4DzIt+ULY9gq2c0L1JgvoLyTz2FYCpK4ySuf5BT48gw6DA/mju?= =?utf-8?q?tYmPiDpMiuN5e3JgkntHotOh5CI+vQVuEY+V/3eIt8lDQTHPsO561IsXCFTPoT+27?= =?utf-8?q?+KEVD3KB1DHNWuUkJuy7zd2z79AoQ83N/asiZobI2qt8a2OQa/kpnqQ1qGh4gnu/0?= =?utf-8?q?NHvR2LcMn9D5byB86Hi3mauRwSjiAc1bT1JxVzUMbsXBdxPQHBfZrcg36BEu8i5rF?= =?utf-8?q?jr0jkk17NMjvTe9wpS9Z+h9I9EABqFYF6RM4vfOc+KzqeVJBWrF662Akhe5xJ+j+d?= =?utf-8?q?YSVoafewZ4pvBavkMst9OmJl4c7CBCSF1ekOR53+HI05YfcOdsCzCg2Ut8QJM47Gf?= =?utf-8?q?+d8olqNbmckkCknZ19THKkZNFjvR0XlOG/FVwwnm+/tHXUWXOOyFjlrQ8jATR/loS?= =?utf-8?q?mGEGh52ksZFCyb13yL9eVjrhMYV5iN/GSXjCFDQTZxuNWzbXTwZ2eeYriP6ec7i6Z?= =?utf-8?q?e2gToUYonwGrINNXNdzrhF6G7pN9aP7i45JiijEoKWq/P8evXu+CSk1Bms5wD7NKm?= =?utf-8?q?5pnLlKlGTKzM4kPBWkRHcfJXEHxPGudH59IyIxlV1FxLOdA3scs7I5r9subTRH4vO?= =?utf-8?q?ttKCRFUZNeRHAJEiyFe6WGioytDyAJX2E4nZJUsmQ7w+wVok8M0V7sVfbpjJO99Ep?= =?utf-8?q?6hnI/bbmvqkoKM54hNasUS5We9cc4zBCT0QquUd5Kb/WdJZLxTpRY/y/yCyq/RKs4?= =?utf-8?q?swuYrU8BnVQXCKdLvklE3k7bNVSrNWlkQ6WzyzazoL76+kghd2L8JzM+DeBQOb03q?= =?utf-8?q?wwzPE9fko70T?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f00893ca-e024-4ce1-2289-08dbb4f14928 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2023 07:07:41.1534 (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: wcc45MvB7BhLll18PrZWilqR6qucjyJ+M1WlMymVuCXhHromEDjxP/kfMD4ETaWh4JOPZCmks9uFBqwmkhJqJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7628 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org From: Peng Fan SCMI v3.2 adds set/get parent clock commands, so update the clk driver to support them. Signed-off-by: Peng Fan --- drivers/clk/clk-scmi.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index 2e1337b511eb..6a283020cbde 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -24,6 +24,7 @@ struct scmi_clk { struct clk_hw hw; const struct scmi_clock_info *info; const struct scmi_protocol_handle *ph; + struct clk_parent_data *parent_data; }; #define to_scmi_clk(clk) container_of(clk, struct scmi_clk, hw) @@ -78,6 +79,26 @@ static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate, return scmi_proto_clk_ops->rate_set(clk->ph, clk->id, rate); } +static int scmi_clk_set_parent(struct clk_hw *hw, u8 parent_index) +{ + struct scmi_clk *clk = to_scmi_clk(hw); + + return scmi_proto_clk_ops->parent_set(clk->ph, clk->id, parent_index); +} + +static u8 scmi_clk_get_parent(struct clk_hw *hw) +{ + struct scmi_clk *clk = to_scmi_clk(hw); + u32 parent_id; + int ret; + + ret = scmi_proto_clk_ops->parent_get(clk->ph, clk->id, &parent_id); + if (ret) + return 0; + + return parent_id; +} + static int scmi_clk_enable(struct clk_hw *hw) { struct scmi_clk *clk = to_scmi_clk(hw); @@ -139,6 +160,8 @@ static const struct clk_ops scmi_clk_ops = { .set_rate = scmi_clk_set_rate, .prepare = scmi_clk_enable, .unprepare = scmi_clk_disable, + .set_parent = scmi_clk_set_parent, + .get_parent = scmi_clk_get_parent, }; static const struct clk_ops scmi_atomic_clk_ops = { @@ -148,6 +171,8 @@ static const struct clk_ops scmi_atomic_clk_ops = { .enable = scmi_clk_atomic_enable, .disable = scmi_clk_atomic_disable, .is_enabled = scmi_clk_atomic_is_enabled, + .set_parent = scmi_clk_set_parent, + .get_parent = scmi_clk_get_parent, }; static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk, @@ -158,9 +183,10 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk, struct clk_init_data init = { .flags = CLK_GET_RATE_NOCACHE, - .num_parents = 0, + .num_parents = sclk->info->num_parents, .ops = scmi_ops, .name = sclk->info->name, + .parent_data = sclk->parent_data, }; sclk->hw.init = &init; @@ -250,6 +276,17 @@ static int scmi_clocks_probe(struct scmi_device *sdev) else scmi_ops = &scmi_clk_ops; + /* Initialize clock parent data. */ + if (sclk->info->num_parents > 0) { + sclk->parent_data = devm_kcalloc(dev, sclk->info->num_parents, + sizeof(*sclk->parent_data), GFP_KERNEL); + + for (int i = 0; i < sclk->info->num_parents; i++) { + sclk->parent_data[i].index = sclk->info->parents[i]; + sclk->parent_data[i].hw = hws[sclk->info->parents[i]]; + } + } + err = scmi_clk_ops_init(dev, sclk, scmi_ops); if (err) { dev_err(dev, "failed to register clock %d\n", idx);