From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 CBEC1266B66 for ; Thu, 6 Nov 2025 09:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762421696; cv=none; b=QCGvX8nxLUgrN3sYBxEQmPhIb/EBwtBOITcCwl9D0iGFGlhmLKyhVYD77VD84r/VC8WxbyJXe4NlW6sDHLIZFJ1J8YMIuudpJNBbVk0J0xS71Z1j4O+9Cm7GGeSfykxq1H5M9Sj+gLkWMhBLDhjmeKmCD3q3vH2JiuBe+OBZy10= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762421696; c=relaxed/simple; bh=BcSUbe1FLBVvgu0toOxV5tGQeQD6E+zZ+WL5+xBbXLI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QL5biua+IBsO9QRXvxJD2b96AOVwrl7eDl+sZEaCgPx0aDVPVEP4/twVinVl6tPx56um89JfEj8UnD7tpsF8vx0XKftQY94FtX88W7b3aQtTvS3yoyyTvZTRyVtmpjHZ70HMmMR0Iwaq6sd9trRZDmGajyOQ9bGrUEfzBQ7/UTE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=qCsqc/gN; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="qCsqc/gN" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 11986C0FA83; Thu, 6 Nov 2025 09:34:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 163646068C; Thu, 6 Nov 2025 09:34:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4297F118507A6; Thu, 6 Nov 2025 10:34:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762421688; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=T0xdNB7d2ITgGZMXcwNGx6G80Kkw5PtD6gU/B/S5C+E=; b=qCsqc/gN6+CJQIhyqUhRuKmvHVWW73kdVRuBPWDjLGyVVNrrkq9NY7ruBwVBZFI+D+II+i 23nBi9N0azUpFtZEYIKo08gyRnEegXJrGHtFQ05a5f83mbu057iiMeTun3PkR73asIjZCg tF/pLrFeb5CpVKduAxcSew6kbrDcJTod7C/housywQOlJicWNJEwbhHsVdBZtHmNqjZchr x7nFyWYHENN5gAIdcTvnr7ZZkOcf+DU8bEN31bEYSZPG2ZWJ9ttro6x1CM47u7MobhxZwY +KnOpupTw5ecWG0qI2vN9yLRi9MOAUNuuny+8npjeN8h4uqaLIeyjyQLNK4vNA== Date: Thu, 6 Nov 2025 10:34:43 +0100 From: Kory Maincent To: Andrew Davis Cc: , , Bajjuri Praneeth , Ramamoorthy Shree , , Aaro Koskinen , Andreas Kemnade , Kevin Hilman , Roger Quadros , Tony Lindgren , Lee Jones Subject: Re: [PATCH] mfd: tps65219: Implement LOCK register handling for TPS65214 Message-ID: <20251106103443.607c8276@kmaincent-XPS-13-7390> In-Reply-To: References: <20251105174735.1465461-1-kory.maincent@bootlin.com> Organization: bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 On Wed, 5 Nov 2025 14:52:21 -0600 Andrew Davis wrote: > On 11/5/25 11:47 AM, Kory Maincent wrote: > > From: "Kory Maincent (TI.com)" > >=20 > > The TPS65214 PMIC variant has a LOCK_REG register that prevents writes = to > > nearly all registers. > >=20 > > Implement custom regmap operations that automatically unlock before wri= tes > > and re-lock afterwards for TPS65214, while leaving other chip variants > > unaffected. > >=20 > > The implementation follows the regmap-i2c design pattern. > >=20 > > Signed-off-by: Kory Maincent (TI.com) > > --- > > drivers/mfd/tps65219.c | 53 +++++++++++++++++++++++++++++++++++- > > include/linux/mfd/tps65219.h | 3 ++ > > 2 files changed, 55 insertions(+), 1 deletion(-) > >=20 > > 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[] =3D { }, > > }; > > =20 > > +static int tps65219_reg_write(void *context, unsigned int reg, unsigned > > int val) +{ > > + struct i2c_client *i2c =3D context; > > + struct tps65219 *tps; > > + int ret; > > + > > + if (val > 0xff || reg > 0xff) > > + return -EINVAL; > > + > > + tps =3D i2c_get_clientdata(i2c); > > + if (tps->chip_id =3D=3D TPS65214) { > > + ret =3D i2c_smbus_write_byte_data(i2c, TPS65214_REG_LOCK, > > + TPS65214_LOCK_ACCESS_CMD); > > + if (ret) > > + return ret; > > + } > > + > > + ret =3D i2c_smbus_write_byte_data(i2c, reg, val); > > + if (ret) > > + return ret; > > + > > + if (tps->chip_id =3D=3D 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 =3D context; > > + int ret; > > + > > + if (reg > 0xff) > > + return -EINVAL; > > + > > + ret =3D i2c_smbus_read_byte_data(i2c, reg); > > + if (ret < 0) > > + return ret; > > + > > + *val =3D ret; > > + > > + return 0; > > +} > > + > > +static const struct regmap_bus tps65219_regmap_bus =3D { > > + .reg_write =3D tps65219_reg_write, > > + .reg_read =3D 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 *clien= t) > > tps->dev =3D &client->dev; > > chip_id =3D (uintptr_t)i2c_get_match_data(client); > > pmic =3D &chip_info_table[chip_id]; > > + tps->chip_id =3D chip_id; > > =20 > > - tps->regmap =3D devm_regmap_init_i2c(client, > > &tps65219_regmap_config); > > + tps->regmap =3D devm_regmap_init(&client->dev, &tps65219_regmap_bus, > > client, > > + &tps65219_regmap_config); =20 >=20 > Why not do the (tps->chip_id =3D=3D TPS65214) check here and only setup t= he > 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, --=20 K=C3=B6ry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com