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: 2595 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D25B63F9E8 for ; Sun, 1 Jan 2023 18:57:51 +0100 (CET) Received: by mail-ed1-f69.google.com with SMTP id r14-20020a05640251ce00b0047d67ab2019sf16910830edd.12 for ; Sun, 01 Jan 2023 09:57:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672595871; cv=pass; d=google.com; s=arc-20160816; b=F2YvMj3K2adbJ32330GF6MHPCK9o+IG4+NhN87gPrB3kHkr8HzNFPbiWn12h7eqa83 snOv+ntHJvtpF0wdaK8RKXl5/JkqJGWc9kBZhiPypVzF53C/cKSkWmhQwXH/7BlPSckz 2v95q2wvJ93zDBvGlBbC5hahwn+GMhmQ4oPkALE7FIbRu8egINQfHq30z1zNAVXvVWzg eo+CU0xzq9gLU/YQHCSto1fM6wCt9DvLc59Gx8+4OrskCnEVf5XBFKKk0Q+MD4/sJOUw gDHwNixghO98st7jYKeUrCgEcwuQwh0GyglmEuG9a8rOmaG+w+likIrSICxhbT7v9X/8 ZhBw== 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=9fkNx7+y+8S/AIp+vOCN1lyng4vaiZgHVYAK6tEI6zo=; b=TJpy+0a34P3DfAO6qKr5rjN5iw8B6OxajrpE5/GmyRaVESUzVOabkEE3HUFtJ7TIIJ gAK3kGuGMbZhCOeXUH/qdPT28dLEdblBc5ZXy6IFZKOiWk96XJ9x/BfR+DAvkB1z0uff gIe7k+O0QpjA7kY40kJbFso2hH3L8XcN26fJOImO+BJe9CCRvtT9D4hRkFedBQC/tK+2 G7Gh+0gTm1n4juibsrMtCtlZq9IDcGOzWFAmgRkQ2l8wQZ1BrdOrDcbihlaFRGeSHmlL L0X9+3ZhB9PmIAB7AXmwcQbSKNUDzgNMEtPEd97BvRh89tsvhk+VyW3/lki+WQcfmm4l Hm0Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=X8CpvA46; 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=9fkNx7+y+8S/AIp+vOCN1lyng4vaiZgHVYAK6tEI6zo=; b=Hoe2keeDymCHyfid2bpR3bwrKy2y0+biY5QRBfZFGtDMQ9VuP2Jvk7xvEEYLJWEVax NaMYmYVdzivwkrzxHnbEMJHOM+LCOSYUbZujK6M/ENvwqhuTkMAm8lYxk8BjNdtw41MF 05hpezqfRDbcuXOQkKowZ7kFFOOryC/cIlnzk= 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=9fkNx7+y+8S/AIp+vOCN1lyng4vaiZgHVYAK6tEI6zo=; b=RTMGegAva23DFVrh9R554jHTK1SO5M0KYC6rLRCUNIx8Pr7PriAvXQHr/njh1mwi/4 S45zXkILcSRPmRxVkCIzcNeJS8r3L3tmpQ/l1z24+/j/Z+5hOn3OrETewcT8n0iI3H0o d90tBxwHhPJ7K2TAt2C3M7GlvAmYu64vPIEfY+MzKG/TMReJ+A/3i8akdgNcKmcBEZud eizykfKg24BZEjbL+EUc1NCkkWH9hYKdo/qev1RALdhoUANEB6msmSTYMgmnoP7hjrxb dDQ3IUDR+0FQJOk5VAkzepsHV5oJdgkYqFSCPPOC4/4cA57dZWIzdkfD0h1IhK11W3M9 EKYQ== X-Gm-Message-State: AFqh2krtvGbRO4LksbDfVXLKz165yuBkdz7Kf0sKcPSn2ZaH7GULVH7n lLjQBk5+g+ynOei52PMdP3LmJGhF X-Google-Smtp-Source: AMrXdXvU+0cinEnTo1feWS7GbrMeAdebN4uaFLw2jGk9VgTVGjK696RX3I9eJPb4qe0lgczAd8j7yg== X-Received: by 2002:a05:6402:289f:b0:486:939e:46ca with SMTP id eg31-20020a056402289f00b00486939e46camr1537353edb.266.1672595871468; Sun, 01 Jan 2023 09:57:51 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:2ed7:b0:7ae:83f4:3bed with SMTP id s23-20020a1709062ed700b007ae83f43bedls2016456eji.2.-pod-prod-gmail; Sun, 01 Jan 2023 09:57:50 -0800 (PST) X-Received: by 2002:a17:906:6dc3:b0:7c1:49c:f9cd with SMTP id j3-20020a1709066dc300b007c1049cf9cdmr33769166ejt.54.1672595870321; Sun, 01 Jan 2023 09:57:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672595870; cv=none; d=google.com; s=arc-20160816; b=bG148eStVbcyOYgQIjbj/axzivWhGRfXWMpyj7XVfV+1Z/8vn9NX4V7/4JfstuTm0H Q+xL0HL4eCqk1pY/8Xb/orV3Ge22kt2mlPtnW/hgToic+1tXCFTq9j1tUCYC5Y/Buslo eawFn0mU8AX10G+Rr2tposyFn6Izy/5mg0TnkPzeYRqbQrHQ9jx0RW975NzFxoS0PcO2 dLAlraMrBRHbSwlAYfd72Ek9zN/SXig7X7EIU1iOBBtx2tpfmqw8hVMyWZkpyjrGso1N ll3+rJdaJ7y3zsfFWZO4XwOSkzP1QqUO5X8LOZ8lLmMs6hgFSipGA0pX+JG6iye1MEK0 IrlQ== 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=ZYenpSMBggNdY4dx5nVECKefdf2t/s6x5XpiG20A4ps=; b=rhTTXXFYEOWhHk4vR0GbMesJu1vTh/P3jlVnEnb+mn+FXluJBzLjONeRrrvkZeLavq YQuOT/qIWnMOEXS97ACEx7rqZoTUeg1RUJ4afgHi9Fz+F/qjNm/Ff8fgNYSL7YH4VDKj xgs605KLAhZeURha0fmmKJE2BGNAHBv55HJ05+5yBCPqWx9Gf2sPLEur9w+aPE0xOpCp vR0i4HDmwlmBr5LiE4Zs9HxfD0Al0lSX9q7ZwO1d4XtjgR6Qj6c0vCvpqbpRo/cd8meF JWSUDiAexxhGcxDeQFtJ4/uGmxW5njzfu2yxwOeulwbuGzJiw46UtDZ4LxOKmCUhM3Hq xt9g== 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 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 g17-20020a17090670d100b007add1199db4sor11468478ejk.76.2023.01.01.09.57.50 for (Google Transport Security); Sun, 01 Jan 2023 09:57:50 -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: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-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=X8CpvA46; 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 --- (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);