From nobody Sun Feb 8 11:56:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A263C7EE22 for ; Mon, 8 May 2023 13:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbjEHNOe (ORCPT ); Mon, 8 May 2023 09:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233557AbjEHNO3 (ORCPT ); Mon, 8 May 2023 09:14:29 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB89C86A2; Mon, 8 May 2023 06:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1683551668; x=1715087668; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=TtHpwat9GIEkB+1blW10QNVbCuv3L2YzA9AyRKP7Tts=; b=hYvACVQw1Ff2L+FCnhACMQ6eC3lf1rXy8ZqkrVeOXHDVOhZf7Q+PLwyD DQXbPRePuTsIZElypBJ9rQuLobWWAyfOl88+lw5Ijju0Xhu5T2f7JZo6c Rt4dYU9+pXFyQGkXE36vMK2Z8Z+p70lL2D5KlJSA5eEOrtNjN6H9yUhiw mvEnAo/K4lZ8wlLczpieRiSEqo2MH0Ck6UIU7NBvy/GDu7oMbHFTCDecS vdTSefXzvIZxiHz/auDqO1Ngoxybbh/3Y+w/cJoourzaUOWP5IAMFKzJp CLJ52EIIBYTAB/VAiDmusVa03BIeBOhMMuYSf0wvmQy/p6VGPifGxnapy w==; From: =?utf-8?q?M=C3=A5rten_Lindahl?= Date: Mon, 8 May 2023 15:14:07 +0200 Subject: [PATCH v3 1/2] regulator: dt-bindings: Add bindings for TPS6287x MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20230502-tps6287x-driver-v3-1-e25140a023f5@axis.com> References: <20230502-tps6287x-driver-v3-0-e25140a023f5@axis.com> In-Reply-To: <20230502-tps6287x-driver-v3-0-e25140a023f5@axis.com> To: Liam Girdwood , Mark Brown , "Rob Herring" , Krzysztof Kozlowski CC: , , , =?utf-8?q?M=C3=A5rten_Lindahl?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1683551664; l=1676; i=marten.lindahl@axis.com; s=20230329; h=from:subject:message-id; bh=KARdrRBkfobsUPZuEvNegZELY7vBi0k9NmejXd4gaFw=; b=nyLrWgIMZg9mzlaoZyM0bh+lRW/6/OZxjEGHU1urwrHpvGEMIVsSJbSlT+POd41G1AbONnto2 x3LDXeAXzndDGZzgkCnMOojZ0z8hwCykgBw6InCf1JV3R3EJlAwaQ7s X-Developer-Key: i=marten.lindahl@axis.com; a=ed25519; pk=JfbjqFPJnIDIQOkJBeatC8+S3Ax3N0RIdmN+fL3wXgw= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add bindings for the TPS62870/TPS62871/TPS62872/TPS62873 voltage regulators. Signed-off-by: M=C3=A5rten Lindahl Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/regulator/ti,tps62870.yaml | 52 ++++++++++++++++++= ++++ 1 file changed, 52 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/ti,tps62870.yaml b= /Documentation/devicetree/bindings/regulator/ti,tps62870.yaml new file mode 100644 index 000000000000..386989544dac --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/ti,tps62870.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/ti,tps62870.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI TPS62870/TPS62871/TPS62872/TPS62873 voltage regulator + +maintainers: + - M=C3=A5rten Lindahl + +allOf: + - $ref: regulator.yaml# + +properties: + compatible: + enum: + - ti,tps62870 + - ti,tps62871 + - ti,tps62872 + - ti,tps62873 + + reg: + maxItems: 1 + + regulator-initial-mode: + enum: [ 1, 2 ] + description: 1 - Forced PWM mode, 2 - Low power mode + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + regulator@41 { + compatible =3D "ti,tps62873"; + reg =3D <0x41>; + regulator-name =3D "+0.75V"; + regulator-min-microvolt =3D <400000>; + regulator-max-microvolt =3D <1675000>; + regulator-initial-mode =3D <1>; + }; + }; + +... --=20 2.30.2 From nobody Sun Feb 8 11:56:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3798C7EE2C for ; Mon, 8 May 2023 13:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233965AbjEHNOi (ORCPT ); Mon, 8 May 2023 09:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232161AbjEHNOb (ORCPT ); Mon, 8 May 2023 09:14:31 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92A221FF3; Mon, 8 May 2023 06:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1683551671; x=1715087671; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=31oPLS+7Hgm9X/Zm9Z+o/iZmWh0uhAjmSuXoswXLrTA=; b=a1s/M2JepKMlXJOhpyOMReaqpFkRq6ibF5rdJ+r9pTw+oSErfK/7H/Sb qjp47JIpI8XMoEHLfwmHZIAW+UI8083hfv4Wv62GyVJhb58fWec3QVb4g DX+erFxaxOI50TYY5CKVFD5H48Hh5BGPZRhudYHN6detL7czyY7IkHmn/ Q9idedCclEfvz8LmzpGmvlUFKT8yQqyJgZ1Qw76swx1G60cvcZl7AqsFr vKJcWzXT9mtQsvMiuS95ESssi8wVD/m7WmY19f+NIbH2n2AHanh2rUbs1 pcgIJDl5xno+krvNjyOxsQv7+apBdW+vccivnmCeoLvar/i5Iez2YveTz Q==; From: =?utf-8?q?M=C3=A5rten_Lindahl?= Date: Mon, 8 May 2023 15:14:08 +0200 Subject: [PATCH v3 2/2] regulator: Add support for TI TPS6287x regulators MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20230502-tps6287x-driver-v3-2-e25140a023f5@axis.com> References: <20230502-tps6287x-driver-v3-0-e25140a023f5@axis.com> In-Reply-To: <20230502-tps6287x-driver-v3-0-e25140a023f5@axis.com> To: Liam Girdwood , Mark Brown , "Rob Herring" , Krzysztof Kozlowski CC: , , , =?utf-8?q?M=C3=A5rten_Lindahl?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1683551664; l=7321; i=marten.lindahl@axis.com; s=20230329; h=from:subject:message-id; bh=Kt3klOUPvbJLgJuPw9rVm9s3RwJlYgoyV77lgGlarnE=; b=qrxS931JcHo1GxxCZ1ZPZeZJFKP+EOvwK2ZEQPDUWfvusWP2zvwzN+fYDBC/dkALei7UwHYWE EoYxbKpuXvVD1e3dcxO/3zu92pCc8L2c5ryfap/Ba5Gt6f47m/Ck75Q X-Developer-Key: i=marten.lindahl@axis.com; a=ed25519; pk=JfbjqFPJnIDIQOkJBeatC8+S3Ax3N0RIdmN+fL3wXgw= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for Texas Instruments TPS6287x, single-channel synchronous step-down converters with four output voltage ranges. Signed-off-by: M=C3=A5rten Lindahl --- drivers/regulator/Kconfig | 11 ++ drivers/regulator/Makefile | 1 + drivers/regulator/tps6287x-regulator.c | 188 +++++++++++++++++++++++++++++= ++++ 3 files changed, 200 insertions(+) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index aae28d0a489c..d7923ac53f53 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1374,6 +1374,17 @@ config REGULATOR_TPS6286X high-frequency synchronous step-down converters with an I2C interface. =20 +config REGULATOR_TPS6287X + tristate "TI TPS6287x Power Regulator" + depends on I2C && OF + select REGMAP_I2C + help + This driver supports TPS6287x voltage regulator chips. These are + pin-to-pin high-frequency synchronous step-down dc-dc converters + with an I2C interface. + + If built as a module it will be called tps6287x-regulator. + config REGULATOR_TPS65023 tristate "TI TPS65023 Power regulators" depends on I2C diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index ee383d8fc835..857995db3fa4 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -161,6 +161,7 @@ obj-$(CONFIG_REGULATOR_TI_ABB) +=3D ti-abb-regulator.o obj-$(CONFIG_REGULATOR_TPS6105X) +=3D tps6105x-regulator.o obj-$(CONFIG_REGULATOR_TPS62360) +=3D tps62360-regulator.o obj-$(CONFIG_REGULATOR_TPS6286X) +=3D tps6286x-regulator.o +obj-$(CONFIG_REGULATOR_TPS6287X) +=3D tps6287x-regulator.o obj-$(CONFIG_REGULATOR_TPS65023) +=3D tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) +=3D tps6507x-regulator.o obj-$(CONFIG_REGULATOR_TPS65086) +=3D tps65086-regulator.o diff --git a/drivers/regulator/tps6287x-regulator.c b/drivers/regulator/tps= 6287x-regulator.c new file mode 100644 index 000000000000..d7fc82175493 --- /dev/null +++ b/drivers/regulator/tps6287x-regulator.c @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 Axis Communications AB + * + * Driver for Texas Instruments TPS6287x PMIC. + * Datasheet: https://www.ti.com/lit/ds/symlink/tps62873.pdf + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TPS6287X_VSET 0x00 +#define TPS6287X_CTRL1 0x01 +#define TPS6287X_CTRL1_VRAMP GENMASK(1, 0) +#define TPS6287X_CTRL1_FPWMEN BIT(4) +#define TPS6287X_CTRL1_SWEN BIT(5) +#define TPS6287X_CTRL2 0x02 +#define TPS6287X_CTRL2_VRANGE GENMASK(3, 2) +#define TPS6287X_CTRL3 0x03 +#define TPS6287X_STATUS 0x04 + +static const struct regmap_config tps6287x_regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, + .max_register =3D TPS6287X_STATUS, +}; + +static const struct linear_range tps6287x_voltage_ranges[] =3D { + LINEAR_RANGE(400000, 0, 0xFF, 1250), + LINEAR_RANGE(400000, 0, 0xFF, 2500), + LINEAR_RANGE(400000, 0, 0xFF, 5000), + LINEAR_RANGE(800000, 0, 0xFF, 10000), +}; + +static const unsigned int tps6287x_voltage_range_sel[] =3D { + 0x0, 0x4, 0x8, 0xC +}; + +static const unsigned int tps6287x_ramp_table[] =3D { + 10000, 5000, 1250, 500 +}; + +static int tps6287x_set_mode(struct regulator_dev *rdev, unsigned int mode) +{ + unsigned int val; + + switch (mode) { + case REGULATOR_MODE_NORMAL: + val =3D 0; + break; + case REGULATOR_MODE_FAST: + val =3D TPS6287X_CTRL1_FPWMEN; + break; + default: + return -EINVAL; + } + + return regmap_update_bits(rdev->regmap, TPS6287X_CTRL1, + TPS6287X_CTRL1_FPWMEN, val); +} + +static unsigned int tps6287x_get_mode(struct regulator_dev *rdev) +{ + unsigned int val; + int ret; + + ret =3D regmap_read(rdev->regmap, TPS6287X_CTRL1, &val); + if (ret < 0) + return 0; + + return (val & TPS6287X_CTRL1_FPWMEN) ? REGULATOR_MODE_FAST : + REGULATOR_MODE_NORMAL; +} + +static unsigned int tps6287x_of_map_mode(unsigned int mode) +{ + switch (mode) { + case REGULATOR_MODE_NORMAL: + case REGULATOR_MODE_FAST: + return mode; + default: + return REGULATOR_MODE_INVALID; + } +} + +static const struct regulator_ops tps6287x_regulator_ops =3D { + .enable =3D regulator_enable_regmap, + .disable =3D regulator_disable_regmap, + .set_mode =3D tps6287x_set_mode, + .get_mode =3D tps6287x_get_mode, + .is_enabled =3D regulator_is_enabled_regmap, + .get_voltage_sel =3D regulator_get_voltage_sel_pickable_regmap, + .set_voltage_sel =3D regulator_set_voltage_sel_pickable_regmap, + .list_voltage =3D regulator_list_voltage_pickable_linear_range, + .set_ramp_delay =3D regulator_set_ramp_delay_regmap, +}; + +static struct regulator_desc tps6287x_reg =3D { + .name =3D "tps6287x", + .owner =3D THIS_MODULE, + .ops =3D &tps6287x_regulator_ops, + .of_map_mode =3D tps6287x_of_map_mode, + .type =3D REGULATOR_VOLTAGE, + .enable_reg =3D TPS6287X_CTRL1, + .enable_mask =3D TPS6287X_CTRL1_SWEN, + .vsel_reg =3D TPS6287X_VSET, + .vsel_mask =3D 0xFF, + .vsel_range_reg =3D TPS6287X_CTRL2, + .vsel_range_mask =3D TPS6287X_CTRL2_VRANGE, + .ramp_reg =3D TPS6287X_CTRL1, + .ramp_mask =3D TPS6287X_CTRL1_VRAMP, + .ramp_delay_table =3D tps6287x_ramp_table, + .n_ramp_values =3D ARRAY_SIZE(tps6287x_ramp_table), + .linear_ranges =3D tps6287x_voltage_ranges, + .n_linear_ranges =3D ARRAY_SIZE(tps6287x_voltage_ranges), + .linear_range_selectors =3D tps6287x_voltage_range_sel, +}; + +static int tps6287x_i2c_probe(struct i2c_client *i2c) +{ + struct device *dev =3D &i2c->dev; + struct regulator_config config =3D {}; + struct regulator_dev *rdev; + + config.regmap =3D devm_regmap_init_i2c(i2c, &tps6287x_regmap_config); + if (IS_ERR(config.regmap)) { + dev_err(dev, "Failed to init i2c\n"); + return PTR_ERR(config.regmap); + } + + config.dev =3D dev; + config.of_node =3D dev->of_node; + config.init_data =3D of_get_regulator_init_data(dev, dev->of_node, + &tps6287x_reg); + + rdev =3D devm_regulator_register(dev, &tps6287x_reg, &config); + if (IS_ERR(rdev)) { + dev_err(dev, "Failed to register regulator\n"); + return PTR_ERR(rdev); + } + + dev_dbg(dev, "Probed regulator\n"); + + return 0; +} + +static const struct of_device_id tps6287x_dt_ids[] =3D { + { .compatible =3D "ti,tps62870", }, + { .compatible =3D "ti,tps62871", }, + { .compatible =3D "ti,tps62872", }, + { .compatible =3D "ti,tps62873", }, + { } +}; + +MODULE_DEVICE_TABLE(of, tps6287x_dt_ids); + +static const struct i2c_device_id tps6287x_i2c_id[] =3D { + { "tps62870", 0 }, + { "tps62871", 0 }, + { "tps62872", 0 }, + { "tps62873", 0 }, + {}, +}; + +MODULE_DEVICE_TABLE(i2c, tps6287x_i2c_id); + +static struct i2c_driver tps6287x_regulator_driver =3D { + .driver =3D { + .name =3D "tps6287x", + .of_match_table =3D tps6287x_dt_ids, + }, + .probe_new =3D tps6287x_i2c_probe, + .id_table =3D tps6287x_i2c_id, +}; + +module_i2c_driver(tps6287x_regulator_driver); + +MODULE_AUTHOR("M=C3=A5rten Lindahl "); +MODULE_DESCRIPTION("Regulator driver for TI TPS6287X PMIC"); +MODULE_LICENSE("GPL"); --=20 2.30.2