From patchwork Sun Jan 1 17:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2600 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 92C293F9E8 for ; Sun, 1 Jan 2023 18:57:58 +0100 (CET) Received: by mail-ed1-f71.google.com with SMTP id v8-20020a056402348800b0048db0688c80sf693909edc.15 for ; Sun, 01 Jan 2023 09:57:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672595878; cv=pass; d=google.com; s=arc-20160816; b=QiB5UiBWiiKr+QgbCMuIbslJMsgQcKR+JPWC61vvkAFCfd0PEYz4I6uV5zulPiKlZZ 8NoK/67yQxrv9BE4ukgBk81nmcSEH8axAmgpoUHMG6hwmZorPVfZIE1xbGtKUU9JChVx SPHCxAf+LKBz7R2uSE4EM0T2dtqBOLRy/AdJxun5zhi97r8FpJvmQkwnSUGogI3COyyO vIWNzdoGdaEu06nfsmOISKBgY3oVOn9jaEDKK2lqGdEpE4YF29wA+wc4Y1oZ6qjdh0bJ riHUXkxCpNiaHdXEe6ee3GrP0HiCVJiEHfJlKRrb287kfTTk4dUqVGg/nHOABErG1OUe e0SQ== 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=yT/MCflEHp3/bBInFlxBI+3hfq/HuWsCCH4hQcRWL0k=; b=b5vDXqdDTEDWVwz0kBRi6kef1mTfX4h8rr2OyOYkmwm1yERTKSDnWAv/4BhGDuP91y nywY3WvxiipVoIB6pKRWTC2YtgkxOMn0+Ce0GgOTRO2SDsbsgbGt63b++Fxg61XzA1EI eooFvVZdOj3IZfp2iUFtNmsgswZ0fU/CBmZqSHfoADIYFmsMHWbPoGCJPs8C22VQG5QL 8tOM+gMV/0ict6V1dUJk1xJEs1Pp2cB05Un4iverG6ZnKnMrNblGoVozVLJV/jSuM09+ D31BSmKeBAKdDBeZt8PHSpodyoa7V8s9wESq7r8wq9d6/Z1zk8iZ1N6L6Fn4aSHYC88C u/pg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OYKuiBkO; 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=yT/MCflEHp3/bBInFlxBI+3hfq/HuWsCCH4hQcRWL0k=; b=PTpanSa7nmZCfN4qtq0LKn1+C6pMsZc1hvRO2XARnWwiuGw3BkmuJS8Vd1kczf+Xxf O/09QDbtehSIxcVsOoz3jqYt9+cEobs2h96yL5SKirU56RRPH7FWOmFqQjnNg0XA5jO5 thUZ/ztBLu7sN8jMQ4r2NDw6YAQ7e71NaB0jU= 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=yT/MCflEHp3/bBInFlxBI+3hfq/HuWsCCH4hQcRWL0k=; b=0yC+iPRdwM7Si/ID1J7i2qxm/iiW7Xkqa/Hj6edIN00zhT4zee4nOiwo8EHl+1ET/h kiHskE0CzuskpAlGY3AvMrRX8mKuGyirKpZjeg5XstNPAmScjSX7LKru0unmMLw/Ic/8 wGgv4q+Z8v9q/t9tcUUIgm5BYCF60Yu7tM4Jd9BaN2Wb/74OIM/01+oeLIEC28dhaPKb 9NW5HgtmtFp3WUrrPDdaFw5ZRQraTKhCqhDW21MUZG2VnJSkIMW9qDQLJpMm38PcUMED grpyjWZ8WFvY9a9Ldxw6pLgvdEcWqbF3yrdBsvhrM3V+HNZT3LaQKunxHUbfHAvr/j6Z 9qnA== X-Gm-Message-State: AFqh2kpD73Fn/mRQ6go3m4pOY2lL6X6/PsuXcpwpSliKNrwqPTktgWHN M9DetlXTN3ItKXBUTjKZD4wX3Xhu X-Google-Smtp-Source: AMrXdXusJu5YEILHuANF0SYTDBIdJCA+TB6n17pa886gz+OsnM1w/Y18Sud98K+Zxboi8/oAoAMGtg== X-Received: by 2002:a05:6402:c18:b0:483:c100:a40a with SMTP id co24-20020a0564020c1800b00483c100a40amr2003406edb.370.1672595878190; Sun, 01 Jan 2023 09:57:58 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:6010:b0:7ad:9566:98a with SMTP id o16-20020a170906601000b007ad9566098als2016343ejj.7.-pod-prod-gmail; Sun, 01 Jan 2023 09:57:57 -0800 (PST) X-Received: by 2002:a17:906:264c:b0:7c1:1b1c:5ecb with SMTP id i12-20020a170906264c00b007c11b1c5ecbmr32168560ejc.7.1672595877045; Sun, 01 Jan 2023 09:57:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672595877; cv=none; d=google.com; s=arc-20160816; b=sapwDsRTuVJbBFAUSm8b59mJsiFIAF4kkKoH04qXSqxiEDNH4m/OZXH3V9oJaBA7Xk AkB1eF48A426wYw1ZzVwPtd1w2qfBEbb2FDvQXCt4Aqs5e3fYYeUnxffgeGQULBDJFRa bZByHBP7678HZ+Hh5urE82BySrCQDeVp9T2P6AtvPiWu8n6+svuoyoohJF33yP8c3oA6 22rzMPE2+Jk35s5j+znLp8hltbp24RE4RvRgLN5nRPqk4WMw+JPi+hio3Z1YbCPCBG/C GLMWQrwYVVmBW1+LH4zWMgzL1KeS+PLqLhR3+jwjceWdhblUfwS7ezpC1/PGmixi7mfP o4Zw== 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=S9smT0T74p/RoQNiIeBlvZXMl6kYsCsXSfs8qRvMbs0=; b=jVeR4w6lhr3ZeGGuNidwqqve52JMTYHxfkFc0gxUIE+XeqDZW5F3G66IJPtMFGuaQE B+wcba8yOLk1MVbIARBEm8BlPpsXj4iuou+8m0le1RgBiISk0jaZiWg0fxCywnOBkWC3 qfGs/Fn1wZACJYQL4n/TeRB+VZb53FLZW4Y4JcfCHKIYUvmZZtLKf94O+J6yMDr//kyb qJ3Uh+dtfnHy7cHr3JNQGGAfUDOPa/ZmwPkJ8LpH5vkIa6oTI0Ysz32GlI4nxk/iob3S DrtKGAkUAr+V33Ci/BJ7uGi4PnnS8mXnMxIUS61SKJ5yl+B902GO5DvJAw+WTBthBITf MMVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OYKuiBkO; 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 h25-20020a170906829900b007bfd6014f23sor11900238ejx.72.2023.01.01.09.57.57 for (Google Transport Security); Sun, 01 Jan 2023 09:57:57 -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:910:b0:7c0:f71b:8b3 with SMTP id i16-20020a170906091000b007c0f71b08b3mr32097158ejd.57.1672595876863; Sun, 01 Jan 2023 09:57:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jan 2023 09:57:56 -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 , kernel test robot , 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 07/11] clk: imx: composite-8m: add device tree support Date: Sun, 1 Jan 2023 18:57:36 +0100 Message-Id: <20230101175740.1010258-8-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=OYKuiBkO; 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: , The patch, backwards compatible, extends the driver to initialize the clock directly from the device tree. Signed-off-by: Dario Binacchi Reported-by: kernel test robot --- Changes in v2: - Fix compiler warnings reported by kernel test robot. drivers/clk/imx/clk-composite-8m.c | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c index cbf0d7955a00..fa5fdfff0b2d 100644 --- a/drivers/clk/imx/clk-composite-8m.c +++ b/drivers/clk/imx/clk-composite-8m.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include "clk.h" @@ -25,6 +27,9 @@ #define PCG_CGC_SHIFT 28 +#undef pr_fmt +#define pr_fmt(fmt) "%s: " fmt, __func__ + static unsigned long imx8m_clk_composite_divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { @@ -250,3 +255,82 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, return ERR_CAST(hw); } EXPORT_SYMBOL_GPL(__imx8m_clk_hw_composite); + +static void __init _of_imx_composite_clk_setup(struct device_node *node, + u32 type) +{ + void __iomem *reg; + struct clk_hw *hw; + const char *name = node->name; + unsigned int num_parents; + const char **parent_names; + unsigned long flags = IMX_COMPOSITE_CLK_FLAGS_DEFAULT; + + reg = of_iomap(node, 0); + if (IS_ERR(reg)) { + pr_err("failed to get reg address for %pOFn\n", node); + return; + } + + num_parents = of_clk_get_parent_count(node); + if (num_parents < 2) { + pr_err("%pOFn must have parents\n", node); + return; + } + + parent_names = kzalloc((sizeof(char *) * num_parents), GFP_KERNEL); + if (!parent_names) + return; + + of_clk_parent_fill(node, parent_names, num_parents); + of_property_read_string(node, "clock-output-names", &name); + + if (of_property_read_bool(node, "fsl,get-rate-nocache")) + flags |= CLK_GET_RATE_NOCACHE; + + if (of_property_read_bool(node, "fsl,is-critical")) + flags |= CLK_IS_CRITICAL; + + hw = __imx8m_clk_hw_composite(name, parent_names, num_parents, reg, + type, flags); + if (!IS_ERR(hw)) + of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw); + + kfree(parent_names); +} + +/** + * of_imx_composite_clk_setup() - Setup function for imx composite clock + * @node: device node for the clock + */ +static void __init of_imx_composite_clk_setup(struct device_node *node) +{ + _of_imx_composite_clk_setup(node, IMX_COMPOSITE_CORE); +} +CLK_OF_DECLARE(fsl_composite_8m_clk, "fsl,imx8m-composite-clock", + of_imx_composite_clk_setup); + +/** + * of_imx_composite_bus_clk_setup() - Setup function for imx composite clock + * @node: device node for the clock + */ +static void __init of_imx_composite_bus_clk_setup(struct device_node *node) +{ + _of_imx_composite_clk_setup(node, IMX_COMPOSITE_BUS); +} +CLK_OF_DECLARE(fsl_composite_bus_8m_clk, "fsl,imx8m-composite-bus-clock", + of_imx_composite_bus_clk_setup); + +/** + * of_imx_composite_fw_managed_clk_setup() - Setup function for imx + * composite fw managed clock + * @node: device node for the clock + */ +static void __init +of_imx_composite_fw_managed_clk_setup(struct device_node *node) +{ + _of_imx_composite_clk_setup(node, IMX_COMPOSITE_FW_MANAGED); +} +CLK_OF_DECLARE(fsl_composite_fw_managed_8m_clk, + "fsl,imx8m-composite-fw-managed-clock", + of_imx_composite_fw_managed_clk_setup);