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 85A75C282DE for ; Thu, 13 Mar 2025 14:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type: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=nwDn29V3N1FLlRNDGUNKsIzGpTbAoIKj1qt8XLcUZ5w=; b=HN6Au/p1GtIXOFKAZSCWrv+8kR nanXuMUoFJAo71tfigsM9c+sYSBb048t0bHjnR3NvFOuiA6GHwKOb01J5WiqJ1skmv/VP0XI///zm owMMJs6os/RjI4CEFUmc4MaB7V9gfmi9qRoehmqwpg/EFuqpYEWcJ36NiPtNHJdBYpcO6wi0ai6mY 2HRk7szB+74CFcOuVQR38QKEFFgNbhoQSjI1taocGvbOWPN9LOvPbuEdIhTP6R2NYy5ECqc/83Zzp O0aikr/vz+656Po19O/Gh18UMiT0zZCk6mHIQqma33zEk7JNKO0fa4OEtjmftm2/sIJH6HRIJHVqh /ElFPdYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsjfA-0000000BYKv-3P5g; Thu, 13 Mar 2025 14:35:56 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsiUN-0000000BN0R-1pzA for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 13:20:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 36D50A474B6; Thu, 13 Mar 2025 13:15:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC62EC4CEE5; Thu, 13 Mar 2025 13:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741872041; bh=7sLRPlPMdxJhpz09Z2Z7FAiXZqSpH6scXcJJzy6jD6M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WBtA0e4YOEjcIza/D/OQhLriwtnpU6IR3sxl+1DAQ+cHYTn77DmxnxinkMlGg/TBR hhbQha4y9eqMBmMseUhJrkzkbqzsvsDaEkeMLCr3Q4MvR60adtKrFyaxUrM7khRj9F UnGbBm+jALy6kuskJ3iSySuxDxb3ZMrX8AxddDinr2wKFDnrE5Da2+R/YqX3VHND6A splMA/3ogKPO5qR2j6ifCvSPWBTMZ2w7Ytx7njAiS+vaTzjo6dZgs1p/1UDcorCSjT n7abIhzeOS3hVMURteAiU88Z2QtloTx53jyL6PYXjzfHzEC8X6acvjkBTRXV09uby/ SMpmUw7/RMIxw== Date: Thu, 13 Mar 2025 13:20:36 +0000 From: Lee Jones To: Artur Weber Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Stanislav Jakubek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ~postmarketos/upstreaming@lists.sr.ht Subject: Re: [PATCH v6 06/10] mfd: bcm590xx: Add PMU ID/revision parsing function Message-ID: <20250313132036.GB3616286@google.com> References: <20250304-bcm59054-v6-0-ae8302358443@gmail.com> <20250304-bcm59054-v6-6-ae8302358443@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250304-bcm59054-v6-6-ae8302358443@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_062043_610551_9149B7DC X-CRM114-Status: GOOD ( 34.99 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 04 Mar 2025, Artur Weber wrote: > The BCM590xx PMUs have two I2C registers for reading the PMU ID > and revision. The revision is useful for subdevice drivers, since > different revisions may have slight differences in behavior (for > example - BCM59054 has different regulator configurations for > revision A0 and A1). > > Check the PMU ID register and make sure it matches the DT compatible. > Fetch the digital and analog revision from the PMUREV register > so that it can be used in subdevice drivers. > > Also add some known revision values to bcm590xx.h, for convenience > when writing subdevice drivers. > > Signed-off-by: Artur Weber > --- > Changes in v6: > - Adapt to PMUID being passed as device type value > - Rename rev_dig and rev_ana to rev_digital and rev_analog > - Rewrite commit message > > Changes in v5: > - Add REG_ prefix to register offset constant names > > Changes in v4: > - Added this commit > --- > drivers/mfd/bcm590xx.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ > include/linux/mfd/bcm590xx.h | 14 ++++++++++ > 2 files changed, 77 insertions(+) > > diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c > index 4620eed0066fbf1dd691a2e392e967747b4d125b..74dc4ae5ecd5db7fadc56918f63110c1265d4a76 100644 > --- a/drivers/mfd/bcm590xx.c > +++ b/drivers/mfd/bcm590xx.c > @@ -17,6 +17,15 @@ > #include > #include > > +/* Under primary I2C address: */ > +#define BCM590XX_REG_PMUID 0x1e > + > +#define BCM590XX_REG_PMUREV 0x1f > +#define BCM590XX_PMUREV_DIG_MASK 0xF > +#define BCM590XX_PMUREV_DIG_SHIFT 0 > +#define BCM590XX_PMUREV_ANA_MASK 0xF0 > +#define BCM590XX_PMUREV_ANA_SHIFT 4 > + > static const struct mfd_cell bcm590xx_devs[] = { > { > .name = "bcm590xx-vregs", > @@ -37,6 +46,56 @@ static const struct regmap_config bcm590xx_regmap_config_sec = { > .cache_type = REGCACHE_MAPLE, > }; > > +/* Map PMU ID value to model name string */ > +static const char * const bcm590xx_names[] = { > + [BCM590XX_PMUID_BCM59054] = "BCM59054", > + [BCM590XX_PMUID_BCM59056] = "BCM59056", > +}; > + > +/* > + * Parse the version from version registers and make sure it matches > + * the device type passed to the compatible. > + */ > +static int bcm590xx_parse_version(struct bcm590xx *bcm590xx) > +{ > + unsigned int id, rev; > + int ret; > + > + /* Get PMU ID and verify that it matches compatible */ > + ret = regmap_read(bcm590xx->regmap_pri, BCM590XX_REG_PMUID, &id); > + if (ret) { > + dev_err(bcm590xx->dev, "failed to read PMU ID: %d\n", ret); > + return ret; > + } > + > + if (id != bcm590xx->pmu_id) { > + dev_err(bcm590xx->dev, > + "Incorrect ID for %s: expected %x, got %x. Check your DT compatible.\n", Isn't it more likely that the H/W this is being executed on is unsupported? If so, say that instead. > + bcm590xx_names[bcm590xx->pmu_id], bcm590xx->pmu_id, id); > + return -EINVAL; -ENODEV > + } > + > + /* Get PMU revision and store it in the info struct */ > + ret = regmap_read(bcm590xx->regmap_pri, BCM590XX_REG_PMUREV, &rev); > + if (ret) { > + dev_err(bcm590xx->dev, "failed to read PMU revision: %d\n", > + ret); > + return ret; > + } > + > + bcm590xx->rev_digital = (rev & BCM590XX_PMUREV_DIG_MASK) > + >> BCM590XX_PMUREV_DIG_SHIFT; > + > + bcm590xx->rev_analog = (rev & BCM590XX_PMUREV_ANA_MASK) > + >> BCM590XX_PMUREV_ANA_SHIFT; > + > + dev_info(bcm590xx->dev, "PMU ID 0x%x (%s), revision: digital %d, analog %d", > + id, bcm590xx_names[id], > + bcm590xx->rev_digital, bcm590xx->rev_analog); > + > + return 0; > +} > + > static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri) > { > struct bcm590xx *bcm590xx; > @@ -78,6 +137,10 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri) > goto err; > } > > + ret = bcm590xx_parse_version(bcm590xx); > + if (ret) > + goto err; > + > ret = devm_mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs, > ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL); > if (ret < 0) { > diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h > index 8d146e3b102a7dbce6f4dbab9f8ae5a9c4e68c0e..fbc458e94bef923ca1b69afe2cac944adf6fedf8 100644 > --- a/include/linux/mfd/bcm590xx.h > +++ b/include/linux/mfd/bcm590xx.h > @@ -17,6 +17,16 @@ > #define BCM590XX_PMUID_BCM59054 0x54 > #define BCM590XX_PMUID_BCM59056 0x56 > > +/* Known chip revision IDs */ > +#define BCM59054_REV_DIGITAL_A1 1 > +#define BCM59054_REV_ANALOG_A1 2 > + > +#define BCM59056_REV_DIGITAL_A0 1 > +#define BCM59056_REV_ANALOG_A0 1 > + > +#define BCM59056_REV_DIGITAL_B0 2 > +#define BCM59056_REV_ANALOG_B0 2 > + > /* max register address */ > #define BCM590XX_MAX_REGISTER_PRI 0xe7 > #define BCM590XX_MAX_REGISTER_SEC 0xf0 > @@ -30,6 +40,10 @@ struct bcm590xx { > > /* PMU ID value; also used as device type */ > u8 pmu_id; > + > + /* Chip revision, read from PMUREV reg */ > + u8 rev_digital; > + u8 rev_analog; > }; > > #endif /* __LINUX_MFD_BCM590XX_H */ > > -- > 2.48.1 > -- Lee Jones [李琼斯]