diff mbox series

[v1,5/7] regulator: tps65215: Add chip_data struct for multi-PMIC support

Message ID 20241226215412.395822-6-s-ramamoorthy@ti.com
State New
Headers show
Series None | expand

Commit Message

Shree Ramamoorthy Dec. 26, 2024, 9:54 p.m. UTC
'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.

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
---
 drivers/regulator/tps65219-regulator.c | 32 ++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c
index 2c49613400e1..13f0e68d8e85 100644
--- a/drivers/regulator/tps65219-regulator.c
+++ b/drivers/regulator/tps65219-regulator.c
@@ -314,6 +314,39 @@  static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+struct chip_data {
+	size_t common_irq_size;
+	size_t common_rdesc_size;
+
+	size_t dev_irq_size
+	size_t rdesc_size;
+	struct tps65219_regulator_irq_type *common_irq_types;
+	struct tps65219_regulator_irq_type *irq_types;
+	const struct regulator_desc *common_rdesc;
+	const struct regulator_desc *rdesc;
+};
+
+static struct chip_data chip_info_table[] = {
+	[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),
+	},
+	[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),
+	},
+};
+
 static int tps65219_regulator_probe(struct platform_device *pdev)
 {
 	struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);