devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Add TI TPS65215 PMIC Regulator Support
@ 2025-01-13 23:10 Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 1/4] regulator: tps65215: Update struct names Shree Ramamoorthy
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Shree Ramamoorthy @ 2025-01-13 23:10 UTC (permalink / raw)
  To: lgirdwood, broonie, robh, krzk+dt, conor+dt, aaro.koskinen,
	andreas, khilman, rogerq, tony, jerome.neanne, linux-omap,
	linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

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 8206c20f4c82 ("mfd: tps65215: Add support for TI TPS65215 PMIC")
Commit 0e0b7f00c111 ("mfd: tps65215: Remove regmap_read check")

TPS65219 Cleanup Series:
GPIO: https://lore.kernel.org/all/20241217204755.1011731-1-s-ramamoorthy@ti.com/
MFD: https://lore.kernel.org/all/20241217204935.1012106-1-s-ramamoorthy@ti.com/
Reg: https://lore.kernel.org/all/20241217204526.1010989-1-s-ramamoorthy@ti.com/

- 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:
v2 -> v3:
dt-bindings: 
- Alphanumeric order for PMIC list
- add allOf:if:then: which will disallow :false two LDOs and their supplies

regulator.c:
- Revert addition of 2 probe helper functions
- Add empty tps65215_regulator_irq_types struct to minimize loops in probe
- Consolidate patches to define and use func/structs in the same patches to
  prevent build error due to no users of the defined functions
- Apply reverse xmas tree style to variable defintions in functions
- Remove unnecessary new lines & add new line after declarations

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 (4):
  regulator: tps65215: Update struct names
  regulator: dt-bindings: Add TI TPS65215 PMIC bindings
  regulator: tps65215: Add support for TPS65215 regulator resources
  regulator: tps65215: Add support for TPS65215 Regulator IRQs

 .../bindings/regulator/ti,tps65219.yaml       |  21 +-
 drivers/regulator/Kconfig                     |   7 +-
 drivers/regulator/tps65219-regulator.c        | 188 +++++++++++++-----
 3 files changed, 165 insertions(+), 51 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/4] regulator: tps65215: Update struct names
  2025-01-13 23:10 [PATCH v3 0/4] Add TI TPS65215 PMIC Regulator Support Shree Ramamoorthy
@ 2025-01-13 23:10 ` Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 2/4] regulator: dt-bindings: Add TI TPS65215 PMIC bindings Shree Ramamoorthy
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Shree Ramamoorthy @ 2025-01-13 23:10 UTC (permalink / raw)
  To: lgirdwood, broonie, robh, krzk+dt, conor+dt, aaro.koskinen,
	andreas, khilman, rogerq, tony, jerome.neanne, linux-omap,
	linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

Isolate changes that involve renaming to indicate this resource is only for
TPS65219 or if it will be common for both devices. The renames are in
preparation for adding TPS65215 support.

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
---
 drivers/regulator/tps65219-regulator.c | 37 +++++++++++++++-----------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c
index aa65077f9d41..3c7c3a6d4c15 100644
--- a/drivers/regulator/tps65219-regulator.c
+++ b/drivers/regulator/tps65219-regulator.c
@@ -125,12 +125,17 @@ static const struct linear_range bucks_ranges[] = {
 	REGULATOR_LINEAR_RANGE(3400000, 0x34, 0x3f, 0),
 };
 
-static const struct linear_range ldos_1_2_ranges[] = {
+static const struct linear_range ldo_1_range[] = {
 	REGULATOR_LINEAR_RANGE(600000, 0x0, 0x37, 50000),
 	REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0),
 };
 
-static const struct linear_range ldos_3_4_ranges[] = {
+static const struct linear_range tps65219_ldo_2_range[] = {
+	REGULATOR_LINEAR_RANGE(600000, 0x0, 0x37, 50000),
+	REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0),
+};
+
+static const struct linear_range tps65219_ldos_3_4_range[] = {
 	REGULATOR_LINEAR_RANGE(1200000, 0x0, 0xC, 0),
 	REGULATOR_LINEAR_RANGE(1250000, 0xD, 0x35, 50000),
 	REGULATOR_LINEAR_RANGE(3300000, 0x36, 0x3F, 0),
@@ -174,7 +179,7 @@ static unsigned int tps65219_get_mode(struct regulator_dev *dev)
 }
 
 /* Operations permitted on BUCK1/2/3 */
-static const struct regulator_ops tps65219_bucks_ops = {
+static const struct regulator_ops bucks_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -189,7 +194,7 @@ static const struct regulator_ops tps65219_bucks_ops = {
 };
 
 /* Operations permitted on LDO1/2 */
-static const struct regulator_ops tps65219_ldos_1_2_ops = {
+static const struct regulator_ops ldos_1_2_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -204,7 +209,7 @@ static const struct regulator_ops tps65219_ldos_1_2_ops = {
 };
 
 /* Operations permitted on LDO3/4 */
-static const struct regulator_ops tps65219_ldos_3_4_ops = {
+static const struct regulator_ops ldos_3_4_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -218,53 +223,53 @@ static const struct regulator_ops tps65219_ldos_3_4_ops = {
 
 static const struct regulator_desc regulators[] = {
 	TPS65219_REGULATOR("BUCK1", "buck1", TPS65219_BUCK_1,
-			   REGULATOR_VOLTAGE, tps65219_bucks_ops, 64,
+			   REGULATOR_VOLTAGE, bucks_ops, 64,
 			   TPS65219_REG_BUCK1_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
 			   TPS65219_ENABLE_BUCK1_EN_MASK, 0, 0, bucks_ranges,
 			   3, 4000, 0, NULL, 0, 0),
 	TPS65219_REGULATOR("BUCK2", "buck2", TPS65219_BUCK_2,
-			   REGULATOR_VOLTAGE, tps65219_bucks_ops, 64,
+			   REGULATOR_VOLTAGE, bucks_ops, 64,
 			   TPS65219_REG_BUCK2_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
 			   TPS65219_ENABLE_BUCK2_EN_MASK, 0, 0, bucks_ranges,
 			   3, 4000, 0, NULL, 0, 0),
 	TPS65219_REGULATOR("BUCK3", "buck3", TPS65219_BUCK_3,
-			   REGULATOR_VOLTAGE, tps65219_bucks_ops, 64,
+			   REGULATOR_VOLTAGE, bucks_ops, 64,
 			   TPS65219_REG_BUCK3_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
 			   TPS65219_ENABLE_BUCK3_EN_MASK, 0, 0, bucks_ranges,
 			   3, 0, 0, NULL, 0, 0),
 	TPS65219_REGULATOR("LDO1", "ldo1", TPS65219_LDO_1,
-			   REGULATOR_VOLTAGE, tps65219_ldos_1_2_ops, 64,
+			   REGULATOR_VOLTAGE, ldos_1_2_ops, 64,
 			   TPS65219_REG_LDO1_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
-			   TPS65219_ENABLE_LDO1_EN_MASK, 0, 0, ldos_1_2_ranges,
+			   TPS65219_ENABLE_LDO1_EN_MASK, 0, 0, ldo_1_range,
 			   2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK),
 	TPS65219_REGULATOR("LDO2", "ldo2", TPS65219_LDO_2,
-			   REGULATOR_VOLTAGE, tps65219_ldos_1_2_ops, 64,
+			   REGULATOR_VOLTAGE, ldos_1_2_ops, 64,
 			   TPS65219_REG_LDO2_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
-			   TPS65219_ENABLE_LDO2_EN_MASK, 0, 0, ldos_1_2_ranges,
+			   TPS65219_ENABLE_LDO2_EN_MASK, 0, 0, tps65219_ldo_2_range,
 			   2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK),
 	TPS65219_REGULATOR("LDO3", "ldo3", TPS65219_LDO_3,
-			   REGULATOR_VOLTAGE, tps65219_ldos_3_4_ops, 64,
+			   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
 			   TPS65219_REG_LDO3_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
-			   TPS65219_ENABLE_LDO3_EN_MASK, 0, 0, ldos_3_4_ranges,
+			   TPS65219_ENABLE_LDO3_EN_MASK, 0, 0, tps65219_ldos_3_4_range,
 			   3, 0, 0, NULL, 0, 0),
 	TPS65219_REGULATOR("LDO4", "ldo4", TPS65219_LDO_4,
-			   REGULATOR_VOLTAGE, tps65219_ldos_3_4_ops, 64,
+			   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
 			   TPS65219_REG_LDO4_VOUT,
 			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
 			   TPS65219_REG_ENABLE_CTRL,
-			   TPS65219_ENABLE_LDO4_EN_MASK, 0, 0, ldos_3_4_ranges,
+			   TPS65219_ENABLE_LDO4_EN_MASK, 0, 0, tps65219_ldos_3_4_range,
 			   3, 0, 0, NULL, 0, 0),
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/4] regulator: dt-bindings: Add TI TPS65215 PMIC bindings
  2025-01-13 23:10 [PATCH v3 0/4] Add TI TPS65215 PMIC Regulator Support Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 1/4] regulator: tps65215: Update struct names Shree Ramamoorthy
@ 2025-01-13 23:10 ` Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs Shree Ramamoorthy
  3 siblings, 0 replies; 9+ messages in thread
