Skip to contentSkip to conversation

Add TI TPS65215 PMIC Regulator Support

PATCH Superseded Shree Ramamoorthy 3 participants 15 messages Jan 3, 2025 – Jan 7, 2025

Subsystems (3)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add TI TPS65215 PMIC Regulator Support

TPS65215 is a Power Management Integrated Circuit (PMIC) that has significant register map overlap with TPS65219. The series introduces TPS65215 and restructures the existing driver to support multiple devices.

This follow-up series is dependent on the TPS65215 MFD Driver Series:
Commit c3cc37e8d23d ("mfd: tps65215: Add support for TI TPS65215 PMIC") Commit 5f0f36835b90 ("mfd: tps65215: Remove regmap_read check")

TPS65219 Cleanup Series:
GPIO: https://lore.kernel.org/all/[email protected]/
MFD: https://lore.kernel.org/all/[email protected]/
Reg: https://lore.kernel.org/all/[email protected]/

- Both TPS65215 and TPS65219 have 3 Buck regulators.
- TPS65215 has 2 LDOs, whereas TPS65219 has 4 LDOs.
- TPS65215 and TPS65219's LDO1 are the same.
- TPS65215's LDO2 maps to TPS65219's LDO3.
- TPS65215 has 1 GPO, whereas TPS65219 has 2 GPOs.
- The remaining features are the same.

TPS65215 TRM: https://www.ti.com/lit/pdf/slvucw5/

AM62L + TPS65215 Test Logs:
https://gist.github.com/ramamoorthyhs/7560eca6110fafc77b51894fa2c0fd22

---
Change Log:
v1 -> v2:
- have any PMIC lists be in alpha-numeric order: TPS65215, then TPS65219
- Add driver prefix to chip_data struct
- Have probe() helper functions use dev_err_probe instead of dev_err() to log the error code in a human readable format & combined with return, it saves a few LoC since { } can be removed.
- Add error handling of 'irq_data' in probe() as previously done.
---

Shree Ramamoorthy (7):
regulator: dt-bindings: Add TI TPS65215 PMIC bindings
regulator: tps65215: Update function & struct names
regulator: tps65215: Update IRQ structs to include TPS65215
regulator: tps65215: Add chip_data struct for multi-PMIC support
regulator: tps65215: Update platform_device_id table
regulator: tps65215: Define probe() helper functions
regulator: tps65215: Restructure probe() for multi-PMIC support

 .../bindings/regulator/ti,tps65219.yaml       |   9 +-
 drivers/regulator/Kconfig                     |   7 +-
 drivers/regulator/tps65219-regulator.c        | 217 +++++++++++++-----
 3 files changed, 177 insertions(+), 56 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/7 regulator: dt-bindings: Add TI TPS65215 PMIC bindings

TPS65215 is a Power Management IC with 3 Buck regulators and 2 LDOs.

TPS65215 has 2 LDOS and 1 GPO, whereas TPS65219 has 4 LDOs and 2 GPOs. The remaining features for both devices are the same.

---
 .../devicetree/bindings/regulator/ti,tps65219.yaml       | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +8 -1
index 78e64521d401..ba5f6fcf5219 100644
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/regulator/ti,tps65219.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: TI tps65219 Power Management Integrated Circuit regulators
+title: TI TPS65215/TPS65219 Power Management Integrated Circuit
 
 maintainers:
   - Jerome Neanne <[email protected]>
@@ -12,10 +12,17 @@ maintainers:
 description: |
   Regulator nodes should be named to buck<number> and ldo<number>.
 
+  TI TPS65219 is a Power Management IC with 3 Buck regulators, 4 Low
+  Drop-out Regulators (LDOs), 1 GPIO, 2 GPOs, and power-button.
+
+  TI TPS65215 is a derivative of TPS65219 with 3 Buck regulators, 2 Low
+  Drop-out Regulators (LDOs), 1 GPIO, 1 GPO, and power-button.
+
 properties:
   compatible:
     enum:
       - ti,tps65219
+      - ti,tps65215
 
   reg:
     maxItems: 1
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 1/7] regulator: dt-bindings: Add TI TPS65215 PMIC bindings

Quoted 25 lines · Shree Ramamoorthy

TPS65215 is a Power Management IC with 3 Buck regulators and 2 LDOs.

TPS65215 has 2 LDOS and 1 GPO, whereas TPS65219 has 4 LDOs and 2 GPOs. The remaining features for both devices are the same.

