Skip to content

Commit 762a8ee

Browse files
abresticbroonie
authored andcommitted
regulator: as3722: detect SD0 low-voltage mode
SD0 may operate in low-voltage mode, with a minimum of 0.41V and a maximum of 1.5V. This is indicated by bit 4 of FUSE7. Signed-off-by: Andrew Bresticker <abrestic@chromium.org> Signed-off-by: Vince Hsu <vinceh@nvidia.com> broonie.e6264@m.evernote.com Signed-off-by: Mark Brown <broonie@linaro.org>
1 parent bc2571f commit 762a8ee

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎drivers/regulator/as3722-regulator.c‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
9999
.sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK,
100100
.control_reg = AS3722_SD0_CONTROL_REG,
101101
.mode_mask = AS3722_SD0_MODE_FAST,
102-
.n_voltages = AS3722_SD0_VSEL_MAX + 1,
103102
},
104103
{
105104
.regulator_id = AS3722_REGULATOR_ID_SD1,
@@ -112,7 +111,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
112111
.sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK,
113112
.control_reg = AS3722_SD1_CONTROL_REG,
114113
.mode_mask = AS3722_SD1_MODE_FAST,
115-
.n_voltages = AS3722_SD0_VSEL_MAX + 1,
116114
},
117115
{
118116
.regulator_id = AS3722_REGULATOR_ID_SD2,
@@ -181,7 +179,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
181179
.sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK,
182180
.control_reg = AS3722_SD6_CONTROL_REG,
183181
.mode_mask = AS3722_SD6_MODE_FAST,
184-
.n_voltages = AS3722_SD0_VSEL_MAX + 1,
185182
},
186183
{
187184
.regulator_id = AS3722_REGULATOR_ID_LDO0,
@@ -595,6 +592,22 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev,
595592
return as3722_update_bits(as3722, reg, mask, val);
596593
}
597594

595+
static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs)
596+
{
597+
int err;
598+
unsigned val;
599+
600+
err = as3722_read(as3722_regs->as3722, AS3722_FUSE7_REG, &val);
601+
if (err < 0) {
602+
dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n",
603+
AS3722_FUSE7_REG, err);
604+
return false;
605+
}
606+
if (val & AS3722_FUSE7_SD0_LOW_VOLTAGE)
607+
return true;
608+
return false;
609+
}
610+
598611
static const struct regulator_linear_range as3722_sd2345_ranges[] = {
599612
REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500),
600613
REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
@@ -820,7 +833,16 @@ static int as3722_regulator_probe(struct platform_device *pdev)
820833
ops = &as3722_sd016_extcntrl_ops;
821834
else
822835
ops = &as3722_sd016_ops;
823-
as3722_regs->desc[id].min_uV = 610000;
836+
if (id == AS3722_REGULATOR_ID_SD0 &&
837+
as3722_sd0_is_low_voltage(as3722_regs)) {
838+
as3722_regs->desc[id].n_voltages =
839+
AS3722_SD0_VSEL_LOW_VOL_MAX + 1;
840+
as3722_regs->desc[id].min_uV = 410000;
841+
} else {
842+
as3722_regs->desc[id].n_voltages =
843+
AS3722_SD0_VSEL_MAX + 1,
844+
as3722_regs->desc[id].min_uV = 610000;
845+
}
824846
as3722_regs->desc[id].uV_step = 10000;
825847
as3722_regs->desc[id].linear_min_sel = 1;
826848
break;

‎include/linux/mfd/as3722.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
#define AS3722_ASIC_ID1_REG 0x90
152152
#define AS3722_ASIC_ID2_REG 0x91
153153
#define AS3722_LOCK_REG 0x9E
154+
#define AS3722_FUSE7_REG 0xA7
154155
#define AS3722_MAX_REGISTER 0xF4
155156

156157
#define AS3722_SD0_EXT_ENABLE_MASK 0x03
@@ -224,6 +225,7 @@
224225
#define AS3722_SD_VSEL_MASK 0x7F
225226
#define AS3722_SD0_VSEL_MIN 0x01
226227
#define AS3722_SD0_VSEL_MAX 0x5A
228+
#define AS3722_SD0_VSEL_LOW_VOL_MAX 0x6E
227229
#define AS3722_SD2_VSEL_MIN 0x01
228230
#define AS3722_SD2_VSEL_MAX 0x7F
229231

@@ -341,6 +343,8 @@
341343
#define AS3722_EXT_CONTROL_ENABLE2 0x2
342344
#define AS3722_EXT_CONTROL_ENABLE3 0x3
343345

346+
#define AS3722_FUSE7_SD0_LOW_VOLTAGE BIT(4)
347+
344348
/* Interrupt IDs */
345349
enum as3722_irq {
346350
AS3722_IRQ_LID,

0 commit comments

Comments
 (0)