Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp238301lqg; Thu, 11 Apr 2024 00:49:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyUHYYJa8Qb5fFQ/13kEWdKiJKSh7+GhqzRBsu9PZY4fZN228qTKlo0MyGMdzZNyyr3rnvZU9lHytBGsdMiOkp39ggP4Vmgt1zYcVWdw== X-Google-Smtp-Source: AGHT+IE67ViPe3aKDVb5xTjKz1JQR9gohJLLP76L863UiYbh8UteZzJHfT08Ua8YDYaNMix1remm X-Received: by 2002:a17:906:c103:b0:a52:2441:99c with SMTP id do3-20020a170906c10300b00a522441099cmr522592ejc.69.1712821776758; Thu, 11 Apr 2024 00:49:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712821776; cv=pass; d=google.com; s=arc-20160816; b=CfQTss4AS55MoWLEZy4LV/IEH9WxQfEkAj6Ab44wFpkZNLl9vNeFwV/tr4wtfXDKSH IBo9/PZWt5NSQMyLC0Xk0aWfVVVS4Cn3QTx2k2zAH9zp4Ce2Uby/tXYUtGAQZjbmWbbI qQjcaVlJkeN+RGpfg2cp7MaRTCg0oKRofR1M8oIMQYMArwN/A/aWLdP0pOpJVppsrLmr 0dA7yihw/sd3+v10vX57qQ+tE+YOEsp3+M1fds2RrRL3BdYoKOeB6l9DzNjfeVEXAR1C Hcl47m0BIyN0/9daYGhvhAWZ/vxydvEAL6Qab3MoICmAZpmsp/RS4kWbwz8oY1f3+9wF I+Vw== ARC-Message-Signature: i=2; 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=ySCDt/AM54ZbkFcmh4dtDT8XHkTuS46fFJQT3Yk8fF8=; fh=hkkUNMAjFLqHsf2lDkFEh9UizNO3MCsiC9aL7IefZQg=; b=Q/3TphYh65TTlDXsRyXtsWwXItTuBoXFmRmzD3pvZtxf7ybblTZJ9HNyDdPwzPcP5p tXEXuCXlS0Yz3BpbUk+j3kb9LZCiXOTPIjGy/rJRoeqCez5sb9rLxkpLwj+yUU5nDMc6 89AKGbBelsUCLKtZvRdfRkB+iRDJvvIy3rnkkZQBaxesjgA4ksoxlA/5vpcTH/qeCye9 VspDobu+E8FwjDlsqRgkXVUsmhKBJdRpMOudHGU1PIn+rhXIDLZIGaZyoaE2aWjNpg18 uASPnwCIN3uL22Hf5xazGOrfuCZKpuHGM3/cyz4OwFUf5aUgQ3pNcyi2665xb+QuD84L br5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=crdVATW2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-140022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e12-20020a170906044c00b00a4e6492c883si473532eja.300.2024.04.11.00.49.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 00:49:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=crdVATW2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-140022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140022-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 791361F23EE8 for ; Thu, 11 Apr 2024 07:49:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BE9113E884; Thu, 11 Apr 2024 07:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="crdVATW2" 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 C085513C824; Thu, 11 Apr 2024 07:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712821767; cv=none; b=OZb/vchSvyBsXKm3SYYwpkm5CMt68CQDzw15XT5KIWJcfoAr3Br5KzIqhx3EJW4CV2h/qCaRHWL7XNFK0guGmVcHnv+Zk4nxV1ICjVvEjiRO4/dheEWE31bwfNTiurxl0FUaW+4Y6bvVoU9ape/ELIRxf4gJWg0BGAOkNyTvsDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712821767; c=relaxed/simple; bh=GQQD6YHCcBkicBSPTMO2OoklUsO8Qz/uM9luYCPMi30=; h=Message-ID:Content-Type:MIME-Version:In-Reply-To:References: Subject:From:Cc:To:Date; b=Ayc4slkldwOoTkCycVEmMG3321YOCp6XAf7yODcPBCBNiRBisGNAqj1o0aAiaMfe7EH80esqwkUKJYzljZ//4IvqTNUqA4WtDHKfhaqmgNptiDr0LBQUj7RpDTnWD2zhtt+UzFbumFgwnV9fMm8cAlTsW7sc9cyYI0Qdabb2GyI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=crdVATW2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30FA2C433F1; Thu, 11 Apr 2024 07:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712821767; bh=GQQD6YHCcBkicBSPTMO2OoklUsO8Qz/uM9luYCPMi30=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=crdVATW2FLVb3crXNiLBHqFn6ynsHqIcCfM5bLTeAs5VDh9JY3eMei8amlkl5tVKg KES6kIL4Nwmjyjybv5PKIyspbnq+7a96u7fm66OoqzqrsQkyuTQN0O1W5nRgiVzQSw UmWvDHagKpqtXszJ/ezQrDVD7m2jOogiY3vsGAzDZLnaF2pQcq7sxhOhQK/G4bHWWu Kui7KQaf1dY6ThAosg5QR005yovEguC3NhlZO/Ed6HpmFQUcAH0c2zku7BC2f8OdCf ccCr0G79iv3SXv3wtIlpUHus7wwW7R/VN3JmNhf8cVGRwivsYVjnbSLJuwle6WToGZ OPUboYjEB4J/Q== Message-ID: <44131080f148a472ed5dee901a66ffa7.sboyd@kernel.org> 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: <20240110133128.286657-9-jeeheng.sia@starfivetech.com> References: <20240110133128.286657-1-jeeheng.sia@starfivetech.com> <20240110133128.286657-9-jeeheng.sia@starfivetech.com> Subject: Re: [RFC v3 08/16] clk: starfive: Add JH8100 North-West clock generator driver From: Stephen Boyd Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, jeeheng.sia@starfivetech.com, leyfoon.tan@starfivetech.com To: Sia Jee Heng , aou@eecs.berkeley.edu, conor@kernel.org, emil.renner.berthing@canonical.com, hal.feng@starfivetech.com, kernel@esmil.dk, krzysztof.kozlowski+dt@linaro.org, mturquette@baylibre.com, p.zabel@pengutronix.de, palmer@dabbelt.com, paul.walmsley@sifive.com, robh+dt@kernel.org, xingyu.wu@starfivetech.com Date: Thu, 11 Apr 2024 00:49:25 -0700 User-Agent: alot/0.10 Quoting Sia Jee Heng (2024-01-10 05:31:20) > diff --git a/drivers/clk/starfive/clk-starfive-jh8100-nw.c b/drivers/clk/= starfive/clk-starfive-jh8100-nw.c > new file mode 100644 > index 000000000000..018f5af6c777 > --- /dev/null > +++ b/drivers/clk/starfive/clk-starfive-jh8100-nw.c > @@ -0,0 +1,237 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * StarFive JH8100 North-West Clock Driver > + * > + * Copyright (C) 2023 StarFive Technology Co., Ltd. [...] > + > +static int jh8100_nwcrg_probe(struct platform_device *pdev) > +{ > + struct starfive_clk_priv *priv; > + unsigned int idx; > + int ret; > + > + priv =3D devm_kzalloc(&pdev->dev, > + struct_size(priv, reg, JH8100_NWCLK_NUM_CLKS), > + GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + spin_lock_init(&priv->rmw_lock); > + priv->dev =3D &pdev->dev; > + priv->base =3D devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(priv->base)) > + return PTR_ERR(priv->base); > + > + for (idx =3D 0; idx < JH8100_NWCLK_NUM_CLKS; idx++) { > + u32 max =3D jh8100_nwcrg_clk_data[idx].max; > + struct clk_parent_data parents[4] =3D {}; > + struct clk_init_data init =3D { > + .name =3D jh8100_nwcrg_clk_data[idx].name, > + .ops =3D starfive_clk_ops(max), > + .parent_data =3D parents, > + .num_parents =3D > + ((max & STARFIVE_CLK_MUX_MASK) >> STARFIV= E_CLK_MUX_SHIFT) + 1, > + .flags =3D jh8100_nwcrg_clk_data[idx].flags, > + }; > + struct starfive_clk *clk =3D &priv->reg[idx]; > + unsigned int i; > + > + for (i =3D 0; i < init.num_parents; i++) { > + unsigned int pidx =3D jh8100_nwcrg_clk_data[idx].= parents[i]; > + > + if (pidx < JH8100_NWCLK_NUM_CLKS) > + parents[i].hw =3D &priv->reg[pidx].hw; > + else if (pidx =3D=3D JH8100_NWCLK_OSC) > + parents[i].fw_name =3D "osc"; Please generate this one time with structures and use an index instead of string names. This is faster in multiple ways, and the parent data is copied anyway. > + else if (pidx =3D=3D JH8100_NWCLK_APB_BUS) > + parents[i].fw_name =3D "apb_bus"; > + else if (pidx =3D=3D JH8100_NWCLK_APB_BUS_PER4) > + parents[i].fw_name =3D "apb_bus_per4";