Merge remote-tracking branches 'regulator/topic/dbx500', 'regulator/topic/load-op', 'regulator/topic/max77693' and 'regulator/topic/max8660' into regulator-next
···648648 if (err < 0)649649 return 0;650650651651- if (!rdev->desc->ops->get_optimum_mode)651651+ if (!rdev->desc->ops->get_optimum_mode &&652652+ !rdev->desc->ops->set_load)652653 return 0;653654654654- if (!rdev->desc->ops->set_mode)655655+ if (!rdev->desc->ops->set_mode &&656656+ !rdev->desc->ops->set_load)655657 return -EINVAL;656658657659 /* get output voltage */···678676 list_for_each_entry(sibling, &rdev->consumer_list, list)679677 current_uA += sibling->uA_load;680678681681- /* now get the optimum mode for our new total regulator load */682682- mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV,683683- output_uV, current_uA);679679+ if (rdev->desc->ops->set_load) {680680+ /* set the optimum mode for our new total regulator load */681681+ err = rdev->desc->ops->set_load(rdev, current_uA);682682+ if (err < 0)683683+ rdev_err(rdev, "failed to set load %d\n", current_uA);684684+ } else {685685+ /* now get the optimum mode for our new total regulator load */686686+ mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV,687687+ output_uV, current_uA);684688685685- /* check the new mode is allowed */686686- err = regulator_mode_constrain(rdev, &mode);687687- if (err < 0) {688688- rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n",689689- current_uA, input_uV, output_uV);690690- return err;689689+ /* check the new mode is allowed */690690+ err = regulator_mode_constrain(rdev, &mode);691691+ if (err < 0) {692692+ rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n",693693+ current_uA, input_uV, output_uV);694694+ return err;695695+ }696696+697697+ err = rdev->desc->ops->set_mode(rdev, mode);698698+ if (err < 0)699699+ rdev_err(rdev, "failed to set optimum mode %x\n", mode);691700 }692692-693693- err = rdev->desc->ops->set_mode(rdev, mode);694694- if (err < 0)695695- rdev_err(rdev, "failed to set optimum mode %x\n", mode);696701697702 return err;698703}
+9-23
drivers/regulator/dbx500-prcmu.c
···95959696static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p)9797{9898- struct device *dev = s->private;9999- int err;100100-10198 /* print power state count */102102- err = seq_printf(s, "ux500-regulator power state count: %i\n",103103- power_state_active_get());104104- if (err < 0)105105- dev_err(dev, "seq_printf overflow\n");9999+ seq_printf(s, "ux500-regulator power state count: %i\n",100100+ power_state_active_get());106101107102 return 0;108103}···119124120125static int ux500_regulator_status_print(struct seq_file *s, void *p)121126{122122- struct device *dev = s->private;123123- int err;124127 int i;125128126129 /* print dump header */127127- err = seq_puts(s, "ux500-regulator status:\n");128128- if (err < 0)129129- dev_err(dev, "seq_puts overflow\n");130130-131131- err = seq_printf(s, "%31s : %8s : %8s\n", "current",132132- "before", "after");133133- if (err < 0)134134- dev_err(dev, "seq_printf overflow\n");130130+ seq_puts(s, "ux500-regulator status:\n");131131+ seq_printf(s, "%31s : %8s : %8s\n", "current", "before", "after");135132136133 for (i = 0; i < rdebug.num_regulators; i++) {137134 struct dbx500_regulator_info *info;···131144 info = &rdebug.regulator_array[i];132145133146 /* print status */134134- err = seq_printf(s, "%20s : %8s : %8s : %8s\n", info->desc.name,135135- info->is_enabled ? "enabled" : "disabled",136136- rdebug.state_before_suspend[i] ? "enabled" : "disabled",137137- rdebug.state_after_suspend[i] ? "enabled" : "disabled");138138- if (err < 0)139139- dev_err(dev, "seq_printf overflow\n");147147+ seq_printf(s, "%20s : %8s : %8s : %8s\n",148148+ info->desc.name,149149+ info->is_enabled ? "enabled" : "disabled",150150+ rdebug.state_before_suspend[i] ? "enabled" : "disabled",151151+ rdebug.state_after_suspend[i] ? "enabled" : "disabled");140152 }141153142154 return 0;
+9-84
drivers/regulator/max77693.c
···128128#define regulator_desc_esafeout(_num) { \129129 .name = "ESAFEOUT"#_num, \130130 .id = MAX77693_ESAFEOUT##_num, \131131+ .of_match = of_match_ptr("ESAFEOUT"#_num), \132132+ .regulators_node = of_match_ptr("regulators"), \131133 .n_voltages = 4, \132134 .ops = &max77693_safeout_ops, \133135 .type = REGULATOR_VOLTAGE, \···147145 {148146 .name = "CHARGER",149147 .id = MAX77693_CHARGER,148148+ .of_match = of_match_ptr("CHARGER"),149149+ .regulators_node = of_match_ptr("regulators"),150150 .ops = &max77693_charger_ops,151151 .type = REGULATOR_CURRENT,152152 .owner = THIS_MODULE,···158154 },159155};160156161161-#ifdef CONFIG_OF162162-static int max77693_pmic_dt_parse_rdata(struct device *dev,163163- struct max77693_regulator_data **rdata)164164-{165165- struct device_node *np;166166- struct of_regulator_match *rmatch;167167- struct max77693_regulator_data *tmp;168168- int i, matched = 0;169169-170170- np = of_get_child_by_name(dev->parent->of_node, "regulators");171171- if (!np)172172- return -EINVAL;173173-174174- rmatch = devm_kzalloc(dev,175175- sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL);176176- if (!rmatch) {177177- of_node_put(np);178178- return -ENOMEM;179179- }180180-181181- for (i = 0; i < ARRAY_SIZE(regulators); i++)182182- rmatch[i].name = regulators[i].name;183183-184184- matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators));185185- of_node_put(np);186186- if (matched <= 0)187187- return matched;188188- *rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL);189189- if (!(*rdata))190190- return -ENOMEM;191191-192192- tmp = *rdata;193193-194194- for (i = 0; i < matched; i++) {195195- tmp->initdata = rmatch[i].init_data;196196- tmp->of_node = rmatch[i].of_node;197197- tmp->id = regulators[i].id;198198- tmp++;199199- }200200-201201- return matched;202202-}203203-#else204204-static int max77693_pmic_dt_parse_rdata(struct device *dev,205205- struct max77693_regulator_data **rdata)206206-{207207- return 0;208208-}209209-#endif /* CONFIG_OF */210210-211211-static int max77693_pmic_init_rdata(struct device *dev,212212- struct max77693_regulator_data **rdata)213213-{214214- struct max77693_platform_data *pdata;215215- int num_regulators = 0;216216-217217- pdata = dev_get_platdata(dev->parent);218218- if (pdata) {219219- *rdata = pdata->regulators;220220- num_regulators = pdata->num_regulators;221221- }222222-223223- if (!(*rdata) && dev->parent->of_node)224224- num_regulators = max77693_pmic_dt_parse_rdata(dev, rdata);225225-226226- return num_regulators;227227-}228228-229157static int max77693_pmic_probe(struct platform_device *pdev)230158{231159 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);232232- struct max77693_regulator_data *rdata = NULL;233233- int num_rdata, i;160160+ int i;234161 struct regulator_config config = { };235162236236- num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata);237237- if (!rdata || num_rdata <= 0) {238238- dev_err(&pdev->dev, "No init data supplied.\n");239239- return -ENODEV;240240- }241241-242242- config.dev = &pdev->dev;163163+ config.dev = iodev->dev;243164 config.regmap = iodev->regmap;244165245245- for (i = 0; i < num_rdata; i++) {246246- int id = rdata[i].id;166166+ for (i = 0; i < ARRAY_SIZE(regulators); i++) {247167 struct regulator_dev *rdev;248168249249- config.init_data = rdata[i].initdata;250250- config.of_node = rdata[i].of_node;251251-252169 rdev = devm_regulator_register(&pdev->dev,253253- ®ulators[id], &config);170170+ ®ulators[i], &config);254171 if (IS_ERR(rdev)) {255172 dev_err(&pdev->dev,256256- "Failed to initialize regulator-%d\n", id);173173+ "Failed to initialize regulator-%d\n", i);257174 return PTR_ERR(rdev);258175 }259176 }
+4-5
drivers/regulator/max8660.c
···382382 const struct i2c_device_id *i2c_id)383383{384384 struct device *dev = &client->dev;385385- struct max8660_platform_data *pdata = dev_get_platdata(dev);385385+ struct max8660_platform_data pdata_of, *pdata = dev_get_platdata(dev);386386 struct regulator_config config = { };387387 struct max8660 *max8660;388388 int boot_on, i, id, ret = -EINVAL;···391391392392 if (dev->of_node && !pdata) {393393 const struct of_device_id *id;394394- struct max8660_platform_data pdata_of;395394396395 id = of_match_device(of_match_ptr(max8660_dt_ids), dev);397396 if (!id)···442443 for (i = 0; i < pdata->num_subdevs; i++) {443444444445 if (!pdata->subdevs[i].platform_data)445445- return ret;446446-447447- boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;446446+ boot_on = false;447447+ else448448+ boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;448449449450 switch (pdata->subdevs[i].id) {450451 case MAX8660_V3:
+30
drivers/regulator/qcom_rpm-regulator.c
···393393 return vreg->is_enabled;394394}395395396396+static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA)397397+{398398+ struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev);399399+ const struct rpm_reg_parts *parts = vreg->parts;400400+ const struct request_member *req = &parts->ia;401401+ int load_mA = load_uA / 1000;402402+ int max_mA = req->mask >> req->shift;403403+ int ret;404404+405405+ if (req->mask == 0)406406+ return -EINVAL;407407+408408+ if (load_mA > max_mA)409409+ load_mA = max_mA;410410+411411+ mutex_lock(&vreg->lock);412412+ ret = rpm_reg_write(vreg, req, load_mA);413413+ mutex_unlock(&vreg->lock);414414+415415+ return ret;416416+}417417+396418static struct regulator_ops uV_ops = {397419 .list_voltage = regulator_list_voltage_linear_range,398420···424402 .enable = rpm_reg_uV_enable,425403 .disable = rpm_reg_uV_disable,426404 .is_enabled = rpm_reg_is_enabled,405405+406406+ .set_load = rpm_reg_set_load,427407};428408429409static struct regulator_ops mV_ops = {···437413 .enable = rpm_reg_mV_enable,438414 .disable = rpm_reg_mV_disable,439415 .is_enabled = rpm_reg_is_enabled,416416+417417+ .set_load = rpm_reg_set_load,440418};441419442420static struct regulator_ops switch_ops = {···731705 dev_err(&pdev->dev, "no voltage specified for regulator\n");732706 return -EINVAL;733707 }708708+709709+ /* Regulators with ia property suppports drms */710710+ if (vreg->parts->ia.mask)711711+ initdata->constraints.valid_ops_mask |= REGULATOR_CHANGE_DRMS;734712735713 key = "bias-pull-down";736714 if (of_property_read_bool(pdev->dev.of_node, key)) {
···9898 * REGULATOR_STATUS value (or negative errno)9999 * @get_optimum_mode: Get the most efficient operating mode for the regulator100100 * when running with the specified parameters.101101+ * @set_load: Set the load for the regulator.101102 *102103 * @set_bypass: Set the regulator in bypass mode.103104 * @get_bypass: Get the regulator bypass mode state.···168167 /* get most efficient regulator operating mode for load */169168 unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,170169 int output_uV, int load_uA);170170+ /* set the load on the regulator */171171+ int (*set_load)(struct regulator_dev *, int load_uA);171172172173 /* control and report on bypass mode */173174 int (*set_bypass)(struct regulator_dev *dev, bool enable);