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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0061C05027 for ; Mon, 20 Feb 2023 06:01:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE12F858D8; Mon, 20 Feb 2023 07:01:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="CniQa8xI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="BaXLZ2Oc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2793857E9; Mon, 20 Feb 2023 07:00:40 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F060385802 for ; Mon, 20 Feb 2023 06:59:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id C80ED3200C8E; Mon, 20 Feb 2023 00:59:57 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 20 Feb 2023 00:59:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1676872797; x=1676959197; bh=nl Zo3SLUihDiAS7vxRt0a2G6+98UpPji/3sCmQDXeGo=; b=CniQa8xI6e6SNhiQEK NKsmzr1fD4+e1r4gfe7mD59F9btW2lR/c1rTUyVnEv+jsIaLtScrh/EMhHa3sGC7 h8mshn0lqHUsLcY5Wt+GDa0Vm6cFTTMGvlhSOnWtQ+yv4xybzL5MEUEEHKeRyTK+ 2VXjxjoCHfkp8io0JURmuup1PiSSPAd9ZmPP1aXdY8znjXA6n/UD+QoY8xaEtbzf awia3MiD2fmKnYzivUn6oyh6KEe0HR9s6WyGWw9y154LCCdjhNmb7PMnxPcgquwb hb71ss2Ggs3xv24wkP/Rw6LPDMeuyOACtResBKQyoXowb+3ye6gAZ5/dzWfrN/dD MJQg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1676872797; x=1676959197; bh=nlZo3SLUihDiA S7vxRt0a2G6+98UpPji/3sCmQDXeGo=; b=BaXLZ2OcEW0cZhGkl8BDAfy+crzQL RDz7a2nyvgiEL2f47SQ/41hJCZ7cfUcOXT3C2hWKZnatfSCO31XhBpppeSdOBw6e O7K05oPSHgO0BZZQrGhd2WUCj1UFLMezlK+hnGGA+sFhw+gAZGYqT6udG4QH3+FE wi7QONqGraCdNRHDp7xtGj5eyxBMkUBRrZsDuDWIVxOUQ5iDeJIkpI7NWKe7FEPs FWQK1bo9S/niBetVogdYupoPaxmrO7T5rcWl7yBVwF4JxNWqJSLfpzUz9ihDQ5fY QIr7mWWeVH8c2pT4B+KwzyrSVAqcZ0exPEbTaI+dI1LuF5Vs4AEmRPywg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudejgedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Feb 2023 00:59:56 -0500 (EST) From: Samuel Holland To: Lukasz Majewski , Sean Anderson , Simon Glass Cc: Samuel Holland , Dario Binacchi , Jean-Jacques Hiblot , Michal Suchanek , Neil Armstrong , Peng Fan , u-boot@lists.denx.de Subject: [PATCH 6/6] clk: Add a .get_parent operation Date: Sun, 19 Feb 2023 23:59:39 -0600 Message-Id: <20230220055940.41890-7-samuel@sholland.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220055940.41890-1-samuel@sholland.org> References: <20230220055940.41890-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This allows clk_get_parent() to work with non-CCF clock drivers. Signed-off-by: Samuel Holland --- drivers/clk/clk-uclass.c | 18 ++++++++++++------ include/clk-uclass.h | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 53cfd819779..d0f8906cd60 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -485,6 +485,7 @@ ulong clk_get_rate(struct clk *clk) struct clk *clk_get_parent(struct clk *clk) { + const struct clk_ops *ops; struct udevice *pdev; struct clk *pclk; @@ -492,12 +493,17 @@ struct clk *clk_get_parent(struct clk *clk) if (!clk_valid(clk)) return ERR_PTR(-ENODEV); - pdev = dev_get_parent(clk->dev); - if (!pdev) - return ERR_PTR(-ENODEV); - pclk = dev_get_clk_ptr(pdev); - if (!pclk) - return ERR_PTR(-ENODEV); + ops = clk_dev_ops(clk->dev); + if (ops->get_parent) { + pclk = ops->get_parent(clk); + } else { + pdev = dev_get_parent(clk->dev); + if (!pdev) + return ERR_PTR(-ENODEV); + pclk = dev_get_clk_ptr(pdev); + if (!pclk) + return ERR_PTR(-ENODEV); + } return pclk; } diff --git a/include/clk-uclass.h b/include/clk-uclass.h index 65ebff9ed27..4d616720865 100644 --- a/include/clk-uclass.h +++ b/include/clk-uclass.h @@ -22,6 +22,7 @@ struct ofnode_phandle_args; * @round_rate: Adjust a rate to the exact rate a clock can provide. * @get_rate: Get current clock rate. * @set_rate: Set current clock rate. + * @get_parent: Get current clock parent * @set_parent: Set current clock parent * @enable: Enable a clock. * @disable: Disable a clock. @@ -36,6 +37,7 @@ struct clk_ops { ulong (*round_rate)(struct clk *clk, ulong rate); ulong (*get_rate)(struct clk *clk); ulong (*set_rate)(struct clk *clk, ulong rate); + struct clk *(*get_parent)(struct clk *clk); int (*set_parent)(struct clk *clk, struct clk *parent); int (*enable)(struct clk *clk); int (*disable)(struct clk *clk); -- 2.39.2