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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED8B3C4361B for ; Tue, 8 Dec 2020 08:23:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2A8A23A5B for ; Tue, 8 Dec 2020 08:23:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2A8A23A5B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AKh0jrC1CobRi58bva3A3KcLHGbBtIY+kBGRgSPixKw=; b=p7XTzUoiCHBdN9XnyyXrZ2Zc5 TjEMVJQ9O7Avfg0ms1Z0CknCIU1/JiJ53ttyqPp3RYQgDA07B7Z6gq8lwplRWJFM9fV6TQC+4msW5 aIUd4eWGCUSPMGuNyr49qEWZ1pTZq5AWMpVR+rglzTAnlz6wPoaCALn54++TH/CLslPBDBj+GC0Ni 6kMJMcZh1akC4fLYbmZVoYm9CeQcI1jHaRqPm7BDcAVrL8xKnjpid55ZKnN5vPL2o6qaFKCjPlWbG eQBVg6uQPn/klLhR28JEAJ5LKqgmschHpMRgGqy/oqy8XVR6kls809APMkBuTqvyTRmcAqcxm8gB8 LCFzxvNEQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmYG1-0005LQ-Co; Tue, 08 Dec 2020 08:22:01 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmYFz-0005L5-CO for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 08:22:00 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 3A406C7F; Tue, 8 Dec 2020 03:21:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 08 Dec 2020 03:21:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=cQfOkOJh+W2ncPOOtPBR29+hpuG wA7DnPqCP/mcp+RQ=; b=ppUo6sT1Rx4Rx33UfWWwLNyk3okKg2/lnFWxRdOdUF2 2xXLJCn+WquhboIWP0Ws2g8DCZAMzRF1NgryUjZ857f4iHIczGNcKQ0C/58OTfYN CX366MJAGM3IrJ5IRl0hMX3hfi1tDRKr8DkRp0Ow2+7zu2IloMDUMRzDcaHuv1Bf HvaqDsvW8xlfsRc6m+HAL52pFWDYuDOUZajdFCq0vQme0g6PNfi0zHeNc4VGy6wo NkG4lPj4t/WkbqkN+rKCpLhGihRn+IW7nhbS0WL9N7rbirT2fkIP6bxqP9Y3Cvpt LYGKwsPLFNFblAMDELibYuqMa6lUmVLZNYXdKdU8NNQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=cQfOkO Jh+W2ncPOOtPBR29+hpuGwA7DnPqCP/mcp+RQ=; b=ozlgh2U7G4WaltBwvAXILY ZIkCkmEPSFWgw+KQZ/BQlDb1Bg0MDPkntOgNmeOBCF8YC87kjK7nAYG49EKdNt4g wu4T8zcu6GxQbxum8U9m3GeoxuuDnOtGAINGOvbKO6e3Rc4P11ShXE//FV9tthPB 1QTX0KMqUPzTKxRYwKeh2QcmThNsOqitx8PbHO8q0w6IV9fklqdFHNhVhu3khSxS yw7nfqO2iPnXdEkw6+Ec6f2efq3Oot7LDI44XK/u0p7y6zx0k1StMKwt89gufLES b3VE+7TPbaJNtwPE62csy2fXOVpLgQtrkvpO0KIL6A2vhX/Z9rZ9PJ07gRND0YiA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejhedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeelkeeghefhuddtleejgfeljeffheffgfeijefhgfeufefhtdevteegheei heegudenucfkphepledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 513081080057; Tue, 8 Dec 2020 03:21:52 -0500 (EST) Date: Tue, 8 Dec 2020 09:21:50 +0100 From: Maxime Ripard To: Shuosheng Huang Subject: Re: [PATCH v4 1/6] cpufreq: sun50i: add efuse_xlate to get efuse version. Message-ID: <20201208082150.jbpdlpcghbj3liqj@gilmour> References: <20201208071928.2078-1-huangshuosheng@allwinnertech.com> MIME-Version: 1.0 In-Reply-To: <20201208071928.2078-1-huangshuosheng@allwinnertech.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_032159_709229_CC3FAFF5 X-CRM114-Status: GOOD ( 26.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, samuel@sholland.org, tiny.windzz@gmail.com, viresh.kumar@linaro.org, linux-pm@vger.kernel.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, wens@csie.org, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============3673621388551485805==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============3673621388551485805== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lez4floknnnll5q5" Content-Disposition: inline --lez4floknnnll5q5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Dec 08, 2020 at 03:19:28PM +0800, Shuosheng Huang wrote: > It's better to use efuse_xlate to extract the differentiated part > regarding different SoC. >=20 > Signed-off-by: Shuosheng Huang Please wait a bit for reviews before sending a new version. You've sent three versions in a day, and I haven't reviewed the first one. Also, please put a changelog in the cover letter, we don't have any way to tell what is the difference between v1, v2, v3 and v4. > --- > drivers/cpufreq/sun50i-cpufreq-nvmem.c | 82 ++++++++++++++++---------- > 1 file changed, 51 insertions(+), 31 deletions(-) >=20 > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun= 50i-cpufreq-nvmem.c > index 9907a165135b..3c0531938d1a 100644 > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c > @@ -19,24 +19,51 @@ > =20 > #define MAX_NAME_LEN 7 > =20 > -#define NVMEM_MASK 0x7 > -#define NVMEM_SHIFT 5 > +#define SUN50I_H6_NVMEM_MASK 0x7 > +#define SUN50I_H6_NVMEM_SHIFT 5 > + > +struct sunxi_cpufreq_soc_data { > + int (*efuse_xlate)(struct nvmem_cell *speedbin_nvmem); > +}; > =20 > static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev; > =20 > +static int sun50i_h6_efuse_xlate(struct nvmem_cell *speedbin_nvmem) > +{ > + size_t len; > + u32 *speedbin; > + u32 efuse_value; > + > + speedbin =3D nvmem_cell_read(speedbin_nvmem, &len); > + if (IS_ERR(speedbin)) > + return PTR_ERR(speedbin); > + > + efuse_value =3D (*(u32 *)speedbin >> SUN50I_H6_NVMEM_SHIFT) & > + SUN50I_H6_NVMEM_MASK; > + kfree(speedbin); > + /* > + * We treat unexpected efuse values as if the SoC was from > + * the slowest bin. Expected efuse values are 1-3, slowest > + * to fastest. > + */ > + if (efuse_value >=3D 1 && efuse_value <=3D 3) > + return efuse_value - 1; > + else > + return 0; > +} > + > /** > * sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value > - * @versions: Set to the value parsed from efuse > + * @soc_data: pointer to sunxi_cpufreq_soc_data context > * > * Returns 0 if success. > */ > -static int sun50i_cpufreq_get_efuse(u32 *versions) > +static int sun50i_cpufreq_get_efuse(const struct sunxi_cpufreq_soc_data = *soc_data) > { > struct nvmem_cell *speedbin_nvmem; > struct device_node *np; > struct device *cpu_dev; > - u32 *speedbin, efuse_value; > - size_t len; > + int versions; > int ret; > =20 > cpu_dev =3D get_cpu_device(0); > @@ -63,43 +90,33 @@ static int sun50i_cpufreq_get_efuse(u32 *versions) > return PTR_ERR(speedbin_nvmem); > } > =20 > - speedbin =3D nvmem_cell_read(speedbin_nvmem, &len); > + versions =3D soc_data->efuse_xlate(speedbin_nvmem); > nvmem_cell_put(speedbin_nvmem); > - if (IS_ERR(speedbin)) > - return PTR_ERR(speedbin); > - > - efuse_value =3D (*speedbin >> NVMEM_SHIFT) & NVMEM_MASK; > - > - /* > - * We treat unexpected efuse values as if the SoC was from > - * the slowest bin. Expected efuse values are 1-3, slowest > - * to fastest. > - */ > - if (efuse_value >=3D 1 && efuse_value <=3D 3) > - *versions =3D efuse_value - 1; > - else > - *versions =3D 0; > =20 > - kfree(speedbin); > - return 0; > + return versions; > }; > =20 > static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) > { > + const struct of_device_id *match; > struct opp_table **opp_tables; > char name[MAX_NAME_LEN]; > unsigned int cpu; > - u32 speed =3D 0; > + int speed =3D 0; > int ret; > =20 > + match =3D dev_get_platdata(&pdev->dev); > + if (!match) > + return -EINVAL; > + > opp_tables =3D kcalloc(num_possible_cpus(), sizeof(*opp_tables), > GFP_KERNEL); > if (!opp_tables) > return -ENOMEM; > =20 > - ret =3D sun50i_cpufreq_get_efuse(&speed); > - if (ret) > - return ret; > + speed =3D sun50i_cpufreq_get_efuse(match->data); > + if (speed < 0) > + return speed; > =20 > snprintf(name, MAX_NAME_LEN, "speed%d", speed); > =20 > @@ -163,8 +180,12 @@ static struct platform_driver sun50i_cpufreq_driver = =3D { > }, > }; > =20 > +static const struct sunxi_cpufreq_soc_data sun50i_h6_data =3D { > + .efuse_xlate =3D sun50i_h6_efuse_xlate, > +}; > + > static const struct of_device_id sun50i_cpufreq_match_list[] =3D { > - { .compatible =3D "allwinner,sun50i-h6" }, > + { .compatible =3D "allwinner,sun50i-h6", .data =3D &sun50i_h6_data }, > {} > }; > =20 > @@ -198,9 +219,8 @@ static int __init sun50i_cpufreq_init(void) > if (unlikely(ret < 0)) > return ret; > =20 > - sun50i_cpufreq_pdev =3D > - platform_device_register_simple("sun50i-cpufreq-nvmem", > - -1, NULL, 0); > + sun50i_cpufreq_pdev =3D platform_device_register_data(NULL, > + "sun50i-cpufreq-nvmem", -1, match, sizeof(*match)); The alignment here raises a checkpatch warning with --strict Maxime --lez4floknnnll5q5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCX883ngAKCRDj7w1vZxhR xbJHAQDmcSqlridLyB0SRGolBHcXCe9dPTSgLj/2rXPbLbyqyQEAgHhkTPY5DzP/ wV7FUsm6Syw1GB66TNsQH/8ty3fyEgc= =x4Ax -----END PGP SIGNATURE----- --lez4floknnnll5q5-- --===============3673621388551485805== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============3673621388551485805==--