summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'regulator/topic/constraints' into regulator-linusMark Brown2013-12-131-3/+8
|\
| * regulator: core: Check for DT every time we check full constraintsMark Brown2013-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | Eliminate the gap between DT becoming available and this being used to say we have full constraints by checking directly for DT every time we check for full constraints. This improves interoperaton with optional regulator support. Signed-off-by: Mark Brown <broonie@linaro.org> Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
| * regulator: core: Replace checks of have_full_constraints with a functionMark Brown2013-11-271-3/+8
| | | | | | | | | | | | | | Simple code reorganisation so we can change the logic for deciding what full constraints are more easily. Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: fixed: fix regulator_list_voltage() for regressionGuennadi Liakhovetski2013-11-131-0/+3
|/ | | | | | | | | | | | | | Commit c368e5fc2a190923b786f2de3e79430ea3566a25 "regulator: fixed: get rid of {get|list}_voltage()" broke regulator_list_voltage() for the fixed regulator, because an earlier commit 5a523605afa7d3b54b2e7041f8c9e6bc39872a7e "regulator: core: provide fixed voltage in desc for single voltage rail" missed to add support for the fixed-voltage special case to that function. This patch fixes that regression. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* Merge remote-tracking branch 'regulator/topic/optional' into regulator-nextMark Brown2013-10-241-34/+15
|\
| * regulator: core: Always warn when using a dummy regulatorMark Brown2013-10-041-7/+2
| | | | | | | | | | | | | | | | This helps people spot if they have missed a supply from a device tree or equivalent data structure. Suggested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * regulator: core: Always use return value when regulator_dev_lookup() failsMark Brown2013-09-241-1/+2
| | | | | | | | | | | | | | | | | | | | Ensure that the return value is always set when we return now that the logic has changed for regulator_get_optional() so we don't get missing codes leaking out. Reported-by: Thierry Reding <treding@nvidia.com> Tested-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * regulator: core: Fix default return value for _get()Mark Brown2013-09-201-1/+1
| | | | | | | | | | | | | | | | | | Now that we are defaulting to providing dummy regulators fix the logic for substituting a dummy by making the default return code -EPROBE_DEFER. Reported-by: Thierry Reding <treding@nvidia.com> Tested-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * regulator: core: Remove unused regulator_use_dummy_regulator()Mark Brown2013-09-171-17/+0
| | | | | | | | | | | | | | | | No boards have used this functionality and the new default of providing dummy regulators by default provides a better solution to the problem it was trying to solve. Signed-off-by: Mark Brown <broonie@linaro.org>
| * regulator: core: Provide a dummy regulator with full constraintsMark Brown2013-09-171-17/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a system has said that it has fully specified constraints for its regulators it is still possible that some supplies may be missing, especially if regulator support has been added to a driver after the board was integrated. We can handle such situations more gracefully by providing a dummy regulator. Unless the caller has specifically indicated that the system design may not include a given regulator by using regulator_get_optional() or that it needs its interactions to have an effect using regulator_get_exclusive() provide a dummy regulator if we can't locate a real one. The kconfig option REGULATOR_DUMMY that provided similar behaviour for all regulators has been removed, systems that need it should flag that they have full constraints instead. Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'regulator/topic/fixed' into regulator-nextMark Brown2013-10-241-1/+4
|\ \
| * | regulator: core: provide fixed voltage in desc for single voltage railLaxman Dewangan2013-09-101-1/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | If given rail has the single voltage (n_voltages = 1) then provide the rail voltage through regulator descriptor so that core can use this value for finding voltage. This will avoid the implementation of the callback for get_voltage() or list_voltage() callback on regulator driver. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown2013-10-241-6/+70
|\ \
| * | regulator: core: Reduce busy-wait loopingThierry Reding2013-09-301-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep busy-wait looping to a minimum while waiting for a regulator to ramp-up to the target voltage. This follows the guidelines set forth in Documentation/timers/timers-howto.txt and assumes that regulators are never enabled in atomic context. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: Fix return code for invalid parametersMark Brown2013-09-231-1/+1
| | | | | | | | | | | | | | | | | | We should be returning an error, a repeated call will never succeed. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: set current constraints while setting machine constraintsLaxman Dewangan2013-09-201-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Machine constraints is configured during regulator register. If current constraints are provided through machine constraints then it is observed that sometime the current configured on rail is out of range what machine constraint has. Set the current constraints when setting machine constraints to make sure that rail's current is within the range of given machine constraints. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: add support for configuring turn-on time through constraintsLaxman Dewangan2013-09-181-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The turn-on time of the regulator depends on the regulator device's electrical characteristics. Sometimes regulator turn-on time also depends on the capacitive load on the given platform and it can be more than the datasheet value. The driver provides the enable-time as per datasheet. Add support for configure the enable ramp time through regulator constraints so that regulator core can take this value for enable time for that regulator. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Add ability to create a lookup alias for supplyCharles Keepax2013-10-181-0/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | These patches add the ability to create an alternative device on which a lookup for a certain supply should be conducted. A common use-case for this would be devices that are logically represented as a collection of drivers within Linux but are are presented as a single device from device tree. It this case it is necessary for each sub device to locate their supply data on the main device. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Split devres code out into a separate fileMark Brown2013-09-171-251/+1
| | | | | | | | | | | | | | | | Cut down on the size of core.c a bit more and ensure that the devres versions of things don't do too much peering inside the internals of the APIs they wrap. Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Refactor devm_regulator_get* APIsAxel Lin2013-09-171-65/+62
| | | | | | | | | | | | | | | | | | | | | | | | The implementation of devm_regulator_get, devm_regulator_get_exclusive and devm_regulator_get_optional are almost the same. Introduce _devm_regulator_get helper function and refactor the code. Also move devm_regulator_get_exclusive to proper place, put it after regulator_get_exclusive() function. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Fix a trivial typoSachin Kamat2013-09-171-1/+1
| | | | | | | | | | | | | | Changed automaticall -> automatically. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Provide managed regulator registrationMark Brown2013-09-171-0/+66
|/ | | | | | | | | Many regulator drivers have a remove function that consists solely of calling regulator_unregister() so provide a devm_regulator_register() in order to allow this repeated code to be removed and help eliminate error handling code. Signed-off-by: Mark Brown <broonie@linaro.org>
* Merge remote-tracking branch 'regulator/topic/ramp' into regulator-nextMark Brown2013-09-011-3/+4
|\
| * regulator: core: Remove redundant checksYadwinder Singh Brar2013-07-151-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In function _regulator_do_set_voltage(), old_selector gets intialised only if (_regulator_is_enabled(rdev) && rdev->desc->ops->set_voltage_time_sel && rdev->desc->ops->get_voltage_sel)) is true. Before calling set_voltage_time_sel() we checks if (old_selector >= 0) and it will true if it got intialised properly. so we don't need to check again _regulator_is_enabled(rdev) && rdev->desc->ops->set_voltage_time_sel before calling set_voltage_time_sel(). Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * regulator: core: Add support for disabling ramp delayYadwinder Singh Brar2013-07-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | Some hardwares support disabling ramp delay, so adding ramp_disable flag to constraints. It will be used to figure out whether ramp_delay in constraints is explicitly set to zero or its unintialized (zero by default). And we don't need to call set_voltage_time_sel() for regulators for whom ramp delay is disabled in constraints. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'regulator/topic/optional' into regulator-nextMark Brown2013-09-011-0/+89
|\ \
| * | regulator: Add devm_regulator_get_exclusive()Matthias Kaehlcke2013-08-291-0/+30
| | | | | | | | | | | | | | | | | | | | | Add a resource managed regulator_get_exclusive() Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: Provide hints to the core about optional suppliesMark Brown2013-07-311-0/+59
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the majority of supplies on devices are mandatory and can't be physically omitted for electrical reasons some devices do have optional supplies and need to know if they are missing, MMC being the most common of these. Currently the core accurately reports all errors when regulators are requested since it does not know if the supply is one that must be provided even if by a regulator software does not know about or if it is one that may genuinely be disconnected. In order to allow this behaviour to be changed and stub regulators to be provided in the former case add a new regulator request function regulator_get_optional() which provides a hint to the core that the regulator may genuinely not be connected. Currently the implementation is identical to the current behaviour, future patches will add support in the core for returning stub regulators in the case where normal regulator_get() fails and the board has requested it. Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Chris Ball <cjb@laptop.org>
* | Merge remote-tracking branch 'regulator/topic/helpers' into regulator-nextMark Brown2013-09-011-427/+0
|\ \
| * | regulator: core: Move list_voltage_{linear,linear_range,table} to helpers.cAxel Lin2013-08-091-86/+0
| | | | | | | | | | | | | | | | | | | | | | | | Move regulator_list_voltage_{linear,linear_range,table} helper functions to helpers.c. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: Move helpers for drivers out into a separate fileMark Brown2013-08-071-341/+0
| | | | | | | | | | | | | | | | | | Reduce the size of core.c a bit. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | Merge remote-tracking branch 'regulator/topic/linear-range' into ↵Mark Brown2013-08-071-0/+95
| |\ \ | | | | | | | | | | | | regulator-helpers
* | \ \ Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown2013-09-011-18/+26
|\ \ \ \ | |_|/ / |/| | |
| * | | regulator: core: Use bool for exclusivitity flagMark Brown2013-08-181-3/+3
| |/ / | | | | | | | | | | | | | | | Just for neatness. Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: convert class code to use dev_groupsGreg Kroah-Hartman2013-07-251-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | The dev_attrs field of struct class is going away soon, dev_groups should be used instead. This converts the regulator class code to use the correct field. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Mark Brown <broonie@linaro.org>
| * | regulator: core: Use the power efficient workqueue for delayed powerdownMark Brown2013-07-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no need to use a normal per-CPU workqueue for delayed power downs as they're not timing or performance critical and waking up a core for them would defeat some of the point. Signed-off-by: Mark Brown <broonie@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Liam Girdwood <liam.r.girdwood@intel.com>
| * | regulator: core: Drop references on supply regulator when unregisteringMark Brown2013-07-151-1/+4
| |/ | | | | | | Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Ensure selector is mappedMark Brown2013-07-181-0/+2
| | | | | | | | | | | | Clearly the testing only covered the bottom range. Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Allow fixed voltage range in multiple linear rangesAxel Lin2013-07-181-3/+9
| | | | | | | | | | | | | | | | | | | | | | Current code does not allow fixed voltage range in multiple linear ranges. If someone does set range->uV_step == 0 in one of the linear ranges, we hit divided by zero bug. This patch fixes this issue. For fixed voltage range, return any selector means the same voltage. Thus just return 0. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | regulator: core: Add helpers for multiple linear rangesMark Brown2013-07-151-0/+87
|/ | | | | | | | | | | | | Many regulators have several linear ranges of selector with different step sizes, for example offering better resolution at lower voltages. Provide regulator_{map,list}_voltage_linear_range() allowing these regulators to use generic code. To do so a table of regulator_linear_range structs needs to be pointed to from the descriptor. This was inspired by similar code included in a driver submission from Chao Xie and Yi Zhang at Marvell. Signed-off-by: Mark Brown <broonie@linaro.org>
* Merge remote-tracking branch 'regulator/topic/linar' into regulator-nextMark Brown2013-07-011-0/+15
|\
| * regulator: core: add regulator_get_linear_step()Paul Walmsley2013-06-071-0/+15
| | | | | | | | | | | | | | | | | | | | | | Add regulator_get_linear_step(), which returns the voltage step size between VSEL values for linear regulators. This is intended for use by regulator consumers which build their own voltage-to-VSEL tables. Signed-off-by: Paul Walmsley <pwalmsley@nvidia.com> Reviewed-by: Andrew Chew <achew@nvidia.com> Cc: Matthew Longnecker <mlongnecker@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
* | Merge remote-tracking branch 'regulator/fix/doc' into regulator-linusMark Brown2013-05-301-1/+4
|\ \
| * | regulator: Fix kernel-doc generation warnings.Robert P. J. Day2013-05-021-1/+4
| |/ | | | | | | | | | | | | | | Add a couple kernel-doc lines to get rid of kernel-doc generation warnings, no functional change. Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | regulator: core: Correct spelling mistake in commentCharles Keepax2013-05-211-1/+1
|/ | | | | Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* Merge remote-tracking branch 'regulator/topic/gpio' into v3.9-rc8Mark Brown2013-04-281-19/+123
|\
| * regulator: core: use regulator_ena_pin memberKim, Milo2013-03-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The regulator_dev has regulator_enable_gpio structure. 'ena_gpio' and 'ena_gpio_invert' were moved to in regulator_enable_gpio. regulator_dev ---> regulator_enable_gpio .ena_gpio .gpio .ena_gpio_invert .ena_gpio_invert Pointer, 'ena_pin' is used for checking valid enable GPIO pin. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Reviewed-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regulator: core: manage enable GPIO listKim, Milo2013-03-041-6/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support shared enable GPIO pin, replace GPIO code with new static functions Reference count: 'enable_count' Balance the reference count of each GPIO and actual pin control. The count is incremented with enabling GPIO. On the other hand, it is decremented on disabling GPIO. Actual GPIO pin is enabled at the initial use.(enable_count = 0) The pin is disabled if it is not used(shared) any more. (enable_count <=1) Regardless of the enable count, update GPIO state of the regulator. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Reviewed-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| * regulator: core: support shared enable GPIO conceptKim, Milo2013-03-041-10/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A Regulator can be enabled by external GPIO pin. This is configurable in the regulator_config. At this moment, the GPIO can be owned by only one regulator device. In some devices, multiple regulators are enabled by shared one GPIO pin. This patch extends this limitation, enabling shared enable GPIO of regulators. New list for enable GPIO: 'regulator_ena_gpio_list' This manages enable GPIO list. New structure for supporting shared enable GPIO: 'regulator_enable_gpio' The enable count is used for balancing GPIO control count. This count is incremented when GPIO is enabled. On the other hand, it's decremented when GPIO is disabled. Reference count: 'request_count' The reference count, 'request_count' is incremented/decremented on requesting/freeing the GPIO. This count makes sure only free the GPIO when it has no users. How it works If the GPIO is already used, skip requesting new GPIO usage. The GPIO is new one, request GPIO function and add it to the list of enable GPIO. This list is used for balancing enable GPIO count and pin control. Updating a GPIO and invert code moved 'ena_gpio' and 'ena_gpio_invert' of the regulator_config were moved to new function, regulator_ena_gpio_request(). Use regulator_enable_pin structure rather than regulator_dev. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Reviewed-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | Merge remote-tracking branch 'regulator/topic/enable-invert' into v3.9-rc8Mark Brown2013-04-281-4/+20
|\ \
OpenPOWER on IntegriCloud