diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2014-10-27 08:11:47 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-28 18:31:54 -0400 |
commit | 7636f19c26a9c4174a139ded0d5216ea5d40b830 (patch) | |
tree | daad84c43943672b4bd9f1ab46fac24227bc721d /drivers/regulator/max77686.c | |
parent | 73dbdf8ff583ff6693536351973bd24f45ee8668 (diff) |
regulator: max77686: Replace hard-coded opmode values with defines
Add defines for regulator operating modes which should be more readable,
especially if one does not have Maxim 77686 datasheet.
The patch does not introduce any functional change.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Suggested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/max77686.c')
-rw-r--r-- | drivers/regulator/max77686.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 0d103ba1d462..db01c09e98f5 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
@@ -45,6 +45,23 @@ | |||
45 | #define MAX77686_DVS_MINUV 600000 | 45 | #define MAX77686_DVS_MINUV 600000 |
46 | #define MAX77686_DVS_UVSTEP 12500 | 46 | #define MAX77686_DVS_UVSTEP 12500 |
47 | 47 | ||
48 | /* | ||
49 | * Values used for configuring LDOs and bucks. | ||
50 | * Forcing low power mode: LDO1, 3-5, 9, 13, 17-26 | ||
51 | */ | ||
52 | #define MAX77686_LDO_LOWPOWER 0x1 | ||
53 | /* | ||
54 | * On/off controlled by PWRREQ: | ||
55 | * - LDO2, 6-8, 10-12, 14-16 | ||
56 | * - buck[1234] | ||
57 | */ | ||
58 | #define MAX77686_OFF_PWRREQ 0x1 | ||
59 | /* Low power mode controlled by PWRREQ: All LDOs */ | ||
60 | #define MAX77686_LDO_LOWPOWER_PWRREQ 0x2 | ||
61 | /* Forcing low power mode: buck[234] */ | ||
62 | #define MAX77686_BUCK_LOWPOWER 0x2 | ||
63 | #define MAX77686_NORMAL 0x3 | ||
64 | |||
48 | #define MAX77686_OPMODE_SHIFT 6 | 65 | #define MAX77686_OPMODE_SHIFT 6 |
49 | #define MAX77686_OPMODE_BUCK234_SHIFT 4 | 66 | #define MAX77686_OPMODE_BUCK234_SHIFT 4 |
50 | #define MAX77686_OPMODE_MASK 0x3 | 67 | #define MAX77686_OPMODE_MASK 0x3 |
@@ -76,9 +93,9 @@ static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) | |||
76 | int ret, id = rdev_get_id(rdev); | 93 | int ret, id = rdev_get_id(rdev); |
77 | 94 | ||
78 | if (id == MAX77686_BUCK1) | 95 | if (id == MAX77686_BUCK1) |
79 | val = 0x1; | 96 | val = MAX77686_OFF_PWRREQ; |
80 | else | 97 | else |
81 | val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT; | 98 | val = MAX77686_OFF_PWRREQ << MAX77686_OPMODE_BUCK234_SHIFT; |
82 | 99 | ||
83 | ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, | 100 | ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, |
84 | rdev->desc->enable_mask, val); | 101 | rdev->desc->enable_mask, val); |
@@ -103,10 +120,10 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev, | |||
103 | 120 | ||
104 | switch (mode) { | 121 | switch (mode) { |
105 | case REGULATOR_MODE_IDLE: /* ON in LP Mode */ | 122 | case REGULATOR_MODE_IDLE: /* ON in LP Mode */ |
106 | val = 0x2 << MAX77686_OPMODE_SHIFT; | 123 | val = MAX77686_LDO_LOWPOWER_PWRREQ << MAX77686_OPMODE_SHIFT; |
107 | break; | 124 | break; |
108 | case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ | 125 | case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ |
109 | val = 0x3 << MAX77686_OPMODE_SHIFT; | 126 | val = MAX77686_NORMAL << MAX77686_OPMODE_SHIFT; |
110 | break; | 127 | break; |
111 | default: | 128 | default: |
112 | pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", | 129 | pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", |
@@ -133,13 +150,13 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev, | |||
133 | 150 | ||
134 | switch (mode) { | 151 | switch (mode) { |
135 | case REGULATOR_MODE_STANDBY: /* switch off */ | 152 | case REGULATOR_MODE_STANDBY: /* switch off */ |
136 | val = 0x1 << MAX77686_OPMODE_SHIFT; | 153 | val = MAX77686_OFF_PWRREQ << MAX77686_OPMODE_SHIFT; |
137 | break; | 154 | break; |
138 | case REGULATOR_MODE_IDLE: /* ON in LP Mode */ | 155 | case REGULATOR_MODE_IDLE: /* ON in LP Mode */ |
139 | val = 0x2 << MAX77686_OPMODE_SHIFT; | 156 | val = MAX77686_LDO_LOWPOWER_PWRREQ << MAX77686_OPMODE_SHIFT; |
140 | break; | 157 | break; |
141 | case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ | 158 | case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ |
142 | val = 0x3 << MAX77686_OPMODE_SHIFT; | 159 | val = MAX77686_NORMAL << MAX77686_OPMODE_SHIFT; |
143 | break; | 160 | break; |
144 | default: | 161 | default: |
145 | pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", | 162 | pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", |