diff options
author | Kevin Liu <kliu5@marvell.com> | 2012-01-04 02:12:04 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-06 13:56:14 -0500 |
commit | 65364e9ab958f4ad21c5c7b6cc8e2e458128dbcb (patch) | |
tree | 481535ab2a705f68270015d64fedc67aca10d7e0 /drivers/regulator | |
parent | e1de2f423462a5c6ba2c902dff1f5ddd8d3dbde3 (diff) |
regulator: max8925: fix enabled/disabled judgement mistake
Max8925 ldo status should be determined by two factors:
1. power up/down sequence selection(LDOCTL[4:2]).
2. i2c enable bit(LDOCTL[0]).
Max8925 ldo support two types of power up/down sequence:
1. flexible sequence(LDOCTL[4:2] = 0~6).
2. i2c sequence(LDOCTL[4:2] = 7).
With flexible sequence selected, the ldo is enabled during power up by default.
With i2c sequence selected, the ldo is controlled by the i2c enable bit(LDOCTL[0]).
Signed-off-by: Kevin Liu <kliu5@marvell.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/max8925-regulator.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index f976e5d0867e..cc290d37c463 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -24,9 +24,13 @@ | |||
24 | #define SD1_DVM_SHIFT 5 /* SDCTL1 bit5 */ | 24 | #define SD1_DVM_SHIFT 5 /* SDCTL1 bit5 */ |
25 | #define SD1_DVM_EN 6 /* SDV1 bit 6 */ | 25 | #define SD1_DVM_EN 6 /* SDV1 bit 6 */ |
26 | 26 | ||
27 | /* bit definitions in SD & LDO control registers */ | 27 | /* bit definitions in LDO control registers */ |
28 | #define OUT_ENABLE 0x1f /* Power U/D sequence as I2C */ | 28 | #define LDO_SEQ_I2C 0x7 /* Power U/D by i2c */ |
29 | #define OUT_DISABLE 0x1e /* Power U/D sequence as I2C */ | 29 | #define LDO_SEQ_MASK 0x7 /* Power U/D sequence mask */ |
30 | #define LDO_SEQ_SHIFT 2 /* Power U/D sequence offset */ | ||
31 | #define LDO_I2C_EN 0x1 /* Enable by i2c */ | ||
32 | #define LDO_I2C_EN_MASK 0x1 /* Enable mask by i2c */ | ||
33 | #define LDO_I2C_EN_SHIFT 0 /* Enable offset by i2c */ | ||
30 | 34 | ||
31 | struct max8925_regulator_info { | 35 | struct max8925_regulator_info { |
32 | struct regulator_desc desc; | 36 | struct regulator_desc desc; |
@@ -40,7 +44,6 @@ struct max8925_regulator_info { | |||
40 | int vol_reg; | 44 | int vol_reg; |
41 | int vol_shift; | 45 | int vol_shift; |
42 | int vol_nbits; | 46 | int vol_nbits; |
43 | int enable_bit; | ||
44 | int enable_reg; | 47 | int enable_reg; |
45 | }; | 48 | }; |
46 | 49 | ||
@@ -98,8 +101,10 @@ static int max8925_enable(struct regulator_dev *rdev) | |||
98 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); | 101 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); |
99 | 102 | ||
100 | return max8925_set_bits(info->i2c, info->enable_reg, | 103 | return max8925_set_bits(info->i2c, info->enable_reg, |
101 | OUT_ENABLE << info->enable_bit, | 104 | LDO_SEQ_MASK << LDO_SEQ_SHIFT | |
102 | OUT_ENABLE << info->enable_bit); | 105 | LDO_I2C_EN_MASK << LDO_I2C_EN_SHIFT, |
106 | LDO_SEQ_I2C << LDO_SEQ_SHIFT | | ||
107 | LDO_I2C_EN << LDO_I2C_EN_SHIFT); | ||
103 | } | 108 | } |
104 | 109 | ||
105 | static int max8925_disable(struct regulator_dev *rdev) | 110 | static int max8925_disable(struct regulator_dev *rdev) |
@@ -107,20 +112,24 @@ static int max8925_disable(struct regulator_dev *rdev) | |||
107 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); | 112 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); |
108 | 113 | ||
109 | return max8925_set_bits(info->i2c, info->enable_reg, | 114 | return max8925_set_bits(info->i2c, info->enable_reg, |
110 | OUT_ENABLE << info->enable_bit, | 115 | LDO_SEQ_MASK << LDO_SEQ_SHIFT | |
111 | OUT_DISABLE << info->enable_bit); | 116 | LDO_I2C_EN_MASK << LDO_I2C_EN_SHIFT, |
117 | LDO_SEQ_I2C << LDO_SEQ_SHIFT); | ||
112 | } | 118 | } |
113 | 119 | ||
114 | static int max8925_is_enabled(struct regulator_dev *rdev) | 120 | static int max8925_is_enabled(struct regulator_dev *rdev) |
115 | { | 121 | { |
116 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); | 122 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); |
117 | int ret; | 123 | int ldo_seq, ret; |
118 | 124 | ||
119 | ret = max8925_reg_read(info->i2c, info->enable_reg); | 125 | ret = max8925_reg_read(info->i2c, info->enable_reg); |
120 | if (ret < 0) | 126 | if (ret < 0) |
121 | return ret; | 127 | return ret; |
122 | 128 | ldo_seq = (ret >> LDO_SEQ_SHIFT) & LDO_SEQ_MASK; | |
123 | return ret & (1 << info->enable_bit); | 129 | if (ldo_seq != LDO_SEQ_I2C) |
130 | return 1; | ||
131 | else | ||
132 | return ret & (LDO_I2C_EN_MASK << LDO_I2C_EN_SHIFT); | ||
124 | } | 133 | } |
125 | 134 | ||
126 | static int max8925_set_dvm_voltage(struct regulator_dev *rdev, int uV) | 135 | static int max8925_set_dvm_voltage(struct regulator_dev *rdev, int uV) |
@@ -188,7 +197,6 @@ static struct regulator_ops max8925_regulator_ldo_ops = { | |||
188 | .vol_shift = 0, \ | 197 | .vol_shift = 0, \ |
189 | .vol_nbits = 6, \ | 198 | .vol_nbits = 6, \ |
190 | .enable_reg = MAX8925_SDCTL##_id, \ | 199 | .enable_reg = MAX8925_SDCTL##_id, \ |
191 | .enable_bit = 0, \ | ||
192 | } | 200 | } |
193 | 201 | ||
194 | #define MAX8925_LDO(_id, min, max, step) \ | 202 | #define MAX8925_LDO(_id, min, max, step) \ |
@@ -207,7 +215,6 @@ static struct regulator_ops max8925_regulator_ldo_ops = { | |||
207 | .vol_shift = 0, \ | 215 | .vol_shift = 0, \ |
208 | .vol_nbits = 6, \ | 216 | .vol_nbits = 6, \ |
209 | .enable_reg = MAX8925_LDOCTL##_id, \ | 217 | .enable_reg = MAX8925_LDOCTL##_id, \ |
210 | .enable_bit = 0, \ | ||
211 | } | 218 | } |
212 | 219 | ||
213 | static struct max8925_regulator_info max8925_regulator_info[] = { | 220 | static struct max8925_regulator_info max8925_regulator_info[] = { |