Add a global linked list named cpr_regulator_list to keep track
of all cpr-regulator devices. It can be used when analyzing RAM
dumps in order find out the state of cpr-regulator devices at the
time of a crash.
Change-Id: Ic2abc76c02799edd641e49ee0dfe003614802b11
Signed-off-by: David Collins <collinsd@codeaurora.org>
The cpr_enable module parameter is currently tied to a global
pointer, the_cpr, which corresponds to the last cpr-regulator
device probed. This means that it is not possible to enable or
disable the CPR controller for the cpr-regulator devices that
probed first.
Remove the the_cpr pointer and the cpr_enable module parameter.
Replace them with a debugfs node for each cpr-regulator device
which can be used to enable and disable CPR individually.
Also fix the callback for the existing debug_info debugfs node
since it depends upon the_cpr.
New Debug Interface:
/sys/module/cpr_regulator/parameters/debug_enable
Integer in which bit 0 enables kernel log messages
generated when handling CPR interrupts and bit 1 enables
other cpr-regulator log messages. This parameter affects
all cpr-regulator devices.
/sys/kernel/debug/regulator/<regulator-name>/cpr_enable
Integer which controls whether or not CPR is enabled for
a particular cpr-regulator device. A value of 0
corresponds to CPR disabled and a value of 1 corresponds
to CPR enabled. <regulator-name> corresponds to
the name of the cpr-regulator device which is specified
via the regulator-name device tree property.
/sys/kernel/debug/regulator/<regulator-name>/debug_info
CPR status information for a particular cpr-regulator
device. <regulator-name> corresponds to the name of the
cpr-regulator device which is specified via the
regulator-name device tree property.
Old Debug Interface:
/sys/module/cpr_regulator/parameters/debug_enable
Integer in which bit 0 enables kernel log messages
generated when handling CPR interrupts and bit 1 enables
other cpr-regulator log messages. This parameter affects
all cpr-regulator devices.
/sys/module/cpr_regulator/parameters/cpr_enable
Integer which controls whether or not CPR is enabled for
the last cpr-regulator device probed. A value of 0
corresponds to CPR disabled and a value of 1 corresponds
to CPR enabled. This parameter incorrectly does not
control the CPR enable state for the first cpr-regulator
devices probed.
/sys/kernel/debug/regulator/<regulator-name>/debug_info
CPR status information for the last cpr-regulator device
probed (regardless of which cpr-regulator device it seems
to be associated with). <regulator-name> corresponds to
the name of the cpr-regulator device which is specified
via the regulator-name device tree property.
Change-Id: I404ebdb3180f7dd9ae095867f7545d274be29e62
Signed-off-by: David Collins <collinsd@codeaurora.org>
Update the spm-regulator driver so that it falls back on an SPMI
register write if the msm_spm_set_vdd() call to set the voltage
of a regulator fails. This retry mechanism is needed because
msm_spm_set_vdd() is not guaranteed to work for all regulators at
all times. It can only work if at least one processor core
powered by the regulator is online. Unfortunately, the clock
driver may request a voltage during the process of bringing the
first such core online.
Change-Id: I93980d603a324da2b8d21e0b78958ff5032168b0
Signed-off-by: David Collins <collinsd@codeaurora.org>
The debugfs node allow read/write access to all the NCP
registers. Useful in validating the regulator.
Change-Id: Ia313afad45efccc6831ffea641a3575ef43dbdd0
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Some SoCs have extremely limited fuse space. In order to save
fuse bits, the CPR target quotients are packed to take up less
space. Add support to unpack the target quotient for each fuse
corner using an offset and multiplier.
Change-Id: Ie1b49b8e881dbb239277876c8a4ae8603832e878
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support in the cpr-regulator driver for a new device tree
property named qcom,cpr-init-voltage-ref which specifies the
reference voltages to use when decoding initial voltage fuse
values. This property decouples inital voltage fuse decoding
from the specification of CPR ceiling voltages. This feature
is needed since some SoCs utilize reference voltages which
are different from the ceiling voltages.
Change-Id: I87cd8a053253fa538e773aefa774c53ab69063a2
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add ti,en-gpio-lpm property to set the enable pins to input/pull
down state when the boost regulator being disabled. This can reduce the
rock bottom power numbers when system entering into sleep state with the
regulators disabled.
Take this chance to correct a typo of drive-strength property specified
in tps65132-en-pin pin group node for msm8916 QRD SKUH board.
Change-Id: I2c2df1f4893c31deeba02c3b2988d1157bdb7b61
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
Some SoCs utilize more than three CPR fuse corners. Add support
for an arbitrary number of fuse corners which is specified via
the device tree property qcom,cpr-fuse-corners.
Update the description for device tree properties that have fixed
sizes to support exactly three fuse corners (SVS, Nominal, Turbo)
in order to denote that their size is now dependent upon the
value of qcom,cpr-fuse-corners. Also replace all fixed size
arrays in the cpr-regulator driver which are used to hold fuse
corner data with dynamically allocated arrays.
Change-Id: Iead3e6e1fba329bf745970925f9faa2a5a227dcf
Signed-off-by: David Collins <collinsd@codeaurora.org>
Currently, the voltage transition slew rate setting for fan53555 is
based on 10 mV voltage scaling step. For regulator with a scaling step
other than 10 mV, the slew rate has a relationship between voltage
scaling step and the slew rate based on 10 mV voltage scaling step.
Change the slew rate setting according to the voltage scaling step, and
round it to a lower avaiable value if it is an itermediate one.
Change-Id: Iccb13ebcb4bac15d76420602363bdcdfe5fc0a2d
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
ACPU clock driver initialization has dependency on regulator driver
initialization. The cpufreq driver requires the ACPU clock handle which
in turn requires the APC regulator handle.
In commit cf54c951db ("clock-a7/krait:
Change initcall level for early probe"), the cpufreq driver was modified
to use subsys_initcall level and ACPU clock driver changed to use
arch_initcall level. Change fan53555 regulator driver to arch_initcall
level to make sure the cpufreq driver can probe successfully.
Change-Id: I0914648c04f50dd542ed872aaa76afe674607546
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
The chips with die revision 23 have 600 mV minimum voltage and 12.5 mV
step size. Add support for chips with this die revision.
Change-Id: Ie63637bdcfae73a706f364e74908d285c2a60954
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
TLMM_SPARE register will be controlled at bootloader. Remove the
TLMM_SPARE register access in onsemi-ncp6335d regulator driver.
This reverts commit e61b7c5004.
Change-Id: I73319ff47c6656e2c042736ad507c73ddb9065c8
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
Print out the type, subtype, and digital major revision register
values when a regulator fails to match supported variants. This
will help when debugging PMIC simulator issues.
Change-Id: I4d0ca163921e6f14737df2977c39cf43b3d303d3
Signed-off-by: David Collins <collinsd@codeaurora.org>
Remove the target quotient validation check which requires the
nominal corner target quotient to be strictly greater than the
SVS corner target quotient. This check unnecessarily disables
CPR on targets which have an SVS quotient that is programmed to
be equal to the nominal quotient.
Change-Id: Ibb8e70d67c1042168e6a711915ef0dfe2fe34b96
Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
ACPU clock driver initialization has dependency on regulator
driver initialization.
The cpufreq driver to successfully register requires the acpu
clock handle which in turn requires the apc regulator handle.
In a recent change the init-call ordering of the cpufreq and
acpu-clock drivers has changed to register them early. Move the
onsemi regulator initialization to arch_initcall() to handle
this modification.
Change-Id: I68d089df66ba559bf39c7d3f67702e1f98546f7c
Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
TPS65132 is a dual output regulator chip. It is usually used for
providing positive and negative supply voltages for LCD panel source
driver ICs.
The chip has a positive supply rail and a negative supply rail. Both
rails support 4V~6V output voltage range and each rail can be
controlled separately.
Change-Id: I6012bc8dd0f19a8cd6a94fe00457fc65b8408346
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
Add support in the spm-regulator driver to configure the PMIC
regulator voltage via SPMI instead of via SPM. This can be used
when simulated chips do not have fully functional SPM models.
Change-Id: Id75b3dd580ed267dfc5c647d36756690d32b774f
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support in the cpr-regulator driver for reading the following
fuse parameters which may span two fuse rows:
qcom,cpr-fuse-target-quot, qcom,cpr-fuse-ro-sel, and
qcom,cpr-fuse-init-voltage. This feature is required for new
chips which pack CPR parameters tightly without regard for fuse
row boundaries.
Change-Id: Idc28a54a37cdc0e40d25ca56e6726b76fc0db213
Signed-off-by: David Collins <collinsd@codeaurora.org>
The CPR target quotient register fields have a length of 12 bits.
However, some targets have a very limited number of fuse bits and
thus encode the target quotients for the different voltage
corners with less than 12 bits. Add support in the cpr-regulator
driver for the optional device tree property
qcom,cpr-fuse-target-quot-size which can be used to specify the
bit length of the target quotient fuse values for each corner.
Change-Id: Ibdb3e2b1adc415480fdf47977b9d1b8c3dc0193d
Signed-off-by: David Collins <collinsd@codeaurora.org>
Update the cpr-regulator driver and documentation in order to
make the qcom,cpr-fuse-bp-cpr-disable device tree property
optional. Some targets do not allocate a fuse bit for the
purpose of disabling CPR so this property cannot be considered
required.
Change-Id: I39aa59e92585c87b97714fc1684b17f3b9c0523f
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support for QPNP PMIC FTS 2.5 type regulators. This type of
regulator supports auto mode control, auto phase control, and
three phases enabled at one time. The FTS 2.5 voltage mapping is
similar to that of existing FTS 2 except for an additional
offset.
Change-Id: I0fa7876ce916f2d039d18a7d89ce7b32c783f68d
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support for QPNP PMIC FTS 2.5 type regulators. This type of
regulator supports auto mode control, auto phase control, and
three phases enabled at one time. The FTS 2.5 voltage mapping is
similar to that of existing FTS 2 except for an additional
offset.
Change-Id: I8c8a3498896fab795d3151a61e19c5b62bd02c2e
Signed-off-by: David Collins <collinsd@codeaurora.org>
commit 66fda75f47dc583f1c187556e9a2c082dd64f8c6 upstream.
There are many places where ops->disable is called directly. Instead we
should use _regulator_do_disable() which also handles gpio regulators.
To be able to use the wrapper function from _regulator_force_disable(),
I moved the _notifier_call_chain() call from _regulator_do_disable() to
_regulator_disable(). This way, _regulator_force_disable() can use
different flags for _notifier_call_chain() without calling it twice.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
disable_irq() is not an efficient call and could cause potential deadlock.
Improve the interrupt handling by removing disable_irq and enable_irq
completely, and instead, checking the state of the interrupt source
(LOOP_EN and BUSY bits) in ISR to bail out immediately if any condition is
not met.
CRs-Fixed: 630182
Change-Id: Ieedadf4f0db4febc41ab85f383af683bdaf34615
Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
Signed-off-by: Ke Liu <keliu@codeaurora.org>
commit 30c219710358c5cca2f8bd2e9e547c6aadf7cf8b upstream.
There are some direct ops->enable in the regulator core driver. This is
a potential issue as the function _regulator_do_enable() handles gpio
regulators and the normal ops->enable calls. These gpio regulators are
simply ignored when ops->enable is called directly.
One possible bug is that boot-on and always-on gpio regulators are not
enabled on registration.
This patch replaces all ops->enable calls by _regulator_do_enable.
[Handle missing enable operations -- broonie]
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Some devices do not have PVS version fuse bits. In such cases the
qcom,pvs-version-fuse-sel property cannot be specified. Initialize
pvs_version to 0 in the case that qcom,pvs-version-fuse-sel is not
present. This allows virtual corners to be used when there are no PVS
version fuse bits.
Change-Id: I835cc12c942a464bfda354fe53b9361ff352cf31
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
The memory accelerator controls delays while accessing
memories. These delays vary based on the power-mode.
Provide the power-mode (corner) information from CPR
to the memory accelerator driver through the regulator
interface.
Change-Id: I9c13df1695d760aa7b4797f3ba5dc65590cf21e6
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
The memory accelerator (MEM ACC) controls the delays applied during
memory access. These delays vary based on the power-mode (corner)
on which the memory is connected. This driver adds a regulator
interface to configure the power-mode of the memory accelerator
based on the APC (application processor) corner.
Change-Id: I830ff000f8a16c4d3de5bdebf48d424354ddb086
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
RPM regulator initialization is done at module_init level which is
late in the boot-up sequence and drivers dependent on regulators
do probe deferral.
Move RPM regulator initialization to arch_init level to minimize
probe deferrals by dependent drivers.
Change-Id: I3e0bc7cb46a90eb62418122869c70345da9217ee
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Check the status of the spm driver using msm_spm_probe_done()
inside of the spm-regulator probe function. Return any error
code from the probe function. This ensures that spm-regulator
will defer its probe in the case that the spm driver has not
yet probed.
Change-Id: I6d006cee6289bd51e38271e70f81c7a4622016ee
Signed-off-by: David Collins <collinsd@codeaurora.org>
The CPR scheme fuse bit is used for indicating if a global or local
target scheme is used for CPR. It will be eliminated on some future
devices.
Make the "qcom,cpr-fuse-bp-scheme" property optional to allow the
future devices without a scheme fuse bit to boot up successfully.
Change-Id: I892e763a0875ec8a5abec8798485defae9b3252b
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
Currently, CPR redundant fuse checking for CPR ring oscillation
selection and target quotient values is mandatory.
However, some devices lack these redundant fuse bits in order to save
space. Therefore, redefine the affected device tree properties as
optional and update the cpr-regulator driver so that it can function
without them.
Change-Id: I5461fc4b173fac318986d7762bbcb15ba86a5a88
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
A new initial voltage coding scheme has been introduced which defines
the initial voltage for each fuse corner using its own fuse value.
Previously, the initial voltage for all fuse corners was determined
from a single PVS bin fuse value. Add support in the cpr-regulator
driver for this new initial voltage coding scheme.
Each fuse encodes the initial voltage for a fuse corner as follows. The
MSB of the fuse value is a sign bit. The remaining bits define an offset.
The offset has units of a predetermined step size which is captured in
device tree. The initial voltage is then: ceiling_voltage - sign *
offset.
Change-Id: I6d48f3c68d62adc730fd406f937f7f3033b73552
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
Move the cpr-regulator driver from the arch/arm/mach-msm
directory into the drivers/regulator directory. Moving this
driver out of the arch/arm/mach-msm directory allows it to be
shared with architectures other than 'arm'. In particular,
moving it allows it to be used by arm64.
Change-Id: I0b487c7fae42c260e06f5b70d1716bfbef065f4b
Signed-off-by: David Collins <collinsd@codeaurora.org>
Move the spm-regulator driver from the arch/arm/mach-msm
directory into the drivers/regulator directory. Moving this
driver out of the arch/arm/mach-msm directory allows it to be
shared with architectures other than 'arm'. In particular,
moving it allows it to be used by arm64.
Also move the header file for the spm-regulator driver from the
arch/arm/mach-msm directory into the include/linux/regulator
directory. Moving the header file requires updating all files
which include it.
Change-Id: I0c5a20a5f3512ef19c9cdb939342224d11667650
Signed-off-by: David Collins <collinsd@codeaurora.org>
Move rpm-smd and rpm-notifier headers to a machine independent
directory in kernel. Change the source files which are referring
to these headers and point them to a new location.
Change-Id: I69f0c1189ac9c69d8e869534f2f6689bf3ac980e
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Add support to the onsemi-ncp6335d driver to select which regulator
operating mode to utilize. There are two possible mode selections: PWM mode
and auto mode. If no mode property is specified in device tree, the
regulator will operate in the hardware default mode.
CRs-Fixed: 607899
Change-Id: I2e21c452a3ea3963146d9abbc7e89e811fd90388
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Certain Qualcomm chips mux the output of some GPIOs using the TLMM_SPARE
register. Add support for a device tree property which can be used to
specify a mask and value to write into this register so that the VSEL GPIO
can be toggled successfully on affected devices. When the appropriate bits
in the TLMM_SPARE register are written, the physical output of the GPIO can
be controlled normally via GPIO control registers.
Change-Id: Ic8a0886886a44687931ab5cb8150383cd84db2f6
Signed-off-by: Ke Liu <keliu@codeaurora.org>
This callback function can help perform validation of the
regulator-min-microvolt and regulator-max-microvolt properties at runtime
automatically.
Change-Id: I63917e06c4fa881f67d938d0c53e7ad71ebda25f
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Add device tree support. Add support for restoring voltage select register
from back up register. Add support for setting vsel pin by gpio output
according to device tree information. Add option to disable regulator
suspend method. Add set_voltage_time_sel to regulator_ops. Add support for
option 13's voltage range.
Change-Id: Iab9b160ff83c66f59cccedbd23d4aed7acb7d7a3
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Add device tree support. Add support for restoring working register
from back up register. Add support for setting vsel pin by gpio output
according to device tree flag. Change ncp6335d_regulator_init into a
global function.
Signed-off-by: Ke Liu <keliu@codeaurora.org>
Change-Id: I5ce861dd307b28e0782d051b105956b10eb1afab
Move the rpm-regulator-smd driver from the arch/arm/mach-msm
directory into the drivers/regulator directory. Also rename it
from rpm-regulator-smd.c to rpm-smd-regulator.c so that it
matches the naming scheme of the other regulator drivers. Moving
this driver out of the arch/arm/mach-msm directory allows it to
be shared with architectures other than 'arm'.
Also move the header file from the arch/arm/mach-msm/include/mach
directory into the include/linux/regulator directory. Moving the
header file requires updating all drivers which include it.
Change the compatible property values so that they match the new
driver name.
Change-Id: I20f2a4503c198ba9d1d04a77b03411dcc98e8aa1
Signed-off-by: David Collins <collinsd@codeaurora.org>
The const keyword is not being used correctly for the
qpnp_print_actions array in qpnp-regulator.c. The array pointer
itself should be specified as const as well.
Change-Id: I0d6f2323d3add646696a7d1453cb58300258c215
Signed-off-by: David Collins <collinsd@codeaurora.org>
This change removes source files from the kernel tree that
were not being used during make. The list of used files
was generated using an annotated make log and was then
compared with new files added since the public release of
kernel version 3.10.00. New files which were added but
not used have been removed from the tree.
A diff was also run to determine the list of files that had
been modified since the release of kernel version 3.10.00.
These files were then scrubbed based on the current kernel
configuration, removing invalid and unused conditionals.
Some files which support planned functionality or are
useful in debugging have been excluded from this reap.
Change-Id: Ia44a224d3cea7bc78dd45e8a8279860d35d4b008
Signed-off-by: Ian Maund <imaund@codeaurora.org>
Add support for QPNP PMIC ULT LDO and SMPS regulators.
ULT LDO/SMPS are regulators designed for PMIC chips with minimal
set of features to achieve better area efficiency.
Change-Id: I52ef77d5c60713c9bd2dfc5e3cde5f4df44ebacd
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
This reverts commit b2296bd43e.
The change results in the following incorrect behavior.
If a given regulator has a parent supply and the regulator is
enabled either before or during regulator_register(), then
regulator_enable() is called on the supply. Unfortunately, there
is no matching regulator_disable() call. This means that the
parent supply will stay enabled forever even if the child is
disabled later.
The stated goal of the change was to enable the parent of a
regulator which was enabled based on its machine constraints.
However, the only constraints that leads to enable() being called
for a regulator are boot-on or always-on. If these have been
specified for a child regulator then they should have also been
specified for its parent regulator. Therefore, there should be
no need to explicitly enable the parent when the child is
registered.
Change-Id: Ib8e6db65dcd44c27ef99509ff0cfd2f8e16e9f65
CRs-Fixed: 540315
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support for QPNP PMIC low-noise (LN) LDO type regulators.
This type of regulator provides very clean and constant voltage
at low current. LN LDOs are used to power oscillators and RF
buffers.
Change-Id: Ibda540899b93bbb750f554e728d118b635bdbc0f
Signed-off-by: David Collins <collinsd@codeaurora.org>
Voltage spikes may occur if the voltage range of a regulator is
changed while the regulator is enabled. Therefore, modify the
voltage setting function so that the current voltage range is
used whenever possible.
Change-Id: I13dda99c751acfe083f2bcaacf09348d317fc0e7
Signed-off-by: David Collins <collinsd@codeaurora.org>
Extend the voltage range configuration data so that it fully
describes all possible set point values for each regulator type
in addition to specifying which range to use in the case of
overlap.
Change-Id: Ifdef83720f1c9ef6f74e64ce27ec5e7e27ccba9f
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support for QPNP PMIC boost-bypass type regulators. This
type of regulator is designed to output a configurable minimum
voltage. If the input voltage is above the set point voltage,
then the regulator automatically enters bypass mode such that the
output voltage is equal to the input voltage. If the input
voltage is below the set point voltage, then it is boosted up to
the set point voltage.
Change-Id: I93704339b7cb730fae099471bf8ec872dae54c04
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add a call to regulator_proxy_consumer_register() at the end of
regulator_register() and a call to
regulator_proxy_consumer_unregister() at the beginning of
regulator_unregister(). These calls ensure that proxy consumer
features may be used by any type of regulator regardless of the
driver supporting it.
Change-Id: Ia70da1df47042fa673c42f389136557f868d19a3
Signed-off-by: David Collins <collinsd@codeaurora.org>
Make the error printing statements after the qpnp-regulator
drivers calls regulator_register() conditional upon the error
code not being -EPROBE_DEFER. This removes some unnecessary
kernel log messages that take place when a qpnp-regulator device
attempts to probe before its parent regulator.
Change-Id: I92d4ed61a238d384bae43458e3ca86c0079380c0
Signed-off-by: David Collins <collinsd@codeaurora.org>
Reset the OCP counter for voltage switches which use the OCP IRQ
in the qpnp_regulator_vs_enable callback function. Resetting the
counter here ensures that a voltage switch is always able to
reach its final output voltage when a valid load is connected if
only one OCP event occurs while enabling the switch.
Change-Id: Ie5b2d5271c81ef4b3cb9c9d874ca66af5530ddc7
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support for a voltage switch OCP interrupt handler which
toggles the switch off and back on after an overcurrent event
takes place. This toggling should only be performed for a
specified maximum number of times with a specified delay between
subsequent retries. Disabling a voltage switch is the only way
to clear the latched over-current state.
Change-Id: I8dbc54ff7bc54c1309ee59c1a282d5e4af2f0ec6
CRs-Fixed: 469134
Signed-off-by: David Collins <collinsd@codeaurora.org>
Correct the register values used to override and not override
voltage switch over current protection (OCP). Also update
documentation to explain exactly how OCP enablement works.
Remove the OCP enable time delay property since it cannot be used
effectively to avoid OCP triggering due to high in-rush current.
Change-Id: I046dd3a42d3f8ec7f3b9689a958b617fbca35254
CRs-Fixed: 469134
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support for a device tree property, qcom,hpm-enable, which
can be used to configure a voltage switch type regulator to be in
high power mode (HPM). When a switch is in HPM, over current
protection and soft start are enabled at all times.
The new property can also be used for other types of regulators.
However, this will likely not have the intended result as the
mode of non-voltage switch regulators is controlled at runtime
via regulator framework APIs.
Change-Id: Id3fca7ebbe3eb13b557e6d483494f218989cd64c
CRs-Fixed: 469134
Signed-off-by: David Collins <collinsd@codeaurora.org>
Sleep mode configures the regulator to enter into a sleep
state when both EN and VSEL are low. There is a significant
reduction in the leakage current in this mode.
Enable the same for 8x25q.
Change-Id: I7377bf9d702633b9eddcea8f3503cc270bb95c95
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Add the onsemi-ncp6335d regulator driver at subsys initcall
as the regulator_get() is used by acpuclock driver at device initcall.
This resolves the dependency chain.
Signed-off-by: Utsab Bose <ubose@codeaurora.org>
Change-Id: Ia7a18218066486c40080b25d57e979372467d8bd
Assign a value to the selector pointer that is passed into
set_voltage() callback functions in the qpnp-regulator driver.
The value assigned to the selector pointer should correctly map
to the regulator voltage through the list_voltage() callback
function.
Change-Id: I7d72feb77e6122982a46c626741450108742fb8b
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add support into the stub-regulator driver so that stub-regulator
devices may be specified via device tree.
Change-Id: Ib72ef7c8caacb50955cd7c182e790300daf152ce
Signed-off-by: David Collins <collinsd@codeaurora.org>
This driver supports OnSemi NCP6335D synchronous buck converter.
The NCP6335D is a step-down switching voltage regulator which
provides a voltage range from 0.6 to 1.4V. The regulator is
controlled via the I2C interface.
Change-Id: I237fe781d5c54d2b3ffc65096b9e83c387d3b6f5
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Add support for the following QPNP PMIC LDO subtypes:
N600_STEPPER
N1200_STEPPER
LV_P50
LV_P150
LV_P300
LV_P600
LV_P1200
The register control interface and output voltage mapping for
LDOs of these subtypes are identical to existing NMOS and PMOS
LDO subtypes.
The STEPPER variants add a new register to enable and control the
speed of stepping between voltage set points. This feature
allows for very smooth voltage transitions. All manipulation of
the stepping control registers will be handled by boot loaders.
The LV variants are identical to the base PLDO subtypes except
that they have a different ESD structure.
Change-Id: Ib20f3d39bd2ad6210975bcb80431ee133c895278
Signed-off-by: David Collins <collinsd@codeaurora.org>
Update the address used for the boost regulator current limit
register to reflect the correctly location in hardware. The
proper address is 0x4A, not 0x40.
Change-Id: Ieefcd072858691940103664a2130a6c69341448f
Signed-off-by: David Collins <collinsd@codeaurora.org>
The mapping between voltage control register set point values and
physical output voltage changes for range 1 of N1200 and N600
LDOs between PM8941 v1 and PM8941 v2. LDOs with the previous
mapping have digital major revision equal to 0. LDOs with the
new mapping have digital major revision equal to 1. Modify the
qpnp-regulator driver so that the digital major revision register
value is taken into account when deciding which voltage mapping
to utilize. N1200 and N600 regulators have identical
(range, voltage set point) --> output voltage mapping.
N1200 LDO range 1 hardware set points (rev=0):
375 mV to 768.75 mV with 6.25 mV step size
N1200 LDO range 1 hardware set points (rev=1):
375 mV to 1537.5 mV with 12.5 mV step size
Configure qpnp-regulator to use only range 0 for N1200 rev 1.
Range 0 is used because there is no benefit to using ranges 1 or
2 given that they have the same maximum voltage and step size
and their minimum voltage is greater than or equal to that of
range 0.
Change-Id: Icac6a1d8fccc014a754843d61c1fa40f550f9c77
Signed-off-by: David Collins <collinsd@codeaurora.org>
On some regulator hardware, the values read on SPMI offset 0x4 (type)
and 0x5 (subtype) are incorrect. Add a new optional property called
qcom,force-type that allows a user to override the hardware values
with values supplied in the Device Tree.
Change-Id: Id73fe69873f5dc9d0f2623771872aa2eaddd66f1
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
Update the FTSMPS voltage ranges so that they accurately reflect
the physical output voltages resulting from set points
programmed on PMIC hardware.
Previous hardware documentation contained these equations:
range == 0: Voutput = setpoint * 5 mV + 80 mV
range == 1: Voutput = setpoint * 10 mV + 160 mV
The actual hardware response is:
range == 0: Voutput = setpoint * 5 mV
range == 1: Voutput = setpoint * 10 mV
Update range data in qpnp-regulator to match the true mapping.
Change-Id: Iabf00591f79705de721f571a347afb15c8b7140e
Signed-off-by: David Collins <collinsd@codeaurora.org>
Pointers are more flexible than index numbers, since index
numbers depend upon an additional reference to the array in
question. In particular, we'd like to add a new API to lookup a
devnode based on a predefined name in the Device Tree. This API
will return a spmi_resource, and so it's natural to want to use
this pointer directly with the other existing APIs.
Also introduce a new API spmi_for_each_devnode that can be used
to iterate each spmi_resource in the dev_node array. This
abstracts the traversal of the array, which was previously done
within the existing APIs.
Change-Id: I18f9397e5d78770e840a9f95dd8061201931df6e
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
It turns out that the only use cases for the qpnp library use
the existing spmi data structures. As such, there's really
no justification for having the library not be called 'spmi'.
There is nothing Qualcomm specific about this code.
Also cleanup some inconsistencies in the Kernel Doc comments
while we're here.
Change-Id: I1c73c88be740b6f5d38ba2de62de1737981b30fa
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
The gpio_vreg_request_gpio() function inside of the
msm-gpio-regulator driver can return successfully even if
gpio_request() has failed. This can lead to a kernel crash via
null pointer dereference when later gpio and regulator functions
are called. Modify gpio_vreg_request_gpio() so that it returns
an error immediately if gpio_request() fails.
Change-Id: I59364eb9efda6c2149b807db9a00e782d8ae6bb8
Signed-off-by: David Collins <collinsd@codeaurora.org>
Move regulator debugfs functions into core.c. This change allows the user
to read and edit regulator information in user space through the debugfs
file system.
Change-Id: I21fa2c1d5d4ab27871ebb543134c2cee5ad70ded
Signed-off-by: Brandon Leong <bleong@codeaurora.org>
With this patch the regulator core aggregates voltage requests and
applies the minimum voltage range that satisifies all consumers of
a shared regulator supply. Only the voltages of consumers that have
enabled the supply are aggregated.
Updated voltage ranges are applied to the corresponding driver upon
the following events:
1. A consumer that has already enabled the regulator sets a voltage
2. A consumer enables the regulator
3. A consumer disables the regulator
Change-Id: Ib5012886cb77185a2038d45f08f3758faff68f60
Signed-off-by: David Collins <collinsd@codeaurora.org>
The regulator framework checks if the current mode is the same as the
one being requested inside of regulator_set_mode. However, when
DRMS changing is allowed, regulator_enable calls drms_uA_update.
This function does not check the value of get_mode before calling
set_mode.
Modify drms_uA_update so that set_mode is only called if the requested
mode is different from the current mode returned by get_mode.
Change-Id: Ifb4f3069cf946e8474565ee82508c1ff45b36543
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add a convenience API to set the voltage on multiple consumers
stored in a struct regulator_bulk_data[] in one API call.
Change-Id: Iaeb5ba8c357a66f1401fb1e142bb03904e8e9c7c
Signed-off-by: Justin Paupore <jpaupore@codeaurora.org>
Extend the of_get_regulator_init_data function so that it can
parse an additional property from regulator device tree nodes
which is needed to support non-device tree consumers.
The new property is named qcom,consumer-supplies. Its value
is a list of strings of the form:
qcom,consumer-supplies = "supply_name1", "device_name1",
"supply_name2", "device_name2", ...
Change-Id: Ia689d04e6de568e6889b807eed15df3116de01d2
Signed-off-by: David Collins <collinsd@codeaurora.org>
Each call to regulator_register() results in a line being written
into the kmsg log. regulator_init_complete() also prints a line for
each unused regulator which is automatically disabled.
Add a function named regulator_suppress_info_printing() which can
be called to disable these print statements.
Change-Id: Ic4c723b7d02a494b4e261858d699d9625da715ea
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add the qpnp-regulator driver to support regulators found in
Qualcomm plug-and-play (QPNP) PMIC chips. QPNP chips make use of
Qualcomm's SPMI register convention. The particular hardware
characteristics of a given regulator can be derived from the
values present in the type and subtype registers.
The qpnp-regulator driver supports probing with either device tree
device specification or with board file specified platform data.
Change-Id: I4f74431a50949763d651faf992b5d2567d05758e
Signed-off-by: David Collins <collinsd@codeaurora.org>
[sboyd: Squash in DT binding document]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Add support for a dummy driver that has an implementation
connected to no real hardware devices. Its purpose is to aid
bringup scenarios by providing clients a regulator interface
that they expect. This driver shouldn't be enabled if a real
device implementation for a particular platform already exists.
Change-Id: Ib83027b4e599ebbc3cb153b2f346bb03495bb746
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
As a regulator driver, this xo buffer driver takes the vote from
client and controls (enable or disable) XO (crystal) buffers so
that XO clock output can be started or stopped.
Change-Id: Iccac863af2f56d66799d8fdb3320958014466d8d
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
Create a new regulator driver, gpio-regulator, which wraps around a
GPIO that is the enable signal for a physical regulator.
Change-Id: I541a9a1cd3a6ffe3200ffaeee9f0f62db5e65795
Signed-off-by: David Collins <collinsd@codeaurora.org>
[sboyd: Moved to msm-gpio-regulator to not conflcit with
upstream's version of essentially the same driver]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Create a PM8XXX regulator driver that can support PMIC PM8921
variants including: PM8018, PM8038, and PM8921.
Change-Id: I60d1302e4af9a4c5caa72301c904867acd2ebe0f
Signed-off-by: David Collins <collinsd@codeaurora.org>
On 8x60 PMIC LDO/SMPS/LVS are controlled from the apps processor.
This driver talks directly to the PMIC over SSBI through the
PMIC8901 core driver. This driver utilizes the regulator framework
to enable, disable, and change regulator voltage levels.
Change-Id: I21c272a490a2526c2fde9fe3ef7590a57418269a
Signed-off-by: Bobby Crabtree <bobbyc@codeaurora.org>
On 8x60 PMIC LDO/SMPS/LVS are controlled from the apps processor.
This driver talks directly to the PMIC over SSBI through the
PMIC8058 core driver. This driver utilizes the regulator framework
to enable, disable, and change regulator voltage levels.
Change-Id: I25e24a3d2801d345d9f3943d54e34a563b6cc21a
Signed-off-by: Bobby Crabtree <bobbyc@quicinc.com>
Add a proxy consumer driver which can be used to ensure that a
given regulator maintains a certain minimum state during bootup.
Enable state, voltage, and current may be forced to specified
levels.
Change-Id: I0ccc63a41684462684ac737fb2f4129a3e6e4aea
Signed-off-by: David Collins <collinsd@codeaurora.org>
Errors returned from regulator_check_drms() are not treated as fatal
by any of its callers, nor are they passed up through exported
regulator APIs. Instead, these errors are used to indicate that a
regulator does not support multiple current modes.
For example, the exported regulator_set_optimum_mode() API explicitly
discards errors from regulator_check_drms() and returns success anyway
since there is no work to be done to change modes.
To prevent errors from being printed in these cases, downgrade the
rdev_err() prints in regulator_check_drms() to rdev_dbg() prints.
Change-Id: I465dcad59722b0f1fb9384beba01f6411a4a693a
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Change the device name of the regulator function to the one chosen for
MODULE_ALIAS. This fixes kernel auto-module loading for the regulator function.
Signed-off-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
regulator_enable_regmap() uses enable_reg to enable the regulator.
But enable_reg for smps10 points to SMPS10_STATUS which is a
read-only register. Fixed the same by having enable_reg
set to SMPS10_CTRL.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org
Since 'id' cannot take two values at the same time, the condition
should probably be an OR (||) instead of AND (&&).
Introduced by commit 28d1e8cd67 ("regulator: palma: add ramp delay
support through regulator constraints").
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
GENERIC_GPIO now synonymous with GPIOLIB. There are no longer any valid
cases for enableing GENERIC_GPIO without GPIOLIB, even though it is
possible to do so which has been causing confusion and breakage. This
branch does the work to completely eliminate GENERIC_GPIO.
However, it is not trivial to just create a branch to remove it. Over
the course of the v3.9 cycle more code referencing GENERIC_GPIO has been
added to linux-next that conflicts with this branch. The following must
be done to resolve the conflicts when merging this branch into mainline:
* "git grep CONFIG_GENERIC_GPIO" should return 0 hits. Matches should be
replaced with CONFIG_GPIOLIB
* "git grep '\bGENERIC_GPIO\b'" should return 1 hit in the Chinese
documentation.
* Selectors of GENERIC_GPIO should be turned into selectors of GPIOLIB
* definitions of the option in architecture Kconfig code should be deleted.
Stephen has 3 merge fixup patches[1] that do the above. They are currently
applicable on mainline as of May 2nd.
[1] http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg428056.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAABAgAGBQJRifUnAAoJEEFnBt12D9kBs2YP/0U6+ia+xYvkVaJc28PDVIzn
OReZNcJOYU8D5voxz0voaRD0EdcPwjbMu9Kp9aXMHlk4VxevF+8jCc/us0bIjtO1
VcB5VmSCIhMhxdnBlum11Mk7Vr5MCweyl9NBsypnPt8cl4obMBZHf2yzoodFktNb
wtyYlOb6FALtc6iDbOO6dG3w9F7FAOLvskUFzdv89m8mupTsBu9jw9NqFDbJHOex
rxq0Sdd+kWF/nkJVcV5Y6jIdletRlhpipefMJ9diexreHvwqh+c4kJEYZaXgB5+m
ha95cPbReK1d+RqzM3A8d4irzSVSmq4k7ijI6QkFOr48+AH7XsgKv5so885LKzMN
IIXg2Phm9i0H8+ecEvhcc4oIYBHJiEKK54Y0qUD9dqbFoDGPTCSqMHdSSMbpAY+J
bIIXlVzj1En3PPNUJLPt8q8Qz6WxCT9mDST3QSGYnD4o90HT+1R9j92RxGL6McOq
rUOyJDwmzFvpBvKK4raGdOU435M+ps2NPKKNIRaIGQPPY9rM1kN4YqvhXukEsC9L
3a3+3cQLh7iKxBHncxeQsJfethP1CPkJnzvF9r+ZZLf2rcPH4pbQIE2uO0XnX/nd
5/DKi0nGgAJ//GMMzdo3RiOA5zGFjIZ/KMvfhQldpP6qFJRhqdGi6FPlAcwr1z1n
YnCByPwwlvfC4LTXFOGL
=xodc
-----END PGP SIGNATURE-----
Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux
Pull removal of GENERIC_GPIO from Grant Likely:
"GENERIC_GPIO now synonymous with GPIOLIB. There are no longer any
valid cases for enableing GENERIC_GPIO without GPIOLIB, even though it
is possible to do so which has been causing confusion and breakage.
This branch does the work to completely eliminate GENERIC_GPIO."
* tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux:
gpio: update gpio Chinese documentation
Remove GENERIC_GPIO config option
Convert selectors of GENERIC_GPIO to GPIOLIB
blackfin: force use of gpiolib
m68k: coldfire: use gpiolib
mips: pnx833x: remove requirement for GENERIC_GPIO
openrisc: default GENERIC_GPIO to false
avr32: default GENERIC_GPIO to false
xtensa: remove explicit selection of GENERIC_GPIO
sh: replace CONFIG_GENERIC_GPIO by CONFIG_GPIOLIB
powerpc: remove redundant GENERIC_GPIO selection
unicore32: default GENERIC_GPIO to false
unicore32: remove unneeded select GENERIC_GPIO
arm: plat-orion: use GPIO driver on CONFIG_GPIOLIB
arm: remove redundant GENERIC_GPIO selection
mips: alchemy: require gpiolib
mips: txx9: change GENERIC_GPIO to GPIOLIB
mips: loongson: use GPIO driver on CONFIG_GPIOLIB
mips: remove redundant GENERIC_GPIO select
power_state_active_get is used only in this file. Make it static.
While at it also move this function definition inside the
CONFIG_REGULATOR_DEBUG macro as it is called only from within it.
This also avoids further build warning related to unused definition.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
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>
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>
It's safe to call regulator_unregister() with NULL, thus remove the NULL test
before regulator_unregister() calls.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@sirena.org.uk>
Patch adds device tree probe support for mc13783-regulator driver.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
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>
Ensure to unregister all regulators before return error in probe().
The regulator register order depends on the regulator ID pass to
ab3100_regulator_register() function. Thus we need to scan ab3100_regulator_desc
and find the index of successfully registered regulators, or alternatively just
call ab3100_regulators_remove() to unregister all registered regulators.
Since current code uses a static ab3100_regulators table, explicitly set
reg->rdev = NULL after regulator_unregister() call to ensure calling
ab3100_regulators_remove() in the unwind path always work.
Also move ab3100_regulators_remove() to avoid forward declaration.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All regulators have ascendant voltage list in this driver.
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>
All regulators have ascendant voltage list in this driver.
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>
All regulators have ascendant voltage list in this driver.
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>
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>
All regulators have ascendant voltage list in this driver.
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>
tps65020 ldo1 and ldo2 vsel tables are identical, merge them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All regulators have ascendant voltage list in this driver.
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>
This implements device tree support for the AB3100 regulators
driver. The initial settings are moved out of platform data
and into the driver for the device tree case, as it appears
that there is no way to supply this as AUXDATA for an I2C
device. The style and bindings are heavily inspired by
Lee Jones' style for AB8500.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This refactors the AB3100 regulator probe to use regulator IDs
and pass this to a separate registration function. This works
much smoother when migrating to device tree, as we can use a
match table with this regulator ID encoded in the .driver_data.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Current code overrides control1 variable when setting ramp delay bits.
Fix it by just setting ramp_delay bits.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Currently we have a special code in tps80031_ldo_set_voltage_sel() to handle
LDO2 track mode for TPS80031 or TPS80032-ES1.0. The purpose is to address below
issues:
Issue description:
- LDO2 traking mode is enabled
- LDO2 tracks SMPS2 voltage.
- LDO2 automatically switch-off when LDO2_CFG_VOLTAGE is changed to some discrete values (non exhaustive list):
00011001, 00011010, 00011011, 00011100, .
- LDO2 switch-on again when LDO2_CFG_VOLTAGE is changed to other values (non exhaustive list):
00011000, 00010111, .
LDOs have reserved codes. For these codes, LDO is switch-off.
In tracking, LDO2 ref comes from SMPS2.
However LDO2 enable is still gated by LDO2 VSEL decoding.
As a result, in tracking mode LDO2 will be disabled for following code (SMPS VSEL format):
000000 & 100000 (MSB not decoded)
011001 & 111001 (MSB not decoded)
011010 & 111010 (MSB not decoded)
011100 & 111100 (MSB not decoded)
011101 & 111101 (MSB not decoded)
011110 & 111110 (MSB not decoded)
However, current code has below bugs:
1. It uses regulator_list_voltage_linear, so list_voltage() still shows above
invalid selectors have supported voltage.
2. Current code may return -EINVAL in tps80031_ldo_set_voltage_sel() for
supported voltage. This is because when we use regulator_list_voltage_linear
as list_voltage callback, regulator core will default use
regulator_map_voltage_linear(). regulator_map_voltage_linear() has an
assumption that the voltages are linear which is not true for this case.
For example,
when request voltage range is: min_uV=950000 uV && max_uV=1200000 uV
regulator_map_voltage_linear() returns the selector is 29 (0x1D),
set_voltage_sel() returns -EINVAL.
(The selector is in invalid range, 0x19 ~ 0x1f).
In above case, map_voltage() should find the lowest valid voltage within
specific range (selector = 0x20) and set_voltage_sel() should successfully
set the voltage to 987500 uV.
This patch fixes these issues by:
1. Add checking valid setting for LDO2 track mode of TPS80031 or TPS80032-ES1.0
in list_voltage. So it returns -EINVAL for invalid selectors.
2. Implement tps80031_ldo_map_voltage, use regulator_map_voltage_iterate()
to find the lowest voltage within specific range for TPS80031 or
TPS80032-ES1.0. This is required when the voltage map is no longer linear.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All regulators have ascendant voltage list in this driver.
Thus use regulator_map_voltage_ascend is more efficient than the default
regulator_map_voltage_iterate.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All regulators have ascendant voltage list in this driver.
Some regulators have more than 200 supported voltages.
e.g.
For TPS65910_REG_VDD1 and TPS65910_REG_VDD2:
n_voltages = VDD1_2_NUM_VOLT_FINE * VDD1_2_NUM_VOLT_COARSE
= 73 * 3
= 219
Thus it worth converting to regulator_map_voltage_ascend rather than use
default regulator_map_voltage_iterate.
For consistent, convert all regulators to regulator_map_voltage_ascend.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All regulators have ascendant voltage list in this driver.
Thus use regulator_map_voltage_ascend is more efficient than the default
regulator_map_voltage_iterate.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All regulators have ascendant voltage list in this driver.
Thus use regulator_map_voltage_ascend is more efficient than the default
regulator_map_voltage_iterate.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Simply the [get|set]_voltage_sel implementation by using
regulator_[set|get]_voltage_sel_regmap instead of open coded.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
According to the datasheet[1]
Register 0x06h Description: RmpCtrl (REGISTER ADDRESS: 0x06h Read/Write)
BIT[5..7]:
RMP[2:0] Output voltage ramp timing
D7-D5 Slope
000 32mV/us
001 16mV/us
010 8mV/us
...
110 0.5mV/us
111 0.25mV/us
Thus to get correct ramp_ctrl value, we need to right-shift 5 bits.
[1] http://www.ti.com/lit/ds/symlink/tps62360.pdf
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Datasheet says:
Time Step (TSTEP) selection, when changing the output voltage, the new value is
reached through successive voltage steps (if not bypassed). The equivalent
programmable slew rate of the output voltage is:
TSTEP[1:0]: 00 Jump (no slope control)
TSTEP[1:0]: 01 10mV/us
TSTEP[1:0]: 10 5mV/us (default)
TSTEP[1:0]: 11 2.5mV/us
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The ctrl_addr setting for SMPS10 is missed, thus palmas_smps_init() read/write
wrong register for SMPS10 in current code. Fix it.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
SMPS3 and SMPS7 do not have tstep_addr setting, so current code actually
writes 0 to smps12_ctl (offset is 0) register when set_ramp_delay callback
is called for SMPS3 and SMPS7.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
When SMPS45 is set to off and LDO8 tracking is enabled, the output voltage can
be set from 0.45 to 1.65 V. Thus set min_uV to be 450000.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The voltage_shift can be calculated from voltage_mask.
Let's remove voltage_shift fied from struct ab8500_regulator_info, this change
can prevent missing voltage_shift setting issue.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The voltage_shift field of struct expand_register is not used now, remove it.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The Palma device like TPS65913 have the mode mask which is also
used for enable/disable the rails. The mode bits are defined as
00: OFF
01: AUTO
10: ECO
11: Forced PWM
and modes are set accordingly as
REGULATOR_MODE_NORMAL: AUTO
REGULATOR_MODE_IDLE: ECO
REGULATOR_MODE_FAST: PWM
Two issue observed:
1. If client calls following sequence:
regulator_enable(),
regulator_set_mode(FAST),
regulator_disable()
and again the regulator_enable() then the mode is reset
to NORMAL inplace of keeping the mode as FAST.
Fixing this by storing the current mode configured by client
and restoring modes when enable() is called after disable().
2. In following sequence, the regulator get enabled:
regulator_disable()
regulator_set_mode(FAST),
Fixing this by updating new mode in register only if it is
enabled.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Currently Palma regulator driver support the ramp delay
through rail specific platform data.
As regulator framework support the configuration of ramp
delay through regulator constraint, using the framework
method and removing the platform specific data approach.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
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>
When setting voltage for AB8540_LDO_AUX3, current code only updates one of
info->voltage_reg and info->expand_register registers which is wrong.
To ensure we set to correct voltage, it always needs to clear or set
expand_register.voltage_mask bit of expand_register.
The function of the expand register bit is the following (from the user manual):
0: VAUX3 output voltage is determined by Vaux3Sel bit settings in register
VldoCVaux3Sel
1: VAUX3 output voltage is set to 3.05V regardless of Vaux3Sel settings in
register VldoCVaux3Sel (VldoCVaux3Sel is the register at 0x0421)
So when going to 3.05V, set the expand register bit.
When leaving 3.05V for another voltage, set the target voltage before clearing
the expand register bit.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Both enable() and disable() functions have only one caller, thus remove them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This ensures info->update_val status is still correct if set_mode() call fails.
Otherwise, get_mode() may return wrong status if a set_mode() call fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Currently, set invalid mode setting for shared mode regulators may change
sm->lp_mode_req flag. This patch ensures we don't set lp_mode_req flag to wrong
status if set_mode() fails.
This patch includes some clean up, and these changes makes this patch looks like
code refactor. The clean up is mainly to avoid adding ugly code to handle
failure paths.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This patch ensures info->update_val is consistent with current register value.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
LDO8 of Palma device like tps65913 support the tracking mode
on which LDO8 track the SMPS45 voltage when SMPS45 is ON
and use the LDO8.VOLTAGE_SEL register when SMPS45 is OFF.
On track mode, the steps of voltage change for LDO8 is 25mV
where in non-tracking mode it is 50mV. Set the steps accordingly.
Number of voltage count is still same for both the cases.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Palmas device have control outputs like REGEN1, REGEN2, REGEN3,
SYSEN1 and SYSEN2. These control outputs can be used for controlling
external voltage switches to enabled/disable voltage outputs.
Add support of these control outputs through regulator framework.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Clear the sleep/warm reset bits when it is not selected through
regulator platform data. This will make sure that configuration
is inline with the platform data regardless of boot/POR
configuration.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
commit 6d191a5fc7
(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>
The same table can be used for multiple instance of pdev, so we don't need to
allocate memory for of_regulator_match table per pdev.
match->driver_data points to the corresponding entry of as3711_reg_info,
however it is not used in current code, thus this patch does not set
driver_data in the of_regulator_match table.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
We can save a register read operation in some case if read
expand_register first.
If info->expand_register.voltage_mask bit is set, no need to read
voltage_reg.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The *dev and *mfd of struct rc5t583_regulator_info are not used after convert
to use regmap, remove them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
GENERIC_GPIO is now equivalent to GPIOLIB and features that depended on
GENERIC_GPIO can now depend on GPIOLIB to allow removal of this option.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
pdata is either a valid pointer or NULL, use NULL checking rather than
IS_ERR_OR_NULL macro.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The voltage_mask is 0xc0, thus we need to set voltage_shift = 6 to get correct
selector in get_voltage_sel and set_voltage_sel.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The voltage_mask and voltage_shift settings of AB8505_LDO_AUDIO are not matched.
It looks like a typo in the voltage_mask settings.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Ensure the regulators are registered with a GPIO parsed from the device
tree when available.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
ab8500_ext_regulator_exit() never fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The implementation of ab8500_ext_fixed_get_voltage is identical to
ab8500_ext_list_voltage. We can avoid the duplicate implementation by just
remove get_voltage. For fixed regulator, regulator core will call
list_voltage(rdev, 0) to get voltage if both get_voltage get_voltage_sel are
not implemented.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This code was added by commit 0fe17e20a6
"regulator: ab8500-ext: Add support for AB9540 regulators"
and commit bd44e2cb "regulator: ab8500: Also check for AB8505 based platforms"
The original patch[1] is to set info->desc.ops = &ab9540_ext_regulator_ops.
However, ab9540_ext_regulator_ops is identical to ab8500_ext_regulator_ops[2].
Thus we can complete remove the unnecessary checking for ab9540 and ab8540.
[1] https://lkml.org/lkml/2013/3/28/333
[2] https://lkml.org/lkml/2013/4/1/178
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The intention of this patch is to simplify the code.
Maintain the is_enabled flag is not trivial, it not only needs to set/clear the
flag in disable()/enable() but also needs to set the flag in is_enable() to get
initial status. The only benefit of keeping is_enabled flag is just save a
register read when set_mode(). Remove is_enabled flag makes the code simpler.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The intention of this patch is to simplify the code.
Maintain the is_enabled flag is not trivial, it not only needs to set/clear the
flag in disable()/enable() but also needs to set the flag in is_enable() to get
initial status. The only benefit of keeping is_enabled flag is just save a
register read when set_mode(). Remove is_enabled flag makes the code simpler.
This patch also moves ab8500_regulator_is_enabled() close to
ab8500_regulator_[en|dis]able functions.
This is required to avoid a forward declaration because now we call
ab8500_regulator_is_enabled() in ab8500_regulator_set_mode().
This change also makes the code better in readability by moving similar
functions to one place.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Almost all systems use the regulators on the WM8994 series devices to
provide DCVDD and AVDD1 so if no init data is supplied then set up the
supplies for the user. This simplifies integration of the device into
systems, especially when device tree is supported.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All users of ab8500_regulator_volt_mode_ops and ab8500_regulator_volt_ops
do not set info->desc.enable_time, thus set_voltage_time_sel() always returns 0.
Remove it.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This patch adds Device Tree support to max8952 regulator driver.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This patch modifies platform data structure of max8952 driver to
use pointer to regulator_init_data struct instead of embedding it.
This is a prerequisite for adding Device Tree support for the driver.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
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>
The regulators can only be used to supply the CODEC so we don't need to
worry about users that still need fudges for init ordering issues.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
For fixed voltage, we can just set min_uV and use regulator_list_voltage_linear
for list_voltage callback. Regulator core will call list_voltage(rdev, 0) if
both get_voltage get_voltage_sel are not implemented. Thus we can also remove
lp8788_ldo_fixed_get_voltage() function.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The id for DLDOx matches the entries in enum lp8788_ldo_id and it's easy to
calculate the id for ALDOx. Thus remove lp8788_dldo_id and lp8788_aldo_id
arrays.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This is required for regulator_list_voltage_table() to properly work.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
commit b080c78a4e
"regulator: ab8500: Update voltage handling for fixed voltage regulators"
removes min_uV settings and sets volt_table for all fixed voltages, thus
we can not use regulator_list_voltage_linear now. Use
regulator_list_voltage_table instead.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
The ab*_match[] arrays should be moved out of the way, instead of
bunched in the middle of the initialisation functions. This patch
moves all initialisation code which currently resides above these
arrays down to be grouped with the others. This makes the whole
thing slightly easier to read.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>