From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E46BC3DA6E for ; Sun, 17 Dec 2023 23:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:To:Cc:From:Subject:References: In-Reply-To:MIME-Version:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K6CfCcemY+/yyNr/gpzEe7wQjBV8YULuxu/J1C57HS8=; b=MS7oE9jztYiu0Q LbSOnSyaGRxNeJZ5d3lhcMf08+C4FFSfK20zaYUWDJ9iRHl1HzCnFtFG3MEcjrTgKSeI9BfxKm7xV aLSpejUMDITZk1KK/Rz263RPgfZ608/oCD/Jt1BVPzmbLTU8PF4WjLD1t5nwZTXmcXeoeWG0drr7p BmKVQ6p0VcU2okfqY6pkxuR8w7sDYMqh1hzDmDZim0JtdDtb1C9L2IWU9361gDxS006KfbkUyARUI huyIpRdAvkkrTbAs55snzK/TI1Kk7mFqPDxMOOW47UDPSm0jF+aDKO04TvQ/JAl6GDSTR1xwjEwbN zKRU2HVjp6YOUwdPP2zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rF0vr-008fGc-1X; Sun, 17 Dec 2023 23:52:27 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rF0vn-008fFw-2o for linux-arm-kernel@lists.infradead.org; Sun, 17 Dec 2023 23:52:26 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 071F3CE0B2A; Sun, 17 Dec 2023 23:52:21 +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: MIME-Version: 1.0 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231217_155224_279226_F0006BDC X-CRM114-Status: GOOD ( 21.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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-stm32mp25.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 STMicroelectronics. > + */ > + > +#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[] = { > + "ck_flexgen_46", "ck_icn_ls_mcu" Can we please migrate to struct clk_parent_data? > +}; > + > +static const char * const adc3_src[] = { > + "ck_flexgen_47", "ck_icn_ls_mcu", "ck_flexgen_46" > +}; > + > +static const char * const usb2phy1_src[] = { > + "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] = {\ Please move these slashes out and align them. > + .offset = (_offset),\ > + .bit_idx = (_bit_idx),\ > + .set_clr = (_offset_clr),\ > + } > + > +static const struct stm32_gate_cfg stm32mp25_gates[GATE_NB] = { > + 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 = { > + .gate_cpt = stm32mp25_cpt_gate, > + .gates = stm32mp25_gates, > + .muxes = stm32mp25_muxes, > +}; > + > +static struct clk_stm32_reset_data stm32mp25_reset_data = { > + .reset_lines = stm32mp25_reset_cfg, > + .nr_lines = ARRAY_SIZE(stm32mp25_reset_cfg), > +}; > + > +static struct stm32_rcc_match_data stm32mp25_data = { const > + .tab_clocks = stm32mp25_clock_cfg, > + .num_clocks = ARRAY_SIZE(stm32mp25_clock_cfg), > + .maxbinding = STM32MP25_LAST_CLK, > + .clock_data = &stm32mp25_clock_data, > + .reset_data = &stm32mp25_reset_data, > +}; > + > +static const struct of_device_id stm32mp25_match_data[] = { > + { > + .compatible = "st,stm32mp25-rcc", > + .data = &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 = 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 = -ENOMEM; > + goto out; > + } > + > + ret = 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[] = { > + "hsi", "hse", "msi", "lsi", "lse", > + }; > + size_t deps_size = sizeof(struct clk *) * ARRAY_SIZE(clock_deps_name); > + struct clk **clk_deps; > + int i; > + > + clk_deps = devm_kzalloc(dev, deps_size, GFP_KERNEL); > + if (!clk_deps) > + return -ENOMEM; > + > + for (i = 0; i < ARRAY_SIZE(clock_deps_name); i++) { > + struct clk *clk; > + > + clk = of_clk_get_by_name(dev_of_node(dev), clock_deps_name[i]); > + > + if (IS_ERR(clk)) { > + if (PTR_ERR(clk) != -EINVAL && PTR_ERR(clk) != -ENOENT) > + return PTR_ERR(clk); > + } else { > + /* Device gets a reference count on the clock */ > + clk_deps[i] = 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 = &pdev->dev; > + int ret = get_clock_deps(dev); > + > + if (!ret) > + ret = stm32mp25_rcc_init(dev); > + > + return ret; > +} > + _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel