SPMI regulator driver
Subsystems (3)
v2 cover SPMI regulator driver
This patchset adds support for the regulators found on Qualcomm's SPMI PMICs. The first patch is the "basic" driver that doesn't have any non-standard features. The next 4 patches add ways to configure some of the non-standard features that are generic but aren't supported in the regulator framework. And the final patch adds support for the non-standard features and some vendor specific features to the SPMI regulator driver.
Changes since v1:
* Split driver into standard and non-standard patches to ease review
* New patches to regulator framework for non-standard features
* Added bypass support
* Namespaced macros
* Switch to set_load() ops instead of get_optimum_mode()
* Consolidated range finding code
* Used delay op to calculate how long to delay after setting voltage on FTSMPS
Stephen Boyd (6):
regulator: Add QCOM SPMI regulator driver
regulator: Add system_load constraint
regulator: Add pull down support
regulator: Add soft start support
regulator: Add input current limit support
regulator: qcom-spmi: Add vendor specific configuration
.../bindings/regulator/qcom,spmi-regulator.txt | 183 +++ .../devicetree/bindings/regulator/regulator.txt | 5 + drivers/regulator/Kconfig | 11 + drivers/regulator/Makefile | 1 + drivers/regulator/core.c | 27 + drivers/regulator/of_regulator.c | 12 + drivers/regulator/qcom_spmi-regulator.c | 1678 ++++++++++++++++++++ include/linux/regulator/driver.h | 10 + include/linux/regulator/machine.h | 8 + 9 files changed, 1935 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt create mode 100644 drivers/regulator/qcom_spmi-regulator.c
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/6 regulator: Add QCOM SPMI regulator driver
Add an SPMI regulator driver for Qualcomm's PM8841, PM8941, and PM8916 PMICs. This driver is based largely on code from codeaurora.org[1].
---
Changes from v1:
* Dropped custom DT properties
* Added bypass support
* Namespaced macros
* Switch to set_load() ops instead of get_optimum_mode()
.../bindings/regulator/qcom,spmi-regulator.txt | 121 ++ drivers/regulator/Kconfig | 11 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom_spmi-regulator.c | 1384 ++++++++++++++++++++ 4 files changed, 1517 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt create mode 100644 drivers/regulator/qcom_spmi-regulator.c
Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt new file +121 -0
@@ -0,0 +1,121 @@ +Qualcomm SPMI Regulators + +- compatible: + Usage: required + Value type: <string> + Definition: must be one of: + "qcom,pm8841-regulators" + "qcom,pm8916-regulators" + "qcom,pm8941-regulators" + +- interrupts: + Usage: optional + Value type: <prop-encoded-array> + Definition: List of OCP interrupts. + +- interrupt-names: + Usage: required if 'interrupts' property present + Value type: <string-array> + Definition: List of strings defining the names of the + interrupts in the 'interrupts' property 1-to-1. + Supported values are "ocp-<regulator_name>", where + <regulator_name> corresponds to a voltage switch + type regulator. + +- vdd_s1-supply: +- vdd_s2-supply: +- vdd_s3-supply: +- vdd_s4-supply: +- vdd_s5-supply: +- vdd_s6-supply: +- vdd_s7-supply: +- vdd_s8-supply: + Usage: optional (pm8841 only) + Value type: <phandle> + Definition: Reference to regulator supplying the input pin, as + described in the data sheet. + +- vdd_s1-supply: +- vdd_s2-supply: +- vdd_s3-supply: +- vdd_s4-supply: +- vdd_l1_l3-supply: +- vdd_l2-supply: +- vdd_l4_l5_l6-supply: +- vdd_l7-supply: +- vdd_l8_l11_l14_l15_l16-supply: +- vdd_l9_l10_l12_l13_l17_l18-supply: + Usage: optional (pm8916 only) + Value type: <phandle> + Definition: Reference to regulator supplying the input pin, as + described in the data sheet. + +- vdd_s1-supply: +- vdd_s2-supply: +- vdd_s3-supply: +- vdd_l1_l3-supply: +- vdd_l2_lvs_1_2_3-supply: +- vdd_l4_l11-supply: +- vdd_l5_l7-supply: +- vdd_l6_l12_l14_l15-supply: +- vdd_l8_l16_l18_19-supply: +- vdd_l9_l10_l17_l22-supply: +- vdd_l13_l20_l23_l24-supply: +- vdd_l21-supply: +- vin_5vs-supply: + Usage: optional (pm8941 only) + Value type: <phandle> + Definition: Reference to regulator supplying the input pin, as + described in the data sheet. + + +The regulator node houses sub-nodes for each regulator within the device. Each +sub-node is identified using the node's name, with valid values listed for each +of the PMICs below. + +pm8841: + s1, s2, s3, s4, s5, s6, s7, s8 + +pm8916: + s1, s2, s3, s4, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, + l14, l15, l16, l17, l18 + +pm8941: + s1, s2, s3, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, + l15, l16, l17, l18, l19, l20, l21, l22, l23, l24, lvs1, lvs2, lvs3, + mvs1, mvs2 + +The content of each sub-node is defined by the standard binding for regulators - +see regulator.txt - with additional custom properties described below: + +- regulator-initial-mode: + Usage: optional + Value type: <u32> + Descrption: 1 = Set initial mode to high power mode (HPM), also referred + to as NPM. HPM consumes more ground current than LPM, but + it can source significantly higher load current. HPM is not + available on boost type regulators. For voltage switch type + regulators, HPM implies that over current protection and + soft start are active all the time. 0 = Set initial mode to + low power mode (LPM). + +Example: + + regulators { + compatible = "qcom,pm8941-regulators"; + vdd_l1_l3-supply = <&s1>; + + s1: s1 { + regulator-min-microvolt = <1300000>; + regulator-max-microvolt = <1400000>; + }; + + ... + + l1: l1 { + regulator-min-microvolt = <1225000>; + regulator-max-microvolt = <1300000>; + }; + + .... + };
drivers/regulator/Kconfig +11 -0
@@ -524,6 +524,17 @@ config REGULATOR_QCOM_SMD_RPM Qualcomm RPM as a module. The module will be named "qcom_smd-regulator". +config REGULATOR_QCOM_SPMI + tristate "Qualcomm SPMI regulator driver" + depends on SPMI || COMPILE_TEST + help + If you say yes to this option, support will be included for the + regulators found in Qualcomm SPMI PMICs. + + Say M here if you want to include support for the regulators on the + Qualcomm SPMI PMICs as a module. The module will be named + "qcom_spmi-regulator". + config REGULATOR_RC5T583 tristate "RICOH RC5T583 Power regulators" depends on MFD_RC5T583
drivers/regulator/Makefile +1 -0
@@ -62,6 +62,7 @@ obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o +obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o obj-$(CONFIG_REGULATOR_PWM) += pwm-regulator.o
drivers/regulator/qcom_spmi-regulator.c new file +1384 -0
1,384 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 2/6 regulator: Add system_load constraint
In reply to Stephen BoydSome regulators have a fixed load that isn't captured by consumers that the kernel knows about. Add a constraint to support this.
--- Documentation/devicetree/bindings/regulator/regulator.txt | 2 ++ drivers/regulator/core.c | 2 ++ drivers/regulator/of_regulator.c | 3 +++ include/linux/regulator/machine.h | 3 +++ 4 files changed, 10 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +2 -0
@@ -37,6 +37,8 @@ Optional properties: - regulator-initial-mode: initial operating mode. The set of possible operating modes depends on the capabilities of every hardware so each device binding documentation explains which values the regulator supports. +- regulator-system-load: Load in uA present on regulator that is not captured by + any consumer request. Deprecated properties: - regulator-compatible: If a regulator chip contains multiple
drivers/regulator/core.c +2 -0
@@ -678,6 +678,8 @@ static int drms_uA_update(struct regulator_dev *rdev)list_for_each_entry (sibling, &rdev->consumer_list, list) current_uA += sibling->uA_load; + current_uA += rdev->constraints->system_load; +if (rdev->desc->ops->set_load) {/* set the optimum mode for our new total regulator load */ err = rdev->desc->ops->set_load (rdev, current_uA);
drivers/regulator/of_regulator.c +3 -0
@@ -95,6 +95,9 @@ static void of_get_regulation_constraints(struct device_node *np, } } +if (!of_property_read_u32 (np,"regulator-system-load" , &pval)) + constraints->system_load = pval; +for (i =0 ; i <ARRAY_SIZE (regulator_states); i++) {switch (i) {case PM_SUSPEND_MEM :
include/linux/regulator/machine.h +3 -0
@@ -75,6 +75,7 @@ struct regulator_state {* * @min_uA: Smallest current consumers may set. * @max_uA: Largest current consumers may set. +* @system_load: Load that isn't captured by any consumer requests. * * @valid_modes_mask: Mask of modes which may be configured by consumers. * @valid_ops_mask: Operations which may be performed by consumers.
@@ -112,6 +113,8 @@ struct regulation_constraints {int min_uA;int max_uA; +int system_load; +/* valid regulator operating modes for this machine */ unsigned int valid_modes_mask;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 3/6 regulator: Add pull down support
In reply to Stephen BoydSome regulators need to be configured to pull down a resistor when the regulator is disabled. Add an op (set_pull_down) and a DT property + constraint to support this.
--- Documentation/devicetree/bindings/regulator/regulator.txt | 1 + drivers/regulator/core.c | 8 ++++++++ drivers/regulator/of_regulator.c | 2 ++ include/linux/regulator/driver.h | 5 +++++ include/linux/regulator/machine.h | 2 ++ 5 files changed, 18 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +1 -0
@@ -39,6 +39,7 @@ Optional properties: documentation explains which values the regulator supports. - regulator-system-load: Load in uA present on regulator that is not captured by any consumer request. +- regulator-pull-down: Enable pull down resistor when the regulator is disabled. Deprecated properties: - regulator-compatible: If a regulator chip contains multiple
drivers/regulator/core.c +8 -0
@@ -1051,6 +1051,14 @@ static int set_machine_constraints(struct regulator_dev *rdev, } } +if (rdev->constraints->pull_down && ops->set_pull_down) { + ret = ops->set_pull_down (rdev); +if (ret <0 ) { +rdev_err (rdev,"failed to set pull down\n" ); + goto out; + } + } +print_constraints (rdev);return 0 ; out:
drivers/regulator/of_regulator.c +2 -0
@@ -67,6 +67,8 @@ static void of_get_regulation_constraints(struct device_node *np,if (!constraints->always_on)/* status change should be possible. */ constraints->valid_ops_mask |=REGULATOR_CHANGE_STATUS ; + constraints->pull_down =of_property_read_bool (np,"regulator-pull-down" ); +if (of_property_read_bool (np,"regulator-allow-bypass" )) constraints->valid_ops_mask |=REGULATOR_CHANGE_BYPASS ;
include/linux/regulator/driver.h +5 -0
@@ -121,6 +121,9 @@ struct regulator_linear_range {* @set_suspend_mode: Set the operating mode for the regulator when the * system is suspended. * +* @set_pull_down: Configure the regulator to pull down when the regulator +* is disabled. +* * This struct describes regulator operations which can be implemented by * regulator chip drivers. */
@@ -187,6 +190,8 @@ struct regulator_ops {/* set regulator suspend operating mode (defined in consumer.h) */ int (*set_suspend_mode) (struct regulator_dev *,unsigned int mode); + +int (*set_pull_down) (struct regulator_dev *); };/*
include/linux/regulator/machine.h +2 -0
@@ -87,6 +87,7 @@ struct regulator_state {* applied. * @apply_uV: Apply the voltage constraint when initialising. * @ramp_disable: Disable ramp delay when initialising or when setting voltage. +* @pull_down: Enable pull down when regulator is disabled. * * @input_uV: Input voltage for regulator when supplied by another regulator. *
@@ -141,6 +142,7 @@ struct regulation_constraints { unsigned boot_on:1; /* bootloader/firmware enabled regulator */ unsigned apply_uV:1; /* apply uV constraint if min == max */ unsigned ramp_disable:1; /* disable ramp delay */ + unsigned pull_down:1; /* pull down resistor when regulator off */ };/**
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 4/6 regulator: Add soft start support
In reply to Stephen BoydSome regulators support a "soft start" feature where the voltage ramps up slowly when the regulator is enabled. Add an op (set_soft_start) and a DT property + constraint to support this.
--- Documentation/devicetree/bindings/regulator/regulator.txt | 1 + drivers/regulator/core.c | 8 ++++++++ drivers/regulator/of_regulator.c | 3 +++ include/linux/regulator/driver.h | 2 ++ include/linux/regulator/machine.h | 1 + 5 files changed, 15 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +1 -0
@@ -19,6 +19,7 @@ Optional properties: design requires. This property describes the total system ramp time required due to the combination of internal ramping of the regulator itself, and board design issues such as trace capacitance and load on the supply. +- regulator-soft-start: Enable soft start so that voltage ramps slowly - regulator-state-mem sub-root node for Suspend-to-RAM mode : suspend to memory, the device goes to sleep, but all data stored in memory, only some external interrupt can wake the device.
drivers/regulator/core.c +8 -0
@@ -1059,6 +1059,14 @@ static int set_machine_constraints(struct regulator_dev *rdev, } } +if (rdev->constraints->soft_start && ops->set_soft_start) { + ret = ops->set_soft_start (rdev); +if (ret <0 ) { +rdev_err (rdev,"failed to set soft start\n" ); + goto out; + } + } +print_constraints (rdev);return 0 ; out:
drivers/regulator/of_regulator.c +3 -0
@@ -84,6 +84,9 @@ static void of_get_regulation_constraints(struct device_node *np,if (!ret) constraints->enable_time = pval; + constraints->soft_start =of_property_read_bool (np, +"regulator-soft-start" ); +if (!of_property_read_u32 (np,"regulator-initial-mode" , &pval)) {if (desc && desc->of_map_mode) { ret = desc->of_map_mode (pval);
include/linux/regulator/driver.h +2 -0
@@ -161,6 +161,8 @@ struct regulator_ops {unsigned int old_selector, unsigned int new_selector); +int (*set_soft_start) (struct regulator_dev *); +/* report regulator status ... most other accessors report * control inputs, this reports results of combining inputs * from Linux (and other sources) with the actual load.
include/linux/regulator/machine.h +1 -0
@@ -142,6 +142,7 @@ struct regulation_constraints { unsigned boot_on:1; /* bootloader/firmware enabled regulator */ unsigned apply_uV:1; /* apply uV constraint if min == max */ unsigned ramp_disable:1; /* disable ramp delay */ + unsigned soft_start:1; /* ramp voltage slowly */ unsigned pull_down:1; /* pull down resistor when regulator off */ };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 5/6 regulator: Add input current limit support
In reply to Stephen BoydSome regulators can limit their input current (typically annotated as ilim). Add an op (set_input_current_limit) and a DT property + constraint to support this.
--- Documentation/devicetree/bindings/regulator/regulator.txt | 1 + drivers/regulator/core.c | 9 +++++++++ drivers/regulator/of_regulator.c | 4 ++++ include/linux/regulator/driver.h | 3 +++ include/linux/regulator/machine.h | 2 ++ 5 files changed, 19 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +1 -0
@@ -7,6 +7,7 @@ Optional properties: - regulator-microvolt-offset: Offset applied to voltages to compensate for voltage drops - regulator-min-microamp: smallest current consumers may set - regulator-max-microamp: largest current consumers may set +- regulator-input-current-limit-microamp: maximum input current regulator allows - regulator-always-on: boolean, regulator should never be disabled - regulator-boot-on: bootloader/firmware enabled regulator - regulator-allow-bypass: allow the regulator to go into bypass mode
drivers/regulator/core.c +9 -0
@@ -1008,6 +1008,15 @@ static int set_machine_constraints(struct regulator_dev *rdev,if (ret !=0 ) goto out; +if (rdev->constraints->ilim_uA && ops->set_input_current_limit) { + ret = ops->set_input_current_limit (rdev, + rdev->constraints->ilim_uA); +if (ret <0 ) { +rdev_err (rdev,"failed to set input limit\n" ); + goto out; + } + } +/* do we need to setup our suspend state */ if (rdev->constraints->initial_state) { ret =suspend_prepare (rdev, rdev->constraints->initial_state);
drivers/regulator/of_regulator.c +4 -0
@@ -58,6 +58,10 @@ static void of_get_regulation_constraints(struct device_node *np,if (!of_property_read_u32 (np,"regulator-max-microamp" , &pval)) constraints->max_uA = pval; +if (!of_property_read_u32 (np,"regulator-input-current-limit-microamp" , + &pval)) + constraints->ilim_uA = pval; +/* Current change possible? */ if (constraints->min_uA != constraints->max_uA) constraints->valid_ops_mask |=REGULATOR_CHANGE_CURRENT ;
include/linux/regulator/driver.h +3 -0
@@ -91,6 +91,7 @@ struct regulator_linear_range {* @set_current_limit: Configure a limit for a current-limited regulator. * The driver should select the current closest to max_uA. * @get_current_limit: Get the configured limit for a current-limited regulator. +* @set_input_current_limit: Configure an input limit. * * @set_mode: Set the configured operating mode for the regulator. * @get_mode: Get the configured operating mode for the regulator.
@@ -145,6 +146,8 @@ struct regulator_ops { int min_uA, int max_uA);int (*get_current_limit) (struct regulator_dev *); +int (*set_input_current_limit) (struct regulator_dev *,int lim_uA); +/* enable/disable regulator */ int (*enable) (struct regulator_dev *);int (*disable) (struct regulator_dev *);
include/linux/regulator/machine.h +2 -0
@@ -75,6 +75,7 @@ struct regulator_state {* * @min_uA: Smallest current consumers may set. * @max_uA: Largest current consumers may set. +* @ilim_uA: Maximum input current. * @system_load: Load that isn't captured by any consumer requests. * * @valid_modes_mask: Mask of modes which may be configured by consumers.
@@ -113,6 +114,7 @@ struct regulation_constraints {/* current output range (inclusive) - for current control */ int min_uA;int max_uA; +int ilim_uA;int system_load;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 6/6 regulator: qcom-spmi: Add vendor specific configuration
In reply to Stephen BoydAdd support for over current protection (OCP), pin control selection, soft start and soft start strength, auto-mode, input current limiting, and pull down.
---
Changes from v1:
* New patch split from orignal SPMI regulator driver
.../bindings/regulator/qcom,spmi-regulator.txt | 62 +++++ drivers/regulator/qcom_spmi-regulator.c | 298 ++++++++++++++++++++- 2 files changed, 358 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt +62 -0
@@ -99,6 +99,68 @@ see regulator.txt - with additional custom properties described below: soft start are active all the time. 0 = Set initial mode to low power mode (LPM). +- qcom,auto-mode-enable: + Usage: optional + Value type: <u32> + Description: 1 = Enable automatic hardware selection of regulator + mode (HPM vs LPM); not available on boost type + regulators. 0 = Disable auto mode selection. + +- qcom,ocp-enable: + Usage: optional + Value type: <u32> + Description: 1 = Allow over current protection (OCP) to be enabled for + voltage switch type regulators so that they latch off + automatically when over current is detected. OCP is + enabled when in HPM or auto mode. 0 = Disable OCP. + +- qcom,ocp-max-retries: + Usage: optional + Value type: <u32> + Description: Maximum number of times to try toggling a voltage switch + off and back on as a result of consecutive over current + events. + +- qcom,ocp-retry-delay: + Usage: optional + Value type: <u32> + Description: Time to delay in milliseconds between each voltage switch + toggle after an over current event takes place. + +- qcom,pin-ctrl-enable: + Usage: optional + Value type: <u32> + Description: Bit mask specifying which hardware pins should be used to + enable the regulator, if any; supported bits are: + 0 = ignore all hardware enable signals + BIT(0) = follow HW0_EN signal + BIT(1) = follow HW1_EN signal + BIT(2) = follow HW2_EN signal + BIT(3) = follow HW3_EN signal + +- qcom,pin-ctrl-hpm: + Usage: optional + Value type: <u32> + Description: Bit mask specifying which hardware pins should be used to + force the regulator into high power mode, if any; + supported bits are: + 0 = ignore all hardware enable signals + BIT(0) = follow HW0_EN signal + BIT(1) = follow HW1_EN signal + BIT(2) = follow HW2_EN signal + BIT(3) = follow HW3_EN signal + BIT(4) = follow PMIC awake state + +- qcom,vs-soft-start-strength: + Usage: optional + Value type: <u32> + Description: This property sets the soft start strength for voltage + switch type regulators; supported values are: + 0 = 0.05 uA + 1 = 0.25 uA + 2 = 0.55 uA + 3 = 0.75 uA + Example: regulators {
drivers/regulator/qcom_spmi-regulator.c +296 -2
374 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 8 lines · Stephen Boyd
This patchset adds support for the regulators found on Qualcomm's SPMI PMICs. The first patch is the "basic" driver that doesn't have any non-standard features. The next 4 patches add ways to configure some of the non-standard features that are generic but aren't supported in the regulator framework. And the final patch adds support for the non-standard features and some vendor specific features to the SPMI regulator driver.
Argh, missed an e! Resending...
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project