diff options
Diffstat (limited to 'drivers/regulator/anatop-regulator.c')
| -rw-r--r-- | drivers/regulator/anatop-regulator.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 1af97686f444..8f39cac661d2 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
| @@ -48,36 +48,21 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, | |||
| 48 | unsigned selector) | 48 | unsigned selector) |
| 49 | { | 49 | { |
| 50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 51 | u32 val, mask; | ||
| 52 | 51 | ||
| 53 | if (!anatop_reg->control_reg) | 52 | if (!anatop_reg->control_reg) |
| 54 | return -ENOTSUPP; | 53 | return -ENOTSUPP; |
| 55 | 54 | ||
| 56 | val = anatop_reg->min_bit_val + selector; | 55 | return regulator_set_voltage_sel_regmap(reg, selector); |
| 57 | dev_dbg(®->dev, "%s: calculated val %d\n", __func__, val); | ||
| 58 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
| 59 | anatop_reg->vol_bit_shift; | ||
| 60 | val <<= anatop_reg->vol_bit_shift; | ||
| 61 | regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, | ||
| 62 | mask, val); | ||
| 63 | |||
| 64 | return 0; | ||
| 65 | } | 56 | } |
| 66 | 57 | ||
| 67 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | 58 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) |
| 68 | { | 59 | { |
| 69 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 60 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
| 70 | u32 val, mask; | ||
| 71 | 61 | ||
| 72 | if (!anatop_reg->control_reg) | 62 | if (!anatop_reg->control_reg) |
| 73 | return -ENOTSUPP; | 63 | return -ENOTSUPP; |
| 74 | 64 | ||
| 75 | regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val); | 65 | return regulator_get_voltage_sel_regmap(reg); |
| 76 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
| 77 | anatop_reg->vol_bit_shift; | ||
| 78 | val = (val & mask) >> anatop_reg->vol_bit_shift; | ||
| 79 | |||
| 80 | return val - anatop_reg->min_bit_val; | ||
| 81 | } | 66 | } |
| 82 | 67 | ||
| 83 | static struct regulator_ops anatop_rops = { | 68 | static struct regulator_ops anatop_rops = { |
| @@ -87,7 +72,7 @@ static struct regulator_ops anatop_rops = { | |||
| 87 | .map_voltage = regulator_map_voltage_linear, | 72 | .map_voltage = regulator_map_voltage_linear, |
| 88 | }; | 73 | }; |
| 89 | 74 | ||
| 90 | static int __devinit anatop_regulator_probe(struct platform_device *pdev) | 75 | static int anatop_regulator_probe(struct platform_device *pdev) |
| 91 | { | 76 | { |
| 92 | struct device *dev = &pdev->dev; | 77 | struct device *dev = &pdev->dev; |
| 93 | struct device_node *np = dev->of_node; | 78 | struct device_node *np = dev->of_node; |
| @@ -158,15 +143,20 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev) | |||
| 158 | goto anatop_probe_end; | 143 | goto anatop_probe_end; |
| 159 | } | 144 | } |
| 160 | 145 | ||
| 161 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) | 146 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 |
| 162 | / 25000 + 1; | 147 | + sreg->min_bit_val; |
| 163 | rdesc->min_uV = sreg->min_voltage; | 148 | rdesc->min_uV = sreg->min_voltage; |
| 164 | rdesc->uV_step = 25000; | 149 | rdesc->uV_step = 25000; |
| 150 | rdesc->linear_min_sel = sreg->min_bit_val; | ||
| 151 | rdesc->vsel_reg = sreg->control_reg; | ||
| 152 | rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << | ||
| 153 | sreg->vol_bit_shift; | ||
| 165 | 154 | ||
| 166 | config.dev = &pdev->dev; | 155 | config.dev = &pdev->dev; |
| 167 | config.init_data = initdata; | 156 | config.init_data = initdata; |
| 168 | config.driver_data = sreg; | 157 | config.driver_data = sreg; |
| 169 | config.of_node = pdev->dev.of_node; | 158 | config.of_node = pdev->dev.of_node; |
| 159 | config.regmap = sreg->anatop; | ||
| 170 | 160 | ||
| 171 | /* register regulator */ | 161 | /* register regulator */ |
| 172 | rdev = regulator_register(rdesc, &config); | 162 | rdev = regulator_register(rdesc, &config); |
| @@ -186,7 +176,7 @@ anatop_probe_end: | |||
| 186 | return ret; | 176 | return ret; |
| 187 | } | 177 | } |
| 188 | 178 | ||
| 189 | static int __devexit anatop_regulator_remove(struct platform_device *pdev) | 179 | static int anatop_regulator_remove(struct platform_device *pdev) |
| 190 | { | 180 | { |
| 191 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | 181 | struct regulator_dev *rdev = platform_get_drvdata(pdev); |
| 192 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); | 182 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); |
| @@ -198,7 +188,7 @@ static int __devexit anatop_regulator_remove(struct platform_device *pdev) | |||
| 198 | return 0; | 188 | return 0; |
| 199 | } | 189 | } |
| 200 | 190 | ||
| 201 | static struct of_device_id __devinitdata of_anatop_regulator_match_tbl[] = { | 191 | static struct of_device_id of_anatop_regulator_match_tbl[] = { |
| 202 | { .compatible = "fsl,anatop-regulator", }, | 192 | { .compatible = "fsl,anatop-regulator", }, |
| 203 | { /* end */ } | 193 | { /* end */ } |
| 204 | }; | 194 | }; |
| @@ -210,7 +200,7 @@ static struct platform_driver anatop_regulator_driver = { | |||
| 210 | .of_match_table = of_anatop_regulator_match_tbl, | 200 | .of_match_table = of_anatop_regulator_match_tbl, |
| 211 | }, | 201 | }, |
| 212 | .probe = anatop_regulator_probe, | 202 | .probe = anatop_regulator_probe, |
| 213 | .remove = __devexit_p(anatop_regulator_remove), | 203 | .remove = anatop_regulator_remove, |
| 214 | }; | 204 | }; |
| 215 | 205 | ||
| 216 | static int __init anatop_regulator_init(void) | 206 | static int __init anatop_regulator_init(void) |