---
 .../devicetree/bindings/regulator/ti,tps65219.yaml       | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +1 -1
index 78e64521d401..ba5f6fcf5219 100644
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/regulator/ti,tps65219.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: TI tps65219 Power Management Integrated Circuit regulators
+title: TI TPS65215/TPS65219 Power Management Integrated Circuit
 
 maintainers:
   - Jerome Neanne <[email protected]>

Documentation/devicetree/bindings/regulator/ti,tps65219.yaml maintainers: · line 19

Quoted 8 lines
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +5 -0
@@ -12,10 +12,17 @@ maintainers:
 description: |
   Regulator nodes should be named to buck<number> and ldo<number>.
 
+  TI TPS65219 is a Power Management IC with 3 Buck regulators, 4 Low
+  Drop-out Regulators (LDOs), 1 GPIO, 2 GPOs, and power-button.
+
+  TI TPS65215 is a derivative of TPS65219 with 3 Buck regulators, 2 Low
+  Drop-out Regulators (LDOs), 1 GPIO, 1 GPO, and power-button.

Then you need allOf:if:then: which will disallow :false two LDOs and their supplies.

Documentation/devicetree/bindings/regulator/ti,tps65219.yaml maintainers: · line 25

Quoted 6 lines
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +2 -0
+
 properties:
   compatible:
     enum:
       - ti,tps65219
+      - ti,tps65215

Keep things ordered, don't add whatever you add to the end of the lists.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/7] regulator: dt-bindings: Add TI TPS65215 PMIC bindings

Hi,

Quoted 29 lines · Krzysztof Kozlowski
Quoted 28 lines · Shree Ramamoorthy

TPS65215 is a Power Management IC with 3 Buck regulators and 2 LDOs.

TPS65215 has 2 LDOS and 1 GPO, whereas TPS65219 has 4 LDOs and 2 GPOs. The remaining features for both devices are the same.

---
 .../devicetree/bindings/regulator/ti,tps65219.yaml       | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +1 -1
index 78e64521d401..ba5f6fcf5219 100644
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/regulator/ti,tps65219.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: TI tps65219 Power Management Integrated Circuit regulators
+title: TI TPS65215/TPS65219 Power Management Integrated Circuit
 
 maintainers:
   - Jerome Neanne <[email protected]>
@@ -12,10 +12,17 @@ maintainers:
 description: |
   Regulator nodes should be named to buck<number> and ldo<number>.
 
Quoted 7 lines

Documentation/devicetree/bindings/regulator/ti,tps65219.yaml maintainers: · line 19

Quoted 5 lines
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +5 -0
+  TI TPS65219 is a Power Management IC with 3 Buck regulators, 4 Low
+  Drop-out Regulators (LDOs), 1 GPIO, 2 GPOs, and power-button.
+
+  TI TPS65215 is a derivative of TPS65219 with 3 Buck regulators, 2 Low
+  Drop-out Regulators (LDOs), 1 GPIO, 1 GPO, and power-button.

Then you need allOf:if:then: which will disallow :false two LDOs and their supplies.

Thank you for your feedback! I did not know about this & will add it in.

Quoted 10 lines

Documentation/devicetree/bindings/regulator/ti,tps65219.yaml maintainers: · line 25

Quoted 6 lines
Documentation/devicetree/bindings/regulator/ti,tps65219.yaml +2 -0
+
 properties:
   compatible:
     enum:
       - ti,tps65219
+      - ti,tps65215

Keep things ordered, don't add whatever you add to the end of the lists.

Best regards,
Krzysztof

Noted, will make this change for the next version. Thanks!

#4 lore raw

PATCH v2 2/7 regulator: tps65215: Update function & struct names

In reply to Shree Ramamoorthy

Update struct and function names to indicate if it supports TPS65219 and/or TPS65215. The 'common' prefix is added to indicate the resource applies to both PMICs.

---
 drivers/regulator/Kconfig              |  7 +--
 drivers/regulator/tps65219-regulator.c | 65 +++++++++++++++++---------
 2 files changed, 48 insertions(+), 24 deletions(-)
drivers/regulator/Kconfig +4 -3
index 39297f7d8177..6cd87443f9bb 100644
@@ -1579,10 +1579,11 @@ config REGULATOR_TPS65219
 	tristate "TI TPS65219 Power regulators"
 	depends on MFD_TPS65219 && OF
 	help
