Hi,
the main purpose of this serie is to add the voltage selection support
upon a given gpio input signal and to dis-/enable a regulator upon a
gpio input signal.
This series depends on [1].
[1] https://patchwork.ozlabs.org/project/linux-gpio/list/?series=131029
Regards,
Marco
Marco Felsch (5):
regulator: da9062: fix suspend_enable/disable preparation
dt-bindings: mfd: da9062: add regulator voltage selection
documentation
regulator: da9062: add voltage selection gpio support
dt-bindings: mfd: da9062: add regulator gpio enable/disable
documentation
regulator: da9062: add gpio based regulator dis-/enable support
.../devicetree/bindings/mfd/da9062.txt | 16 +
drivers/regulator/da9062-regulator.c | 347 ++++++++++++++----
2 files changed, 292 insertions(+), 71 deletions(-)
--
2.20.1
Currently the suspend reg_field maps to the pmic voltage selection bits
and is used during suspend_enabe/disable() and during get_mode(). This
seems to be wrong for both use cases.
Use case one (suspend_enabe/disable):
Those callbacks are used to mark a regulator device as enabled/disabled
during suspend. Marking the regulator enabled during suspend is done by
the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT registers.
Setting this bit tells the DA9062 PMIC state machine to keep the
regulator on in POWERDOWN mode and switch to suspend voltage.
Use case two (get_mode):
The get_mode callback is used to retrieve the active mode state. Since
the regulator-setting-A is used for the active state and
regulator-setting-B for the suspend state there is no need to check
which regulator setting is active.
Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
Signed-off-by: Marco Felsch <[email protected]>
---
drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
1 file changed, 47 insertions(+), 71 deletions(-)
diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 2ffc64622451..9b2ca472f70c 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
{
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
- struct regmap_field *field;
unsigned int val, mode = 0;
int ret;
@@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}
- /* Detect current regulator state */
- ret = regmap_field_read(regl->suspend, &val);
- if (ret < 0)
- return 0;
-
- /* Read regulator mode from proper register, depending on state */
- if (val)
- field = regl->suspend_sleep;
- else
- field = regl->sleep;
-
- ret = regmap_field_read(field, &val);
+ ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;
@@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
{
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
- struct regmap_field *field;
int ret, val;
- /* Detect current regulator state */
- ret = regmap_field_read(regl->suspend, &val);
- if (ret < 0)
- return 0;
-
- /* Read regulator mode from proper register, depending on state */
- if (val)
- field = regl->suspend_sleep;
- else
- field = regl->sleep;
-
- ret = regmap_field_read(field, &val);
+ ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;
@@ -408,10 +384,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_BUCK2,
@@ -444,10 +420,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_BUCK3,
@@ -480,10 +456,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_LDO1,
@@ -509,10 +485,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO1_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
+ __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -542,10 +518,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO2_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
+ __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -575,10 +551,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO3_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
+ __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -608,10 +584,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO4_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
+ __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -652,10 +628,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK2,
@@ -688,10 +664,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK3,
@@ -724,10 +700,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK4,
@@ -760,10 +736,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_LDO1,
@@ -789,10 +765,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO1_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
+ __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -822,10 +798,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO2_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
+ __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -855,10 +831,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO3_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
+ __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -888,10 +864,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO4_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
+ __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
--
2.20.1
At the gpio-based regulator enable/disable documentation. This property
can be applied to each subnode within the 'regulators' node so each
regulator can be configured differently.
Signed-off-by: Marco Felsch <[email protected]>
---
Documentation/devicetree/bindings/mfd/da9062.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/devicetree/bindings/mfd/da9062.txt b/Documentation/devicetree/bindings/mfd/da9062.txt
index 9d9820d8177d..3d4b90bf8ea6 100644
--- a/Documentation/devicetree/bindings/mfd/da9062.txt
+++ b/Documentation/devicetree/bindings/mfd/da9062.txt
@@ -75,6 +75,13 @@ Sub-nodes:
same. Also the gpio phandle must refer to to the dlg,da9062-gpio device
other gpios are not allowed and make no sense.
+ - dlg,ena-sense-gpios : The GPIO reference which should be used by the
+ regulator to enable/disable the output. If the signal is active the
+ regulator is on else it is off. Attention: Sharing the same gpio for other
+ purposes or across multiple regulators is possible but the gpio settings
+ must be the same. Also the gpio phandle must refer to to the
+ dlg,da9062-gpio device other gpios are not allowed and make no sense.
+
- rtc : This node defines settings required for the Real-Time Clock associated
with the DA9062. There are currently no entries in this binding, however
compatible = "dlg,da9062-rtc" should be added if a node is created.
--
2.20.1
On 17 September 2019 13:43, Marco Felsch wrote:
> Currently the suspend reg_field maps to the pmic voltage selection bits
> and is used during suspend_enabe/disable() and during get_mode(). This
> seems to be wrong for both use cases.
Hi Marco,
I'd be very surprised if what was in place was wrong as I know Stephen tested
this driver thoroughly over its lifetime. Regardless, I'll need some time to review
your proposed updates to make sure this aligns with our expectation of operation.
>
> Use case one (suspend_enabe/disable):
> Those callbacks are used to mark a regulator device as enabled/disabled
> during suspend. Marking the regulator enabled during suspend is done by
> the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT
> registers.
> Setting this bit tells the DA9062 PMIC state machine to keep the
> regulator on in POWERDOWN mode and switch to suspend voltage.
>
> Use case two (get_mode):
> The get_mode callback is used to retrieve the active mode state. Since
> the regulator-setting-A is used for the active state and
> regulator-setting-B for the suspend state there is no need to check
> which regulator setting is active.
>
> Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
> Signed-off-by: Marco Felsch <[email protected]>
> ---
> drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
> 1 file changed, 47 insertions(+), 71 deletions(-)
>
> diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> regulator.c
> index 2ffc64622451..9b2ca472f70c 100644
> --- a/drivers/regulator/da9062-regulator.c
> +++ b/drivers/regulator/da9062-regulator.c
> @@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev
> *rdev, unsigned mode)
> static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
> {
> struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> - struct regmap_field *field;
> unsigned int val, mode = 0;
> int ret;
>
> @@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct
> regulator_dev *rdev)
> return REGULATOR_MODE_NORMAL;
> }
>
> - /* Detect current regulator state */
> - ret = regmap_field_read(regl->suspend, &val);
> - if (ret < 0)
> - return 0;
> -
> - /* Read regulator mode from proper register, depending on state */
> - if (val)
> - field = regl->suspend_sleep;
> - else
> - field = regl->sleep;
> -
> - ret = regmap_field_read(field, &val);
> + ret = regmap_field_read(regl->sleep, &val);
> if (ret < 0)
> return 0;
>
> @@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev
> *rdev, unsigned mode)
> static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
> {
> struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> - struct regmap_field *field;
> int ret, val;
>
> - /* Detect current regulator state */
> - ret = regmap_field_read(regl->suspend, &val);
> - if (ret < 0)
> - return 0;
> -
> - /* Read regulator mode from proper register, depending on state */
> - if (val)
> - field = regl->suspend_sleep;
> - else
> - field = regl->sleep;
> -
> - ret = regmap_field_read(field, &val);
> + ret = regmap_field_read(regl->sleep, &val);
> if (ret < 0)
> return 0;
>
> @@ -408,10 +384,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9061_ID_BUCK2,
> @@ -444,10 +420,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9061_ID_BUCK3,
> @@ -480,10 +456,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9061_ID_LDO1,
> @@ -509,10 +485,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO1_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -542,10 +518,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO2_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -575,10 +551,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO3_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -608,10 +584,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO4_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -652,10 +628,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_BUCK2,
> @@ -688,10 +664,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_BUCK3,
> @@ -724,10 +700,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_BUCK4,
> @@ -760,10 +736,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_LDO1,
> @@ -789,10 +765,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO1_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -822,10 +798,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO2_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -855,10 +831,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO3_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -888,10 +864,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO4_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> --
> 2.20.1
Hi Adam,
On 19-09-18 12:41, Adam Thomson wrote:
> On 17 September 2019 13:43, Marco Felsch wrote:
>
> > Currently the suspend reg_field maps to the pmic voltage selection bits
> > and is used during suspend_enabe/disable() and during get_mode(). This
> > seems to be wrong for both use cases.
>
> Hi Marco,
>
> I'd be very surprised if what was in place was wrong as I know Stephen tested
> this driver thoroughly over its lifetime. Regardless, I'll need some time to review
> your proposed updates to make sure this aligns with our expectation of operation.
Thanks for the upcoming review.
Regards,
Marco
> >
> > Use case one (suspend_enabe/disable):
> > Those callbacks are used to mark a regulator device as enabled/disabled
> > during suspend. Marking the regulator enabled during suspend is done by
> > the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT
> > registers.
> > Setting this bit tells the DA9062 PMIC state machine to keep the
> > regulator on in POWERDOWN mode and switch to suspend voltage.
> >
> > Use case two (get_mode):
> > The get_mode callback is used to retrieve the active mode state. Since
> > the regulator-setting-A is used for the active state and
> > regulator-setting-B for the suspend state there is no need to check
> > which regulator setting is active.
> >
> > Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
> > Signed-off-by: Marco Felsch <[email protected]>
> > ---
> > drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
> > 1 file changed, 47 insertions(+), 71 deletions(-)
> >
> > diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> > regulator.c
> > index 2ffc64622451..9b2ca472f70c 100644
> > --- a/drivers/regulator/da9062-regulator.c
> > +++ b/drivers/regulator/da9062-regulator.c
> > @@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev
> > *rdev, unsigned mode)
> > static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
> > {
> > struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> > - struct regmap_field *field;
> > unsigned int val, mode = 0;
> > int ret;
> >
> > @@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct
> > regulator_dev *rdev)
> > return REGULATOR_MODE_NORMAL;
> > }
> >
> > - /* Detect current regulator state */
> > - ret = regmap_field_read(regl->suspend, &val);
> > - if (ret < 0)
> > - return 0;
> > -
> > - /* Read regulator mode from proper register, depending on state */
> > - if (val)
> > - field = regl->suspend_sleep;
> > - else
> > - field = regl->sleep;
> > -
> > - ret = regmap_field_read(field, &val);
> > + ret = regmap_field_read(regl->sleep, &val);
> > if (ret < 0)
> > return 0;
> >
> > @@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev
> > *rdev, unsigned mode)
> > static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
> > {
> > struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> > - struct regmap_field *field;
> > int ret, val;
> >
> > - /* Detect current regulator state */
> > - ret = regmap_field_read(regl->suspend, &val);
> > - if (ret < 0)
> > - return 0;
> > -
> > - /* Read regulator mode from proper register, depending on state */
> > - if (val)
> > - field = regl->suspend_sleep;
> > - else
> > - field = regl->sleep;
> > -
> > - ret = regmap_field_read(field, &val);
> > + ret = regmap_field_read(regl->sleep, &val);
> > if (ret < 0)
> > return 0;
> >
> > @@ -408,10 +384,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9061_ID_BUCK2,
> > @@ -444,10 +420,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9061_ID_BUCK3,
> > @@ -480,10 +456,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9061_ID_LDO1,
> > @@ -509,10 +485,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO1_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -542,10 +518,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO2_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -575,10 +551,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO3_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -608,10 +584,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO4_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -652,10 +628,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_BUCK2,
> > @@ -688,10 +664,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_BUCK3,
> > @@ -724,10 +700,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_BUCK4,
> > @@ -760,10 +736,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_LDO1,
> > @@ -789,10 +765,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO1_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -822,10 +798,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO2_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -855,10 +831,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO3_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -888,10 +864,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO4_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > --
> > 2.20.1
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On 17 September 2019 13:43, Marco Felsch wrote:
> Currently the suspend reg_field maps to the pmic voltage selection bits
> and is used during suspend_enabe/disable() and during get_mode(). This
> seems to be wrong for both use cases.
>
> Use case one (suspend_enabe/disable):
> Those callbacks are used to mark a regulator device as enabled/disabled
> during suspend. Marking the regulator enabled during suspend is done by
> the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT
> registers.
> Setting this bit tells the DA9062 PMIC state machine to keep the
> regulator on in POWERDOWN mode and switch to suspend voltage.
>
> Use case two (get_mode):
> The get_mode callback is used to retrieve the active mode state. Since
> the regulator-setting-A is used for the active state and
> regulator-setting-B for the suspend state there is no need to check
> which regulator setting is active.
>
So I believe you're correct with the above statements. The driver, rather than
enabling/disabling a regulator in system suspend, will instead put the regulator
to a low power state, which is definitely not the desired outcome. Thanks for
rectifying this.
Reviewed-by: Adam Thomson <[email protected]>
> Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
> Signed-off-by: Marco Felsch <[email protected]>
> ---
> drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
> 1 file changed, 47 insertions(+), 71 deletions(-)
>
> diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> regulator.c
> index 2ffc64622451..9b2ca472f70c 100644
> --- a/drivers/regulator/da9062-regulator.c
> +++ b/drivers/regulator/da9062-regulator.c
> @@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev
> *rdev, unsigned mode)
> static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
> {
> struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> - struct regmap_field *field;
> unsigned int val, mode = 0;
> int ret;
>
> @@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct
> regulator_dev *rdev)
> return REGULATOR_MODE_NORMAL;
> }
>
> - /* Detect current regulator state */
> - ret = regmap_field_read(regl->suspend, &val);
> - if (ret < 0)
> - return 0;
> -
> - /* Read regulator mode from proper register, depending on state */
> - if (val)
> - field = regl->suspend_sleep;
> - else
> - field = regl->sleep;
> -
> - ret = regmap_field_read(field, &val);
> + ret = regmap_field_read(regl->sleep, &val);
> if (ret < 0)
> return 0;
>
> @@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev
> *rdev, unsigned mode)
> static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
> {
> struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> - struct regmap_field *field;
> int ret, val;
>
> - /* Detect current regulator state */
> - ret = regmap_field_read(regl->suspend, &val);
> - if (ret < 0)
> - return 0;
> -
> - /* Read regulator mode from proper register, depending on state */
> - if (val)
> - field = regl->suspend_sleep;
> - else
> - field = regl->sleep;
> -
> - ret = regmap_field_read(field, &val);
> + ret = regmap_field_read(regl->sleep, &val);
> if (ret < 0)
> return 0;
>
> @@ -408,10 +384,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9061_ID_BUCK2,
> @@ -444,10 +420,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9061_ID_BUCK3,
> @@ -480,10 +456,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9061_ID_LDO1,
> @@ -509,10 +485,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO1_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -542,10 +518,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO2_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -575,10 +551,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO3_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -608,10 +584,10 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO4_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -652,10 +628,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_BUCK2,
> @@ -688,10 +664,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_BUCK3,
> @@ -724,10 +700,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_BUCK4,
> @@ -760,10 +736,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> },
> {
> .desc.id = DA9062_ID_LDO1,
> @@ -789,10 +765,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO1_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -822,10 +798,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO2_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -855,10 +831,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO3_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> @@ -888,10 +864,10 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
> sizeof(unsigned int) * 8 -
> __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> .suspend_vsel_reg = DA9062AA_VLDO4_B,
> - .suspend = REG_FIELD(DA9062AA_DVC_1,
> - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> sizeof(unsigned int) * 8 -
> - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> sizeof(unsigned int) * 8 -
> --
> 2.20.1
The patch
regulator: da9062: fix suspend_enable/disable preparation
has been applied to the regulator tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4
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
From a72865f057820ea9f57597915da4b651d65eb92f Mon Sep 17 00:00:00 2001
From: Marco Felsch <[email protected]>
Date: Tue, 17 Sep 2019 14:42:42 +0200
Subject: [PATCH] regulator: da9062: fix suspend_enable/disable preparation
Currently the suspend reg_field maps to the pmic voltage selection bits
and is used during suspend_enabe/disable() and during get_mode(). This
seems to be wrong for both use cases.
Use case one (suspend_enabe/disable):
Those callbacks are used to mark a regulator device as enabled/disabled
during suspend. Marking the regulator enabled during suspend is done by
the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT registers.
Setting this bit tells the DA9062 PMIC state machine to keep the
regulator on in POWERDOWN mode and switch to suspend voltage.
Use case two (get_mode):
The get_mode callback is used to retrieve the active mode state. Since
the regulator-setting-A is used for the active state and
regulator-setting-B for the suspend state there is no need to check
which regulator setting is active.
Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
Signed-off-by: Marco Felsch <[email protected]>
Reviewed-by: Adam Thomson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
1 file changed, 47 insertions(+), 71 deletions(-)
diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 56f3f72d7707..710e67081d53 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
{
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
- struct regmap_field *field;
unsigned int val, mode = 0;
int ret;
@@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}
- /* Detect current regulator state */
- ret = regmap_field_read(regl->suspend, &val);
- if (ret < 0)
- return 0;
-
- /* Read regulator mode from proper register, depending on state */
- if (val)
- field = regl->suspend_sleep;
- else
- field = regl->sleep;
-
- ret = regmap_field_read(field, &val);
+ ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;
@@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
{
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
- struct regmap_field *field;
int ret, val;
- /* Detect current regulator state */
- ret = regmap_field_read(regl->suspend, &val);
- if (ret < 0)
- return 0;
-
- /* Read regulator mode from proper register, depending on state */
- if (val)
- field = regl->suspend_sleep;
- else
- field = regl->sleep;
-
- ret = regmap_field_read(field, &val);
+ ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;
@@ -408,10 +384,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_BUCK2,
@@ -444,10 +420,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_BUCK3,
@@ -480,10 +456,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_LDO1,
@@ -509,10 +485,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO1_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
+ __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -542,10 +518,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO2_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
+ __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -575,10 +551,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO3_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
+ __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -608,10 +584,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO4_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
+ __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -652,10 +628,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK2,
@@ -688,10 +664,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK3,
@@ -724,10 +700,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK4,
@@ -760,10 +736,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
+ __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_LDO1,
@@ -789,10 +765,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO1_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
+ __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -822,10 +798,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO2_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
+ __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -855,10 +831,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO3_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
+ __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
@@ -888,10 +864,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO4_B,
- .suspend = REG_FIELD(DA9062AA_DVC_1,
- __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
+ .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
+ __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
- __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
+ __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
--
2.20.1
Hi Adam,
On 19-09-23 16:03, Adam Thomson wrote:
> On 17 September 2019 13:43, Marco Felsch wrote:
>
> > Currently the suspend reg_field maps to the pmic voltage selection bits
> > and is used during suspend_enabe/disable() and during get_mode(). This
> > seems to be wrong for both use cases.
> >
> > Use case one (suspend_enabe/disable):
> > Those callbacks are used to mark a regulator device as enabled/disabled
> > during suspend. Marking the regulator enabled during suspend is done by
> > the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT
> > registers.
> > Setting this bit tells the DA9062 PMIC state machine to keep the
> > regulator on in POWERDOWN mode and switch to suspend voltage.
> >
> > Use case two (get_mode):
> > The get_mode callback is used to retrieve the active mode state. Since
> > the regulator-setting-A is used for the active state and
> > regulator-setting-B for the suspend state there is no need to check
> > which regulator setting is active.
> >
>
> So I believe you're correct with the above statements. The driver, rather than
> enabling/disabling a regulator in system suspend, will instead put the regulator
> to a low power state, which is definitely not the desired outcome. Thanks for
> rectifying this.
>
> Reviewed-by: Adam Thomson <[email protected]>
Thanks a lot for reviewing the patch :) Can you also have a look on the
other patches within this series?
Regards,
Marco
> > Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
> > Signed-off-by: Marco Felsch <[email protected]>
> > ---
> > drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
> > 1 file changed, 47 insertions(+), 71 deletions(-)
> >
> > diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> > regulator.c
> > index 2ffc64622451..9b2ca472f70c 100644
> > --- a/drivers/regulator/da9062-regulator.c
> > +++ b/drivers/regulator/da9062-regulator.c
> > @@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev
> > *rdev, unsigned mode)
> > static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
> > {
> > struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> > - struct regmap_field *field;
> > unsigned int val, mode = 0;
> > int ret;
> >
> > @@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct
> > regulator_dev *rdev)
> > return REGULATOR_MODE_NORMAL;
> > }
> >
> > - /* Detect current regulator state */
> > - ret = regmap_field_read(regl->suspend, &val);
> > - if (ret < 0)
> > - return 0;
> > -
> > - /* Read regulator mode from proper register, depending on state */
> > - if (val)
> > - field = regl->suspend_sleep;
> > - else
> > - field = regl->sleep;
> > -
> > - ret = regmap_field_read(field, &val);
> > + ret = regmap_field_read(regl->sleep, &val);
> > if (ret < 0)
> > return 0;
> >
> > @@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev
> > *rdev, unsigned mode)
> > static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
> > {
> > struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> > - struct regmap_field *field;
> > int ret, val;
> >
> > - /* Detect current regulator state */
> > - ret = regmap_field_read(regl->suspend, &val);
> > - if (ret < 0)
> > - return 0;
> > -
> > - /* Read regulator mode from proper register, depending on state */
> > - if (val)
> > - field = regl->suspend_sleep;
> > - else
> > - field = regl->sleep;
> > -
> > - ret = regmap_field_read(field, &val);
> > + ret = regmap_field_read(regl->sleep, &val);
> > if (ret < 0)
> > return 0;
> >
> > @@ -408,10 +384,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9061_ID_BUCK2,
> > @@ -444,10 +420,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9061_ID_BUCK3,
> > @@ -480,10 +456,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9061_ID_LDO1,
> > @@ -509,10 +485,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO1_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -542,10 +518,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO2_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -575,10 +551,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO3_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -608,10 +584,10 @@ static const struct da9062_regulator_info
> > local_da9061_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO4_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -652,10 +628,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_BUCK2,
> > @@ -688,10 +664,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_BUCK3,
> > @@ -724,10 +700,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_BUCK4,
> > @@ -760,10 +736,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> > + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> > },
> > {
> > .desc.id = DA9062_ID_LDO1,
> > @@ -789,10 +765,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO1_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -822,10 +798,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO2_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -855,10 +831,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO3_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > @@ -888,10 +864,10 @@ static const struct da9062_regulator_info
> > local_da9062_regulator_info[] = {
> > sizeof(unsigned int) * 8 -
> > __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> > .suspend_vsel_reg = DA9062AA_VLDO4_B,
> > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> > + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> > + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> > + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> > sizeof(unsigned int) * 8 -
> > --
> > 2.20.1
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On 23 September 2019 23:03, Marco Felsch wrote:
> Hi Adam,
>
> On 19-09-23 16:03, Adam Thomson wrote:
> > On 17 September 2019 13:43, Marco Felsch wrote:
> >
> > > Currently the suspend reg_field maps to the pmic voltage selection bits
> > > and is used during suspend_enabe/disable() and during get_mode(). This
> > > seems to be wrong for both use cases.
> > >
> > > Use case one (suspend_enabe/disable):
> > > Those callbacks are used to mark a regulator device as enabled/disabled
> > > during suspend. Marking the regulator enabled during suspend is done by
> > > the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT
> > > registers.
> > > Setting this bit tells the DA9062 PMIC state machine to keep the
> > > regulator on in POWERDOWN mode and switch to suspend voltage.
> > >
> > > Use case two (get_mode):
> > > The get_mode callback is used to retrieve the active mode state. Since
> > > the regulator-setting-A is used for the active state and
> > > regulator-setting-B for the suspend state there is no need to check
> > > which regulator setting is active.
> > >
> >
> > So I believe you're correct with the above statements. The driver, rather than
> > enabling/disabling a regulator in system suspend, will instead put the regulator
> > to a low power state, which is definitely not the desired outcome. Thanks for
> > rectifying this.
> >
> > Reviewed-by: Adam Thomson <[email protected]>
>
> Thanks a lot for reviewing the patch :) Can you also have a look on the
> other patches within this series?
Yes, I will take a look at those next. :)
>
> Regards,
> Marco
>
> > > Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
> > > Signed-off-by: Marco Felsch <[email protected]>
> > > ---
> > > drivers/regulator/da9062-regulator.c | 118 +++++++++++----------------
> > > 1 file changed, 47 insertions(+), 71 deletions(-)
> > >
> > > diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> > > regulator.c
> > > index 2ffc64622451..9b2ca472f70c 100644
> > > --- a/drivers/regulator/da9062-regulator.c
> > > +++ b/drivers/regulator/da9062-regulator.c
> > > @@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct
> regulator_dev
> > > *rdev, unsigned mode)
> > > static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
> > > {
> > > struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> > > - struct regmap_field *field;
> > > unsigned int val, mode = 0;
> > > int ret;
> > >
> > > @@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct
> > > regulator_dev *rdev)
> > > return REGULATOR_MODE_NORMAL;
> > > }
> > >
> > > - /* Detect current regulator state */
> > > - ret = regmap_field_read(regl->suspend, &val);
> > > - if (ret < 0)
> > > - return 0;
> > > -
> > > - /* Read regulator mode from proper register, depending on state */
> > > - if (val)
> > > - field = regl->suspend_sleep;
> > > - else
> > > - field = regl->sleep;
> > > -
> > > - ret = regmap_field_read(field, &val);
> > > + ret = regmap_field_read(regl->sleep, &val);
> > > if (ret < 0)
> > > return 0;
> > >
> > > @@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev
> > > *rdev, unsigned mode)
> > > static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
> > > {
> > > struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> > > - struct regmap_field *field;
> > > int ret, val;
> > >
> > > - /* Detect current regulator state */
> > > - ret = regmap_field_read(regl->suspend, &val);
> > > - if (ret < 0)
> > > - return 0;
> > > -
> > > - /* Read regulator mode from proper register, depending on state */
> > > - if (val)
> > > - field = regl->suspend_sleep;
> > > - else
> > > - field = regl->sleep;
> > > -
> > > - ret = regmap_field_read(field, &val);
> > > + ret = regmap_field_read(regl->sleep, &val);
> > > if (ret < 0)
> > > return 0;
> > >
> > > @@ -408,10 +384,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9061_ID_BUCK2,
> > > @@ -444,10 +420,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9061_ID_BUCK3,
> > > @@ -480,10 +456,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9061_ID_LDO1,
> > > @@ -509,10 +485,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO1_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -542,10 +518,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO2_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -575,10 +551,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO3_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -608,10 +584,10 @@ static const struct da9062_regulator_info
> > > local_da9061_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO4_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -652,10 +628,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9062_ID_BUCK2,
> > > @@ -688,10 +664,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9062_ID_BUCK3,
> > > @@ -724,10 +700,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9062_ID_BUCK4,
> > > @@ -760,10 +736,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
> > > + __builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
> > > },
> > > {
> > > .desc.id = DA9062_ID_LDO1,
> > > @@ -789,10 +765,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO1_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO1_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -822,10 +798,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO2_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO2_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -855,10 +831,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO3_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO3_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > @@ -888,10 +864,10 @@ static const struct da9062_regulator_info
> > > local_da9062_regulator_info[] = {
> > > sizeof(unsigned int) * 8 -
> > > __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
> > > .suspend_vsel_reg = DA9062AA_VLDO4_B,
> > > - .suspend = REG_FIELD(DA9062AA_DVC_1,
> > > - __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
> > > + .suspend = REG_FIELD(DA9062AA_LDO4_CONT,
> > > + __builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > - __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
> > > + __builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
> > > .oc_event = REG_FIELD(DA9062AA_STATUS_D,
> > > __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
> > > sizeof(unsigned int) * 8 -
> > > --
> > > 2.20.1
> >
> >
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |