Commit graph

331 commits

Author SHA1 Message Date
Mark Brown 317b5684d5 regulator: core: Correct default return value for full constraints
Once we have full constraints then all supply mappings should be known to
the regulator API. This means that we should treat failed lookups as fatal
rather than deferring in the hope of further registrations but this was
broken by commit 9b92da1f12 "regulator: core: Fix default return
value for _get()" which was targeted at DT systems but unintentionally
broke non-DT systems by changing the default return value.

Fix this by explicitly returning -EPROBE_DEFER from the DT lookup if we
find a property but no corresponding regulator and by having the non-DT
case default to -ENODEV when we have full constraints.

Fixes: 9b92da1f12 "regulator: core: Fix default return value for _get()"
Signed-off-by: Mark Brown <broonie@linaro.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org
2014-01-28 11:37:43 +00:00
Jingoo Han 0d25d09de1 regulator: core: Fix checkpatch issue
Fix the following checkpatch errors and warnings.

  ERROR: trailing whitespace
  ERROR: return is not a function, parentheses are not required
  WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-01-08 17:13:57 +00:00
Hans de Goede 0781719bd6 regulator: core: don't print an error when no regulator is found
Only print an error when _regulator_get() is expected to return a valid
regulator, that is when _regulator_get() is called from regulator_get() and
we're not using the dummy because we don't have full-constraints, or when
_regulator_get() is called from regulator_get_exclusive() in which case
returning a dummy is not allowed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-12-17 22:59:15 +00:00
Mark Brown 334a82086d Merge remote-tracking branch 'regulator/topic/constraints' into regulator-linus 2013-12-13 13:44:57 +00:00
Mark Brown 75bc9641ca regulator: core: Check for DT every time we check full constraints
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>
2013-11-27 17:13:29 +00:00
Mark Brown 87b2841753 regulator: core: Replace checks of have_full_constraints with a function
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>
2013-11-27 16:39:16 +00:00
Guennadi Liakhovetski f446043f1a regulator: fixed: fix regulator_list_voltage() for regression
Commit c368e5fc2a "regulator: fixed:
get rid of {get|list}_voltage()" broke regulator_list_voltage() for
the fixed regulator, because an earlier commit
5a523605af "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>
2013-11-13 14:00:51 +00:00
Mark Brown aef393da75 Merge remote-tracking branch 'regulator/topic/optional' into regulator-next 2013-10-24 11:11:39 +01:00
Mark Brown 706664c290 Merge remote-tracking branch 'regulator/topic/fixed' into regulator-next 2013-10-24 11:11:36 +01:00
Mark Brown 81e439f476 Merge remote-tracking branch 'regulator/topic/core' into regulator-next 2013-10-24 11:11:33 +01:00
Charles Keepax a06ccd9c37 regulator: core: Add ability to create a lookup alias for supply
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>
2013-10-18 00:56:05 +01:00
Mark Brown 4040394e12 regulator: core: Always warn when using a dummy regulator
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>
2013-10-04 11:47:15 +01:00
Thierry Reding 5df529d440 regulator: core: Reduce busy-wait looping
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>
2013-09-30 11:43:12 +01:00
Mark Brown ef60abbb6b regulator: core: Always use return value when regulator_dev_lookup() fails
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>
2013-09-24 10:37:55 +01:00
Mark Brown 043c998f95 regulator: core: Fix return code for invalid parameters
We should be returning an error, a repeated call will never succeed.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-23 12:04:13 +01:00
Mark Brown 9b92da1f12 regulator: core: Fix default return value for _get()
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>
2013-09-20 17:38:44 +01:00
Laxman Dewangan f8c1700dd7 regulator: core: set current constraints while setting machine constraints
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>
2013-09-20 10:50:29 +01:00
Laxman Dewangan 00c877c69b regulator: core: add support for configuring turn-on time through constraints
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>
2013-09-18 17:13:02 +01:00
Mark Brown 4f0ac6dabf regulator: core: Remove unused regulator_use_dummy_regulator()
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>
2013-09-17 00:30:25 +01:00
Mark Brown 4ddfebd3b0 regulator: core: Provide a dummy regulator with full constraints
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>
2013-09-17 00:30:25 +01:00
Mark Brown 0cdfcc0f93 regulator: core: Split devres code out into a separate file
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>
2013-09-17 00:28:45 +01:00
Axel Lin cee8e35594 regulator: core: Refactor devm_regulator_get* APIs
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>
2013-09-17 00:28:44 +01:00
Sachin Kamat 42141f22e3 regulator: core: Fix a trivial typo
Changed automaticall -> automatically.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 00:28:44 +01:00
Mark Brown b33e46bcdc regulator: core: Provide managed regulator registration
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>
2013-09-17 00:27:53 +01:00
Laxman Dewangan 5a523605af regulator: core: provide fixed voltage in desc for single voltage rail
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>
2013-09-10 18:19:52 +01:00
Mark Brown a89f5c7598 Merge remote-tracking branch 'regulator/topic/ramp' into regulator-next 2013-09-01 13:50:20 +01:00
Mark Brown f27a5fb424 Merge remote-tracking branch 'regulator/topic/optional' into regulator-next 2013-09-01 13:50:17 +01:00
Mark Brown 724d054490 Merge remote-tracking branch 'regulator/topic/helpers' into regulator-next 2013-09-01 13:50:09 +01:00
Mark Brown 1ad13028e5 Merge remote-tracking branch 'regulator/topic/core' into regulator-next 2013-09-01 13:50:06 +01:00
Matthias Kaehlcke 9efdd27678 regulator: Add devm_regulator_get_exclusive()
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-29 19:38:33 +01:00
Mark Brown 84fcf447a9 regulator: core: Use bool for exclusivitity flag
Just for neatness.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-18 18:04:32 +01:00
Axel Lin d295f76701 regulator: core: Move list_voltage_{linear,linear_range,table} to helpers.c
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-09 11:45:02 +01:00
Mark Brown c4a54b8d54 regulator: core: Move helpers for drivers out into a separate file
Reduce the size of core.c a bit.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-08-07 16:32:00 +01:00
Mark Brown eca2a654b8 Merge remote-tracking branch 'regulator/topic/linear-range' into regulator-helpers 2013-08-07 11:05:04 +01:00
Mark Brown de1dd9fd21 regulator: core: Provide hints to the core about optional supplies
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-31 09:56:39 +01:00
Greg Kroah-Hartman 587cea27e4 regulator: core: convert class code to use dev_groups
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-25 10:30:24 +01:00
Mark Brown 6c918d2209 regulator: core: Ensure selector is mapped
Clearly the testing only covered the bottom range.

Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-18 16:06:33 +01:00
Axel Lin a56d66a2f0 regulator: core: Allow fixed voltage range in multiple linear ranges
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-18 15:55:09 +01:00
Mark Brown 070260f07c regulator: core: Use the power efficient workqueue for delayed powerdown
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-18 12:01:51 +01:00
Yadwinder Singh Brar 5b17595201 regulator: core: Remove redundant checks
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-15 11:27:48 +01:00
Yadwinder Singh Brar 1653ccf4c5 regulator: core: Add support for disabling ramp delay
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-15 11:27:48 +01:00
Mark Brown 94d33c02c7 regulator: core: Add helpers for multiple linear ranges
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-15 11:20:32 +01:00
Mark Brown 891636ea27 regulator: core: Drop references on supply regulator when unregistering
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-07-15 11:20:08 +01:00
Mark Brown 0a192cc860 Merge remote-tracking branch 'regulator/topic/linar' into regulator-next 2013-07-01 11:17:08 +01:00
Paul Walmsley 2a668a8bc2 regulator: core: add regulator_get_linear_step()
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-06-07 11:19:29 +01:00
Mark Brown 2a66a854f5 Merge remote-tracking branch 'regulator/fix/doc' into regulator-linus 2013-05-30 11:58:39 +01:00
Charles Keepax ce0d10f887 regulator: core: Correct spelling mistake in comment
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-05-21 10:35:40 -05:00
Robert P. J. Day 31d6eebf7e regulator: Fix kernel-doc generation warnings.
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-05-02 15:42:54 +01:00
Mark Brown 3dc06c1baf Merge remote-tracking branch 'regulator/topic/gpio' into v3.9-rc8 2013-04-28 02:13:40 +01:00
Mark Brown 1d60a4cf97 Merge remote-tracking branch 'regulator/topic/enable-invert' into v3.9-rc8 2013-04-28 02:13:37 +01:00