Add support for regulator operation mode of mt6397
Some regulators support different operating modes, but there is no suitable property that can pass the opeation mode constraints on runtime at present.
This series making the change to specify supported modes as a devicetree list. Consumers can change or get the regulator operation mode by regulator_set_mode /regulator_get_mode and define the support operating mode on devicetree.
There is a requirement from SVS driver. SVS calibartion requires that the regulator be in its low-noise (pwm mode) state at boot, but at all other times it can be normal mode for power saving
http://www.spinics.net/lists/devicetree/msg111204.html
Henry Chen (2):
regulator: Add support for parsing operation mode
regulator: mt6397: Add buck change mode regulator interface for mt6397
.../bindings/regulator/mt6397-regulator.txt | 22 +++++ .../devicetree/bindings/regulator/regulator.txt | 10 +++ drivers/regulator/mt6397-regulator.c | 95 +++++++++++++++++++--- drivers/regulator/of_regulator.c | 14 ++++ 4 files changed, 129 insertions(+), 12 deletions(-)
Signature · 1 line
1.8.1.1.dirty
PATCH RESEND 1/2 regulator: Add support for parsing operation mode
Some regulators support their operating mode to be changed by consumers for module specific purpose.
This patch adds support to parse those properties and fill the regulator constraints so the regulator core can call the regualtor_set_mode to change the modes.
--- Documentation/devicetree/bindings/regulator/regulator.txt | 10 ++++++++++ drivers/regulator/of_regulator.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +10 -0
@@ -49,6 +49,16 @@ Optional properties: 0: Disable active discharge. 1: Enable active discharge. Absence of this property will leave configuration to default. +- regulator-allow-change-mode: allow the regulator mode to be configured +- regulator-supported-modes: Regulators can run in a variety of different operating + modes depending on output load. This allows further system power savings by + selecting the best (and most efficient) regulator mode for a desired load. + The definition for each of these operation is defined at + include/linux/regulator/consumer.h + 0: FAST. + 1: NORMAL. + 2: IDLE. + 3: STANDBY. Deprecated properties: - regulator-compatible: If a regulator chip contains multiple
drivers/regulator/of_regulator.c +14 -0
@@ -167,6 +167,20 @@ static void of_get_regulation_constraints(struct device_node *np, suspend_state =NULL ; suspend_np =NULL ; } + +if (of_property_read_bool (np,"regulator-allow-change-mode" )) + constraints->valid_ops_mask |=REGULATOR_CHANGE_MODE ; + + ret =of_property_count_elems_of_size (np, +"regulator-supported-modes" , +sizeof (u32)); +for (i =0 ; i < ret; i++) { +u32 mode; + +of_property_read_u32_index (np,"regulator-supported-modes" , + i, &mode); + constraints->valid_modes_mask |= (1 << mode); + } }/**
Signature · 1 line
1.8.1.1.dirty
PATCH RESEND 2/2 regulator: mt6397: Add buck change mode regulator interface for mt6397
In reply to Henry ChenBUCKs of mt6397 have auto mode and pwm mode. User can use regulator interfaces to control modes.
--- .../bindings/regulator/mt6397-regulator.txt | 22 +++++ drivers/regulator/mt6397-regulator.c | 95 +++++++++++++++++++--- 2 files changed, 105 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +22 -0
@@ -7,6 +7,26 @@ Required properties: The definition for each of these nodes is defined using the standard binding for regulators at Documentation/devicetree/bindings/regulator/regulator.txt. +The mt6397 buck supports two different operating modes: Fast and Normal +Mode. Some regulators support the modes to be changed by the consumers during +normal operation. + +The regulators that support the standard "regulator-allow-change-mode" property, +changing their mode during normal operation are: + buck_vpca15, buck_vpca7, buck_vsramca15, buck_vsramca7, buck_vcore, buck_vgpu, + buck_vdrm, buck_vio18 + +The possible values for "regulator-supported-modes" are: + 0: PWM mode, mapping to regulator fast mode, allow the + converter to remain in the PWM mode regardless of the load current, so + that the noise spectrum of the converter can be minimized for certain + highly-noise-sensitive handset applications. + 1: Auto mode, mapping to regulator normal mode, mode switch by current + loading. At light load currents, the converter automatically enters + PFM mode to save power and improve light load efficiency. At heavy + load currents, the converter automatically enters PWM mode to minimiz + the noise spectrum of the converter. + The valid names for regulators are:: BUCK: buck_vpca15, buck_vpca7, buck_vsramca15, buck_vsramca7, buck_vcore, buck_vgpu,
@@ -30,6 +50,8 @@ Example: regulator-max-microvolt = <1350000>; regulator-ramp-delay = <12500>; regulator-enable-ramp-delay = <200>; + regulator-allow-change-mode; + regulator-supported-modes = <0 1>; }; mt6397_vpca7_reg: buck_vpca7 {
drivers/regulator/mt6397-regulator.c +83 -12
162 lines not on this page · raw message
Signature · 1 line
1.8.1.1.dirty
Mark Brown
maintainerRe: [PATCH RESEND 1/2] regulator: Add support for parsing operation mode
In reply to Henry ChenDocumentation/devicetree/bindings/regulator/regulator.txt Optional properties: · line 57
Quoted 6 lines · Henry Chen
+- regulator-allow-change-mode: allow the regulator mode to be configured +- regulator-supported-modes: Regulators can run in a variety of different operatingDocumentation/devicetree/bindings/regulator/regulator.txt +4
-0+ modes depending on output load. This allows further system power savings by + selecting the best (and most efficient) regulator mode for a desired load. + The definition for each of these operation is defined at + include/linux/regulator/consumer.h
It really isn't OK for a DT binding to be documented by referencing Linux kernel internals.
Documentation/devicetree/bindings/regulator/regulator.txt Optional properties: · line 61
Quoted 4 lines
Documentation/devicetree/bindings/regulator/regulator.txt +4
-0+ 0: FAST. + 1: NORMAL. + 2: IDLE. + 3: STANDBY.
The problem with these is that they don't really mean anything outside of a specific regulator. This makes it very hard to make them at all interoperable, and is also incompatible with the way we're currently handling the modes elsewhere in the bindings. If we're going to make an ABI of this we need to have something with abstraction in it but it's hard to see how to abstract modes since they're so implementation specific, even if the mechanisms are similar the different load ranges that regulators support mean that what's a very taxing load for one regulator may be nothing to another.
Mark Brown
maintainerRe: [PATCH RESEND 2/2] regulator: mt6397: Add buck change mode regulator interface for mt6397
In reply to Henry ChenDocumentation/devicetree/bindings/regulator/mt6397-regulator.txt Required properties: · line 28
Quoted 10 lines · Henry Chen
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +10
-0+The possible values for "regulator-supported-modes" are: + 0: PWM mode, mapping to regulator fast mode, allow the + converter to remain in the PWM mode regardless of the load current, so + that the noise spectrum of the converter can be minimized for certain + highly-noise-sensitive handset applications. + 1: Auto mode, mapping to regulator normal mode, mode switch by current + loading. At light load currents, the converter automatically enters + PFM mode to save power and improve light load efficiency. At heavy + load currents, the converter automatically enters PWM mode to minimiz + the noise spectrum of the converter.
The details of how this maps onto Linux shouldn't be in the bindings.
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt Example: · line 54
Quoted 2 lines
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +2
-0+ regulator-allow-change-mode; + regulator-supported-modes = <0 1>;
These are problematic too as covered in my other mail.
drivers/regulator/mt6397-regulator.c static int mt6397_get_status(struct regulator_dev *rdev) · line 230
Quoted 2 lines
drivers/regulator/mt6397-regulator.c +1
-1-static struct regulator_ops mt6397_volt_range_ops = { +static const struct regulator_ops mt6397_volt_range_ops = {
The constification is fine but an unrelated change. Otherwise this looks fine from a code point of view, let's get that merged separately.
Re: [PATCH RESEND 2/2] regulator: mt6397: Add buck change mode regulator interface for mt6397
Hi Mark,
Quoted 20 lines · Mark Brown
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt Required properties: · line 28
Quoted 10 lines · Henry Chen
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +10
-0+The possible values for "regulator-supported-modes" are: + 0: PWM mode, mapping to regulator fast mode, allow the + converter to remain in the PWM mode regardless of the load current, so + that the noise spectrum of the converter can be minimized for certain + highly-noise-sensitive handset applications. + 1: Auto mode, mapping to regulator normal mode, mode switch by current + loading. At light load currents, the converter automatically enters + PFM mode to save power and improve light load efficiency. At heavy + load currents, the converter automatically enters PWM mode to minimiz + the noise spectrum of the converter.The details of how this maps onto Linux shouldn't be in the bindings.
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt Example: · line 54
Quoted 2 lines
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +2
-0+ regulator-allow-change-mode; + regulator-supported-modes = <0 1>;These are problematic too as covered in my other mail.
Quoted 5 lines
drivers/regulator/mt6397-regulator.c static int mt6397_get_status(struct regulator_dev *rdev) · line 230
Quoted 2 lines
drivers/regulator/mt6397-regulator.c +1
-1-static struct regulator_ops mt6397_volt_range_ops = { +static const struct regulator_ops mt6397_volt_range_ops = {The constification is fine but an unrelated change. Otherwise this looks fine from a code point of view, let's get that merged separately.
Okay, although we didn't have conclusion and solution for regulator operation mode, as you said that we can get some patch merged separately, so I will resend the patch which clean up comments from you and Daniel.