11 Dec, 2018
12 commits
-
The GPIO descriptors used by the DA9211 driver are retrieved
during probe() and it is really helpful to have those under
devres management because of all the errorpaths in the
intialization.Using the new dev_gpiod_unhinge() call we can remove the
devres management of the descriptor right before handing
it over to the regulators core.Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
The probe path of this driver is a bit complex: sometimes the
GPIO descriptor is passed to the regulator core, sometimes
it is not.To handle it in a simple way: stick with the devm_* resource
management and unhinge the GPIO descriptor devres handling
right before passing it to the regulator core, if we pass it
to the regulator core.Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
This adds a function named devm_gpiod_unhinge() that removes
the resource management from a GPIO descriptor.I am not sure if this is the best anglosaxon name for the
function, no other managed resources have an equivalent
currently, but I chose "unhinge" as the closest intuitive
thing I could imagine that fits Rusty Russell's API design
criterions "the obvious use is the correct one" and
"the name tells you how to use it".The idea came out of a remark from Mark Brown that it should
be possible to handle over management of a resource from
devres to the regulator core, and indeed we can do that.Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
When we get a nonexeclusive GPIO descriptor using managed
resources, we should only add it to the list of managed
resources once: on the first user. Augment the
devm_gpiod_get_index() and devm_gpiod_get_from_of_node()
calls to account for this by checking if the descriptor
is already resource managed before we proceed to allocate
a new resource management struct.Fixes: b0ce7b29bfcd ("regulator/gpio: Allow nonexclusive GPIO access")
Reported-by: Marek Szyprowski
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
This makes gpiod_get_from_of_node() respect the
GPIOD_FLAGS_BIT_NONEXCLUSIVE flag which is especially
nice when getting regulator GPIOs right out of device
tree nodes.Suggested-by: Marek Szyprowski
Fixes: b0ce7b29bfcd ("regulator/gpio: Allow nonexclusive GPIO access")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
Use the gpiod_get_from_of_node() rather than the devm_*
version so that the regulator core can handle the lifecycle
of these descriptors.Fix up the errorpath so that we free this descriptor if
an error occurs in the callback. Rely on the regulator
core to deal with it after this point: a previous patch
fixed up the regulator core to properly dispose any
GPIO descriptors once you call regulator_register().Fixes: 96392c3d8ca4 ("regulator: max77686: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
This function already exist inside gpiolib, we were just
reluctant to make it available to the kernel at large as
the devm_* seemed to be enough for anyone.However we found out that regulators need to do their own
lifecycle/refcounting on GPIO descriptors and explicitly
call gpiod_put() when done with a descriptor, so export
this function so we can hand the refcounting over to the
regulator core for these descriptors after retrieveal.Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
Use the gpiod_get() rather than the devm_* version so that the
regulator core can handle the lifecycle of these descriptors.Fixes: d7a261c2d1f2 ("regulator: max8952: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
Use the gpiod_get() rather than the devm_* version so that the
regulator core can handle the lifecycle of these descriptors.Fixes: 2468f0d51548 ("regulator: lp8788-ldo: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
Use the gpiod_get() rather than the devm_* version so that the
regulator core can handle the lifecycle of these descriptors.Fixes: b2d751b7f69b ("regulator: lm363x: Pass descriptor instead of GPIO number")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
Use the gpiod_get() rather than the devm_* version so that the
regulator core can handle the lifecycle of these descriptors.Fixes: efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only")
Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown -
If a GPIO descriptor is passed to the regulator_register()
function inside the config->ena_gpiod callers must be
sure that once they call this API the regulator core
owns that descriptor and will make sure to issue
gpiod_put() on it, no matter whether the call is
successful or not.For device tree regulators, the regulator core will
automatically set up regulator init data from the device
tree when registering a regulator by calling
regulator_of_get_init_data() which in turn calls down to
the regulator driver's .of_parse_cb() callback.
This callback (in drivers such as for max77686) may also
choose to fill in the config->ena_gpiod field with a GPIO
descriptor.Harden the errorpath of regulator_register() to
properly gpiod_put() any passed in cfg->ena_gpiod
or any gpiod coming from the device tree on any type
of error.Signed-off-by: Linus Walleij
Reviewed-by: Marek Szyprowski
Tested-by: Marek Szyprowski
Reviewed-by: Charles Keepax
Signed-off-by: Mark Brown
07 Dec, 2018
1 commit
-
Convert string compares of DT node names to use of_node_name_eq helper
instead. This removes direct access to the node name pointer.For instances using of_node_cmp, this has the side effect of now using
case sensitive comparisons. This should not matter for any FDT based
system which all of these are.Cc: Liam Girdwood
Cc: Mark Brown
Cc: Support Opensource
Cc: Sangbeom Kim
Cc: Krzysztof Kozlowski
Cc: Bartlomiej Zolnierkiewicz
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Rob Herring
Acked-by: Adam Thomson
Signed-off-by: Mark Brown
05 Dec, 2018
2 commits
-
Currently it is expected that regulator init data will be defined as a
series of sub-nodes from the node that bound in the driver. Add support
for a node to both bind in a driver and contain init data for that
regulator.Signed-off-by: Charles Keepax
Signed-off-by: Mark Brown -
To support future additions factor out the location of the OF node
containing the init data for the regulator from the code that parses the
init data.Signed-off-by: Charles Keepax
Signed-off-by: Mark Brown
03 Dec, 2018
1 commit
-
fix a compilation issue due to regulator_lock usage.
Signed-off-by: Pascal Paillet
Signed-off-by: Mark Brown
27 Nov, 2018
1 commit
-
Prior to commit 5451781dadf8 ("regulator: core: Only count load for
enabled consumers") we used to always add up the total load on every
enable in _regulator_enable(). After that commit we only updated the
total load when enabling / disabling a regulator where a consumer
specified a load or when changing the consumer load on an enabled
regulator.The problem with the new scheme is that if there is a system load
specified for a regulator but no consumers specify a load then we
never account for it.Let's account for the system load in set_machine_constraints().
NOTE: with the new scheme we end up with a bit of a quandry. What if
someone specifies _both_ an initial mode and a system load? If we
take the system load into account right at init time then it will
effectively clobber the initial mode. We'll resolve this by saying
that if both are specified then the initial mode will win. The system
load will then only take effect if/when a consumer specifies a load.
If no consumers ever specify a load then the initial mode will persist
and the system load will have no effect.Fixes: 5451781dadf8 ("regulator: core: Only count load for enabled consumers")
Reported-by: Brian Masney
Signed-off-by: Douglas Anderson
Tested-by: Brian Masney
Signed-off-by: Mark Brown
22 Nov, 2018
3 commits
-
Address remaining comments from original driver patch series
* Move RD_FIFO_CFG to be ordered corretly
* Expand spinlock commentSigned-off-by: Ryan Case
Reviewed-by: Stephen Boyd
Reviewed-by: Douglas Anderson
Signed-off-by: Mark Brown -
When we called regulator_enable() on a regulator we'd end up
propagating that call all the way up the chain every time. This is a
bit of a waste of time. A child regulator already refcounts its own
enables so it should avoid passing on to its parent unless the
refcount transitioned between 0 and 1.Historically this hasn't been a huge problem since we skipped dealing
with enable for always-on regulators. In a previous patch, however,
we removed the always-on optimization. On one system, the debugfs
regulator_summary was now showing a "use_count" of 33 for a top-level
regulator.Let's implement this optimization. This turns out to be fairly
trivial with the recent reorganization of the regulator core.NOTE: as part of this patch I'll make "always-on" regulators start
with a use count of 1. This keeps the counts clean when recursively
resolving regulators.ALSO NOTE: this commit also contains somewhat of a bug fix to
regulator_force_disable(). It was incorrectly looping over
"rdev->open_count" when it should have been looping over use_count.
We have to touch that code anyway (since we should no longer loop at
all), so we'll fix it together in one patch. Also: since this comes
after commit f8702f9e4aa7 ("regulator: core: Use ww_mutex for
regulators locking") we can now move to use _regulator_disable() for
our supply and keep it in the lock.Signed-off-by: Douglas Anderson
Signed-off-by: Mark Brown -
In general when the consumer of a regulator requests that the
regulator be disabled it no longer will be drawing much load from the
regulator--it should just be the leakage current and that should be
very close to 0.Up to this point the regulator framework has continued to count a
consumer's load request for disabled regulators. This has led to code
patterns that look like this:enable_my_thing():
regular_set_load(reg, load_uA)
regulator_enable(reg)disable_my_thing():
regulator_disable(reg)
regulator_set_load(reg, 0)Sometimes disable_my_thing() sets a nominal (
Signed-off-by: Mark Brown
21 Nov, 2018
2 commits
-
The regulator core takes over managing the lifetime of the enable GPIO
once the regulator is registered. As such we shouldn't register the
enable GPIO using devm, or it will be freed twice.Reported-by: Marek Szyprowski
Signed-off-by: Charles Keepax
Tested-by: Marek Szyprowski
Signed-off-by: Mark Brown -
The "requested_microamps" sysfs attribute was only being exposed for
"current" regulators. This didn't make sense. Allow it to be exposed
always.Signed-off-by: Douglas Anderson
Signed-off-by: Mark Brown
20 Nov, 2018
3 commits
-
Lochnagar is an evaluation and development board for Cirrus
Logic Smart CODEC and Amp devices. It allows the connection of
most Cirrus Logic devices on mini-cards, as well as allowing
connection of various application processor systems to provide a
full evaluation platform. This driver supports the board
controller chip on the Lochnagar board.Signed-off-by: Charles Keepax
Signed-off-by: Mark Brown -
Based on review comments on the MFD driver, move the child drivers for
the Lochnagar MFD over to binding through device tree.Signed-off-by: Charles Keepax
Signed-off-by: Mark Brown -
GPIO descriptor array must be zero initialized to ensure that core will
properly handle also the case when no external GPIO pin is defined.Fixes: 1c984942f0a4 ("regulator: s2mps11: Pass descriptor instead of GPIO number")
Signed-off-by: Marek Szyprowski
Reviewed-by: Krzysztof Kozlowski
Signed-off-by: Mark Brown
19 Nov, 2018
5 commits
-
…broonie/regulator into regulator-4.21 for trivial conflict
-
Redefine binding for regulator-coupled-max-spread property in a way that
max-spread values are defined per regulator couple instead of defining
single max-spread for the whole group of coupled regulators.With that change the following regulators coupling configuration will be
possible:regA: regulatorA {
regulator-coupled-with = ;
regulator-coupled-max-spread = ;
};regB: regulatorB {
regulator-coupled-with = ;
regulator-coupled-max-spread = ;
};regC: regulatorC {
regulator-coupled-with = ;
regulator-coupled-max-spread = ;
};Note that the regulator-coupled-max-spread property does not have any
users yet, hence it's okay to change the binding.Signed-off-by: Dmitry Osipenko
Signed-off-by: Mark Brown -
It's unlikely that regulators may disappear/appear while regulators
debug-summary is being prepared, but let's be consistent and avoid that
situation.Signed-off-by: Dmitry Osipenko
Signed-off-by: Mark Brown -
Check whether supply regulator is the couple to avoid infinite recursion
during of locking.Signed-off-by: Dmitry Osipenko
Signed-off-by: Mark Brown -
Wait/wound mutex shall be used in order to avoid lockups on locking of
coupled regulators.Signed-off-by: Dmitry Osipenko
Suggested-by: Lucas Stach
Signed-off-by: Mark Brown
16 Nov, 2018
4 commits
-
when the VIR_LDO1 regulator supplier is it's brother,
we can't find the supplier.example code :
&vir_regulator {
ldo0_vir: ldo0-virtual {
regulator-compatible = "VIR_LDO0";
regulator-name= "VIR_LDO0";
regulator-min-microvolt = ;
regulator-max-microvolt = ;
};
ldo1_vir: ldo1-virtual {
regulator-compatible = "VIR_LDO1";
regulator-name= "VIR_LDO1";
regulator-min-microvolt = ;
regulator-max-microvolt = ;
ldo1-supply = ;
};
...
}so we add the child ptah to find the suppier.
Signed-off-by: zoro
Signed-off-by: Mark Brown -
Instead of passing a global GPIO number, pass a descriptor looked
up from the device tree configuration node.Tested on Odroid U3 (with max77686 although not using any GPIOs
for regulators, so at least default paths are not broken).Cc: Chanwoo Choi
Cc: Krzysztof Kozlowski
Cc: Bartlomiej Zolnierkiewicz
Reviewed-by: Krzysztof Kozlowski
Tested-by: Krzysztof Kozlowski
Signed-off-by: Linus Walleij
Signed-off-by: Mark Brown -
Instead of passing a global GPIO number for the enable GPIO, pass
a descriptor looked up from the device tree node or the board file
decriptor table for the regulator.There is a single board file passing the GPIOs for LDO1 and LDO2
through platform data, so augment this to pass descriptors
associated with the i2c device as well.The special GPIO enable DT property for the enable GPIO is
nonstandard but this was accomodated in
commit 6a537d48461deacc57c07ed86d9915e5aa4b3539
"gpio: of: Support regulator nonstandard GPIO properties".Cc: patches@opensource.cirrus.com
Acked-by: Charles Keepax
Acked-by: Lee Jones
Signed-off-by: Linus Walleij
Signed-off-by: Mark Brown -
Instead of passing a global GPIO number for the enable GPIO, pass
a descriptor looked up with the standard devm_gpiod_get_optional()
call.This regulator supports passing platform data, but enable/sleep
regulators are looked up from the device tree exclusively, so
we can need not touch other files.Tested on Odroid XU3 (with s2mps11 although not using any GPIOs
for regulators, so at least default paths are not broken).Cc: Sangbeom Kim
Cc: Chanwoo Choi
Cc: Bartlomiej Zolnierkiewicz
Cc: Krzysztof Kozlowski
Reviewed-by: Krzysztof Kozlowski
Tested-by: Krzysztof Kozlowski
Signed-off-by: Linus Walleij
Signed-off-by: Mark Brown
14 Nov, 2018
6 commits
-
BD71837 and BD71847 have a HW functionality which leave power
rails OFF after powerof state:
- if they have been controlled by SW.
- if state transition from poweroff is done to SNVSBD71837 can after reset transition from power-off to SNVS or
READY state depending on reset reason. By default only wathcdog
reset changes state from poweroff to ready. Change PMIC
configuration to always transition to READY in order to avoid
crucial power rails being OFF after reset.If SNVS is required the crucial power rails should not be
controlled by SW - eg corresponding regulator control register
should have SEL bit kept zero. Currently the driver assumes all
regulators to be controlled by SW so it sets all SEL bits to 1.Signed-off-by: Matti Vaittinen
Signed-off-by: Mark Brown -
This patch updates license to use SPDX-License-Identifier
instead of verbose license text.Signed-off-by: Kuninori Morimoto
Signed-off-by: Mark Brown -
This patch updates license to use SPDX-License-Identifier
instead of verbose license text.Signed-off-by: Kuninori Morimoto
Signed-off-by: Mark Brown -
The voltages in bd718xx_3rd_nodvs_buck_volts are in ascendant order, so use
regulator_map_voltage_ascend.Signed-off-by: Axel Lin
Signed-off-by: Mark Brown -
Set the according constraints for PM_SUSPEND_STANDBY case.
Previously, only suspend to mem/disk were taken into
consideration.Signed-off-by: Andrei Stefanescu
Signed-off-by: Mark Brown -
For state-mem and state-disk regulators can have
various parameters applied such as enabled/disabled,
current mode, voltage etc.This patch adds documentation on how to set these parameters
in the device tree for the standby state.Signed-off-by: Andrei Stefanescu
Signed-off-by: Mark Brown