aboutsummaryrefslogtreecommitdiff
path: root/drivers/regulator/core.c
AgeCommit message (Collapse)Author
2013-09-01Merge remote-tracking branch 'regulator/topic/ramp' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/optional' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/helpers' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown
2013-08-29regulator: Add devm_regulator_get_exclusive()Matthias Kaehlcke
Add a resource managed regulator_get_exclusive() Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net> Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-18regulator: core: Use bool for exclusivitity flagMark Brown
Just for neatness. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-09regulator: core: Move list_voltage_{linear,linear_range,table} to helpers.cAxel Lin
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>
2013-08-07regulator: core: Move helpers for drivers out into a separate fileMark Brown
Reduce the size of core.c a bit. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-07Merge remote-tracking branch 'regulator/topic/linear-range' into ↵Mark Brown
regulator-helpers
2013-07-31regulator: core: Provide hints to the core about optional suppliesMark Brown
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>
2013-07-25regulator: core: convert class code to use dev_groupsGreg Kroah-Hartman
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>
2013-07-18regulator: core: Ensure selector is mappedMark Brown
Clearly the testing only covered the bottom range. Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-18regulator: core: Allow fixed voltage range in multiple linear rangesAxel Lin
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>
2013-07-18regulator: core: Use the power efficient workqueue for delayed powerdownMark Brown
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>
2013-07-15regulator: core: Remove redundant checksYadwinder Singh Brar
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>
2013-07-15regulator: core: Add support for disabling ramp delayYadwinder Singh Brar
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>
2013-07-15regulator: core: Add helpers for multiple linear rangesMark Brown
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>
2013-07-15regulator: core: Drop references on supply regulator when unregisteringMark Brown
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-01Merge remote-tracking branch 'regulator/topic/linar' into regulator-nextMark Brown
2013-06-07regulator: core: add regulator_get_linear_step()Paul Walmsley
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>
2013-05-30Merge remote-tracking branch 'regulator/fix/doc' into regulator-linusMark Brown
2013-05-21regulator: core: Correct spelling mistake in commentCharles Keepax
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-02regulator: Fix kernel-doc generation warnings.Robert P. J. Day
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>
2013-04-28Merge remote-tracking branch 'regulator/topic/gpio' into v3.9-rc8Mark Brown
2013-04-28Merge remote-tracking branch 'regulator/topic/enable-invert' into v3.9-rc8Mark Brown
2013-04-28Merge remote-tracking branch 'regulator/topic/core' into v3.9-rc8Mark Brown
2013-04-18regulator: core: Add regulator_map_voltage_ascend() APIAxel Lin
A lot of regulator hardware has ascendant voltage list. This patch adds regulator_map_voltage_ascend() and export it. Drivers that have ascendant voltage list can use this as their map_voltage() operation, this is more efficient than default regulator_map_voltage_iterate() function. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-17regulator: core: return err value for regulator_get if there is no DT bindingNishanth Menon
commit 6d191a5fc7a969d972f1681e1c23781aecb06a61 (regulator: core: Don't defer probe if there's no DT binding for a supply) Attempted to differentiate between regulator_get() with an actual DT binding for the supply and when there is none to avoid unnecessary deferal. However, ret value supplied by regulator_dev_lookup() is being ignored by regulator_get(). So, exit with the appropriate return value. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-04-05regulator: core: don't require a supply when supply_name is specifiedAndrew Bresticker
Regulator drivers may specify regulator_desc->supply_name which regulator_register() will use to find the supply node for a regulator. If no supply was specified in the device tree or the supply has yet to be registered regulator_register() will fail, deferring the probe of the regulator. In the case where no supply node was specified in the device tree, there is no supply and it is pointless to try and find one later, so go ahead and add the regulator without the supply. Signed-off-by: Andrew Bresticker <abrestic@chromium.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-25regulator: Fix typo in of_get_regulator function commentsMaxime Ripard
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-05regulator: core: Add enable_is_inverted flag to indicate set enable_mask ↵Axel Lin
bits to disable Add enable_is_inverted flag to indicate set enable_mask bits to disable when using regulator_enable_regmap and friends APIs. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-05Merge remote-tracking branch 'regulator/fix/doc' into tmpMark Brown
2013-03-04regulator: core: use regulator_ena_pin memberKim, Milo
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>
2013-03-04regulator: core: manage enable GPIO listKim, Milo
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>
2013-03-04regulator: core: support shared enable GPIO conceptKim, Milo
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>
2013-03-01regulator: fixed regulator_bulk_enable unwinding codeAndrzej Hajda
Unwinding code disables all successfully enabled regulators. Error is logged for every failed regulator. Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-01regulator: core: fix documentation error in regulator_allow_bypassNishanth Menon
commit f59c8f9f (regulator: core: Support bypass mode) has a short documentation error around the regulator_allow_bypass parameter 'enable' which is documented as 'allow'. This generates kernel-doc warning as follows: ./scripts/kernel-doc drivers/regulator/core.c >/dev/null Warning(drivers/regulator/core.c:2841): No description found for parameter 'enable' Warning(drivers/regulator/core.c:2841): Excess function parameter 'allow' description in 'regulator_allow_bypass' Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: linux-kernel@vger.kernel.org Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-02-19Merge remote-tracking branch 'regulator/topic/gpio' into regulator-nextMark Brown
2013-02-19Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown
2013-02-19Merge remote-tracking branch 'regulator/topic/apply' into regulator-nextMark Brown
2013-02-14regulator: Fix memory garbage dev_err printout.Russ Dill
commit dd8004af: 'regulator: core: Log when a device causes a voltage constraint fail', tried to print out some information about the check consumer min/max uV fixup, however, it uses a garbage pointer left over from list_for_each_entry leading to boot messages in the form: '[ 2.079890] <RANDOM ASCII>: Restricting voltage, 3735899821-4294967295uV' Because it references regulator->dev, it could potentially read memory from anywhere causing a panic. This patch instead uses rdev and the updated min/max uV values. Signed-off-by: Russ Dill <Russ.Dill@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-02-14Merge tag 'v3.8-rc7' into regulator-coreMark Brown
Linux 3.8-rc7
2013-02-08regulator: core: Optimize _regulator_do_set_voltage if voltage does not changeAxel Lin
Optimize _regulator_do_set_voltage() for the case selector is equal to old_selector. Since the voltage does not change, we don't need to call set_voltage_sel() and set_voltage_time_sel() in this case. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-02-04regulator: show state for GPIO-controlled regulatorsMichał Mirosław
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-01-03regulator: core: Fix comment for regulator_register()Axel Lin
regulator_register() does not return 0 on success, fix the comment. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-12-24regulator: core: Allow specify apply_[reg|bit] for regmap based voltage_sel ↵Axel Lin
operations Some DVM regulators needs to update apply_bit after setting vsel_reg to initiate voltage change on the output. This patch adds apply_reg and apply_bit to struct regulator_desc and update regulator_set_voltage_sel_regmap() to set apply_bit of apply_reg when apply_bit is set. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-12-24regulator: core: Fix continuous_voltage_range case in ↵Axel Lin
regulator_can_change_voltage Regulator drivers with continuous_voltage_range flag set allows not setting n_voltages. Thus if continuous_voltage_range is set, check the constraint range instead. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-12-15regulator: core: if voltage scaling fails, restore original voltage valuesPaolo Pisati
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com> Tested-by: Robert Nelson <robertcnelson@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-12-11Merge remote-tracking branch 'regulator/topic/change' into regulator-nextMark Brown
2012-12-11regulator: core: Fix logic to determinate if regulator can change voltageAxel Lin
Having a linear_min_sel setting means the first linear_min_sel selectors are invalid. We need to subtract linear_min_sel when use n_voltages to determinate if regulator can change voltage. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>