These regulator_ops variables should never change, make them const.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Since c32569e358 ("regulator: Use of_node_name_eq for node name
comparisons") Vivien reported the mc13892-regulator complaining about
not being able to find regulators.
This is because prior to that commit we used of_node_cmp() to compare
the regulator array passed from mc13892_regulators down to
mc13xxx_parse_regulators_dt() and they are all defined in uppercase
letters by the MC13892_*_DEFINE* macros, whereas they are defined as
lowercase in the DTS.
Fix this by using a lowercase regulator name to match the DT node name.
Fixes: c32569e358 ("regulator: Use of_node_name_eq for node name comparisons")
Reported-by: Vivien Didelot <vivien.didelot@gmail.com>
Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Tested-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Quite a lot of core work this time around, though not 100% successful.
We gained support for runtime mode changes thanks to David Collins and
improved support for write only regulators (ones where we can't read
back the configuration) from Douglas Anderson.
There's been quite a bit of work from Linus Walleij on converting from
specfying GPIOs by numbers to descriptors. Sadly the testing turned out
to be less good than we had hoped and so a lot of this had to be
reverted.
We also have the start of updates to use coupled regulators from Maciej
Purski, unfortunately there are further problems there so the last
couple of patches have been reverted.
We also have new drivers for BD71837 and SY8106A devices, SAW regulators
on Qualcomm SPMI and dropped support for some preproduction chips
that never made it to market from the AB8500 driver.
-----BEGIN PGP SIGNATURE-----
iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlsarcETHGJyb29uaWVA
a2VybmVsLm9yZwAKCRAk1otyXVSH0B4HB/9MFV/MK7Hw2hsVCX3qWTiH4tJ/X0MG
tGz1PfmbH0CJ9ly5g+rvCoT+1/s7BydKzi1cd1RHnimBv2U1XagwSny3LNEcJs2Q
pmhpGViakkQI/Y2h+u/j0Jk1nE+jTiKk+1ozUB7YnPekrGyQlf7TMhvKOLTvLKyX
56jdNxcW0MgSnXV2N6y4NpWhgvrQwvKjacTxV5iX7WP2rnK2WNFeG7Q859buhtI0
znRi+tO5hZsw5T44ickdPfotZn+i5o7MYLCkkaA2h1EwtpbYwVINfUjp3KtuyFhH
3B9GmCsjjN2Z2eInnkpzWfVXK2S1Vlp6+ka2FSs+U/4rVdd3Bw2KkblS
=Ftua
-----END PGP SIGNATURE-----
Merge tag 'regulator-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown:
"Quite a lot of core work this time around, though not 100% successful.
We gained support for runtime mode changes thanks to David Collins and
improved support for write only regulators (ones where we can't read
back the configuration) from Douglas Anderson.
There's been quite a bit of work from Linus Walleij on converting from
specfying GPIOs by numbers to descriptors. Sadly the testing turned
out to be less good than we had hoped and so a lot of this had to be
reverted.
We also have the start of updates to use coupled regulators from
Maciej Purski, unfortunately there are further problems there so the
last couple of patches have been reverted.
We also have new drivers for BD71837 and SY8106A devices, SAW
regulators on Qualcomm SPMI and dropped support for some preproduction
chips that never made it to market from the AB8500 driver"
* tag 'regulator-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (57 commits)
regulator: gpio: Revert
ARM: pxa, regulator: fix building ezx e680
regulator: Revert coupled regulator support again
regulator: wm8994: Fix shared GPIOs
regulator: max77686: Fix shared GPIOs
regulator: bd71837: BD71837 PMIC regulator driver
regulator: bd71837: Devicetree bindings for BD71837 regulators
regulator: gpio: Get enable GPIO using GPIO descriptor
regulator: fixed: Convert to use GPIO descriptor only
regulator: s2mps11: Fix boot on Odroid XU3
dt-bindings: qcom_spmi: Document SAW support
regulator: qcom_spmi: Add support for SAW
regulator: tps65090: Pass descriptor instead of GPIO number
regulator: s5m8767: Pass descriptor instead of GPIO number
regulator: pfuze100: Delete reference to ena_gpio
regulator: max8952: Pass descriptor instead of GPIO number
regulator: lp8788-ldo: Pass descriptor instead of GPIO number
regulator: lm363x: Pass descriptor instead of GPIO number
regulator: max8973: Pass descriptor instead of GPIO number
regulator: mc13xxx-core: Switch to SPDX identifier
...
Adopt the SPDX license identifier headers to ease license compliance
management.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Commit 272e2315fa ("regulator: core: add const qualifier to ops in
struct regulator_desc") introduced const qualifier to ops in regulator_desc.
This patch adds 'const' to regulator_ops vars in newly added core APIs
for v3.17-rc1:
- regulator_get_hardware_vsel_register()
- regulator_list_hardware_vsel()
This patch also fix a build error in mc13892-regulator.c due to const
regulator_desc.ops. Modification of regulator_desc.ops' member fields is not
allowed.
Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Fix the following checkpatch warnings.
WARNING: Avoid unnecessary line continuations
WARNING: line over 80 characters
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
devm_* simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Since 0998d06310 "device-core: Ensure drvdata = NULL when no driver is bound",
this is done by driver core after device_release or on probe failure.
Thus we can remove all platform_set_drvdata(pdev, NULL) in drivers.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
It is necessary to clear MC13892_SWITCHERS0_SWxHI bit when set voltage to the
voltage range from 1100000 to 1375000. Leaving MC13892_SWITCHERS0_SWxHI bit
untouched may result in wrong voltage setting.
For example, currently switch voltage from 1400000 to 1300000 will set the
voltage to 1800000 because the HI bit is still set.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@sirena.org.uk>
This patch adds a warning about incorrect regulators instead of
printing the names of non-information message about the wrong amount.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Mark Brown <broonie@sirena.org.uk>
Both mc13892_sw1 and mc13892_sw voltage table have ascendant voltage list.
Use regulator_map_voltage_ascend for them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Imagine a situation where a device tree has a few regulators in an
appropriate node:
regulators {
sw1 {
..
};
vvideo {
..
};
:
vfake {
..
};
vtypo {
..
};
};
In the above example, the node name "vfake" is an attempt to match a
regulator name inside the driver which just so happens to not exist. The
node name "vtypo" represents an accidental typographical error in a
regulator name which may have been introduced to a device tree.
In these cases, the number of regulators the mc13892 driver thinks it has
does not match the number of regulators it parsed and registered. Since
it will go over this array based on this number, it will actually
re-register regulator "0" (which happens to be SW1) over and over
again until it reaches the number, resulting in messages on the kernel
log such as these:
SW1: at 1100 mV
VVIDEO: at 2775mV
:
SW1: at 1100 mV
SW1: at 1100 mV
.. up to that number of "mismatched" regulators. Nobody using DT can/will
consume these regulators, so it should not be possible for it to cause any
real regulator problems or driver breakages, but it is an easy thing to
miss in a kernel log and is an immediate indication of a problem with the
device tree authoring.
This patch effectively sanity checks the number of counted children of
the regulators node vs. the number that actually matched driver names,
and sets the appropriate num_regulators value. It also gives a little
warning for device tree authors that they MAY have screwed something up,
such that this patch does not hide the device tree authoring problem.
Signed-off-by: Matt Sealey <matt@genesi-usa.com>
Tested-by: Steev Klimaszewski <steev@genesi-usa.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
MC13892 PMIC supports a "HI" bit for 3 of it's 4 buck switcher outputs,
which enables a higher set of voltage ranges.
Despite a comment in the code ('sw regulators need special care due to the
"hi" bit'), it actually does not take special care since it does not modify
it's use of the selector table index when this bit is set, giving us very
odd behavior when setting a high voltage on supported switchers or listing
current voltages. Net effect is in best case the kernel and sysfs report
lower voltages than are actually set in hardware (1300mV instead of 1800mV
for example) and in the worst case setting a voltage (e.g. 1800mV) will cause
an undervoltage condition (e.g. 1300mV).
Correct the behavior, taking into account SW1 doesn't support the HI bit,
and as such we need to ignore it.
While we are modifying these functions, fix and optimize the following;
* set_voltage_sel callback was using .reg instead of .vsel_reg - since
they were set to the same value it actually didn't break anything but
it would be semantically incorrect to use .reg in this case. We now use
.vsel_reg and be consistent.
* vsel_shift is always 0 for every SWx regulator, and constantly shifting
and masking off the bottom few bits is time consuming and makes the
code very hard to read - optimize this out.
* get_voltage_sel uses the variable "val" and set_voltage_sel uses the
variable "selector" (and reg_value). Introduce the variable "selector"
to get_voltage_sel such that it makes more sense and allow some leaner
code in light of the modifications in this patch. Add better exposure
to the debug print so the register value AND the selector are printed as
this will adequately show the HI bit in the register.
* correct a comment in probe which is doing a version check. Magic
values are awful but for once instance, a comment does just as
good a job as something symbolic.
Signed-off-by: Matt Sealey <matt@genesi-usa.com>
Tested-by: Steev Klimaszewski <steev@genesi-usa.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This is not required after commit f7df20ec
"regulator: core: Use list_voltage() to read single voltage regulators"
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Use mc13xxx_reg_rmw rather than a mc13xxx_reg_read and a mc13xxx_reg_write calls.
This logic to set MC13892_SWITCHERS0_SWxHI bit is pretty simple:
if (volt > 1375000)
set MC13892_SWITCHERS0_SWxHI bit
else if (volt < 1100000)
clear MC13892_SWITCHERS0_SWxHI bit
else
leave MC13892_SWITCHERS0_SWxHI bit untouched
We already know the selector, so we don't need to calculate the selector again.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Then we can remove lock/unlock around the caller.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
If .is_enabled callback is not implemented, regulator core assumes that the
regulator is always on. Thus we don't need mc13xxx_sw_regulator_is_enabled
function.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Convert mc13783 and mc13892 to use a struct to pass in regulator runtime
configuration.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Convert mc13892_sw_regulator_ops and mc13xxx_regulator_ops to set_voltage_sel.
mc13xxx_get_best_voltage_index function is not used now, remove it.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
We do not hold a lock while registering regulator, thus should not call unlock
if regulator_register fails.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Convert mc13892-regulator driver to use devm_kzalloc().
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
It adds device tree probe support for mc13892-regulator driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
With device tree support for regulators, its needed that the
regulator_dev->dev device has the right of_node attached.
To be able to do this add an additional parameter to the
regulator_register() api, wherein the dt-adapted driver can
then pass this additional info onto the regulator core.
Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Another group of drivers that are taking advantage of the implicit
presence of module.h -- and will break when we pull the carpet out
from under them during a cleanup. Fix 'em now.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Voltage values should be expressed in microvolts, not in milivolts.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Ranjani Vaidyanathan <ra5478@freescale.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
I check this patch again and found this actually is not a bug
because MC13xxx_DEFINE explictly defines the order of each entry in the array.
Thus revert the patch.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Currently, we call mc13xxx_reg_read and mc13xxx_reg_rmw for the same register.
This can be converted to simply a mc13xxx_reg_read and a mc13xxx_reg_write,
thus save a redundant register read.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
In include/linux/mfd/mc13892.h, we define MC13892_VCOINCELL as 23.
Thus VCOINCELL should be defined as 23th element in mc13892_regulators array, not the first one.
This actually fixes an off-by-one bug while accessing mc13892_regulators array.
For example,
In mc13892_regulator_probe, we use MC13892_VCAM as array index of mc13892_regulators array.
mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
= mc13892_vcam_set_mode;
Currently, it access mc13892_regulators[12] ,which is VAUDIO not VCAM.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
With the addition of a platform device mfd_cell pointer, MFD drivers
can go back to passing platform data back to their sub drivers.
This allows for an mfd_cell->mfd_data removal and thus keep the
sub drivers MFD agnostic. This is mostly needed for non MFD aware
sub drivers.
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
The cell's platform_data is now accessed with a helper function;
change clients to use that, and remove the now-unused data_size.
Note that mfd-core no longer makes a copy of platform_data, but the
mc13xxx-core driver creates the pdata structures on the stack. In
order to get around that, the various ARM mach types that set the
pdata have been changed to hold the variable in static (global) memory.
Also note that __initdata references in aforementioned pdata structs
have been dropped.
Signed-off-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Otherwise, we will not return error if write to MC13892_SWITCHERS5 failed.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Yong Shen <yong.shen@linaro.org>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
No point exposing functions that aren't used elsewhere to the global
namespace and sparse warns about doing so.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>