-	  This driver supports TPS65219 voltage regulator chips.
+	  This driver supports TPS65219 series and TPS65215 voltage regulator chips.
 	  TPS65219 series of PMICs have 3 single phase BUCKs & 4 LDOs
-	  voltage regulators. It supports software based voltage control
-	  for different voltage domains.
+	  voltage regulators.
+	  TPS65215 PMIC has 3 single phase BUCKs & 2 LDOs.
+	  Both PMICs support software based voltage control for different voltage domains.
 
 config REGULATOR_TPS6594
 	tristate "TI TPS6594 Power regulators"
drivers/regulator/tps65219-regulator.c +44 -21

147 lines not on this page · raw message

Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v2 2/7] regulator: tps65215: Update function & struct names

kernel test robot noticed the following build errors:

Hi Shree,

kernel test robot noticed the following build errors:

[auto build test ERROR on broonie-regulator/for-next]
[also build test ERROR on next-20241220]
[cannot apply to robh/for-next tmlind-omap/for-next linus/master v6.13-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shree-Ramamoorthy/regulator-dt-bindings-Add-TI-TPS65215-PMIC-bindings/20250104-070914
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/20250103230446.197597-3-s-ramamoorthy%40ti.com
patch subject: [PATCH v2 2/7] regulator: tps65215: Update function & struct names
config: i386-buildonly-randconfig-004-20250104 (https://download.01.org/0day-ci/archive/20250104/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/regulator/tps65219-regulator.c:261:44: error: 'TPS65215_LDO_2' undeclared here (not in a function); did you mean 'TPS65219_LDO_2'?
     261 |         TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
         |                                            ^~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:99:43: note: in definition of macro 'TPS65219_REGULATOR'
      99 |                 .id                     = _id,                          \
         |                                           ^~~
>> drivers/regulator/tps65219-regulator.c:263:28: error: 'TPS65215_REG_LDO2_VOUT' undeclared here (not in a function); did you mean 'TPS65219_REG_LDO2_VOUT'?
     263 |                            TPS65215_REG_LDO2_VOUT,
         |                            ^~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:104:43: note: in definition of macro 'TPS65219_REGULATOR'
     104 |                 .vsel_reg               = _vr,                          \
         |                                           ^~~
>> drivers/regulator/tps65219-regulator.c:266:28: error: 'TPS65215_ENABLE_LDO2_EN_MASK' undeclared here (not in a function); did you mean 'TPS65219_ENABLE_LDO2_EN_MASK'?
     266 |                            TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:111:43: note: in definition of macro 'TPS65219_REGULATOR'
     111 |                 .enable_mask            = _em,                          \
         |                                           ^~~
   In file included from include/linux/kernel.h:16,
                    from drivers/regulator/tps65219-regulator.c:12:
   drivers/regulator/tps65219-regulator.c: In function 'tps65219_regulator_probe':
   drivers/regulator/tps65219-regulator.c:328:36: error: 'regulators' undeclared (first use in this function); did you mean 'regulator'?
     328 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                                    ^~~~~~~~~~
   include/linux/array_size.h:11:33: note: in definition of macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                 ^~~
   drivers/regulator/tps65219-regulator.c:328:36: note: each undeclared identifier is reported only once for each function it appears in
     328 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                                    ^~~~~~~~~~
   include/linux/array_size.h:11:33: note: in definition of macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                 ^~~
   In file included from include/linux/array_size.h:5:
   include/linux/compiler.h:245:77: error: expression in static assertion is not an integer
     245 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
         |                                                                             ^
   include/linux/compiler.h:249:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
     249 | #define __must_be_array(a)      __BUILD_BUG_ON_ZERO_MSG(__same_type((a), &(a)[0]), "must be array")
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/array_size.h:11:59: note: in expansion of macro '__must_be_array'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                                           ^~~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:328:25: note: in expansion of macro 'ARRAY_SIZE'
     328 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                         ^~~~~~~~~~
   drivers/regulator/tps65219-regulator.c: At top level:
   drivers/regulator/tps65219-regulator.c:270:36: warning: 'tps65219_regs' defined but not used [-Wunused-const-variable=]
     270 | static const struct regulator_desc tps65219_regs[] = {
         |                                    ^~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:259:36: warning: 'tps65215_regs' defined but not used [-Wunused-const-variable=]
     259 | static const struct regulator_desc tps65215_regs[] = {
         |                                    ^~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:228:36: warning: 'common_regs' defined but not used [-Wunused-const-variable=]
     228 | static const struct regulator_desc common_regs[] = {
         |                                    ^~~~~~~~~~~

vim +261 drivers/regulator/tps65219-regulator.c

258
259 static const struct regulator_desc tps65215_regs[] = {
260 // TPS65215's LDO2 is the same as TPS65219's LDO3

 > 261		TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
   262				   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
 > 263				   TPS65215_REG_LDO2_VOUT,
   264				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   265				   TPS65219_REG_ENABLE_CTRL,
 > 266				   TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
   267				   3, 0, 0, NULL, 0, 0),

268 };
269

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#6 lore raw

Re: [PATCH v2 2/7] regulator: tps65215: Update function & struct names

In reply to Shree Ramamoorthy
kernel test robot noticed the following build errors:

Hi Shree,

kernel test robot noticed the following build errors:

[auto build test ERROR on broonie-regulator/for-next]
[also build test ERROR on next-20241220]
[cannot apply to robh/for-next tmlind-omap/for-next linus/master v6.13-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shree-Ramamoorthy/regulator-dt-bindings-Add-TI-TPS65215-PMIC-bindings/20250104-070914
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/20250103230446.197597-3-s-ramamoorthy%40ti.com
patch subject: [PATCH v2 2/7] regulator: tps65215: Update function & struct names
config: i386-buildonly-randconfig-001-20250104 (https://download.01.org/0day-ci/archive/20250104/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/regulator/tps65219-regulator.c:21:
In file included from include/linux/regulator/driver.h:18:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2223:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> drivers/regulator/tps65219-regulator.c:261:37: error: use of undeclared identifier 'TPS65215_LDO_2'; did you mean 'TPS65219_LDO_2'?
     261 |         TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
         |                                            ^~~~~~~~~~~~~~
         |                                            TPS65219_LDO_2
   drivers/regulator/tps65219-regulator.c:99:11: note: expanded from macro 'TPS65219_REGULATOR'
      99 |                 .id                     = _id,                          \
         |                                           ^
   include/linux/mfd/tps65219.h:302:2: note: 'TPS65219_LDO_2' declared here
     302 |         TPS65219_LDO_2,
         |         ^
>> drivers/regulator/tps65219-regulator.c:263:7: error: use of undeclared identifier 'TPS65215_REG_LDO2_VOUT'
     263 |                            TPS65215_REG_LDO2_VOUT,
         |                            ^
>> drivers/regulator/tps65219-regulator.c:266:7: error: use of undeclared identifier 'TPS65215_ENABLE_LDO2_EN_MASK'
     266 |                            TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
         |                            ^
>> drivers/regulator/tps65219-regulator.c:263:7: error: use of undeclared identifier 'TPS65215_REG_LDO2_VOUT'
     263 |                            TPS65215_REG_LDO2_VOUT,
         |                            ^
   drivers/regulator/tps65219-regulator.c:328:29: error: use of undeclared identifier 'regulators'
     328 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                                    ^
   drivers/regulator/tps65219-regulator.c:328:29: error: use of undeclared identifier 'regulators'
   drivers/regulator/tps65219-regulator.c:328:29: error: use of undeclared identifier 'regulators'
   drivers/regulator/tps65219-regulator.c:329:47: error: use of undeclared identifier 'regulators'
     329 |                 rdev = devm_regulator_register(&pdev->dev, &regulators[i],
         |                                                             ^
   drivers/regulator/tps65219-regulator.c:334:6: error: use of undeclared identifier 'regulators'
     334 |                                         regulators[i].name);
         |                                         ^

1 warning and 9 errors generated.

vim +261 drivers/regulator/tps65219-regulator.c

258
259 static const struct regulator_desc tps65215_regs[] = {
260 // TPS65215's LDO2 is the same as TPS65219's LDO3

 > 261		TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
   262				   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
 > 263				   TPS65215_REG_LDO2_VOUT,
   264				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   265				   TPS65219_REG_ENABLE_CTRL,
 > 266				   TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
   267				   3, 0, 0, NULL, 0, 0),

268 };
269

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#7 lore raw

PATCH v2 3/7 regulator: tps65215: Update IRQ structs to include TPS65215

In reply to Shree Ramamoorthy

Organize _regulator_irq_type structs into common (applies to TPS65215 and TPS65219) and separate device-specific structs, if needed.

---
 drivers/regulator/tps65219-regulator.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/regulator/tps65219-regulator.c +8 -4
index 4b96050561df..eddb22d0758a 100644
@@ -36,6 +36,14 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
 	{ "LDO4_SCG", "LDO4", "short circuit to ground", REGULATOR_EVENT_REGULATION_OUT },
 	{ "LDO4_OC", "LDO4", "overcurrent", REGULATOR_EVENT_OVER_CURRENT },
 	{ "LDO4_UV", "LDO4", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
+	{ "LDO3_RV", "LDO3", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
+	{ "LDO4_RV", "LDO4", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
+	{ "LDO3_RV_SD", "LDO3", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
+	{ "LDO4_RV_SD", "LDO4", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
+};
+
+/*  All of TPS65215's irq types are the same as common_regulator_irq_types */
+static struct tps65219_regulator_irq_type common_regulator_irq_types[] = {
 	{ "LDO1_SCG", "LDO1", "short circuit to ground", REGULATOR_EVENT_REGULATION_OUT },
 	{ "LDO1_OC", "LDO1", "overcurrent", REGULATOR_EVENT_OVER_CURRENT },
 	{ "LDO1_UV", "LDO1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
@@ -59,8 +67,6 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
 	{ "BUCK3_RV", "BUCK3", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "LDO1_RV", "LDO1", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "LDO2_RV", "LDO2", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
-	{ "LDO3_RV", "LDO3", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
-	{ "LDO4_RV", "LDO4", "residual voltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "BUCK1_RV_SD", "BUCK1", "residual voltage on shutdown",
 	 REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "BUCK2_RV_SD", "BUCK2", "residual voltage on shutdown",
@@ -69,8 +75,6 @@ static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
 	 REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "LDO1_RV_SD", "LDO1", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "LDO2_RV_SD", "LDO2", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
-	{ "LDO3_RV_SD", "LDO3", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
-	{ "LDO4_RV_SD", "LDO4", "residual voltage on shutdown", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
 	{ "SENSOR_3_WARM", "SENSOR3", "warm temperature", REGULATOR_EVENT_OVER_TEMP_WARN},
 	{ "SENSOR_2_WARM", "SENSOR2", "warm temperature", REGULATOR_EVENT_OVER_TEMP_WARN },
 	{ "SENSOR_1_WARM", "SENSOR1", "warm temperature", REGULATOR_EVENT_OVER_TEMP_WARN },
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 4/7 regulator: tps65215: Add chip_data struct for multi-PMIC support

In reply to Shree Ramamoorthy

'chipid' will identify which PMIC to support, and the corresponding chip_data struct element to use in probe(). The chip_data struct is helpful for any new PMICs added to this driver. The goal is to add future PMIC info to necessary structs and minimize probe() function edits.

---
 drivers/regulator/tps65219-regulator.c | 33 ++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
drivers/regulator/tps65219-regulator.c +33 -0
index eddb22d0758a..30928f1f216f 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+
 //
 // Regulator driver for TPS65215/TPS65219 PMIC
 //
@@ -314,6 +315,38 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+struct tps65219_chip_data {
+	size_t common_irq_size;
+	size_t rdesc_size;
+	size_t common_rdesc_size;
+	size_t dev_irq_size;
+	const struct regulator_desc *rdesc;
+	const struct regulator_desc *common_rdesc;
+	struct tps65219_regulator_irq_type *irq_types;
+	struct tps65219_regulator_irq_type *common_irq_types;
+};
+
+static struct tps65219_chip_data chip_info_table[] = {
+	[TPS65215] = {
+		.rdesc = tps65215_regs,
+		.rdesc_size = ARRAY_SIZE(tps65215_regs),
+		.common_rdesc = common_regs,
+		.common_rdesc_size = ARRAY_SIZE(common_regs),
+		.common_irq_types = common_regulator_irq_types,
+		.common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
+	},
+	[TPS65219] = {
+		.rdesc = tps65219_regs,
+		.rdesc_size = ARRAY_SIZE(tps65219_regs),
+		.common_rdesc = common_regs,
+		.common_rdesc_size = ARRAY_SIZE(common_regs),
+		.common_irq_types = common_regulator_irq_types,
+		.common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
+		.irq_types = tps65219_regulator_irq_types,
+		.dev_irq_size = ARRAY_SIZE(tps65219_regulator_irq_types),
+	},
+};
+
 static int tps65219_regulator_probe(struct platform_device *pdev)
 {
 	struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
Signature · 1 line
2.34.1
#9 lore raw

Re: [PATCH v2 4/7] regulator: tps65215: Add chip_data struct for multi-PMIC support

kernel test robot noticed the following build errors:

Hi Shree,

kernel test robot noticed the following build errors:

[auto build test ERROR on broonie-regulator/for-next]
[also build test ERROR on next-20241220]
[cannot apply to robh/for-next tmlind-omap/for-next linus/master v6.13-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shree-Ramamoorthy/regulator-dt-bindings-Add-TI-TPS65215-PMIC-bindings/20250104-070914
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/20250103230446.197597-5-s-ramamoorthy%40ti.com
patch subject: [PATCH v2 4/7] regulator: tps65215: Add chip_data struct for multi-PMIC support
config: i386-buildonly-randconfig-004-20250104 (https://download.01.org/0day-ci/archive/20250104/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/regulator/tps65219-regulator.c:266:44: error: 'TPS65215_LDO_2' undeclared here (not in a function); did you mean 'TPS65219_LDO_2'?

     266 |         TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
         |                                            ^~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:104:43: note: in definition of macro 'TPS65219_REGULATOR'
     104 |                 .id                     = _id,                          \
         |                                           ^~~
   drivers/regulator/tps65219-regulator.c:268:28: error: 'TPS65215_REG_LDO2_VOUT' undeclared here (not in a function); did you mean 'TPS65219_REG_LDO2_VOUT'?
     268 |                            TPS65215_REG_LDO2_VOUT,
         |                            ^~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:109:43: note: in definition of macro 'TPS65219_REGULATOR'
     109 |                 .vsel_reg               = _vr,                          \
         |                                           ^~~
   drivers/regulator/tps65219-regulator.c:271:28: error: 'TPS65215_ENABLE_LDO2_EN_MASK' undeclared here (not in a function); did you mean 'TPS65219_ENABLE_LDO2_EN_MASK'?
     271 |                            TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:116:43: note: in definition of macro 'TPS65219_REGULATOR'
     116 |                 .enable_mask            = _em,                          \
         |                                           ^~~
>> drivers/regulator/tps65219-regulator.c:330:10: error: 'TPS65215' undeclared here (not in a function); did you mean 'TPS65219'?
     330 |         [TPS65215] = {
         |          ^~~~~~~~
         |          TPS65219
>> drivers/regulator/tps65219-regulator.c:330:10: error: array index in initializer not of integer type
   drivers/regulator/tps65219-regulator.c:330:10: note: (near initialization for 'chip_info_table')
   In file included from include/linux/kernel.h:16,
                    from drivers/regulator/tps65219-regulator.c:13:
   drivers/regulator/tps65219-regulator.c: In function 'tps65219_regulator_probe':
   drivers/regulator/tps65219-regulator.c:365:36: error: 'regulators' undeclared (first use in this function); did you mean 'regulator'?
     365 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                                    ^~~~~~~~~~
   include/linux/array_size.h:11:33: note: in definition of macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                 ^~~
   drivers/regulator/tps65219-regulator.c:365:36: note: each undeclared identifier is reported only once for each function it appears in
     365 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                                    ^~~~~~~~~~
   include/linux/array_size.h:11:33: note: in definition of macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                 ^~~
   In file included from include/linux/array_size.h:5:
   include/linux/compiler.h:245:77: error: expression in static assertion is not an integer
     245 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
         |                                                                             ^
   include/linux/compiler.h:249:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
     249 | #define __must_be_array(a)      __BUILD_BUG_ON_ZERO_MSG(__same_type((a), &(a)[0]), "must be array")
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/array_size.h:11:59: note: in expansion of macro '__must_be_array'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                                           ^~~~~~~~~~~~~~~
   drivers/regulator/tps65219-regulator.c:365:25: note: in expansion of macro 'ARRAY_SIZE'
     365 |         for (i = 0; i < ARRAY_SIZE(regulators); i++) {
         |                         ^~~~~~~~~~
   drivers/regulator/tps65219-regulator.c: At top level:
   drivers/regulator/tps65219-regulator.c:329:34: warning: 'chip_info_table' defined but not used [-Wunused-variable]
     329 | static struct tps65219_chip_data chip_info_table[] = {
         |                                  ^~~~~~~~~~~~~~~

vim +330 drivers/regulator/tps65219-regulator.c

328
329 static struct tps65219_chip_data chip_info_table[] = {

 > 330		[TPS65215] = {

331 .rdesc = tps65215_regs,
332 .rdesc_size = ARRAY_SIZE(tps65215_regs),
333 .common_rdesc = common_regs,
334 .common_rdesc_size = ARRAY_SIZE(common_regs),
335 .common_irq_types = common_regulator_irq_types,
336 .common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
337 },
338 [TPS65219] = {
339 .rdesc = tps65219_regs,
340 .rdesc_size = ARRAY_SIZE(tps65219_regs),
341 .common_rdesc = common_regs,
342 .common_rdesc_size = ARRAY_SIZE(common_regs),
343 .common_irq_types = common_regulator_irq_types,
344 .common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
345 .irq_types = tps65219_regulator_irq_types,
346 .dev_irq_size = ARRAY_SIZE(tps65219_regulator_irq_types),
347 },
348 };
349

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw

PATCH v2 5/7 regulator: tps65215: Update platform_device_id table

In reply to Shree Ramamoorthy

Add TI TPS65215 PMIC to the existing platform_device_id struct, so the regulator probe() can match which PMIC chip_data information.

---
 drivers/regulator/tps65219-regulator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/tps65219-regulator.c +2 -1
index 30928f1f216f..6dc0829cf29a 100644
@@ -404,7 +404,8 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
 }
 
 static const struct platform_device_id tps65219_regulator_id_table[] = {
-	{ "tps65219-regulator", },
+	{ "tps65215-regulator", TPS65215 },
+	{ "tps65219-regulator", TPS65219 },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, tps65219_regulator_id_table);
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH v2 5/7] regulator: tps65215: Update platform_device_id table

Quoted 2 lines · Shree Ramamoorthy

Add TI TPS65215 PMIC to the existing platform_device_id struct, so the regulator probe() can match which PMIC chip_data information.

Why is this a separate commit? Adding new device support is one commit - so the tables, regulator definition and the quirks/ID table.

The next commit will be adding new entry to of_device_id?

Best regards,
Krzysztof

#12 lore raw

Re: [PATCH v2 5/7] regulator: tps65215: Update platform_device_id table

Hi,

Quoted 10 lines · Krzysztof Kozlowski
Quoted 2 lines · Shree Ramamoorthy

Add TI TPS65215 PMIC to the existing platform_device_id struct, so the regulator probe() can match which PMIC chip_data information.

Why is this a separate commit? Adding new device support is one commit - so the tables, regulator definition and the quirks/ID table.

The next commit will be adding new entry to of_device_id?

Best regards,
Krzysztof

I'll reorganize the commits to define and use the new resources & functions within the same patch.

Signature · 3 lines
Best,
Shree Ramamoorthy
PMIC Software Engineer
#13 lore raw

PATCH v2 6/7 regulator: tps65215: Define probe() helper functions

In reply to Shree Ramamoorthy

Factor register_regulators() and request_irqs() out into smaller functions. These 2 helper functions are used in the next restructure probe() patch to go through the common (overlapping) regulators and irqs first, then the device-specific structs identifed in the chip_data struct.

---
 drivers/regulator/tps65219-regulator.c | 59 ++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
drivers/regulator/tps65219-regulator.c +59 -0
index 6dc0829cf29a..31d76706bfc0 100644
@@ -347,6 +347,65 @@ static struct tps65219_chip_data chip_info_table[] = {
 	},
 };
 
+static int tps65219_register_regulators(const struct regulator_desc *regulators,
+					struct tps65219 *tps,
+					struct device *dev,
+					struct regulator_config config,
+					unsigned int arr_size)
+{
+	int i;
+	struct regulator_dev *rdev;
+
+	config.driver_data = tps;
+	config.dev = tps->dev;
+	config.regmap = tps->regmap;
+
+	for (i = 0; i < arr_size; i++) {
+		rdev = devm_regulator_register(dev, &regulators[i],
+						&config);
+		if (IS_ERR(rdev))
+			return dev_err_probe(tps->dev, PTR_ERR(rdev),
+				"Failed to register %s regulator\n",
+				regulators[i].name);
+	}
+
+	return 0;
+}
+
+static int tps65219_request_irqs(struct tps65219_regulator_irq_type *irq_types,
+				 struct tps65219 *tps, struct platform_device *pdev,
+				 struct tps65219_regulator_irq_data *irq_data,
+				 unsigned int arr_size)
+{
+	int i;
+	int irq;
+	int error;
+	struct tps65219_regulator_irq_type *irq_type;
+
+	for (i = 0; i < arr_size; ++i) {
+		irq_type = &irq_types[i];
+
+		irq = platform_get_irq_byname(pdev, irq_type->irq_name);
+		if (irq < 0)
+			return -EINVAL;
+
+		irq_data[i].dev = tps->dev;
+		irq_data[i].type = irq_type;
+
+		error = devm_request_threaded_irq(tps->dev, irq, NULL,
+						  tps65219_regulator_irq_handler,
+						  IRQF_ONESHOT,
+						  irq_type->irq_name,
+						  &irq_data[i]);
+		if (error)
+			return dev_err_probe(tps->dev, error,
+				"Failed to request %s IRQ %d\n",
+				irq_type->irq_name, irq);
+	}
+
+	return 0;
+}
+
 static int tps65219_regulator_probe(struct platform_device *pdev)
 {
 	struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 7/7 regulator: tps65215: Restructure probe() for multi-PMIC support

In reply to Shree Ramamoorthy

The probe() function will now utilize the register_regulators() and request_irqs() helper functions defined in the previous patch. Probe() will cycle through common (overlapping) regulators and irqs first, and then handle device-specific resources identified using the chip_data struct.

---
 drivers/regulator/tps65219-regulator.c | 63 ++++++++++++--------------
 1 file changed, 28 insertions(+), 35 deletions(-)
drivers/regulator/tps65219-regulator.c +28 -35
index 31d76706bfc0..56415f1fd60d 100644
@@ -409,54 +409,47 @@ static int tps65219_request_irqs(struct tps65219_regulator_irq_type *irq_types,
 static int tps65219_regulator_probe(struct platform_device *pdev)
 {
 	struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
-	struct regulator_dev *rdev;
 	struct regulator_config config = { };
-	int i;
 	int error;
-	int irq;
 	struct tps65219_regulator_irq_data *irq_data;
-	struct tps65219_regulator_irq_type *irq_type;
+	struct tps65219_chip_data *pmic;
+
+
+	enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
+
+	pmic = &chip_info_table[chip];
 
 	config.dev = tps->dev;
 	config.driver_data = tps;
 	config.regmap = tps->regmap;
 
-	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
-		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
-					       &config);
-		if (IS_ERR(rdev))
-			return dev_err_probe(tps->dev, PTR_ERR(rdev),
-					"Failed to register %s regulator\n",
-					regulators[i].name);
-	}
+	error = tps65219_register_regulators(pmic->common_rdesc, tps,
+						&pdev->dev, config, pmic->common_rdesc_size);
+	if (error)
+		return error;
 
-	irq_data = devm_kmalloc(tps->dev,
-				ARRAY_SIZE(tps65219_regulator_irq_types) *
-				sizeof(struct tps65219_regulator_irq_data),
-				GFP_KERNEL);
+	error = tps65219_register_regulators(pmic->rdesc, tps, &pdev->dev,
+						config, pmic->rdesc_size);
+	if (error)
+		return error;
+
+	irq_data = devm_kmalloc(tps->dev, pmic->common_irq_size, GFP_KERNEL);
 	if (!irq_data)
 		return -ENOMEM;
 
-	for (i = 0; i < ARRAY_SIZE(tps65219_regulator_irq_types); ++i) {
-		irq_type = &tps65219_regulator_irq_types[i];
-
-		irq = platform_get_irq_byname(pdev, irq_type->irq_name);
-		if (irq < 0)
-			return -EINVAL;
-
-		irq_data[i].dev = tps->dev;
-		irq_data[i].type = irq_type;
-
-		error = devm_request_threaded_irq(tps->dev, irq, NULL,
-						  tps65219_regulator_irq_handler,
-						  IRQF_ONESHOT,
-						  irq_type->irq_name,
-						  &irq_data[i]);
-		if (error) {
-			dev_err(tps->dev, "failed to request %s IRQ %d: %d\n",
-				irq_type->irq_name, irq, error);
+	error = tps65219_request_irqs(pmic->common_irq_types, tps, pdev,
+					irq_data, pmic->common_irq_size);
+	if (error)
+		return error;
+
+	if (chip == TPS65219) {
+		irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL);
+		if (!irq_data)
+			return -ENOMEM;
+		error = tps65219_request_irqs(pmic->irq_types, tps, pdev,
+						irq_data, pmic->dev_irq_size);
+		if (error)
 			return error;
-		}
 	}
 
 	return 0;
Signature · 1 line
2.34.1