aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-07-05 08:42:01 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-05 08:49:35 -0400
commit6be5bfc3bf0d31a70745a52e69f7f46de974193f (patch)
treea6a157abba4cf674381104ebeb5521b7e0a9aab9
parent4706fcab9b064e6077404ccb6c5ca9c188758068 (diff)
regulator: fixed: dt: support for input supply
Add support for input supply in DT parsing of node. The input supply will be provided by the property "vin-supply" in the regulator node. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--Documentation/devicetree/bindings/regulator/fixed-regulator.txt2
-rw-r--r--drivers/regulator/fixed.c19
-rw-r--r--include/linux/regulator/fixed.h2
3 files changed, 22 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
index 2f5b6b1ba15f..4fae41d54798 100644
--- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
@@ -10,6 +10,7 @@ Optional properties:
10If this property is missing, the default assumed is Active low. 10If this property is missing, the default assumed is Active low.
11- gpio-open-drain: GPIO is open drain type. 11- gpio-open-drain: GPIO is open drain type.
12 If this property is missing then default assumption is false. 12 If this property is missing then default assumption is false.
13-vin-supply: Input supply name.
13 14
14Any property defined as part of the core regulator 15Any property defined as part of the core regulator
15binding, defined in regulator.txt, can also be used. 16binding, defined in regulator.txt, can also be used.
@@ -29,4 +30,5 @@ Example:
29 enable-active-high; 30 enable-active-high;
30 regulator-boot-on; 31 regulator-boot-on;
31 gpio-open-drain; 32 gpio-open-drain;
33 vin-supply = <&parent_reg>;
32 }; 34 };
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 1a0b17e8d8a9..185468c4d38f 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -102,6 +102,9 @@ of_get_fixed_voltage_config(struct device *dev)
102 if (of_find_property(np, "gpio-open-drain", NULL)) 102 if (of_find_property(np, "gpio-open-drain", NULL))
103 config->gpio_is_open_drain = true; 103 config->gpio_is_open_drain = true;
104 104
105 if (of_find_property(np, "vin-supply", NULL))
106 config->input_supply = "vin";
107
105 return config; 108 return config;
106} 109}
107 110
@@ -169,6 +172,17 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
169 172
170 drvdata->desc.enable_time = config->startup_delay; 173 drvdata->desc.enable_time = config->startup_delay;
171 174
175 if (config->input_supply) {
176 drvdata->desc.supply_name = kstrdup(config->input_supply,
177 GFP_KERNEL);
178 if (!drvdata->desc.supply_name) {
179 dev_err(&pdev->dev,
180 "Failed to allocate input supply\n");
181 ret = -ENOMEM;
182 goto err_name;
183 }
184 }
185
172 if (config->microvolts) 186 if (config->microvolts)
173 drvdata->desc.n_voltages = 1; 187 drvdata->desc.n_voltages = 1;
174 188
@@ -202,7 +216,7 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
202 if (IS_ERR(drvdata->dev)) { 216 if (IS_ERR(drvdata->dev)) {
203 ret = PTR_ERR(drvdata->dev); 217 ret = PTR_ERR(drvdata->dev);
204 dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); 218 dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
205 goto err_name; 219 goto err_input;
206 } 220 }
207 221
208 platform_set_drvdata(pdev, drvdata); 222 platform_set_drvdata(pdev, drvdata);
@@ -212,6 +226,8 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
212 226
213 return 0; 227 return 0;
214 228
229err_input:
230 kfree(drvdata->desc.supply_name);
215err_name: 231err_name:
216 kfree(drvdata->desc.name); 232 kfree(drvdata->desc.name);
217err: 233err:
@@ -223,6 +239,7 @@ static int __devexit reg_fixed_voltage_remove(struct platform_device *pdev)
223 struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev); 239 struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev);
224 240
225 regulator_unregister(drvdata->dev); 241 regulator_unregister(drvdata->dev);
242 kfree(drvdata->desc.supply_name);
226 kfree(drvdata->desc.name); 243 kfree(drvdata->desc.name);
227 244
228 return 0; 245 return 0;
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
index f83f7440b488..d6c24c53adf4 100644
--- a/include/linux/regulator/fixed.h
+++ b/include/linux/regulator/fixed.h
@@ -22,6 +22,7 @@ struct regulator_init_data;
22/** 22/**
23 * struct fixed_voltage_config - fixed_voltage_config structure 23 * struct fixed_voltage_config - fixed_voltage_config structure
24 * @supply_name: Name of the regulator supply 24 * @supply_name: Name of the regulator supply
25 * @input_supply: Name of the input regulator supply
25 * @microvolts: Output voltage of regulator 26 * @microvolts: Output voltage of regulator
26 * @gpio: GPIO to use for enable control 27 * @gpio: GPIO to use for enable control
27 * set to -EINVAL if not used 28 * set to -EINVAL if not used
@@ -46,6 +47,7 @@ struct regulator_init_data;
46 */ 47 */
47struct fixed_voltage_config { 48struct fixed_voltage_config {
48 const char *supply_name; 49 const char *supply_name;
50 const char *input_supply;
49 int microvolts; 51 int microvolts;
50 int gpio; 52 int gpio;
51 unsigned startup_delay; 53 unsigned startup_delay;