Skip to content

Commit fd37685

Browse files
akemnadegregkh
authored andcommitted
regulator: twl6030: fix get status of twl6032 regulators
[ Upstream commit 31a6297 ] Status is reported as always off in the 6032 case. Status reporting now matches the logic in the setters. Once of the differences to the 6030 is that there are no groups, therefore the state needs to be read out in the lower bits. Signed-off-by: Andreas Kemnade <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 9f74b9a commit fd37685

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/regulator/twl6030-regulator.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct twlreg_info {
6767
#define TWL6030_CFG_STATE_SLEEP 0x03
6868
#define TWL6030_CFG_STATE_GRP_SHIFT 5
6969
#define TWL6030_CFG_STATE_APP_SHIFT 2
70+
#define TWL6030_CFG_STATE_MASK 0x03
7071
#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
7172
#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
7273
TWL6030_CFG_STATE_APP_SHIFT)
@@ -128,13 +129,14 @@ static int twl6030reg_is_enabled(struct regulator_dev *rdev)
128129
if (grp < 0)
129130
return grp;
130131
grp &= P1_GRP_6030;
132+
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
133+
val = TWL6030_CFG_STATE_APP(val);
131134
} else {
135+
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
136+
val &= TWL6030_CFG_STATE_MASK;
132137
grp = 1;
133138
}
134139

135-
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
136-
val = TWL6030_CFG_STATE_APP(val);
137-
138140
return grp && (val == TWL6030_CFG_STATE_ON);
139141
}
140142

@@ -187,7 +189,12 @@ static int twl6030reg_get_status(struct regulator_dev *rdev)
187189

188190
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
189191

190-
switch (TWL6030_CFG_STATE_APP(val)) {
192+
if (info->features & TWL6032_SUBCLASS)
193+
val &= TWL6030_CFG_STATE_MASK;
194+
else
195+
val = TWL6030_CFG_STATE_APP(val);
196+
197+
switch (val) {
191198
case TWL6030_CFG_STATE_ON:
192199
return REGULATOR_STATUS_NORMAL;
193200

0 commit comments

Comments
 (0)