[PATCH 1/2] regulator: pca9450: Add LOADSW regulator

Nicolas Heemeryck posted 2 patches 2 years, 11 months ago
[PATCH 1/2] regulator: pca9450: Add LOADSW regulator
Posted by Nicolas Heemeryck 2 years, 11 months ago
Make the load switch present in the PCA9450 accessible and configurable
from the devicetree. Note that the SWIn for the load switch is
connected to BUCK4.

Signed-off-by: Nicolas Heemeryck <nicolas.heemeryck@devialet.com>
---
 drivers/regulator/pca9450-regulator.c | 32 +++++++++++++++++++++++++++
 include/linux/regulator/pca9450.h     |  4 ++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9450-regulator.c
index c6351fac9f4d..ccb61fc73a59 100644
--- a/drivers/regulator/pca9450-regulator.c
+++ b/drivers/regulator/pca9450-regulator.c
@@ -99,6 +99,12 @@ static const struct regulator_ops pca9450_ldo_regulator_ops = {
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 };
 
+static const struct regulator_ops pca9450_loadsw_regulator_ops = {
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+};
+
 /*
  * BUCK1/2/3
  * 0.60 to 2.1875V (12.5mV step)
@@ -452,6 +458,19 @@ static const struct pca9450_regulator_desc pca9450a_regulators[] = {
 			.owner = THIS_MODULE,
 		},
 	},
+	{
+		.desc = {
+			.name = "loadsw",
+			.of_match = of_match_ptr("LOADSW"),
+			.regulators_node = of_match_ptr("regulators"),
+			.id = PCA9450_LOADSW,
+			.ops = &pca9450_loadsw_regulator_ops,
+			.type = REGULATOR_VOLTAGE,
+			.enable_reg = PCA9450_REG_LOADSW_CTRL,
+			.enable_mask = LOADSW_CTRL_EN_MASK,
+			.owner = THIS_MODULE,
+		},
+	},
 };
 
 /*
@@ -661,6 +680,19 @@ static const struct pca9450_regulator_desc pca9450bc_regulators[] = {
 			.owner = THIS_MODULE,
 		},
 	},
+	{
+		.desc = {
+			.name = "loadsw",
+			.of_match = of_match_ptr("LOADSW"),
+			.regulators_node = of_match_ptr("regulators"),
+			.id = PCA9450_LOADSW,
+			.ops = &pca9450_loadsw_regulator_ops,
+			.type = REGULATOR_VOLTAGE,
+			.enable_reg = PCA9450_REG_LOADSW_CTRL,
+			.enable_mask = LOADSW_CTRL_EN_MASK,
+			.owner = THIS_MODULE,
+		},
+	},
 };
 
 static irqreturn_t pca9450_irq_handler(int irq, void *data)
diff --git a/include/linux/regulator/pca9450.h b/include/linux/regulator/pca9450.h
index 3c01c2bf84f5..4e922d6010cb 100644
--- a/include/linux/regulator/pca9450.h
+++ b/include/linux/regulator/pca9450.h
@@ -24,6 +24,7 @@ enum {
 	PCA9450_LDO3,
 	PCA9450_LDO4,
 	PCA9450_LDO5,
+	PCA9450_LOADSW,
 	PCA9450_REGULATOR_CNT,
 };
 
@@ -209,6 +210,9 @@ enum {
 #define LDO5H_EN_MASK			0xC0
 #define LDO5HOUT_MASK			0x0F
 
+/* PCA9450_REG_LOADSW_CTRL bits */
+#define LOADSW_CTRL_EN_MASK		0x03
+
 /* PCA9450_REG_IRQ bits */
 #define IRQ_PWRON			0x80
 #define IRQ_WDOGB			0x40
-- 
2.34.1


-- 
- Confidential -