diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-24 06:11:36 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-24 06:11:36 -0400 |
commit | 706664c290d69f890a9e3acfc6a8196098459826 (patch) | |
tree | a8b8e7bc7f9172a412363b1ceb9ea1a78587e077 | |
parent | b735e47f6e94f07911dcdf92837ebfd0ec1cf7c0 (diff) | |
parent | 609d5f6ddc18d05801646c869fcf4d0537b9110b (diff) |
Merge remote-tracking branch 'regulator/topic/fixed' into regulator-next
-rw-r--r-- | drivers/regulator/core.c | 5 | ||||
-rw-r--r-- | drivers/regulator/fixed.c | 38 | ||||
-rw-r--r-- | include/linux/regulator/driver.h | 2 |
3 files changed, 12 insertions, 33 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 916cadf45279..960103a61000 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2582,6 +2582,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) | |||
2582 | ret = rdev->desc->ops->get_voltage(rdev); | 2582 | ret = rdev->desc->ops->get_voltage(rdev); |
2583 | } else if (rdev->desc->ops->list_voltage) { | 2583 | } else if (rdev->desc->ops->list_voltage) { |
2584 | ret = rdev->desc->ops->list_voltage(rdev, 0); | 2584 | ret = rdev->desc->ops->list_voltage(rdev, 0); |
2585 | } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { | ||
2586 | ret = rdev->desc->fixed_uV; | ||
2585 | } else { | 2587 | } else { |
2586 | return -EINVAL; | 2588 | return -EINVAL; |
2587 | } | 2589 | } |
@@ -3217,7 +3219,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev) | |||
3217 | /* some attributes need specific methods to be displayed */ | 3219 | /* some attributes need specific methods to be displayed */ |
3218 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || | 3220 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || |
3219 | (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || | 3221 | (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || |
3220 | (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0)) { | 3222 | (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0) || |
3223 | (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1))) { | ||
3221 | status = device_create_file(dev, &dev_attr_microvolts); | 3224 | status = device_create_file(dev, &dev_attr_microvolts); |
3222 | if (status < 0) | 3225 | if (status < 0) |
3223 | return status; | 3226 | return status; |
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 7610920014d7..5ea64b94341c 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c | |||
@@ -34,7 +34,6 @@ | |||
34 | struct fixed_voltage_data { | 34 | struct fixed_voltage_data { |
35 | struct regulator_desc desc; | 35 | struct regulator_desc desc; |
36 | struct regulator_dev *dev; | 36 | struct regulator_dev *dev; |
37 | int microvolts; | ||
38 | }; | 37 | }; |
39 | 38 | ||
40 | 39 | ||
@@ -108,30 +107,7 @@ of_get_fixed_voltage_config(struct device *dev) | |||
108 | return config; | 107 | return config; |
109 | } | 108 | } |
110 | 109 | ||
111 | static int fixed_voltage_get_voltage(struct regulator_dev *dev) | ||
112 | { | ||
113 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); | ||
114 | |||
115 | if (data->microvolts) | ||
116 | return data->microvolts; | ||
117 | else | ||
118 | return -EINVAL; | ||
119 | } | ||
120 | |||
121 | static int fixed_voltage_list_voltage(struct regulator_dev *dev, | ||
122 | unsigned selector) | ||
123 | { | ||
124 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); | ||
125 | |||
126 | if (selector != 0) | ||
127 | return -EINVAL; | ||
128 | |||
129 | return data->microvolts; | ||
130 | } | ||
131 | |||
132 | static struct regulator_ops fixed_voltage_ops = { | 110 | static struct regulator_ops fixed_voltage_ops = { |
133 | .get_voltage = fixed_voltage_get_voltage, | ||
134 | .list_voltage = fixed_voltage_list_voltage, | ||
135 | }; | 111 | }; |
136 | 112 | ||
137 | static int reg_fixed_voltage_probe(struct platform_device *pdev) | 113 | static int reg_fixed_voltage_probe(struct platform_device *pdev) |
@@ -186,23 +162,21 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) | |||
186 | if (config->microvolts) | 162 | if (config->microvolts) |
187 | drvdata->desc.n_voltages = 1; | 163 | drvdata->desc.n_voltages = 1; |
188 | 164 | ||
189 | drvdata->microvolts = config->microvolts; | 165 | drvdata->desc.fixed_uV = config->microvolts; |
190 | 166 | ||
191 | if (config->gpio >= 0) | 167 | if (config->gpio >= 0) |
192 | cfg.ena_gpio = config->gpio; | 168 | cfg.ena_gpio = config->gpio; |
193 | cfg.ena_gpio_invert = !config->enable_high; | 169 | cfg.ena_gpio_invert = !config->enable_high; |
194 | if (config->enabled_at_boot) { | 170 | if (config->enabled_at_boot) { |
195 | if (config->enable_high) { | 171 | if (config->enable_high) |
196 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; | 172 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; |
197 | } else { | 173 | else |
198 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; | 174 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; |
199 | } | ||
200 | } else { | 175 | } else { |
201 | if (config->enable_high) { | 176 | if (config->enable_high) |
202 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; | 177 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; |
203 | } else { | 178 | else |
204 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; | 179 | cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; |
205 | } | ||
206 | } | 180 | } |
207 | if (config->gpio_is_open_drain) | 181 | if (config->gpio_is_open_drain) |
208 | cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; | 182 | cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; |
@@ -222,7 +196,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) | |||
222 | platform_set_drvdata(pdev, drvdata); | 196 | platform_set_drvdata(pdev, drvdata); |
223 | 197 | ||
224 | dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, | 198 | dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, |
225 | drvdata->microvolts); | 199 | drvdata->desc.fixed_uV); |
226 | 200 | ||
227 | return 0; | 201 | return 0; |
228 | 202 | ||
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 779b877e0fa1..c8b492c6b6a8 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -209,6 +209,7 @@ enum regulator_type { | |||
209 | * @min_uV: Voltage given by the lowest selector (if linear mapping) | 209 | * @min_uV: Voltage given by the lowest selector (if linear mapping) |
210 | * @uV_step: Voltage increase with each selector (if linear mapping) | 210 | * @uV_step: Voltage increase with each selector (if linear mapping) |
211 | * @linear_min_sel: Minimal selector for starting linear mapping | 211 | * @linear_min_sel: Minimal selector for starting linear mapping |
212 | * @fixed_uV: Fixed voltage of rails. | ||
212 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) | 213 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) |
213 | * @volt_table: Voltage mapping table (if table based mapping) | 214 | * @volt_table: Voltage mapping table (if table based mapping) |
214 | * | 215 | * |
@@ -241,6 +242,7 @@ struct regulator_desc { | |||
241 | unsigned int min_uV; | 242 | unsigned int min_uV; |
242 | unsigned int uV_step; | 243 | unsigned int uV_step; |
243 | unsigned int linear_min_sel; | 244 | unsigned int linear_min_sel; |
245 | int fixed_uV; | ||
244 | unsigned int ramp_delay; | 246 | unsigned int ramp_delay; |
245 | 247 | ||
246 | const struct regulator_linear_range *linear_ranges; | 248 | const struct regulator_linear_range *linear_ranges; |