Received: by 2002:a05:7412:a9a8:b0:f9:92ae:e617 with SMTP id o40csp12465rdh; Wed, 20 Dec 2023 14:17:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7K7okRsrhWUQ7dGEPQHaZjEEPEp+kh5e/C6ng8Nc1Ywul8r73ImO4bVwCRN4p9k1v/yv+ X-Received: by 2002:a05:6e02:1a4e:b0:35f:c9d7:ba35 with SMTP id u14-20020a056e021a4e00b0035fc9d7ba35mr1982761ilv.32.1703110623378; Wed, 20 Dec 2023 14:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703110623; cv=none; d=google.com; s=arc-20160816; b=0meig6VrmVh/OS/iwzyRh4XZRVnr+37sn2LI750yMZGUgfDCjCm9Fz7b+YdF/05kp9 dhREnnyYfAhcxjEuHxXZXIdXTaoNRBbzL73NPfPdOJ7JyuFY52FoJUxhP5hy4ViG2LwC hrNSWJA58mzg/fmf2FcDJ0Q/g/pE0DzY1DaF20MO45z4eyYlqK755qJqoqZ8MvsCGtgC TcGJXdWdwv8lSE/tPlcWE3ilrws1A+Dck0drhS8JwiRkvt5KTztkMNhgSlptRmqfUWlc RMFccWAXScugPN08ht0tuQndIfYx6yySPjpQ5VpC0M9j68rYJXfdxyPqr+OtG/2yhe8z BM+Q== 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=j3adf1rPAOMHHW81RtT/w3XP7QYSaP+7Z5by9LXjbk8=; fh=Gl/Yif5rfF4EJMt8k1/6hCXyE2db+CELxkQ+WPGsafo=; b=LMRBoVcNYGNcu6i+qK1x6+OnyxoKFWQJg4+JBnvDWVRXTzEUDEV39/hs6Jdcu/jDuw k9cbs5CWGDcYXvkKyNMt21jOH9wRQ6NhP6Pk9zFomV0cQ5FaIwL8qpukRFyRBZHUYbrp YbAtQ4vmuj3InFOg3byKi9GdSTFVBN3lv+99Ty2DMCjFY5QiKd8Nx0vyJYNxglTI1KJt TKcjGamUPAWEMIkgzbjhcofqGqkQmWC6AlrBQ3qPM/lQ0JRXOoSDJ0xbwu4sJDGh5gfc EFN/QNo8MCuvo+VqeE6MT9kU2jVkpabIsanseCN1Lrn+pny4/goOpWmnJb3m5DrM89/N Fq6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="s/b1Ax84"; spf=pass (google.com: domain of linux-kernel+bounces-7498-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7498-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b18-20020a639312000000b005bddb7249e0si413033pge.313.2023.12.20.14.17.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:17:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7498-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="s/b1Ax84"; spf=pass (google.com: domain of linux-kernel+bounces-7498-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7498-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2E955B21CBA for ; Wed, 20 Dec 2023 22:16:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AAEB4A98E; Wed, 20 Dec 2023 22:16:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s/b1Ax84" 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 C389649F7F; Wed, 20 Dec 2023 22:16:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A132C433C8; Wed, 20 Dec 2023 22:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703110609; bh=EYuAHLFAu52JNqdpI9RE6CjobCj8plhFfDlK2x+vg4g=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=s/b1Ax841wkTMn/VP+5NRp8THggUZTYTKKns1K2yPYtcF8+nZ154CP8JzyCW0rbwE qTiFBMa1gjuru+k4XPM/5Qb1Zwwx44HHWTpO2I+mG6lBY7uvx0U3nMVlhuaIIPJXSm aF5Zyj5xgOpJUK+lEIl10FBFsA0N++OyUpakjkYltY2ih5wjPBpR4vHhuXN0HBc2gg NMK/NFN5l+gy5zOSbJl4yb7bY3L/k5viKx4NToRSxuXk5wWJfCjlUbCOt0xJMDj5lI uOf5Olc5gcU5pIE4PpmVoFDg7GelklhmU9diq/hp1CA5NSgOdjkuKW8s4xeUteAe/E XQE9p9Fo/1XTw== 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: <20231219130909.265091-2-gabriel.fernandez@foss.st.com> References: <20231219130909.265091-1-gabriel.fernandez@foss.st.com> <20231219130909.265091-2-gabriel.fernandez@foss.st.com> Subject: Re: [PATCH v7 1/2] 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: Wed, 20 Dec 2023 14:16:46 -0800 User-Agent: alot/0.10 Quoting gabriel.fernandez@foss.st.com (2023-12-19 05:09:08) > diff --git a/drivers/clk/stm32/clk-stm32mp25.c b/drivers/clk/stm32/clk-st= m32mp25.c > new file mode 100644 > index 000000000000..313e022c6142 > --- /dev/null > +++ b/drivers/clk/stm32/clk-stm32mp25.c > @@ -0,0 +1,1826 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) STMicroelectronics 2023 - All Rights Reserved > + * Author: Gabriel Fernandez for STMicro= electronics. > + */ > + > +#include > +#include > +#include > + > +#include "clk-stm32-core.h" > +#include "reset-stm32.h" > +#include "stm32mp25_rcc.h" > + > +#include > +#include > + > +static const struct clk_parent_data adc12_src[] =3D { > + { .name =3D "ck_flexgen_46" }, This is a new driver. Don't use .name here. Instead use .index or .hw and if that can't work then use .fw_name. > + { .name =3D "ck_icn_ls_mcu" }, > +}; > + > +static const struct clk_parent_data adc3_src[] =3D { > + { .name =3D "ck_flexgen_47" }, > + { .name =3D "ck_icn_ls_mcu" }, > + { .name =3D "ck_flexgen_46" }, > +}; [...] > +static struct clk_stm32_composite ck_ker_usb3pciephy =3D { > + .gate_id =3D GATE_USB3PCIEPHY, > + .mux_id =3D MUX_USB3PCIEPHY, > + .div_id =3D NO_STM32_DIV, > + .hw.init =3D CLK_HW_INIT_PARENTS_DATA("ck_ker_usb3pciephy", usb3p= ciphy_src, > + &clk_stm32_composite_ops, 0), > +}; > + > +/* USB3 DRD */ > +static struct clk_stm32_gate ck_icn_m_usb3dr =3D { > + .gate_id =3D GATE_USB3DR, > + .hw.init =3D CLK_HW_INIT("ck_icn_m_usb3dr", "ck_icn_hsl", &clk_st= m32_gate_ops, 0), > +}; > + > +static struct clk_stm32_gate ck_ker_usb2phy2 =3D { > + .gate_id =3D GATE_USB3DR, > + .hw.init =3D CLK_HW_INIT("ck_ker_usb2phy2", "ck_flexgen_58", &clk= _stm32_gate_ops, 0), > +}; > + > +/* USBTC */ > +static struct clk_stm32_gate ck_icn_p_usbtc =3D { > + .gate_id =3D GATE_USBTC, > + .hw.init =3D CLK_HW_INIT("ck_icn_p_usbtc", "ck_icn_apb4", &clk_st= m32_gate_ops, 0), Please stop using strings to match parents, i.e. don't use CLK_HW_INIT. > +}; > + > +static struct clk_stm32_gate ck_ker_usbtc =3D { > + .gate_id =3D GATE_USBTC, > + .hw.init =3D CLK_HW_INIT("ck_ker_usbtc", "ck_flexgen_35", &clk_st= m32_gate_ops, 0), > +}; > + > +/* VDEC / VENC */ > +static struct clk_stm32_gate ck_icn_p_vdec =3D { > + .gate_id =3D GATE_VDEC, > + .hw.init =3D CLK_HW_INIT("ck_icn_p_vdec", "ck_icn_apb4", &clk_stm= 32_gate_ops, 0), > +}; > + > +static struct clk_stm32_gate ck_icn_p_venc =3D { > + .gate_id =3D GATE_VENC, > + .hw.init =3D CLK_HW_INIT("ck_icn_p_venc", "ck_icn_apb4", &clk_stm= 32_gate_ops, 0), > +}; > + > +/* VREF */ > +static struct clk_stm32_gate ck_icn_p_vref =3D { > + .gate_id =3D GATE_VREF, > + .hw.init =3D CLK_HW_INIT("ck_icn_p_vref", "ck_icn_apb3", &clk_stm= 32_gate_ops, 0), > +}; > + > +/* WWDG */ > +static struct clk_stm32_gate ck_icn_p_wwdg1 =3D { > + .gate_id =3D GATE_WWDG1, > + .hw.init =3D CLK_HW_INIT("ck_icn_p_wwdg1", "ck_icn_apb3", &clk_st= m32_gate_ops, 0), > +}; > + > +static struct clk_stm32_gate ck_icn_p_wwdg2 =3D { > + .gate_id =3D GATE_WWDG2, > + .hw.init =3D CLK_HW_INIT("ck_icn_p_wwdg2", "ck_icn_ls_mcu", &clk_= stm32_gate_ops, 0), > +}; > + > +enum security_clk { > + SECF_NONE, What is the use of this single value enum? > +}; > + > +static const struct clock_config stm32mp25_clock_cfg[] =3D { > + STM32_GATE_CFG(CK_BUS_ETH1, ck_icn_p_eth1, S= ECF_NONE), > + STM32_GATE_CFG(CK_BUS_ETH2, ck_icn_p_eth2, S= ECF_NONE), [....] > + > +static const struct of_device_id stm32mp25_match_data[] =3D { > + { > + .compatible =3D "st,stm32mp25-rcc", > + .data =3D &stm32mp25_data, > + }, One line please: { .compatible =3D "st,stm32mp25-rcc", .data =3D &stm32mp25_data, }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, stm32mp25_match_data); > + > +static int get_clock_deps(struct device *dev) What is the explanation for this function? > +{ > + static const char * const clock_deps_name[] =3D { > + "hsi", "hse", "msi", "lsi", "lse", > + }; > + int i; > + > + 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)) > + return PTR_ERR(clk); > + > + clk_put(clk); > + } > + > + return 0; > +} > + > +static int stm32mp25_rcc_clocks_probe(struct platform_device *pdev) > +{ > + struct device *dev =3D &pdev->dev; > + void __iomem *base; > + int ret; > + > + ret =3D get_clock_deps(dev); > + if (ret) > + return ret; > + > + base =3D devm_of_iomap(dev, dev->of_node, 0, NULL); Use platform device APIs. > + if (WARN_ON(IS_ERR(base))) > + return PTR_ERR(base); > + > + return stm32_rcc_init(dev, stm32mp25_match_data, base); > +} > + > +static int stm32mp25_rcc_clocks_remove(struct platform_device *pdev) > +{ > + struct device *dev =3D &pdev->dev; > + struct device_node *child, *np =3D dev_of_node(dev); > + > + for_each_available_child_of_node(np, child) > + of_clk_del_provider(child); Add the providers with devm? > + > + return 0; > +} > + > +static struct platform_driver stm32mp25_rcc_clocks_driver =3D { > + .driver =3D { > + .name =3D "stm32mp25_rcc", > + .of_match_table =3D stm32mp25_match_data, > + }, > + .probe =3D stm32mp25_rcc_clocks_probe, > + .remove =3D stm32mp25_rcc_clocks_remove, > +}; > + > +static int __init stm32mp25_clocks_init(void) > +{ > + return platform_driver_register(&stm32mp25_rcc_clocks_driver); > +} > + > +core_initcall(stm32mp25_clocks_init);