From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3AD963B71A4 for ; Mon, 14 Sep 2026 07:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371966; cv=none; b=PKlTcJN2c3zw8/Ec+vAWLEr/5MoN2tKp3G3BCzZ5WeWEyorzDu2ah1g1S8Ycb3zr9aqbTtQYNNDKfK7UtNvoPEyCKaB/gdVeUE6c+Lo38GqqyqlQwsJ4wKCCHTC3iL2Vv/GuSfQ+5we9f2bGAbcVi82WiFaYwLL2EKQJWvr3EYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371966; c=relaxed/simple; bh=zwEor6K8yGoFURlxDvbOjCkK1oLF41ASBn1v919rW7k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tuYVG/GKstO0/AG6Qrb/gUV1fSt4nQl95Vn4VNE3OqTjyiYbWHYVoFyVTqVgq3ByUyIrbqy7rIPHZ57K51kh7Aimc+t1oXoZg9RWUIngcBDHTasoZ3N7l2TvkrLN9HSXrVza8XICDnBC047E8sQCmHJYmbeNIIV6a4/jqOuo2QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hkNMWODj; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hkNMWODj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DB751F00898; Mon, 14 Sep 2026 07:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371964; bh=S6FY7ZetqMty4OJBLyaiR50VfGzmS5JdgvQQAtmW5og=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hkNMWODjCp66HXsxP40B6blv8cONrbJukcJ/P2yD5rFqHu1HH/cAdIPa6ZXuhv93s 9303f0QcA06EiHGNfU63DL4v/77c41jF3vDiXPO6v0CeV6jfg0Vo0zJVv2nZuWL5RH ZAr9lzJr6+CDgHX5MiuaC6wKUdbSKS33EDRrNowgZUlwrFRAbIOxcKLy2fHY5mPXbr EhyJmaTiBbEcvtcnLV+huW2Gj/SF2rzwZCUUu/CQu9LGqrKArnw97S5X76gVRBkFwa Oc2Q+yds/RTYSv5IB62Vdr3nYHND4TTfDGnS//oCpM7du54OV0DiU/dad6IHatUlQk zG/jmF4aA/qGQ== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:00 +0200 Subject: [PATCH v3 01/10] regulator: ab8500: Fix AB8505 VANA voltage selectors 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-1-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 The AB8505 VANA voltage table assumes selector 0 represents 1.05 V and all eight selectors increase linearly. Selector 0 actually represents 1.2 V. Selectors 1 through 6 cover 1.05 V through 1.175 V, and selector 7 represents 1.225 V. Correct the table so each selector reports and programs the documented voltage. Reference: AB8505 User Manual, DM00046744 Rev 3, p. 257 Fixes: 8a3b1b8703fe ("regulator: ab8500: Add voltage selection for AUDIO an= d ANA on AB8505") Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 3705c98b0713..ca59406d42a8 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -264,13 +264,13 @@ static const unsigned int fixed_2050000_voltage[] =3D= { }; =20 static const unsigned int ldo_vana_voltages[] =3D { + 1200000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, - 1200000, 1225000, }; =20 --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C15A3282F21 for ; Mon, 14 Sep 2026 07:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371968; cv=none; b=fjpb9A2AepgBSN8fSv/8Mcsug+fAZvFBH6Rc60VoyyarJ6h2mGcqgdMeg3lsxL+yQzPLG3iEB/qAf7aeUl6wAxPkCeHrDz0pQjykir6gg3uywumyot6tBapkDNWum1z3RIcEsaE8OcJJ+pHnaMFJTE+3Oo2YQd5GwdusCKZRipM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371968; c=relaxed/simple; bh=ef+oXwxcVa8FKk7hEmWZPLiJFVo/qq/f25Yz8mXsKCA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hv3InHsXTFdrbmsPUZySNmvVEOcji+ofnuiEgog4UPqHO7kzh1iG6lg3rZj0YPiwaR4aaKRDb8jcMr/r2nxv47B8z9Q6zG5Sa/cCl8cweK4anx/bZzoqUamcFjJ5GcvP4tDrOPtBTrCAcjrThc+wqnzI1x8+Jn9I/T5GGJu3Hjg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SoXtCBXY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SoXtCBXY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48B8A1F000FF; Mon, 14 Sep 2026 07:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371966; bh=Fr64MGYLyhfXI/VcMfbC/lq4kwHH2zRzUBhtquow60k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=SoXtCBXYz8HELzdXCgV0Zk7b19CIFJNZ86SOJj3whEkFvT88hv84ODSXjb1xVx8nV BU/6z1UItonQ0cnmd9rUqCWZVROzEXcSMkUly+I1H8fz14MPjqJQ8fpnHsWE78kMno O3z3t3UgTrV/BX+wEV9VNpWRMaikzcFm+cD+ddFrwMdJVT6cwzHk4RO7gVfM/5Uxgz KJbnLkar7hwXT319YdL4HAFddCPxaildBZYguuU+ZnKI3iSlgCc05LCUOyWNOhLyw7 JAjE9M2xNeRi8IlxTz6AC2JUlEkZX7ZhjwDiBRSmjiSio7OuU655d7GoacUUgjoiC8 1vMSXrx6hUi5g== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:01 +0200 Subject: [PATCH v3 02/10] regulator: ab8500: Add AB8505 VAUX3 3.05 V setting 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-2-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 AB8505 has an additional VAUX3 voltage setting which is not encoded in the normal three-bit selector. ArmRegu2.Vaux3Sel3 overrides that selector and selects 3.05 V. Add the missing voltage and use the override bit as an extended selector. Program the ordinary selector before clearing the override so VAUX3 does not briefly switch to a stale voltage. Reference: AB8505 User Manual, DM00046744 Rev 3, pp. 229 and 254 Fixes: 547f384f33db ("regulator: ab8500: add support for ab8505") Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 101 +++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index ca59406d42a8..07d96f8ff944 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -173,6 +173,7 @@ struct ab8500_shared_mode { * @voltage_bank: bank to control regulator voltage * @voltage_reg: register to control regulator voltage * @voltage_mask: mask to control regulator voltage + * @expand_register: additional register used to select an extra voltage */ struct ab8500_regulator_info { struct device *dev; @@ -193,6 +194,12 @@ struct ab8500_regulator_info { u8 voltage_bank; u8 voltage_reg; u8 voltage_mask; + struct { + u8 voltage_limit; + u8 voltage_bank; + u8 voltage_reg; + u8 voltage_mask; + } expand_register; }; =20 /* voltage tables for the vauxn/vintcore supplies */ @@ -226,6 +233,18 @@ static const unsigned int ldo_vaux3_voltages[] =3D { 2910000, }; =20 +static const unsigned int ldo_vaux3_ab8505_voltages[] =3D { + 1200000, + 1500000, + 1800000, + 2100000, + 2500000, + 2750000, + 2790000, + 2910000, + 3050000, +}; + static const unsigned int ldo_vaux56_voltages[] =3D { 1800000, 1050000, @@ -593,6 +612,64 @@ static int ab8500_regulator_set_voltage_sel(struct reg= ulator_dev *rdev, return ret; } =20 +static int ab8500_regulator_get_voltage_sel_expand(struct regulator_dev *r= dev) +{ + struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); + u8 regval; + int ret; + + if (!info) + return -EINVAL; + + ret =3D abx500_get_register_interruptible(info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, ®val); + if (ret < 0) { + dev_err(rdev_get_dev(rdev), + "couldn't read voltage expand reg for regulator\n"); + return ret; + } + + if (regval & info->expand_register.voltage_mask) + return info->expand_register.voltage_limit; + + return ab8500_regulator_get_voltage_sel(rdev); +} + +static int ab8500_regulator_set_voltage_sel_expand(struct regulator_dev *r= dev, + unsigned int selector) +{ + struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); + u8 regval; + int ret; + + if (!info) + return -EINVAL; + + if (selector > info->expand_register.voltage_limit) + return -EINVAL; + + if (selector < info->expand_register.voltage_limit) { + ret =3D ab8500_regulator_set_voltage_sel(rdev, selector); + if (ret < 0) + return ret; + + regval =3D 0; + } else { + regval =3D info->expand_register.voltage_mask; + } + + ret =3D abx500_mask_and_set_register_interruptible(info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, + info->expand_register.voltage_mask, regval); + if (ret < 0) + dev_err(rdev_get_dev(rdev), + "couldn't set voltage expand reg for regulator\n"); + + return ret; +} + static const struct regulator_ops ab8500_regulator_volt_mode_ops =3D { .enable =3D ab8500_regulator_enable, .disable =3D ab8500_regulator_disable, @@ -605,6 +682,18 @@ static const struct regulator_ops ab8500_regulator_vol= t_mode_ops =3D { .list_voltage =3D regulator_list_voltage_table, }; =20 +static const struct regulator_ops ab8500_regulator_volt_mode_expand_ops = =3D { + .enable =3D ab8500_regulator_enable, + .disable =3D ab8500_regulator_disable, + .is_enabled =3D ab8500_regulator_is_enabled, + .get_optimum_mode =3D ab8500_regulator_get_optimum_mode, + .set_mode =3D ab8500_regulator_set_mode, + .get_mode =3D ab8500_regulator_get_mode, + .get_voltage_sel =3D ab8500_regulator_get_voltage_sel_expand, + .set_voltage_sel =3D ab8500_regulator_set_voltage_sel_expand, + .list_voltage =3D regulator_list_voltage_table, +}; + static const struct regulator_ops ab8500_regulator_volt_ops =3D { .enable =3D ab8500_regulator_enable, .disable =3D ab8500_regulator_disable, @@ -908,12 +997,12 @@ static struct ab8500_regulator_info [AB8505_LDO_AUX3] =3D { .desc =3D { .name =3D "LDO-AUX3", - .ops =3D &ab8500_regulator_volt_mode_ops, + .ops =3D &ab8500_regulator_volt_mode_expand_ops, .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_LDO_AUX3, .owner =3D THIS_MODULE, - .n_voltages =3D ARRAY_SIZE(ldo_vaux3_voltages), - .volt_table =3D ldo_vaux3_voltages, + .n_voltages =3D ARRAY_SIZE(ldo_vaux3_ab8505_voltages), + .volt_table =3D ldo_vaux3_ab8505_voltages, }, .load_lp_uA =3D 5000, .update_bank =3D 0x04, @@ -925,6 +1014,12 @@ static struct ab8500_regulator_info .voltage_bank =3D 0x04, .voltage_reg =3D 0x21, .voltage_mask =3D 0x07, + .expand_register =3D { + .voltage_limit =3D 8, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x01, + .voltage_mask =3D 0x10, + }, }, [AB8505_LDO_AUX4] =3D { .desc =3D { --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 486803E95B2 for ; Mon, 14 Sep 2026 07:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371969; cv=none; b=r1CLwszzdBY83FVqdHnB0Nm9YykdCSrg1qJyUPlF2LeIcvsPSA7tM22wupJwKwyfOdX/ohgag8TKUYLITCPYN0fLI5I78QK7XFg6HeixPlqwVsThXq1uCmw2iw6UxbNmnvJ13+tM/U+ZWh3x9h/L/gGCKSJdmp8qlDAqXDzJEuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371969; c=relaxed/simple; bh=cB+fFscuIXMfLe/OVF0fbusXR/2htOwHCywwC00gyro=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cHfnWZPQe3jReuGBTLmkxMl6rMNbQQbjGTQn3404YEvPK+ogEIFcohvQ5i11DcvY8w3SNzPHAyfHXcNMnZVvlW8LpaFIvrBLic8wkwAx4ChGrvLIWlSAj9V+S2R2sd86kLeE2B69MgBc17PcO0BL3QTQZQIrh1yC6WrY9FjN46o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JxoK2+fa; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JxoK2+fa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7D911F00893; Mon, 14 Sep 2026 07:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371968; bh=uadjvHfGlhBu4sVq6tllQ+UPTpmDztODzyfXrEERPV8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=JxoK2+fasVkUdZzSD0cNvjk/bQT5L9hxsnn8fjFsnkJxn9jrkpk+205KB/i+NnIDN oz58TJ+o0QeXgVa/IIEfGs40ssveEQzJz/CkLIUfjLrqtKoZk5RRzsvwTJdf6jnCIp yKQwFWzSF+QuxxrxCuKHgahi20H8nHbtQORemrry7m9dTr7/U0v3jlsMK2sVc57EDQ 1IYMkGd03XoJQOxCFl+mQUuG6VWKDSulZTAX0lYmvNIhziV8DmZETCnPESH2Xuc0XX 65yF9g1G0ZYmb+wMYa19kn7P5woWscW5BmXL97DW06l7Kr6fS3iMli5gmJGF2QMKvm BHuINNRAQm+NA== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:02 +0200 Subject: [PATCH v3 03/10] regulator: ab8500: Handle AB8505 VINTCORE selector 7 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-3-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 The AB8505 VINTCORE table exposes only selectors 0 through 6. The hardware also accepts selector 7 and maps it to 1.35 V, just like selector 6. Omitting it can make an OTP-programmed selector 7 appear invalid to the regulator core. Give AB8505 its own eight-entry selector table while leaving the AB8500 table unchanged. Reference: AB8505 User Manual, DM00046744 Rev 3, p. 223 Fixes: 547f384f33db ("regulator: ab8500: add support for ab8505") Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 07d96f8ff944..5e24e6cdc773 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -266,6 +266,17 @@ static const unsigned int ldo_vintcore_voltages[] =3D { 1350000, }; =20 +static const unsigned int ldo_vintcore_ab8505_voltages[] =3D { + 1200000, + 1225000, + 1250000, + 1275000, + 1300000, + 1325000, + 1350000, + 1350000, +}; + static const unsigned int fixed_1200000_voltage[] =3D { 1200000, }; @@ -1095,8 +1106,8 @@ static struct ab8500_regulator_info .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_LDO_INTCORE, .owner =3D THIS_MODULE, - .n_voltages =3D ARRAY_SIZE(ldo_vintcore_voltages), - .volt_table =3D ldo_vintcore_voltages, + .n_voltages =3D ARRAY_SIZE(ldo_vintcore_ab8505_voltages), + .volt_table =3D ldo_vintcore_ab8505_voltages, }, .load_lp_uA =3D 5000, .update_bank =3D 0x03, --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3B1D73E51D3 for ; Mon, 14 Sep 2026 07:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371971; cv=none; b=Nj8shJ0tVOi9l3PVWr+M2u/O3YwxDD2Suy0yHf/RQI+m0PuIxPXLWBoWG3sdILULFYHfhTT8STS6jmVf6++S0F4PwAW5d9taYLam+QllRaFSr06g9T9UCrMDwmsm4Ezx5npnV1kXfvVVnmOyHLHTETY2OIrT5xNiZ77xszKugYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371971; c=relaxed/simple; bh=5L7BeYhXO/6uJ84EQV5MJCSYczZ7+SYHAwWJcZPwu9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W3EJlaGaHoBRShwJi1fe9h76z3uTwxG4T4aK7y23nE2bLsmH+sQfSiPT9nviHbzDHnXEKcRxyPh7SOw0o5tUbnfaAcqX7AAM60haUSMNm03BnV08REg+OpfjQRrmaeMXFwonpgxrTg627b4eQJqOTZsCvOxKIOoscG2moQTCAd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o0Uvry2R; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o0Uvry2R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 928D61F000FF; Mon, 14 Sep 2026 07:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371969; bh=W7I499jooT1wgVBKh3MKxZ2T8LqsKbR+3xzF5b+GSow=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=o0Uvry2R/cF8chYJ3SCd5f0d0RMSOxkaZ1wWUGPqZ6hzmpX7x2WH90eof50OawtK6 xqEJjznor17hEFf6oIaGwoqIG+zAa+qbIj4JIlL8VoyvwEiyvplGgUwyvcLeCM4vWU CDxji9iF9DKheYlabfMQ8MQ8O39hjbJIzzXVe9X63JIWCHcWIk4aYIezV+gosjMIQi he+Ik+9kijSJSucyd2GPNV9Ugra2os1H/of6KndMq5hdSJnQB3759CznmNsKaif8yr R3vBCapOxpCnzehSZD9bj3pVCrBFQKb00EVqElqaigVdOqjMsVxOfWHJdTaKmY7ogu dRPHKqixf5kfQ== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:03 +0200 Subject: [PATCH v3 04/10] regulator: ab8500: Treat cut 1.0 VAUX3 as fixed 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-4-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 The early-cut workaround currently gives AB8500 cut 1.0 the 16 programmable VAUX3 settings introduced with cut 1.1. On cut 1.0 the selector is not programmable and VAUX3 is fixed at 1.2 V. Register VAUX3 as a fixed-voltage regulator on cut 1.0 and retain the 16-value workaround only for cut 1.1. Reference: AB8500 User Manual, UM0836 Rev 3, p. 240 Fixes: 2b75151a1041 ("regulators: Added ab8500 v2 support") Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 5e24e6cdc773..42cb8dfdc7c9 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -1783,9 +1783,14 @@ static int ab8500_regulator_register(struct platform= _device *pdev, config.driver_data =3D info; config.of_node =3D np; =20 - /* fix for hardware before ab8500v2.0 */ - if (is_ab8500_1p1_or_earlier(ab8500)) { - if (info->desc.id =3D=3D AB8500_LDO_AUX3) { + /* Handle the different VAUX3 implementations in early AB8500 cuts. */ + if (info->desc.id =3D=3D AB8500_LDO_AUX3) { + if (is_ab8500_1p0_or_earlier(ab8500)) { + info->desc.ops =3D &ab8500_regulator_mode_ops; + info->desc.n_voltages =3D 1; + info->desc.volt_table =3D fixed_1200000_voltage; + info->voltage_mask =3D 0; + } else if (is_ab8500_1p1_or_earlier(ab8500)) { info->desc.n_voltages =3D ARRAY_SIZE(ldo_vauxn_voltages); info->desc.volt_table =3D ldo_vauxn_voltages; --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 467633F4831 for ; Mon, 14 Sep 2026 07:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371973; cv=none; b=QA3kkO6zlQ4aCBTZnrTCBZ06ZuxiVUegF77zYzwV/rouaXjcVrCynfviHY3jwkIYTe5zolwG/ItUB5ve4Jzq1X9phvui/CP9nKRh4ZlymffcJeFVH70z/XoleQEiO3BY2/KwT6E29H7aA85L2GnKcllKDdVxmmv7Cyh7Gg/kBuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371973; c=relaxed/simple; bh=sm7o6cCzp8flppDMwW5Z+rofLj0ey1Q6EInHqIwTGW8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kqFpOq6UB4+tjMTkgvmd7XA7TjeGFdwu23NvCoDKePRcVGucm+6Y2Mq8c+3G9hh5aLf98TNqE5v7oaolinbezV9Cfwphq6v5rQYI3ny90KmgFAJ52HwphFalNS/ycx2Xca+9EKY46WTWA0RKyl/Hf4CWKvCM7QOYog3fSum5k6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B4PM/Xxr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B4PM/Xxr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DD141F00893; Mon, 14 Sep 2026 07:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371971; bh=cYxLvSFl/YWS+JRovkLaSv4pMP7UxSGmiLqc9zYTVx0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=B4PM/XxrZwSCkND9Ny2qARrx0g+X1mjy0RsF1ROFtiIlIQJGGBrYYkRfUX1YxtQCg CteJLTYlpAHORWlqpRIIAkvX5i89j5ObKZf4cEIoRvaWZAkKO5qTrAcjZU0O4vVs/x 2teQPVSyATSx/FdDUssha5ZR5RZxsswMnMkVwyQ8kCpNQgJjS/PcMrieIpA2h6BfZf zfzNmndwze6TULGQUd8W3L2sZp38VT+qtZjQfvOCfqTnvDE6Bbjcbne110iTevkrnB eH5F9jHCDqNMoIUlp0FOfHLkNSUhOBjBYO1Cq/Tk/jn70FJPcA2bMbEMupC7XQdmXM UeB/Lrdf2Py+A== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:04 +0200 Subject: [PATCH v3 05/10] regulator: ab8500: Test dedicated enable bits only 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-5-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 Some regulator control registers have independent enable and low-power bits. is_enabled() currently tests their combined update mask, so an off regulator with its low-power bit set is incorrectly reported as enabled. Add an optional enable mask and use it for VINTCORE, AB8500 TVOUT, AB8505 ADC, and AB8505 VAUX5/6. Regulators whose two-bit field encodes the complete operating state continue to test the full update mask. References: AB8500 User Manual, UM0836 Rev 3, p. 214; AB8505 User Manual, DM00046744 Rev 3, pp. 171-172 and 223 Fixes: 65e03ed2d0cd ("regulators: Fixed errors in ab8500 register mapping") Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 42cb8dfdc7c9..05c6b9c7af0c 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -162,6 +162,7 @@ struct ab8500_shared_mode { * @update_bank: bank to control on/off * @update_reg: register to control on/off * @update_mask: mask to enable/disable and set mode of regulator + * @enable_mask: optional mask for an enable bit separate from the mode bit * @update_val: bits holding the regulator current mode * @update_val_idle: bits to enable the regulator in idle (low power) mode * @update_val_normal: bits to enable the regulator in normal (high power)= mode @@ -183,6 +184,7 @@ struct ab8500_regulator_info { u8 update_bank; u8 update_reg; u8 update_mask; + u8 enable_mask; u8 update_val; u8 update_val_idle; u8 update_val_normal; @@ -377,6 +379,7 @@ static int ab8500_regulator_is_enabled(struct regulator= _dev *rdev) { int ret; struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); + u8 enable_mask; u8 regval; =20 if (info =3D=3D NULL) { @@ -392,13 +395,15 @@ static int ab8500_regulator_is_enabled(struct regulat= or_dev *rdev) return ret; } =20 + enable_mask =3D info->enable_mask ? info->enable_mask : info->update_mask; + dev_vdbg(rdev_get_dev(rdev), "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," " 0x%x\n", info->desc.name, info->update_bank, info->update_reg, - info->update_mask, regval); + enable_mask, regval); =20 - if (regval & info->update_mask) + if (regval & enable_mask) return 1; else return 0; @@ -833,6 +838,7 @@ static struct ab8500_regulator_info .update_bank =3D 0x03, .update_reg =3D 0x80, .update_mask =3D 0x44, + .enable_mask =3D 0x04, .update_val =3D 0x44, .update_val_idle =3D 0x44, .update_val_normal =3D 0x04, @@ -861,6 +867,7 @@ static struct ab8500_regulator_info .update_bank =3D 0x03, .update_reg =3D 0x80, .update_mask =3D 0x82, + .enable_mask =3D 0x02, .update_val =3D 0x02, .update_val_idle =3D 0x82, .update_val_normal =3D 0x02, @@ -1070,6 +1077,7 @@ static struct ab8500_regulator_info .update_bank =3D 0x01, .update_reg =3D 0x55, .update_mask =3D 0x18, + .enable_mask =3D 0x10, .update_val =3D 0x10, .update_val_idle =3D 0x18, .update_val_normal =3D 0x10, @@ -1092,6 +1100,7 @@ static struct ab8500_regulator_info .update_bank =3D 0x01, .update_reg =3D 0x56, .update_mask =3D 0x18, + .enable_mask =3D 0x10, .update_val =3D 0x10, .update_val_idle =3D 0x18, .update_val_normal =3D 0x10, @@ -1113,6 +1122,7 @@ static struct ab8500_regulator_info .update_bank =3D 0x03, .update_reg =3D 0x80, .update_mask =3D 0x44, + .enable_mask =3D 0x04, .update_val =3D 0x04, .update_val_idle =3D 0x44, .update_val_normal =3D 0x04, @@ -1141,6 +1151,7 @@ static struct ab8500_regulator_info .update_bank =3D 0x03, .update_reg =3D 0x80, .update_mask =3D 0x82, + .enable_mask =3D 0x02, .update_val =3D 0x02, .update_val_idle =3D 0x82, .update_val_normal =3D 0x02, --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 73A473F4DD6 for ; Mon, 14 Sep 2026 07:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371974; cv=none; b=czc+HFja0RHlPTU20SBwh6rc4AWF1lvsjpRPjpjevXlfWPLNF2H0dBQDVN6qjxi3oENqqIaukNZMPOXR69aJ6CarLJIGo/r/Yp1TpkugWfrUdpXn7PkB1MxftN04bgsgxEf8T9wVoEh7Se8hlqthdAIZS44lz5yOASM+TDLSKCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371974; c=relaxed/simple; bh=Dv/QiirNXaEGGNxNMEdOvs71nxTnxu7bZFGiiKUplfk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=vCQgIDK5TQx/QziaKAaSXcRdu/rquibrOmaEdBho3/dE82W25IRuBUwOfZ2orjF8JFcIhpCWwa+MYgwgISV+98UOAD9s7sNjiMR2wWRd9lYzX4mx3zG3UCF0aSLoIRYnl2602elF9fzPuu3ufCXDQhfszd/WGVLAk3lPFanaxrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dcfy7cpD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dcfy7cpD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD7451F000FF; Mon, 14 Sep 2026 07:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371973; bh=bMZt0GB7fomwJcSjpqK2GXhF/LZOwUajUGEkniPFZLE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=dcfy7cpDgeCDXHHMQu/QiW2ZZgaAR4e29sYuHgFrVBADiD4uaz/2fAngVJiq2Y3qi rQB+CGdWKTlRXoZxcbq6DLvrs+DI4I7zJZ5+t4GBCphmlHhtrSvMJz3CGD7LIvNkXw AvtO9Ab6KVL6lbBpcLaqkwp1MFBGyIBc+0yQnWEOzZIcr6xH8jg6XGmEv6GJJwNdEh FIfgKha1Dz6m9kW0MYgL0G4fSbRV3aTJX0xJQw7EMjwPe+fXQaPEL1Og8FGGtvNOgb RzpSUDNR3p6YGijbgvP8X+H2bV0dOCFIm30g7t7xTmkW1wxzabV58RsxV3ZGmfSTUE 6VXy/xr4GpCdw== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:05 +0200 Subject: [PATCH v3 06/10] regulator: ab8500: Propagate mode enable read errors 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-6-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 For regulators whose enable and mode share a state field, set_mode() first reads that field so changing the requested mode does not enable a disabled rail. A register read error is currently treated as true and the driver proceeds to write the new mode, potentially enabling a rail whose state is unknown. Return the read error without changing the register or cached mode. References: AB8500 User Manual, UM0836 Rev 3, p. 227; AB8505 User Manual, DM00046744 Rev 3, p. 237 Fixes: 438e695b87e0 ("regulator: ab8500: Get rid of is_enabled from struct = ab8500_regulator_info") Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 05c6b9c7af0c..e4c3502c8dbc 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -433,7 +433,7 @@ static unsigned int ab8500_regulator_get_optimum_mode( static int ab8500_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode) { - int ret =3D 0; + int enabled, ret =3D 0; u8 bank, reg, mask, val; bool lp_mode_req =3D false; struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); @@ -490,7 +490,17 @@ static int ab8500_regulator_set_mode(struct regulator_= dev *rdev, goto out_unlock; } =20 - if (info->mode_mask || ab8500_regulator_is_enabled(rdev)) { + if (info->mode_mask) { + enabled =3D 1; + } else { + enabled =3D ab8500_regulator_is_enabled(rdev); + if (enabled < 0) { + ret =3D enabled; + goto out_unlock; + } + } + + if (enabled) { ret =3D abx500_mask_and_set_register_interruptible(info->dev, bank, reg, mask, val); if (ret < 0) { --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2CFC73F4859 for ; Mon, 14 Sep 2026 07:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371976; cv=none; b=ioj3+sGPahvRPw+53P/tKw2Gw7bHDREaOWfiJMevQiOpqFzfw9j2r+2CP+WLFfwAUj/0+l8pTHmGKYUJ0zHrG1ePBkI76WKjAv3ZNT6P3yzWlpCpfhyTCsTtmE2aemmUxJe94Cfidk7FBBsUctZiovEbF+Ub7sW6Lj0SPaVq1Y4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371976; c=relaxed/simple; bh=o2g5BJsdLmgKohvdPEwdQASKwo6XZOlBHx9JkteNmOM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JVSV6WnsjXwaoZ7N7PJDpuYFb8AQxMNkjAGtSN4AKYNzrixhJdShj1CURS2SB/9a3qVRtNUCSNYxntgyn68y1R80jcN51pWR6H5F39MJRF2A1u16HNuYuI0Z0kyq3UyaymVHNfvP+o71yYfYtfh7IF2Jn6Zr3l8W69MSwFyhrL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XVu+S3zH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XVu+S3zH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88B241F00898; Mon, 14 Sep 2026 07:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371974; bh=XgsPq9RhCd3/kciawcNEGIUOwsxaXN47MCNNBD2JLps=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=XVu+S3zH69dhsk5mEq0h7vPyasVe6Fx0QcGOnJYFvtB3ng0W28ZV/iaNE+onKEafd m+TvZ92bDhojXe69or3SIuXOtTMrrJIkqNaIqwZYEZ4sdtqeVAbb2K53AdFNRARmah Z3eYvyM2Q9wr5q9+wsYqHNVTdgXhBQ0a7vOjokMImKfbYFLfmXqetqlOd8FNNzyJeO 8QnFs0OUUcMuyv+wGwkR+3HepGwQFbjDqHj7uDY/xdEG0H2NT+U1+adhfSS4XtcrBq gLIAS2btcH4BRFgRtNtqAKlLWAfqs7fBJ8vTDh3Ia16DbEdlwDU4oTcdsItzmechly S0lqwfcqMJ9AA== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:06 +0200 Subject: [PATCH v3 07/10] regulator: ab8500: Use linear ranges for LDO voltages 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-7-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 VINTCORE uses consecutive selectors with uniform 25 mV steps, with AB8505 duplicating the highest voltage at selector 7. AB8505 VAUDIO likewise has uniform 100 mV steps followed by a duplicate selector for its highest voltage. Describe these selector encodings with linear ranges and the matching regulator helpers instead of enumerated voltage tables. Keep tables for the irregular and non-monotonic VAUX and VANA selectors. Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 74 +++++++++++++++++++++++-------------------= ---- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index e4c3502c8dbc..d1540099104c 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -258,25 +258,13 @@ static const unsigned int ldo_vaux56_voltages[] =3D { 2790000, }; =20 -static const unsigned int ldo_vintcore_voltages[] =3D { - 1200000, - 1225000, - 1250000, - 1275000, - 1300000, - 1325000, - 1350000, +static const struct linear_range ldo_vintcore_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1200000, 0, 6, 25000), }; =20 -static const unsigned int ldo_vintcore_ab8505_voltages[] =3D { - 1200000, - 1225000, - 1250000, - 1275000, - 1300000, - 1325000, - 1350000, - 1350000, +static const struct linear_range ldo_vintcore_ab8505_ranges[] =3D { + REGULATOR_LINEAR_RANGE(1200000, 0, 6, 25000), + REGULATOR_LINEAR_RANGE(1350000, 7, 7, 0), }; =20 static const unsigned int fixed_1200000_voltage[] =3D { @@ -306,15 +294,10 @@ static const unsigned int ldo_vana_voltages[] =3D { 1225000, }; =20 -static const unsigned int ldo_vaudio_voltages[] =3D { - 2000000, - 2100000, - 2200000, - 2300000, - 2400000, - 2500000, - 2600000, - 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */ +static const struct linear_range ldo_vaudio_ranges[] =3D { + REGULATOR_LINEAR_RANGE(2000000, 0, 6, 100000), + /* Duplicated in Vaudio and IsoUicc Control register. */ + REGULATOR_LINEAR_RANGE(2600000, 7, 7, 0), }; =20 static DEFINE_MUTEX(shared_mode_mutex); @@ -720,13 +703,27 @@ static const struct regulator_ops ab8500_regulator_vo= lt_mode_expand_ops =3D { .list_voltage =3D regulator_list_voltage_table, }; =20 -static const struct regulator_ops ab8500_regulator_volt_ops =3D { +static const struct regulator_ops ab8500_regulator_linear_range_volt_mode_= ops =3D { + .enable =3D ab8500_regulator_enable, + .disable =3D ab8500_regulator_disable, + .is_enabled =3D ab8500_regulator_is_enabled, + .get_optimum_mode =3D ab8500_regulator_get_optimum_mode, + .set_mode =3D ab8500_regulator_set_mode, + .get_mode =3D ab8500_regulator_get_mode, + .get_voltage_sel =3D ab8500_regulator_get_voltage_sel, + .set_voltage_sel =3D ab8500_regulator_set_voltage_sel, + .list_voltage =3D regulator_list_voltage_linear_range, + .map_voltage =3D regulator_map_voltage_linear_range, +}; + +static const struct regulator_ops ab8500_regulator_linear_range_volt_ops = =3D { .enable =3D ab8500_regulator_enable, .disable =3D ab8500_regulator_disable, .is_enabled =3D ab8500_regulator_is_enabled, .get_voltage_sel =3D ab8500_regulator_get_voltage_sel, .set_voltage_sel =3D ab8500_regulator_set_voltage_sel, - .list_voltage =3D regulator_list_voltage_table, + .list_voltage =3D regulator_list_voltage_linear_range, + .map_voltage =3D regulator_map_voltage_linear_range, }; =20 static const struct regulator_ops ab8500_regulator_mode_ops =3D { @@ -836,12 +833,13 @@ static struct ab8500_regulator_info [AB8500_LDO_INTCORE] =3D { .desc =3D { .name =3D "LDO-INTCORE", - .ops =3D &ab8500_regulator_volt_mode_ops, + .ops =3D &ab8500_regulator_linear_range_volt_mode_ops, .type =3D REGULATOR_VOLTAGE, .id =3D AB8500_LDO_INTCORE, .owner =3D THIS_MODULE, - .n_voltages =3D ARRAY_SIZE(ldo_vintcore_voltages), - .volt_table =3D ldo_vintcore_voltages, + .n_voltages =3D 7, + .linear_ranges =3D ldo_vintcore_ranges, + .n_linear_ranges =3D ARRAY_SIZE(ldo_vintcore_ranges), .enable_time =3D 750, }, .load_lp_uA =3D 5000, @@ -1121,12 +1119,13 @@ static struct ab8500_regulator_info [AB8505_LDO_INTCORE] =3D { .desc =3D { .name =3D "LDO-INTCORE", - .ops =3D &ab8500_regulator_volt_mode_ops, + .ops =3D &ab8500_regulator_linear_range_volt_mode_ops, .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_LDO_INTCORE, .owner =3D THIS_MODULE, - .n_voltages =3D ARRAY_SIZE(ldo_vintcore_ab8505_voltages), - .volt_table =3D ldo_vintcore_ab8505_voltages, + .n_voltages =3D 8, + .linear_ranges =3D ldo_vintcore_ab8505_ranges, + .n_linear_ranges =3D ARRAY_SIZE(ldo_vintcore_ab8505_ranges), }, .load_lp_uA =3D 5000, .update_bank =3D 0x03, @@ -1169,12 +1168,13 @@ static struct ab8500_regulator_info [AB8505_LDO_AUDIO] =3D { .desc =3D { .name =3D "LDO-AUDIO", - .ops =3D &ab8500_regulator_volt_ops, + .ops =3D &ab8500_regulator_linear_range_volt_ops, .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_LDO_AUDIO, .owner =3D THIS_MODULE, - .n_voltages =3D ARRAY_SIZE(ldo_vaudio_voltages), - .volt_table =3D ldo_vaudio_voltages, + .n_voltages =3D 8, + .linear_ranges =3D ldo_vaudio_ranges, + .n_linear_ranges =3D ARRAY_SIZE(ldo_vaudio_ranges), }, .update_bank =3D 0x03, .update_reg =3D 0x83, --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AB4223F8243 for ; Mon, 14 Sep 2026 07:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371978; cv=none; b=nkef5Z76zaR15+9Xa+IP9z0ZgC77vzmL1nJCcnv4HNkvucxolUJWGFblBtbgpZPQ/b14hZLhqgpkSyFPWIKspm0bibz4yndeMid9QSXZGxABMATjabKs2f4gR90SdcZAvSAiMC3ZiniylMRPAUeyUFKe7n2pAZYsm38NA45Ea2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371978; c=relaxed/simple; bh=MT8sDGgmi+VnXl2CGP2Enoev1en9znyBtD06gddifuw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M2Ba2vdGAmJfHCSCSiyj8Pswi3ZtfS/zXHWHTWOD4NExYNFUhHWJyyoj1BalYdc/6+o4/Rc89zobHoyEGMjefy9dGRMaBdIPMc3w1rSLSRTkmeEKYp4GyUGLdX3JtpZMCipVeUKV1b1iywqbFGoOKd2vrVG1FYqJTeuiNHuafUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kWliG36t; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kWliG36t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 341D91F000FF; Mon, 14 Sep 2026 07:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371976; bh=JllXSUHy+b3zdtDBvkgrDgyujMMYgJPstjjx5MbnyKk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=kWliG36tDIHYc8I2yrBcYz+4A6fDMgttFglDiRLU9C6o2pnKfz2UM2WYgPB1HgE5H 3aU1Z/aTB+S0AqqP8NHAWyMfxLF2kr8wALPf1kcnSkWEw1GQs7ee+qQ/l6VKFRUCx4 TizgSNMQd3QI+rNqZR01akbyYWc9/Sz7CV77LwzRCnLFRm3DsphIWLl4F1wMOt+Q6h E70e4q0mw+G8hPV9pWv3CnjMDveMlkWvAWNNROTfrpjUNG+/bnhzRguN4vPFfd/6qJ /lx2lP/0ufwMOwvVSDN0ebdVSdPE3uwG4DAHy9fayt/FqNWqSC5ocyBbDre0CsFnQL NrjEb2VZZlb7g== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:07 +0200 Subject: [PATCH v3 08/10] regulator: ab8500: Add buck converter support 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-8-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 Register the SMPS1, SMPS2, SMPS3, ARM, APE and MOD buck converters on AB8500 and the VSMPSA, VSMPSB, VSAFE, VARM, VSMPSC and VSMPSM buck converters on AB8505 so that the new device tree nodes can supply consumers. Match each variant through its own device tree node names. AB8500 SMPS3 supplies Vsafe and AB8505 VSAFE occupies the corresponding control and selector registers at 0x0405 and 0x041b through 0x041d. AB8500 VAPE and AB8505 VSMPSC instead use 0x0402 and the 0x040e through 0x0410 selector registers. Keep separate AB8505 regulator descriptors and identifiers so these variant-specific rails are not conflated. Describe the hardware selector ranges and follow the selector-control registers when reading or changing voltage. This accounts for AB8505 using Sel2 after reset, its additional selector registers and its separate 7-bit VARM range. Use the AB8500-compatible and low-range OTP profiles found on the supported platforms for the other rails. SMPS1 through SMPS3 and VSMPSA, VSMPSB and VSAFE also expose enable and low-power mode control. Keep the ARM, APE, MOD, VARM, VSMPSC and VSMPSM rails voltage-only since their on/off state is managed with the SoC. Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 461 +++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 452 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index d1540099104c..130febf2680a 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -9,10 +9,12 @@ * AB8500 peripheral regulators * * AB8500 supports the following regulators: - * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA + * VSMPS1/2/3, VARM, VAPE, VMOD, VAUX1/2/3, VINTCORE, VTVOUT, + * VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA * * AB8505 supports the following regulators: - * VAUX1/2/3/4/5/6, VINTCORE, VADC, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA + * VSMPSA/B/C/M, VSAFE, VARM, VAUX1/2/3/4/5/6, VINTCORE, + * VADC, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA */ #include #include @@ -39,6 +41,12 @@ enum ab8500_regulator_id { AB8500_LDO_ANAMIC2, AB8500_LDO_DMIC, AB8500_LDO_ANA, + AB8500_BUCK_SMPS1, + AB8500_BUCK_SMPS2, + AB8500_BUCK_SMPS3, + AB8500_BUCK_ARM, + AB8500_BUCK_APE, + AB8500_BUCK_MOD, AB8500_NUM_REGULATORS, }; =20 @@ -57,6 +65,12 @@ enum ab8505_regulator_id { AB8505_LDO_ANAMIC2, AB8505_LDO_AUX8, AB8505_LDO_ANA, + AB8505_BUCK_SMPSA, + AB8505_BUCK_SMPSB, + AB8505_BUCK_SAFE, + AB8505_BUCK_ARM, + AB8505_BUCK_SMPSC, + AB8505_BUCK_SMPSM, AB8505_NUM_REGULATORS, }; =20 @@ -172,9 +186,17 @@ struct ab8500_shared_mode { * @mode_val_idle: mode setting for low power * @mode_val_normal: mode setting for normal power * @voltage_bank: bank to control regulator voltage - * @voltage_reg: register to control regulator voltage + * @voltage_reg: first register containing a selectable regulator voltage * @voltage_mask: mask to control regulator voltage * @expand_register: additional register used to select an extra voltage + * @voltage_ctrl_bank: bank containing the voltage selector control + * @voltage_ctrl_reg: register containing the voltage selector control + * @voltage_ctrl_mask: mask selecting one of the first voltage registers + * @voltage_ext_ctrl_bank: bank containing the extended selector control + * @voltage_ext_ctrl_reg: register containing the extended selector control + * @voltage_ext_ctrl_mask: mask selecting one of the extended voltage regi= sters + * @voltage_ext_reg: first extended voltage register + * @voltage_ext_regs: number of extended voltage registers */ struct ab8500_regulator_info { struct device *dev; @@ -202,6 +224,14 @@ struct ab8500_regulator_info { u8 voltage_reg; u8 voltage_mask; } expand_register; + u8 voltage_ctrl_bank; + u8 voltage_ctrl_reg; + u8 voltage_ctrl_mask; + u8 voltage_ext_ctrl_bank; + u8 voltage_ext_ctrl_reg; + u8 voltage_ext_ctrl_mask; + u8 voltage_ext_reg; + u8 voltage_ext_regs; }; =20 /* voltage tables for the vauxn/vintcore supplies */ @@ -300,6 +330,40 @@ static const struct linear_range ldo_vaudio_ranges[] = =3D { REGULATOR_LINEAR_RANGE(2600000, 7, 7, 0), }; =20 +/* + * AB8505 buck ranges except VARM are selected by OTP. The supported + * platforms use the AB8500-compatible profiles for VSMPSA/B and the low + * profiles for VSAFE, VSMPSC and VSMPSM. + */ +static const struct linear_range buck_low_voltages[] =3D { + REGULATOR_LINEAR_RANGE(700000, 0, 53, 12500), + REGULATOR_LINEAR_RANGE(1362500, 54, 63, 0), +}; + +/* VSMPS3 and VSAFE have a 7-bit selector, but the same low range. */ +static const struct linear_range buck_low_7bit_voltages[] =3D { + REGULATOR_LINEAR_RANGE(700000, 0, 53, 12500), + REGULATOR_LINEAR_RANGE(1362500, 54, 127, 0), +}; + +/* AB8505 VARM uses a separate 0.6 V to 1.39375 V selector range. */ +static const struct linear_range ab8505_buck_arm_voltages[] =3D { + REGULATOR_LINEAR_RANGE(600000, 0, 127, 6250), +}; + +/* VSMPS1 and the VSMPSA AB8500-compatible profile clamp to this range. */ +static const struct linear_range buck_smps1_voltages[] =3D { + REGULATOR_LINEAR_RANGE(1100000, 0, 32, 0), + REGULATOR_LINEAR_RANGE(1112500, 33, 48, 12500), + REGULATOR_LINEAR_RANGE(1300000, 49, 63, 0), +}; + +/* VSMPS2 and the VSMPSB AB8500-compatible profile clamp to this range. */ +static const struct linear_range buck_smps2_voltages[] =3D { + REGULATOR_LINEAR_RANGE(1800000, 0, 57, 0), + REGULATOR_LINEAR_RANGE(1812500, 58, 63, 12500), +}; + static DEFINE_MUTEX(shared_mode_mutex); static struct ab8500_shared_mode ldo_anamic1_shared; static struct ab8500_shared_mode ldo_anamic2_shared; @@ -558,11 +622,67 @@ static unsigned int ab8500_regulator_get_mode(struct = regulator_dev *rdev) return ret; } =20 +static int ab8500_regulator_get_voltage_reg(struct regulator_dev *rdev, + u8 *voltage_reg) +{ + struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); + u8 regval; + unsigned int selector; + int ret; + + if (info->voltage_ext_ctrl_mask) { + ret =3D abx500_get_register_interruptible(info->dev, + info->voltage_ext_ctrl_bank, + info->voltage_ext_ctrl_reg, ®val); + if (ret < 0) + return ret; + + selector =3D (regval & info->voltage_ext_ctrl_mask) >> + (ffs(info->voltage_ext_ctrl_mask) - 1); + if (selector) { + selector =3D min_t(unsigned int, selector, + info->voltage_ext_regs); + *voltage_reg =3D info->voltage_ext_reg + selector - 1; + return 0; + } + } + + if (!info->voltage_ctrl_mask) { + *voltage_reg =3D info->voltage_reg; + return 0; + } + + ret =3D abx500_get_register_interruptible(info->dev, + info->voltage_ctrl_bank, + info->voltage_ctrl_reg, ®val); + if (ret < 0) + return ret; + + /* The three hardware selector layouts all use consecutive registers. */ + switch (info->voltage_ctrl_mask) { + case 0x0c: + selector =3D min((unsigned int)((regval & 0x0c) >> 2), 2U); + break; + case 0x24: + selector =3D regval & BIT(5) ? 2 : !!(regval & BIT(2)); + break; + case 0x04: + selector =3D !!(regval & BIT(2)); + break; + default: + return -EINVAL; + } + + *voltage_reg =3D info->voltage_reg + selector; + + return 0; +} + static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) { int ret, voltage_shift; struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); - u8 regval; + u8 regval, voltage_reg; =20 if (info =3D=3D NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); @@ -571,8 +691,15 @@ static int ab8500_regulator_get_voltage_sel(struct reg= ulator_dev *rdev) =20 voltage_shift =3D ffs(info->voltage_mask) - 1; =20 + ret =3D ab8500_regulator_get_voltage_reg(rdev, &voltage_reg); + if (ret < 0) { + dev_err(rdev_get_dev(rdev), + "couldn't read voltage selector control\n"); + return ret; + } + ret =3D abx500_get_register_interruptible(info->dev, - info->voltage_bank, info->voltage_reg, ®val); + info->voltage_bank, voltage_reg, ®val); if (ret < 0) { dev_err(rdev_get_dev(rdev), "couldn't read voltage reg for regulator\n"); @@ -583,7 +710,7 @@ static int ab8500_regulator_get_voltage_sel(struct regu= lator_dev *rdev) "%s-get_voltage (bank, reg, mask, shift, value): " "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", info->desc.name, info->voltage_bank, - info->voltage_reg, info->voltage_mask, + voltage_reg, info->voltage_mask, voltage_shift, regval); =20 return (regval & info->voltage_mask) >> voltage_shift; @@ -594,7 +721,7 @@ static int ab8500_regulator_set_voltage_sel(struct regu= lator_dev *rdev, { int ret, voltage_shift; struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); - u8 regval; + u8 regval, voltage_reg; =20 if (info =3D=3D NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); @@ -603,10 +730,17 @@ static int ab8500_regulator_set_voltage_sel(struct re= gulator_dev *rdev, =20 voltage_shift =3D ffs(info->voltage_mask) - 1; =20 + ret =3D ab8500_regulator_get_voltage_reg(rdev, &voltage_reg); + if (ret < 0) { + dev_err(rdev_get_dev(rdev), + "couldn't read voltage selector control\n"); + return ret; + } + /* set the registers for the request */ regval =3D (u8)selector << voltage_shift; ret =3D abx500_mask_and_set_register_interruptible(info->dev, - info->voltage_bank, info->voltage_reg, + info->voltage_bank, voltage_reg, info->voltage_mask, regval); if (ret < 0) dev_err(rdev_get_dev(rdev), @@ -615,7 +749,7 @@ static int ab8500_regulator_set_voltage_sel(struct regu= lator_dev *rdev, dev_vdbg(rdev_get_dev(rdev), "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," " 0x%x\n", - info->desc.name, info->voltage_bank, info->voltage_reg, + info->desc.name, info->voltage_bank, voltage_reg, info->voltage_mask, regval); =20 return ret; @@ -726,6 +860,26 @@ static const struct regulator_ops ab8500_regulator_lin= ear_range_volt_ops =3D { .map_voltage =3D regulator_map_voltage_linear_range, }; =20 +static const struct regulator_ops ab8500_buck_ops =3D { + .enable =3D ab8500_regulator_enable, + .disable =3D ab8500_regulator_disable, + .is_enabled =3D ab8500_regulator_is_enabled, + .get_optimum_mode =3D ab8500_regulator_get_optimum_mode, + .set_mode =3D ab8500_regulator_set_mode, + .get_mode =3D ab8500_regulator_get_mode, + .get_voltage_sel =3D ab8500_regulator_get_voltage_sel, + .set_voltage_sel =3D ab8500_regulator_set_voltage_sel, + .list_voltage =3D regulator_list_voltage_linear_range, + .map_voltage =3D regulator_map_voltage_linear_range, +}; + +static const struct regulator_ops ab8500_buck_voltage_ops =3D { + .get_voltage_sel =3D ab8500_regulator_get_voltage_sel, + .set_voltage_sel =3D ab8500_regulator_set_voltage_sel, + .list_voltage =3D regulator_list_voltage_linear_range, + .map_voltage =3D regulator_map_voltage_linear_range, +}; + static const struct regulator_ops ab8500_regulator_mode_ops =3D { .enable =3D ab8500_regulator_enable, .disable =3D ab8500_regulator_disable, @@ -967,6 +1121,137 @@ static struct ab8500_regulator_info .update_val_idle =3D 0x0c, .update_val_normal =3D 0x04, }, + + /* Buck converters */ + [AB8500_BUCK_SMPS1] =3D { + .desc =3D { + .name =3D "BUCK-SMPS1", + .ops =3D &ab8500_buck_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8500_BUCK_SMPS1, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_smps1_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_smps1_voltages), + }, + .load_lp_uA =3D 20000, + .update_bank =3D 0x04, + .update_reg =3D 0x03, + .update_mask =3D 0x03, + .update_val =3D 0x01, + .update_val_idle =3D 0x03, + .update_val_normal =3D 0x01, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x13, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x03, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8500_BUCK_SMPS2] =3D { + .desc =3D { + .name =3D "BUCK-SMPS2", + .ops =3D &ab8500_buck_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8500_BUCK_SMPS2, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_smps2_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_smps2_voltages), + }, + .load_lp_uA =3D 20000, + .update_bank =3D 0x04, + .update_reg =3D 0x04, + .update_mask =3D 0x03, + .update_val =3D 0x01, + .update_val_idle =3D 0x03, + .update_val_normal =3D 0x01, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x17, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x04, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8500_BUCK_SMPS3] =3D { + .desc =3D { + .name =3D "BUCK-SMPS3", + .ops =3D &ab8500_buck_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8500_BUCK_SMPS3, + .owner =3D THIS_MODULE, + .n_voltages =3D 128, + .linear_ranges =3D buck_low_7bit_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_7bit_voltages), + }, + .load_lp_uA =3D 50000, + .update_bank =3D 0x04, + .update_reg =3D 0x05, + .update_mask =3D 0x03, + .update_val =3D 0x01, + .update_val_idle =3D 0x03, + .update_val_normal =3D 0x01, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x1b, + .voltage_mask =3D 0x7f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x05, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8500_BUCK_ARM] =3D { + .desc =3D { + .name =3D "BUCK-ARM", + .ops =3D &ab8500_buck_voltage_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8500_BUCK_ARM, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_low_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_voltages), + }, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x0b, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x00, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8500_BUCK_APE] =3D { + .desc =3D { + .name =3D "BUCK-APE", + .ops =3D &ab8500_buck_voltage_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8500_BUCK_APE, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_low_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_voltages), + }, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x0e, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x02, + .voltage_ctrl_mask =3D 0x24, + }, + [AB8500_BUCK_MOD] =3D { + .desc =3D { + .name =3D "BUCK-MOD", + .ops =3D &ab8500_buck_voltage_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8500_BUCK_MOD, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_low_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_voltages), + }, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x41, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x40, + .voltage_ctrl_mask =3D 0x04, + }, }; =20 /* AB8505 regulator information */ @@ -1265,6 +1550,152 @@ static struct ab8500_regulator_info .voltage_reg =3D 0x29, .voltage_mask =3D 0x7, }, + + /* Buck converters */ + [AB8505_BUCK_SMPSA] =3D { + .desc =3D { + .name =3D "BUCK-SMPSA", + .ops =3D &ab8500_buck_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8505_BUCK_SMPSA, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_smps1_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_smps1_voltages), + }, + .load_lp_uA =3D 20000, + .update_bank =3D 0x04, + .update_reg =3D 0x03, + .update_mask =3D 0x03, + .update_val =3D 0x01, + .update_val_idle =3D 0x03, + .update_val_normal =3D 0x01, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x13, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x03, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8505_BUCK_SMPSB] =3D { + .desc =3D { + .name =3D "BUCK-SMPSB", + .ops =3D &ab8500_buck_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8505_BUCK_SMPSB, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_smps2_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_smps2_voltages), + }, + .load_lp_uA =3D 20000, + .update_bank =3D 0x04, + .update_reg =3D 0x04, + .update_mask =3D 0x03, + .update_val =3D 0x01, + .update_val_idle =3D 0x03, + .update_val_normal =3D 0x01, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x17, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x04, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8505_BUCK_SAFE] =3D { + .desc =3D { + .name =3D "BUCK-SAFE", + .ops =3D &ab8500_buck_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8505_BUCK_SAFE, + .owner =3D THIS_MODULE, + .n_voltages =3D 128, + .linear_ranges =3D buck_low_7bit_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_7bit_voltages), + }, + .load_lp_uA =3D 50000, + .update_bank =3D 0x04, + .update_reg =3D 0x05, + .update_mask =3D 0x03, + .update_val =3D 0x01, + .update_val_idle =3D 0x03, + .update_val_normal =3D 0x01, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x1b, + .voltage_mask =3D 0x7f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x05, + .voltage_ctrl_mask =3D 0x0c, + }, + [AB8505_BUCK_ARM] =3D { + .desc =3D { + .name =3D "BUCK-ARM", + .ops =3D &ab8500_buck_voltage_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8505_BUCK_ARM, + .owner =3D THIS_MODULE, + .n_voltages =3D 128, + .linear_ranges =3D ab8505_buck_arm_voltages, + .n_linear_ranges =3D ARRAY_SIZE(ab8505_buck_arm_voltages), + }, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x0b, + .voltage_mask =3D 0x7f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x00, + .voltage_ctrl_mask =3D 0x0c, + .voltage_ext_ctrl_bank =3D 0x04, + .voltage_ext_ctrl_reg =3D 0x28, + .voltage_ext_ctrl_mask =3D 0x07, + .voltage_ext_reg =3D 0x24, + .voltage_ext_regs =3D 4, + }, + [AB8505_BUCK_SMPSC] =3D { + .desc =3D { + .name =3D "BUCK-SMPSC", + .ops =3D &ab8500_buck_voltage_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8505_BUCK_SMPSC, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_low_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_voltages), + }, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x0e, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x02, + .voltage_ctrl_mask =3D 0x24, + .voltage_ext_ctrl_bank =3D 0x04, + .voltage_ext_ctrl_reg =3D 0x2a, + .voltage_ext_ctrl_mask =3D 0x03, + .voltage_ext_reg =3D 0x2b, + .voltage_ext_regs =3D 2, + }, + [AB8505_BUCK_SMPSM] =3D { + .desc =3D { + .name =3D "BUCK-SMPSM", + .ops =3D &ab8500_buck_voltage_ops, + .type =3D REGULATOR_VOLTAGE, + .id =3D AB8505_BUCK_SMPSM, + .owner =3D THIS_MODULE, + .n_voltages =3D 64, + .linear_ranges =3D buck_low_voltages, + .n_linear_ranges =3D ARRAY_SIZE(buck_low_voltages), + }, + .voltage_bank =3D 0x04, + .voltage_reg =3D 0x41, + .voltage_mask =3D 0x3f, + .voltage_ctrl_bank =3D 0x04, + .voltage_ctrl_reg =3D 0x40, + .voltage_ctrl_mask =3D 0x04, + .voltage_ext_ctrl_bank =3D 0x04, + .voltage_ext_ctrl_reg =3D 0x47, + .voltage_ext_ctrl_mask =3D 0x03, + .voltage_ext_reg =3D 0x45, + .voltage_ext_regs =3D 2, + }, }; =20 static struct ab8500_shared_mode ldo_anamic1_shared =3D { @@ -1740,6 +2171,12 @@ static struct of_regulator_match ab8500_regulator_ma= tch[] =3D { { .name =3D "ab8500_ldo_anamic2", .driver_data =3D (void *) AB8500_LDO_AN= AMIC2, }, { .name =3D "ab8500_ldo_dmic", .driver_data =3D (void *) AB8500_LDO_DM= IC, }, { .name =3D "ab8500_ldo_ana", .driver_data =3D (void *) AB8500_LDO_AN= A, }, + { .name =3D "ab8500_buck_smps1", .driver_data =3D (void *)AB8500_BUCK_SM= PS1, }, + { .name =3D "ab8500_buck_smps2", .driver_data =3D (void *)AB8500_BUCK_SM= PS2, }, + { .name =3D "ab8500_buck_smps3", .driver_data =3D (void *)AB8500_BUCK_SM= PS3, }, + { .name =3D "ab8500_buck_arm", .driver_data =3D (void *)AB8500_BUCK_AR= M, }, + { .name =3D "ab8500_buck_ape", .driver_data =3D (void *)AB8500_BUCK_AP= E, }, + { .name =3D "ab8500_buck_mod", .driver_data =3D (void *)AB8500_BUCK_MO= D, }, }; =20 static struct of_regulator_match ab8505_regulator_match[] =3D { @@ -1756,6 +2193,12 @@ static struct of_regulator_match ab8505_regulator_ma= tch[] =3D { { .name =3D "ab8500_ldo_anamic2", .driver_data =3D (void *) AB8505_LDO_AN= AMIC2, }, { .name =3D "ab8500_ldo_aux8", .driver_data =3D (void *) AB8505_LDO_AU= X8, }, { .name =3D "ab8500_ldo_ana", .driver_data =3D (void *) AB8505_LDO_AN= A, }, + { .name =3D "ab8505_buck_smpsa", .driver_data =3D (void *)AB8505_BUCK_SM= PSA, }, + { .name =3D "ab8505_buck_smpsb", .driver_data =3D (void *)AB8505_BUCK_SM= PSB, }, + { .name =3D "ab8505_buck_safe", .driver_data =3D (void *)AB8505_BUCK_SA= FE, }, + { .name =3D "ab8505_buck_arm", .driver_data =3D (void *)AB8505_BUCK_AR= M, }, + { .name =3D "ab8505_buck_smpsc", .driver_data =3D (void *)AB8505_BUCK_SM= PSC, }, + { .name =3D "ab8505_buck_smpsm", .driver_data =3D (void *)AB8505_BUCK_SM= PSM, }, }; =20 static struct { --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5B7393FE347 for ; Mon, 14 Sep 2026 07:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371979; cv=none; b=Kmnq9v0DuQ1NCMlnev0OJCA3unD8wialcn0RN1YWdooQD1DzCSZAwEloJc2tev63M5x7qsobX5qNZIn/tiL9RG8bAoGOKC6Wu+ApV9dQzJ0vnw8BcWyQiWSGCtqIgq3B6waQrDlymp8YEItH9mUoMPRseN03ICgeqWkGpOCTvDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371979; c=relaxed/simple; bh=XY7mOhZqq9LWXUt88AII2yu7FLuLutizkwgrhvSheuE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=soLYFFifyYBtxS3GYYUO68ckRhaWJl2fQk8p3SL7cOxywC1Ek96K49H0/31u2F2cJpfSc4fcauTDMU7+Re5xM/CIrNUiVQ5Nva696yzDDrHOeQr79a9gKl4khHx7ksUxNme4svToxDXsO/GWadG7GZgSB1fFIXI25u2Anf0U0AM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZUoVKTbt; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZUoVKTbt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ADC51F00893; Mon, 14 Sep 2026 07:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371978; bh=HW64KVa5kWJeO60DzhKz9juuefGy7uyjxpyhr0h7unk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ZUoVKTbtkkjmab7Wrf7HciKjTtpF6KZF//yjujrhqWNCsIQV3qBQmZg221WIazEsY +NWTxNMHL85N6TN3Fcs3wZymg0wTblHTr0eBJR53g6cdzCZ+u6uNEdPRUWqRX+qru4 WOP/khZLbsLcPADVVWn9/YUIA0b084g7wVZeLw/m64MFuF+fO4u82eXcrj3GrVzzBt PTSDwfVhZ+bOJQ3z2M05txpyPelKULbV4qUgIe7/N7DhY30rHFzoMA8Ni1GbezFgbm kiTJlbI5lC7TWZ6vXZ14P1VbKTJg7S9gGLn6cy/w+DvdAg5x4KuNPyIQJq2kT0mPNr tt+dz+MtG9y3g== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:08 +0200 Subject: [PATCH v3 09/10] regulator: ab8500: Preserve OTP-enabled buck regulators 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-9-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 The SMPS enable fields are initialized from OTP and may leave a rail enabled for discrete consumers which cannot be described in the device tree. Such a rail currently looks unused to the regulator core and is disabled when constraints are completed. Read the enable field while registering each switchable buck regulator. If it is nonzero, mark the regulator boot-on and always-on dynamically so the unused-regulator sweep leaves it alone. Keep the enable operation idempotent so applying the always-on constraint preserves an OTP-selected hardware-control or low-power mode instead of forcing high-power mode. Synchronize the cached mode with the preserved field so an OTP-selected low-power state is also reported correctly. Regulators which are disabled by OTP retain normal switchable behavior. Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 76 ++++++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 130febf2680a..57ef3d4610e6 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -422,11 +422,10 @@ static int ab8500_regulator_disable(struct regulator_= dev *rdev) return ret; } =20 -static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) +static int ab8500_regulator_get_enable_value(struct regulator_dev *rdev) { int ret; struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); - u8 enable_mask; u8 regval; =20 if (info =3D=3D NULL) { @@ -442,18 +441,71 @@ static int ab8500_regulator_is_enabled(struct regulat= or_dev *rdev) return ret; } =20 - enable_mask =3D info->enable_mask ? info->enable_mask : info->update_mask; - dev_vdbg(rdev_get_dev(rdev), "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," " 0x%x\n", info->desc.name, info->update_bank, info->update_reg, - enable_mask, regval); + info->update_mask, regval); + + return regval & info->update_mask; +} + +static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) +{ + struct ab8500_regulator_info *info =3D rdev_get_drvdata(rdev); + u8 enable_mask; + int ret; + + ret =3D ab8500_regulator_get_enable_value(rdev); + if (ret < 0) + return ret; + + enable_mask =3D info->enable_mask ? info->enable_mask : info->update_mask; + + return !!(ret & enable_mask); +} =20 - if (regval & enable_mask) - return 1; +static int ab8500_buck_enable(struct regulator_dev *rdev) +{ + int ret; + + /* Keep an OTP-selected hardware or low-power mode intact. */ + ret =3D ab8500_regulator_is_enabled(rdev); + if (ret) + return ret < 0 ? ret : 0; + + return ab8500_regulator_enable(rdev); +} + +static int ab8500_buck_init(struct regulator_dev *rdev, + struct regulator_config *config) +{ + struct ab8500_regulator_info *info =3D config->driver_data; + int ret; + + ret =3D ab8500_regulator_get_enable_value(rdev); + if (ret <=3D 0) + return ret; + + /* Report forced LP accurately; HP and hardware control are normal mode. = */ + if (ret =3D=3D info->update_val_idle) + info->update_val =3D info->update_val_idle; else - return 0; + info->update_val =3D info->update_val_normal; + + /* + * The SMPS enable state is selected by OTP. An enabled rail may + * supply discrete board components which are not represented as + * regulator consumers, so keep it out of the unused-regulator sweep. + */ + rdev->constraints->boot_on =3D true; + rdev->constraints->always_on =3D true; + rdev->constraints->valid_ops_mask &=3D ~REGULATOR_CHANGE_STATUS; + + dev_dbg(config->dev, "%s: preserving OTP-enabled state\n", + info->desc.name); + + return 0; } =20 static unsigned int ab8500_regulator_get_optimum_mode( @@ -861,7 +913,7 @@ static const struct regulator_ops ab8500_regulator_line= ar_range_volt_ops =3D { }; =20 static const struct regulator_ops ab8500_buck_ops =3D { - .enable =3D ab8500_regulator_enable, + .enable =3D ab8500_buck_enable, .disable =3D ab8500_regulator_disable, .is_enabled =3D ab8500_regulator_is_enabled, .get_optimum_mode =3D ab8500_regulator_get_optimum_mode, @@ -1127,6 +1179,7 @@ static struct ab8500_regulator_info .desc =3D { .name =3D "BUCK-SMPS1", .ops =3D &ab8500_buck_ops, + .init_cb =3D ab8500_buck_init, .type =3D REGULATOR_VOLTAGE, .id =3D AB8500_BUCK_SMPS1, .owner =3D THIS_MODULE, @@ -1152,6 +1205,7 @@ static struct ab8500_regulator_info .desc =3D { .name =3D "BUCK-SMPS2", .ops =3D &ab8500_buck_ops, + .init_cb =3D ab8500_buck_init, .type =3D REGULATOR_VOLTAGE, .id =3D AB8500_BUCK_SMPS2, .owner =3D THIS_MODULE, @@ -1177,6 +1231,7 @@ static struct ab8500_regulator_info .desc =3D { .name =3D "BUCK-SMPS3", .ops =3D &ab8500_buck_ops, + .init_cb =3D ab8500_buck_init, .type =3D REGULATOR_VOLTAGE, .id =3D AB8500_BUCK_SMPS3, .owner =3D THIS_MODULE, @@ -1556,6 +1611,7 @@ static struct ab8500_regulator_info .desc =3D { .name =3D "BUCK-SMPSA", .ops =3D &ab8500_buck_ops, + .init_cb =3D ab8500_buck_init, .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_BUCK_SMPSA, .owner =3D THIS_MODULE, @@ -1581,6 +1637,7 @@ static struct ab8500_regulator_info .desc =3D { .name =3D "BUCK-SMPSB", .ops =3D &ab8500_buck_ops, + .init_cb =3D ab8500_buck_init, .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_BUCK_SMPSB, .owner =3D THIS_MODULE, @@ -1606,6 +1663,7 @@ static struct ab8500_regulator_info .desc =3D { .name =3D "BUCK-SAFE", .ops =3D &ab8500_buck_ops, + .init_cb =3D ab8500_buck_init, .type =3D REGULATOR_VOLTAGE, .id =3D AB8505_BUCK_SAFE, .owner =3D THIS_MODULE, --=20 2.55.0 From nobody Fri Sep 25 10:38:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0256F40B0E8 for ; Mon, 14 Sep 2026 07:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371981; cv=none; b=Myq4LohNxUk0QIP3+puFRYvcf/kXZU5C/WjGIMmk1UTakyT0rdPrDINzri9bXwDXQMEDyvrabTU4RMK0wOVKmqABLwL63DdW8CJ9KrN8ybSme+ZfU7g596N5QMOZ6VQWIM9rrqUwkZh+e4sZkrLMm9LNm23RRCKPM1yjpdwZkvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789371981; c=relaxed/simple; bh=R3jxbGkgGfOX4rp8Evxp0ZbJMbQnQCwHgRqRn6sEKTs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SUtQR9vBso3aaMprW2LwLjkCWu1bbxk0GuPFqtdq5plqDhAzl6krse+z0VL94+kvUDrpWe+ARjtEIS0o3kx2SMQwJqqmioHTIy/EPwgNGdG/ogEjf6W8pd2BORebIvoUvXYTqIT54RbCdtq9cachxoFgJc9p6Lzgdoh+cOECmCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QzpOKgoq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QzpOKgoq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA85A1F000FF; Mon, 14 Sep 2026 07:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789371979; bh=YmJceeDBdhPEgVm3BODfgB8lKWRTXnpjxh7sCmUtsWM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=QzpOKgoqQFQVJlXp5IwKsjhNTuUmd1kOIVJsQGFjGd0i/8+AiCiGFovTWY5oyaKsW OAhsQNtz5M+vmJbPbH0mrM2Mf1uQyetF++x9HDhOuY+VH7GWOlMo8PdXilm2xKUWS6 uPiluwxir1Ig6mUkSzdx3C1KVfrzQFvMWv/OiaPNt7cAbcq15ZFKKOcXKdW1bMN+rR 7ePRAzzttZLnkm2CoI4GaiphoXoiRVsRdGGmdt8KzYTYvkgVjaQoPu9QdjWY3YDRLl Ls2Iigar8zcurr4c+OS8sT4Csp3nwOpcoMrnVc4dCFz7iMUUGCSk/9rKFLwdIVqq9E NkikGs52K4uHA== From: Linus Walleij Date: Mon, 14 Sep 2026 09:46:09 +0200 Subject: [PATCH v3 10/10] regulator: ab8500: Use scoped guard for shared mode mutex 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 Message-Id: <20260914-ux500-dts-snowball-regulator-v3-10-7f92a365628e@kernel.org> References: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> In-Reply-To: <20260914-ux500-dts-snowball-regulator-v3-0-7f92a365628e@kernel.org> To: Stephan Gerhold , Liam Girdwood , Mark Brown , Axel Lin Cc: linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.3 Use a scoped mutex guard in ab8500_regulator_set_mode(). Assisted-by: LLM Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 57ef3d4610e6..3c1962ad85d4 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -542,6 +543,8 @@ static int ab8500_regulator_set_mode(struct regulator_d= ev *rdev, return -EINVAL; } =20 + guard(mutex)(&shared_mode_mutex); + if (info->mode_mask) { bank =3D info->mode_bank; reg =3D info->mode_reg; @@ -552,9 +555,6 @@ static int ab8500_regulator_set_mode(struct regulator_d= ev *rdev, mask =3D info->update_mask; } =20 - if (info->shared_mode) - mutex_lock(&shared_mode_mutex); - switch (mode) { case REGULATOR_MODE_NORMAL: if (info->shared_mode) @@ -573,7 +573,7 @@ static int ab8500_regulator_set_mode(struct regulator_d= ev *rdev, if (!shared_regulator->shared_mode->lp_mode_req) { /* Other regulator prevent LP mode */ info->shared_mode->lp_mode_req =3D true; - goto out_unlock; + return 0; } =20 lp_mode_req =3D true; @@ -585,18 +585,15 @@ static int ab8500_regulator_set_mode(struct regulator= _dev *rdev, val =3D info->update_val_idle; break; default: - ret =3D -EINVAL; - goto out_unlock; + return -EINVAL; } =20 if (info->mode_mask) { enabled =3D 1; } else { enabled =3D ab8500_regulator_is_enabled(rdev); - if (enabled < 0) { - ret =3D enabled; - goto out_unlock; - } + if (enabled < 0) + return enabled; } =20 if (enabled) { @@ -605,7 +602,7 @@ static int ab8500_regulator_set_mode(struct regulator_d= ev *rdev, if (ret < 0) { dev_err(rdev_get_dev(rdev), "couldn't set regulator mode\n"); - goto out_unlock; + return ret; } =20 dev_vdbg(rdev_get_dev(rdev), @@ -621,10 +618,6 @@ static int ab8500_regulator_set_mode(struct regulator_= dev *rdev, if (info->shared_mode) info->shared_mode->lp_mode_req =3D lp_mode_req; =20 -out_unlock: - if (info->shared_mode) - mutex_unlock(&shared_mode_mutex); - return ret; } =20 --=20 2.55.0