Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'topic/suspend' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-max77802

+232 -95
+22
Documentation/devicetree/bindings/regulator/regulator.txt
··· 19 19 design requires. This property describes the total system ramp time 20 20 required due to the combination of internal ramping of the regulator itself, 21 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 41 Deprecated properties: 24 42 - regulator-compatible: If a regulator chip contains multiple ··· 52 34 regulator-max-microvolt = <2500000>; 53 35 regulator-always-on; 54 36 vin-supply = <&vin>; 37 + 38 + regulator-state-mem { 39 + regulator-on-in-suspend; 40 + }; 55 41 }; 56 42 57 43 Regulator Consumers:
+2 -1
drivers/regulator/88pm8607.c
··· 330 330 for_each_child_of_node(nproot, np) { 331 331 if (!of_node_cmp(np->name, info->desc.name)) { 332 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 335 config->of_node = np; 335 336 break; 336 337 }
+3 -2
drivers/regulator/anatop-regulator.c
··· 189 189 int ret = 0; 190 190 u32 val; 191 191 192 - initdata = of_get_regulator_init_data(dev, np); 193 192 sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); 194 193 if (!sreg) 195 194 return -ENOMEM; 196 - sreg->initdata = initdata; 197 195 sreg->name = of_get_property(np, "regulator-name", NULL); 198 196 rdesc = &sreg->rdesc; 199 197 rdesc->name = sreg->name; 200 198 rdesc->type = REGULATOR_VOLTAGE; 201 199 rdesc->owner = THIS_MODULE; 200 + 201 + initdata = of_get_regulator_init_data(dev, np, rdesc); 202 + sreg->initdata = initdata; 202 203 203 204 anatop_np = of_get_parent(np); 204 205 if (!anatop_np)
+5 -3
drivers/regulator/arizona-ldo1.c
··· 179 179 }; 180 180 181 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 185 struct arizona_pdata *pdata = &arizona->pdata; 185 186 struct arizona_ldo1 *ldo1 = config->driver_data; ··· 195 194 if (init_node) { 196 195 config->of_node = init_node; 197 196 198 - init_data = of_get_regulator_init_data(arizona->dev, init_node); 197 + init_data = of_get_regulator_init_data(arizona->dev, init_node, 198 + desc); 199 199 200 200 if (init_data) { 201 201 init_data->consumer_supplies = &ldo1->supply; ··· 259 257 260 258 if (IS_ENABLED(CONFIG_OF)) { 261 259 if (!dev_get_platdata(arizona->dev)) { 262 - ret = arizona_ldo1_of_get_pdata(arizona, &config); 260 + ret = arizona_ldo1_of_get_pdata(arizona, &config, desc); 263 261 if (ret < 0) 264 262 return ret; 265 263 }
+5 -3
drivers/regulator/arizona-micsupp.c
··· 198 198 }; 199 199 200 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 204 struct arizona_pdata *pdata = &arizona->pdata; 204 205 struct arizona_micsupp *micsupp = config->driver_data; ··· 211 210 if (np) { 212 211 config->of_node = np; 213 212 214 - init_data = of_get_regulator_init_data(arizona->dev, np); 213 + init_data = of_get_regulator_init_data(arizona->dev, np, desc); 215 214 216 215 if (init_data) { 217 216 init_data->consumer_supplies = &micsupp->supply; ··· 265 264 266 265 if (IS_ENABLED(CONFIG_OF)) { 267 266 if (!dev_get_platdata(arizona->dev)) { 268 - ret = arizona_micsupp_of_get_pdata(arizona, &config); 267 + ret = arizona_micsupp_of_get_pdata(arizona, &config, 268 + desc); 269 269 if (ret < 0) 270 270 return ret; 271 271 }
+2 -1
drivers/regulator/da9052-regulator.c
··· 436 436 if (!of_node_cmp(np->name, 437 437 regulator->info->reg_desc.name)) { 438 438 config.init_data = of_get_regulator_init_data( 439 - &pdev->dev, np); 439 + &pdev->dev, np, 440 + &regulator->info->reg_desc); 440 441 config.of_node = np; 441 442 break; 442 443 }
+1 -1
drivers/regulator/da9210-regulator.c
··· 147 147 148 148 config.dev = &i2c->dev; 149 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 151 config.driver_data = chip; 152 152 config.regmap = chip->regmap; 153 153 config.of_node = dev->of_node;
+9 -8
drivers/regulator/fan53555.c
··· 302 302 }; 303 303 304 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 308 struct fan53555_platform_data *pdata; 308 309 int ret; ··· 313 312 if (!pdata) 314 313 return NULL; 315 314 316 - pdata->regulator = of_get_regulator_init_data(dev, np); 315 + pdata->regulator = of_get_regulator_init_data(dev, np, desc); 317 316 318 317 ret = of_property_read_u32(np, "fcs,suspend-voltage-selector", 319 318 &tmp); ··· 348 347 unsigned int val; 349 348 int ret; 350 349 350 + di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), 351 + GFP_KERNEL); 352 + if (!di) 353 + return -ENOMEM; 354 + 351 355 pdata = dev_get_platdata(&client->dev); 352 356 if (!pdata) 353 - pdata = fan53555_parse_dt(&client->dev, np); 357 + pdata = fan53555_parse_dt(&client->dev, np, &di->desc); 354 358 355 359 if (!pdata || !pdata->regulator) { 356 360 dev_err(&client->dev, "Platform data not found!\n"); 357 361 return -ENODEV; 358 362 } 359 - 360 - di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), 361 - GFP_KERNEL); 362 - if (!di) 363 - return -ENOMEM; 364 363 365 364 di->regulator = pdata->regulator; 366 365 if (client->dev.of_node) {
+11 -8
drivers/regulator/fixed.c
··· 40 40 /** 41 41 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info 42 42 * @dev: device requesting for fixed_voltage_config 43 + * @desc: regulator description 43 44 * 44 45 * Populates fixed_voltage_config structure by extracting data from device 45 46 * tree node, returns a pointer to the populated structure of NULL if memory 46 47 * alloc fails. 47 48 */ 48 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 53 struct fixed_voltage_config *config; 52 54 struct device_node *np = dev->of_node; ··· 59 57 if (!config) 60 58 return ERR_PTR(-ENOMEM); 61 59 62 - config->init_data = of_get_regulator_init_data(dev, dev->of_node); 60 + config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); 63 61 if (!config->init_data) 64 62 return ERR_PTR(-EINVAL); 65 63 ··· 114 112 struct regulator_config cfg = { }; 115 113 int ret; 116 114 115 + drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), 116 + GFP_KERNEL); 117 + if (!drvdata) 118 + return -ENOMEM; 119 + 117 120 if (pdev->dev.of_node) { 118 - config = of_get_fixed_voltage_config(&pdev->dev); 121 + config = of_get_fixed_voltage_config(&pdev->dev, 122 + &drvdata->desc); 119 123 if (IS_ERR(config)) 120 124 return PTR_ERR(config); 121 125 } else { ··· 129 121 } 130 122 131 123 if (!config) 132 - return -ENOMEM; 133 - 134 - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), 135 - GFP_KERNEL); 136 - if (!drvdata) 137 124 return -ENOMEM; 138 125 139 126 drvdata->desc.name = devm_kstrdup(&pdev->dev,
+10 -8
drivers/regulator/gpio-regulator.c
··· 133 133 }; 134 134 135 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 139 struct gpio_regulator_config *config; 139 140 const char *regtype; ··· 147 146 if (!config) 148 147 return ERR_PTR(-ENOMEM); 149 148 150 - config->init_data = of_get_regulator_init_data(dev, np); 149 + config->init_data = of_get_regulator_init_data(dev, np, desc); 151 150 if (!config->init_data) 152 151 return ERR_PTR(-EINVAL); 153 152 ··· 244 243 struct regulator_config cfg = { }; 245 244 int ptr, ret, state; 246 245 247 - if (np) { 248 - config = of_get_gpio_regulator_config(&pdev->dev, np); 249 - if (IS_ERR(config)) 250 - return PTR_ERR(config); 251 - } 252 - 253 246 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), 254 247 GFP_KERNEL); 255 248 if (drvdata == NULL) 256 249 return -ENOMEM; 250 + 251 + if (np) { 252 + config = of_get_gpio_regulator_config(&pdev->dev, np, 253 + &drvdata->desc); 254 + if (IS_ERR(config)) 255 + return PTR_ERR(config); 256 + } 257 257 258 258 drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); 259 259 if (drvdata->desc.name == NULL) {
+1 -1
drivers/regulator/max8952.c
··· 174 174 if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed)) 175 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, &regulator); 178 178 if (!pd->reg_data) { 179 179 dev_err(dev, "Failed to parse regulator init data\n"); 180 180 return NULL;
+2 -1
drivers/regulator/max8973-regulator.c
··· 458 458 459 459 config.dev = &client->dev; 460 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 463 config.driver_data = max; 463 464 config.of_node = client->dev.of_node; 464 465 config.regmap = max->regmap;
+2 -1
drivers/regulator/max8997.c
··· 953 953 954 954 rdata->id = i; 955 955 rdata->initdata = of_get_regulator_init_data(&pdev->dev, 956 - reg_np); 956 + reg_np, 957 + &regulators[i]); 957 958 rdata->reg_node = reg_np; 958 959 rdata++; 959 960 }
+3 -2
drivers/regulator/max8998.c
··· 686 686 continue; 687 687 688 688 rdata->id = regulators[i].id; 689 - rdata->initdata = of_get_regulator_init_data( 690 - iodev->dev, reg_np); 689 + rdata->initdata = of_get_regulator_init_data(iodev->dev, 690 + reg_np, 691 + &regulators[i]); 691 692 rdata->reg_node = reg_np; 692 693 ++rdata; 693 694 }
+2 -1
drivers/regulator/mc13xxx-regulator-core.c
··· 194 194 regulators[i].desc.name)) { 195 195 p->id = i; 196 196 p->init_data = of_get_regulator_init_data( 197 - &pdev->dev, child); 197 + &pdev->dev, child, 198 + &regulators[i].desc); 198 199 p->node = child; 199 200 p++; 200 201
+81 -6
drivers/regulator/of_regulator.c
··· 19 19 20 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 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 31 const __be32 *min_uV, *max_uV; 26 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 36 u32 pval; 29 37 30 38 constraints->name = of_get_property(np, "regulator-name", NULL); ··· 81 73 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); 82 74 if (!ret) 83 75 constraints->enable_time = pval; 76 + 77 + if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { 78 + if (desc && desc->of_map_mode) { 79 + ret = desc->of_map_mode(pval); 80 + if (ret == -EINVAL) 81 + pr_err("%s: invalid mode %u\n", np->name, pval); 82 + else 83 + constraints->initial_mode = ret; 84 + } else { 85 + pr_warn("%s: mapping for mode %d not defined\n", 86 + np->name, pval); 87 + } 88 + } 89 + 90 + for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { 91 + switch (i) { 92 + case PM_SUSPEND_MEM: 93 + suspend_state = &constraints->state_mem; 94 + break; 95 + case PM_SUSPEND_MAX: 96 + suspend_state = &constraints->state_disk; 97 + break; 98 + case PM_SUSPEND_ON: 99 + case PM_SUSPEND_FREEZE: 100 + case PM_SUSPEND_STANDBY: 101 + default: 102 + continue; 103 + }; 104 + 105 + suspend_np = of_get_child_by_name(np, regulator_states[i]); 106 + if (!suspend_np || !suspend_state) 107 + continue; 108 + 109 + if (!of_property_read_u32(suspend_np, "regulator-mode", 110 + &pval)) { 111 + if (desc && desc->of_map_mode) { 112 + ret = desc->of_map_mode(pval); 113 + if (ret == -EINVAL) 114 + pr_err("%s: invalid mode %u\n", 115 + np->name, pval); 116 + else 117 + suspend_state->mode = ret; 118 + } else { 119 + pr_warn("%s: mapping for mode %d not defined\n", 120 + np->name, pval); 121 + } 122 + } 123 + 124 + if (of_property_read_bool(suspend_np, 125 + "regulator-on-in-suspend")) 126 + suspend_state->enabled = true; 127 + else if (of_property_read_bool(suspend_np, 128 + "regulator-off-in-suspend")) 129 + suspend_state->disabled = true; 130 + 131 + if (!of_property_read_u32(suspend_np, 132 + "regulator-suspend-microvolt", &pval)) 133 + suspend_state->uV = pval; 134 + 135 + of_node_put(suspend_np); 136 + suspend_state = NULL; 137 + suspend_np = NULL; 138 + } 84 139 } 85 140 86 141 /** 87 142 * of_get_regulator_init_data - extract regulator_init_data structure info 88 143 * @dev: device requesting for regulator_init_data 144 + * @node: regulator device node 145 + * @desc: regulator description 89 146 * 90 147 * Populates regulator_init_data structure by extracting data from device 91 148 * tree node, returns a pointer to the populated struture or NULL if memory 92 149 * alloc fails. 93 150 */ 94 151 struct regulator_init_data *of_get_regulator_init_data(struct device *dev, 95 - struct device_node *node) 152 + struct device_node *node, 153 + const struct regulator_desc *desc) 96 154 { 97 155 struct regulator_init_data *init_data; 98 156 ··· 169 95 if (!init_data) 170 96 return NULL; /* Out of memory? */ 171 97 172 - of_get_regulation_constraints(node, &init_data); 98 + of_get_regulation_constraints(node, &init_data, desc); 173 99 return init_data; 174 100 } 175 101 EXPORT_SYMBOL_GPL(of_get_regulator_init_data); ··· 250 176 continue; 251 177 252 178 match->init_data = 253 - of_get_regulator_init_data(dev, child); 179 + of_get_regulator_init_data(dev, child, 180 + match->desc); 254 181 if (!match->init_data) { 255 182 dev_err(dev, 256 183 "failed to parse DT for regulator %s\n", ··· 298 223 if (strcmp(desc->of_match, name)) 299 224 continue; 300 225 301 - init_data = of_get_regulator_init_data(dev, child); 226 + init_data = of_get_regulator_init_data(dev, child, desc); 302 227 if (!init_data) { 303 228 dev_err(dev, 304 229 "failed to parse DT for regulator %s\n",
+2 -1
drivers/regulator/pwm-regulator.c
··· 149 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 154 if (!config.init_data) 154 155 return -ENOMEM; 155 156
+5 -4
drivers/regulator/qcom_rpm-regulator.c
··· 643 643 match = of_match_device(rpm_of_match, &pdev->dev); 644 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 646 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 651 647 if (!vreg) { 652 648 dev_err(&pdev->dev, "failed to allocate vreg\n"); ··· 661 665 dev_err(&pdev->dev, "unable to retrieve handle to rpm\n"); 662 666 return -ENODEV; 663 667 } 668 + 669 + initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, 670 + &vreg->desc); 671 + if (!initdata) 672 + return -EINVAL; 664 673 665 674 key = "reg"; 666 675 ret = of_property_read_u32(pdev->dev.of_node, key, &val);
+2 -1
drivers/regulator/s5m8767.c
··· 581 581 582 582 rdata->id = i; 583 583 rdata->initdata = of_get_regulator_init_data( 584 - &pdev->dev, reg_np); 584 + &pdev->dev, reg_np, 585 + &regulators[i]); 585 586 rdata->reg_node = reg_np; 586 587 rdata++; 587 588 rmode->id = i;
+1 -1
drivers/regulator/sky81452-regulator.c
··· 76 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 81 of_node_put(np); 82 82 return init_data;
+2 -1
drivers/regulator/stw481x-vmmc.c
··· 72 72 config.regmap = stw481x->map; 73 73 config.of_node = pdev->dev.of_node; 74 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 78 stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, 78 79 &vmmc_regulator, &config);
+2 -1
drivers/regulator/ti-abb-regulator.c
··· 837 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 842 if (!initdata) { 842 843 dev_err(dev, "%s: Unable to alloc regulator init data\n", 843 844 __func__);
+23 -20
drivers/regulator/tps51632-regulator.c
··· 221 221 MODULE_DEVICE_TABLE(of, tps51632_of_match); 222 222 223 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 227 struct tps51632_regulator_platform_data *pdata; 227 228 struct device_node *np = dev->of_node; ··· 231 230 if (!pdata) 232 231 return NULL; 233 232 234 - pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); 233 + pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node, 234 + desc); 235 235 if (!pdata->reg_init_data) { 236 236 dev_err(dev, "Not able to get OF regulator init data\n"); 237 237 return NULL; ··· 250 248 } 251 249 #else 252 250 static struct tps51632_regulator_platform_data * 253 - of_get_tps51632_platform_data(struct device *dev) 251 + of_get_tps51632_platform_data(struct device *dev, 252 + const struct regulator_desc *desc) 254 253 { 255 254 return NULL; 256 255 } ··· 276 273 } 277 274 } 278 275 276 + tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 277 + if (!tps) 278 + return -ENOMEM; 279 + 280 + tps->dev = &client->dev; 281 + tps->desc.name = client->name; 282 + tps->desc.id = 0; 283 + tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; 284 + tps->desc.min_uV = TPS51632_MIN_VOLTAGE; 285 + tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; 286 + tps->desc.linear_min_sel = TPS51632_MIN_VSEL; 287 + tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; 288 + tps->desc.ops = &tps51632_dcdc_ops; 289 + tps->desc.type = REGULATOR_VOLTAGE; 290 + tps->desc.owner = THIS_MODULE; 291 + 279 292 pdata = dev_get_platdata(&client->dev); 280 293 if (!pdata && client->dev.of_node) 281 - pdata = of_get_tps51632_platform_data(&client->dev); 294 + pdata = of_get_tps51632_platform_data(&client->dev, &tps->desc); 282 295 if (!pdata) { 283 296 dev_err(&client->dev, "No Platform data\n"); 284 297 return -EINVAL; ··· 314 295 return -EINVAL; 315 296 } 316 297 } 317 - 318 - tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 319 - if (!tps) 320 - return -ENOMEM; 321 - 322 - tps->dev = &client->dev; 323 - tps->desc.name = client->name; 324 - tps->desc.id = 0; 325 - tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; 326 - tps->desc.min_uV = TPS51632_MIN_VOLTAGE; 327 - tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; 328 - tps->desc.linear_min_sel = TPS51632_MIN_VSEL; 329 - tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; 330 - tps->desc.ops = &tps51632_dcdc_ops; 331 - tps->desc.type = REGULATOR_VOLTAGE; 332 - tps->desc.owner = THIS_MODULE; 333 298 334 299 if (pdata->enable_pwm_dvfs) 335 300 tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG;
+17 -14
drivers/regulator/tps62360-regulator.c
··· 293 293 }; 294 294 295 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 299 struct tps62360_regulator_platform_data *pdata; 299 300 struct device_node *np = dev->of_node; ··· 303 302 if (!pdata) 304 303 return NULL; 305 304 306 - pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); 305 + pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node, 306 + desc); 307 307 if (!pdata->reg_init_data) { 308 308 dev_err(dev, "Not able to get OF regulator init data\n"); 309 309 return NULL; ··· 352 350 353 351 pdata = dev_get_platdata(&client->dev); 354 352 353 + tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 354 + if (!tps) 355 + return -ENOMEM; 356 + 357 + tps->desc.name = client->name; 358 + tps->desc.id = 0; 359 + tps->desc.ops = &tps62360_dcdc_ops; 360 + tps->desc.type = REGULATOR_VOLTAGE; 361 + tps->desc.owner = THIS_MODULE; 362 + tps->desc.uV_step = 10000; 363 + 355 364 if (client->dev.of_node) { 356 365 const struct of_device_id *match; 357 366 match = of_match_device(of_match_ptr(tps62360_of_match), ··· 373 360 } 374 361 chip_id = (int)(long)match->data; 375 362 if (!pdata) 376 - pdata = of_get_tps62360_platform_data(&client->dev); 363 + pdata = of_get_tps62360_platform_data(&client->dev, 364 + &tps->desc); 377 365 } else if (id) { 378 366 chip_id = id->driver_data; 379 367 } else { ··· 387 373 __func__); 388 374 return -EIO; 389 375 } 390 - 391 - tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 392 - if (!tps) 393 - return -ENOMEM; 394 376 395 377 tps->en_discharge = pdata->en_discharge; 396 378 tps->en_internal_pulldn = pdata->en_internal_pulldn; ··· 410 400 default: 411 401 return -ENODEV; 412 402 } 413 - 414 - tps->desc.name = client->name; 415 - tps->desc.id = 0; 416 - tps->desc.ops = &tps62360_dcdc_ops; 417 - tps->desc.type = REGULATOR_VOLTAGE; 418 - tps->desc.owner = THIS_MODULE; 419 - tps->desc.uV_step = 10000; 420 403 421 404 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); 422 405 if (IS_ERR(tps->regmap)) {
+2 -1
drivers/regulator/tps65218-regulator.c
··· 231 231 232 232 template = match->data; 233 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 + &regulators[id]); 235 236 236 237 platform_set_drvdata(pdev, tps); 237 238
+2 -1
drivers/regulator/twl-regulator.c
··· 1104 1104 template = match->data; 1105 1105 id = template->desc.id; 1106 1106 initdata = of_get_regulator_init_data(&pdev->dev, 1107 - pdev->dev.of_node); 1107 + pdev->dev.of_node, 1108 + &template->desc); 1108 1109 drvdata = NULL; 1109 1110 } else { 1110 1111 id = pdev->id;
+2 -1
drivers/regulator/vexpress.c
··· 74 74 reg->desc.owner = THIS_MODULE; 75 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 + &reg->desc); 78 79 if (!init_data) 79 80 return -EINVAL; 80 81
+4
include/linux/regulator/driver.h
··· 243 243 * 244 244 * @enable_time: Time taken for initial enable of regulator (in uS). 245 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 249 struct regulator_desc { 248 250 const char *name; ··· 287 285 unsigned int enable_time; 288 286 289 287 unsigned int off_on_delay; 288 + 289 + unsigned int (*of_map_mode)(unsigned int mode); 290 290 }; 291 291 292 292 /**
+7 -2
include/linux/regulator/of_regulator.h
··· 6 6 #ifndef __LINUX_OF_REG_H 7 7 #define __LINUX_OF_REG_H 8 8 9 + struct regulator_desc; 10 + 9 11 struct of_regulator_match { 10 12 const char *name; 11 13 void *driver_data; 12 14 struct regulator_init_data *init_data; 13 15 struct device_node *of_node; 16 + const struct regulator_desc *desc; 14 17 }; 15 18 16 19 #if defined(CONFIG_OF) 17 20 extern struct regulator_init_data 18 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 24 extern int of_regulator_match(struct device *dev, struct device_node *node, 21 25 struct of_regulator_match *matches, 22 26 unsigned int num_matches); 23 27 #else 24 28 static inline struct regulator_init_data 25 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 33 return NULL; 29 34 }