diff options
| author | Mark Brown <broonie@kernel.org> | 2014-11-26 14:42:41 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2014-11-26 14:42:41 -0500 |
| commit | f9fbc21d03d719a10cbffe19870092592bf60d56 (patch) | |
| tree | 3f0ed48bd94d1957bd03fbebdc9779270840adc8 | |
| parent | a26ed45c912d46cedac5f15c2872aa7e462fcdf1 (diff) | |
| parent | 5e5e3a42c653c5ef1c281651f1882411601129bd (diff) | |
Merge branch 'topic/suspend' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-max77802
29 files changed, 232 insertions, 95 deletions
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index 86074334e342..abb26b58c83e 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt | |||
| @@ -19,6 +19,24 @@ Optional properties: | |||
| 19 | design requires. This property describes the total system ramp time | 19 | design requires. This property describes the total system ramp time |
| 20 | required due to the combination of internal ramping of the regulator itself, | 20 | required due to the combination of internal ramping of the regulator itself, |
| 21 | and board design issues such as trace capacitance and load on the supply. | 21 | and board design issues such as trace capacitance and load on the supply. |
| 22 | - regulator-state-mem sub-root node for Suspend-to-RAM mode | ||
| 23 | : suspend to memory, the device goes to sleep, but all data stored in memory, | ||
| 24 | only some external interrupt can wake the device. | ||
| 25 | - regulator-state-disk sub-root node for Suspend-to-DISK mode | ||
| 26 | : suspend to disk, this state operates similarly to Suspend-to-RAM, | ||
| 27 | but includes a final step of writing memory contents to disk. | ||
| 28 | - regulator-state-[mem/disk] node has following common properties: | ||
| 29 | - regulator-on-in-suspend: regulator should be on in suspend state. | ||
| 30 | - regulator-off-in-suspend: regulator should be off in suspend state. | ||
| 31 | - regulator-suspend-microvolt: regulator should be set to this voltage | ||
| 32 | in suspend. | ||
| 33 | - regulator-mode: operating mode in the given suspend state. | ||
| 34 | The set of possible operating modes depends on the capabilities of | ||
| 35 | every hardware so the valid modes are documented on each regulator | ||
| 36 | device tree binding document. | ||
| 37 | - regulator-initial-mode: initial operating mode. The set of possible operating | ||
| 38 | modes depends on the capabilities of every hardware so each device binding | ||
| 39 | documentation explains which values the regulator supports. | ||
| 22 | 40 | ||
| 23 | Deprecated properties: | 41 | Deprecated properties: |
| 24 | - regulator-compatible: If a regulator chip contains multiple | 42 | - regulator-compatible: If a regulator chip contains multiple |
| @@ -34,6 +52,10 @@ Example: | |||
| 34 | regulator-max-microvolt = <2500000>; | 52 | regulator-max-microvolt = <2500000>; |
| 35 | regulator-always-on; | 53 | regulator-always-on; |
| 36 | vin-supply = <&vin>; | 54 | vin-supply = <&vin>; |
| 55 | |||
| 56 | regulator-state-mem { | ||
| 57 | regulator-on-in-suspend; | ||
| 58 | }; | ||
| 37 | }; | 59 | }; |
| 38 | 60 | ||
| 39 | Regulator Consumers: | 61 | Regulator Consumers: |
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 6d77dcd7dcf6..3fe47bd66153 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
| @@ -330,7 +330,8 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev, | |||
| 330 | for_each_child_of_node(nproot, np) { | 330 | for_each_child_of_node(nproot, np) { |
| 331 | if (!of_node_cmp(np->name, info->desc.name)) { | 331 | if (!of_node_cmp(np->name, info->desc.name)) { |
| 332 | config->init_data = | 332 | config->init_data = |
| 333 | of_get_regulator_init_data(&pdev->dev, np); | 333 | of_get_regulator_init_data(&pdev->dev, np, |
| 334 | &info->desc); | ||
| 334 | config->of_node = np; | 335 | config->of_node = np; |
| 335 | break; | 336 | break; |
| 336 | } | 337 | } |
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 4f730af70e7c..6eaef9f64420 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
| @@ -189,17 +189,18 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
| 189 | int ret = 0; | 189 | int ret = 0; |
| 190 | u32 val; | 190 | u32 val; |
| 191 | 191 | ||
| 192 | initdata = of_get_regulator_init_data(dev, np); | ||
| 193 | sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); | 192 | sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); |
| 194 | if (!sreg) | 193 | if (!sreg) |
| 195 | return -ENOMEM; | 194 | return -ENOMEM; |
| 196 | sreg->initdata = initdata; | ||
| 197 | sreg->name = of_get_property(np, "regulator-name", NULL); | 195 | sreg->name = of_get_property(np, "regulator-name", NULL); |
| 198 | rdesc = &sreg->rdesc; | 196 | rdesc = &sreg->rdesc; |
| 199 | rdesc->name = sreg->name; | 197 | rdesc->name = sreg->name; |
| 200 | rdesc->type = REGULATOR_VOLTAGE; | 198 | rdesc->type = REGULATOR_VOLTAGE; |
| 201 | rdesc->owner = THIS_MODULE; | 199 | rdesc->owner = THIS_MODULE; |
| 202 | 200 | ||
| 201 | initdata = of_get_regulator_init_data(dev, np, rdesc); | ||
| 202 | sreg->initdata = initdata; | ||
| 203 | |||
| 203 | anatop_np = of_get_parent(np); | 204 | anatop_np = of_get_parent(np); |
| 204 | if (!anatop_np) | 205 | if (!anatop_np) |
| 205 | return -ENODEV; | 206 | return -ENODEV; |
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 4c9db589f6c1..b1eea7f76489 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c | |||
| @@ -179,7 +179,8 @@ static const struct regulator_init_data arizona_ldo1_default = { | |||
| 179 | }; | 179 | }; |
| 180 | 180 | ||
| 181 | static int arizona_ldo1_of_get_pdata(struct arizona *arizona, | 181 | static int arizona_ldo1_of_get_pdata(struct arizona *arizona, |
| 182 | struct regulator_config *config) | 182 | struct regulator_config *config, |
| 183 | const struct regulator_desc *desc) | ||
| 183 | { | 184 | { |
| 184 | struct arizona_pdata *pdata = &arizona->pdata; | 185 | struct arizona_pdata *pdata = &arizona->pdata; |
| 185 | struct arizona_ldo1 *ldo1 = config->driver_data; | 186 | struct arizona_ldo1 *ldo1 = config->driver_data; |
| @@ -194,7 +195,8 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona, | |||
| 194 | if (init_node) { | 195 | if (init_node) { |
| 195 | config->of_node = init_node; | 196 | config->of_node = init_node; |
| 196 | 197 | ||
| 197 | init_data = of_get_regulator_init_data(arizona->dev, init_node); | 198 | init_data = of_get_regulator_init_data(arizona->dev, init_node, |
| 199 | desc); | ||
| 198 | 200 | ||
| 199 | if (init_data) { | 201 | if (init_data) { |
| 200 | init_data->consumer_supplies = &ldo1->supply; | 202 | init_data->consumer_supplies = &ldo1->supply; |
| @@ -257,7 +259,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
| 257 | 259 | ||
| 258 | if (IS_ENABLED(CONFIG_OF)) { | 260 | if (IS_ENABLED(CONFIG_OF)) { |
| 259 | if (!dev_get_platdata(arizona->dev)) { | 261 | if (!dev_get_platdata(arizona->dev)) { |
| 260 | ret = arizona_ldo1_of_get_pdata(arizona, &config); | 262 | ret = arizona_ldo1_of_get_pdata(arizona, &config, desc); |
| 261 | if (ret < 0) | 263 | if (ret < 0) |
| 262 | return ret; | 264 | return ret; |
| 263 | } | 265 | } |
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index ce9aca5f8ee7..c313ef4c3a2f 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c | |||
| @@ -198,7 +198,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = { | |||
| 198 | }; | 198 | }; |
| 199 | 199 | ||
| 200 | static int arizona_micsupp_of_get_pdata(struct arizona *arizona, | 200 | static int arizona_micsupp_of_get_pdata(struct arizona *arizona, |
| 201 | struct regulator_config *config) | 201 | struct regulator_config *config, |
| 202 | const struct regulator_desc *desc) | ||
| 202 | { | 203 | { |
| 203 | struct arizona_pdata *pdata = &arizona->pdata; | 204 | struct arizona_pdata *pdata = &arizona->pdata; |
| 204 | struct arizona_micsupp *micsupp = config->driver_data; | 205 | struct arizona_micsupp *micsupp = config->driver_data; |
| @@ -210,7 +211,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona, | |||
| 210 | if (np) { | 211 | if (np) { |
| 211 | config->of_node = np; | 212 | config->of_node = np; |
| 212 | 213 | ||
| 213 | init_data = of_get_regulator_init_data(arizona->dev, np); | 214 | init_data = of_get_regulator_init_data(arizona->dev, np, desc); |
| 214 | 215 | ||
| 215 | if (init_data) { | 216 | if (init_data) { |
| 216 | init_data->consumer_supplies = &micsupp->supply; | 217 | init_data->consumer_supplies = &micsupp->supply; |
| @@ -264,7 +265,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
| 264 | 265 | ||
| 265 | if (IS_ENABLED(CONFIG_OF)) { | 266 | if (IS_ENABLED(CONFIG_OF)) { |
| 266 | if (!dev_get_platdata(arizona->dev)) { | 267 | if (!dev_get_platdata(arizona->dev)) { |
| 267 | ret = arizona_micsupp_of_get_pdata(arizona, &config); | 268 | ret = arizona_micsupp_of_get_pdata(arizona, &config, |
| 269 | desc); | ||
| 268 | if (ret < 0) | 270 | if (ret < 0) |
| 269 | return ret; | 271 | return ret; |
| 270 | } | 272 | } |
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 00033625a09c..3945f1006d23 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c | |||
| @@ -436,7 +436,8 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
| 436 | if (!of_node_cmp(np->name, | 436 | if (!of_node_cmp(np->name, |
| 437 | regulator->info->reg_desc.name)) { | 437 | regulator->info->reg_desc.name)) { |
| 438 | config.init_data = of_get_regulator_init_data( | 438 | config.init_data = of_get_regulator_init_data( |
| 439 | &pdev->dev, np); | 439 | &pdev->dev, np, |
| 440 | ®ulator->info->reg_desc); | ||
| 440 | config.of_node = np; | 441 | config.of_node = np; |
| 441 | break; | 442 | break; |
| 442 | } | 443 | } |
diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index 7a320dd11c46..bc6100103f7f 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c | |||
| @@ -147,7 +147,7 @@ static int da9210_i2c_probe(struct i2c_client *i2c, | |||
| 147 | 147 | ||
| 148 | config.dev = &i2c->dev; | 148 | config.dev = &i2c->dev; |
| 149 | config.init_data = pdata ? &pdata->da9210_constraints : | 149 | config.init_data = pdata ? &pdata->da9210_constraints : |
| 150 | of_get_regulator_init_data(dev, dev->of_node); | 150 | of_get_regulator_init_data(dev, dev->of_node, &da9210_reg); |
| 151 | config.driver_data = chip; | 151 | config.driver_data = chip; |
| 152 | config.regmap = chip->regmap; | 152 | config.regmap = chip->regmap; |
| 153 | config.of_node = dev->of_node; | 153 | config.of_node = dev->of_node; |
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index f8e4257aef92..6c43ab2d5121 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c | |||
| @@ -302,7 +302,8 @@ static struct regmap_config fan53555_regmap_config = { | |||
| 302 | }; | 302 | }; |
| 303 | 303 | ||
| 304 | static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, | 304 | static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, |
| 305 | struct device_node *np) | 305 | struct device_node *np, |
| 306 | const struct regulator_desc *desc) | ||
| 306 | { | 307 | { |
| 307 | struct fan53555_platform_data *pdata; | 308 | struct fan53555_platform_data *pdata; |
| 308 | int ret; | 309 | int ret; |
| @@ -312,7 +313,7 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, | |||
| 312 | if (!pdata) | 313 | if (!pdata) |
| 313 | return NULL; | 314 | return NULL; |
| 314 | 315 | ||
| 315 | pdata->regulator = of_get_regulator_init_data(dev, np); | 316 | pdata->regulator = of_get_regulator_init_data(dev, np, desc); |
| 316 | 317 | ||
| 317 | ret = of_property_read_u32(np, "fcs,suspend-voltage-selector", | 318 | ret = of_property_read_u32(np, "fcs,suspend-voltage-selector", |
| 318 | &tmp); | 319 | &tmp); |
| @@ -347,20 +348,20 @@ static int fan53555_regulator_probe(struct i2c_client *client, | |||
| 347 | unsigned int val; | 348 | unsigned int val; |
| 348 | int ret; | 349 | int ret; |
| 349 | 350 | ||
| 351 | di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), | ||
| 352 | GFP_KERNEL); | ||
| 353 | if (!di) | ||
| 354 | return -ENOMEM; | ||
| 355 | |||
| 350 | pdata = dev_get_platdata(&client->dev); | 356 | pdata = dev_get_platdata(&client->dev); |
| 351 | if (!pdata) | 357 | if (!pdata) |
| 352 | pdata = fan53555_parse_dt(&client->dev, np); | 358 | pdata = fan53555_parse_dt(&client->dev, np, &di->desc); |
| 353 | 359 | ||
| 354 | if (!pdata || !pdata->regulator) { | 360 | if (!pdata || !pdata->regulator) { |
| 355 | dev_err(&client->dev, "Platform data not found!\n"); | 361 | dev_err(&client->dev, "Platform data not found!\n"); |
| 356 | return -ENODEV; | 362 | return -ENODEV; |
| 357 | } | 363 | } |
| 358 | 364 | ||
| 359 | di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), | ||
| 360 | GFP_KERNEL); | ||
| 361 | if (!di) | ||
| 362 | return -ENOMEM; | ||
| 363 | |||
| 364 | di->regulator = pdata->regulator; | 365 | di->regulator = pdata->regulator; |
| 365 | if (client->dev.of_node) { | 366 | if (client->dev.of_node) { |
| 366 | const struct of_device_id *match; | 367 | const struct of_device_id *match; |
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 354105eff1f8..6cfcbc8b6594 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c | |||
| @@ -40,13 +40,15 @@ struct fixed_voltage_data { | |||
| 40 | /** | 40 | /** |
| 41 | * of_get_fixed_voltage_config - extract fixed_voltage_config structure info | 41 | * of_get_fixed_voltage_config - extract fixed_voltage_config structure info |
| 42 | * @dev: device requesting for fixed_voltage_config | 42 | * @dev: device requesting for fixed_voltage_config |
| 43 | * @desc: regulator description | ||
| 43 | * | 44 | * |
| 44 | * Populates fixed_voltage_config structure by extracting data from device | 45 | * Populates fixed_voltage_config structure by extracting data from device |
| 45 | * tree node, returns a pointer to the populated structure of NULL if memory | 46 | * tree node, returns a pointer to the populated structure of NULL if memory |
| 46 | * alloc fails. | 47 | * alloc fails. |
| 47 | */ | 48 | */ |
| 48 | static struct fixed_voltage_config * | 49 | static struct fixed_voltage_config * |
| 49 | of_get_fixed_voltage_config(struct device *dev) | 50 | of_get_fixed_voltage_config(struct device *dev, |
| 51 | const struct regulator_desc *desc) | ||
| 50 | { | 52 | { |
| 51 | struct fixed_voltage_config *config; | 53 | struct fixed_voltage_config *config; |
| 52 | struct device_node *np = dev->of_node; | 54 | struct device_node *np = dev->of_node; |
| @@ -57,7 +59,7 @@ of_get_fixed_voltage_config(struct device *dev) | |||
| 57 | if (!config) | 59 | if (!config) |
| 58 | return ERR_PTR(-ENOMEM); | 60 | return ERR_PTR(-ENOMEM); |
| 59 | 61 | ||
| 60 | config->init_data = of_get_regulator_init_data(dev, dev->of_node); | 62 | config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); |
| 61 | if (!config->init_data) | 63 | if (!config->init_data) |
| 62 | return ERR_PTR(-EINVAL); | 64 | return ERR_PTR(-EINVAL); |
| 63 | 65 | ||
| @@ -112,8 +114,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) | |||
| 112 | struct regulator_config cfg = { }; | 114 | struct regulator_config cfg = { }; |
| 113 | int ret; | 115 | int ret; |
| 114 | 116 | ||
| 117 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), | ||
| 118 | GFP_KERNEL); | ||
| 119 | if (!drvdata) | ||
| 120 | return -ENOMEM; | ||
| 121 | |||
| 115 | if (pdev->dev.of_node) { | 122 | if (pdev->dev.of_node) { |
| 116 | config = of_get_fixed_voltage_config(&pdev->dev); | 123 | config = of_get_fixed_voltage_config(&pdev->dev, |
| 124 | &drvdata->desc); | ||
| 117 | if (IS_ERR(config)) | 125 | if (IS_ERR(config)) |
| 118 | return PTR_ERR(config); | 126 | return PTR_ERR(config); |
| 119 | } else { | 127 | } else { |
| @@ -123,11 +131,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) | |||
| 123 | if (!config) | 131 | if (!config) |
| 124 | return -ENOMEM; | 132 | return -ENOMEM; |
| 125 | 133 | ||
| 126 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), | ||
| 127 | GFP_KERNEL); | ||
| 128 | if (!drvdata) | ||
| 129 | return -ENOMEM; | ||
| 130 | |||
| 131 | drvdata->desc.name = devm_kstrdup(&pdev->dev, | 134 | drvdata->desc.name = devm_kstrdup(&pdev->dev, |
| 132 | config->supply_name, | 135 | config->supply_name, |
| 133 | GFP_KERNEL); | 136 | GFP_KERNEL); |
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 989b23b377c0..5c3bcae478b9 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
| @@ -133,7 +133,8 @@ static struct regulator_ops gpio_regulator_voltage_ops = { | |||
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| 135 | static struct gpio_regulator_config * | 135 | static struct gpio_regulator_config * |
| 136 | of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | 136 | of_get_gpio_regulator_config(struct device *dev, struct device_node *np, |
| 137 | const struct regulator_desc *desc) | ||
| 137 | { | 138 | { |
| 138 | struct gpio_regulator_config *config; | 139 | struct gpio_regulator_config *config; |
| 139 | const char *regtype; | 140 | const char *regtype; |
| @@ -146,7 +147,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
| 146 | if (!config) | 147 | if (!config) |
| 147 | return ERR_PTR(-ENOMEM); | 148 | return ERR_PTR(-ENOMEM); |
| 148 | 149 | ||
| 149 | config->init_data = of_get_regulator_init_data(dev, np); | 150 | config->init_data = of_get_regulator_init_data(dev, np, desc); |
| 150 | if (!config->init_data) | 151 | if (!config->init_data) |
| 151 | return ERR_PTR(-EINVAL); | 152 | return ERR_PTR(-EINVAL); |
| 152 | 153 | ||
| @@ -243,17 +244,18 @@ static int gpio_regulator_probe(struct platform_device *pdev) | |||
| 243 | struct regulator_config cfg = { }; | 244 | struct regulator_config cfg = { }; |
| 244 | int ptr, ret, state; | 245 | int ptr, ret, state; |
| 245 | 246 | ||
| 246 | if (np) { | ||
| 247 | config = of_get_gpio_regulator_config(&pdev->dev, np); | ||
| 248 | if (IS_ERR(config)) | ||
| 249 | return PTR_ERR(config); | ||
| 250 | } | ||
| 251 | |||
| 252 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), | 247 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), |
| 253 | GFP_KERNEL); | 248 | GFP_KERNEL); |
| 254 | if (drvdata == NULL) | 249 | if (drvdata == NULL) |
| 255 | return -ENOMEM; | 250 | return -ENOMEM; |
| 256 | 251 | ||
| 252 | if (np) { | ||
| 253 | config = of_get_gpio_regulator_config(&pdev->dev, np, | ||
| 254 | &drvdata->desc); | ||
| 255 | if (IS_ERR(config)) | ||
| 256 | return PTR_ERR(config); | ||
| 257 | } | ||
| 258 | |||
| 257 | drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); | 259 | drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); |
| 258 | if (drvdata->desc.name == NULL) { | 260 | if (drvdata->desc.name == NULL) { |
| 259 | dev_err(&pdev->dev, "Failed to allocate supply name\n"); | 261 | dev_err(&pdev->dev, "Failed to allocate supply name\n"); |
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index f7f9efcfedb7..6e54d786b22c 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c | |||
| @@ -174,7 +174,7 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) | |||
| 174 | if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed)) | 174 | if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed)) |
| 175 | dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n"); | 175 | dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n"); |
| 176 | 176 | ||
| 177 | pd->reg_data = of_get_regulator_init_data(dev, np); | 177 | pd->reg_data = of_get_regulator_init_data(dev, np, ®ulator); |
| 178 | if (!pd->reg_data) { | 178 | if (!pd->reg_data) { |
| 179 | dev_err(dev, "Failed to parse regulator init data\n"); | 179 | dev_err(dev, "Failed to parse regulator init data\n"); |
| 180 | return NULL; | 180 | return NULL; |
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index dbedf1768db0..c3d55c2db593 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c | |||
| @@ -458,7 +458,8 @@ static int max8973_probe(struct i2c_client *client, | |||
| 458 | 458 | ||
| 459 | config.dev = &client->dev; | 459 | config.dev = &client->dev; |
| 460 | config.init_data = pdata ? pdata->reg_init_data : | 460 | config.init_data = pdata ? pdata->reg_init_data : |
| 461 | of_get_regulator_init_data(&client->dev, client->dev.of_node); | 461 | of_get_regulator_init_data(&client->dev, client->dev.of_node, |
| 462 | &max->desc); | ||
| 462 | config.driver_data = max; | 463 | config.driver_data = max; |
| 463 | config.of_node = client->dev.of_node; | 464 | config.of_node = client->dev.of_node; |
| 464 | config.regmap = max->regmap; | 465 | config.regmap = max->regmap; |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 9c31e215a521..726fde1d883e 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
| @@ -953,7 +953,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
| 953 | 953 | ||
| 954 | rdata->id = i; | 954 | rdata->id = i; |
| 955 | rdata->initdata = of_get_regulator_init_data(&pdev->dev, | 955 | rdata->initdata = of_get_regulator_init_data(&pdev->dev, |
| 956 | reg_np); | 956 | reg_np, |
| 957 | ®ulators[i]); | ||
| 957 | rdata->reg_node = reg_np; | 958 | rdata->reg_node = reg_np; |
| 958 | rdata++; | 959 | rdata++; |
| 959 | } | 960 | } |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 961091b46557..59e34a05a4a2 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
| @@ -686,8 +686,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, | |||
| 686 | continue; | 686 | continue; |
| 687 | 687 | ||
| 688 | rdata->id = regulators[i].id; | 688 | rdata->id = regulators[i].id; |
| 689 | rdata->initdata = of_get_regulator_init_data( | 689 | rdata->initdata = of_get_regulator_init_data(iodev->dev, |
| 690 | iodev->dev, reg_np); | 690 | reg_np, |
| 691 | ®ulators[i]); | ||
| 691 | rdata->reg_node = reg_np; | 692 | rdata->reg_node = reg_np; |
| 692 | ++rdata; | 693 | ++rdata; |
| 693 | } | 694 | } |
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index afba024953e1..0281c31ae2ed 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c | |||
| @@ -194,7 +194,8 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | |||
| 194 | regulators[i].desc.name)) { | 194 | regulators[i].desc.name)) { |
| 195 | p->id = i; | 195 | p->id = i; |
| 196 | p->init_data = of_get_regulator_init_data( | 196 | p->init_data = of_get_regulator_init_data( |
| 197 | &pdev->dev, child); | 197 | &pdev->dev, child, |
| 198 | ®ulators[i].desc); | ||
| 198 | p->node = child; | 199 | p->node = child; |
| 199 | p++; | 200 | p++; |
| 200 | 201 | ||
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 7a51814abdc5..163946075656 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
| @@ -19,12 +19,20 @@ | |||
| 19 | 19 | ||
| 20 | #include "internal.h" | 20 | #include "internal.h" |
| 21 | 21 | ||
| 22 | static const char *const regulator_states[PM_SUSPEND_MAX + 1] = { | ||
| 23 | [PM_SUSPEND_MEM] = "regulator-state-mem", | ||
| 24 | [PM_SUSPEND_MAX] = "regulator-state-disk", | ||
| 25 | }; | ||
| 26 | |||
| 22 | static void of_get_regulation_constraints(struct device_node *np, | 27 | static void of_get_regulation_constraints(struct device_node *np, |
| 23 | struct regulator_init_data **init_data) | 28 | struct regulator_init_data **init_data, |
| 29 | const struct regulator_desc *desc) | ||
| 24 | { | 30 | { |
| 25 | const __be32 *min_uV, *max_uV; | 31 | const __be32 *min_uV, *max_uV; |
| 26 | struct regulation_constraints *constraints = &(*init_data)->constraints; | 32 | struct regulation_constraints *constraints = &(*init_data)->constraints; |
| 27 | int ret; | 33 | struct regulator_state *suspend_state; |
| 34 | struct device_node *suspend_np; | ||
| 35 | int ret, i; | ||
| 28 | u32 pval; | 36 | u32 pval; |
| 29 | 37 | ||
| 30 | constraints->name = of_get_property(np, "regulator-name", NULL); | 38 | constraints->name = of_get_property(np, "regulator-name", NULL); |
| @@ -73,18 +81,84 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
| 73 | ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); | 81 | ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); |
| 74 | if (!ret) | 82 | if (!ret) |
| 75 | constraints->enable_time = pval; | 83 | constraints->enable_time = pval; |
| 84 | |||
| 85 | if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { | ||
| 86 | if (desc && desc->of_map_mode) { | ||
| 87 | ret = desc->of_map_mode(pval); | ||
| 88 | if (ret == -EINVAL) | ||
| 89 | pr_err("%s: invalid mode %u\n", np->name, pval); | ||
| 90 | else | ||
| 91 | constraints->initial_mode = ret; | ||
| 92 | } else { | ||
| 93 | pr_warn("%s: mapping for mode %d not defined\n", | ||
| 94 | np->name, pval); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { | ||
| 99 | switch (i) { | ||
| 100 | case PM_SUSPEND_MEM: | ||
| 101 | suspend_state = &constraints->state_mem; | ||
| 102 | break; | ||
| 103 | case PM_SUSPEND_MAX: | ||
| 104 | suspend_state = &constraints->state_disk; | ||
| 105 | break; | ||
| 106 | case PM_SUSPEND_ON: | ||
| 107 | case PM_SUSPEND_FREEZE: | ||
| 108 | case PM_SUSPEND_STANDBY: | ||
| 109 | default: | ||
| 110 | continue; | ||
| 111 | }; | ||
| 112 | |||
| 113 | suspend_np = of_get_child_by_name(np, regulator_states[i]); | ||
| 114 | if (!suspend_np || !suspend_state) | ||
| 115 | continue; | ||
| 116 | |||
| 117 | if (!of_property_read_u32(suspend_np, "regulator-mode", | ||
| 118 | &pval)) { | ||
| 119 | if (desc && desc->of_map_mode) { | ||
| 120 | ret = desc->of_map_mode(pval); | ||
| 121 | if (ret == -EINVAL) | ||
| 122 | pr_err("%s: invalid mode %u\n", | ||
| 123 | np->name, pval); | ||
| 124 | else | ||
| 125 | suspend_state->mode = ret; | ||
| 126 | } else { | ||
| 127 | pr_warn("%s: mapping for mode %d not defined\n", | ||
| 128 | np->name, pval); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | if (of_property_read_bool(suspend_np, | ||
| 133 | "regulator-on-in-suspend")) | ||
| 134 | suspend_state->enabled = true; | ||
| 135 | else if (of_property_read_bool(suspend_np, | ||
| 136 | "regulator-off-in-suspend")) | ||
| 137 | suspend_state->disabled = true; | ||
| 138 | |||
| 139 | if (!of_property_read_u32(suspend_np, | ||
| 140 | "regulator-suspend-microvolt", &pval)) | ||
| 141 | suspend_state->uV = pval; | ||
| 142 | |||
| 143 | of_node_put(suspend_np); | ||
| 144 | suspend_state = NULL; | ||
| 145 | suspend_np = NULL; | ||
| 146 | } | ||
| 76 | } | 147 | } |
| 77 | 148 | ||
| 78 | /** | 149 | /** |
| 79 | * of_get_regulator_init_data - extract regulator_init_data structure info | 150 | * of_get_regulator_init_data - extract regulator_init_data structure info |
| 80 | * @dev: device requesting for regulator_init_data | 151 | * @dev: device requesting for regulator_init_data |
| 152 | * @node: regulator device node | ||
| 153 | * @desc: regulator description | ||
| 81 | * | 154 | * |
| 82 | * Populates regulator_init_data structure by extracting data from device | 155 | * Populates regulator_init_data structure by extracting data from device |
| 83 | * tree node, returns a pointer to the populated struture or NULL if memory | 156 | * tree node, returns a pointer to the populated struture or NULL if memory |
| 84 | * alloc fails. | 157 | * alloc fails. |
| 85 | */ | 158 | */ |
| 86 | struct regulator_init_data *of_get_regulator_init_data(struct device *dev, | 159 | struct regulator_init_data *of_get_regulator_init_data(struct device *dev, |
| 87 | struct device_node *node) | 160 | struct device_node *node, |
| 161 | const struct regulator_desc *desc) | ||
| 88 | { | 162 | { |
| 89 | struct regulator_init_data *init_data; | 163 | struct regulator_init_data *init_data; |
| 90 | 164 | ||
| @@ -95,7 +169,7 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev, | |||
| 95 | if (!init_data) | 169 | if (!init_data) |
| 96 | return NULL; /* Out of memory? */ | 170 | return NULL; /* Out of memory? */ |
| 97 | 171 | ||
| 98 | of_get_regulation_constraints(node, &init_data); | 172 | of_get_regulation_constraints(node, &init_data, desc); |
| 99 | return init_data; | 173 | return init_data; |
| 100 | } | 174 | } |
| 101 | EXPORT_SYMBOL_GPL(of_get_regulator_init_data); | 175 | EXPORT_SYMBOL_GPL(of_get_regulator_init_data); |
| @@ -176,7 +250,8 @@ int of_regulator_match(struct device *dev, struct device_node *node, | |||
| 176 | continue; | 250 | continue; |
| 177 | 251 | ||
| 178 | match->init_data = | 252 | match->init_data = |
| 179 | of_get_regulator_init_data(dev, child); | 253 | of_get_regulator_init_data(dev, child, |
| 254 | match->desc); | ||
| 180 | if (!match->init_data) { | 255 | if (!match->init_data) { |
| 181 | dev_err(dev, | 256 | dev_err(dev, |
| 182 | "failed to parse DT for regulator %s\n", | 257 | "failed to parse DT for regulator %s\n", |
| @@ -223,7 +298,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, | |||
| 223 | if (strcmp(desc->of_match, name)) | 298 | if (strcmp(desc->of_match, name)) |
| 224 | continue; | 299 | continue; |
| 225 | 300 | ||
| 226 | init_data = of_get_regulator_init_data(dev, child); | 301 | init_data = of_get_regulator_init_data(dev, child, desc); |
| 227 | if (!init_data) { | 302 | if (!init_data) { |
| 228 | dev_err(dev, | 303 | dev_err(dev, |
| 229 | "failed to parse DT for regulator %s\n", | 304 | "failed to parse DT for regulator %s\n", |
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index d3f55eaea058..91f34ca3a9ac 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c | |||
| @@ -149,7 +149,8 @@ static int pwm_regulator_probe(struct platform_device *pdev) | |||
| 149 | return ret; | 149 | return ret; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | config.init_data = of_get_regulator_init_data(&pdev->dev, np); | 152 | config.init_data = of_get_regulator_init_data(&pdev->dev, np, |
| 153 | &drvdata->desc); | ||
| 153 | if (!config.init_data) | 154 | if (!config.init_data) |
| 154 | return -ENOMEM; | 155 | return -ENOMEM; |
| 155 | 156 | ||
diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c index b55cd5b50ebe..dabd28a359dc 100644 --- a/drivers/regulator/qcom_rpm-regulator.c +++ b/drivers/regulator/qcom_rpm-regulator.c | |||
| @@ -643,10 +643,6 @@ static int rpm_reg_probe(struct platform_device *pdev) | |||
| 643 | match = of_match_device(rpm_of_match, &pdev->dev); | 643 | match = of_match_device(rpm_of_match, &pdev->dev); |
| 644 | template = match->data; | 644 | template = match->data; |
| 645 | 645 | ||
| 646 | initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); | ||
| 647 | if (!initdata) | ||
| 648 | return -EINVAL; | ||
| 649 | |||
| 650 | vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); | 646 | vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); |
| 651 | if (!vreg) { | 647 | if (!vreg) { |
| 652 | dev_err(&pdev->dev, "failed to allocate vreg\n"); | 648 | dev_err(&pdev->dev, "failed to allocate vreg\n"); |
| @@ -666,6 +662,11 @@ static int rpm_reg_probe(struct platform_device *pdev) | |||
| 666 | return -ENODEV; | 662 | return -ENODEV; |
| 667 | } | 663 | } |
| 668 | 664 | ||
| 665 | initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, | ||
| 666 | &vreg->desc); | ||
| 667 | if (!initdata) | ||
| 668 | return -EINVAL; | ||
| 669 | |||
| 669 | key = "reg"; | 670 | key = "reg"; |
| 670 | ret = of_property_read_u32(pdev->dev.of_node, key, &val); | 671 | ret = of_property_read_u32(pdev->dev.of_node, key, &val); |
| 671 | if (ret) { | 672 | if (ret) { |
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 0ab5cbeeb797..26932fe42b47 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
| @@ -581,7 +581,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
| 581 | 581 | ||
| 582 | rdata->id = i; | 582 | rdata->id = i; |
| 583 | rdata->initdata = of_get_regulator_init_data( | 583 | rdata->initdata = of_get_regulator_init_data( |
| 584 | &pdev->dev, reg_np); | 584 | &pdev->dev, reg_np, |
| 585 | ®ulators[i]); | ||
| 585 | rdata->reg_node = reg_np; | 586 | rdata->reg_node = reg_np; |
| 586 | rdata++; | 587 | rdata++; |
| 587 | rmode->id = i; | 588 | rmode->id = i; |
diff --git a/drivers/regulator/sky81452-regulator.c b/drivers/regulator/sky81452-regulator.c index 97aff0ccd65f..75deae706f84 100644 --- a/drivers/regulator/sky81452-regulator.c +++ b/drivers/regulator/sky81452-regulator.c | |||
| @@ -76,7 +76,7 @@ static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev) | |||
| 76 | return NULL; | 76 | return NULL; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | init_data = of_get_regulator_init_data(dev, np); | 79 | init_data = of_get_regulator_init_data(dev, np, &sky81452_reg); |
| 80 | 80 | ||
| 81 | of_node_put(np); | 81 | of_node_put(np); |
| 82 | return init_data; | 82 | return init_data; |
diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c index a7e152696a02..b4f1696456a7 100644 --- a/drivers/regulator/stw481x-vmmc.c +++ b/drivers/regulator/stw481x-vmmc.c | |||
| @@ -72,7 +72,8 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) | |||
| 72 | config.regmap = stw481x->map; | 72 | config.regmap = stw481x->map; |
| 73 | config.of_node = pdev->dev.of_node; | 73 | config.of_node = pdev->dev.of_node; |
| 74 | config.init_data = of_get_regulator_init_data(&pdev->dev, | 74 | config.init_data = of_get_regulator_init_data(&pdev->dev, |
| 75 | pdev->dev.of_node); | 75 | pdev->dev.of_node, |
| 76 | &vmmc_regulator); | ||
| 76 | 77 | ||
| 77 | stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, | 78 | stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, |
| 78 | &vmmc_regulator, &config); | 79 | &vmmc_regulator, &config); |
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index a2dabb575b97..1ef5aba96f17 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c | |||
| @@ -837,7 +837,8 @@ skip_opt: | |||
| 837 | return -EINVAL; | 837 | return -EINVAL; |
| 838 | } | 838 | } |
| 839 | 839 | ||
| 840 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); | 840 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node, |
| 841 | &abb->rdesc); | ||
| 841 | if (!initdata) { | 842 | if (!initdata) { |
| 842 | dev_err(dev, "%s: Unable to alloc regulator init data\n", | 843 | dev_err(dev, "%s: Unable to alloc regulator init data\n", |
| 843 | __func__); | 844 | __func__); |
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index f31f22e3e1bd..c213e37eb69e 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
| @@ -221,7 +221,8 @@ static const struct of_device_id tps51632_of_match[] = { | |||
| 221 | MODULE_DEVICE_TABLE(of, tps51632_of_match); | 221 | MODULE_DEVICE_TABLE(of, tps51632_of_match); |
| 222 | 222 | ||
| 223 | static struct tps51632_regulator_platform_data * | 223 | static struct tps51632_regulator_platform_data * |
| 224 | of_get_tps51632_platform_data(struct device *dev) | 224 | of_get_tps51632_platform_data(struct device *dev, |
| 225 | const struct regulator_desc *desc) | ||
| 225 | { | 226 | { |
| 226 | struct tps51632_regulator_platform_data *pdata; | 227 | struct tps51632_regulator_platform_data *pdata; |
| 227 | struct device_node *np = dev->of_node; | 228 | struct device_node *np = dev->of_node; |
| @@ -230,7 +231,8 @@ static struct tps51632_regulator_platform_data * | |||
| 230 | if (!pdata) | 231 | if (!pdata) |
| 231 | return NULL; | 232 | return NULL; |
| 232 | 233 | ||
| 233 | pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); | 234 | pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node, |
| 235 | desc); | ||
| 234 | if (!pdata->reg_init_data) { | 236 | if (!pdata->reg_init_data) { |
| 235 | dev_err(dev, "Not able to get OF regulator init data\n"); | 237 | dev_err(dev, "Not able to get OF regulator init data\n"); |
| 236 | return NULL; | 238 | return NULL; |
| @@ -248,7 +250,8 @@ static struct tps51632_regulator_platform_data * | |||
| 248 | } | 250 | } |
| 249 | #else | 251 | #else |
| 250 | static struct tps51632_regulator_platform_data * | 252 | static struct tps51632_regulator_platform_data * |
| 251 | of_get_tps51632_platform_data(struct device *dev) | 253 | of_get_tps51632_platform_data(struct device *dev, |
| 254 | const struct regulator_desc *desc) | ||
| 252 | { | 255 | { |
| 253 | return NULL; | 256 | return NULL; |
| 254 | } | 257 | } |
| @@ -273,9 +276,25 @@ static int tps51632_probe(struct i2c_client *client, | |||
| 273 | } | 276 | } |
| 274 | } | 277 | } |
| 275 | 278 | ||
| 279 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); | ||
| 280 | if (!tps) | ||
| 281 | return -ENOMEM; | ||
| 282 | |||
| 283 | tps->dev = &client->dev; | ||
| 284 | tps->desc.name = client->name; | ||
| 285 | tps->desc.id = 0; | ||
| 286 | tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; | ||
| 287 | tps->desc.min_uV = TPS51632_MIN_VOLTAGE; | ||
| 288 | tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; | ||
| 289 | tps->desc.linear_min_sel = TPS51632_MIN_VSEL; | ||
| 290 | tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; | ||
| 291 | tps->desc.ops = &tps51632_dcdc_ops; | ||
| 292 | tps->desc.type = REGULATOR_VOLTAGE; | ||
| 293 | tps->desc.owner = THIS_MODULE; | ||
| 294 | |||
| 276 | pdata = dev_get_platdata(&client->dev); | 295 | pdata = dev_get_platdata(&client->dev); |
| 277 | if (!pdata && client->dev.of_node) | 296 | if (!pdata && client->dev.of_node) |
| 278 | pdata = of_get_tps51632_platform_data(&client->dev); | 297 | pdata = of_get_tps51632_platform_data(&client->dev, &tps->desc); |
| 279 | if (!pdata) { | 298 | if (!pdata) { |
| 280 | dev_err(&client->dev, "No Platform data\n"); | 299 | dev_err(&client->dev, "No Platform data\n"); |
| 281 | return -EINVAL; | 300 | return -EINVAL; |
| @@ -296,22 +315,6 @@ static int tps51632_probe(struct i2c_client *client, | |||
| 296 | } | 315 | } |
| 297 | } | 316 | } |
| 298 | 317 | ||
| 299 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); | ||
| 300 | if (!tps) | ||
| 301 | return -ENOMEM; | ||
| 302 | |||
| 303 | tps->dev = &client->dev; | ||
| 304 | tps->desc.name = client->name; | ||
| 305 | tps->desc.id = 0; | ||
| 306 | tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; | ||
| 307 | tps->desc.min_uV = TPS51632_MIN_VOLTAGE; | ||
| 308 | tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; | ||
| 309 | tps->desc.linear_min_sel = TPS51632_MIN_VSEL; | ||
| 310 | tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; | ||
| 311 | tps->desc.ops = &tps51632_dcdc_ops; | ||
| 312 | tps->desc.type = REGULATOR_VOLTAGE; | ||
| 313 | tps->desc.owner = THIS_MODULE; | ||
| 314 | |||
| 315 | if (pdata->enable_pwm_dvfs) | 318 | if (pdata->enable_pwm_dvfs) |
| 316 | tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG; | 319 | tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG; |
| 317 | else | 320 | else |
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index a1672044e519..a1fd626c6c96 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
| @@ -293,7 +293,8 @@ static const struct regmap_config tps62360_regmap_config = { | |||
| 293 | }; | 293 | }; |
| 294 | 294 | ||
| 295 | static struct tps62360_regulator_platform_data * | 295 | static struct tps62360_regulator_platform_data * |
| 296 | of_get_tps62360_platform_data(struct device *dev) | 296 | of_get_tps62360_platform_data(struct device *dev, |
| 297 | const struct regulator_desc *desc) | ||
| 297 | { | 298 | { |
| 298 | struct tps62360_regulator_platform_data *pdata; | 299 | struct tps62360_regulator_platform_data *pdata; |
| 299 | struct device_node *np = dev->of_node; | 300 | struct device_node *np = dev->of_node; |
| @@ -302,7 +303,8 @@ static struct tps62360_regulator_platform_data * | |||
| 302 | if (!pdata) | 303 | if (!pdata) |
| 303 | return NULL; | 304 | return NULL; |
| 304 | 305 | ||
| 305 | pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); | 306 | pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node, |
| 307 | desc); | ||
| 306 | if (!pdata->reg_init_data) { | 308 | if (!pdata->reg_init_data) { |
| 307 | dev_err(dev, "Not able to get OF regulator init data\n"); | 309 | dev_err(dev, "Not able to get OF regulator init data\n"); |
| 308 | return NULL; | 310 | return NULL; |
| @@ -350,6 +352,17 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 350 | 352 | ||
| 351 | pdata = dev_get_platdata(&client->dev); | 353 | pdata = dev_get_platdata(&client->dev); |
| 352 | 354 | ||
| 355 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); | ||
| 356 | if (!tps) | ||
| 357 | return -ENOMEM; | ||
| 358 | |||
| 359 | tps->desc.name = client->name; | ||
| 360 | tps->desc.id = 0; | ||
| 361 | tps->desc.ops = &tps62360_dcdc_ops; | ||
| 362 | tps->desc.type = REGULATOR_VOLTAGE; | ||
| 363 | tps->desc.owner = THIS_MODULE; | ||
| 364 | tps->desc.uV_step = 10000; | ||
| 365 | |||
| 353 | if (client->dev.of_node) { | 366 | if (client->dev.of_node) { |
| 354 | const struct of_device_id *match; | 367 | const struct of_device_id *match; |
| 355 | match = of_match_device(of_match_ptr(tps62360_of_match), | 368 | match = of_match_device(of_match_ptr(tps62360_of_match), |
| @@ -360,7 +373,8 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 360 | } | 373 | } |
| 361 | chip_id = (int)(long)match->data; | 374 | chip_id = (int)(long)match->data; |
| 362 | if (!pdata) | 375 | if (!pdata) |
| 363 | pdata = of_get_tps62360_platform_data(&client->dev); | 376 | pdata = of_get_tps62360_platform_data(&client->dev, |
| 377 | &tps->desc); | ||
| 364 | } else if (id) { | 378 | } else if (id) { |
| 365 | chip_id = id->driver_data; | 379 | chip_id = id->driver_data; |
| 366 | } else { | 380 | } else { |
| @@ -374,10 +388,6 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 374 | return -EIO; | 388 | return -EIO; |
| 375 | } | 389 | } |
| 376 | 390 | ||
| 377 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); | ||
| 378 | if (!tps) | ||
| 379 | return -ENOMEM; | ||
| 380 | |||
| 381 | tps->en_discharge = pdata->en_discharge; | 391 | tps->en_discharge = pdata->en_discharge; |
| 382 | tps->en_internal_pulldn = pdata->en_internal_pulldn; | 392 | tps->en_internal_pulldn = pdata->en_internal_pulldn; |
| 383 | tps->vsel0_gpio = pdata->vsel0_gpio; | 393 | tps->vsel0_gpio = pdata->vsel0_gpio; |
| @@ -401,13 +411,6 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 401 | return -ENODEV; | 411 | return -ENODEV; |
| 402 | } | 412 | } |
| 403 | 413 | ||
| 404 | tps->desc.name = client->name; | ||
| 405 | tps->desc.id = 0; | ||
| 406 | tps->desc.ops = &tps62360_dcdc_ops; | ||
| 407 | tps->desc.type = REGULATOR_VOLTAGE; | ||
| 408 | tps->desc.owner = THIS_MODULE; | ||
| 409 | tps->desc.uV_step = 10000; | ||
| 410 | |||
| 411 | tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); | 414 | tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); |
| 412 | if (IS_ERR(tps->regmap)) { | 415 | if (IS_ERR(tps->regmap)) { |
| 413 | ret = PTR_ERR(tps->regmap); | 416 | ret = PTR_ERR(tps->regmap); |
diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c index f0a40281b9c1..263cc85d6202 100644 --- a/drivers/regulator/tps65218-regulator.c +++ b/drivers/regulator/tps65218-regulator.c | |||
| @@ -231,7 +231,8 @@ static int tps65218_regulator_probe(struct platform_device *pdev) | |||
| 231 | 231 | ||
| 232 | template = match->data; | 232 | template = match->data; |
| 233 | id = template->id; | 233 | id = template->id; |
| 234 | init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); | 234 | init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, |
| 235 | ®ulators[id]); | ||
| 235 | 236 | ||
| 236 | platform_set_drvdata(pdev, tps); | 237 | platform_set_drvdata(pdev, tps); |
| 237 | 238 | ||
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 0b4f8660fdb4..dd727bca1983 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
| @@ -1104,7 +1104,8 @@ static int twlreg_probe(struct platform_device *pdev) | |||
| 1104 | template = match->data; | 1104 | template = match->data; |
| 1105 | id = template->desc.id; | 1105 | id = template->desc.id; |
| 1106 | initdata = of_get_regulator_init_data(&pdev->dev, | 1106 | initdata = of_get_regulator_init_data(&pdev->dev, |
| 1107 | pdev->dev.of_node); | 1107 | pdev->dev.of_node, |
| 1108 | &template->desc); | ||
| 1108 | drvdata = NULL; | 1109 | drvdata = NULL; |
| 1109 | } else { | 1110 | } else { |
| 1110 | id = pdev->id; | 1111 | id = pdev->id; |
diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c index 02e7267ccf92..5e7c789023a9 100644 --- a/drivers/regulator/vexpress.c +++ b/drivers/regulator/vexpress.c | |||
| @@ -74,7 +74,8 @@ static int vexpress_regulator_probe(struct platform_device *pdev) | |||
| 74 | reg->desc.owner = THIS_MODULE; | 74 | reg->desc.owner = THIS_MODULE; |
| 75 | reg->desc.continuous_voltage_range = true; | 75 | reg->desc.continuous_voltage_range = true; |
| 76 | 76 | ||
| 77 | init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); | 77 | init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, |
| 78 | ®->desc); | ||
| 78 | if (!init_data) | 79 | if (!init_data) |
| 79 | return -EINVAL; | 80 | return -EINVAL; |
| 80 | 81 | ||
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index fc0ee0ce8325..73dd073afef5 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
| @@ -243,6 +243,8 @@ enum regulator_type { | |||
| 243 | * | 243 | * |
| 244 | * @enable_time: Time taken for initial enable of regulator (in uS). | 244 | * @enable_time: Time taken for initial enable of regulator (in uS). |
| 245 | * @off_on_delay: guard time (in uS), before re-enabling a regulator | 245 | * @off_on_delay: guard time (in uS), before re-enabling a regulator |
| 246 | * | ||
| 247 | * @of_map_mode: Maps a hardware mode defined in a DeviceTree to a standard mode | ||
| 246 | */ | 248 | */ |
| 247 | struct regulator_desc { | 249 | struct regulator_desc { |
| 248 | const char *name; | 250 | const char *name; |
| @@ -285,6 +287,8 @@ struct regulator_desc { | |||
| 285 | unsigned int enable_time; | 287 | unsigned int enable_time; |
| 286 | 288 | ||
| 287 | unsigned int off_on_delay; | 289 | unsigned int off_on_delay; |
| 290 | |||
| 291 | unsigned int (*of_map_mode)(unsigned int mode); | ||
| 288 | }; | 292 | }; |
| 289 | 293 | ||
| 290 | /** | 294 | /** |
diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index f9217965aaa3..763953f7e3b8 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h | |||
| @@ -6,24 +6,29 @@ | |||
| 6 | #ifndef __LINUX_OF_REG_H | 6 | #ifndef __LINUX_OF_REG_H |
| 7 | #define __LINUX_OF_REG_H | 7 | #define __LINUX_OF_REG_H |
| 8 | 8 | ||
| 9 | struct regulator_desc; | ||
| 10 | |||
| 9 | struct of_regulator_match { | 11 | struct of_regulator_match { |
| 10 | const char *name; | 12 | const char *name; |
| 11 | void *driver_data; | 13 | void *driver_data; |
| 12 | struct regulator_init_data *init_data; | 14 | struct regulator_init_data *init_data; |
| 13 | struct device_node *of_node; | 15 | struct device_node *of_node; |
| 16 | const struct regulator_desc *desc; | ||
| 14 | }; | 17 | }; |
| 15 | 18 | ||
| 16 | #if defined(CONFIG_OF) | 19 | #if defined(CONFIG_OF) |
| 17 | extern struct regulator_init_data | 20 | extern struct regulator_init_data |
| 18 | *of_get_regulator_init_data(struct device *dev, | 21 | *of_get_regulator_init_data(struct device *dev, |
| 19 | struct device_node *node); | 22 | struct device_node *node, |
| 23 | const struct regulator_desc *desc); | ||
| 20 | extern int of_regulator_match(struct device *dev, struct device_node *node, | 24 | extern int of_regulator_match(struct device *dev, struct device_node *node, |
| 21 | struct of_regulator_match *matches, | 25 | struct of_regulator_match *matches, |
| 22 | unsigned int num_matches); | 26 | unsigned int num_matches); |
| 23 | #else | 27 | #else |
| 24 | static inline struct regulator_init_data | 28 | static inline struct regulator_init_data |
| 25 | *of_get_regulator_init_data(struct device *dev, | 29 | *of_get_regulator_init_data(struct device *dev, |
| 26 | struct device_node *node) | 30 | struct device_node *node, |
| 31 | const struct regulator_desc *desc) | ||
| 27 | { | 32 | { |
| 28 | return NULL; | 33 | return NULL; |
| 29 | } | 34 | } |
