linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] STPMIC1 Fixes
@ 2019-02-19 10:04 Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 1/8] regulator: stpmic1: Use regulator mode definition from bindings Pascal PAILLET-LME
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

The goal of this patch-set is to improve the stpmic1 regulator driver:
with Fixes:
- Simplify regulator registration code
- Remove support of regulator pull-down
- Fix buck1 voltage range
- Fix binding documentation
with a new feature:
- Add support for active discharge

Pascal Paillet (8):
  regulator: stpmic1: Use regulator mode definition from bindings
  regulator: stpmic1: Simplify regulators registration
  dt-bindings: regulator: remove interrupt-parent description on stpmic1
  dt-bindings: regulator: remove regulator pull-down support for stpmic1
  regulator: stpmic1: Remove support for regulator pull down
  regulator: stpmic1: Change buck1 voltage range
  dt-bindings: regulator: Add active discharge support for stpmic1
  regulator: stpmic1: Add active discharge support

 .../bindings/regulator/st,stpmic1-regulator.txt    |   6 +-
 drivers/regulator/stpmic1_regulator.c              | 258 +++++++++------------
 2 files changed, 113 insertions(+), 151 deletions(-)

-- 
1.9.1

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

* [PATCH 1/8] regulator: stpmic1: Use regulator mode definition from bindings
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 3/8] dt-bindings: regulator: remove interrupt-parent description on stpmic1 Pascal PAILLET-LME
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Get the regulator mode definition from the bindings header.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 drivers/regulator/stpmic1_regulator.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index d456fb5..c25f82f 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -12,6 +12,8 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>
 
+#include <dt-bindings/mfd/st,stpmic1.h>
+
 /**
  * stpmic1 regulator description
  * @desc: regulator framework description
@@ -68,9 +70,6 @@ enum {
 /* Enable time worst case is 5000mV/(2250uV/uS) */
 #define PMIC_ENABLE_TIME_US 2200
 
-#define STPMIC1_BUCK_MODE_NORMAL 0
-#define STPMIC1_BUCK_MODE_LP BUCK_HPLP_ENABLE_MASK
-
 static const struct regulator_linear_range buck1_ranges[] = {
 	REGULATOR_LINEAR_RANGE(600000, 0, 30, 25000),
 	REGULATOR_LINEAR_RANGE(1350000, 31, 63, 0),
-- 
1.9.1

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

* [PATCH 2/8] regulator: stpmic1: Simplify regulators registration
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 1/8] regulator: stpmic1: Use regulator mode definition from bindings Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 3/8] dt-bindings: regulator: remove interrupt-parent description on stpmic1 Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 4/8] dt-bindings: regulator: remove regulator pull-down support for stpmic1 Pascal PAILLET-LME
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Stop using a regulator_init callback. This leads to a more simple regulator
registration code. This also permits to spuress struct stpmic1_regulator.
Also rename stpmic1_regulators_matches to stpmic1_matches.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 drivers/regulator/stpmic1_regulator.c | 168 +++++++++++-----------------------
 1 file changed, 52 insertions(+), 116 deletions(-)

diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index c25f82f..f5c0e58 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -15,7 +15,7 @@
 #include <dt-bindings/mfd/st,stpmic1.h>
 
 /**
- * stpmic1 regulator description
+ * stpmic1 regulator description: this structure is used as driver data
  * @desc: regulator framework description
  * @mask_reset_reg: mask reset register address
  * @mask_reset_mask: mask rank and mask reset register mask
@@ -30,24 +30,9 @@ struct stpmic1_regulator_cfg {
 	u8 icc_mask;
 };
 
-/**
- * stpmic1 regulator data: this structure is used as driver data
- * @reg_node: DT node of regulator (unused on non-DT platforms)
- * @cfg: stpmic specific regulator description
- * @mask_reset: mask_reset bit value
- * @irq_curlim: current limit interrupt number
- */
-struct stpmic1_regulator {
-	struct device_node *reg_node;
-	const struct stpmic1_regulator_cfg *cfg;
-	u8 mask_reset;
-	int irq_curlim;
-};
-
 static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode);
 static unsigned int stpmic1_get_mode(struct regulator_dev *rdev);
 static int stpmic1_set_icc(struct regulator_dev *rdev);
-static int stpmic1_regulator_parse_dt(void *driver_data);
 static unsigned int stpmic1_map_mode(unsigned int mode);
 
 enum {
@@ -439,8 +424,9 @@ static unsigned int stpmic1_map_mode(unsigned int mode)
 static unsigned int stpmic1_get_mode(struct regulator_dev *rdev)
 {
 	int value;
+	struct regmap *regmap = rdev_get_regmap(rdev);
 
-	regmap_read(rdev->regmap, rdev->desc->enable_reg, &value);
+	regmap_read(regmap, rdev->desc->enable_reg, &value);
 
 	if (value & STPMIC1_BUCK_MODE_LP)
 		return REGULATOR_MODE_STANDBY;
@@ -451,6 +437,7 @@ static unsigned int stpmic1_get_mode(struct regulator_dev *rdev)
 static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode)
 {
 	int value;
+	struct regmap *regmap = rdev_get_regmap(rdev);
 
 	switch (mode) {
 	case REGULATOR_MODE_NORMAL:
@@ -463,18 +450,18 @@ static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode)
 		return -EINVAL;
 	}
 
-	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
+	return regmap_update_bits(regmap, rdev->desc->enable_reg,
 				  STPMIC1_BUCK_MODE_LP, value);
 }
 
 static int stpmic1_set_icc(struct regulator_dev *rdev)
 {
-	struct stpmic1_regulator *regul = rdev_get_drvdata(rdev);
+	struct stpmic1_regulator_cfg *cfg = rdev_get_drvdata(rdev);
 	struct regmap *regmap = rdev_get_regmap(rdev);
 
 	/* enable switch off in case of over current */
-	return regmap_update_bits(regmap, regul->cfg->icc_reg,
-				  regul->cfg->icc_mask, regul->cfg->icc_mask);
+	return regmap_update_bits(regmap, cfg->icc_reg, cfg->icc_mask,
+				  cfg->icc_mask);
 }
 
 static irqreturn_t stpmic1_curlim_irq_handler(int irq, void *data)
@@ -493,47 +480,13 @@ static irqreturn_t stpmic1_curlim_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int stpmic1_regulator_init(struct platform_device *pdev,
-				  struct regulator_dev *rdev)
-{
-	struct stpmic1_regulator *regul = rdev_get_drvdata(rdev);
-	struct regmap *regmap = rdev_get_regmap(rdev);
-	int ret = 0;
-
-	/* set mask reset */
-	if (regul->mask_reset && regul->cfg->mask_reset_reg != 0) {
-		ret = regmap_update_bits(regmap,
-					 regul->cfg->mask_reset_reg,
-					 regul->cfg->mask_reset_mask,
-					 regul->cfg->mask_reset_mask);
-		if (ret) {
-			dev_err(&pdev->dev, "set mask reset failed\n");
-			return ret;
-		}
-	}
-
-	/* setup an irq handler for over-current detection */
-	if (regul->irq_curlim > 0) {
-		ret = devm_request_threaded_irq(&pdev->dev,
-						regul->irq_curlim, NULL,
-						stpmic1_curlim_irq_handler,
-						IRQF_ONESHOT | IRQF_SHARED,
-						pdev->name, rdev);
-		if (ret) {
-			dev_err(&pdev->dev, "Request IRQ failed\n");
-			return ret;
-		}
-	}
-	return 0;
-}
-
 #define MATCH(_name, _id) \
 	[STPMIC1_##_id] = { \
 		.name = #_name, \
 		.desc = &stpmic1_regulator_cfgs[STPMIC1_##_id].desc, \
 	}
 
-static struct of_regulator_match stpmic1_regulators_matches[] = {
+static struct of_regulator_match stpmic1_matches[] = {
 	MATCH(buck1, BUCK1),
 	MATCH(buck2, BUCK2),
 	MATCH(buck3, BUCK3),
@@ -550,92 +503,75 @@ static int stpmic1_regulator_init(struct platform_device *pdev,
 	MATCH(pwr_sw2, SW_OUT),
 };
 
-static int stpmic1_regulator_parse_dt(void *driver_data)
-{
-	struct stpmic1_regulator *regul =
-		(struct stpmic1_regulator *)driver_data;
-
-	if (!regul)
-		return -EINVAL;
-
-	if (of_get_property(regul->reg_node, "st,mask-reset", NULL))
-		regul->mask_reset = 1;
-
-	regul->irq_curlim = of_irq_get(regul->reg_node, 0);
-
-	return 0;
-}
-
-static struct
-regulator_dev *stpmic1_regulator_register(struct platform_device *pdev, int id,
-					  struct regulator_init_data *init_data,
-					  struct stpmic1_regulator *regul)
+static int stpmic1_regulator_register(struct platform_device *pdev, int id,
+				      struct of_regulator_match *match,
+				      const struct stpmic1_regulator_cfg *cfg)
 {
 	struct stpmic1 *pmic_dev = dev_get_drvdata(pdev->dev.parent);
 	struct regulator_dev *rdev;
 	struct regulator_config config = {};
+	int ret = 0;
+	int irq;
 
 	config.dev = &pdev->dev;
-	config.init_data = init_data;
-	config.of_node = stpmic1_regulators_matches[id].of_node;
+	config.init_data = match->init_data;
+	config.of_node = match->of_node;
 	config.regmap = pmic_dev->regmap;
-	config.driver_data = regul;
-
-	regul->reg_node = config.of_node;
-	regul->cfg = &stpmic1_regulator_cfgs[id];
+	config.driver_data = (void *)cfg;
 
-	rdev = devm_regulator_register(&pdev->dev, &regul->cfg->desc, &config);
+	rdev = devm_regulator_register(&pdev->dev, &cfg->desc, &config);
 	if (IS_ERR(rdev)) {
 		dev_err(&pdev->dev, "failed to register %s regulator\n",
-			regul->cfg->desc.name);
+			cfg->desc.name);
+		return PTR_ERR(rdev);
 	}
 
-	return rdev;
+	/* set mask reset */
+	if (of_get_property(config.of_node, "st,mask-reset", NULL) &&
+	    cfg->mask_reset_reg != 0) {
+		ret = regmap_update_bits(pmic_dev->regmap,
+					 cfg->mask_reset_reg,
+					 cfg->mask_reset_mask,
+					 cfg->mask_reset_mask);
+		if (ret) {
+			dev_err(&pdev->dev, "set mask reset failed\n");
+			return ret;
+		}
+	}
+
+	/* setup an irq handler for over-current detection */
+	irq = of_irq_get(config.of_node, 0);
+	if (irq > 0) {
+		ret = devm_request_threaded_irq(&pdev->dev,
+						irq, NULL,
+						stpmic1_curlim_irq_handler,
+						IRQF_ONESHOT | IRQF_SHARED,
+						pdev->name, rdev);
+		if (ret) {
+			dev_err(&pdev->dev, "Request IRQ failed\n");
+			return ret;
+		}
+	}
+	return 0;
 }
 
 static int stpmic1_regulator_probe(struct platform_device *pdev)
 {
-	struct regulator_dev *rdev;
-	struct stpmic1_regulator *regul;
-	struct regulator_init_data *init_data;
-	struct device_node *np;
 	int i, ret;
 
-	np = pdev->dev.of_node;
-
-	ret = of_regulator_match(&pdev->dev, np,
-				 stpmic1_regulators_matches,
-				 ARRAY_SIZE(stpmic1_regulators_matches));
+	ret = of_regulator_match(&pdev->dev, pdev->dev.of_node, stpmic1_matches,
+				 ARRAY_SIZE(stpmic1_matches));
 	if (ret < 0) {
 		dev_err(&pdev->dev,
 			"Error in PMIC regulator device tree node");
 		return ret;
 	}
 
-	regul = devm_kzalloc(&pdev->dev, ARRAY_SIZE(stpmic1_regulator_cfgs) *
-			     sizeof(struct stpmic1_regulator),
-			     GFP_KERNEL);
-	if (!regul)
-		return -ENOMEM;
-
 	for (i = 0; i < ARRAY_SIZE(stpmic1_regulator_cfgs); i++) {
-		/* Parse DT & find regulators to register */
-		init_data = stpmic1_regulators_matches[i].init_data;
-		if (init_data)
-			init_data->regulator_init = &stpmic1_regulator_parse_dt;
-
-		rdev = stpmic1_regulator_register(pdev, i, init_data, regul);
-		if (IS_ERR(rdev))
-			return PTR_ERR(rdev);
-
-		ret = stpmic1_regulator_init(pdev, rdev);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"failed to initialize regulator %d\n", ret);
+		ret = stpmic1_regulator_register(pdev, i, &stpmic1_matches[i],
+						 &stpmic1_regulator_cfgs[i]);
+		if (ret < 0)
 			return ret;
-		}
-
-		regul++;
 	}
 
 	dev_dbg(&pdev->dev, "stpmic1_regulator driver probed\n");
-- 
1.9.1

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

* [PATCH 3/8] dt-bindings: regulator: remove interrupt-parent description on stpmic1
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 1/8] regulator: stpmic1: Use regulator mode definition from bindings Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 2/8] regulator: stpmic1: Simplify regulators registration Pascal PAILLET-LME
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

The interrupt parent description is not needed as the parent is a parent
node with 'interrupt-controller' property.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt b/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
index a3f4762..de27897 100644
--- a/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
@@ -29,7 +29,6 @@ Optional properties:
     if set, all regulators are switched off in case of over-current detection
     on this regulator,
     if not set, the driver only sends an over-current event.
-- interrupt-parent: phandle to the parent interrupt controller
 - interrupts: index of current limit detection interrupt
 - <regulator>-supply: phandle to the parent supply/regulator node
 	each regulator supply can be described except vref_ddr.
@@ -43,7 +42,6 @@ regulators {
 	vdd_core: buck1 {
 		regulator-name = "vdd_core";
 		interrupts = <IT_CURLIM_BUCK1 0>;
-		interrupt-parent = <&pmic>;
 		st,mask-reset;
 		regulator-pull-down;
 		regulator-min-microvolt = <700000>;
@@ -53,7 +51,6 @@ regulators {
 	v3v3: buck4 {
 		regulator-name = "v3v3";
 		interrupts = <IT_CURLIM_BUCK4 0>;
-		interrupt-parent = <&mypmic>;
 
 		regulator-min-microvolt = <3300000>;
 		regulator-max-microvolt = <3300000>;
-- 
1.9.1

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

* [PATCH 5/8] regulator: stpmic1: Remove support for regulator pull down
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
                   ` (3 preceding siblings ...)
  2019-02-19 10:04 ` [PATCH 4/8] dt-bindings: regulator: remove regulator pull-down support for stpmic1 Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 6/8] regulator: stpmic1: Change buck1 voltage range Pascal PAILLET-LME
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Regulator high pull down are enabled by default so remove support in the
driver.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 drivers/regulator/stpmic1_regulator.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index f5c0e58..6970e45 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -133,7 +133,6 @@ enum {
 	.disable = regulator_disable_regmap,
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
-	.set_pull_down = regulator_set_pull_down_regmap,
 	.set_over_current_protection = stpmic1_set_icc,
 };
 
@@ -145,7 +144,6 @@ enum {
 	.disable = regulator_disable_regmap,
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
-	.set_pull_down = regulator_set_pull_down_regmap,
 	.get_bypass = regulator_get_bypass_regmap,
 	.set_bypass = regulator_set_bypass_regmap,
 	.set_over_current_protection = stpmic1_set_icc,
@@ -155,7 +153,6 @@ enum {
 	.is_enabled = regulator_is_enabled_regmap,
 	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
-	.set_pull_down = regulator_set_pull_down_regmap,
 	.set_over_current_protection = stpmic1_set_icc,
 };
 
@@ -177,7 +174,6 @@ enum {
 	.is_enabled = regulator_is_enabled_regmap,
 	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
-	.set_pull_down = regulator_set_pull_down_regmap,
 };
 
 static const struct regulator_ops stpmic1_switch_regul_ops = {
@@ -203,8 +199,6 @@ enum {
 	.enable_val = 1, \
 	.disable_val = 0, \
 	.enable_time = PMIC_ENABLE_TIME_US, \
-	.pull_down_reg = ids##_PULL_DOWN_REG, \
-	.pull_down_mask = ids##_PULL_DOWN_MASK, \
 	.supply_name = #base, \
 }
 
@@ -228,8 +222,6 @@ enum {
 	.bypass_mask = LDO_BYPASS_MASK, \
 	.bypass_val_on = LDO_BYPASS_MASK, \
 	.bypass_val_off = 0, \
-	.pull_down_reg = ids##_PULL_DOWN_REG, \
-	.pull_down_mask = ids##_PULL_DOWN_MASK, \
 	.supply_name = #base, \
 }
 
@@ -247,8 +239,6 @@ enum {
 	.enable_val = 1, \
 	.disable_val = 0, \
 	.enable_time = PMIC_ENABLE_TIME_US, \
-	.pull_down_reg = ids##_PULL_DOWN_REG, \
-	.pull_down_mask = ids##_PULL_DOWN_MASK, \
 	.supply_name = #base, \
 }
 
@@ -288,8 +278,6 @@ enum {
 	.enable_val = 1, \
 	.disable_val = 0, \
 	.enable_time = PMIC_ENABLE_TIME_US, \
-	.pull_down_reg = ids##_PULL_DOWN_REG, \
-	.pull_down_mask = ids##_PULL_DOWN_MASK, \
 	.supply_name = #base, \
 }
 
-- 
1.9.1

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

* [PATCH 4/8] dt-bindings: regulator: remove regulator pull-down support for stpmic1
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
                   ` (2 preceding siblings ...)
  2019-02-19 10:04 ` [PATCH 2/8] regulator: stpmic1: Simplify regulators registration Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 5/8] regulator: stpmic1: Remove support for regulator pull down Pascal PAILLET-LME
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Regulator high pull down are enabled by default so remove support in the
driver.

Signed-off-by: Pascal Paillet <p.paillet@st.com>
---
 Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt b/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
index de27897..bf9385b 100644
--- a/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
@@ -23,8 +23,6 @@ Switches are fixed voltage regulators with only enable/disable capability.
 Optional properties:
 - st,mask-reset: mask reset for this regulator: the regulator configuration
   is maintained during pmic reset.
-- regulator-pull-down: enable high pull down
-  if not specified light pull down is used
 - regulator-over-current-protection:
     if set, all regulators are switched off in case of over-current detection
     on this regulator,
-- 
1.9.1

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

* [PATCH 7/8] dt-bindings: regulator: Add active discharge support for stpmic1
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
                   ` (5 preceding siblings ...)
  2019-02-19 10:04 ` [PATCH 6/8] regulator: stpmic1: Change buck1 voltage range Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 8/8] regulator: stpmic1: Add active discharge support Pascal PAILLET-LME
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Add support for active discharge for USB power switches.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt b/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
index bf9385b..6189df7 100644
--- a/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/st,stpmic1-regulator.txt
@@ -30,6 +30,7 @@ Optional properties:
 - interrupts: index of current limit detection interrupt
 - <regulator>-supply: phandle to the parent supply/regulator node
 	each regulator supply can be described except vref_ddr.
+- regulator-active-discharge: can be used on pwr_sw1 and pwr_sw2.
 
 Example:
 regulators {
-- 
1.9.1

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

* [PATCH 6/8] regulator: stpmic1: Change buck1 voltage range
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
                   ` (4 preceding siblings ...)
  2019-02-19 10:04 ` [PATCH 5/8] regulator: stpmic1: Remove support for regulator pull down Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  2019-02-19 10:42   ` Mark Brown
  2019-02-19 10:04 ` [PATCH 7/8] dt-bindings: regulator: Add active discharge support for stpmic1 Pascal PAILLET-LME
  2019-02-19 10:04 ` [PATCH 8/8] regulator: stpmic1: Add active discharge support Pascal PAILLET-LME
  7 siblings, 1 reply; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Change buck1 voltage range to be conform with the data-sheet.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 drivers/regulator/stpmic1_regulator.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index 6970e45..41128c4 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -56,8 +56,9 @@ enum {
 #define PMIC_ENABLE_TIME_US 2200
 
 static const struct regulator_linear_range buck1_ranges[] = {
-	REGULATOR_LINEAR_RANGE(600000, 0, 30, 25000),
-	REGULATOR_LINEAR_RANGE(1350000, 31, 63, 0),
+	REGULATOR_LINEAR_RANGE(725000, 0, 4, 0),
+	REGULATOR_LINEAR_RANGE(725000, 5, 36, 25000),
+	REGULATOR_LINEAR_RANGE(1500000, 37, 63, 0),
 };
 
 static const struct regulator_linear_range buck2_ranges[] = {
-- 
1.9.1

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

* [PATCH 8/8] regulator: stpmic1: Add active discharge support
  2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
                   ` (6 preceding siblings ...)
  2019-02-19 10:04 ` [PATCH 7/8] dt-bindings: regulator: Add active discharge support for stpmic1 Pascal PAILLET-LME
@ 2019-02-19 10:04 ` Pascal PAILLET-LME
  7 siblings, 0 replies; 10+ messages in thread
From: Pascal PAILLET-LME @ 2019-02-19 10:04 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, linux-kernel,
	devicetree, axel.lin
  Cc: Pascal PAILLET-LME, benjamin.gaignard, linux-stm32

Add support for active discharge for USB power switches.

Signed-off-by: pascal paillet <p.paillet@st.com>
---
 drivers/regulator/stpmic1_regulator.c | 68 ++++++++++++++++++++++++++++-------
 1 file changed, 55 insertions(+), 13 deletions(-)

diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index 41128c4..f090614 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -177,11 +177,19 @@ enum {
 	.disable = regulator_disable_regmap,
 };
 
+static const struct regulator_ops stpmic1_boost_regul_ops = {
+	.is_enabled = regulator_is_enabled_regmap,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.set_over_current_protection = stpmic1_set_icc,
+};
+
 static const struct regulator_ops stpmic1_switch_regul_ops = {
 	.is_enabled = regulator_is_enabled_regmap,
 	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
 	.set_over_current_protection = stpmic1_set_icc,
+	.set_active_discharge = regulator_set_active_discharge_regmap,
 };
 
 #define REG_LDO(ids, base) { \
@@ -282,7 +290,44 @@ enum {
 	.supply_name = #base, \
 }
 
-#define REG_SWITCH(ids, base, reg, mask, val) { \
+#define REG_BOOST(ids, base) { \
+	.name = #ids, \
+	.id = STPMIC1_##ids, \
+	.n_voltages = 1, \
+	.ops = &stpmic1_boost_regul_ops, \
+	.type = REGULATOR_VOLTAGE, \
+	.owner = THIS_MODULE, \
+	.min_uV = 0, \
+	.fixed_uV = 5000000, \
+	.enable_reg = BST_SW_CR, \
+	.enable_mask = BOOST_ENABLED, \
+	.enable_val = BOOST_ENABLED, \
+	.disable_val = 0, \
+	.enable_time = PMIC_ENABLE_TIME_US, \
+	.supply_name = #base, \
+}
+
+#define REG_VBUS_OTG(ids, base) { \
+	.name = #ids, \
+	.id = STPMIC1_##ids, \
+	.n_voltages = 1, \
+	.ops = &stpmic1_switch_regul_ops, \
+	.type = REGULATOR_VOLTAGE, \
+	.owner = THIS_MODULE, \
+	.min_uV = 0, \
+	.fixed_uV = 5000000, \
+	.enable_reg = BST_SW_CR, \
+	.enable_mask = USBSW_OTG_SWITCH_ENABLED, \
+	.enable_val = USBSW_OTG_SWITCH_ENABLED, \
+	.disable_val = 0, \
+	.enable_time = PMIC_ENABLE_TIME_US, \
+	.supply_name = #base, \
+	.active_discharge_reg = BST_SW_CR, \
+	.active_discharge_mask = VBUS_OTG_DISCHARGE, \
+	.active_discharge_on = VBUS_OTG_DISCHARGE, \
+}
+
+#define REG_SW_OUT(ids, base) { \
 	.name = #ids, \
 	.id = STPMIC1_##ids, \
 	.n_voltages = 1, \
@@ -291,12 +336,15 @@ enum {
 	.owner = THIS_MODULE, \
 	.min_uV = 0, \
 	.fixed_uV = 5000000, \
-	.enable_reg = (reg), \
-	.enable_mask = (mask), \
-	.enable_val = (val), \
+	.enable_reg = BST_SW_CR, \
+	.enable_mask = SWIN_SWOUT_ENABLED, \
+	.enable_val = SWIN_SWOUT_ENABLED, \
 	.disable_val = 0, \
 	.enable_time = PMIC_ENABLE_TIME_US, \
 	.supply_name = #base, \
+	.active_discharge_reg = BST_SW_CR, \
+	.active_discharge_mask = SW_OUT_DISCHARGE, \
+	.active_discharge_on = SW_OUT_DISCHARGE, \
 }
 
 static const struct stpmic1_regulator_cfg stpmic1_regulator_cfgs[] = {
@@ -376,23 +424,17 @@ enum {
 		.mask_reset_mask = BIT(6),
 	},
 	[STPMIC1_BOOST] = {
-		.desc = REG_SWITCH(BOOST, boost, BST_SW_CR,
-				   BOOST_ENABLED,
-				   BOOST_ENABLED),
+		.desc = REG_BOOST(BOOST, boost),
 		.icc_reg = BUCKS_ICCTO_CR,
 		.icc_mask = BIT(6),
 	},
 	[STPMIC1_VBUS_OTG] = {
-		.desc = REG_SWITCH(VBUS_OTG, pwr_sw1, BST_SW_CR,
-				   USBSW_OTG_SWITCH_ENABLED,
-				   USBSW_OTG_SWITCH_ENABLED),
+		.desc = REG_VBUS_OTG(VBUS_OTG, pwr_sw1),
 		.icc_reg = BUCKS_ICCTO_CR,
 		.icc_mask = BIT(4),
 	},
 	[STPMIC1_SW_OUT] = {
-		.desc = REG_SWITCH(SW_OUT, pwr_sw2, BST_SW_CR,
-				   SWIN_SWOUT_ENABLED,
-				   SWIN_SWOUT_ENABLED),
+		.desc = REG_SW_OUT(SW_OUT, pwr_sw2),
 		.icc_reg = BUCKS_ICCTO_CR,
 		.icc_mask = BIT(5),
 	},
-- 
1.9.1

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

* Re: [PATCH 6/8] regulator: stpmic1: Change buck1 voltage range
  2019-02-19 10:04 ` [PATCH 6/8] regulator: stpmic1: Change buck1 voltage range Pascal PAILLET-LME
@ 2019-02-19 10:42   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2019-02-19 10:42 UTC (permalink / raw)
  To: Pascal PAILLET-LME
  Cc: lgirdwood, robh+dt, mark.rutland, linux-kernel, devicetree,
	axel.lin, benjamin.gaignard, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

On Tue, Feb 19, 2019 at 10:04:34AM +0000, Pascal PAILLET-LME wrote:
> Change buck1 voltage range to be conform with the data-sheet.

This is a bug fix so it should've gone at the start of the series to
make it easier to apply and send to Linus as a fix.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-02-19 10:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 10:04 [PATCH 0/8] STPMIC1 Fixes Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 1/8] regulator: stpmic1: Use regulator mode definition from bindings Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 3/8] dt-bindings: regulator: remove interrupt-parent description on stpmic1 Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 2/8] regulator: stpmic1: Simplify regulators registration Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 4/8] dt-bindings: regulator: remove regulator pull-down support for stpmic1 Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 5/8] regulator: stpmic1: Remove support for regulator pull down Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 6/8] regulator: stpmic1: Change buck1 voltage range Pascal PAILLET-LME
2019-02-19 10:42   ` Mark Brown
2019-02-19 10:04 ` [PATCH 7/8] dt-bindings: regulator: Add active discharge support for stpmic1 Pascal PAILLET-LME
2019-02-19 10:04 ` [PATCH 8/8] regulator: stpmic1: Add active discharge support Pascal PAILLET-LME

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