From: Shree Ramamoorthy @ 2025-01-13 23:10 UTC (permalink / raw)
  To: lgirdwood, broonie, robh, krzk+dt, conor+dt, aaro.koskinen,
	andreas, khilman, rogerq, tony, jerome.neanne, linux-omap,
	linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

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.

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 .../bindings/regulator/ti,tps65219.yaml       | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/regulator/ti,tps65219.yaml b/Documentation/devicetree/bindings/regulator/ti,tps65219.yaml
index 78e64521d401..b0d47415bf83 100644
--- a/Documentation/devicetree/bindings/regulator/ti,tps65219.yaml
+++ b/Documentation/devicetree/bindings/regulator/ti,tps65219.yaml
@@ -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 Circuits
 
 maintainers:
   - Jerome Neanne <jerome.neanne@baylibre.com>
@@ -12,9 +12,16 @@ 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,tps65215
       - ti,tps65219
 
   reg:
@@ -90,6 +97,18 @@ required:
 
 additionalProperties: false
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: ti,tps65215
+    then:
+      properties:
+        regulators:
+          patternProperties:
+            "^ldo[3-4]$": false
+
 examples:
   - |
     #include <dt-bindings/interrupt-controller/arm-gic.h>
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources
  2025-01-13 23:10 [PATCH v3 0/4] Add TI TPS65215 PMIC Regulator Support Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 1/4] regulator: tps65215: Update struct names Shree Ramamoorthy
  2025-01-13 23:10 ` [PATCH v3 2/4] regulator: dt-bindings: Add TI TPS65215 PMIC bindings Shree Ramamoorthy
@ 2025-01-13 23:10 ` Shree Ramamoorthy
  2025-01-17  9:15   ` kernel test robot
  2025-01-19  2:16   ` kernel test robot
  2025-01-13 23:10 ` [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs Shree Ramamoorthy
  3 siblings, 2 replies; 9+ messages in thread
From: Shree Ramamoorthy @ 2025-01-13 23:10 UTC (permalink / raw)
  To: lgirdwood, broonie, robh, krzk+dt, conor+dt, aaro.koskinen,
	andreas, khilman, rogerq, tony, jerome.neanne, linux-omap,
	linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

Isolate all changes involving TPS65215 regulator desc and range resources.

- '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.

- The probe() will now loop through common (overlapping) regulators first,
  then device-specific structs identified in the chip_data struct.

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

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
---
 drivers/regulator/Kconfig              |  7 ++-
 drivers/regulator/tps65219-regulator.c | 85 +++++++++++++++++++++-----
 2 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 39297f7d8177..6cd87443f9bb 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -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"
diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c
index 3c7c3a6d4c15..cfb2ab6dbab4 100644
--- a/drivers/regulator/tps65219-regulator.c
+++ b/drivers/regulator/tps65219-regulator.c
@@ -1,10 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0
 //
-// tps65219-regulator.c
-//
-// Regulator driver for TPS65219 PMIC
+// Regulator driver for TPS65215/TPS65219 PMIC
 //
 // Copyright (C) 2022 BayLibre Incorporated - https://www.baylibre.com/
+// Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
 //
 // This implementation derived from tps65218 authored by
 // "J Keerthy <j-keerthy@ti.com>"
@@ -130,6 +129,11 @@ static const struct linear_range ldo_1_range[] = {
 	REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0),
 };
 
+static const struct linear_range tps65215_ldo_2_range[] = {
+	REGULATOR_LINEAR_RANGE(1200000, 0x0, 0xC, 50000),
+	REGULATOR_LINEAR_RANGE(3300000, 0x36, 0x3F, 0),
+};
+
 static const struct linear_range tps65219_ldo_2_range[] = {
 	REGULATOR_LINEAR_RANGE(600000, 0x0, 0x37, 50000),
 	REGULATOR_LINEAR_RANGE(3400000, 0x38, 0x3f, 0),
@@ -221,7 +225,7 @@ static const struct regulator_ops ldos_3_4_ops = {
 	.map_voltage		= regulator_map_voltage_linear_range,
 };
 
-static const struct regulator_desc regulators[] = {
+static const struct regulator_desc common_regs[] = {
 	TPS65219_REGULATOR("BUCK1", "buck1", TPS65219_BUCK_1,
 			   REGULATOR_VOLTAGE, bucks_ops, 64,
 			   TPS65219_REG_BUCK1_VOUT,
@@ -250,6 +254,20 @@ static const struct regulator_desc regulators[] = {
 			   TPS65219_REG_ENABLE_CTRL,
 			   TPS65219_ENABLE_LDO1_EN_MASK, 0, 0, ldo_1_range,
 			   2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK),
+};
+
+static const struct regulator_desc tps65215_regs[] = {
+	// TPS65215's LDO2 is the same as TPS65219's LDO3
+	TPS65219_REGULATOR("LDO2", "ldo2", TPS65215_LDO_2,
+			   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
+			   TPS65215_REG_LDO2_VOUT,
+			   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
+			   TPS65219_REG_ENABLE_CTRL,
+			   TPS65215_ENABLE_LDO2_EN_MASK, 0, 0, tps65215_ldo_2_range,
+			   3, 0, 0, NULL, 0, 0),
+};
+
+static const struct regulator_desc tps65219_regs[] = {
 	TPS65219_REGULATOR("LDO2", "ldo2", TPS65219_LDO_2,
 			   REGULATOR_VOLTAGE, ldos_1_2_ops, 64,
 			   TPS65219_REG_LDO2_VOUT,
@@ -292,28 +310,64 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+struct tps65219_chip_data {
+	size_t rdesc_size;
+	size_t common_rdesc_size;
+	const struct regulator_desc *rdesc;
+	const struct regulator_desc *common_rdesc;
+};
+
+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),
+	},
+	[TPS65219] = {
+		.rdesc = tps65219_regs,
+		.rdesc_size = ARRAY_SIZE(tps65219_regs),
+		.common_rdesc = common_regs,
+		.common_rdesc_size = ARRAY_SIZE(common_regs),
+	},
+};
+
 static int tps65219_regulator_probe(struct platform_device *pdev)
 {
-	struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
+	struct tps65219_regulator_irq_data *irq_data;
+	struct tps65219_regulator_irq_type *irq_type;
+
+	struct tps65219_chip_data *pmic;
 	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;
+	int i;
+
+	struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
+	struct regulator_config config = { };
+	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],
+	for (i = 0; i <  pmic->common_rdesc_size; i++) {
+		rdev = devm_regulator_register(&pdev->dev, &pmic->common_rdesc[i],
+					       &config);
+		if (IS_ERR(rdev))
+			 return dev_err_probe(tps->dev, PTR_ERR(rdev),
+					      "Failed to register %s regulator\n",
+					      pmic->common_rdesc[i].name);
+	}
+
+	for (i = 0; i <  pmic->rdesc_size; i++) {
+		rdev = devm_regulator_register(&pdev->dev, &pmic->rdesc[i],
 					       &config);
 		if (IS_ERR(rdev))
 			return dev_err_probe(tps->dev, PTR_ERR(rdev),
-					"Failed to register %s regulator\n",
-					regulators[i].name);
+					     "Failed to register %s regulator\n",
+					     pmic->rdesc[i].name);
 	}
 
 	irq_data = devm_kmalloc(tps->dev,
@@ -349,7 +403,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);
@@ -366,5 +421,5 @@ static struct platform_driver tps65219_regulator_driver = {
 module_platform_driver(tps65219_regulator_driver);
 
 MODULE_AUTHOR("Jerome Neanne <j-neanne@baylibre.com>");
-MODULE_DESCRIPTION("TPS65219 voltage regulator driver");
+MODULE_DESCRIPTION("TPS65215/TPS65219 voltage regulator driver");
 MODULE_LICENSE("GPL");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs
  2025-01-13 23:10 [PATCH v3 0/4] Add TI TPS65215 PMIC Regulator Support Shree Ramamoorthy
                   ` (2 preceding siblings ...)
  2025-01-13 23:10 ` [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources Shree Ramamoorthy
@ 2025-01-13 23:10 ` Shree Ramamoorthy
  2025-01-14  0:49   ` Andrew Davis
  3 siblings, 1 reply; 9+ messages in thread
From: Shree Ramamoorthy @ 2025-01-13 23:10 UTC (permalink / raw)
  To: lgirdwood, broonie, robh, krzk+dt, conor+dt, aaro.koskinen,
	andreas, khilman, rogerq, tony, jerome.neanne, linux-omap,
	linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

Isolate all changes involving regulator IRQ types:
- Adding in TPS65215 resources
- Organize what resources are common vs device-specific
- How the chip_data uses these resource structs
- Restructure the probe() for multi-PMIC support.

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
---
 drivers/regulator/tps65219-regulator.c | 68 +++++++++++++++++++-------
 1 file changed, 51 insertions(+), 17 deletions(-)

diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c
index cfb2ab6dbab4..732e28c213c3 100644
--- a/drivers/regulator/tps65219-regulator.c
+++ b/drivers/regulator/tps65219-regulator.c
@@ -29,6 +29,8 @@ struct tps65219_regulator_irq_type {
 	unsigned long event;
 };
 
+static struct tps65219_regulator_irq_type tps65215_regulator_irq_types[] = { 0 };
+
 static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
 	{ "LDO3_SCG", "LDO3", "short circuit to ground", REGULATOR_EVENT_REGULATION_OUT },
 	{ "LDO3_OC", "LDO3", "overcurrent", REGULATOR_EVENT_OVER_CURRENT },
@@ -36,6 +38,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 +69,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 +77,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 },
@@ -313,8 +319,12 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
 struct tps65219_chip_data {
 	size_t rdesc_size;
 	size_t common_rdesc_size;
+	size_t dev_irq_size;
+	size_t common_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[] = {
@@ -323,12 +333,20 @@ static struct tps65219_chip_data chip_info_table[] = {
 		.rdesc_size = ARRAY_SIZE(tps65215_regs),
 		.common_rdesc = common_regs,
 		.common_rdesc_size = ARRAY_SIZE(common_regs),
+		.irq_types = tps65215_regulator_irq_types,
+		.dev_irq_size = ARRAY_SIZE(tps65215_regulator_irq_types),
+		.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),
+		.irq_types = tps65219_regulator_irq_types,
+		.dev_irq_size = ARRAY_SIZE(tps65219_regulator_irq_types),
+		.common_irq_types = common_regulator_irq_types,
+		.common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
 	},
 };
 
@@ -336,7 +354,6 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
 {
 	struct tps65219_regulator_irq_data *irq_data;
 	struct tps65219_regulator_irq_type *irq_type;
-
 	struct tps65219_chip_data *pmic;
 	struct regulator_dev *rdev;
 	int error;
@@ -370,33 +387,50 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
 					     pmic->rdesc[i].name);
 	}
 
-	irq_data = devm_kmalloc(tps->dev,
-				ARRAY_SIZE(tps65219_regulator_irq_types) *
-				sizeof(struct tps65219_regulator_irq_data),
-				GFP_KERNEL);
+	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];
-
+	for (i = 0; i < pmic->common_irq_size; ++i) {
+		irq_type = &pmic->common_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, PTR_ERR(rdev),
+					     "Failed to request %s IRQ %d: %d\n",
+					     irq_type->irq_name, irq, error);
+	}
+
+	irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL);
+	if (!irq_data)
+		return -ENOMEM;
 
+	for (i = 0; i < pmic->dev_irq_size; ++i) {
+		irq_type = &pmic->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);
-			return error;
-		}
+		if (error)
+			return dev_err_probe(tps->dev, PTR_ERR(rdev),
+					     "Failed to request %s IRQ %d: %d\n",
+					     irq_type->irq_name, irq, error);
 	}
 
 	return 0;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs
  2025-01-13 23:10 ` [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs Shree Ramamoorthy
@ 2025-01-14  0:49   ` Andrew Davis
  2025-01-14 18:17     ` Shree Ramamoorthy
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Davis @ 2025-01-14  0:49 UTC (permalink / raw)
  To: Shree Ramamoorthy, lgirdwood, broonie, robh, krzk+dt, conor+dt,
	aaro.koskinen, andreas, khilman, rogerq, tony, jerome.neanne,
	linux-omap, linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

On 1/13/25 5:10 PM, Shree Ramamoorthy wrote:
> Isolate all changes involving regulator IRQ types:
> - Adding in TPS65215 resources
> - Organize what resources are common vs device-specific
> - How the chip_data uses these resource structs
> - Restructure the probe() for multi-PMIC support.
> 
> Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
> ---
>   drivers/regulator/tps65219-regulator.c | 68 +++++++++++++++++++-------
>   1 file changed, 51 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c
> index cfb2ab6dbab4..732e28c213c3 100644
> --- a/drivers/regulator/tps65219-regulator.c
> +++ b/drivers/regulator/tps65219-regulator.c
> @@ -29,6 +29,8 @@ struct tps65219_regulator_irq_type {
>   	unsigned long event;
>   };
>   
> +static struct tps65219_regulator_irq_type tps65215_regulator_irq_types[] = { 0 };

This creates a struct array of length 1, guessing you wanted an empty
array here, so { 0 }; -> { };

But might be even easier if you have no extra irqs for this device to
drop this empty array then below in the device definition simply do this:

+		.irq_types = NULL,
+		.dev_irq_size = 0,

Andrew

> +
>   static struct tps65219_regulator_irq_type tps65219_regulator_irq_types[] = {
>   	{ "LDO3_SCG", "LDO3", "short circuit to ground", REGULATOR_EVENT_REGULATION_OUT },
>   	{ "LDO3_OC", "LDO3", "overcurrent", REGULATOR_EVENT_OVER_CURRENT },
> @@ -36,6 +38,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 +69,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 +77,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 },
> @@ -313,8 +319,12 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
>   struct tps65219_chip_data {
>   	size_t rdesc_size;
>   	size_t common_rdesc_size;
> +	size_t dev_irq_size;
> +	size_t common_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[] = {
> @@ -323,12 +333,20 @@ static struct tps65219_chip_data chip_info_table[] = {
>   		.rdesc_size = ARRAY_SIZE(tps65215_regs),
>   		.common_rdesc = common_regs,
>   		.common_rdesc_size = ARRAY_SIZE(common_regs),
> +		.irq_types = tps65215_regulator_irq_types,
> +		.dev_irq_size = ARRAY_SIZE(tps65215_regulator_irq_types),
> +		.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),
> +		.irq_types = tps65219_regulator_irq_types,
> +		.dev_irq_size = ARRAY_SIZE(tps65219_regulator_irq_types),
> +		.common_irq_types = common_regulator_irq_types,
> +		.common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
>   	},
>   };
>   
> @@ -336,7 +354,6 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
>   {
>   	struct tps65219_regulator_irq_data *irq_data;
>   	struct tps65219_regulator_irq_type *irq_type;
> -
>   	struct tps65219_chip_data *pmic;
>   	struct regulator_dev *rdev;
>   	int error;
> @@ -370,33 +387,50 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
>   					     pmic->rdesc[i].name);
>   	}
>   
> -	irq_data = devm_kmalloc(tps->dev,
> -				ARRAY_SIZE(tps65219_regulator_irq_types) *
> -				sizeof(struct tps65219_regulator_irq_data),
> -				GFP_KERNEL);
> +	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];
> -
> +	for (i = 0; i < pmic->common_irq_size; ++i) {
> +		irq_type = &pmic->common_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, PTR_ERR(rdev),
> +					     "Failed to request %s IRQ %d: %d\n",
> +					     irq_type->irq_name, irq, error);
> +	}
> +
> +	irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL);
> +	if (!irq_data)
> +		return -ENOMEM;
>   
> +	for (i = 0; i < pmic->dev_irq_size; ++i) {
> +		irq_type = &pmic->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);
> -			return error;
> -		}
> +		if (error)
> +			return dev_err_probe(tps->dev, PTR_ERR(rdev),
> +					     "Failed to request %s IRQ %d: %d\n",
> +					     irq_type->irq_name, irq, error);
>   	}
>   
>   	return 0;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs
  2025-01-14  0:49   ` Andrew Davis
@ 2025-01-14 18:17     ` Shree Ramamoorthy
  0 siblings, 0 replies; 9+ messages in thread
