Add support for PMICs used on Tegra 3 devices
v9 cover Add support for PMICs used on Tegra 3 devices
Patch set adds basic support for PMICs used in many Tegra 3 devices. All PMIC drivers are based on datasheets provided by vendors. Implemented API include regulator set/get voltage enable/disable and basic PMIC r/w capabilities.
Drivers were tested by me on LG P895 (max77663), HTC One X (TPS80032) and ASUS TF300T (tps65911). Calculations and behavior were correct, predictable and reproducible.
Poweroff functional will be added after this basic drivers are merged.
---
Changes from v8:
- dropped common.h
- decreased amount of inclusions
Changes from v7:
- no activity for 3 weeks, no changes, re-sending
Changes from v6:
- no changes, re-sending
Changes from v5:
- pass tps6591x regulator children directly via udevice_id data field
Changes from v4:
- used private structure for TPS80031 SPMS driver so that internal flags do not interfere with those from dm_regulator_uclass_plat
- fixed detection on ldoln and ldousb for palmas ldo driver
Changes from v3:
- expanded descriptions in Kconfigs for pmics and regulators
- replaced ret with other variable name if it is not used for return
- dropped prefixed with pmic name
- dropped () in ~(var) type expressions
- return dm_i2c_* output in pmic_read/write functions
- switched to log_debug in some places
- added descryptions for some "non obvious" functions
- fixed tps80031 spms voltage calculation in non linear region
- adjsuted tps65911 vio voltage calculation
Changes from v2:
- removed all previously made poweroff API in favour to use sysreset after this patchset is accepted
Changes from v1:
- created poweroff API for PMIC and integrated it call into do_poweroff
- added poweroff function to submitted max77663, tps80032 and tps65911 drivers
- fixed registers asignments for regulators with non-numeric name (ldoln, ldousb, vddctrl)
---
Svyatoslav Ryhel (8):
power: pmic: palmas: support TI TPS65913 PMIC
power: regulator: palmas: fix ldoln and ldousb detection
power: pmic: add the base MAX77663 PMIC support
power: regulator: max77663: add regulator support
power: pmic: add the base TPS80031 PMIC support
power: regulator: tps80031: add regulator support
power: pmic: tps65910: add TPS65911 PMIC support
power: regulator: tps65911: add regulator support
doc/device-tree-bindings/pmic/max77663.txt | 84 ++++ doc/device-tree-bindings/pmic/tps65911.txt | 78 ++++ doc/device-tree-bindings/pmic/tps80031.txt | 76 ++++ drivers/power/pmic/Kconfig | 20 + drivers/power/pmic/Makefile | 2 + drivers/power/pmic/max77663.c | 81 ++++ drivers/power/pmic/palmas.c | 1 + drivers/power/pmic/pmic_tps65910_dm.c | 15 +- drivers/power/pmic/tps80031.c | 82 ++++ drivers/power/regulator/Kconfig | 28 ++ drivers/power/regulator/Makefile | 3 + drivers/power/regulator/max77663_regulator.c | 375 ++++++++++++++++++ drivers/power/regulator/palmas_regulator.c | 24 +- drivers/power/regulator/tps65911_regulator.c | 395 +++++++++++++++++++ drivers/power/regulator/tps80031_regulator.c | 347 ++++++++++++++++ include/power/max77663.h | 42 ++ include/power/tps65910_pmic.h | 44 +++ include/power/tps80031.h | 45 +++ 18 files changed, 1729 insertions(+), 13 deletions(-) create mode 100644 doc/device-tree-bindings/pmic/max77663.txt create mode 100644 doc/device-tree-bindings/pmic/tps65911.txt create mode 100644 doc/device-tree-bindings/pmic/tps80031.txt create mode 100644 drivers/power/pmic/max77663.c create mode 100644 drivers/power/pmic/tps80031.c create mode 100644 drivers/power/regulator/max77663_regulator.c create mode 100644 drivers/power/regulator/tps65911_regulator.c create mode 100644 drivers/power/regulator/tps80031_regulator.c create mode 100644 include/power/max77663.h create mode 100644 include/power/tps80031.h
Signature · 1 line
2.39.2
PATCH v9 1/8 power: pmic: palmas: support TI TPS65913 PMIC
Existing PALMAS PMIC driver is fully compatible with TI TPS65913 PMIC found in many Tegra 4 devices, like Tegra Note 7 and ASUS TF701T. TPS65913 shares same structure of regulators like TPS659038 so data can be reused.
--- drivers/power/pmic/palmas.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/pmic/palmas.c +1 -0
@@ -88,6 +88,7 @@ static struct dm_pmic_ops palmas_ops = {static const struct udevice_id palmas_ids[] = { { .compatible ="ti,tps659038" , .data =TPS659038 }, + { .compatible ="ti,tps65913" , .data =TPS659038 }, { .compatible ="ti,tps65917" , .data =TPS65917 }, { } };
Signature · 1 line
2.39.2
RE: [PATCH v9 1/8] power: pmic: palmas: support TI TPS65913 PMIC
Quoted 10 lines
-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Friday, October 27, 2023 5:26 PM
To: Tom Rini <[email protected]>; Jaehoon Chung <[email protected]>; Simon Glass <[email protected]>; Svyatoslav Ryhel <[email protected]>
Cc: [email protected]
Subject: [PATCH v9 1/8] power: pmic: palmas: support TI TPS65913 PMIC
Quoted 8 lines
Existing PALMAS PMIC driver is fully compatible with TI TPS65913 PMIC found in many Tegra 4 devices, like Tegra Note 7 and ASUS TF701T. TPS65913 shares same structure of regulators like TPS659038 so data can be reused.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Simon Glass <[email protected]>
Best Regards,
Jaehoon Chung
Quoted 18 lines
--- drivers/power/pmic/palmas.c | 1 + 1 file changed, 1 insertion(+)drivers/power/pmic/palmas.c +1
-1@@ -88,6 +88,7 @@ static struct dm_pmic_ops palmas_ops = {static const struct udevice_id palmas_ids[] = { { .compatible ="ti,tps659038" , .data =TPS659038 }, + { .compatible ="ti,tps65913" , .data =TPS659038 }, { .compatible ="ti,tps65917" , .data =TPS65917 }, { } }; --2.39.2
Re: [PATCH v9 1/8] power: pmic: palmas: support TI TPS65913 PMIC
In reply to Svyatoslav RyhelQuoted 9 lines · Svyatoslav Ryhel
Existing PALMAS PMIC driver is fully compatible with TI TPS65913 PMIC found in many Tegra 4 devices, like Tegra Note 7 and ASUS TF701T. TPS65913 shares same structure of regulators like TPS659038 so data can be reused.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Jaehoon Chung <[email protected]>
For the series, applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH v9 2/8 power: regulator: palmas: fix ldoln and ldousb detection
In reply to Svyatoslav Ryheldev->driver_data will carry the tail of ldo if there is a number and if there is no number it will be an error code, anyway it will not be zero. This results in a wrong ldo regulator detection.
To avoid this check for non-numerical ldo first and then manipulate dev->driver_data.
--- drivers/power/regulator/palmas_regulator.c | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/power/regulator/palmas_regulator.c +14 -10
@@ -301,19 +301,23 @@ static int palmas_ldo_probe(struct udevice *dev) uc_pdata->type =REGULATOR_TYPE_LDO ; -if (dev->driver_data) { +/* check for ldoln and ldousb cases */ +if (!strcmp ("ldoln" , dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9 ]; + uc_pdata->volt_reg = palmas_ldo_volt[type][9 ]; +return 0 ; + } + +if (!strcmp ("ldousb" , dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10 ]; + uc_pdata->volt_reg = palmas_ldo_volt[type][10 ]; +return 0 ; + } + +if (dev->driver_data >0 ) {u8 idx = dev->driver_data -1 ; uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][idx]; uc_pdata->volt_reg = palmas_ldo_volt[type][idx]; - }else { -/* check for ldoln and ldousb cases */ -if (!strcmp ("ldoln" , dev->name)) { - uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9 ]; - uc_pdata->volt_reg = palmas_ldo_volt[type][9 ]; - }else if (!strcmp ("ldousb" , dev->name)) { - uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10 ]; - uc_pdata->volt_reg = palmas_ldo_volt[type][10 ]; - } }return 0 ;
Signature · 1 line
2.39.2
PATCH v9 3/8 power: pmic: add the base MAX77663 PMIC support
In reply to Svyatoslav RyhelAdd support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write functions to access pmic registers.
--- doc/device-tree-bindings/pmic/max77663.txt | 84 ++++++++++++++++++++++ drivers/power/pmic/Kconfig | 9 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/max77663.c | 81 +++++++++++++++++++++ include/power/max77663.h | 42 +++++++++++ 5 files changed, 217 insertions(+) create mode 100644 doc/device-tree-bindings/pmic/max77663.txt create mode 100644 drivers/power/pmic/max77663.c create mode 100644 include/power/max77663.h
doc/device-tree-bindings/pmic/max77663.txt new file +84 -0
@@ -0,0 +1,84 @@ +MAXIM, MAX77663 PMIC + +This device uses two drivers: +- drivers/power/pmic/max77663.c (for parent device) +- drivers/power/regulator/max77663_regulator.c (for child regulators) + +This chapter describes the binding info for the PMIC driver and regulators. + +Required properties for PMIC: +- compatible: "maxim,max77663" +- reg: usually 0x1c or 0x3c + +With those two properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulators subnode should exists. + +Optional subnode: +- name: regulators (subnode list of each device's regulator) + +Regulators subnode contains set on supported regulators. + +Required properties: +- regulator-name: used for regulator uclass platform data '.name', + +List of supported regulator nodes names for max77663: +- sd0, sd1, sd2, sd3, ldo0, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8 + +Optional: +- regulator-min-microvolt: minimum allowed Voltage to set +- regulator-max-microvolt: minimum allowed Voltage to set +- regulator-always-on: regulator should be never disabled +- regulator-boot-on: regulator should be enabled by the bootloader + +Linux driver binding for this driver is compatible. + +Example: + +max77663@1c { + compatible = "maxim,max77663"; + reg = <0x1c>; + + regulators { + sd0 { + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo0 { + regulator-name = "avdd_pll"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + ... + + ldo2 { + regulator-name = "avdd_usb"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo3 { + regulator-name = "vdd_sdmmc3"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo8 { + regulator-name = "avdd_dsi_csi"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + }; +};
drivers/power/pmic/Kconfig +9 -0
@@ -184,6 +184,15 @@ config SPL_DM_PMIC_PFUZE100 This config enables implementation of driver-model pmic uclass features for PMIC PFUZE100 in SPL. The driver implements read/write operations. +config DM_PMIC_MAX77663 + bool "Enable Driver Model for PMIC MAX77663" + ---help--- + This config enables implementation of driver-model pmic uclass features + for PMIC MAX77663. The driver implements read/write operations. + This is a Power Management IC with a decent set of peripherals from which + 4 DC-to-DC Step-Down (SD) Regulators, 9 Low-Dropout Linear (LDO) Regulators, + 8 GPIOs, Real-Time Clock (RTC) and more with I2C Compatible Interface. + config DM_PMIC_MAX77686 bool "Enable Driver Model for PMIC MAX77686" ---help---
drivers/power/pmic/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DM_PMIC) += pmic-uclass.o obj-$(CONFIG_$(SPL_)DM_PMIC_FAN53555) += fan53555.o obj-$(CONFIG_$(SPL_)DM_PMIC_DA9063) += da9063.o +obj-$(CONFIG_$(SPL_)DM_PMIC_MAX77663) += max77663.o obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o obj-$(CONFIG_DM_PMIC_MC34708) += mc34708.o
drivers/power/pmic/max77663.c new file +81 -0
81 lines not on this page · raw message
include/power/max77663.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.39.2
RE: [PATCH v9 3/8] power: pmic: add the base MAX77663 PMIC support
Quoted 10 lines
-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Friday, October 27, 2023 5:26 PM
To: Tom Rini <[email protected]>; Jaehoon Chung <[email protected]>; Simon Glass <[email protected]>; Svyatoslav Ryhel <[email protected]>
Cc: [email protected]
Subject: [PATCH v9 3/8] power: pmic: add the base MAX77663 PMIC support
Quoted 6 lines
Add support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write functions to access pmic registers.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Simon Glass <[email protected]>
Just add a minor comment at below.
Quoted 252 lines
--- doc/device-tree-bindings/pmic/max77663.txt | 84 ++++++++++++++++++++++ drivers/power/pmic/Kconfig | 9 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/max77663.c | 81 +++++++++++++++++++++ include/power/max77663.h | 42 +++++++++++ 5 files changed, 217 insertions(+) create mode 100644 doc/device-tree-bindings/pmic/max77663.txt create mode 100644 drivers/power/pmic/max77663.c create mode 100644 include/power/max77663.hdoc/device-tree-bindings/pmic/max77663.txt new file +84
-0@@ -0,0 +1,84 @@ +MAXIM, MAX77663 PMIC + +This device uses two drivers: +- drivers/power/pmic/max77663.c (for parent device) +- drivers/power/regulator/max77663_regulator.c (for child regulators) + +This chapter describes the binding info for the PMIC driver and regulators. + +Required properties for PMIC: +- compatible: "maxim,max77663" +- reg: usually 0x1c or 0x3c + +With those two properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulators subnode should exists. + +Optional subnode: +- name: regulators (subnode list of each device's regulator) + +Regulators subnode contains set on supported regulators. + +Required properties: +- regulator-name: used for regulator uclass platform data '.name', + +List of supported regulator nodes names for max77663: +- sd0, sd1, sd2, sd3, ldo0, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8 + +Optional: +- regulator-min-microvolt: minimum allowed Voltage to set +- regulator-max-microvolt: minimum allowed Voltage to set +- regulator-always-on: regulator should be never disabled +- regulator-boot-on: regulator should be enabled by the bootloader + +Linux driver binding for this driver is compatible. + +Example: + +max77663@1c { + compatible = "maxim,max77663"; + reg = <0x1c>; + + regulators { + sd0 { + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo0 { + regulator-name = "avdd_pll"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + ... + + ldo2 { + regulator-name = "avdd_usb"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo3 { + regulator-name = "vdd_sdmmc3"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo8 { + regulator-name = "avdd_dsi_csi"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + }; +};drivers/power/pmic/Kconfig +9
-0@@ -184,6 +184,15 @@ config SPL_DM_PMIC_PFUZE100 This config enables implementation of driver-model pmic uclass features for PMIC PFUZE100 in SPL. The driver implements read/write operations. +config DM_PMIC_MAX77663 + bool "Enable Driver Model for PMIC MAX77663" + ---help--- + This config enables implementation of driver-model pmic uclass features + for PMIC MAX77663. The driver implements read/write operations. + This is a Power Management IC with a decent set of peripherals from which + 4 DC-to-DC Step-Down (SD) Regulators, 9 Low-Dropout Linear (LDO) Regulators, + 8 GPIOs, Real-Time Clock (RTC) and more with I2C Compatible Interface. + config DM_PMIC_MAX77686 bool "Enable Driver Model for PMIC MAX77686" ---help---drivers/power/pmic/Makefile +1
-0@@ -6,6 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DM_PMIC) += pmic-uclass.o obj-$(CONFIG_$(SPL_)DM_PMIC_FAN53555) += fan53555.o obj-$(CONFIG_$(SPL_)DM_PMIC_DA9063) += da9063.o +obj-$(CONFIG_$(SPL_)DM_PMIC_MAX77663) += max77663.o obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o obj-$(CONFIG_DM_PMIC_MC34708) += mc34708.odrivers/power/pmic/max77663.c new file +81
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright(C) 2023 Svyatoslav Ryhel <[email protected]> +*/ + +#include <dm.h> +#include <dm/lists.h> +#include <power/pmic.h> +#include <power/max77663.h> + +static const struct pmic_child_info pmic_children_info[] = { + { .prefix ="ldo" , .driver =MAX77663_LDO_DRIVER }, + { .prefix ="sd" , .driver =MAX77663_SD_DRIVER }, + { }, +}; + +static int max77663_write (struct udevice *dev,uint reg,const uint8_t *buff, +int len) +{ +int ret; + + ret =dm_i2c_write (dev, reg, buff, len); +if (ret) { +log_debug ("write error to device: %p register: %#x!\n" , dev, reg); +return ret; + } + +return 0 ; +} + +static int max77663_read (struct udevice *dev,uint reg,uint8_t *buff,int len) +{ +int ret; + + ret =dm_i2c_read (dev, reg, buff, len); +if (ret) { +log_debug ("read error from device: %p register: %#x!\n" , dev, reg); +return ret; + } + +return 0 ; +} + +static int max77663_bind (struct udevice *dev) +{ +ofnode regulators_node; +int children; + + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) { +log_err ("%s regulators subnode not found!\n" , dev->name); +return -ENXIO ; + } + +debug ("%s: '%s' - found regulators subnode\n" , __func__, dev->name); + + children =pmic_bind_children (dev, regulators_node, pmic_children_info); +if (!children) +log_err ("%s - no child found\n" , dev->name); + +/* Always return success for this device */ +return 0 ; +} + +static struct dm_pmic_ops max77663_ops = { + .read = max77663_read, + .write = max77663_write, +}; + +static const struct udevice_id max77663_ids[] = { + { .compatible ="maxim,max77663" }, + { } +}; + +U_BOOT_DRIVER (pmic_max77663) = { + .name ="max77663_pmic" , + .id =UCLASS_PMIC , + .of_match = max77663_ids, + .bind = max77663_bind, + .ops = &max77663_ops, +};include/power/max77663.h new file +26
-0@@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright(C) 2023 Svyatoslav Ryhel <[email protected]> +*/ + +#ifndef _MAX77663_H_ +#define _MAX77663_H_ + +#define MAX77663_LDO_NUM 9 +#define MAX77663_SD_NUM 5 + +/* Drivers name */ +#define MAX77663_LDO_DRIVER "max77663_ldo" +#define MAX77663_SD_DRIVER "max77663_sd" + +/* Step-Down (SD) Regulator calculations */ +#define SD_STATUS_MASK 0x30 + +#define SD0_VOLT_MAX_HEX 0x40 +#define SD1_VOLT_MAX_HEX 0x4c +#define SD_VOLT_MAX_HEX 0xff +#define SD_VOLT_MIN_HEX 0x02 + +#define SD0_VOLT_MAX 1400000 +#define SD1_VOLT_MAX 1550000 +#define SD_VOLT_MAX 3787500
include/power/max77663.h line 36
Quoted 10 lines
include/power/max77663.h new file +10
-0+#define SD_VOLT_MIN 625000 + +#define SD_VOLT_BASE 600000 + +/* Low-Dropout Linear (LDO) Regulator calculations */ +#define LDO_STATUS_MASK 0xc0 +#define LDO_VOLT_MASK 0x3f +#define LDO_VOLT_MAX_HEX 0x3f + +#define LDO01_VOLT_MAX 2375000
Does it mean ldo0~1 or only ldo1?
Quoted 8 lines
include/power/max77663.h new file +6
-1+#define LDO4_VOLT_MAX 1587500 +#define LDO_VOLT_MAX 3950000 + +#define LDO_VOLT_BASE 800000 + +#endif /* _MAX77663_H_ */ --2.39.2
Re: [PATCH v9 3/8] power: pmic: add the base MAX77663 PMIC support
вт, 31 жовт. 2023 р. о 10:57 Jaehoon Chung <[email protected]> пише:
Quoted 278 lines
Quoted 11 lines
-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Friday, October 27, 2023 5:26 PM
To: Tom Rini <[email protected]>; Jaehoon Chung <[email protected]>; Simon Glass <[email protected]>; Svyatoslav Ryhel <[email protected]>
Cc: [email protected]
Subject: [PATCH v9 3/8] power: pmic: add the base MAX77663 PMIC supportQuoted 6 lines
Add support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write functions to access pmic registers.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Jaehoon Chung <[email protected]>Just add a minor comment at below.
Quoted 256 lines
--- doc/device-tree-bindings/pmic/max77663.txt | 84 ++++++++++++++++++++++ drivers/power/pmic/Kconfig | 9 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/max77663.c | 81 +++++++++++++++++++++ include/power/max77663.h | 42 +++++++++++ 5 files changed, 217 insertions(+) create mode 100644 doc/device-tree-bindings/pmic/max77663.txt create mode 100644 drivers/power/pmic/max77663.c create mode 100644 include/power/max77663.hdoc/device-tree-bindings/pmic/max77663.txt new file +84
-0@@ -0,0 +1,84 @@ +MAXIM, MAX77663 PMIC + +This device uses two drivers: +- drivers/power/pmic/max77663.c (for parent device) +- drivers/power/regulator/max77663_regulator.c (for child regulators) + +This chapter describes the binding info for the PMIC driver and regulators. + +Required properties for PMIC: +- compatible: "maxim,max77663" +- reg: usually 0x1c or 0x3c + +With those two properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulators subnode should exists. + +Optional subnode: +- name: regulators (subnode list of each device's regulator) + +Regulators subnode contains set on supported regulators. + +Required properties: +- regulator-name: used for regulator uclass platform data '.name', + +List of supported regulator nodes names for max77663: +- sd0, sd1, sd2, sd3, ldo0, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8 + +Optional: +- regulator-min-microvolt: minimum allowed Voltage to set +- regulator-max-microvolt: minimum allowed Voltage to set +- regulator-always-on: regulator should be never disabled +- regulator-boot-on: regulator should be enabled by the bootloader + +Linux driver binding for this driver is compatible. + +Example: + +max77663@1c { + compatible = "maxim,max77663"; + reg = <0x1c>; + + regulators { + sd0 { + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo0 { + regulator-name = "avdd_pll"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + ... + + ldo2 { + regulator-name = "avdd_usb"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo3 { + regulator-name = "vdd_sdmmc3"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo8 { + regulator-name = "avdd_dsi_csi"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + }; +};drivers/power/pmic/Kconfig +9
-0@@ -184,6 +184,15 @@ config SPL_DM_PMIC_PFUZE100 This config enables implementation of driver-model pmic uclass features for PMIC PFUZE100 in SPL. The driver implements read/write operations. +config DM_PMIC_MAX77663 + bool "Enable Driver Model for PMIC MAX77663" + ---help--- + This config enables implementation of driver-model pmic uclass features + for PMIC MAX77663. The driver implements read/write operations. + This is a Power Management IC with a decent set of peripherals from which + 4 DC-to-DC Step-Down (SD) Regulators, 9 Low-Dropout Linear (LDO) Regulators, + 8 GPIOs, Real-Time Clock (RTC) and more with I2C Compatible Interface. + config DM_PMIC_MAX77686 bool "Enable Driver Model for PMIC MAX77686" ---help---drivers/power/pmic/Makefile +1
-0@@ -6,6 +6,7 @@ obj-$(CONFIG_$(SPL_TPL_)DM_PMIC) += pmic-uclass.o obj-$(CONFIG_$(SPL_)DM_PMIC_FAN53555) += fan53555.o obj-$(CONFIG_$(SPL_)DM_PMIC_DA9063) += da9063.o +obj-$(CONFIG_$(SPL_)DM_PMIC_MAX77663) += max77663.o obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o obj-$(CONFIG_DM_PMIC_MC34708) += mc34708.odrivers/power/pmic/max77663.c new file +81
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright(C) 2023 Svyatoslav Ryhel <[email protected]> +*/ + +#include <dm.h> +#include <dm/lists.h> +#include <power/pmic.h> +#include <power/max77663.h> + +static const struct pmic_child_info pmic_children_info[] = { + { .prefix ="ldo" , .driver =MAX77663_LDO_DRIVER }, + { .prefix ="sd" , .driver =MAX77663_SD_DRIVER }, + { }, +}; + +static int max77663_write (struct udevice *dev,uint reg,const uint8_t *buff, +int len) +{ +int ret; + + ret =dm_i2c_write (dev, reg, buff, len); +if (ret) { +log_debug ("write error to device: %p register: %#x!\n" , dev, reg); +return ret; + } + +return 0 ; +} + +static int max77663_read (struct udevice *dev,uint reg,uint8_t *buff,int len) +{ +int ret; + + ret =dm_i2c_read (dev, reg, buff, len); +if (ret) { +log_debug ("read error from device: %p register: %#x!\n" , dev, reg); +return ret; + } + +return 0 ; +} + +static int max77663_bind (struct udevice *dev) +{ +ofnode regulators_node; +int children; + + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) { +log_err ("%s regulators subnode not found!\n" , dev->name); +return -ENXIO ; + } + +debug ("%s: '%s' - found regulators subnode\n" , __func__, dev->name); + + children =pmic_bind_children (dev, regulators_node, pmic_children_info); +if (!children) +log_err ("%s - no child found\n" , dev->name); + +/* Always return success for this device */ +return 0 ; +} + +static struct dm_pmic_ops max77663_ops = { + .read = max77663_read, + .write = max77663_write, +}; + +static const struct udevice_id max77663_ids[] = { + { .compatible ="maxim,max77663" }, + { } +}; + +U_BOOT_DRIVER (pmic_max77663) = { + .name ="max77663_pmic" , + .id =UCLASS_PMIC , + .of_match = max77663_ids, + .bind = max77663_bind, + .ops = &max77663_ops, +};include/power/max77663.h new file +30
-0@@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright(C) 2023 Svyatoslav Ryhel <[email protected]> +*/ + +#ifndef _MAX77663_H_ +#define _MAX77663_H_ + +#define MAX77663_LDO_NUM 9 +#define MAX77663_SD_NUM 5 + +/* Drivers name */ +#define MAX77663_LDO_DRIVER "max77663_ldo" +#define MAX77663_SD_DRIVER "max77663_sd" + +/* Step-Down (SD) Regulator calculations */ +#define SD_STATUS_MASK 0x30 + +#define SD0_VOLT_MAX_HEX 0x40 +#define SD1_VOLT_MAX_HEX 0x4c +#define SD_VOLT_MAX_HEX 0xff +#define SD_VOLT_MIN_HEX 0x02 + +#define SD0_VOLT_MAX 1400000 +#define SD1_VOLT_MAX 1550000 +#define SD_VOLT_MAX 3787500 +#define SD_VOLT_MIN 625000 + +#define SD_VOLT_BASE 600000 +
Quoted 9 lines
include/power/max77663.h line 36
Quoted 6 lines
include/power/max77663.h new file +6
-0+/* Low-Dropout Linear (LDO) Regulator calculations */ +#define LDO_STATUS_MASK 0xc0 +#define LDO_VOLT_MASK 0x3f +#define LDO_VOLT_MAX_HEX 0x3f + +#define LDO01_VOLT_MAX 2375000Does it mean ldo0~1 or only ldo1?
0 and 1, then 4 and then the rest. They are grouped by common the properties (max voltage and step)
Best regards,
Svyatoslav R.
Quoted 10 lines
Quoted 8 lines
include/power/max77663.h new file +6
-1+#define LDO4_VOLT_MAX 1587500 +#define LDO_VOLT_MAX 3950000 + +#define LDO_VOLT_BASE 800000 + +#endif /* _MAX77663_H_ */ --2.39.2
PATCH v9 4/8 power: regulator: max77663: add regulator support
In reply to Svyatoslav RyhelThe driver provides regulator set/get voltage enable/disable functions for MAXIM MAX77663 PMICs.
--- drivers/power/regulator/Kconfig | 9 + drivers/power/regulator/Makefile | 1 + drivers/power/regulator/max77663_regulator.c | 375 +++++++++++++++++++ 3 files changed, 385 insertions(+) create mode 100644 drivers/power/regulator/max77663_regulator.c
drivers/power/regulator/Kconfig +9 -0
@@ -141,6 +141,15 @@ config SPL_REGULATOR_PWM This config enables implementation of driver-model regulator uclass features for PWM regulators in SPL. +config DM_REGULATOR_MAX77663 + bool "Enable Driver Model for REGULATOR MAX77663" + depends on DM_REGULATOR && DM_PMIC_MAX77663 + ---help--- + This config enables implementation of driver-model regulator uclass + features for REGULATOR MAX77663. The driver supports both DC-to-DC + Step-Down (SD) Regulators and Low-Dropout Linear (LDO) Regulators + found in MAX77663 PMIC and implements get/set api for value and enable. + config DM_REGULATOR_MAX77686 bool "Enable Driver Model for REGULATOR MAX77686" depends on DM_REGULATOR && DM_PMIC_MAX77686
drivers/power/regulator/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o obj-$(CONFIG_$(SPL_)REGULATOR_AXP_USB_POWER) += axp_usb_power.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_MAX77663) += max77663_regulator.o obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
drivers/power/regulator/max77663_regulator.c new file +375 -0
375 lines not on this page · raw message
Signature · 1 line
2.39.2
RE: [PATCH v9 4/8] power: regulator: max77663: add regulator support
Quoted 10 lines
-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Friday, October 27, 2023 5:26 PM
To: Tom Rini <[email protected]>; Jaehoon Chung <[email protected]>; Simon Glass <[email protected]>; Svyatoslav Ryhel <[email protected]>
Cc: [email protected]
Subject: [PATCH v9 4/8] power: regulator: max77663: add regulator support
Quoted 5 lines
The driver provides regulator set/get voltage enable/disable functions for MAXIM MAX77663 PMICs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Simon Glass <[email protected]>
Best Regards,
Jaehoon Chung
Quoted 423 lines
--- drivers/power/regulator/Kconfig | 9 + drivers/power/regulator/Makefile | 1 + drivers/power/regulator/max77663_regulator.c | 375 +++++++++++++++++++ 3 files changed, 385 insertions(+) create mode 100644 drivers/power/regulator/max77663_regulator.cdrivers/power/regulator/Kconfig +9
-0@@ -141,6 +141,15 @@ config SPL_REGULATOR_PWM This config enables implementation of driver-model regulator uclass features for PWM regulators in SPL. +config DM_REGULATOR_MAX77663 + bool "Enable Driver Model for REGULATOR MAX77663" + depends on DM_REGULATOR && DM_PMIC_MAX77663 + ---help--- + This config enables implementation of driver-model regulator uclass + features for REGULATOR MAX77663. The driver supports both DC-to-DC + Step-Down (SD) Regulators and Low-Dropout Linear (LDO) Regulators + found in MAX77663 PMIC and implements get/set api for value and enable. + config DM_REGULATOR_MAX77686 bool "Enable Driver Model for REGULATOR MAX77686" depends on DM_REGULATOR && DM_PMIC_MAX77686drivers/power/regulator/Makefile +1
-0@@ -10,6 +10,7 @@ obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o obj-$(CONFIG_$(SPL_)REGULATOR_AXP_USB_POWER) += axp_usb_power.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_MAX77663) += max77663_regulator.o obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.odrivers/power/regulator/max77663_regulator.c new file +375
-1@@ -0,0 +1,375 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright(C) 2023 Svyatoslav Ryhel <[email protected]> +*/ + +#include <dm.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/max77663.h> + +/* fist row is control registers, second is voltage registers */ +static const char max77663_sd_reg[][MAX77663_SD_NUM ] = { + {0x1d ,0x1e ,0x1f ,0x20 ,0x21 }, + {0x16 ,0x17 ,0x18 ,0x19 ,0x2a }, +}; + +static const char max77663_ldo_reg[MAX77663_LDO_NUM ] = { +0x23 ,0x25 ,0x27 ,0x29 ,0x2b ,0x2d ,0x2f ,0x31 ,0x33 +}; + +static int max77663_sd_enable (struct udevice *dev,int op,bool *enable) +{ +struct dm_regulator_uclass_plat *uc_pdata = +dev_get_uclass_plat (dev); +u32 adr = uc_pdata->ctrl_reg; +int val, ret; + + val =pmic_reg_read (dev->parent, adr); +if (val <0 ) +return val; + +if (op ==PMIC_OP_GET ) { +if (val &SD_STATUS_MASK ) + *enable = true; +else + *enable = false; + +return 0 ; + }else if (op ==PMIC_OP_SET ) { + val &= ~SD_STATUS_MASK ; + +if (*enable) + val |=SD_STATUS_MASK ; + + ret =pmic_reg_write (dev->parent, adr, val); +if (ret) +return ret; + } + +return 0 ; +} + +/** +* max77663_*_volt2hex() - convert voltage in uV into +* applicable to register hex value +* +* @idx: regulator index +* @uV: voltage in uV +* +* Return: voltage in hex on success, -ve on failure +*/ +static int max77663_sd_volt2hex (int idx,int uV) +{ +switch (idx) { +case 0 : +/* SD0 has max voltage 1.4V */ +if (uV >SD0_VOLT_MAX ) +return -EINVAL ; +break ; +case 1 : +/* SD1 has max voltage 1.55V */ +if (uV >SD1_VOLT_MAX ) +return -EINVAL ; +break ; +default : +/* SD2 and SD3 have max voltage 3.79V */ +if (uV >SD_VOLT_MAX ) +return -EINVAL ; +break ; + }; + +if (uV <SD_VOLT_MIN ) + uV =SD_VOLT_MIN ; + +return (uV -SD_VOLT_BASE ) /12500 ; +} + +/** +* max77663_*_hex2volt() - convert register hex value into +* actual voltage in uV +* +* @idx: regulator index +* @hex: hex value of register +* +* Return: voltage in uV on success, -ve on failure +*/ +static int max77663_sd_hex2volt (int idx,int hex) +{ +switch (idx) { +case 0 : +/* SD0 has max voltage 1.4V */ +if (hex >SD0_VOLT_MAX_HEX ) +return -EINVAL ; +break ; +case 1 : +/* SD1 has max voltage 1.55V */ +if (hex >SD1_VOLT_MAX_HEX ) +return -EINVAL ; +break ; +default : +/* SD2 and SD3 have max voltage 3.79V */ +if (hex >SD_VOLT_MAX_HEX ) +return -EINVAL ; +break ; + }; + +if (hex <SD_VOLT_MIN_HEX ) + hex =SD_VOLT_MIN_HEX ; + +return SD_VOLT_BASE + hex *12500 ; +} + +static int max77663_sd_val (struct udevice *dev,int op,int *uV) +{ +struct dm_regulator_uclass_plat *uc_pdata = +dev_get_uclass_plat (dev); +u32 adr = uc_pdata->volt_reg; +int idx = dev->driver_data; +int hex, ret; + +if (op ==PMIC_OP_GET ) { + hex =pmic_reg_read (dev->parent, adr); +if (hex <0 ) +return hex; + + *uV =0 ; + + ret =max77663_sd_hex2volt (idx, hex); +if (ret <0 ) +return ret; + *uV = ret; + +return 0 ; + } + +/* SD regulators use entire register for voltage */ + hex =max77663_sd_volt2hex (idx, *uV); +if (hex <0 ) +return hex; + +return pmic_reg_write (dev->parent, adr, hex); +} + +static int max77663_sd_probe (struct udevice *dev) +{ +struct dm_regulator_uclass_plat *uc_pdata = +dev_get_uclass_plat (dev); +int idx = dev->driver_data; + + uc_pdata->type =REGULATOR_TYPE_BUCK ; + uc_pdata->ctrl_reg = max77663_sd_reg[0 ][idx]; + uc_pdata->volt_reg = max77663_sd_reg[1 ][idx]; + +return 0 ; +} + +static int sd_get_value (struct udevice *dev) +{ +int uV; +int ret; + + ret =max77663_sd_val (dev,PMIC_OP_GET , &uV); +if (ret) +return ret; + +return uV; +} + +static int sd_set_value (struct udevice *dev,int uV) +{ +return max77663_sd_val (dev,PMIC_OP_SET , &uV); +} + +static int sd_get_enable (struct udevice *dev) +{ +bool enable = false; +int ret; + + ret =max77663_sd_enable (dev,PMIC_OP_GET , &enable); +if (ret) +return ret; + +return enable; +} + +static int sd_set_enable (struct udevice *dev,bool enable) +{ +return max77663_sd_enable (dev,PMIC_OP_SET , &enable); +} + +static const struct dm_regulator_ops max77663_sd_ops = { + .get_value = sd_get_value, + .set_value = sd_set_value, + .get_enable = sd_get_enable, + .set_enable = sd_set_enable, +}; + +U_BOOT_DRIVER (max77663_sd) = { + .name =MAX77663_SD_DRIVER , + .id =UCLASS_REGULATOR , + .ops = &max77663_sd_ops, + .probe = max77663_sd_probe, +}; + +static int max77663_ldo_enable (struct udevice *dev,int op,bool *enable) +{ +struct dm_regulator_uclass_plat *uc_pdata = +dev_get_uclass_plat (dev); +u32 adr = uc_pdata->ctrl_reg; +int val, ret; + + val =pmic_reg_read (dev->parent, adr); +if (val <0 ) +return val; + +if (op ==PMIC_OP_GET ) { +if (val &LDO_STATUS_MASK ) + *enable = true; +else + *enable = false; + +return 0 ; + }else if (op ==PMIC_OP_SET ) { + val &= ~LDO_STATUS_MASK ; + +if (*enable) + val |=LDO_STATUS_MASK ; + + ret =pmic_reg_write (dev->parent, adr, val); +if (ret) +return ret; + } + +return 0 ; +} + +static int max77663_ldo_volt2hex (int idx,int uV) +{ +switch (idx) { +case 0 : +case 1 : +if (uV >LDO01_VOLT_MAX ) +return -EINVAL ; + +return (uV -LDO_VOLT_BASE ) /25000 ; +case 4 : +if (uV >LDO4_VOLT_MAX ) +return -EINVAL ; + +return (uV -LDO_VOLT_BASE ) /12500 ; +default : +if (uV >LDO_VOLT_MAX ) +return -EINVAL ; + +return (uV -LDO_VOLT_BASE ) /50000 ; + }; +} + +static int max77663_ldo_hex2volt (int idx,int hex) +{ +if (hex >LDO_VOLT_MAX_HEX ) +return -EINVAL ; + +switch (idx) { +case 0 : +case 1 : +return (hex *25000 ) +LDO_VOLT_BASE ; +case 4 : +return (hex *12500 ) +LDO_VOLT_BASE ; +default : +return (hex *50000 ) +LDO_VOLT_BASE ; + }; +} + +static int max77663_ldo_val (struct udevice *dev,int op,int *uV) +{ +struct dm_regulator_uclass_plat *uc_pdata = +dev_get_uclass_plat (dev); +u32 adr = uc_pdata->ctrl_reg; +int idx = dev->driver_data; +int hex, val, ret; + + val =pmic_reg_read (dev->parent, adr); +if (val <0 ) +return val; + +if (op ==PMIC_OP_GET ) { + *uV =0 ; + + ret =max77663_ldo_hex2volt (idx, val &LDO_VOLT_MASK ); +if (ret <0 ) +return ret; + + *uV = ret; +return 0 ; + } + + hex =max77663_ldo_volt2hex (idx, *uV); +if (hex <0 ) +return hex; + + val &= ~LDO_VOLT_MASK ; + +return pmic_reg_write (dev->parent, adr, val | hex); +} + +static int max77663_ldo_probe (struct udevice *dev) +{ +struct dm_regulator_uclass_plat *uc_pdata = +dev_get_uclass_plat (dev); +int idx = dev->driver_data; + + uc_pdata->type =REGULATOR_TYPE_LDO ; + uc_pdata->ctrl_reg = max77663_ldo_reg[idx]; + +return 0 ; +} + +static int ldo_get_value (struct udevice *dev) +{ +int uV; +int ret; + + ret =max77663_ldo_val (dev,PMIC_OP_GET , &uV); +if (ret) +return ret; + +return uV; +} + +static int ldo_set_value (struct udevice *dev,int uV) +{ +return max77663_ldo_val (dev,PMIC_OP_SET , &uV); +} + +static int ldo_get_enable (struct udevice *dev) +{ +bool enable = false; +int ret; + + ret =max77663_ldo_enable (dev,PMIC_OP_GET , &enable); +if (ret) +return ret; + +return enable; +} + +static int ldo_set_enable (struct udevice *dev,bool enable) +{ +return max77663_ldo_enable (dev,PMIC_OP_SET , &enable); +} + +static const struct dm_regulator_ops max77663_ldo_ops = { + .get_value = ldo_get_value, + .set_value = ldo_set_value, + .get_enable = ldo_get_enable, + .set_enable = ldo_set_enable, +}; + +U_BOOT_DRIVER (max77663_ldo) = { + .name =MAX77663_LDO_DRIVER , + .id =UCLASS_REGULATOR , + .ops = &max77663_ldo_ops, + .probe = max77663_ldo_probe, +}; --2.39.2
PATCH v9 5/8 power: pmic: add the base TPS80031 PMIC support
In reply to Svyatoslav RyhelAdd support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write functions to access pmic registers.
--- doc/device-tree-bindings/pmic/tps80031.txt | 76 ++++++++++++++++++++ drivers/power/pmic/Kconfig | 11 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/tps80031.c | 82 ++++++++++++++++++++++ include/power/tps80031.h | 45 ++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 doc/device-tree-bindings/pmic/tps80031.txt create mode 100644 drivers/power/pmic/tps80031.c create mode 100644 include/power/tps80031.h
doc/device-tree-bindings/pmic/tps80031.txt new file +76 -0
@@ -0,0 +1,76 @@ +Texas Instruments, TPS80031/TPS80032 PMIC + +This device uses two drivers: +- drivers/power/pmic/tps80031.c (for parent device) +- drivers/power/regulator/tps80031_regulator.c (for child regulators) + +This chapter describes the binding info for the PMIC driver and regulators. + +Required properties for PMIC: +- compatible: "ti,tps80031" or "ti,tps80032" +- reg: 0x48 + +With those two properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulators subnode should exists. + +Optional subnode: +- name: regulators (subnode list of each device's regulator) + +Regulators subnode contains set on supported regulators. + +Required properties: +- regulator-name: used for regulator uclass platform data '.name', + +List of supported regulator nodes names for tps80031/tps80032: +- smps1, smps2, smps3, smps4, smps5 +- ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldoln, ldousb + +SMPS5 in Linux 3.1.10 is referred as vio, but datasheet clearly names it SMPS5. + +Optional: +- regulator-min-microvolt: minimum allowed Voltage to set +- regulator-max-microvolt: minimum allowed Voltage to set +- regulator-always-on: regulator should be never disabled +- regulator-boot-on: regulator should be enabled by the bootloader + +Example: + +tps80032@48 { + compatible = "ti,tps80032"; + reg = <0x48>; + + regulators { + smps1 { + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + smps5 { + regulator-name = "vdd_1v8_gen"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo1 { + regulator-name = "avdd_dsi_csi"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-boot-on; + }; + + ... + + ldousb { + regulator-name = "avdd_usb"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + }; + }; +};
drivers/power/pmic/Kconfig +11 -0
@@ -351,6 +351,17 @@ config DM_PMIC_TPS65910 DC-DC converter, 8 LDOs and a RTC. This driver binds the SMPS and LDO pmic children. +config DM_PMIC_TPS80031 + bool "Enable driver for Texas Instruments TPS80031/TPS80032 PMIC" + ---help--- + This config enables implementation of driver-model pmic uclass features + for TPS80031/TPS80032 PMICs. The driver implements read/write operations. + This is a Power Management IC with a decent set of peripherals from which + 5 Buck Converters refered as Switched-mode power supply (SMPS), 11 General- + Purpose Low-Dropout Voltage Regulators (LDO), USB OTG Module, Real-Time + Clock (RTC) with Timer and Alarm Wake-Up, Two Digital PWM Outputs and more + with I2C Compatible Interface. PMIC occupies 4 I2C addresses. + config PMIC_STPMIC1 bool "Enable support for STMicroelectronics STPMIC1 PMIC" depends on DM_I2C
drivers/power/pmic/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_$(SPL_)PMIC_RN5T567) += rn5t567.o obj-$(CONFIG_PMIC_TPS65090) += tps65090.o obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o obj-$(CONFIG_DM_PMIC_TPS65910) += pmic_tps65910_dm.o +obj-$(CONFIG_$(SPL_)DM_PMIC_TPS80031) += tps80031.o obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o obj-$(CONFIG_$(SPL_)PMIC_LP87565) += lp87565.o
drivers/power/pmic/tps80031.c new file +82 -0
82 lines not on this page · raw message
include/power/tps80031.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v9 6/8 power: regulator: tps80031: add regulator support
In reply to Svyatoslav RyhelThe driver provides regulator set/get voltage enable/disable functions for TI TPS80031/TPS80032 PMICs.
--- drivers/power/regulator/Kconfig | 8 + drivers/power/regulator/Makefile | 1 + drivers/power/regulator/tps80031_regulator.c | 347 +++++++++++++++++++ 3 files changed, 356 insertions(+) create mode 100644 drivers/power/regulator/tps80031_regulator.c
drivers/power/regulator/Kconfig +8 -0
@@ -356,6 +356,14 @@ config DM_REGULATOR_TPS62360 implements the get/set api for value only, as the power line is always on. +config DM_REGULATOR_TPS80031 + bool "Enable driver for TPS80031/TPS80032 PMIC regulators" + depends on DM_PMIC_TPS80031 + ---help--- + This enables implementation of driver-model regulator uclass + features for TPS80031/TPS80032 PMICs. The driver implements + get/set api for: value and enable. + config DM_REGULATOR_STPMIC1 bool "Enable driver for STPMIC1 regulators" depends on DM_REGULATOR && PMIC_STPMIC1
drivers/power/regulator/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o obj-$(CONFIG_DM_REGULATOR_TPS65910) += tps65910_regulator.o obj-$(CONFIG_DM_REGULATOR_TPS62360) += tps62360_regulator.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_TPS80031) += tps80031_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_STPMIC1) += stpmic1.o obj-$(CONFIG_DM_REGULATOR_TPS65941) += tps65941_regulator.o obj-$(CONFIG_DM_REGULATOR_SCMI) += scmi_regulator.o
drivers/power/regulator/tps80031_regulator.c new file +347 -0
347 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v9 7/8 power: pmic: tps65910: add TPS65911 PMIC support
In reply to Svyatoslav RyhelAdd support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write functions to access pmic registers.
--- doc/device-tree-bindings/pmic/tps65911.txt | 78 ++++++++++++++++++++++ drivers/power/pmic/pmic_tps65910_dm.c | 15 ++++- include/power/tps65910_pmic.h | 44 ++++++++++++ 3 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 doc/device-tree-bindings/pmic/tps65911.txt
doc/device-tree-bindings/pmic/tps65911.txt new file +78 -0
@@ -0,0 +1,78 @@ +Texas Instruments, TPS65911 PMIC + +This device uses two drivers: +- drivers/power/pmic/tps65910.c (for parent device) +- drivers/power/regulator/tps65911_regulator.c (for child regulators) + +This chapter describes the binding info for the PMIC driver and regulators. + +Required properties for PMIC: +- compatible: "ti,tps65911" +- reg: 0x2d + +With those two properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulators subnode should exists. + +Optional subnode: +- name: regulators (subnode list of each device's regulator) + +Regulators subnode contains set on supported regulators. + +Required properties: +- regulator-name: used for regulator uclass platform data '.name', + +List of supported regulator nodes names for tps65911: +- vdd1, vdd2, vddctrl, vddio +- ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8 + +vddio in datasheet is referred as vio, but for reduction of code and +unification of smps regulators it is named vddio. + +Optional: +- regulator-min-microvolt: minimum allowed Voltage to set +- regulator-max-microvolt: minimum allowed Voltage to set +- regulator-always-on: regulator should be never disabled +- regulator-boot-on: regulator should be enabled by the bootloader + +Example: + +tps65911@2d { + compatible = "ti,tps65911"; + reg = <0x2d>; + + regulators { + vdd1 { + regulator-name = "vdd_1v2_backlight"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + vddio { + regulator-name = "vdd_1v8_gen"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo1 { + regulator-name = "vdd_emmc_core"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo8 { + regulator-name = "vdd_ddr_hs"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + }; + }; +};
drivers/power/pmic/pmic_tps65910_dm.c +12 -3
@@ -12,13 +12,19 @@#include <power/regulator.h> #include <power/tps65910_pmic.h> -static const struct pmic_child_info pmic_children_info[] = { +static const struct pmic_child_info tps65910_children_info[] = { { .prefix ="ldo_" , .driver =TPS65910_LDO_DRIVER }, { .prefix ="buck_" , .driver =TPS65910_BUCK_DRIVER }, { .prefix ="boost_" , .driver =TPS65910_BOOST_DRIVER }, { }, }; +static const struct pmic_child_info tps65911_children_info[] = { + { .prefix ="ldo" , .driver =TPS65911_LDO_DRIVER }, + { .prefix ="vdd" , .driver =TPS65911_VDD_DRIVER }, + { }, +}; +static int pmic_tps65910_reg_count (struct udevice *dev) {return TPS65910_NUM_REGS ;
@@ -50,6 +56,8 @@ static int pmic_tps65910_read(struct udevice *dev, uint reg, u8 *buffer,static int pmic_tps65910_bind (struct udevice *dev) { +const struct pmic_child_info *tps6591x_children_info = + (struct pmic_child_info *)dev_get_driver_data (dev);ofnode regulators_node;int children;
@@ -59,7 +67,7 @@ static int pmic_tps65910_bind(struct udevice *dev)return -EINVAL ; } - children =pmic_bind_children (dev, regulators_node, pmic_children_info); + children =pmic_bind_children (dev, regulators_node, tps6591x_children_info);if (!children)debug ("%s has no children (regulators)\n" , dev->name);
@@ -83,7 +91,8 @@ static struct dm_pmic_ops pmic_tps65910_ops = { };static const struct udevice_id pmic_tps65910_match[] = { - { .compatible ="ti,tps65910" }, + { .compatible ="ti,tps65910" , .data = (ulong)&tps65910_children_info }, + { .compatible ="ti,tps65911" , .data = (ulong)&tps65911_children_info }, {/* sentinel */ } };
include/power/tps65910_pmic.h +44 -0
48 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v9 8/8 power: regulator: tps65911: add regulator support
In reply to Svyatoslav RyhelThe driver provides regulator set/get voltage enable/disable functions for TI TPS5911 PMIC.
--- drivers/power/regulator/Kconfig | 11 + drivers/power/regulator/Makefile | 1 + drivers/power/regulator/tps65911_regulator.c | 395 +++++++++++++++++++ 3 files changed, 407 insertions(+) create mode 100644 drivers/power/regulator/tps65911_regulator.c
drivers/power/regulator/Kconfig +11 -0
@@ -346,6 +346,17 @@ config DM_REGULATOR_TPS65910 regulator types of the TPS65910 (BUCK, BOOST and LDO). It implements the get/set api for value and enable. +config DM_REGULATOR_TPS65911 + bool "Enable driver for TPS65911 PMIC regulators" + depends on DM_PMIC_TPS65910 + ---help--- + This config enables implementation of driver-model regulator + uclass features for the TPS65911 PMIC. The driver supports Step-Down + DC-DC Converters for Processor Cores (VDD1 and VDD2), Step-Down DC-DC + Converter for I/O Power (VIO), Controller for External FETs (VDDCtrl) + and LDO Voltage Regulators found in TPS65911 PMIC and implements + get/set api for value and enable. + config DM_REGULATOR_TPS62360 bool "Enable driver for TPS6236x Power Regulator" depends on DM_REGULATOR
drivers/power/regulator/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o obj-$(CONFIG_DM_REGULATOR_TPS65910) += tps65910_regulator.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_TPS65911) += tps65911_regulator.o obj-$(CONFIG_DM_REGULATOR_TPS62360) += tps62360_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_TPS80031) += tps80031_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_STPMIC1) += stpmic1.o
drivers/power/regulator/tps65911_regulator.c new file +395 -0
395 lines not on this page · raw message
Signature · 1 line
2.39.2