···1111Drivers can register a regulator by calling :-12121313struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,1414- struct device *dev, struct regulator_init_data *init_data,1515- void *driver_data, struct device_node *of_node);1414+ const struct regulator_config *config);16151716This will register the regulators capabilities and operations to the regulator1817core.
···223223 Say Y here to support the voltage regulators and convertors224224 on PCF50633225225226226+config REGULATOR_RC5T583227227+ tristate "RICOH RC5T583 Power regulators"228228+ depends on MFD_RC5T583229229+ help230230+ Select this option to enable the power regulator of RICOH231231+ PMIC RC5T583.232232+ This driver supports the control of different power rails of device233233+ through regulator interface. The device supports multiple DCDC/LDO234234+ outputs which can be controlled by i2c communication.235235+226236config REGULATOR_S5M8767227237 tristate "Samsung S5M8767A voltage regulator"228238 depends on MFD_S5M_CORE···278268 audio amplifiers.279269280270config REGULATOR_TPS62360281281- tristate "TI TPS62360 Power Regulator"271271+ tristate "TI TPS6236x Power Regulator"282272 depends on I2C283273 select REGMAP_I2C284274 help285285- This driver supports TPS62360 voltage regulator chip. This275275+ This driver supports TPS6236x voltage regulator chip. This286276 regulator is meant for processor core supply. This chip is287277 high-frequency synchronous step down dc-dc converter optimized288278 for battery-powered portable applications.···303293 This driver supports TPS6507X voltage regulator chips. TPS6507X provides304294 three step-down converters and two general-purpose LDO voltage regulators.305295 It supports TI's software based Class-2 SmartReflex implementation.296296+297297+config REGULATOR_TPS65090298298+ tristate "TI TPS65090 Power regulator"299299+ depends on MFD_TPS65090300300+ help301301+ This driver provides support for the voltage regulators on the302302+ TI TPS65090 PMIC.306303307304config REGULATOR_TPS65217308305 tristate "TI TPS65217 Power regulators"
···2424#include <linux/suspend.h>2525#include <linux/delay.h>2626#include <linux/of.h>2727+#include <linux/regmap.h>2728#include <linux/regulator/of_regulator.h>2829#include <linux/regulator/consumer.h>2930#include <linux/regulator/driver.h>···7574struct regulator {7675 struct device *dev;7776 struct list_head list;7777+ unsigned int always_on:1;7878 int uA_load;7979 int min_uV;8080 int max_uV;···155153 return NULL;156154 }157155 return regnode;156156+}157157+158158+static int _regulator_can_change_status(struct regulator_dev *rdev)159159+{160160+ if (!rdev->constraints)161161+ return 0;162162+163163+ if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_STATUS)164164+ return 1;165165+ else166166+ return 0;158167}159168160169/* Platform voltage constraint check */···662649 /* get input voltage */663650 input_uV = 0;664651 if (rdev->supply)665665- input_uV = _regulator_get_voltage(rdev);652652+ input_uV = regulator_get_voltage(rdev->supply);666653 if (input_uV <= 0)667654 input_uV = rdev->constraints->input_uV;668655 if (input_uV <= 0)···686673 struct regulator_state *rstate)687674{688675 int ret = 0;689689- bool can_set_state;690690-691691- can_set_state = rdev->desc->ops->set_suspend_enable &&692692- rdev->desc->ops->set_suspend_disable;693676694677 /* If we have no suspend mode configration don't set anything;695695- * only warn if the driver actually makes the suspend mode696696- * configurable.678678+ * only warn if the driver implements set_suspend_voltage or679679+ * set_suspend_mode callback.697680 */698681 if (!rstate->enabled && !rstate->disabled) {699699- if (can_set_state)682682+ if (rdev->desc->ops->set_suspend_voltage ||683683+ rdev->desc->ops->set_suspend_mode)700684 rdev_warn(rdev, "No configuration\n");701685 return 0;702686 }···703693 return -EINVAL;704694 }705695706706- if (!can_set_state) {707707- rdev_err(rdev, "no way to set suspend state\n");708708- return -EINVAL;709709- }710710-711711- if (rstate->enabled)696696+ if (rstate->enabled && rdev->desc->ops->set_suspend_enable)712697 ret = rdev->desc->ops->set_suspend_enable(rdev);713713- else698698+ else if (rstate->disabled && rdev->desc->ops->set_suspend_disable)714699 ret = rdev->desc->ops->set_suspend_disable(rdev);700700+ else /* OK if set_suspend_enable or set_suspend_disable is NULL */701701+ ret = 0;702702+715703 if (ret < 0) {716704 rdev_err(rdev, "failed to enabled/disable\n");717705 return ret;···11541146 ®ulator->max_uV);11551147 }1156114811491149+ /*11501150+ * Check now if the regulator is an always on regulator - if11511151+ * it is then we don't need to do nearly so much work for11521152+ * enable/disable calls.11531153+ */11541154+ if (!_regulator_can_change_status(rdev) &&11551155+ _regulator_is_enabled(rdev))11561156+ regulator->always_on = true;11571157+11571158 mutex_unlock(&rdev->mutex);11581159 return regulator;11591160link_name_err:···11861169}1187117011881171static struct regulator_dev *regulator_dev_lookup(struct device *dev,11891189- const char *supply)11721172+ const char *supply,11731173+ int *ret)11901174{11911175 struct regulator_dev *r;11921176 struct device_node *node;11771177+ struct regulator_map *map;11781178+ const char *devname = NULL;1193117911941180 /* first do a dt based lookup */11951181 if (dev && dev->of_node) {11961182 node = of_get_regulator(dev, supply);11971197- if (node)11831183+ if (node) {11981184 list_for_each_entry(r, ®ulator_list, list)11991185 if (r->dev.parent &&12001186 node == r->dev.of_node)12011187 return r;11881188+ } else {11891189+ /*11901190+ * If we couldn't even get the node then it's11911191+ * not just that the device didn't register11921192+ * yet, there's no node and we'll never11931193+ * succeed.11941194+ */11951195+ *ret = -ENODEV;11961196+ }12021197 }1203119812041199 /* if not found, try doing it non-dt way */12001200+ if (dev)12011201+ devname = dev_name(dev);12021202+12051203 list_for_each_entry(r, ®ulator_list, list)12061204 if (strcmp(rdev_get_name(r), supply) == 0)12071205 return r;12061206+12071207+ list_for_each_entry(map, ®ulator_map_list, list) {12081208+ /* If the mapping has a device set up it must match */12091209+ if (map->dev_name &&12101210+ (!devname || strcmp(map->dev_name, devname)))12111211+ continue;12121212+12131213+ if (strcmp(map->supply, supply) == 0)12141214+ return map->regulator;12151215+ }12161216+1208121712091218 return NULL;12101219}···12401197 int exclusive)12411198{12421199 struct regulator_dev *rdev;12431243- struct regulator_map *map;12441200 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);12451201 const char *devname = NULL;12461202 int ret;···1254121212551213 mutex_lock(®ulator_list_mutex);1256121412571257- rdev = regulator_dev_lookup(dev, id);12151215+ rdev = regulator_dev_lookup(dev, id, &ret);12581216 if (rdev)12591217 goto found;12601260-12611261- list_for_each_entry(map, ®ulator_map_list, list) {12621262- /* If the mapping has a device set up it must match */12631263- if (map->dev_name &&12641264- (!devname || strcmp(map->dev_name, devname)))12651265- continue;12661266-12671267- if (strcmp(map->supply, id) == 0) {12681268- rdev = map->regulator;12691269- goto found;12701270- }12711271- }1272121812731219 if (board_wants_dummy_regulator) {12741220 rdev = dummy_regulator_rdev;···14651435}14661436EXPORT_SYMBOL_GPL(devm_regulator_put);1467143714681468-static int _regulator_can_change_status(struct regulator_dev *rdev)14691469-{14701470- if (!rdev->constraints)14711471- return 0;14721472-14731473- if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_STATUS)14741474- return 1;14751475- else14761476- return 0;14771477-}14781478-14791438/* locks held by regulator_enable() */14801439static int _regulator_enable(struct regulator_dev *rdev)14811440{···15441525 struct regulator_dev *rdev = regulator->rdev;15451526 int ret = 0;1546152715281528+ if (regulator->always_on)15291529+ return 0;15301530+15471531 if (rdev->supply) {15481532 ret = regulator_enable(rdev->supply);15491533 if (ret != 0)···16241602{16251603 struct regulator_dev *rdev = regulator->rdev;16261604 int ret = 0;16051605+16061606+ if (regulator->always_on)16071607+ return 0;1627160816281609 mutex_lock(&rdev->mutex);16291610 ret = _regulator_disable(rdev);···17361711 struct regulator_dev *rdev = regulator->rdev;17371712 int ret;1738171317141714+ if (regulator->always_on)17151715+ return 0;17161716+17391717 mutex_lock(&rdev->mutex);17401718 rdev->deferred_disables++;17411719 mutex_unlock(&rdev->mutex);···17511723 return 0;17521724}17531725EXPORT_SYMBOL_GPL(regulator_disable_deferred);17261726+17271727+/**17281728+ * regulator_is_enabled_regmap - standard is_enabled() for regmap users17291729+ *17301730+ * @rdev: regulator to operate on17311731+ *17321732+ * Regulators that use regmap for their register I/O can set the17331733+ * enable_reg and enable_mask fields in their descriptor and then use17341734+ * this as their is_enabled operation, saving some code.17351735+ */17361736+int regulator_is_enabled_regmap(struct regulator_dev *rdev)17371737+{17381738+ unsigned int val;17391739+ int ret;17401740+17411741+ ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);17421742+ if (ret != 0)17431743+ return ret;17441744+17451745+ return (val & rdev->desc->enable_mask) != 0;17461746+}17471747+EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);17481748+17491749+/**17501750+ * regulator_enable_regmap - standard enable() for regmap users17511751+ *17521752+ * @rdev: regulator to operate on17531753+ *17541754+ * Regulators that use regmap for their register I/O can set the17551755+ * enable_reg and enable_mask fields in their descriptor and then use17561756+ * this as their enable() operation, saving some code.17571757+ */17581758+int regulator_enable_regmap(struct regulator_dev *rdev)17591759+{17601760+ return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,17611761+ rdev->desc->enable_mask,17621762+ rdev->desc->enable_mask);17631763+}17641764+EXPORT_SYMBOL_GPL(regulator_enable_regmap);17651765+17661766+/**17671767+ * regulator_disable_regmap - standard disable() for regmap users17681768+ *17691769+ * @rdev: regulator to operate on17701770+ *17711771+ * Regulators that use regmap for their register I/O can set the17721772+ * enable_reg and enable_mask fields in their descriptor and then use17731773+ * this as their disable() operation, saving some code.17741774+ */17751775+int regulator_disable_regmap(struct regulator_dev *rdev)17761776+{17771777+ return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,17781778+ rdev->desc->enable_mask, 0);17791779+}17801780+EXPORT_SYMBOL_GPL(regulator_disable_regmap);1754178117551782static int _regulator_is_enabled(struct regulator_dev *rdev)17561783{···18311748int regulator_is_enabled(struct regulator *regulator)18321749{18331750 int ret;17511751+17521752+ if (regulator->always_on)17531753+ return 1;1834175418351755 mutex_lock(®ulator->rdev->mutex);18361756 ret = _regulator_is_enabled(regulator->rdev);···19231837}19241838EXPORT_SYMBOL_GPL(regulator_is_supported_voltage);1925183918401840+/**18411841+ * regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users18421842+ *18431843+ * @rdev: regulator to operate on18441844+ *18451845+ * Regulators that use regmap for their register I/O can set the18461846+ * vsel_reg and vsel_mask fields in their descriptor and then use this18471847+ * as their get_voltage_vsel operation, saving some code.18481848+ */18491849+int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev)18501850+{18511851+ unsigned int val;18521852+ int ret;18531853+18541854+ ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);18551855+ if (ret != 0)18561856+ return ret;18571857+18581858+ val &= rdev->desc->vsel_mask;18591859+ val >>= ffs(rdev->desc->vsel_mask) - 1;18601860+18611861+ return val;18621862+}18631863+EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_regmap);18641864+18651865+/**18661866+ * regulator_set_voltage_sel_regmap - standard set_voltage_sel for regmap users18671867+ *18681868+ * @rdev: regulator to operate on18691869+ * @sel: Selector to set18701870+ *18711871+ * Regulators that use regmap for their register I/O can set the18721872+ * vsel_reg and vsel_mask fields in their descriptor and then use this18731873+ * as their set_voltage_vsel operation, saving some code.18741874+ */18751875+int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel)18761876+{18771877+ sel <<= ffs(rdev->desc->vsel_mask) - 1;18781878+18791879+ return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,18801880+ rdev->desc->vsel_mask, sel);18811881+}18821882+EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_regmap);18831883+19261884static int _regulator_do_set_voltage(struct regulator_dev *rdev,19271885 int min_uV, int max_uV)19281886{19291887 int ret;19301888 int delay = 0;19311889 unsigned int selector;18901890+ int old_selector = -1;18911891+ int best_val = INT_MAX;1932189219331893 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV);1934189419351895 min_uV += rdev->constraints->uV_offset;19361896 max_uV += rdev->constraints->uV_offset;1937189718981898+ /*18991899+ * If we can't obtain the old selector there is not enough19001900+ * info to call set_voltage_time_sel().19011901+ */19021902+ if (rdev->desc->ops->set_voltage_time_sel &&19031903+ rdev->desc->ops->get_voltage_sel) {19041904+ old_selector = rdev->desc->ops->get_voltage_sel(rdev);19051905+ if (old_selector < 0)19061906+ return old_selector;19071907+ }19081908+19381909 if (rdev->desc->ops->set_voltage) {19391910 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,19401911 &selector);1941191219421913 if (rdev->desc->ops->list_voltage)19431943- selector = rdev->desc->ops->list_voltage(rdev,19141914+ best_val = rdev->desc->ops->list_voltage(rdev,19441915 selector);19451916 else19461946- selector = -1;19171917+ best_val = -1;19471918 } else if (rdev->desc->ops->set_voltage_sel) {19481948- int best_val = INT_MAX;19491919 int i;1950192019511921 selector = 0;···20201878 }20211879 }2022188020232023- /*20242024- * If we can't obtain the old selector there is not enough20252025- * info to call set_voltage_time_sel().20262026- */20272027- if (rdev->desc->ops->set_voltage_time_sel &&20282028- rdev->desc->ops->get_voltage_sel) {20292029- unsigned int old_selector = 0;20302030-20312031- ret = rdev->desc->ops->get_voltage_sel(rdev);20322032- if (ret < 0)20332033- return ret;20342034- old_selector = ret;20352035- ret = rdev->desc->ops->set_voltage_time_sel(rdev,20362036- old_selector, selector);20372037- if (ret < 0)20382038- rdev_warn(rdev, "set_voltage_time_sel() failed: %d\n", ret);20392039- else20402040- delay = ret;20412041- }20422042-20432043- if (best_val != INT_MAX) {18811881+ if (best_val != INT_MAX)20441882 ret = rdev->desc->ops->set_voltage_sel(rdev, selector);20452045- selector = best_val;20462046- } else {18831883+ else20471884 ret = -EINVAL;20482048- }20491885 } else {20501886 ret = -EINVAL;18871887+ }18881888+18891889+ /* Call set_voltage_time_sel if successfully obtained old_selector */18901890+ if (ret == 0 && old_selector >= 0 &&18911891+ rdev->desc->ops->set_voltage_time_sel) {18921892+18931893+ delay = rdev->desc->ops->set_voltage_time_sel(rdev,18941894+ old_selector, selector);18951895+ if (delay < 0) {18961896+ rdev_warn(rdev, "set_voltage_time_sel() failed: %d\n",18971897+ delay);18981898+ delay = 0;18991899+ }20511900 }2052190120531902 /* Insert any necessary delays */···20531920 _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,20541921 NULL);2055192220562056- trace_regulator_set_voltage_complete(rdev_get_name(rdev), selector);19231923+ trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val);2057192420581925 return ret;20591926}···24572324 */24582325 ret = -EINVAL;2459232623272327+ if (!rdev->desc->ops->set_mode)23282328+ goto out;23292329+24602330 /* get output voltage */24612331 output_uV = _regulator_get_voltage(rdev);24622332 if (output_uV <= 0) {···26612525 int i;26622526 int ret = 0;2663252726642664- for (i = 0; i < num_consumers; i++)26652665- async_schedule_domain(regulator_bulk_enable_async,26662666- &consumers[i], &async_domain);25282528+ for (i = 0; i < num_consumers; i++) {25292529+ if (consumers[i].consumer->always_on)25302530+ consumers[i].ret = 0;25312531+ else25322532+ async_schedule_domain(regulator_bulk_enable_async,25332533+ &consumers[i], &async_domain);25342534+ }2667253526682536 async_synchronize_full_domain(&async_domain);26692537···27062566 struct regulator_bulk_data *consumers)27072567{27082568 int i;27092709- int ret;25692569+ int ret, r;2710257027112571 for (i = num_consumers - 1; i >= 0; --i) {27122572 ret = regulator_disable(consumers[i].consumer);···2718257827192579err:27202580 pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret);27212721- for (++i; i < num_consumers; ++i)27222722- regulator_enable(consumers[i].consumer);25812581+ for (++i; i < num_consumers; ++i) {25822582+ r = regulator_enable(consumers[i].consumer);25832583+ if (r != 0)25842584+ pr_err("Failed to reename %s: %d\n",25852585+ consumers[i].supply, r);25862586+ }2723258727242588 return ret;27252589}···29002756 return status;29012757 }2902275829032903- /* suspend mode constraints need multiple supporting methods */29042904- if (!(ops->set_suspend_enable && ops->set_suspend_disable))29052905- return status;29062906-29072759 status = device_create_file(dev, &dev_attr_suspend_standby_state);29082760 if (status < 0)29092761 return status;···29602820/**29612821 * regulator_register - register regulator29622822 * @regulator_desc: regulator to register29632963- * @dev: struct device for the regulator29642964- * @init_data: platform provided init data, passed through by driver29652965- * @driver_data: private regulator data29662966- * @of_node: OpenFirmware node to parse for device tree bindings (may be29672967- * NULL).28232823+ * @config: runtime configuration for regulator29682824 *29692825 * Called by regulator drivers to register a regulator.29702826 * Returns 0 on success.29712827 */29722972-struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,29732973- struct device *dev, const struct regulator_init_data *init_data,29742974- void *driver_data, struct device_node *of_node)28282828+struct regulator_dev *28292829+regulator_register(const struct regulator_desc *regulator_desc,28302830+ const struct regulator_config *config)29752831{29762832 const struct regulation_constraints *constraints = NULL;28332833+ const struct regulator_init_data *init_data;29772834 static atomic_t regulator_no = ATOMIC_INIT(0);29782835 struct regulator_dev *rdev;28362836+ struct device *dev;29792837 int ret, i;29802838 const char *supply = NULL;2981283929822982- if (regulator_desc == NULL)28402840+ if (regulator_desc == NULL || config == NULL)29832841 return ERR_PTR(-EINVAL);28422842+28432843+ dev = config->dev;28442844+ WARN_ON(!dev);2984284529852846 if (regulator_desc->name == NULL || regulator_desc->ops == NULL)29862847 return ERR_PTR(-EINVAL);···30062865 return ERR_PTR(-EINVAL);30072866 }3008286728682868+ init_data = config->init_data;28692869+30092870 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);30102871 if (rdev == NULL)30112872 return ERR_PTR(-ENOMEM);···30152872 mutex_lock(®ulator_list_mutex);3016287330172874 mutex_init(&rdev->mutex);30183018- rdev->reg_data = driver_data;28752875+ rdev->reg_data = config->driver_data;30192876 rdev->owner = regulator_desc->owner;30202877 rdev->desc = regulator_desc;28782878+ rdev->regmap = config->regmap;30212879 INIT_LIST_HEAD(&rdev->consumer_list);30222880 INIT_LIST_HEAD(&rdev->list);30232881 BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier);···3033288930342890 /* register with sysfs */30352891 rdev->dev.class = ®ulator_class;30363036- rdev->dev.of_node = of_node;28922892+ rdev->dev.of_node = config->of_node;30372893 rdev->dev.parent = dev;30382894 dev_set_name(&rdev->dev, "regulator.%d",30392895 atomic_inc_return(®ulator_no) - 1);···30662922 if (supply) {30672923 struct regulator_dev *r;3068292430693069- r = regulator_dev_lookup(dev, supply);29252925+ r = regulator_dev_lookup(dev, supply, &ret);3070292630712927 if (!r) {30722928 dev_err(dev, "Failed to find supply %s\n", supply);
···277277 return 0;278278}279279280280-static int max8998_get_voltage(struct regulator_dev *rdev)280280+static int max8998_get_voltage_sel(struct regulator_dev *rdev)281281{282282 struct max8998_data *max8998 = rdev_get_drvdata(rdev);283283 struct i2c_client *i2c = max8998->iodev->i2c;···295295 val >>= shift;296296 val &= mask;297297298298- return max8998_list_voltage(rdev, val);298298+ return val;299299}300300301301static int max8998_set_voltage_ldo(struct regulator_dev *rdev,···306306 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;307307 const struct voltage_map_desc *desc;308308 int ldo = rdev_get_id(rdev);309309- int reg, shift = 0, mask, ret;310310- int i = 0;309309+ int reg, shift = 0, mask, ret, i;311310312311 if (ldo >= ARRAY_SIZE(ldo_voltage_map))313312 return -EINVAL;···318319 if (max_vol < desc->min || min_vol > desc->max)319320 return -EINVAL;320321321321- while (desc->min + desc->step*i < min_vol &&322322- desc->min + desc->step*i < desc->max)323323- i++;322322+ if (min_vol < desc->min)323323+ min_vol = desc->min;324324+325325+ i = DIV_ROUND_UP(min_vol - desc->min, desc->step);324326325327 if (desc->min + desc->step*i > max_vol)326328 return -EINVAL;···359359 const struct voltage_map_desc *desc;360360 int buck = rdev_get_id(rdev);361361 int reg, shift = 0, mask, ret;362362- int difference = 0, i = 0, j = 0, previous_vol = 0;363363- u8 val = 0;362362+ int i, j, previous_sel;364363 static u8 buck1_last_val;365364366365 if (buck >= ARRAY_SIZE(ldo_voltage_map))···373374 if (max_vol < desc->min || min_vol > desc->max)374375 return -EINVAL;375376376376- while (desc->min + desc->step*i < min_vol &&377377- desc->min + desc->step*i < desc->max)378378- i++;377377+ if (min_vol < desc->min)378378+ min_vol = desc->min;379379+380380+ i = DIV_ROUND_UP(min_vol - desc->min, desc->step);379381380382 if (desc->min + desc->step*i > max_vol)381383 return -EINVAL;···387387 if (ret)388388 return ret;389389390390- previous_vol = max8998_get_voltage(rdev);390390+ previous_sel = max8998_get_voltage_sel(rdev);391391392392 /* Check if voltage needs to be changed */393393 /* if previous_voltage equal new voltage, return */394394- if (previous_vol == max8998_list_voltage(rdev, i)) {394394+ if (previous_sel == i) {395395 dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n",396396- previous_vol, max8998_list_voltage(rdev, i));396396+ max8998_list_voltage(rdev, previous_sel),397397+ max8998_list_voltage(rdev, i));397398 return ret;398399 }399400···483482 break;484483 }485484485485+ return ret;486486+}487487+488488+static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,489489+ unsigned int old_selector,490490+ unsigned int new_selector)491491+{492492+ struct max8998_data *max8998 = rdev_get_drvdata(rdev);493493+ struct i2c_client *i2c = max8998->iodev->i2c;494494+ const struct voltage_map_desc *desc;495495+ int buck = rdev_get_id(rdev);496496+ u8 val = 0;497497+ int difference, ret;498498+499499+ if (buck < MAX8998_BUCK1 || buck > MAX8998_BUCK4)500500+ return -EINVAL;501501+502502+ desc = ldo_voltage_map[buck];503503+486504 /* Voltage stabilization */487487- max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val);505505+ ret = max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val);506506+ if (ret)507507+ return ret;488508489509 /* lp3974 hasn't got ENRAMP bit - ramp is assumed as true */490510 /* MAX8998 has ENRAMP bit implemented, so test it*/491511 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))492492- return ret;512512+ return 0;493513494494- difference = desc->min + desc->step*i - previous_vol/1000;514514+ difference = (new_selector - old_selector) * desc->step;495515 if (difference > 0)496496- udelay(difference / ((val & 0x0f) + 1));516516+ return difference / ((val & 0x0f) + 1);497517498498- return ret;518518+ return 0;499519}500520501521static struct regulator_ops max8998_ldo_ops = {···524502 .is_enabled = max8998_ldo_is_enabled,525503 .enable = max8998_ldo_enable,526504 .disable = max8998_ldo_disable,527527- .get_voltage = max8998_get_voltage,505505+ .get_voltage_sel = max8998_get_voltage_sel,528506 .set_voltage = max8998_set_voltage_ldo,529507 .set_suspend_enable = max8998_ldo_enable,530508 .set_suspend_disable = max8998_ldo_disable,···535513 .is_enabled = max8998_ldo_is_enabled,536514 .enable = max8998_ldo_enable,537515 .disable = max8998_ldo_disable,538538- .get_voltage = max8998_get_voltage,516516+ .get_voltage_sel = max8998_get_voltage_sel,539517 .set_voltage = max8998_set_voltage_buck,518518+ .set_voltage_time_sel = max8998_set_voltage_buck_time_sel,540519 .set_suspend_enable = max8998_ldo_enable,541520 .set_suspend_disable = max8998_ldo_disable,542521};···708685{709686 struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);710687 struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev);688688+ struct regulator_config config = { };711689 struct regulator_dev **rdev;712690 struct max8998_data *max8998;713691 struct i2c_client *i2c;···864840 int count = (desc->max - desc->min) / desc->step + 1;865841 regulators[index].n_voltages = count;866842 }867867- rdev[i] = regulator_register(®ulators[index], max8998->dev,868868- pdata->regulators[i].initdata, max8998, NULL);843843+844844+ config.dev = max8998->dev;845845+ config.init_data = pdata->regulators[i].initdata;846846+ config.driver_data = max8998;847847+848848+ rdev[i] = regulator_register(®ulators[index], &config);869849 if (IS_ERR(rdev[i])) {870850 ret = PTR_ERR(rdev[i]);871851 dev_err(max8998->dev, "regulator init failed\n");
+10-4
drivers/regulator/mc13783-regulator.c
···340340 struct mc13xxx_regulator_platform_data *pdata =341341 dev_get_platdata(&pdev->dev);342342 struct mc13xxx_regulator_init_data *init_data;343343+ struct regulator_config config = { };343344 int i, ret;344345345346 dev_dbg(&pdev->dev, "%s id %d\n", __func__, pdev->id);···358357 priv->mc13xxx = mc13783;359358360359 for (i = 0; i < pdata->num_regulators; i++) {361361- init_data = &pdata->regulators[i];362362- priv->regulators[i] = regulator_register(363363- &mc13783_regulators[init_data->id].desc,364364- &pdev->dev, init_data->init_data, priv, NULL);360360+ struct regulator_desc *desc;365361362362+ init_data = &pdata->regulators[i];363363+ desc = &mc13783_regulators[init_data->id].desc;364364+365365+ config.dev = &pdev->dev;366366+ config.init_data = init_data->init_data;367367+ config.driver_data = priv;368368+369369+ priv->regulators[i] = regulator_register(desc, &config);366370 if (IS_ERR(priv->regulators[i])) {367371 dev_err(&pdev->dev, "failed to register regulator %s\n",368372 mc13783_regulators[i].desc.name);
+10-15
drivers/regulator/mc13892-regulator.c
···428428 return val;429429}430430431431-static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev,432432- int min_uV, int max_uV, unsigned *selector)431431+static int mc13892_sw_regulator_set_voltage_sel(struct regulator_dev *rdev,432432+ unsigned selector)433433{434434 struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);435435 int hi, value, mask, id = rdev_get_id(rdev);436436 u32 valread;437437 int ret;438438439439- dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",440440- __func__, id, min_uV, max_uV);441441-442442- /* Find the best index */443443- value = mc13xxx_get_best_voltage_index(rdev, min_uV, max_uV);444444- dev_dbg(rdev_get_dev(rdev), "%s best value: %d\n", __func__, value);445445- if (value < 0)446446- return value;447447-448448- value = mc13892_regulators[id].voltages[value];439439+ value = mc13892_regulators[id].voltages[selector];449440450441 mc13xxx_lock(priv->mc13xxx);451442 ret = mc13xxx_reg_read(priv->mc13xxx,···471480static struct regulator_ops mc13892_sw_regulator_ops = {472481 .is_enabled = mc13xxx_sw_regulator_is_enabled,473482 .list_voltage = mc13xxx_regulator_list_voltage,474474- .set_voltage = mc13892_sw_regulator_set_voltage,483483+ .set_voltage_sel = mc13892_sw_regulator_set_voltage_sel,475484 .get_voltage = mc13892_sw_regulator_get_voltage,476485};477486···519528 struct mc13xxx_regulator_platform_data *pdata =520529 dev_get_platdata(&pdev->dev);521530 struct mc13xxx_regulator_init_data *mc13xxx_data;531531+ struct regulator_config config = { };522532 int i, ret;523533 int num_regulators = 0;524534 u32 val;···589597 }590598 desc = &mc13892_regulators[id].desc;591599592592- priv->regulators[i] = regulator_register(593593- desc, &pdev->dev, init_data, priv, node);600600+ config.dev = &pdev->dev;601601+ config.init_data = init_data;602602+ config.driver_data = priv;603603+ config.of_node = node;594604605605+ priv->regulators[i] = regulator_register(desc, &config);595606 if (IS_ERR(priv->regulators[i])) {596607 dev_err(&pdev->dev, "failed to register regulator %s\n",597608 mc13892_regulators[i].desc.name);
+5-49
drivers/regulator/mc13xxx-regulator-core.c
···9494}9595EXPORT_SYMBOL_GPL(mc13xxx_regulator_list_voltage);96969797-int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,9898- int min_uV, int max_uV)9797+static int mc13xxx_regulator_set_voltage_sel(struct regulator_dev *rdev,9898+ unsigned selector)9999{100100 struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);101101 struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;102102- int reg_id = rdev_get_id(rdev);103103- int i;104104- int bestmatch;105105- int bestindex;106106-107107- /*108108- * Locate the minimum voltage fitting the criteria on109109- * this regulator. The switchable voltages are not110110- * in strict falling order so we need to check them111111- * all for the best match.112112- */113113- bestmatch = INT_MAX;114114- bestindex = -1;115115- for (i = 0; i < mc13xxx_regulators[reg_id].desc.n_voltages; i++) {116116- if (mc13xxx_regulators[reg_id].voltages[i] >= min_uV &&117117- mc13xxx_regulators[reg_id].voltages[i] < bestmatch) {118118- bestmatch = mc13xxx_regulators[reg_id].voltages[i];119119- bestindex = i;120120- }121121- }122122-123123- if (bestindex < 0 || bestmatch > max_uV) {124124- dev_warn(&rdev->dev, "no possible value for %d<=x<=%d uV\n",125125- min_uV, max_uV);126126- return -EINVAL;127127- }128128- return bestindex;129129-}130130-EXPORT_SYMBOL_GPL(mc13xxx_get_best_voltage_index);131131-132132-static int mc13xxx_regulator_set_voltage(struct regulator_dev *rdev, int min_uV,133133- int max_uV, unsigned *selector)134134-{135135- struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);136136- struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;137137- int value, id = rdev_get_id(rdev);102102+ int id = rdev_get_id(rdev);138103 int ret;139139-140140- dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",141141- __func__, id, min_uV, max_uV);142142-143143- /* Find the best index */144144- value = mc13xxx_get_best_voltage_index(rdev, min_uV, max_uV);145145- dev_dbg(rdev_get_dev(rdev), "%s best value: %d\n", __func__, value);146146- if (value < 0)147147- return value;148104149105 mc13xxx_lock(priv->mc13xxx);150106 ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg,151107 mc13xxx_regulators[id].vsel_mask,152152- value << mc13xxx_regulators[id].vsel_shift);108108+ selector << mc13xxx_regulators[id].vsel_shift);153109 mc13xxx_unlock(priv->mc13xxx);154110155111 return ret;···143187 .disable = mc13xxx_regulator_disable,144188 .is_enabled = mc13xxx_regulator_is_enabled,145189 .list_voltage = mc13xxx_regulator_list_voltage,146146- .set_voltage = mc13xxx_regulator_set_voltage,190190+ .set_voltage_sel = mc13xxx_regulator_set_voltage_sel,147191 .get_voltage = mc13xxx_regulator_get_voltage,148192};149193EXPORT_SYMBOL_GPL(mc13xxx_regulator_ops);
-2
drivers/regulator/mc13xxx.h
···35353636extern int mc13xxx_sw_regulator(struct regulator_dev *rdev);3737extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev);3838-extern int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,3939- int min_uV, int max_uV);4038extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,4139 unsigned selector);4240extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
+17-37
drivers/regulator/pcap-regulator.c
···150150 VREG_INFO(SW2S, PCAP_REG_LOWPWR, NA, 20, NA, NA), */151151};152152153153-static int pcap_regulator_set_voltage(struct regulator_dev *rdev,154154- int min_uV, int max_uV,155155- unsigned *selector)153153+static int pcap_regulator_set_voltage_sel(struct regulator_dev *rdev,154154+ unsigned selector)156155{157156 struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];158157 void *pcap = rdev_get_drvdata(rdev);159159- int uV;160160- u8 i;161158162159 /* the regulator doesn't support voltage switching */163160 if (vreg->n_voltages == 1)164161 return -EINVAL;165162166166- for (i = 0; i < vreg->n_voltages; i++) {167167- /* For V1 the first is not the best match */168168- if (i == 0 && rdev_get_id(rdev) == V1)169169- i = 1;170170- else if (i + 1 == vreg->n_voltages && rdev_get_id(rdev) == V1)171171- i = 0;172172-173173- uV = vreg->voltage_table[i] * 1000;174174- if (min_uV <= uV && uV <= max_uV) {175175- *selector = i;176176- return ezx_pcap_set_bits(pcap, vreg->reg,177177- (vreg->n_voltages - 1) << vreg->index,178178- i << vreg->index);179179- }180180-181181- if (i == 0 && rdev_get_id(rdev) == V1)182182- i = vreg->n_voltages - 1;183183- }184184-185185- /* the requested voltage range is not supported by this regulator */186186- return -EINVAL;163163+ return ezx_pcap_set_bits(pcap, vreg->reg,164164+ (vreg->n_voltages - 1) << vreg->index,165165+ selector << vreg->index);187166}188167189189-static int pcap_regulator_get_voltage(struct regulator_dev *rdev)168168+static int pcap_regulator_get_voltage_sel(struct regulator_dev *rdev)190169{191170 struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];192171 void *pcap = rdev_get_drvdata(rdev);193172 u32 tmp;194194- int mV;195173196174 if (vreg->n_voltages == 1)197197- return vreg->voltage_table[0] * 1000;175175+ return 0;198176199177 ezx_pcap_read(pcap, vreg->reg, &tmp);200178 tmp = ((tmp >> vreg->index) & (vreg->n_voltages - 1));201201- mV = vreg->voltage_table[tmp];202202-203203- return mV * 1000;179179+ return tmp;204180}205181206182static int pcap_regulator_enable(struct regulator_dev *rdev)···224248225249static struct regulator_ops pcap_regulator_ops = {226250 .list_voltage = pcap_regulator_list_voltage,227227- .set_voltage = pcap_regulator_set_voltage,228228- .get_voltage = pcap_regulator_get_voltage,251251+ .set_voltage_sel = pcap_regulator_set_voltage_sel,252252+ .get_voltage_sel = pcap_regulator_get_voltage_sel,229253 .enable = pcap_regulator_enable,230254 .disable = pcap_regulator_disable,231255 .is_enabled = pcap_regulator_is_enabled,···241265 .owner = THIS_MODULE, \242266 }243267244244-static struct regulator_desc pcap_regulators[] = {268268+static const struct regulator_desc pcap_regulators[] = {245269 VREG(V1), VREG(V2), VREG(V3), VREG(V4), VREG(V5), VREG(V6), VREG(V7),246270 VREG(V8), VREG(V9), VREG(V10), VREG(VAUX1), VREG(VAUX2), VREG(VAUX3),247271 VREG(VAUX4), VREG(VSIM), VREG(VSIM2), VREG(VVIB), VREG(SW1), VREG(SW2),···251275{252276 struct regulator_dev *rdev;253277 void *pcap = dev_get_drvdata(pdev->dev.parent);278278+ struct regulator_config config = { };254279255255- rdev = regulator_register(&pcap_regulators[pdev->id], &pdev->dev,256256- pdev->dev.platform_data, pcap, NULL);280280+ config.dev = &pdev->dev;281281+ config.init_data = pdev->dev.platform_data;282282+ config.driver_data = pcap;283283+284284+ rdev = regulator_register(&pcap_regulators[pdev->id], &config);257285 if (IS_ERR(rdev))258286 return PTR_ERR(rdev);259287
+49-150
drivers/regulator/pcf50633-regulator.c
···2424#include <linux/mfd/pcf50633/core.h>2525#include <linux/mfd/pcf50633/pmic.h>26262727-#define PCF50633_REGULATOR(_name, _id, _n) \2828- { \2929- .name = _name, \3030- .id = _id, \3131- .ops = &pcf50633_regulator_ops, \3232- .n_voltages = _n, \3333- .type = REGULATOR_VOLTAGE, \3434- .owner = THIS_MODULE, \2727+#define PCF50633_REGULATOR(_name, _id, _n) \2828+ { \2929+ .name = _name, \3030+ .id = PCF50633_REGULATOR_##_id, \3131+ .ops = &pcf50633_regulator_ops, \3232+ .n_voltages = _n, \3333+ .type = REGULATOR_VOLTAGE, \3434+ .owner = THIS_MODULE, \3535+ .vsel_reg = PCF50633_REG_##_id##OUT, \3636+ .vsel_mask = 0xff, \3737+ .enable_reg = PCF50633_REG_##_id##OUT + 1, \3838+ .enable_mask = PCF50633_REGULATOR_ON, \3539 }3636-3737-static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {3838- [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,3939- [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,4040- [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,4141- [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,4242- [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,4343- [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,4444- [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,4545- [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,4646- [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,4747- [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,4848- [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,4949-};50405141/* Bits from voltage value */5242static u8 auto_voltage_bits(unsigned int millivolts)5343{5444 if (millivolts < 1800)5555- return 0;4545+ return 0x2f;5646 if (millivolts > 3800)5747 return 0xff;5848···7787/* Obtain voltage value from bits */7888static unsigned int auto_voltage_value(u8 bits)7989{9090+ /* AUTOOUT: 00000000 to 00101110 are reserved.9191+ * Return 0 for bits in reserved range, which means this selector code9292+ * can't be used on this system */8093 if (bits < 0x2f)8194 return 0;8295···116123117124 millivolts = min_uV / 1000;118125119119- regnr = pcf50633_regulator_registers[regulator_id];126126+ regnr = rdev->desc->vsel_reg;120127121128 switch (regulator_id) {122129 case PCF50633_REGULATOR_AUTO:···147154 return pcf50633_reg_write(pcf, regnr, volt_bits);148155}149156150150-static int pcf50633_regulator_voltage_value(enum pcf50633_regulator_id id,151151- u8 bits)157157+static int pcf50633_regulator_list_voltage(struct regulator_dev *rdev,158158+ unsigned int index)152159{160160+ int regulator_id = rdev_get_id(rdev);161161+153162 int millivolts;154163155155- switch (id) {164164+ switch (regulator_id) {156165 case PCF50633_REGULATOR_AUTO:157157- millivolts = auto_voltage_value(bits);166166+ millivolts = auto_voltage_value(index);158167 break;159168 case PCF50633_REGULATOR_DOWN1:160160- millivolts = down_voltage_value(bits);169169+ millivolts = down_voltage_value(index);161170 break;162171 case PCF50633_REGULATOR_DOWN2:163163- millivolts = down_voltage_value(bits);172172+ millivolts = down_voltage_value(index);164173 break;165174 case PCF50633_REGULATOR_LDO1:166175 case PCF50633_REGULATOR_LDO2:···172177 case PCF50633_REGULATOR_LDO6:173178 case PCF50633_REGULATOR_HCLDO:174179 case PCF50633_REGULATOR_MEMLDO:175175- millivolts = ldo_voltage_value(bits);180180+ millivolts = ldo_voltage_value(index);176181 break;177182 default:178183 return -EINVAL;···181186 return millivolts * 1000;182187}183188184184-static int pcf50633_regulator_get_voltage(struct regulator_dev *rdev)185185-{186186- struct pcf50633 *pcf;187187- int regulator_id;188188- u8 volt_bits, regnr;189189-190190- pcf = rdev_get_drvdata(rdev);191191-192192- regulator_id = rdev_get_id(rdev);193193- if (regulator_id >= PCF50633_NUM_REGULATORS)194194- return -EINVAL;195195-196196- regnr = pcf50633_regulator_registers[regulator_id];197197-198198- volt_bits = pcf50633_reg_read(pcf, regnr);199199-200200- return pcf50633_regulator_voltage_value(regulator_id, volt_bits);201201-}202202-203203-static int pcf50633_regulator_list_voltage(struct regulator_dev *rdev,204204- unsigned int index)205205-{206206- struct pcf50633 *pcf;207207- int regulator_id;208208-209209- pcf = rdev_get_drvdata(rdev);210210-211211- regulator_id = rdev_get_id(rdev);212212-213213- switch (regulator_id) {214214- case PCF50633_REGULATOR_AUTO:215215- index += 0x2f;216216- break;217217- default:218218- break;219219- }220220-221221- return pcf50633_regulator_voltage_value(regulator_id, index);222222-}223223-224224-static int pcf50633_regulator_enable(struct regulator_dev *rdev)225225-{226226- struct pcf50633 *pcf = rdev_get_drvdata(rdev);227227- int regulator_id;228228- u8 regnr;229229-230230- regulator_id = rdev_get_id(rdev);231231- if (regulator_id >= PCF50633_NUM_REGULATORS)232232- return -EINVAL;233233-234234- /* The *ENA register is always one after the *OUT register */235235- regnr = pcf50633_regulator_registers[regulator_id] + 1;236236-237237- return pcf50633_reg_set_bit_mask(pcf, regnr, PCF50633_REGULATOR_ON,238238- PCF50633_REGULATOR_ON);239239-}240240-241241-static int pcf50633_regulator_disable(struct regulator_dev *rdev)242242-{243243- struct pcf50633 *pcf = rdev_get_drvdata(rdev);244244- int regulator_id;245245- u8 regnr;246246-247247- regulator_id = rdev_get_id(rdev);248248- if (regulator_id >= PCF50633_NUM_REGULATORS)249249- return -EINVAL;250250-251251- /* the *ENA register is always one after the *OUT register */252252- regnr = pcf50633_regulator_registers[regulator_id] + 1;253253-254254- return pcf50633_reg_set_bit_mask(pcf, regnr,255255- PCF50633_REGULATOR_ON, 0);256256-}257257-258258-static int pcf50633_regulator_is_enabled(struct regulator_dev *rdev)259259-{260260- struct pcf50633 *pcf = rdev_get_drvdata(rdev);261261- int regulator_id = rdev_get_id(rdev);262262- u8 regnr;263263-264264- regulator_id = rdev_get_id(rdev);265265- if (regulator_id >= PCF50633_NUM_REGULATORS)266266- return -EINVAL;267267-268268- /* the *ENA register is always one after the *OUT register */269269- regnr = pcf50633_regulator_registers[regulator_id] + 1;270270-271271- return pcf50633_reg_read(pcf, regnr) & PCF50633_REGULATOR_ON;272272-}273273-274189static struct regulator_ops pcf50633_regulator_ops = {275190 .set_voltage = pcf50633_regulator_set_voltage,276276- .get_voltage = pcf50633_regulator_get_voltage,191191+ .get_voltage_sel = regulator_get_voltage_sel_regmap,277192 .list_voltage = pcf50633_regulator_list_voltage,278278- .enable = pcf50633_regulator_enable,279279- .disable = pcf50633_regulator_disable,280280- .is_enabled = pcf50633_regulator_is_enabled,193193+ .enable = regulator_enable_regmap,194194+ .disable = regulator_disable_regmap,195195+ .is_enabled = regulator_is_enabled_regmap,281196};282197283283-static struct regulator_desc regulators[] = {284284- [PCF50633_REGULATOR_AUTO] =285285- PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO, 81),286286- [PCF50633_REGULATOR_DOWN1] =287287- PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1, 96),288288- [PCF50633_REGULATOR_DOWN2] =289289- PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2, 96),290290- [PCF50633_REGULATOR_LDO1] =291291- PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1, 28),292292- [PCF50633_REGULATOR_LDO2] =293293- PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2, 28),294294- [PCF50633_REGULATOR_LDO3] =295295- PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3, 28),296296- [PCF50633_REGULATOR_LDO4] =297297- PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4, 28),298298- [PCF50633_REGULATOR_LDO5] =299299- PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5, 28),300300- [PCF50633_REGULATOR_LDO6] =301301- PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6, 28),302302- [PCF50633_REGULATOR_HCLDO] =303303- PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO, 28),304304- [PCF50633_REGULATOR_MEMLDO] =305305- PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO, 28),198198+static const struct regulator_desc regulators[] = {199199+ [PCF50633_REGULATOR_AUTO] = PCF50633_REGULATOR("auto", AUTO, 128),200200+ [PCF50633_REGULATOR_DOWN1] = PCF50633_REGULATOR("down1", DOWN1, 96),201201+ [PCF50633_REGULATOR_DOWN2] = PCF50633_REGULATOR("down2", DOWN2, 96),202202+ [PCF50633_REGULATOR_LDO1] = PCF50633_REGULATOR("ldo1", LDO1, 28),203203+ [PCF50633_REGULATOR_LDO2] = PCF50633_REGULATOR("ldo2", LDO2, 28),204204+ [PCF50633_REGULATOR_LDO3] = PCF50633_REGULATOR("ldo3", LDO3, 28),205205+ [PCF50633_REGULATOR_LDO4] = PCF50633_REGULATOR("ldo4", LDO4, 28),206206+ [PCF50633_REGULATOR_LDO5] = PCF50633_REGULATOR("ldo5", LDO5, 28),207207+ [PCF50633_REGULATOR_LDO6] = PCF50633_REGULATOR("ldo6", LDO6, 28),208208+ [PCF50633_REGULATOR_HCLDO] = PCF50633_REGULATOR("hcldo", HCLDO, 28),209209+ [PCF50633_REGULATOR_MEMLDO] = PCF50633_REGULATOR("memldo", MEMLDO, 28),306210};307211308212static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)309213{310214 struct regulator_dev *rdev;311215 struct pcf50633 *pcf;216216+ struct regulator_config config = { };312217313218 /* Already set by core driver */314219 pcf = dev_to_pcf50633(pdev->dev.parent);315220316316- rdev = regulator_register(®ulators[pdev->id], &pdev->dev,317317- pdev->dev.platform_data, pcf, NULL);221221+ config.dev = &pdev->dev;222222+ config.init_data = pdev->dev.platform_data;223223+ config.driver_data = pcf;224224+ config.regmap = pcf->regmap;225225+226226+ rdev = regulator_register(®ulators[pdev->id], &config);318227 if (IS_ERR(rdev))319228 return PTR_ERR(rdev);320229
+295
drivers/regulator/rc5t583-regulator.c
···11+/*22+ * Regulator driver for RICOH RC5T583 power management chip.33+ *44+ * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved.55+ * Author: Laxman dewangan <ldewangan@nvidia.com>66+ *77+ * based on code88+ * Copyright (C) 2011 RICOH COMPANY,LTD99+ *1010+ *1111+ * This program is free software; you can redistribute it and/or modify it1212+ * under the terms and conditions of the GNU General Public License,1313+ * version 2, as published by the Free Software Foundation.1414+ *1515+ * This program is distributed in the hope it will be useful, but WITHOUT1616+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1717+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1818+ * more details.1919+ *2020+ * You should have received a copy of the GNU General Public License2121+ * along with this program. If not, see <http://www.gnu.org/licenses/>.2222+ *2323+ */2424+2525+#include <linux/module.h>2626+#include <linux/delay.h>2727+#include <linux/init.h>2828+#include <linux/slab.h>2929+#include <linux/err.h>3030+#include <linux/platform_device.h>3131+#include <linux/regulator/driver.h>3232+#include <linux/regulator/machine.h>3333+#include <linux/gpio.h>3434+#include <linux/mfd/rc5t583.h>3535+3636+struct rc5t583_regulator_info {3737+ int deepsleep_id;3838+3939+ /* Regulator register address.*/4040+ uint8_t reg_disc_reg;4141+ uint8_t disc_bit;4242+ uint8_t deepsleep_reg;4343+4444+ /* Chip constraints on regulator behavior */4545+ int min_uV;4646+ int max_uV;4747+ int step_uV;4848+4949+ /* Regulator specific turn-on delay and voltage settling time*/5050+ int enable_uv_per_us;5151+ int change_uv_per_us;5252+5353+ /* Used by regulator core */5454+ struct regulator_desc desc;5555+};5656+5757+struct rc5t583_regulator {5858+ struct rc5t583_regulator_info *reg_info;5959+6060+ /* Devices */6161+ struct device *dev;6262+ struct rc5t583 *mfd;6363+ struct regulator_dev *rdev;6464+};6565+6666+static int rc5t583_list_voltage(struct regulator_dev *rdev, unsigned selector)6767+{6868+ struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);6969+ struct rc5t583_regulator_info *ri = reg->reg_info;7070+ return ri->min_uV + (ri->step_uV * selector);7171+}7272+7373+static int rc5t583_set_voltage(struct regulator_dev *rdev,7474+ int min_uV, int max_uV, unsigned *selector)7575+{7676+ struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);7777+ struct rc5t583_regulator_info *ri = reg->reg_info;7878+ int sel, ret;7979+8080+ if (min_uV < ri->min_uV)8181+ min_uV = ri->min_uV;8282+8383+ sel = DIV_ROUND_UP(min_uV - ri->min_uV, ri->step_uV);8484+8585+ if (sel >= rdev->desc->n_voltages) {8686+ dev_err(&rdev->dev, "Invalid selector 0x%02x\n", sel);8787+ return -EINVAL;8888+ }8989+9090+ *selector = sel;9191+9292+ ret = rc5t583_update(reg->mfd->dev, rdev->desc->vsel_reg, sel,9393+ rdev->desc->vsel_mask);9494+ if (ret < 0)9595+ dev_err(&rdev->dev, "Error in update voltage register 0x%02x\n",9696+ rdev->desc->vsel_reg);9797+ return ret;9898+}9999+100100+static int rc5t583_regulator_enable_time(struct regulator_dev *rdev)101101+{102102+ struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);103103+ int vsel = regulator_get_voltage_sel_regmap(rdev);104104+ int curr_uV = rc5t583_list_voltage(rdev, vsel);105105+106106+ return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us);107107+}108108+109109+static int rc5t583_set_voltage_time_sel(struct regulator_dev *rdev,110110+ unsigned int old_selector, unsigned int new_selector)111111+{112112+ struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);113113+ int old_uV, new_uV;114114+ old_uV = rc5t583_list_voltage(rdev, old_selector);115115+116116+ if (old_uV < 0)117117+ return old_uV;118118+119119+ new_uV = rc5t583_list_voltage(rdev, new_selector);120120+ if (new_uV < 0)121121+ return new_uV;122122+123123+ return DIV_ROUND_UP(abs(old_uV - new_uV),124124+ reg->reg_info->change_uv_per_us);125125+}126126+127127+128128+static struct regulator_ops rc5t583_ops = {129129+ .is_enabled = regulator_is_enabled_regmap,130130+ .enable = regulator_enable_regmap,131131+ .disable = regulator_disable_regmap,132132+ .enable_time = rc5t583_regulator_enable_time,133133+ .get_voltage_sel = regulator_get_voltage_sel_regmap,134134+ .set_voltage = rc5t583_set_voltage,135135+ .list_voltage = rc5t583_list_voltage,136136+ .set_voltage_time_sel = rc5t583_set_voltage_time_sel,137137+};138138+139139+#define RC5T583_REG(_id, _en_reg, _en_bit, _disc_reg, _disc_bit, \140140+ _vout_mask, _min_mv, _max_mv, _step_uV, _enable_mv) \141141+{ \142142+ .reg_disc_reg = RC5T583_REG_##_disc_reg, \143143+ .disc_bit = _disc_bit, \144144+ .deepsleep_reg = RC5T583_REG_##_id##DAC_DS, \145145+ .min_uV = _min_mv * 1000, \146146+ .max_uV = _max_mv * 1000, \147147+ .step_uV = _step_uV, \148148+ .enable_uv_per_us = _enable_mv * 1000, \149149+ .change_uv_per_us = 40 * 1000, \150150+ .deepsleep_id = RC5T583_DS_##_id, \151151+ .desc = { \152152+ .name = "rc5t583-regulator-"#_id, \153153+ .id = RC5T583_REGULATOR_##_id, \154154+ .n_voltages = (_max_mv - _min_mv) * 1000 / _step_uV + 1, \155155+ .ops = &rc5t583_ops, \156156+ .type = REGULATOR_VOLTAGE, \157157+ .owner = THIS_MODULE, \158158+ .vsel_reg = RC5T583_REG_##_id##DAC, \159159+ .vsel_mask = _vout_mask, \160160+ .enable_reg = RC5T583_REG_##_en_reg, \161161+ .enable_mask = BIT(_en_bit), \162162+ }, \163163+}164164+165165+static struct rc5t583_regulator_info rc5t583_reg_info[RC5T583_REGULATOR_MAX] = {166166+ RC5T583_REG(DC0, DC0CTL, 0, DC0CTL, 1, 0x7F, 700, 1500, 12500, 4),167167+ RC5T583_REG(DC1, DC1CTL, 0, DC1CTL, 1, 0x7F, 700, 1500, 12500, 14),168168+ RC5T583_REG(DC2, DC2CTL, 0, DC2CTL, 1, 0x7F, 900, 2400, 12500, 14),169169+ RC5T583_REG(DC3, DC3CTL, 0, DC3CTL, 1, 0x7F, 900, 2400, 12500, 14),170170+ RC5T583_REG(LDO0, LDOEN2, 0, LDODIS2, 0, 0x7F, 900, 3400, 25000, 160),171171+ RC5T583_REG(LDO1, LDOEN2, 1, LDODIS2, 1, 0x7F, 900, 3400, 25000, 160),172172+ RC5T583_REG(LDO2, LDOEN2, 2, LDODIS2, 2, 0x7F, 900, 3400, 25000, 160),173173+ RC5T583_REG(LDO3, LDOEN2, 3, LDODIS2, 3, 0x7F, 900, 3400, 25000, 160),174174+ RC5T583_REG(LDO4, LDOEN2, 4, LDODIS2, 4, 0x3F, 750, 1500, 12500, 133),175175+ RC5T583_REG(LDO5, LDOEN2, 5, LDODIS2, 5, 0x7F, 900, 3400, 25000, 267),176176+ RC5T583_REG(LDO6, LDOEN2, 6, LDODIS2, 6, 0x7F, 900, 3400, 25000, 133),177177+ RC5T583_REG(LDO7, LDOEN2, 7, LDODIS2, 7, 0x7F, 900, 3400, 25000, 233),178178+ RC5T583_REG(LDO8, LDOEN1, 0, LDODIS1, 0, 0x7F, 900, 3400, 25000, 233),179179+ RC5T583_REG(LDO9, LDOEN1, 1, LDODIS1, 1, 0x7F, 900, 3400, 25000, 133),180180+};181181+182182+static int __devinit rc5t583_regulator_probe(struct platform_device *pdev)183183+{184184+ struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent);185185+ struct rc5t583_platform_data *pdata = dev_get_platdata(rc5t583->dev);186186+ struct regulator_init_data *reg_data;187187+ struct regulator_config config = { };188188+ struct rc5t583_regulator *reg = NULL;189189+ struct rc5t583_regulator *regs;190190+ struct regulator_dev *rdev;191191+ struct rc5t583_regulator_info *ri;192192+ int ret;193193+ int id;194194+195195+ if (!pdata) {196196+ dev_err(&pdev->dev, "No platform data, exiting...\n");197197+ return -ENODEV;198198+ }199199+200200+ regs = devm_kzalloc(&pdev->dev, RC5T583_REGULATOR_MAX *201201+ sizeof(struct rc5t583_regulator), GFP_KERNEL);202202+ if (!regs) {203203+ dev_err(&pdev->dev, "Memory allocation failed exiting..\n");204204+ return -ENOMEM;205205+ }206206+207207+208208+ for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) {209209+ reg_data = pdata->reg_init_data[id];210210+211211+ /* No need to register if there is no regulator data */212212+ if (!reg_data)213213+ continue;214214+215215+ reg = ®s[id];216216+ ri = &rc5t583_reg_info[id];217217+ reg->reg_info = ri;218218+ reg->mfd = rc5t583;219219+ reg->dev = &pdev->dev;220220+221221+ if (ri->deepsleep_id == RC5T583_DS_NONE)222222+ goto skip_ext_pwr_config;223223+224224+ ret = rc5t583_ext_power_req_config(rc5t583->dev,225225+ ri->deepsleep_id,226226+ pdata->regulator_ext_pwr_control[id],227227+ pdata->regulator_deepsleep_slot[id]);228228+ /*229229+ * Configuring external control is not a major issue,230230+ * just give warning.231231+ */232232+ if (ret < 0)233233+ dev_warn(&pdev->dev,234234+ "Failed to configure ext control %d\n", id);235235+236236+skip_ext_pwr_config:237237+ config.dev = &pdev->dev;238238+ config.init_data = reg_data;239239+ config.driver_data = reg;240240+ config.regmap = rc5t583->regmap;241241+242242+ rdev = regulator_register(&ri->desc, &config);243243+ if (IS_ERR(rdev)) {244244+ dev_err(&pdev->dev, "Failed to register regulator %s\n",245245+ ri->desc.name);246246+ ret = PTR_ERR(rdev);247247+ goto clean_exit;248248+ }249249+ reg->rdev = rdev;250250+ }251251+ platform_set_drvdata(pdev, regs);252252+ return 0;253253+254254+clean_exit:255255+ while (--id >= 0)256256+ regulator_unregister(regs[id].rdev);257257+258258+ return ret;259259+}260260+261261+static int __devexit rc5t583_regulator_remove(struct platform_device *pdev)262262+{263263+ struct rc5t583_regulator *regs = platform_get_drvdata(pdev);264264+ int id;265265+266266+ for (id = 0; id < RC5T583_REGULATOR_MAX; ++id)267267+ regulator_unregister(regs[id].rdev);268268+ return 0;269269+}270270+271271+static struct platform_driver rc5t583_regulator_driver = {272272+ .driver = {273273+ .name = "rc5t583-regulator",274274+ .owner = THIS_MODULE,275275+ },276276+ .probe = rc5t583_regulator_probe,277277+ .remove = __devexit_p(rc5t583_regulator_remove),278278+};279279+280280+static int __init rc5t583_regulator_init(void)281281+{282282+ return platform_driver_register(&rc5t583_regulator_driver);283283+}284284+subsys_initcall(rc5t583_regulator_init);285285+286286+static void __exit rc5t583_regulator_exit(void)287287+{288288+ platform_driver_unregister(&rc5t583_regulator_driver);289289+}290290+module_exit(rc5t583_regulator_exit);291291+292292+MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");293293+MODULE_DESCRIPTION("RC5T583 regulator driver");294294+MODULE_ALIAS("platform:rc5t583-regulator");295295+MODULE_LICENSE("GPL v2");
···11+/*22+ * Regulator driver for tps65090 power management chip.33+ *44+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.55+66+ * This program is free software; you can redistribute it and/or modify it77+ * under the terms and conditions of the GNU General Public License,88+ * version 2, as published by the Free Software Foundation.99+1010+ * This program is distributed in the hope it will be useful, but WITHOUT1111+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1212+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1313+ * more details.1414+1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program. If not, see <http://www.gnu.org/licenses/>1717+ */1818+1919+#include <linux/module.h>2020+#include <linux/delay.h>2121+#include <linux/init.h>2222+#include <linux/slab.h>2323+#include <linux/err.h>2424+#include <linux/platform_device.h>2525+#include <linux/regulator/driver.h>2626+#include <linux/regulator/machine.h>2727+#include <linux/mfd/tps65090.h>2828+#include <linux/regulator/tps65090-regulator.h>2929+3030+struct tps65090_regulator {3131+ int id;3232+ /* used by regulator core */3333+ struct regulator_desc desc;3434+3535+ /* Device */3636+ struct device *dev;3737+};3838+3939+static struct regulator_ops tps65090_ops = {4040+ .enable = regulator_enable_regmap,4141+ .disable = regulator_disable_regmap,4242+ .is_enabled = regulator_is_enabled_regmap,4343+};4444+4545+#define tps65090_REG(_id) \4646+{ \4747+ .id = TPS65090_ID_##_id, \4848+ .desc = { \4949+ .name = tps65090_rails(_id), \5050+ .id = TPS65090_ID_##_id, \5151+ .ops = &tps65090_ops, \5252+ .type = REGULATOR_VOLTAGE, \5353+ .owner = THIS_MODULE, \5454+ .enable_reg = (TPS65090_ID_##_id) + 12, \5555+ .enable_mask = BIT(0), \5656+ }, \5757+}5858+5959+static struct tps65090_regulator TPS65090_regulator[] = {6060+ tps65090_REG(DCDC1),6161+ tps65090_REG(DCDC2),6262+ tps65090_REG(DCDC3),6363+ tps65090_REG(FET1),6464+ tps65090_REG(FET2),6565+ tps65090_REG(FET3),6666+ tps65090_REG(FET4),6767+ tps65090_REG(FET5),6868+ tps65090_REG(FET6),6969+ tps65090_REG(FET7),7070+};7171+7272+static inline struct tps65090_regulator *find_regulator_info(int id)7373+{7474+ struct tps65090_regulator *ri;7575+ int i;7676+7777+ for (i = 0; i < ARRAY_SIZE(TPS65090_regulator); i++) {7878+ ri = &TPS65090_regulator[i];7979+ if (ri->desc.id == id)8080+ return ri;8181+ }8282+ return NULL;8383+}8484+8585+static int __devinit tps65090_regulator_probe(struct platform_device *pdev)8686+{8787+ struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent);8888+ struct tps65090_regulator *ri = NULL;8989+ struct regulator_config config = { };9090+ struct regulator_dev *rdev;9191+ struct tps65090_regulator_platform_data *tps_pdata;9292+ int id = pdev->id;9393+9494+ dev_dbg(&pdev->dev, "Probing regulator %d\n", id);9595+9696+ ri = find_regulator_info(id);9797+ if (ri == NULL) {9898+ dev_err(&pdev->dev, "invalid regulator ID specified\n");9999+ return -EINVAL;100100+ }101101+ tps_pdata = pdev->dev.platform_data;102102+ ri->dev = &pdev->dev;103103+104104+ config.dev = &pdev->dev;105105+ config.init_data = &tps_pdata->regulator;106106+ config.driver_data = ri;107107+ config.regmap = tps65090_mfd->rmap;108108+109109+ rdev = regulator_register(&ri->desc, &config);110110+ if (IS_ERR(rdev)) {111111+ dev_err(&pdev->dev, "failed to register regulator %s\n",112112+ ri->desc.name);113113+ return PTR_ERR(rdev);114114+ }115115+116116+ platform_set_drvdata(pdev, rdev);117117+ return 0;118118+}119119+120120+static int __devexit tps65090_regulator_remove(struct platform_device *pdev)121121+{122122+ struct regulator_dev *rdev = platform_get_drvdata(pdev);123123+124124+ regulator_unregister(rdev);125125+ return 0;126126+}127127+128128+static struct platform_driver tps65090_regulator_driver = {129129+ .driver = {130130+ .name = "tps65090-regulator",131131+ .owner = THIS_MODULE,132132+ },133133+ .probe = tps65090_regulator_probe,134134+ .remove = __devexit_p(tps65090_regulator_remove),135135+};136136+137137+static int __init tps65090_regulator_init(void)138138+{139139+ return platform_driver_register(&tps65090_regulator_driver);140140+}141141+subsys_initcall(tps65090_regulator_init);142142+143143+static void __exit tps65090_regulator_exit(void)144144+{145145+ platform_driver_unregister(&tps65090_regulator_driver);146146+}147147+module_exit(tps65090_regulator_exit);148148+149149+MODULE_DESCRIPTION("tps65090 regulator driver");150150+MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@nvidia.com>");151151+MODULE_LICENSE("GPL v2");
···250250 RC5T583_EXT_PWRREQ2_CONTROL = 0x2,251251};252252253253+enum {254254+ RC5T583_REGULATOR_DC0,255255+ RC5T583_REGULATOR_DC1,256256+ RC5T583_REGULATOR_DC2,257257+ RC5T583_REGULATOR_DC3,258258+ RC5T583_REGULATOR_LDO0,259259+ RC5T583_REGULATOR_LDO1,260260+ RC5T583_REGULATOR_LDO2,261261+ RC5T583_REGULATOR_LDO3,262262+ RC5T583_REGULATOR_LDO4,263263+ RC5T583_REGULATOR_LDO5,264264+ RC5T583_REGULATOR_LDO6,265265+ RC5T583_REGULATOR_LDO7,266266+ RC5T583_REGULATOR_LDO8,267267+ RC5T583_REGULATOR_LDO9,268268+269269+ /* Should be last entry */270270+ RC5T583_REGULATOR_MAX,271271+};272272+253273struct rc5t583 {254274 struct device *dev;255275 struct regmap *regmap;···293273 * The board specific data is provided through this structure.294274 * @irq_base: Irq base number on which this device registers their interrupts.295275 * @enable_shutdown: Enable shutdown through the input pin "shutdown".276276+ * @regulator_deepsleep_slot: The slot number on which device goes to sleep277277+ * in device sleep mode.278278+ * @regulator_ext_pwr_control: External power request regulator control. The279279+ * regulator output enable/disable is controlled by the external280280+ * power request input state.281281+ * @reg_init_data: Regulator init data.296282 */297283298284struct rc5t583_platform_data {299285 int irq_base;300286 bool enable_shutdown;287287+ int regulator_deepsleep_slot[RC5T583_REGULATOR_MAX];288288+ unsigned long regulator_ext_pwr_control[RC5T583_REGULATOR_MAX];289289+ struct regulator_init_data *reg_init_data[RC5T583_REGULATOR_MAX];301290};302291303292static inline int rc5t583_write(struct device *dev, uint8_t reg, uint8_t val)
+1
include/linux/mfd/s5m87xx/s5m-core.h
···335335336336struct s5m_platform_data {337337 struct s5m_regulator_data *regulators;338338+ struct s5m_opmode_data *opmode;338339 int device_type;339340 int num_regulators;340341
+29
include/linux/mfd/s5m87xx/s5m-pmic.h
···5858 S5M8767_REG_MAX,5959};60606161+#define S5M8767_ENCTRL_SHIFT 66262+6163/* S5M8763 regulator ids */6264enum s5m8763_regulators {6365 S5M8763_LDO1,···9795struct s5m_regulator_data {9896 int id;9997 struct regulator_init_data *initdata;9898+};9999+100100+/*101101+ * s5m_opmode_data - regulator operation mode data102102+ * @id: regulator id103103+ * @mode: regulator operation mode104104+ */105105+struct s5m_opmode_data {106106+ int id;107107+ int mode;108108+};109109+110110+/*111111+ * s5m regulator operation mode112112+ * S5M_OPMODE_OFF Regulator always OFF113113+ * S5M_OPMODE_ON Regulator always ON114114+ * S5M_OPMODE_LOWPOWER Regulator is on in low-power mode115115+ * S5M_OPMODE_SUSPEND Regulator is changed by PWREN pin116116+ * If PWREN is high, regulator is on117117+ * If PWREN is low, regulator is off118118+ */119119+120120+enum s5m_opmode {121121+ S5M_OPMODE_OFF,122122+ S5M_OPMODE_ON,123123+ S5M_OPMODE_LOWPOWER,124124+ S5M_OPMODE_SUSPEND,100125};101126102127#endif /* __LINUX_MFD_S5M_PMIC_H */
···1919#include <linux/notifier.h>2020#include <linux/regulator/consumer.h>21212222+struct regmap;2223struct regulator_dev;2324struct regulator_init_data;2425···149148};150149151150/**152152- * struct regulator_desc - Regulator descriptor151151+ * struct regulator_desc - Static regulator descriptor153152 *154154- * Each regulator registered with the core is described with a structure of155155- * this type.153153+ * Each regulator registered with the core is described with a154154+ * structure of this type and a struct regulator_config. This155155+ * structure contains the non-varying parts of the regulator156156+ * description.156157 *157158 * @name: Identifying name for the regulator.158159 * @supply_name: Identifying the regulator supply···164161 * @irq: Interrupt number for the regulator.165162 * @type: Indicates if the regulator is a voltage or current regulator.166163 * @owner: Module providing the regulator, used for refcounting.164164+165165+ * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_166166+ * @vsel_mask: Mask for register bitfield used for selector167167+ * @enable_reg: Register for control when using regmap enable/disable ops168168+ * @enable_mask: Mask for control when using regmap enable/disable ops167169 */168170struct regulator_desc {169171 const char *name;···179171 int irq;180172 enum regulator_type type;181173 struct module *owner;174174+175175+ unsigned int vsel_reg;176176+ unsigned int vsel_mask;177177+ unsigned int enable_reg;178178+ unsigned int enable_mask;179179+};180180+181181+/**182182+ * struct regulator_config - Dynamic regulator descriptor183183+ *184184+ * Each regulator registered with the core is described with a185185+ * structure of this type and a struct regulator_desc. This structure186186+ * contains the runtime variable parts of the regulator description.187187+ *188188+ * @dev: struct device for the regulator189189+ * @init_data: platform provided init data, passed through by driver190190+ * @driver_data: private regulator data191191+ * @of_node: OpenFirmware node to parse for device tree bindings (may be192192+ * NULL).193193+ * @regmap: regmap to use for core regmap helpers194194+ */195195+struct regulator_config {196196+ struct device *dev;197197+ const struct regulator_init_data *init_data;198198+ void *driver_data;199199+ struct device_node *of_node;200200+ struct regmap *regmap;182201};183202184203/*···219184 * no other direct access).220185 */221186struct regulator_dev {222222- struct regulator_desc *desc;187187+ const struct regulator_desc *desc;223188 int exclusive;224189 u32 use_count;225190 u32 open_count;···236201 struct device dev;237202 struct regulation_constraints *constraints;238203 struct regulator *supply; /* for tree */204204+ struct regmap *regmap;239205240206 struct delayed_work disable_work;241207 int deferred_disables;···246210 struct dentry *debugfs;247211};248212249249-struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,250250- struct device *dev, const struct regulator_init_data *init_data,251251- void *driver_data, struct device_node *of_node);213213+struct regulator_dev *214214+regulator_register(const struct regulator_desc *regulator_desc,215215+ const struct regulator_config *config);252216void regulator_unregister(struct regulator_dev *rdev);253217254218int regulator_notifier_call_chain(struct regulator_dev *rdev,···259223int rdev_get_id(struct regulator_dev *rdev);260224261225int regulator_mode_to_status(unsigned int);226226+227227+int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev);228228+int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);229229+int regulator_is_enabled_regmap(struct regulator_dev *rdev);230230+int regulator_enable_regmap(struct regulator_dev *rdev);231231+int regulator_disable_regmap(struct regulator_dev *rdev);262232263233void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);264234
+7
include/linux/regulator/fixed.h
···2626 * @gpio: GPIO to use for enable control2727 * set to -EINVAL if not used2828 * @startup_delay: Start-up time in microseconds2929+ * @gpio_is_open_drain: Gpio pin is open drain or normal type.3030+ * If it is open drain type then HIGH will be set3131+ * through PULL-UP with setting gpio as input3232+ * and low will be set as gpio-output with driven3333+ * to low. For non-open-drain case, the gpio will3434+ * will be in output and drive to low/high accordingly.2935 * @enable_high: Polarity of enable GPIO3036 * 1 = Active high, 0 = Active low3137 * @enabled_at_boot: Whether regulator has been enabled at···4943 int microvolts;5044 int gpio;5145 unsigned startup_delay;4646+ unsigned gpio_is_open_drain:1;5247 unsigned enable_high:1;5348 unsigned enabled_at_boot:1;5449 struct regulator_init_data *init_data;
+50
include/linux/regulator/tps65090-regulator.h
···11+/*22+ * Regulator driver interface for TI TPS65090 PMIC family33+ *44+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.55+66+ * This program is free software; you can redistribute it and/or modify it77+ * under the terms and conditions of the GNU General Public License,88+ * version 2, as published by the Free Software Foundation.99+1010+ * This program is distributed in the hope it will be useful, but WITHOUT1111+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1212+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1313+ * more details.1414+1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1717+ */1818+1919+#ifndef __REGULATOR_TPS65090_H2020+#define __REGULATOR_TPS65090_H2121+2222+#include <linux/regulator/machine.h>2323+2424+#define tps65090_rails(_name) "tps65090_"#_name2525+2626+enum {2727+ TPS65090_ID_DCDC1,2828+ TPS65090_ID_DCDC2,2929+ TPS65090_ID_DCDC3,3030+ TPS65090_ID_FET1,3131+ TPS65090_ID_FET2,3232+ TPS65090_ID_FET3,3333+ TPS65090_ID_FET4,3434+ TPS65090_ID_FET5,3535+ TPS65090_ID_FET6,3636+ TPS65090_ID_FET7,3737+};3838+3939+/*4040+ * struct tps65090_regulator_platform_data4141+ *4242+ * @regulator: The regulator init data.4343+ * @slew_rate_uV_per_us: Slew rate microvolt per microsec.4444+ */4545+4646+struct tps65090_regulator_platform_data {4747+ struct regulator_init_data regulator;4848+};4949+5050+#endif /* __REGULATOR_TPS65090_H */