From: Shree Ramamoorthy @ 2025-01-14 18:17 UTC (permalink / raw)
  To: Andrew Davis, lgirdwood, broonie, robh, krzk+dt, conor+dt,
	aaro.koskinen, andreas, khilman, rogerq, tony, jerome.neanne,
	linux-omap, linux-kernel, devicetree
  Cc: m-leonard, praneeth, christophe.jaillet

Hi,

On 1/13/25 6:49 PM, Andrew Davis wrote:
> On 1/13/25 5:10 PM, Shree Ramamoorthy wrote:
>> Isolate all changes involving regulator IRQ types:
>> - Adding in TPS65215 resources
>> - Organize what resources are common vs device-specific
>> - How the chip_data uses these resource structs
>> - Restructure the probe() for multi-PMIC support.
>>
>> Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
>> ---
>>   drivers/regulator/tps65219-regulator.c | 68 +++++++++++++++++++-------
>>   1 file changed, 51 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/regulator/tps65219-regulator.c 
>> b/drivers/regulator/tps65219-regulator.c
>> index cfb2ab6dbab4..732e28c213c3 100644
>> --- a/drivers/regulator/tps65219-regulator.c
>> +++ b/drivers/regulator/tps65219-regulator.c
>> @@ -29,6 +29,8 @@ struct tps65219_regulator_irq_type {
>>       unsigned long event;
>>   };
>>   +static struct tps65219_regulator_irq_type 
>> tps65215_regulator_irq_types[] = { 0 };
>
> This creates a struct array of length 1, guessing you wanted an empty
> array here, so { 0 }; -> { };
>
> But might be even easier if you have no extra irqs for this device to
> drop this empty array then below in the device definition simply do this:
>
> +        .irq_types = NULL,
> +        .dev_irq_size = 0,
>
> Andrew
>
Thank you for reviewing, will correct this for the next version!

