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

Merge remote-tracking branches 'regulator/topic/dbx500', 'regulator/topic/load-op', 'regulator/topic/max77693' and 'regulator/topic/max8660' into regulator-next

+80 -138
+24 -15
drivers/regulator/core.c
··· 648 648 if (err < 0) 649 649 return 0; 650 650 651 - if (!rdev->desc->ops->get_optimum_mode) 651 + if (!rdev->desc->ops->get_optimum_mode && 652 + !rdev->desc->ops->set_load) 652 653 return 0; 653 654 654 - if (!rdev->desc->ops->set_mode) 655 + if (!rdev->desc->ops->set_mode && 656 + !rdev->desc->ops->set_load) 655 657 return -EINVAL; 656 658 657 659 /* get output voltage */ ··· 678 676 list_for_each_entry(sibling, &rdev->consumer_list, list) 679 677 current_uA += sibling->uA_load; 680 678 681 - /* now get the optimum mode for our new total regulator load */ 682 - mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV, 683 - output_uV, current_uA); 679 + if (rdev->desc->ops->set_load) { 680 + /* set the optimum mode for our new total regulator load */ 681 + err = rdev->desc->ops->set_load(rdev, current_uA); 682 + if (err < 0) 683 + rdev_err(rdev, "failed to set load %d\n", current_uA); 684 + } else { 685 + /* now get the optimum mode for our new total regulator load */ 686 + mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV, 687 + output_uV, current_uA); 684 688 685 - /* check the new mode is allowed */ 686 - err = regulator_mode_constrain(rdev, &mode); 687 - if (err < 0) { 688 - rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n", 689 - current_uA, input_uV, output_uV); 690 - return err; 689 + /* check the new mode is allowed */ 690 + err = regulator_mode_constrain(rdev, &mode); 691 + if (err < 0) { 692 + rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n", 693 + current_uA, input_uV, output_uV); 694 + return err; 695 + } 696 + 697 + err = rdev->desc->ops->set_mode(rdev, mode); 698 + if (err < 0) 699 + rdev_err(rdev, "failed to set optimum mode %x\n", mode); 691 700 } 692 - 693 - err = rdev->desc->ops->set_mode(rdev, mode); 694 - if (err < 0) 695 - rdev_err(rdev, "failed to set optimum mode %x\n", mode); 696 701 697 702 return err; 698 703 }
+9 -23
drivers/regulator/dbx500-prcmu.c
··· 95 95 96 96 static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p) 97 97 { 98 - struct device *dev = s->private; 99 - int err; 100 - 101 98 /* print power state count */ 102 - err = seq_printf(s, "ux500-regulator power state count: %i\n", 103 - power_state_active_get()); 104 - if (err < 0) 105 - dev_err(dev, "seq_printf overflow\n"); 99 + seq_printf(s, "ux500-regulator power state count: %i\n", 100 + power_state_active_get()); 106 101 107 102 return 0; 108 103 } ··· 119 124 120 125 static int ux500_regulator_status_print(struct seq_file *s, void *p) 121 126 { 122 - struct device *dev = s->private; 123 - int err; 124 127 int i; 125 128 126 129 /* print dump header */ 127 - err = seq_puts(s, "ux500-regulator status:\n"); 128 - if (err < 0) 129 - dev_err(dev, "seq_puts overflow\n"); 130 - 131 - err = seq_printf(s, "%31s : %8s : %8s\n", "current", 132 - "before", "after"); 133 - if (err < 0) 134 - dev_err(dev, "seq_printf overflow\n"); 130 + seq_puts(s, "ux500-regulator status:\n"); 131 + seq_printf(s, "%31s : %8s : %8s\n", "current", "before", "after"); 135 132 136 133 for (i = 0; i < rdebug.num_regulators; i++) { 137 134 struct dbx500_regulator_info *info; ··· 131 144 info = &rdebug.regulator_array[i]; 132 145 133 146 /* print status */ 134 - err = seq_printf(s, "%20s : %8s : %8s : %8s\n", info->desc.name, 135 - info->is_enabled ? "enabled" : "disabled", 136 - rdebug.state_before_suspend[i] ? "enabled" : "disabled", 137 - rdebug.state_after_suspend[i] ? "enabled" : "disabled"); 138 - if (err < 0) 139 - dev_err(dev, "seq_printf overflow\n"); 147 + seq_printf(s, "%20s : %8s : %8s : %8s\n", 148 + info->desc.name, 149 + info->is_enabled ? "enabled" : "disabled", 150 + rdebug.state_before_suspend[i] ? "enabled" : "disabled", 151 + rdebug.state_after_suspend[i] ? "enabled" : "disabled"); 140 152 } 141 153 142 154 return 0;
+9 -84
drivers/regulator/max77693.c
··· 128 128 #define regulator_desc_esafeout(_num) { \ 129 129 .name = "ESAFEOUT"#_num, \ 130 130 .id = MAX77693_ESAFEOUT##_num, \ 131 + .of_match = of_match_ptr("ESAFEOUT"#_num), \ 132 + .regulators_node = of_match_ptr("regulators"), \ 131 133 .n_voltages = 4, \ 132 134 .ops = &max77693_safeout_ops, \ 133 135 .type = REGULATOR_VOLTAGE, \ ··· 147 145 { 148 146 .name = "CHARGER", 149 147 .id = MAX77693_CHARGER, 148 + .of_match = of_match_ptr("CHARGER"), 149 + .regulators_node = of_match_ptr("regulators"), 150 150 .ops = &max77693_charger_ops, 151 151 .type = REGULATOR_CURRENT, 152 152 .owner = THIS_MODULE, ··· 158 154 }, 159 155 }; 160 156 161 - #ifdef CONFIG_OF 162 - static int max77693_pmic_dt_parse_rdata(struct device *dev, 163 - struct max77693_regulator_data **rdata) 164 - { 165 - struct device_node *np; 166 - struct of_regulator_match *rmatch; 167 - struct max77693_regulator_data *tmp; 168 - int i, matched = 0; 169 - 170 - np = of_get_child_by_name(dev->parent->of_node, "regulators"); 171 - if (!np) 172 - return -EINVAL; 173 - 174 - rmatch = devm_kzalloc(dev, 175 - sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL); 176 - if (!rmatch) { 177 - of_node_put(np); 178 - return -ENOMEM; 179 - } 180 - 181 - for (i = 0; i < ARRAY_SIZE(regulators); i++) 182 - rmatch[i].name = regulators[i].name; 183 - 184 - matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators)); 185 - of_node_put(np); 186 - if (matched <= 0) 187 - return matched; 188 - *rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL); 189 - if (!(*rdata)) 190 - return -ENOMEM; 191 - 192 - tmp = *rdata; 193 - 194 - for (i = 0; i < matched; i++) { 195 - tmp->initdata = rmatch[i].init_data; 196 - tmp->of_node = rmatch[i].of_node; 197 - tmp->id = regulators[i].id; 198 - tmp++; 199 - } 200 - 201 - return matched; 202 - } 203 - #else 204 - static int max77693_pmic_dt_parse_rdata(struct device *dev, 205 - struct max77693_regulator_data **rdata) 206 - { 207 - return 0; 208 - } 209 - #endif /* CONFIG_OF */ 210 - 211 - static int max77693_pmic_init_rdata(struct device *dev, 212 - struct max77693_regulator_data **rdata) 213 - { 214 - struct max77693_platform_data *pdata; 215 - int num_regulators = 0; 216 - 217 - pdata = dev_get_platdata(dev->parent); 218 - if (pdata) { 219 - *rdata = pdata->regulators; 220 - num_regulators = pdata->num_regulators; 221 - } 222 - 223 - if (!(*rdata) && dev->parent->of_node) 224 - num_regulators = max77693_pmic_dt_parse_rdata(dev, rdata); 225 - 226 - return num_regulators; 227 - } 228 - 229 157 static int max77693_pmic_probe(struct platform_device *pdev) 230 158 { 231 159 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); 232 - struct max77693_regulator_data *rdata = NULL; 233 - int num_rdata, i; 160 + int i; 234 161 struct regulator_config config = { }; 235 162 236 - num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); 237 - if (!rdata || num_rdata <= 0) { 238 - dev_err(&pdev->dev, "No init data supplied.\n"); 239 - return -ENODEV; 240 - } 241 - 242 - config.dev = &pdev->dev; 163 + config.dev = iodev->dev; 243 164 config.regmap = iodev->regmap; 244 165 245 - for (i = 0; i < num_rdata; i++) { 246 - int id = rdata[i].id; 166 + for (i = 0; i < ARRAY_SIZE(regulators); i++) { 247 167 struct regulator_dev *rdev; 248 168 249 - config.init_data = rdata[i].initdata; 250 - config.of_node = rdata[i].of_node; 251 - 252 169 rdev = devm_regulator_register(&pdev->dev, 253 - &regulators[id], &config); 170 + &regulators[i], &config); 254 171 if (IS_ERR(rdev)) { 255 172 dev_err(&pdev->dev, 256 - "Failed to initialize regulator-%d\n", id); 173 + "Failed to initialize regulator-%d\n", i); 257 174 return PTR_ERR(rdev); 258 175 } 259 176 }
+4 -5
drivers/regulator/max8660.c
··· 382 382 const struct i2c_device_id *i2c_id) 383 383 { 384 384 struct device *dev = &client->dev; 385 - struct max8660_platform_data *pdata = dev_get_platdata(dev); 385 + struct max8660_platform_data pdata_of, *pdata = dev_get_platdata(dev); 386 386 struct regulator_config config = { }; 387 387 struct max8660 *max8660; 388 388 int boot_on, i, id, ret = -EINVAL; ··· 391 391 392 392 if (dev->of_node && !pdata) { 393 393 const struct of_device_id *id; 394 - struct max8660_platform_data pdata_of; 395 394 396 395 id = of_match_device(of_match_ptr(max8660_dt_ids), dev); 397 396 if (!id) ··· 442 443 for (i = 0; i < pdata->num_subdevs; i++) { 443 444 444 445 if (!pdata->subdevs[i].platform_data) 445 - return ret; 446 - 447 - boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; 446 + boot_on = false; 447 + else 448 + boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; 448 449 449 450 switch (pdata->subdevs[i].id) { 450 451 case MAX8660_V3:
+30
drivers/regulator/qcom_rpm-regulator.c
··· 393 393 return vreg->is_enabled; 394 394 } 395 395 396 + static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA) 397 + { 398 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 399 + const struct rpm_reg_parts *parts = vreg->parts; 400 + const struct request_member *req = &parts->ia; 401 + int load_mA = load_uA / 1000; 402 + int max_mA = req->mask >> req->shift; 403 + int ret; 404 + 405 + if (req->mask == 0) 406 + return -EINVAL; 407 + 408 + if (load_mA > max_mA) 409 + load_mA = max_mA; 410 + 411 + mutex_lock(&vreg->lock); 412 + ret = rpm_reg_write(vreg, req, load_mA); 413 + mutex_unlock(&vreg->lock); 414 + 415 + return ret; 416 + } 417 + 396 418 static struct regulator_ops uV_ops = { 397 419 .list_voltage = regulator_list_voltage_linear_range, 398 420 ··· 424 402 .enable = rpm_reg_uV_enable, 425 403 .disable = rpm_reg_uV_disable, 426 404 .is_enabled = rpm_reg_is_enabled, 405 + 406 + .set_load = rpm_reg_set_load, 427 407 }; 428 408 429 409 static struct regulator_ops mV_ops = { ··· 437 413 .enable = rpm_reg_mV_enable, 438 414 .disable = rpm_reg_mV_disable, 439 415 .is_enabled = rpm_reg_is_enabled, 416 + 417 + .set_load = rpm_reg_set_load, 440 418 }; 441 419 442 420 static struct regulator_ops switch_ops = { ··· 731 705 dev_err(&pdev->dev, "no voltage specified for regulator\n"); 732 706 return -EINVAL; 733 707 } 708 + 709 + /* Regulators with ia property suppports drms */ 710 + if (vreg->parts->ia.mask) 711 + initdata->constraints.valid_ops_mask |= REGULATOR_CHANGE_DRMS; 734 712 735 713 key = "bias-pull-down"; 736 714 if (of_property_read_bool(pdev->dev.of_node, key)) {
+1 -11
include/linux/mfd/max77693.h
··· 30 30 #ifndef __LINUX_MFD_MAX77693_H 31 31 #define __LINUX_MFD_MAX77693_H 32 32 33 - /* MAX77686 regulator IDs */ 33 + /* MAX77693 regulator IDs */ 34 34 enum max77693_regulators { 35 35 MAX77693_ESAFEOUT1 = 0, 36 36 MAX77693_ESAFEOUT2, 37 37 MAX77693_CHARGER, 38 38 MAX77693_REG_MAX, 39 - }; 40 - 41 - struct max77693_regulator_data { 42 - int id; 43 - struct regulator_init_data *initdata; 44 - struct device_node *of_node; 45 39 }; 46 40 47 41 struct max77693_reg_data { ··· 97 103 /* MAX77693 */ 98 104 99 105 struct max77693_platform_data { 100 - /* regulator data */ 101 - struct max77693_regulator_data *regulators; 102 - int num_regulators; 103 - 104 106 /* muic data */ 105 107 struct max77693_muic_platform_data *muic_data; 106 108 struct max77693_led_platform_data *led_data;
+3
include/linux/regulator/driver.h
··· 98 98 * REGULATOR_STATUS value (or negative errno) 99 99 * @get_optimum_mode: Get the most efficient operating mode for the regulator 100 100 * when running with the specified parameters. 101 + * @set_load: Set the load for the regulator. 101 102 * 102 103 * @set_bypass: Set the regulator in bypass mode. 103 104 * @get_bypass: Get the regulator bypass mode state. ··· 168 167 /* get most efficient regulator operating mode for load */ 169 168 unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV, 170 169 int output_uV, int load_uA); 170 + /* set the load on the regulator */ 171 + int (*set_load)(struct regulator_dev *, int load_uA); 171 172 172 173 /* control and report on bypass mode */ 173 174 int (*set_bypass)(struct regulator_dev *dev, bool enable);