Received: by 2002:a05:7412:361b:b0:f9:2edb:3e4d with SMTP id ie27csp83575rdb; Sun, 17 Dec 2023 15:52:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOoqpb7qYSYxkFXB7got2eVNUIaL4wGkiF3kwoRO/WishsgeC94ivnGgZKMOhoKaEh5mWk X-Received: by 2002:a05:6870:15ca:b0:203:97c6:ab7c with SMTP id k10-20020a05687015ca00b0020397c6ab7cmr3225225oad.16.1702857148960; Sun, 17 Dec 2023 15:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702857148; cv=none; d=google.com; s=arc-20160816; b=o5x/aTufGkZMWe1QsQJ4KkRsSXnG+kWyUBqaIWdTxGAdNjwpaEDKpJeURjV12raj6F GnMiGmNOlwzSe/FQUDswAT38w1lhm/6g8e/TD7BgaJR28ysMamELrI7OlXrX8pcHX13k 8tWq0VTKfeGe1EQwa190WEyb/TYmt9JfW5JHlg2BUIOQ61T8NYxTmD8s7VHxKSNcHeTa YH7nvlX4IrxmcL1wPlJoOaTfVTpjqhYznI+7EqiZhIpXPa4az3WPyTJ6uYJM0e4noJmB kl837jvW0T57sCOzYU4wcI6GfoHRVgGuHHH72uv1s/scGWSMw8nycEoUkuaIyLY/+Gea Bv5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:date:to:cc:from:subject:references:in-reply-to :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:dkim-signature; bh=Wf/uIaqQ7cMmjvyJ6DePSxEoZgUMQ6GZxn3JZpODDC8=; fh=Gl/Yif5rfF4EJMt8k1/6hCXyE2db+CELxkQ+WPGsafo=; b=efAy6ETB9d3mqneJ3KgHgyexPAfVlvL4e8eQGEUocggURQ1Zo0HoDDzw33V4erA0JK s/aLRjjASJnNAEkW3qcbYdtjLK2ssaamuCw46svQVEhVa0yrafW5j9K71f7s0D03C/U9 wPoQuVa7ctmp3slr+eQcncjwodMb246cHY21VlqDUtB98r8Revf/YzMv5FMyPWHday4L senWkN8BOFnfwwkQRQ97NS9WhO0UAHhfV/VwmCe4phtp63bfwULfqBcX37JyG+rxR4uW K2rzeZ6VCZmKpCEf3uzxlKamwU/zwGF28S3JVBtlWYVyZzcEOF4hfSwIEOg05HlqbmtQ O3fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Lcjc/JkG"; spf=pass (google.com: domain of linux-kernel+bounces-2873-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2873-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n22-20020a635916000000b005c662419214si5394342pgb.229.2023.12.17.15.52.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 15:52:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2873-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Lcjc/JkG"; spf=pass (google.com: domain of linux-kernel+bounces-2873-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2873-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 900582822A7 for ; Sun, 17 Dec 2023 23:52:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0CCF4B123; Sun, 17 Dec 2023 23:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Lcjc/JkG" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8ED44B124; Sun, 17 Dec 2023 23:52:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F3E9C433C8; Sun, 17 Dec 2023 23:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702857140; bh=6ao4QwwxsmhGEWfg70Ew5Z3bfAgkkiWmUHeBKXMWP5A=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=Lcjc/JkGziIa2RuVNBajY3AdoGjPMQzGHrloj/z82rGm5VgIW2UQ26gGUe7/6l8zP hx/rGKwEQ08lUDQNm1ogKrdw5xNJkdsp0MnsqSSfGMH7X/eHqCt0rlpGP7M2jPInIe sa4WwNTbybCwMo+98RfVWEeSYoo5FKXqncxHVP+VNcd4kMykiLgpI9YKWsspjGb05b RHBNIhwV1umhWMt8BYvgbKr017ldpwB5jYtwWq8u4951MYML8J0TXJWWXkKVdyg4XY Z/Pkkoc7slZiPaI8DfvaHReY0ryORFLPPQQ2MktBKxh5xjX0MuqvE3Rv+4L7E0343I CaYdFKJ2OKoeQ== Message-ID: Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20231208143700.354785-5-gabriel.fernandez@foss.st.com> References: <20231208143700.354785-1-gabriel.fernandez@foss.st.com> <20231208143700.354785-5-gabriel.fernandez@foss.st.com> Subject: Re: [PATCH v6 4/5] clk: stm32: introduce clocks for STM32MP257 platform From: Stephen Boyd Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org To: Alexandre Torgue , Conor Dooley , Gabriel Fernandez , Krzysztof Kozlowski , Maxime Coquelin , Michael Turquette , Philipp Zabel , Rob Herring Date: Sun, 17 Dec 2023 15:52:17 -0800 User-Agent: alot/0.10 Quoting gabriel.fernandez@foss.st.com (2023-12-08 06:36:59) > diff --git a/drivers/clk/stm32/clk-stm32mp25.c b/drivers/clk/stm32/clk-st= m32mp25.c > new file mode 100644 > index 000000000000..36321fd6142e > --- /dev/null > +++ b/drivers/clk/stm32/clk-stm32mp25.c > @@ -0,0 +1,1125 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) STMicroelectronics 2023 - All Rights Reserved > + * Author: Gabriel Fernandez for STMicro= electronics. > + */ > + > +#include > +#include > +#include Is this include used? > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Is this include used? > + > +#include "clk-stm32-core.h" > +#include "reset-stm32.h" > + > +#include > +#include > + > +#include "stm32mp25_rcc.h" > + > +static const char * const adc12_src[] =3D { > + "ck_flexgen_46", "ck_icn_ls_mcu" Can we please migrate to struct clk_parent_data? > +}; > + > +static const char * const adc3_src[] =3D { > + "ck_flexgen_47", "ck_icn_ls_mcu", "ck_flexgen_46" > +}; > + > +static const char * const usb2phy1_src[] =3D { > + "ck_flexgen_57", "hse_div2_ck" > +}; [...] > + GATE_TIM4, > + GATE_TIM5, > + GATE_TIM6, > + GATE_TIM7, > + GATE_TIM8, > + GATE_UART4, > + GATE_UART5, > + GATE_UART7, > + GATE_UART8, > + GATE_UART9, > + GATE_USART1, > + GATE_USART2, > + GATE_USART3, > + GATE_USART6, > + GATE_USB2, > + GATE_USB2PHY1, > + GATE_USB2PHY2, > + GATE_USB3DR, > + GATE_USB3PCIEPHY, > + GATE_USBTC, > + GATE_VDEC, > + GATE_VENC, > + GATE_VREF, > + GATE_WWDG1, > + GATE_WWDG2, > + GATE_NB > +}; > + > +#define GATE_CFG(id, _offset, _bit_idx, _offset_clr)\ > + [id] =3D {\ Please move these slashes out and align them. > + .offset =3D (_offset),\ > + .bit_idx =3D (_bit_idx),\ > + .set_clr =3D (_offset_clr),\ > + } > + > +static const struct stm32_gate_cfg stm32mp25_gates[GATE_NB] =3D { > + GATE_CFG(GATE_ADC12, RCC_ADC12CFGR, 1, 0= ), > + GATE_CFG(GATE_ADC3, RCC_ADC3CFGR, 1, 0= ), > + GATE_CFG(GATE_ADF1, RCC_ADF1CFGR, 1, 0= ), > + GATE_CFG(GATE_CCI, RCC_CCICFGR, 1, 0= ), > + GATE_CFG(GATE_CRC, RCC_CRCCFGR, 1, 0= ), > + GATE_CFG(GATE_CRYP1, RCC_CRYP1CFGR, 1, 0= ), [....] > + > +static struct clk_stm32_clock_data stm32mp25_clock_data =3D { > + .gate_cpt =3D stm32mp25_cpt_gate, > + .gates =3D stm32mp25_gates, > + .muxes =3D stm32mp25_muxes, > +}; > + > +static struct clk_stm32_reset_data stm32mp25_reset_data =3D { > + .reset_lines =3D stm32mp25_reset_cfg, > + .nr_lines =3D ARRAY_SIZE(stm32mp25_reset_cfg), > +}; > + > +static struct stm32_rcc_match_data stm32mp25_data =3D { const > + .tab_clocks =3D stm32mp25_clock_cfg, > + .num_clocks =3D ARRAY_SIZE(stm32mp25_clock_cfg), > + .maxbinding =3D STM32MP25_LAST_CLK, > + .clock_data =3D &stm32mp25_clock_data, > + .reset_data =3D &stm32mp25_reset_data, > +}; > + > +static const struct of_device_id stm32mp25_match_data[] =3D { > + { > + .compatible =3D "st,stm32mp25-rcc", > + .data =3D &stm32mp25_data, > + }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, stm32mp25_match_data); > + > +static int stm32mp25_rcc_init(struct device *dev) Please inline this function in the one call site. > +{ > + void __iomem *base; > + int ret; > + > + base =3D of_iomap(dev_of_node(dev), 0); Use platform device APIs instead of OF specific ones. > + if (!base) { > + dev_err(dev, "%pOFn: unable to map resource", dev_of_node= (dev)); Missing newline. > + ret =3D -ENOMEM; > + goto out; > + } > + > + ret =3D stm32_rcc_init(dev, stm32mp25_match_data, base); > + > +out: > + if (ret) { > + if (base) > + iounmap(base); > + > + of_node_put(dev_of_node(dev)); When did we get the node? > + } > + > + return ret; > +} > + > +static int get_clock_deps(struct device *dev) > +{ > + static const char * const clock_deps_name[] =3D { > + "hsi", "hse", "msi", "lsi", "lse", > + }; > + size_t deps_size =3D sizeof(struct clk *) * ARRAY_SIZE(clock_deps= _name); > + struct clk **clk_deps; > + int i; > + > + clk_deps =3D devm_kzalloc(dev, deps_size, GFP_KERNEL); > + if (!clk_deps) > + return -ENOMEM; > + > + for (i =3D 0; i < ARRAY_SIZE(clock_deps_name); i++) { > + struct clk *clk; > + > + clk =3D of_clk_get_by_name(dev_of_node(dev), clock_deps_n= ame[i]); > + > + if (IS_ERR(clk)) { > + if (PTR_ERR(clk) !=3D -EINVAL && PTR_ERR(clk) != =3D -ENOENT) > + return PTR_ERR(clk); > + } else { > + /* Device gets a reference count on the clock */ > + clk_deps[i] =3D devm_clk_get(dev, __clk_get_name(= clk)); Is something using this clk_deps array? > + clk_put(clk); > + } > + } > + > + return 0; > +} > + > +static int stm32mp25_rcc_clocks_probe(struct platform_device *pdev) > +{ > + struct device *dev =3D &pdev->dev; > + int ret =3D get_clock_deps(dev); > + > + if (!ret) > + ret =3D stm32mp25_rcc_init(dev); > + > + return ret; > +} > +