From patchwork Sun Jan 1 17:57:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 37967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3857324wrt; Sun, 1 Jan 2023 09:58:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSK6zJCxlP3T7E3AxvjoF5TATHVYUTmFSVCp6mKtB0uw1++CIMg4J0SN0UytOLBtqpeaOb X-Received: by 2002:a05:6402:2217:b0:48b:c8de:9d15 with SMTP id cq23-20020a056402221700b0048bc8de9d15mr6132296edb.1.1672595925287; Sun, 01 Jan 2023 09:58:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672595925; cv=none; d=google.com; s=arc-20160816; b=joOxwvS2i80R1DP7354E6k29zNHerSK0o9Vxmvpti9klv3CCl0onr1ge5FxhozV3Iu 1rn0LdZVlHnyi+ReN2I9jJfSjeMcFTL2MVkU+WT17wRFWyGT+HuBaZ7cjIfsd7aDhK6Y 6xwXy20I0k3shwj+1olr0CtTNLypuL63Katlrmm8Ftucz/mTPF14E2J1D994isYvOI7G QjYoGxMIOyLqRgTeKM7+j8RT0kb7aOKF5z5POdKZxF+1Kp+6bDxTDvxaCEcB6ib4zIBW PHi2+AVBwGh/k3YpAjgFPkJkJaHr5IQlxBY9TcpRuixsCWTXUEIN8E6yMvhQO3PjXULy L+gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZYenpSMBggNdY4dx5nVECKefdf2t/s6x5XpiG20A4ps=; b=0oHgU40UKhWmesS+tmru5+alks5ztngBZ61ljuHj4+itvGskdSMXXf0D+ephg4eZ85 X7uUyUXIx8jGgE/kIirQmdnKYNktSDpqTrioT7iOla3lIfHgIDHM7+yA1Hlc9kwAkKN2 zbZBKbLDGIwp1lJfujY3bDtOEGUYqn4HhevO+FWlLdOUt+JJSQY02KVkJuLmR2NNWxqz zFeYcbbIf7nkAryX/givROoOSrO0S6MWKnQbf+nKrES8/L5rOoXDbVb8uKwDL/8XguAF tlkkQiJaexg5ElB0xkdYH5ogNkx3A4Avgvhb9TUo8KWhtGoK101KHKT0g2Nyr+G2zXTI xssQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=X8CpvA46; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a056402525400b0047d5e755f87si24357019edd.236.2023.01.01.09.58.21; Sun, 01 Jan 2023 09:58:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=X8CpvA46; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231535AbjAAR6A (ORCPT + 99 others); Sun, 1 Jan 2023 12:58:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbjAAR5x (ORCPT ); Sun, 1 Jan 2023 12:57:53 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C84142AD1 for ; Sun, 1 Jan 2023 09:57:51 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id qk9so62233106ejc.3 for ; Sun, 01 Jan 2023 09:57:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZYenpSMBggNdY4dx5nVECKefdf2t/s6x5XpiG20A4ps=; b=X8CpvA46t2Qvqw7HL1QfBLBCNiBiZxDPmsHSv5qc5s48zDrioonv13L4/XbypOWl3i 2ufzJE5cydbnR0u3pOCYq7IV52oOMKhAmmhNf1NqubD1xApVQk8ccod0Lgn++gT5GkVw mVqGLAT9PrhhMdxNp2UqwA3LMQkKlV6XoO5ek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZYenpSMBggNdY4dx5nVECKefdf2t/s6x5XpiG20A4ps=; b=Ot+KJtgCMOMzvOsmC/cRiRV1Ybo0tbam2q4uihEmhtZQKeYNgz8lFLnhToz9MXYaYR tH3CqXPWi8/zkClTN9d9LSNGs6nwv2lFab30/8HC4tanAAG8Dn0B72A5MyFgfpXb5gDY cLv9vd3iwcDjgSjESKN8pxGf79+XsG3Jr1JjN1xnlYb6ncMj8IvWF6O/1Y93hSAnF3mJ U8LdvV/zG5ihnGZbf3C8LtLON46gtXklEQQWesUqt7i2DNKSiM2Y3iF3sXVI7EimpsRe a5+8R+VBzPKPjRKz/xrySsNI5NUYT+F7enQ1x1NvnTT+7dbWNi+9mg/NmOPdh5yx5zJ0 UIrg== X-Gm-Message-State: AFqh2krhyyzkFQxxf/Buzmt/TFj5LxQt447dvbL8F7ZRnJg3lY+xpAM8 DaLHzvxJwc0GIxdl8Vt0B4hecgmOo7jLr7TZWYo= X-Received: by 2002:a17:906:55cb:b0:844:44e0:1c5b with SMTP id z11-20020a17090655cb00b0084444e01c5bmr28639393ejp.12.1672595870140; Sun, 01 Jan 2023 09:57:50 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-180-23-57.retail.telecomitalia.it. [80.180.23.57]) by smtp.gmail.com with ESMTPSA id q2-20020a1709063d4200b0082ddfb47d06sm12273018ejf.148.2023.01.01.09.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jan 2023 09:57:49 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: angelo@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com, Chen-Yu Tsai , linux-amarula@amarulasolutions.com, anthony@amarulasolutions.com, jagan@amarulasolutions.com, Dario Binacchi , Abel Vesa , Fabio Estevam , Michael Turquette , NXP Linux Team , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH v2 02/11] clk: imx: add clk_hw based API imx_get_clk_hw_from_dt() Date: Sun, 1 Jan 2023 18:57:31 +0100 Message-Id: <20230101175740.1010258-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230101175740.1010258-1-dario.binacchi@amarulasolutions.com> References: <20230101175740.1010258-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753843945139754923?= X-GMAIL-MSGID: =?utf-8?q?1753843945139754923?= Clock providers are recommended to use the struct clk_hw based API, so add an IMX provider helper to get clk_hw from device tree node name. This is a preparation patch for the upcoming support to setup clocks directly from the device tree. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/clk/imx/clk.c | 21 +++++++++++++++++++++ drivers/clk/imx/clk.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c index b636cc099d96..6ae122ccd83e 100644 --- a/drivers/clk/imx/clk.c +++ b/drivers/clk/imx/clk.c @@ -68,6 +68,27 @@ void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count) } EXPORT_SYMBOL_GPL(imx_check_clk_hws); +struct clk_hw *imx_get_clk_hw_from_dt(struct device_node *np, + const char *name) +{ + struct of_phandle_args clkspec; + struct clk *clk; + + clkspec.np = of_find_node_by_name(np, name); + if (clkspec.np) { + clk = of_clk_get_from_provider(&clkspec); + if (!IS_ERR(clk)) { + pr_debug("%s: got %s clock\n", __func__, name); + of_node_put(clkspec.np); + return __clk_get_hw(clk); + } + } + + pr_err("%s: failed to %s clock\n", __func__, name); + return ERR_PTR(-ENODEV); +} +EXPORT_SYMBOL_GPL(imx_get_clk_hw_from_dt); + static struct clk *imx_obtain_fixed_clock_from_dt(const char *name) { struct of_phandle_args phandle; diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index 86538c990a0d..a0e6b8357eb7 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -294,6 +294,9 @@ struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name, u8 clk_gate_flags, spinlock_t *lock, unsigned int *share_count); +struct clk_hw *imx_get_clk_hw_from_dt(struct device_node *np, + const char *name); + struct clk * imx_obtain_fixed_clock( const char *name, unsigned long rate);