aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Bresticker <abrestic@chromium.org>2013-12-26 16:48:46 -0500
committerMark Brown <broonie@linaro.org>2014-01-06 13:09:36 -0500
commit762a8ee808972354ce4bca988309aa7fb63ed5ae (patch)
tree19fed2a02e18080a06aef61eae22131e3c494f1f
parentbc2571f4ba375101c9d0b7d46d8c241822652433 (diff)
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>
-rw-r--r--drivers/regulator/as3722-regulator.c30
-rw-r--r--include/linux/mfd/as3722.h4
2 files changed, 30 insertions, 4 deletions
diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c
index fdb31371a232..3d7fbc21181d 100644
--- a/drivers/regulator/as3722-regulator.c
+++ b/drivers/regulator/as3722-regulator.c
@@ -99,7 +99,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
99 .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, 99 .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK,
100 .control_reg = AS3722_SD0_CONTROL_REG, 100 .control_reg = AS3722_SD0_CONTROL_REG,
101 .mode_mask = AS3722_SD0_MODE_FAST, 101 .mode_mask = AS3722_SD0_MODE_FAST,
102 .n_voltages = AS3722_SD0_VSEL_MAX + 1,
103 }, 102 },
104 { 103 {
105 .regulator_id = AS3722_REGULATOR_ID_SD1, 104 .regulator_id = AS3722_REGULATOR_ID_SD1,
@@ -112,7 +111,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
112 .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, 111 .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK,
113 .control_reg = AS3722_SD1_CONTROL_REG, 112 .control_reg = AS3722_SD1_CONTROL_REG,
114 .mode_mask = AS3722_SD1_MODE_FAST, 113 .mode_mask = AS3722_SD1_MODE_FAST,
115 .n_voltages = AS3722_SD0_VSEL_MAX + 1,
116 }, 114 },
117 { 115 {
118 .regulator_id = AS3722_REGULATOR_ID_SD2, 116 .regulator_id = AS3722_REGULATOR_ID_SD2,
@@ -181,7 +179,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = {
181 .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, 179 .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK,
182 .control_reg = AS3722_SD6_CONTROL_REG, 180 .control_reg = AS3722_SD6_CONTROL_REG,
183 .mode_mask = AS3722_SD6_MODE_FAST, 181 .mode_mask = AS3722_SD6_MODE_FAST,
184 .n_voltages = AS3722_SD0_VSEL_MAX + 1,
185 }, 182 },
186 { 183 {
187 .regulator_id = AS3722_REGULATOR_ID_LDO0, 184 .regulator_id = AS3722_REGULATOR_ID_LDO0,
@@ -595,6 +592,22 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev,
595 return as3722_update_bits(as3722, reg, mask, val); 592 return as3722_update_bits(as3722, reg, mask, val);
596} 593}
597 594
595static 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
598static const struct regulator_linear_range as3722_sd2345_ranges[] = { 611static const struct regulator_linear_range as3722_sd2345_ranges[] = {
599 REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), 612 REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500),
600 REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), 613 REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
@@ -820,7 +833,16 @@ static int as3722_regulator_probe(struct platform_device *pdev)
820 ops = &as3722_sd016_extcntrl_ops; 833 ops = &as3722_sd016_extcntrl_ops;
821 else 834 else
822 ops = &as3722_sd016_ops; 835 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 }
824 as3722_regs->desc[id].uV_step = 10000; 846 as3722_regs->desc[id].uV_step = 10000;
825 as3722_regs->desc[id].linear_min_sel = 1; 847 as3722_regs->desc[id].linear_min_sel = 1;
826 break; 848 break;
diff --git a/include/linux/mfd/as3722.h b/include/linux/mfd/as3722.h
index 16bf8a0dcd97..bb9616dc0efa 100644
--- a/include/linux/mfd/as3722.h
+++ b/include/linux/mfd/as3722.h
@@ -151,6 +151,7 @@
151#define AS3722_ASIC_ID1_REG 0x90 151#define AS3722_ASIC_ID1_REG 0x90
152#define AS3722_ASIC_ID2_REG 0x91 152#define AS3722_ASIC_ID2_REG 0x91
153#define AS3722_LOCK_REG 0x9E 153#define AS3722_LOCK_REG 0x9E
154#define AS3722_FUSE7_REG 0xA7
154#define AS3722_MAX_REGISTER 0xF4 155#define AS3722_MAX_REGISTER 0xF4
155 156
156#define AS3722_SD0_EXT_ENABLE_MASK 0x03 157#define AS3722_SD0_EXT_ENABLE_MASK 0x03
@@ -224,6 +225,7 @@
224#define AS3722_SD_VSEL_MASK 0x7F 225#define AS3722_SD_VSEL_MASK 0x7F
225#define AS3722_SD0_VSEL_MIN 0x01 226#define AS3722_SD0_VSEL_MIN 0x01
226#define AS3722_SD0_VSEL_MAX 0x5A 227#define AS3722_SD0_VSEL_MAX 0x5A
228#define AS3722_SD0_VSEL_LOW_VOL_MAX 0x6E
227#define AS3722_SD2_VSEL_MIN 0x01 229#define AS3722_SD2_VSEL_MIN 0x01
228#define AS3722_SD2_VSEL_MAX 0x7F 230#define AS3722_SD2_VSEL_MAX 0x7F
229 231
@@ -341,6 +343,8 @@
341#define AS3722_EXT_CONTROL_ENABLE2 0x2 343#define AS3722_EXT_CONTROL_ENABLE2 0x2
342#define AS3722_EXT_CONTROL_ENABLE3 0x3 344#define AS3722_EXT_CONTROL_ENABLE3 0x3
343 345
346#define AS3722_FUSE7_SD0_LOW_VOLTAGE BIT(4)
347
344/* Interrupt IDs */ 348/* Interrupt IDs */
345enum as3722_irq { 349enum as3722_irq {
346 AS3722_IRQ_LID, 350 AS3722_IRQ_LID,