From patchwork Sat Dec 31 10:47:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2583 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5E6CA3F18E for ; Sat, 31 Dec 2022 11:47:54 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id f15-20020a056402354f00b00485864db618sf9326500edd.13 for ; Sat, 31 Dec 2022 02:47:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672483674; cv=pass; d=google.com; s=arc-20160816; b=auEwnF4Wx4AGXMzXtIx5bM0fDOkVEs4M5vnX+uVth2A6afSA0Grf8/mb9ogw+HtSfX 2pjSrAWQyYWPluRCgWpZjh5s0ZXfTDTAYsn/4ZEqebYb+X9LaNolommDL1bfz5eV7rdc CpoR5L9IQHablYnkjGIQ0mE/WHgqnSKFA6T/oHG9k338VtBkrwkv6Mgy/Mc4rJKwCNkJ azS2OXBAb8VQfWp+bUs9FoM5AmOaRHWsAkGj0etBdZAKGfPf0SlxkhSHh3lKYpeGntyq JSO04KobqYf5DuKeBs7u5hHhpk94RmsNK1HIoFUDZCeAUPmN9U3HJR+pr8YExHSr7FHM OTHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kJhwXmlWembsgGpLBYIOTEu6N6p/rTpk5PeeuqH2czE=; b=qeU3bM/YaZ0pu+2wGRSsHGxmLJMFZ7oWOxbwvEwyMXrdFuLAmEPLdPUhtJ+UrvABNi uyzSUBGILHN1a4wRzYKF/OxIf3gHKq/ijSkX/HKgj3r1kh1Elcem8YjdIQa5UwnYNtM2 ArABzkRH7KmMLUEWugjDyesdVobQrTBaJxhSLPZa4xxWRQ9IettKT42O7WMcR7CERUhi SHcIhJJ/gOyUvGimKcI3gT+IiX9mA8JYOIfnrVFcreRf75Lyy+W81MPhk8T9E/vrcpix oPU9gi6VBqzT8OPp9yCvDGkXWeytqV8i0KFkHFh+JYD0/t/bQT27TmBQQksFbaGz/Vzz JZ4Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dpGsl32H; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=kJhwXmlWembsgGpLBYIOTEu6N6p/rTpk5PeeuqH2czE=; b=gn38ZmKKBXcuWmCjXfwq8dsFAUN0EhKexCnmq4DeiLvoBjLZ0BXle2DXaddxwKJ8cd SCrfHx+O/1gszakcEh1Oy/WYPH9A5I+GDYmlf2ixUIgcujfNOg3Cv3ijab0O4lDrbwoA Lnpf3rdn9SpQuJKkXhV73EibRfIAYKUlJtBFw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=kJhwXmlWembsgGpLBYIOTEu6N6p/rTpk5PeeuqH2czE=; b=AGho4WiG+XiEyYZhFU5M8gI8uZPiVJ8zoVO5CMilWAR05wZm9YsJ2+eUox5/Vp6uJH MfMrg0laoUWVTj/gCwQyYdsM5UL7izX+n7deeP9HmAlxocwOwv8zg4IzpFMrM3vrc3N7 OLsOOJbcEoONC9+QsBhZspwmLN6YfsdqJJ5Yn4I/OQzJMT0n9QvFBSUcAuePp6/43WfX NhDKqsic+gxO+hka4oTB2190kgUXaykYj6fhZINWqtnCvk6cVxRFnpUfrnHrB8PGHjaK BxqvulFPr+8JnXtLT3sIevXPwrzcLiABOBUlt9QoJT+u7XDs47Ef8yGpr4yiLttZE3ER KLgw== X-Gm-Message-State: AFqh2krKsoPc050NmV+mTH+xEKladQlI2oEeX3zBKHDdY8Eey9WR5D2a P/6szmMhxhkvN+t5PmeQNfui5bNY X-Google-Smtp-Source: AMrXdXup6ZxPOd7AODHl9PhaG89zdjqipc2P0VsLd86Ju+wI+uw01j0jdHZxioAHcoIZEdLr9KbERQ== X-Received: by 2002:aa7:dccd:0:b0:46c:38a4:a54c with SMTP id w13-20020aa7dccd000000b0046c38a4a54cmr2918395edu.393.1672483674067; Sat, 31 Dec 2022 02:47:54 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:40d5:b0:479:6c1:ef04 with SMTP id z21-20020a05640240d500b0047906c1ef04ls1007617edb.0.-pod-prod-gmail; Sat, 31 Dec 2022 02:47:53 -0800 (PST) X-Received: by 2002:a05:6402:550a:b0:47f:bc9b:46ec with SMTP id fi10-20020a056402550a00b0047fbc9b46ecmr24258737edb.7.1672483672850; Sat, 31 Dec 2022 02:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672483672; cv=none; d=google.com; s=arc-20160816; b=cOucyTLHNVjImOLMddKXvQmcwa9yoR37yEEZpPdbli/nTTBYwhe6Jkgnv+lU9zO80h IQZbAvMDVJU0JJYShtA9MOBkqaY3pJltE4zGn3ytbDG5v005aOGiNojQGi5TTCq5GmzD 51VnZ5z8IncHAz5dPn3z4JTSVMt6VADI7m6C0ppN9pSOi5CRrfKGMWu91ze1PEOWbYzl +v4ti7sRgxVbgifCc4vewFhULtq+7GnDO0Qfav/0iVBL0tMC1L+9iB25jkT43B+c/ky6 DUEr5Rv6xKfUDBXeaKsBBWyO0n4ir9UujQigxjbFQdNcGaUbsK03jCR+rX+RorBGZtFN yQrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9LiLmCOA0Z19dwC3ajYydNnRTh+WZFHl0GJOC3Tfb7Q=; b=wjmz0QQa6MYpL9qpT/PKf48ut0slD6eN9pfGMOzhfVSF1quC+wpuCXDjU35PGeoh2R /AjWb8CnDNVIQWI0Klb8scv4ziYZ1UxfhEbLqWFrbkPOwmjUMt6SOtFUY5NcLylg3I/2 kDeOHaFldclFZSFJX1Sn8im52yLp9h7Dt75aosC5/+9kQBapUM69de4MpKM0T+ioFJw9 Z2zXZgjFlLB6+s3VewsimJ9/n8fGP9Uy18jO3Jedww5tQNwI/8fVsQQrYqu9epZtJFBu 2CamwR9ugqeJwYkBGC6MHQ7VQ26hS3k0VUmBTyU7hdn3vv8cdJbgI0rOprS/DZWRGv01 G8/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dpGsl32H; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id l3-20020a50cbc3000000b0046b593e0c60sor11987653edi.41.2022.12.31.02.47.52 for (Google Transport Security); Sat, 31 Dec 2022 02:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:f05:b0:45c:834b:f28c with SMTP id i5-20020a0564020f0500b0045c834bf28cmr31100958eda.9.1672483672554; Sat, 31 Dec 2022 02:47:52 -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 z4-20020a17090655c400b0083ffb81f01esm10765438ejp.136.2022.12.31.02.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Dec 2022 02:47:52 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: tommaso.merciai@amarulasolutions.com, linux-amarula@amarulasolutions.com, Chen-Yu Tsai , jagan@amarulasolutions.com, angelo@amarulasolutions.com, anthony@amarulasolutions.com, michael@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 02/11] clk: imx: add clk_hw based API imx_get_clk_hw_from_dt() Date: Sat, 31 Dec 2022 11:47:27 +0100 Message-Id: <20221231104736.12635-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221231104736.12635-1-dario.binacchi@amarulasolutions.com> References: <20221231104736.12635-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dpGsl32H; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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);