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 7D387C4829E for ; Thu, 15 Feb 2024 09:13:53 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6JYaoQObHsfVh3vPZUr2vUia646KBkT2S81PJaMm9J8=; b=LYcFj6wMIHovgP WEDGx7pe+vBa5Sa0hOZdX1+Gu0b13g67XVibwMkYm4cHHGIrn+/CJLg5VXi7fqbFtTnhD1fhJ27oo 1OfVQlL10giMvM6607REFtl1BnXfKiTy8kf6bsODN3YxKyoYR04iZF/s0zJmXrKBrAgFzUopANOY9 YHDeMLlnkJZQMG3dHsz+VnOo1hNZeKB3a/2ItWiAWglWrKCKJPkRlscOQGGNGEyViyndHjKl6pHTr k6aEAWk2KEPBy4YHLar6aNJl6NNTYRiHYig+AhGXylC5ZYtrtzvcjX5RZFWZ7oNVOfUAlURNIaYWx QjTifd1GzSV0b9Dr4aUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raXoJ-0000000FVOn-3SI9; Thu, 15 Feb 2024 09:13:39 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raXoH-0000000FVN9-01ap for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2024 09:13:38 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41F9DWBV055880; Thu, 15 Feb 2024 03:13:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707988412; bh=HK2jGaqe1B73/CKo9oLFbqeMHRqjhANdj2JYm1spQ4g=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=jLp2V/qVP+59xdlbu99/3t853hK/nnfLyklukdV+adyQo7mFrYy1xDwUnN7Z8p4Ke VH4DNnjCsokqs+NtWdso2oHlGc+Np7SEGauP+hdYodBRh8GmGSZhvrMLCsx48254s5 wsTbdGuOQH9x1qc6lZtmCAaOBsFEMme4wVPmT1Bs= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41F9DWQG049150 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Feb 2024 03:13:32 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 15 Feb 2024 03:13:32 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 15 Feb 2024 03:13:32 -0600 Received: from localhost (dhruva.dhcp.ti.com [172.24.227.68]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41F9DVMV039681; Thu, 15 Feb 2024 03:13:31 -0600 Date: Thu, 15 Feb 2024 14:43:30 +0530 From: Dhruva Gole To: Markus Schneider-Pargmann CC: Viresh Kumar , Nishanth Menon , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra , Tero Kristo , "Rafael J . Wysocki" , Andrew Davis , , , , Subject: Re: [PATCH 2/3] cpufreq: ti-cpufreq: Support nvmem for chip version Message-ID: <20240215091330.bzprmfsz2dw2j7xa@dhruva> References: <20240206145721.2418893-1-msp@baylibre.com> <20240206145721.2418893-3-msp@baylibre.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240206145721.2418893-3-msp@baylibre.com> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_011337_208138_A325BB1C X-CRM114-Status: GOOD ( 27.62 ) 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 Hi, On Feb 06, 2024 at 15:57:20 +0100, Markus Schneider-Pargmann wrote: > Support using nvmem-cells 'chipvariant' and 'chipspeed' instead of > syscon. This makes it more flexible and moves more configuration into > the devicetree. > > If nvmem-cells are present, probing will fail if the configuration of > these cells is broken. If nvmem-cells is not present syscon will be > used. > > Signed-off-by: Markus Schneider-Pargmann > --- > drivers/cpufreq/ti-cpufreq.c | 105 ++++++++++++++++++++++------------- > 1 file changed, 66 insertions(+), 39 deletions(-) > > diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c > index 46c41e2ca727..3ee72b1309f0 100644 > --- a/drivers/cpufreq/ti-cpufreq.c > +++ b/drivers/cpufreq/ti-cpufreq.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -65,6 +66,7 @@ struct ti_cpufreq_soc_data { > > struct ti_cpufreq_data { > struct device *cpu_dev; > + struct device *dev; > struct device_node *opp_node; > struct regmap *syscon; > const struct ti_cpufreq_soc_data *soc_data; > @@ -244,31 +246,40 @@ static struct ti_cpufreq_soc_data am625_soc_data = { > static int ti_cpufreq_get_efuse(struct ti_cpufreq_data *opp_data, > u32 *efuse_value) > { > + struct device_node *np = opp_data->opp_node; Umm.. slightly confused, where is *np being used? > struct device *dev = opp_data->cpu_dev; > u32 efuse; > int ret; > > - ret = regmap_read(opp_data->syscon, opp_data->soc_data->efuse_offset, > - &efuse); > - if (ret == -EIO) { > - /* not a syscon register! */ > - void __iomem *regs = ioremap(OMAP3_SYSCON_BASE + > - opp_data->soc_data->efuse_offset, 4); > - > - if (!regs) > - return -ENOMEM; > - efuse = readl(regs); > - iounmap(regs); > + ret = nvmem_cell_read_u32(opp_data->dev, "chipspeed", &efuse); > + if (ret && (ret != -ENOENT || !opp_data->syscon)) > + return dev_err_probe(dev, ret, > + "Failed to read nvmem cell 'chipspeed': %pe", > + ERR_PTR(ret)); > + > + if (ret) { > + ret = regmap_read(opp_data->syscon, opp_data->soc_data->efuse_offset, > + &efuse); > + if (ret == -EIO) { > + /* not a syscon register! */ > + void __iomem *regs = ioremap(OMAP3_SYSCON_BASE + > + opp_data->soc_data->efuse_offset, 4); > + > + if (!regs) > + return -ENOMEM; > + efuse = readl(regs); > + iounmap(regs); > + } > + else if (ret) { else should be enough I guess, no need of elif? > + dev_err(dev, > + "Failed to read the efuse value from syscon: %d\n", > + ret); > + return ret; > } > - else if (ret) { > - dev_err(dev, > - "Failed to read the efuse value from syscon: %d\n", > - ret); > - return ret; > - } > > - efuse = (efuse & opp_data->soc_data->efuse_mask); > - efuse >>= opp_data->soc_data->efuse_shift; > + efuse = (efuse & opp_data->soc_data->efuse_mask); > + efuse >>= opp_data->soc_data->efuse_shift; > + } > > *efuse_value = opp_data->soc_data->efuse_xlate(opp_data, efuse); > > @@ -285,30 +296,41 @@ static int ti_cpufreq_get_efuse(struct ti_cpufreq_data *opp_data, > static int ti_cpufreq_get_rev(struct ti_cpufreq_data *opp_data, > u32 *revision_value) > { > + struct device_node *np = opp_data->opp_node; where is this used? Atleast, in this patch I don't see it... > struct device *dev = opp_data->cpu_dev; > u32 revision; > int ret; > > - ret = regmap_read(opp_data->syscon, opp_data->soc_data->rev_offset, > - &revision); > - if (ret == -EIO) { > - /* not a syscon register! */ > - void __iomem *regs = ioremap(OMAP3_SYSCON_BASE + > - opp_data->soc_data->rev_offset, 4); > - > - if (!regs) > - return -ENOMEM; > - revision = readl(regs); > - iounmap(regs); > + ret = nvmem_cell_read_u32(opp_data->dev, "chipvariant", &revision); > + if (ret && (ret != -ENOENT || !opp_data->syscon)) > + return dev_err_probe(dev, ret, > + "Failed to read nvmem cell 'chipvariant': %pe", > + ERR_PTR(ret)); > + > + if (ret) { > + ret = regmap_read(opp_data->syscon, opp_data->soc_data->rev_offset, > + &revision); > + if (ret == -EIO) { > + /* not a syscon register! */ > + void __iomem *regs = ioremap(OMAP3_SYSCON_BASE + > + opp_data->soc_data->rev_offset, 4); > + > + if (!regs) > + return -ENOMEM; > + revision = readl(regs); > + iounmap(regs); > + } > + else if (ret) { Do you really have to? This code will reach only if(ret) is satisfied, the elif feels redundant. Else should be fine > + dev_err(dev, > + "Failed to read the revision number from syscon: %d\n", > + ret); > + return ret; > } > - else if (ret) { > - dev_err(dev, > - "Failed to read the revision number from syscon: %d\n", > - ret); > - return ret; > + > + revision = (revision >> REVISION_SHIFT) & REVISION_MASK; > } > > - *revision_value = BIT((revision >> REVISION_SHIFT) & REVISION_MASK); > + *revision_value = BIT(revision); > > return 0; > } > @@ -392,9 +414,14 @@ static int ti_cpufreq_probe(struct platform_device *pdev) > goto register_cpufreq_dt; > } > > - ret = ti_cpufreq_setup_syscon_register(opp_data); > - if (ret) > - goto fail_put_node; > + opp_data->dev = &pdev->dev; > + opp_data->dev->of_node = opp_data->opp_node; > + > + if (!of_property_read_bool(opp_data->opp_node, "nvmem-cells")) { > + ret = ti_cpufreq_setup_syscon_register(opp_data); > + if (ret) > + goto fail_put_node; > + } Mostly looks okay, with above comments addressed: Reviewed-by: Dhruva Gole -- Best regards, Dhruva Gole _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel