Skip to contentSkip to conversation

Qualcomm labibb regulator driver

PATCH Superseded Sumit Semwal 3 participants 7 messages Jun 22, 2020 – Jul 15, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v5 cover Qualcomm labibb regulator driver

This series adds a driver for LAB/IBB regulators found on some Qualcomm SoCs. These regulators provide positive and/or negative boost power supplies for LCD/LED display panels connected to the SoC.

This series adds the support for pmi8998 PMIC found in SDM845 family of SoCs.

Changes from v4:
- v4 Review comments incorporated
- simplified the driver: removed of_get_child_by_name(); use ENABLE_CTL register and switch over to use the regulator_*_regmap helpers
- improved kerneldoc
- From the dt-bindings, removed interrupt-names, changed to dual license, added unevaluatedProperties: false, removed interrupt-names, since there is only one interrupt per node
- Since the Short Circuit handling needs more details from QC engineers, drop the SC handling patch from this series, to submit it later

Changes from v3:
- Handled review comments from v3
- In core, swapped the meaning of enable_time and poll_enabled_time; so we wait for total enable_time delay, and poll in-between at poll_enabled_time interval now.
- fixed dt_bindings_check issues in dt-bindings patch.
- Cleanup of register_labibb_regulator(), and adapted to updated meaning of poll_enabled_time.

Changes from v2:
- Review comments from v2
- Moved the poll-to-check-enabled functionality to regulator core.
- Used more core features to simplify enable/disable functions.
- Moved the devicetree binding to yaml.
- Updated interrupt-names and simplified handling.

Changes from v1:
- Incorporated review comments from v1
- Changed from virtual-regulator based handling to individual regulator based handling.
- Reworked the core to merge most of enable/disable functions, combine the regulator_ops into one and allow for future variations.
- is_enabled() is now _really_ is_enabled()
- Simplified the SC interrupt handling - use regmap_read_poll_timeout, REGULATOR_EVENT_OVER_CURRENT handling and notification to clients.

Nisha Kumari (3):
dt-bindings: regulator: Add labibb regulator
arm64: dts: qcom: pmi8998: Add nodes for LAB and IBB regulators
regulator: qcom: Add labibb driver

Sumit Semwal (1):
regulator: Allow regulators to verify enabled during enable()

 .../regulator/qcom-labibb-regulator.yaml      |  70 +++++++
 arch/arm64/boot/dts/qcom/pmi8998.dtsi         |  12 ++
 drivers/regulator/Kconfig                     |  10 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/core.c                      |  63 ++++++-
 drivers/regulator/qcom-labibb-regulator.c     | 175 ++++++++++++++++++
 include/linux/regulator/driver.h              |   5 +
 7 files changed, 335 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml
 create mode 100644 drivers/regulator/qcom-labibb-regulator.c
Signature · 1 line
2.27.0
#1 lore raw

PATCH v5 1/4 regulator: Allow regulators to verify enabled during enable()

Some regulators might need to verify that they have indeed been enabled after the enable() call is made and enable_time delay has passed.

This is implemented by repeatedly checking is_enabled() upto poll_enabled_time, waiting for the already calculated enable delay in each iteration.

---
v3: addressed minor review comments, improved kernel doc
v2: Address review comments, including swapping enable_time and poll_enabled_time.

---
 drivers/regulator/core.c         | 63 +++++++++++++++++++++++++++++++-
 include/linux/regulator/driver.h |  5 +++
 2 files changed, 67 insertions(+), 1 deletion(-)
drivers/regulator/core.c +62 -1
index 03154f5b939f..538a2779986a 100644
@@ -2347,6 +2347,37 @@ static void _regulator_enable_delay(unsigned int delay)
 		udelay(us);
 }
 
+/**
+ * _regulator_check_status_enabled
+ *
+ * A helper function to check if the regulator status can be interpreted
+ * as 'regulator is enabled'.
+ * @rdev: the regulator device to check
+ *
+ * Return:
+ * * 1			- if status shows regulator is in enabled state
+ * * 0			- if not enabled state
+ * * Error Value	- as received from ops->get_status()
+ */
+static inline int _regulator_check_status_enabled(struct regulator_dev *rdev)
+{
+	int ret = rdev->desc->ops->get_status(rdev);
+
+	if (ret < 0) {
+		rdev_info(rdev, "get_status returned error: %d\n", ret);
+		return ret;
+	}
+
+	switch (ret) {
+	case REGULATOR_STATUS_OFF:
+	case REGULATOR_STATUS_ERROR:
+	case REGULATOR_STATUS_UNDEFINED:
+		return 0;
+	default:
+		return 1;
+	}
+}
+
 static int _regulator_do_enable(struct regulator_dev *rdev)
 {
 	int ret, delay;
@@ -2407,7 +2438,37 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
 	 * together.  */
 	trace_regulator_enable_delay(rdev_get_name(rdev));
 
-	_regulator_enable_delay(delay);
+	/* If poll_enabled_time is set, poll upto the delay calculated
+	 * above, delaying poll_enabled_time uS to check if the regulator
+	 * actually got enabled.
+	 * If the regulator isn't enabled after enable_delay has
+	 * expired, return -ETIMEDOUT.
+	 */
+	if (rdev->desc->poll_enabled_time) {
+		unsigned int time_remaining = delay;
+
+		while (time_remaining > 0) {
+			_regulator_enable_delay(rdev->desc->poll_enabled_time);
+
+			if (rdev->desc->ops->get_status) {
+				ret = _regulator_check_status_enabled(rdev);
+				if (ret < 0)
+					return ret;
+				else if (ret)
+					break;
+			} else if (rdev->desc->ops->is_enabled(rdev))
+				break;
+
+			time_remaining -= rdev->desc->poll_enabled_time;
+		}
+
+		if (time_remaining <= 0) {
+			rdev_err(rdev, "Enabled check timed out\n");
+			return -ETIMEDOUT;
+		}
+	} else {
+		_regulator_enable_delay(delay);
+	}
 
 	trace_regulator_enable_complete(rdev_get_name(rdev));
 
include/linux/regulator/driver.h +5 -0
index 7eb9fea8e482..436df3ba0b2a 100644
@@ -305,6 +305,9 @@ enum regulator_type {
  * @enable_time: Time taken for initial enable of regulator (in uS).
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
  *
+ * @poll_enabled_time: The polling interval (in uS) to use while checking that
+ *                     the regulator was actually enabled. Max upto enable_time.
+ *
  * @of_map_mode: Maps a hardware mode defined in a DeviceTree to a standard mode
  */
 struct regulator_desc {
@@ -372,6 +375,8 @@ struct regulator_desc {
 
 	unsigned int off_on_delay;
 
+	unsigned int poll_enabled_time;
+
 	unsigned int (*of_map_mode)(unsigned int mode);
 };
 
Signature · 1 line
2.27.0
#2 lore raw

PATCH v5 2/4 dt-bindings: regulator: Add labibb regulator

In reply to Sumit Semwal

From: Nisha Kumari <[email protected]>

Adding the devicetree binding for labibb regulator.

[sumits: cleanup as per review comments and update to yaml]

---
v5: Addressed review comments - removed interrupt-names, changed to
dual license, added unevaluatedProperties: false
v4: fixed dt_binding_check issues
v3: moved to yaml
v2: updated for better compatible string and names.

---
 .../regulator/qcom-labibb-regulator.yaml      | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml
Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml new file +70 -0
new file mode 100644
index 000000000000..085cbd1ad8d0
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/qcom-labibb-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm's LAB(LCD AMOLED Boost)/IBB(Inverting Buck Boost) Regulator
+
+maintainers:
+  - Sumit Semwal <[email protected]>
+
+description:
+  LAB can be used as a positive boost power supply and IBB can be used as a
+  negative boost power supply for display panels. Currently implemented for
+  pmi8998.
+
+properties:
+  compatible:
+    const: qcom,pmi8998-lab-ibb
+
+  lab:
+    type: object
+
+    properties:
+
+      interrupts:
+        maxItems: 1
+        description:
+          Short-circuit interrupt for lab.
+
+    required:
+    - interrupts
+
+  ibb:
+    type: object
+
+    properties:
+
+      interrupts:
+        maxItems: 1
+        description:
+          Short-circuit interrupt for lab.
+
+    required:
+    - interrupts
+
+required:
+  - compatible
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    labibb {
+      compatible = "qcom,pmi8998-lab-ibb";
+
+      lab {
+        interrupts = <0x3 0x0 IRQ_TYPE_EDGE_RISING>;
+        interrupt-names = "sc-err";
+      };
+
+      ibb {
+        interrupts = <0x3 0x2 IRQ_TYPE_EDGE_RISING>;
+        interrupt-names = "sc-err";
+      };
+    };
+
+...
Signature · 1 line
2.27.0
maintainer Reviewed-by on v5 2/4
#3 lore raw

Re: [PATCH v5 2/4] dt-bindings: regulator: Add labibb regulator

Quoted 14 lines · Sumit Semwal

From: Nisha Kumari <[email protected]>

Adding the devicetree binding for labibb regulator.

[sumits: cleanup as per review comments and update to yaml]

---
v5: Addressed review comments - removed interrupt-names, changed to
dual license, added unevaluatedProperties: false
v4: fixed dt_binding_check issues
v3: moved to yaml
v2: updated for better compatible string and names.

Quoted 5 lines
---
 .../regulator/qcom-labibb-regulator.yaml      | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml
#4 lore raw

PATCH v5 3/4 arm64: dts: qcom: pmi8998: Add nodes for LAB and IBB regulators

In reply to Sumit Semwal

From: Nisha Kumari <[email protected]>

This patch adds devicetree nodes for LAB and IBB regulators.

[sumits: Updated for better compatible strings and names]

---
v5: sumits: removed interrupt-names, since there is only one
interrupt per node
v4: sumits: removed labibb label which is not needed
v3: sumits: updated interrupt-names as per review comments
v2: sumits: updated for better compatible string and names

---
 arch/arm64/boot/dts/qcom/pmi8998.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/qcom/pmi8998.dtsi +12 -0
index 23f9146a161e..d016b12967eb 100644
@@ -25,5 +25,17 @@ pmi8998_lsid1: pmic@3 {
 		reg = <0x3 SPMI_USID>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+
+		labibb {
+			compatible = "qcom,pmi8998-lab-ibb";
+
+			ibb: ibb {
+				interrupts = <0x3 0xdc 0x2 IRQ_TYPE_EDGE_RISING>;
+			};
+
+			lab: lab {
+				interrupts = <0x3 0xde 0x0 IRQ_TYPE_EDGE_RISING>;
+			};
+		};
 	};
 };
Signature · 1 line
2.27.0
#5 lore raw

PATCH v5 4/4 regulator: qcom: Add labibb driver

In reply to Sumit Semwal

From: Nisha Kumari <[email protected]>

Qualcomm platforms have LAB(LCD AMOLED Boost)/IBB(Inverting Buck Boost) regulators, labibb for short, which are used as power supply for LCD Mode displays.

This patch adds labibb regulator driver for pmi8998 PMIC, found on SDM845 platforms.

[sumits: reworked the driver design as per upstream review]

---
v5: sumits: review comments addressed
- removed dev_info about registering
- removed of_get_child_by_name()
- changed from using STATUS1 register to using ENABLE_CTL; this allows us to use the regulator_*_regmap helpers and makes this code cleaner. (In limited testing, STATUS1 seemed to report the change faster than ENABLE_CTL, but in absence of mechanism to validate if the regulator has indeed fully ramped when STATUS1 starts flagging, broonie suggested to use the slower ENABLE_CTL path for safety).
v4: sumits: address review comments from v3, including cleaning up
register_labibb_regulator(), and adapted to updated meaning of poll_enabled_time.
v3: sumits: addressed review comments from v2; moved to use core
regulator features like enable_time, off_on_delay, and the newly added poll_enabled_time. Moved the check_enabled functionality to core framework via poll_enabled_time.
v2: sumits: reworked the driver for more common code, and addressed
review comments from v1

---
 drivers/regulator/Kconfig                 |  10 ++
 drivers/regulator/Makefile                |   1 +
 drivers/regulator/qcom-labibb-regulator.c | 175 ++++++++++++++++++++++
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/regulator/qcom-labibb-regulator.c
drivers/regulator/Kconfig +10 -0
index 8f677f5d79b4..c6377df023bc 100644
@@ -1178,5 +1178,15 @@ config REGULATOR_WM8994
 	  This driver provides support for the voltage regulators on the
 	  WM8994 CODEC.
 
+config REGULATOR_QCOM_LABIBB
+	tristate "QCOM LAB/IBB regulator support"
+	depends on SPMI || COMPILE_TEST
+	help
+	  This driver supports Qualcomm's LAB/IBB regulators present on the
+	  Qualcomm's PMIC chip pmi8998. QCOM LAB and IBB are SPMI
+	  based PMIC implementations. LAB can be used as positive
+	  boost regulator and IBB can be used as a negative boost regulator
+	  for LCD display panel.
+
 endif
 
drivers/regulator/Makefile +1 -0
index e8f163371071..2c2b0861df76 100644
@@ -88,6 +88,7 @@ obj-$(CONFIG_REGULATOR_MT6323)	+= mt6323-regulator.o
 obj-$(CONFIG_REGULATOR_MT6358)	+= mt6358-regulator.o
 obj-$(CONFIG_REGULATOR_MT6380)	+= mt6380-regulator.o
 obj-$(CONFIG_REGULATOR_MT6397)	+= mt6397-regulator.o
+obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o
drivers/regulator/qcom-labibb-regulator.c new file +175 -0

175 lines not on this page · raw message

Signature · 1 line
2.27.0
maintainer
#6 lore raw
In reply to Sumit Semwal
Quoted 17 lines · Sumit Semwal

This series adds a driver for LAB/IBB regulators found on some Qualcomm SoCs. These regulators provide positive and/or negative boost power supplies for LCD/LED display panels connected to the SoC.

This series adds the support for pmi8998 PMIC found in SDM845 family of SoCs.

Changes from v4:
- v4 Review comments incorporated
- simplified the driver: removed of_get_child_by_name(); use ENABLE_CTL register and switch over to use the regulator_*_regmap helpers
- improved kerneldoc
- From the dt-bindings, removed interrupt-names, changed to dual license, added unevaluatedProperties: false, removed interrupt-names, since there is only one interrupt per node
- Since the Short Circuit handling needs more details from QC engineers, drop the SC handling patch from this series, to submit it later

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/3] regulator: Allow regulators to verify enabled during enable()

      commit: f7d7ad42a9dc2d63cab6a79fe31e6732a30dacf5
[2/3] regulator: Add labibb regulator binding
      commit: 88c14de2b6786ef503fd1bc2c952159e65fe45cc
[3/3] regulator: qcom: Add labibb driver
      commit: 498ab2fdf8554690c9567c1eee436b858637e3ff

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark