lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251106103443.607c8276@kmaincent-XPS-13-7390>
Date: Thu, 6 Nov 2025 10:34:43 +0100
From: Kory Maincent <kory.maincent@...tlin.com>
To: Andrew Davis <afd@...com>
Cc: <linux-omap@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Bajjuri
 Praneeth <praneeth@...com>, Ramamoorthy Shree <s-ramamoorthy@...com>,
 <thomas.petazzoni@...tlin.com>, Aaro Koskinen <aaro.koskinen@....fi>,
 Andreas Kemnade <andreas@...nade.info>, Kevin Hilman
 <khilman@...libre.com>, Roger Quadros <rogerq@...nel.org>, Tony Lindgren
 <tony@...mide.com>, Lee Jones <lee@...nel.org>
Subject: Re: [PATCH] mfd: tps65219: Implement LOCK register handling for
 TPS65214

On Wed, 5 Nov 2025 14:52:21 -0600
Andrew Davis <afd@...com> wrote:

> On 11/5/25 11:47 AM, Kory Maincent wrote:
> > From: "Kory Maincent (TI.com)" <kory.maincent@...tlin.com>
> > 
> > The TPS65214 PMIC variant has a LOCK_REG register that prevents writes to
> > nearly all registers.
> > 
> > Implement custom regmap operations that automatically unlock before writes
> > and re-lock afterwards for TPS65214, while leaving other chip variants
> > unaffected.
> > 
> > The implementation follows the regmap-i2c design pattern.
> > 
> > Signed-off-by: Kory Maincent (TI.com) <kory.maincent@...tlin.com>
> > ---
> >   drivers/mfd/tps65219.c       | 53 +++++++++++++++++++++++++++++++++++-
> >   include/linux/mfd/tps65219.h |  3 ++
> >   2 files changed, 55 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mfd/tps65219.c b/drivers/mfd/tps65219.c
> > index 65a952555218d..1d8a06afb1048 100644
> > --- a/drivers/mfd/tps65219.c
> > +++ b/drivers/mfd/tps65219.c
> > @@ -473,6 +473,55 @@ static const struct tps65219_chip_data
> > chip_info_table[] = { },
> >   };
> >   
> > +static int tps65219_reg_write(void *context, unsigned int reg, unsigned
> > int val) +{
> > +	struct i2c_client *i2c = context;
> > +	struct tps65219 *tps;
> > +	int ret;
> > +
> > +	if (val > 0xff || reg > 0xff)
> > +		return -EINVAL;
> > +
> > +	tps = i2c_get_clientdata(i2c);
> > +	if (tps->chip_id == TPS65214) {
> > +		ret = i2c_smbus_write_byte_data(i2c, TPS65214_REG_LOCK,
> > +						TPS65214_LOCK_ACCESS_CMD);
> > +		if (ret)
> > +			return ret;
> > +	}
> > +
> > +	ret = i2c_smbus_write_byte_data(i2c, reg, val);
> > +	if (ret)
> > +		return ret;
> > +
> > +	if (tps->chip_id == TPS65214)
> > +		return i2c_smbus_write_byte_data(i2c, TPS65214_REG_LOCK,
> > 0); +
> > +	return 0;
> > +}
> > +
> > +static int tps65219_reg_read(void *context, unsigned int reg, unsigned int
> > *val) +{
> > +	struct i2c_client *i2c = context;
> > +	int ret;
> > +
> > +	if (reg > 0xff)
> > +		return -EINVAL;
> > +
> > +	ret = i2c_smbus_read_byte_data(i2c, reg);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	*val = ret;
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct regmap_bus tps65219_regmap_bus = {
> > +	.reg_write = tps65219_reg_write,
> > +	.reg_read = tps65219_reg_read,
> > +};
> > +
> >   static int tps65219_probe(struct i2c_client *client)
> >   {
> >   	struct tps65219 *tps;
> > @@ -490,8 +539,10 @@ static int tps65219_probe(struct i2c_client *client)
> >   	tps->dev = &client->dev;
> >   	chip_id = (uintptr_t)i2c_get_match_data(client);
> >   	pmic = &chip_info_table[chip_id];
> > +	tps->chip_id = chip_id;
> >   
> > -	tps->regmap = devm_regmap_init_i2c(client,
> > &tps65219_regmap_config);
> > +	tps->regmap = devm_regmap_init(&client->dev, &tps65219_regmap_bus,
> > client,
> > +				       &tps65219_regmap_config);  
> 
> Why not do the (tps->chip_id == TPS65214) check here and only setup the
> special regmap_bus for the TPS65214. Then you don't need to do the checks
> every time reg_write is called.

Yes indeed that's a better idea!

Thanks,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