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 13EC3C636CC for ; Mon, 20 Feb 2023 16:13:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B49108591C; Mon, 20 Feb 2023 17:13:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EkD48vdk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1B1D85926; Mon, 20 Feb 2023 17:13:13 +0100 (CET) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 234DF8591C for ; Mon, 20 Feb 2023 17:13:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x82b.google.com with SMTP id w23so1220083qtn.6 for ; Mon, 20 Feb 2023 08:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=c+DBYLFrwYvH/0XcsVSV4zWfRZWuNPZBKeWEsna7LeU=; b=EkD48vdkvsjdSF8QCp97tZBA1UI7ay8cAtJ2ZhlAhr1QRpFH/BCTP9w7wXmiC4AC0+ JhCHzL586Mc9iJReKGR/1SXvemJ7oktdyz1tcuImknlMcvFlgYDuEV7aBKSSV0PuGRNU WzrNjqH1uvTQaxYXT8Y6Fa+YR6+qknxHg+XoBLdl/bNMJLH51CN+72uOwPFQPTbxgSQR m7GFal4SUMCG5a0lGsTw131oBHE+aVh3JQS+XU6X05h4spPclmyojgYnw4CZj+bu3jaV 6AXEsx+9baDeW2hBdWSotcsshOSWnAaO8iOJ5Pkup+Dds3UqXqKn8BnQcM5kTUOLizz3 kuDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c+DBYLFrwYvH/0XcsVSV4zWfRZWuNPZBKeWEsna7LeU=; b=1buvm7NDOzyfnOGqTgeJQmdiicMaTdn+tH2Mw7jAxNyhSVJVoRI35kJth2vh2ffwF3 /LF0Lyl+12+Rvy/sfoOy92VuRxrXPwNNVNzmGj8UYyrKBTwLTJxws9RBodMmCR2e3bfI gtG/13WIqcg8wb/18JATRX38FKCppClZ4kCPIxDh+W1qTxtrWH2bciAFzadmmRv5AB0x KRp3l6R+e9nRqf9mxEIeVIdbQpufcvRZShliEKKbb0cqLgw+RaYq9o7h9AVKInULO7qc 464oZnS9OxjCuTqyLEGeTww1ERAIc3H6AIf8U0oc6lqrraH9zHxvOFj1VQEArhB/pJ6P Z/bg== X-Gm-Message-State: AO0yUKUaiUzeCa1K8E0yVcM9WAenG1eQ873HghkGWb1zjF8uV9zUMYY+ JMkmfJnCBsXgjRHAjpPdLakC+10A89ftfw== X-Google-Smtp-Source: AK7set8NlrxXLrTjgKP6uU4dDmHufABAehjrwkEn5qw4Ov9kjMw6+vtdsKCPoCOIRuR9Jkvdzlf1IQ== X-Received: by 2002:ac8:5a8b:0:b0:3ba:1360:ec0a with SMTP id c11-20020ac85a8b000000b003ba1360ec0amr2582176qtc.41.1676909588935; Mon, 20 Feb 2023 08:13:08 -0800 (PST) Received: from [192.168.1.201] (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with ESMTPSA id o16-20020ac84290000000b003b63b8df24asm701789qtl.36.2023.02.20.08.13.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 08:13:08 -0800 (PST) Message-ID: Date: Mon, 20 Feb 2023 11:13:07 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 6/6] clk: Add a .get_parent operation Content-Language: en-US To: Samuel Holland , Lukasz Majewski , Simon Glass Cc: Dario Binacchi , Jean-Jacques Hiblot , Michal Suchanek , Neil Armstrong , Peng Fan , u-boot@lists.denx.de References: <20230220055940.41890-1-samuel@sholland.org> <20230220055940.41890-7-samuel@sholland.org> From: Sean Anderson In-Reply-To: <20230220055940.41890-7-samuel@sholland.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 2/20/23 00:59, Samuel Holland wrote: > 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); Missing documentation. --Sean