mbox series

[v3,0/5] Add regulator suspend and resume support

Message ID 1515752305-15907-1-git-send-email-zhang.chunyan@linaro.org
Headers show
Series Add regulator suspend and resume support | expand

Message

Chunyan Zhang Jan. 12, 2018, 10:18 a.m. UTC
Some systems need to set regulators to specific states when they enter low
power modes, especially around CPUs.

Currently the regulator driver, for suspend and resume features, provides
two functions which are exported for being called directly by any modules
or subsystems when they thought the regulator should be entering into
suspend states.

This patchset adds hooks to PM suspend core and provides suspend/resume
callback functions to regulator device, for those who can be switched
off or set low voltage in suspend states only need to implement the
callback functions in the driver, and set the right configurations for
suspend states via device tree and the APIs which regulator core
driver provides.

Those drivers who use the old interfaces - i.e. regulator_suspend_prepare()
and regulator_suspend_finish() should stop using that, since we leave these
two functions empty and plan to remove them one day in the future.

Any comments would be greatly appreciated.

Thanks,
Chunyan

Changes from V1: (https://lkml.org/lkml/2017/12/21/9)
* Rephrased the commit message of patch 0001;
* Declared the property 'regulator-suspend-microvolt' deperated and documented
  the way recommended;
* Revised of_regulator.c, use suspend_state::min_uV as default suspend
  voltage if the property 'regulator-suspend-microvolt' is not used.

Changes from V2: (https://lkml.org/lkml/2018/1/4/75)
* Correct the typo;
* Removed redundant comments;
* Export regulator_suspend_enable/disable(), on't call these two functions in
  regulator_set_suspend_voltage() instead;
* Checking if rstate->min_uV == rstate->max_uV instead of checking the flag.

Chunyan Zhang (5):
  bindings: regulator: added support for suspend states
  regulator: make regulator voltage be an array to support more states
  drivers: regulator: leave one item to record whether regulator is
    enabled
  drivers: regulator: empty the old suspend functions
  regulator: add PM suspend and resume hooks

 .../devicetree/bindings/regulator/regulator.txt    |  15 +-
 drivers/regulator/core.c                           | 336 ++++++++++++++-------
 drivers/regulator/internal.h                       |  18 +-
 drivers/regulator/of_regulator.c                   |  20 +-
 include/linux/regulator/driver.h                   |   2 +
 include/linux/regulator/machine.h                  |  37 ++-
 6 files changed, 302 insertions(+), 126 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Chunyan Zhang Jan. 12, 2018, 10:23 a.m. UTC | #1
Some systems need to set regulators to specific states when they enter low
power modes, especially around CPUs.

Currently the regulator driver, for suspend and resume features, provides
two functions which are exported for being called directly by any modules
or subsystems when they thought the regulator should be entering into
suspend states.

This patchset adds hooks to PM suspend core and provides suspend/resume
callback functions to regulator device, for those who can be switched
off or set low voltage in suspend states only need to implement the
callback functions in the driver, and set the right configurations for
suspend states via device tree and the APIs which regulator core
driver provides.

Those drivers who use the old interfaces - i.e. regulator_suspend_prepare()
and regulator_suspend_finish() should stop using that, since we leave these
two functions empty and plan to remove them one day in the future.

Any comments would be greatly appreciated.

Thanks,
Chunyan

Changes from V1: (https://lkml.org/lkml/2017/12/21/9)
* Rephrased the commit message of patch 0001;
* Declared the property 'regulator-suspend-microvolt' deperated and documented
  the way recommended;
* Revised of_regulator.c, use suspend_state::min_uV as default suspend
  voltage if the property 'regulator-suspend-microvolt' is not used.

Changes from V2: (https://lkml.org/lkml/2018/1/4/75)
* Correct the typo;
* Removed redundant comments;
* Export regulator_suspend_enable/disable(), don't call these two functions in
  regulator_set_suspend_voltage() instead;
* Checking if rstate->min_uV == rstate->max_uV instead of checking the flag when
  setting the suspend voltage.

Chunyan Zhang (5):
  bindings: regulator: added support for suspend states
  regulator: make regulator voltage be an array to support more states
  drivers: regulator: leave one item to record whether regulator is
    enabled
  drivers: regulator: empty the old suspend functions
  regulator: add PM suspend and resume hooks

 .../devicetree/bindings/regulator/regulator.txt    |  15 +-
 drivers/regulator/core.c                           | 336 ++++++++++++++-------
 drivers/regulator/internal.h                       |  18 +-
 drivers/regulator/of_regulator.c                   |  20 +-
 include/linux/regulator/driver.h                   |   2 +
 include/linux/regulator/machine.h                  |  37 ++-
 6 files changed, 302 insertions(+), 126 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rob Herring Jan. 19, 2018, 10:11 p.m. UTC | #2
On Fri, Jan 12, 2018 at 06:18:21PM +0800, Chunyan Zhang wrote:
> Some systems need to set regulators to specific states when they enter

> low power modes, especially around CPUs. There are many of these modes

> depending on the particular runtime state.

> 

> Currently the regulator consumers are not granted permission to change

> suspend state of regulator devices, the constraints are configured at

> startup.  In order to allow changes in a vlotage range, we need to add

> new properties for voltage range and a flag to give permission to

> change the suspend voltage and suspend on/off in suspend mode.

> 

> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>

> ---

>  Documentation/devicetree/bindings/regulator/regulator.txt | 15 +++++++++++++--

>  1 file changed, 13 insertions(+), 2 deletions(-)

> 

> diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt

> index 378f6dc..532e286 100644

> --- a/Documentation/devicetree/bindings/regulator/regulator.txt

> +++ b/Documentation/devicetree/bindings/regulator/regulator.txt

> @@ -42,8 +42,19 @@ Optional properties:

>  - regulator-state-[mem/disk] node has following common properties:

>  	- regulator-on-in-suspend: regulator should be on in suspend state.

>  	- regulator-off-in-suspend: regulator should be off in suspend state.

> -	- regulator-suspend-microvolt: regulator should be set to this voltage

> -	  in suspend.

> +	- regulator-suspend-min-microvolt: minimum voltage may be set in

> +	  suspend state.

> +	- regulator-suspend-max-microvolt: maximum voltage may be set in

> +	  suspend state.

> +	- regulator-suspend-microvolt: the default voltage which regulator

> +	  would be set in suspend. The voltage for suspend also can be

> +	  adjusted among {regulator-suspend-min-microvolt,

> +	  regulator-suspend-max-microvolt} by calling

> +	  regulator_set_suspend_voltage(). This property is now deprecated,

> +	  setting voltage for suspend mode via API the regulator driver

> +	  provides is recommended.


Please reword. This is Linux implementation details that shouldn't be in 
the binding.

> +	- regulator-changeable-in-suspend: whether the default voltage and

> +	  the regulator on/off in suspend can be changed in runtime.

>  	- regulator-mode: operating mode in the given suspend state.

>  	  The set of possible operating modes depends on the capabilities of

>  	  every hardware so the valid modes are documented on each regulator

> -- 

> 2.7.4

> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chunyan Zhang Jan. 22, 2018, 2:16 a.m. UTC | #3
On 20 January 2018 at 06:11, Rob Herring <robh@kernel.org> wrote:
> On Fri, Jan 12, 2018 at 06:18:21PM +0800, Chunyan Zhang wrote:

>> Some systems need to set regulators to specific states when they enter

>> low power modes, especially around CPUs. There are many of these modes

>> depending on the particular runtime state.

>>

>> Currently the regulator consumers are not granted permission to change

>> suspend state of regulator devices, the constraints are configured at

>> startup.  In order to allow changes in a vlotage range, we need to add

>> new properties for voltage range and a flag to give permission to

>> change the suspend voltage and suspend on/off in suspend mode.

>>

>> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>

>> ---

>>  Documentation/devicetree/bindings/regulator/regulator.txt | 15 +++++++++++++--

>>  1 file changed, 13 insertions(+), 2 deletions(-)

>>

>> diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt

>> index 378f6dc..532e286 100644

>> --- a/Documentation/devicetree/bindings/regulator/regulator.txt

>> +++ b/Documentation/devicetree/bindings/regulator/regulator.txt

>> @@ -42,8 +42,19 @@ Optional properties:

>>  - regulator-state-[mem/disk] node has following common properties:

>>       - regulator-on-in-suspend: regulator should be on in suspend state.

>>       - regulator-off-in-suspend: regulator should be off in suspend state.

>> -     - regulator-suspend-microvolt: regulator should be set to this voltage

>> -       in suspend.

>> +     - regulator-suspend-min-microvolt: minimum voltage may be set in

>> +       suspend state.

>> +     - regulator-suspend-max-microvolt: maximum voltage may be set in

>> +       suspend state.

>> +     - regulator-suspend-microvolt: the default voltage which regulator

>> +       would be set in suspend. The voltage for suspend also can be

>> +       adjusted among {regulator-suspend-min-microvolt,

>> +       regulator-suspend-max-microvolt} by calling

>> +       regulator_set_suspend_voltage(). This property is now deprecated,

>> +       setting voltage for suspend mode via API the regulator driver

>> +       provides is recommended.

>

> Please reword. This is Linux implementation details that shouldn't be in

> the binding.


Ok, I guess just updating this one instead of the whole patchset for
this minor modification should be fine.

>

>> +     - regulator-changeable-in-suspend: whether the default voltage and

>> +       the regulator on/off in suspend can be changed in runtime.

>>       - regulator-mode: operating mode in the given suspend state.

>>         The set of possible operating modes depends on the capabilities of

>>         every hardware so the valid modes are documented on each regulator

>> --

>> 2.7.4

>>

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html