>> +
>>   static struct tps65219_regulator_irq_type 
>> tps65219_regulator_irq_types[] = {
>>       { "LDO3_SCG", "LDO3", "short circuit to ground", 
>> REGULATOR_EVENT_REGULATION_OUT },
>>       { "LDO3_OC", "LDO3", "overcurrent", 
>> REGULATOR_EVENT_OVER_CURRENT },
>> @@ -36,6 +38,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 +69,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 +77,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 },
>> @@ -313,8 +319,12 @@ static irqreturn_t 
>> tps65219_regulator_irq_handler(int irq, void *data)
>>   struct tps65219_chip_data {
>>       size_t rdesc_size;
>>       size_t common_rdesc_size;
>> +    size_t dev_irq_size;
>> +    size_t common_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[] = {
>> @@ -323,12 +333,20 @@ static struct tps65219_chip_data 
>> chip_info_table[] = {
>>           .rdesc_size = ARRAY_SIZE(tps65215_regs),
>>           .common_rdesc = common_regs,
>>           .common_rdesc_size = ARRAY_SIZE(common_regs),
>> +        .irq_types = tps65215_regulator_irq_types,
>> +        .dev_irq_size = ARRAY_SIZE(tps65215_regulator_irq_types),
>> +        .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),
>> +        .irq_types = tps65219_regulator_irq_types,
>> +        .dev_irq_size = ARRAY_SIZE(tps65219_regulator_irq_types),
>> +        .common_irq_types = common_regulator_irq_types,
>> +        .common_irq_size = ARRAY_SIZE(common_regulator_irq_types),
>>       },
>>   };
>>   @@ -336,7 +354,6 @@ static int tps65219_regulator_probe(struct 
>> platform_device *pdev)
>>   {
>>       struct tps65219_regulator_irq_data *irq_data;
>>       struct tps65219_regulator_irq_type *irq_type;
>> -
>>       struct tps65219_chip_data *pmic;
>>       struct regulator_dev *rdev;
>>       int error;
>> @@ -370,33 +387,50 @@ static int tps65219_regulator_probe(struct 
>> platform_device *pdev)
>>                            pmic->rdesc[i].name);
>>       }
>>   -    irq_data = devm_kmalloc(tps->dev,
>> -                ARRAY_SIZE(tps65219_regulator_irq_types) *
>> -                sizeof(struct tps65219_regulator_irq_data),
>> -                GFP_KERNEL);
>> +    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];
>> -
>> +    for (i = 0; i < pmic->common_irq_size; ++i) {
>> +        irq_type = &pmic->common_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, PTR_ERR(rdev),
>> +                         "Failed to request %s IRQ %d: %d\n",
>> +                         irq_type->irq_name, irq, error);
>> +    }
>> +
>> +    irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL);
>> +    if (!irq_data)
>> +        return -ENOMEM;
>>   +    for (i = 0; i < pmic->dev_irq_size; ++i) {
>> +        irq_type = &pmic->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);
>> -            return error;
>> -        }
>> +        if (error)
>> +            return dev_err_probe(tps->dev, PTR_ERR(rdev),
>> +                         "Failed to request %s IRQ %d: %d\n",
>> +                         irq_type->irq_name, irq, error);
>>       }
>>         return 0;

-- 
Best,
Shree Ramamoorthy
PMIC Software Engineer


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources
  2025-01-13 23:10 ` [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources Shree Ramamoorthy
@ 2025-01-17  9:15   ` kernel test robot
  2025-01-19  2:16   ` kernel test robot
  1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-01-17  9:15 UTC (permalink / raw)
  To: Shree Ramamoorthy, lgirdwood, broonie, robh, krzk+dt, conor+dt,
	aaro.koskinen, andreas, khilman, rogerq, tony, jerome.neanne,
	linux-omap, linux-kernel, devicetree
  Cc: oe-kbuild-all, m-leonard, praneeth, christophe.jaillet

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-20250117]
[cannot apply to robh/for-next tmlind-omap/for-next linus/master v6.13-rc7]
[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-tps65215-Update-struct-names/20250114-071259
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/20250113231018.125426-4-s-ramamoorthy%40ti.com
patch subject: [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources
config: x86_64-randconfig-123-20250116 (https://download.01.org/0day-ci/archive/20250117/202501171720.615uCClE-lkp@intel.com/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/20250117/202501171720.615uCClE-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501171720.615uCClE-lkp@intel.com/

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:323:17: error: invalid application of 'sizeof' to an incomplete type 'const struct regulator_desc[]'
     323 |                 .rdesc_size = ARRAY_SIZE(tps65215_regs),
         |                               ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/array_size.h:11:32: note: expanded from macro 'ARRAY_SIZE'
      11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                ^~~~~
>> drivers/regulator/tps65219-regulator.c:348:15: error: variable has incomplete type 'enum pmic_id'
     348 |         enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
         |                      ^
   drivers/regulator/tps65219-regulator.c:348:7: note: forward declaration of 'enum pmic_id'
     348 |         enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
         |              ^
>> drivers/regulator/tps65219-regulator.c:406:26: error: use of undeclared identifier 'TPS65215'
     406 |         { "tps65215-regulator", TPS65215 },
         |                                 ^
>> drivers/regulator/tps65219-regulator.c:410:1: error: definition of variable with array type needs an explicit size or an initializer
     410 | MODULE_DEVICE_TABLE(platform, tps65219_regulator_id_table);
         | ^
   include/linux/module.h:250:21: note: expanded from macro 'MODULE_DEVICE_TABLE'
     250 | extern typeof(name) __mod_device_table__##type##__##name                \
         |                     ^
   <scratch space>:180:1: note: expanded from here
     180 | __mod_device_table__platform__tps65219_regulator_id_table
         | ^
   drivers/regulator/tps65219-regulator.c:321:3: error: use of undeclared identifier 'TPS65215'
     321 |         [TPS65215] = {
         |          ^
   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	
   270	static const struct regulator_desc tps65219_regs[] = {
   271		TPS65219_REGULATOR("LDO2", "ldo2", TPS65219_LDO_2,
   272				   REGULATOR_VOLTAGE, ldos_1_2_ops, 64,
   273				   TPS65219_REG_LDO2_VOUT,
   274				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   275				   TPS65219_REG_ENABLE_CTRL,
   276				   TPS65219_ENABLE_LDO2_EN_MASK, 0, 0, tps65219_ldo_2_range,
   277				   2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK),
   278		TPS65219_REGULATOR("LDO3", "ldo3", TPS65219_LDO_3,
   279				   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
   280				   TPS65219_REG_LDO3_VOUT,
   281				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   282				   TPS65219_REG_ENABLE_CTRL,
   283				   TPS65219_ENABLE_LDO3_EN_MASK, 0, 0, tps65219_ldos_3_4_range,
   284				   3, 0, 0, NULL, 0, 0),
   285		TPS65219_REGULATOR("LDO4", "ldo4", TPS65219_LDO_4,
   286				   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
   287				   TPS65219_REG_LDO4_VOUT,
   288				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   289				   TPS65219_REG_ENABLE_CTRL,
   290				   TPS65219_ENABLE_LDO4_EN_MASK, 0, 0, tps65219_ldos_3_4_range,
   291				   3, 0, 0, NULL, 0, 0),
   292	};
   293	
   294	static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
   295	{
   296		struct tps65219_regulator_irq_data *irq_data = data;
   297	
   298		if (irq_data->type->event_name[0] == '\0') {
   299			/* This is the timeout interrupt no specific regulator */
   300			dev_err(irq_data->dev,
   301				"System was put in shutdown due to timeout during an active or standby transition.\n");
   302			return IRQ_HANDLED;
   303		}
   304	
   305		regulator_notifier_call_chain(irq_data->rdev,
   306					      irq_data->type->event, NULL);
   307	
   308		dev_err(irq_data->dev, "Error IRQ trap %s for %s\n",
   309			irq_data->type->event_name, irq_data->type->regulator_name);
   310		return IRQ_HANDLED;
   311	}
   312	
   313	struct tps65219_chip_data {
   314		size_t rdesc_size;
   315		size_t common_rdesc_size;
   316		const struct regulator_desc *rdesc;
   317		const struct regulator_desc *common_rdesc;
   318	};
   319	
   320	static struct tps65219_chip_data chip_info_table[] = {
   321		[TPS65215] = {
   322			.rdesc = tps65215_regs,
 > 323			.rdesc_size = ARRAY_SIZE(tps65215_regs),
   324			.common_rdesc = common_regs,
   325			.common_rdesc_size = ARRAY_SIZE(common_regs),
   326		},
   327		[TPS65219] = {
   328			.rdesc = tps65219_regs,
   329			.rdesc_size = ARRAY_SIZE(tps65219_regs),
   330			.common_rdesc = common_regs,
   331			.common_rdesc_size = ARRAY_SIZE(common_regs),
   332		},
   333	};
   334	
   335	static int tps65219_regulator_probe(struct platform_device *pdev)
   336	{
   337		struct tps65219_regulator_irq_data *irq_data;
   338		struct tps65219_regulator_irq_type *irq_type;
   339	
   340		struct tps65219_chip_data *pmic;
   341		struct regulator_dev *rdev;
   342		int error;
   343		int irq;
   344		int i;
   345	
   346		struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
   347		struct regulator_config config = { };
 > 348		enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
   349		pmic = &chip_info_table[chip];
   350	
   351		config.dev = tps->dev;
   352		config.driver_data = tps;
   353		config.regmap = tps->regmap;
   354	
   355		for (i = 0; i <  pmic->common_rdesc_size; i++) {
   356			rdev = devm_regulator_register(&pdev->dev, &pmic->common_rdesc[i],
   357						       &config);
   358			if (IS_ERR(rdev))
   359				 return dev_err_probe(tps->dev, PTR_ERR(rdev),
   360						      "Failed to register %s regulator\n",
   361						      pmic->common_rdesc[i].name);
   362		}
   363	
   364		for (i = 0; i <  pmic->rdesc_size; i++) {
   365			rdev = devm_regulator_register(&pdev->dev, &pmic->rdesc[i],
   366						       &config);
   367			if (IS_ERR(rdev))
   368				return dev_err_probe(tps->dev, PTR_ERR(rdev),
   369						     "Failed to register %s regulator\n",
   370						     pmic->rdesc[i].name);
   371		}
   372	
   373		irq_data = devm_kmalloc(tps->dev,
   374					ARRAY_SIZE(tps65219_regulator_irq_types) *
   375					sizeof(struct tps65219_regulator_irq_data),
   376					GFP_KERNEL);
   377		if (!irq_data)
   378			return -ENOMEM;
   379	
   380		for (i = 0; i < ARRAY_SIZE(tps65219_regulator_irq_types); ++i) {
   381			irq_type = &tps65219_regulator_irq_types[i];
   382	
   383			irq = platform_get_irq_byname(pdev, irq_type->irq_name);
   384			if (irq < 0)
   385				return -EINVAL;
   386	
   387			irq_data[i].dev = tps->dev;
   388			irq_data[i].type = irq_type;
   389	
   390			error = devm_request_threaded_irq(tps->dev, irq, NULL,
   391							  tps65219_regulator_irq_handler,
   392							  IRQF_ONESHOT,
   393							  irq_type->irq_name,
   394							  &irq_data[i]);
   395			if (error) {
   396				dev_err(tps->dev, "failed to request %s IRQ %d: %d\n",
   397					irq_type->irq_name, irq, error);
   398				return error;
   399			}
   400		}
   401	
   402		return 0;
   403	}
   404	
   405	static const struct platform_device_id tps65219_regulator_id_table[] = {
 > 406		{ "tps65215-regulator", TPS65215 },
   407		{ "tps65219-regulator", TPS65219 },
   408		{ /* sentinel */ }
   409	};
 > 410	MODULE_DEVICE_TABLE(platform, tps65219_regulator_id_table);
   411	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources
  2025-01-13 23:10 ` [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources Shree Ramamoorthy
  2025-01-17  9:15   ` kernel test robot
@ 2025-01-19  2:16   ` kernel test robot
  1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-01-19  2:16 UTC (permalink / raw)
  To: Shree Ramamoorthy, lgirdwood, broonie, robh, krzk+dt, conor+dt,
	aaro.koskinen, andreas, khilman, rogerq, tony, jerome.neanne,
	linux-omap, linux-kernel, devicetree
  Cc: oe-kbuild-all, m-leonard, praneeth, christophe.jaillet

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-20250117]
[cannot apply to robh/for-next tmlind-omap/for-next linus/master v6.13-rc7]
[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-tps65215-Update-struct-names/20250114-071259
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
patch link:    https://lore.kernel.org/r/20250113231018.125426-4-s-ramamoorthy%40ti.com
patch subject: [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources
config: microblaze-allmodconfig (https://download.01.org/0day-ci/archive/20250119/202501191022.syh1x4cP-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250119/202501191022.syh1x4cP-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501191022.syh1x4cP-lkp@intel.com/

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,                          \
         |                                           ^~~
>> drivers/regulator/tps65219-regulator.c:321:10: error: 'TPS65215' undeclared here (not in a function); did you mean 'TPS65219'?
     321 |         [TPS65215] = {
         |          ^~~~~~~~
         |          TPS65219
>> drivers/regulator/tps65219-regulator.c:321:10: error: array index in initializer not of integer type
   drivers/regulator/tps65219-regulator.c:321:10: note: (near initialization for 'chip_info_table')
   drivers/regulator/tps65219-regulator.c: In function 'tps65219_regulator_probe':
>> drivers/regulator/tps65219-regulator.c:348:14: error: variable 'chip' has initializer but incomplete type
     348 |         enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
         |              ^~~~~~~
>> drivers/regulator/tps65219-regulator.c:348:22: error: storage size of 'chip' isn't known
     348 |         enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
         |                      ^~~~
   drivers/regulator/tps65219-regulator.c:348:22: warning: unused variable 'chip' [-Wunused-variable]


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	
   270	static const struct regulator_desc tps65219_regs[] = {
   271		TPS65219_REGULATOR("LDO2", "ldo2", TPS65219_LDO_2,
   272				   REGULATOR_VOLTAGE, ldos_1_2_ops, 64,
   273				   TPS65219_REG_LDO2_VOUT,
   274				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   275				   TPS65219_REG_ENABLE_CTRL,
   276				   TPS65219_ENABLE_LDO2_EN_MASK, 0, 0, tps65219_ldo_2_range,
   277				   2, 0, 0, NULL, 0, TPS65219_LDOS_BYP_CONFIG_MASK),
   278		TPS65219_REGULATOR("LDO3", "ldo3", TPS65219_LDO_3,
   279				   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
   280				   TPS65219_REG_LDO3_VOUT,
   281				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   282				   TPS65219_REG_ENABLE_CTRL,
   283				   TPS65219_ENABLE_LDO3_EN_MASK, 0, 0, tps65219_ldos_3_4_range,
   284				   3, 0, 0, NULL, 0, 0),
   285		TPS65219_REGULATOR("LDO4", "ldo4", TPS65219_LDO_4,
   286				   REGULATOR_VOLTAGE, ldos_3_4_ops, 64,
   287				   TPS65219_REG_LDO4_VOUT,
   288				   TPS65219_BUCKS_LDOS_VOUT_VSET_MASK,
   289				   TPS65219_REG_ENABLE_CTRL,
   290				   TPS65219_ENABLE_LDO4_EN_MASK, 0, 0, tps65219_ldos_3_4_range,
   291				   3, 0, 0, NULL, 0, 0),
   292	};
   293	
   294	static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
   295	{
   296		struct tps65219_regulator_irq_data *irq_data = data;
   297	
   298		if (irq_data->type->event_name[0] == '\0') {
   299			/* This is the timeout interrupt no specific regulator */
   300			dev_err(irq_data->dev,
   301				"System was put in shutdown due to timeout during an active or standby transition.\n");
   302			return IRQ_HANDLED;
   303		}
   304	
   305		regulator_notifier_call_chain(irq_data->rdev,
   306					      irq_data->type->event, NULL);
   307	
   308		dev_err(irq_data->dev, "Error IRQ trap %s for %s\n",
   309			irq_data->type->event_name, irq_data->type->regulator_name);
   310		return IRQ_HANDLED;
   311	}
   312	
   313	struct tps65219_chip_data {
   314		size_t rdesc_size;
   315		size_t common_rdesc_size;
   316		const struct regulator_desc *rdesc;
   317		const struct regulator_desc *common_rdesc;
   318	};
   319	
   320	static struct tps65219_chip_data chip_info_table[] = {
 > 321		[TPS65215] = {
   322			.rdesc = tps65215_regs,
   323			.rdesc_size = ARRAY_SIZE(tps65215_regs),
   324			.common_rdesc = common_regs,
   325			.common_rdesc_size = ARRAY_SIZE(common_regs),
   326		},
   327		[TPS65219] = {
   328			.rdesc = tps65219_regs,
   329			.rdesc_size = ARRAY_SIZE(tps65219_regs),
   330			.common_rdesc = common_regs,
   331			.common_rdesc_size = ARRAY_SIZE(common_regs),
   332		},
   333	};
   334	
   335	static int tps65219_regulator_probe(struct platform_device *pdev)
   336	{
   337		struct tps65219_regulator_irq_data *irq_data;
   338		struct tps65219_regulator_irq_type *irq_type;
   339	
   340		struct tps65219_chip_data *pmic;
   341		struct regulator_dev *rdev;
   342		int error;
   343		int irq;
   344		int i;
   345	
   346		struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
   347		struct regulator_config config = { };
 > 348		enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
   349		pmic = &chip_info_table[chip];
   350	
   351		config.dev = tps->dev;
   352		config.driver_data = tps;
   353		config.regmap = tps->regmap;
   354	
   355		for (i = 0; i <  pmic->common_rdesc_size; i++) {
   356			rdev = devm_regulator_register(&pdev->dev, &pmic->common_rdesc[i],
   357						       &config);
   358			if (IS_ERR(rdev))
   359				 return dev_err_probe(tps->dev, PTR_ERR(rdev),
   360						      "Failed to register %s regulator\n",
   361						      pmic->common_rdesc[i].name);
   362		}
   363	
   364		for (i = 0; i <  pmic->rdesc_size; i++) {
   365			rdev = devm_regulator_register(&pdev->dev, &pmic->rdesc[i],
   366						       &config);
   367			if (IS_ERR(rdev))
   368				return dev_err_probe(tps->dev, PTR_ERR(rdev),
   369						     "Failed to register %s regulator\n",
   370						     pmic->rdesc[i].name);
   371		}
   372	
   373		irq_data = devm_kmalloc(tps->dev,
   374					ARRAY_SIZE(tps65219_regulator_irq_types) *
   375					sizeof(struct tps65219_regulator_irq_data),
   376					GFP_KERNEL);
   377		if (!irq_data)
   378			return -ENOMEM;
   379	
   380		for (i = 0; i < ARRAY_SIZE(tps65219_regulator_irq_types); ++i) {
   381			irq_type = &tps65219_regulator_irq_types[i];
   382	
   383			irq = platform_get_irq_byname(pdev, irq_type->irq_name);
   384			if (irq < 0)
   385				return -EINVAL;
   386	
   387			irq_data[i].dev = tps->dev;
   388			irq_data[i].type = irq_type;
   389	
   390			error = devm_request_threaded_irq(tps->dev, irq, NULL,
   391							  tps65219_regulator_irq_handler,
   392							  IRQF_ONESHOT,
   393							  irq_type->irq_name,
   394							  &irq_data[i]);
   395			if (error) {
   396				dev_err(tps->dev, "failed to request %s IRQ %d: %d\n",
   397					irq_type->irq_name, irq, error);
   398				return error;
   399			}
   400		}
   401	
   402		return 0;
   403	}
   404	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-19  2:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 23:10 [PATCH v3 0/4] Add TI TPS65215 PMIC Regulator Support Shree Ramamoorthy
2025-01-13 23:10 ` [PATCH v3 1/4] regulator: tps65215: Update struct names Shree Ramamoorthy
2025-01-13 23:10 ` [PATCH v3 2/4] regulator: dt-bindings: Add TI TPS65215 PMIC bindings Shree Ramamoorthy
2025-01-13 23:10 ` [PATCH v3 3/4] regulator: tps65215: Add support for TPS65215 regulator resources Shree Ramamoorthy
2025-01-17  9:15   ` kernel test robot
2025-01-19  2:16   ` kernel test robot
2025-01-13 23:10 ` [PATCH v3 4/4] regulator: tps65215: Add support for TPS65215 Regulator IRQs Shree Ramamoorthy
2025-01-14  0:49   ` Andrew Davis
2025-01-14 18:17     ` Shree Ramamoorthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).