summaryrefslogtreecommitdiff
path: root/drivers/regulator/axp20x-regulator.c
AgeCommit message (Collapse)AuthorFilesLines
2021-01-20regulator: axp20x: Fix reference cout leakPan Bian1-4/+3
Decrements the reference count of device node and its child node. Fixes: dfe7a1b058bb ("regulator: AXP20x: Add support for regulators subsystem") Signed-off-by: Pan Bian <bianpan2016@163.com> Link: https://lore.kernel.org/r/20210120123313.107640-1-bianpan2016@163.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-04regulator: axp20x: Fix DLDO2 voltage control register mask for AXP22xDingHua Ma1-1/+1
When I use the axp20x chip to power my SDIO device on the 5.4 kernel, the output voltage of DLDO2 is wrong. After comparing the register manual and source code of the chip, I found that the mask bit of the driver register of the port was wrong. I fixed this error by modifying the mask register of the source code. This error seems to be a copy error of the macro when writing the code. Now the voltage output of the DLDO2 port of axp20x is correct. My development environment is Allwinner A40I of arm architecture, and the kernel version is 5.4. Signed-off-by: DingHua Ma <dinghua.ma.sz@gmail.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Cc: <stable@vger.kernel.org> Fixes: db4a555f7c4c ("regulator: axp20x: use defines for masks") Link: https://lore.kernel.org/r/20201201001000.22302-1-dinghua.ma.sz@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-26Merge tag 'regulator-fix-v5.9-rc6' of ↵Linus Torvalds1-3/+4
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator Pull regulator fix from Mark Brown: "A single fix for incorrect specification of some of the register fields on axp20x devices which would break voltage setting on affected systems" * tag 'regulator-fix-v5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: axp20x: fix LDO2/4 description
2020-09-23regulator: axp20x: fix LDO2/4 descriptionIcenowy Zheng1-3/+4
Currently we wrongly set the mask of value of LDO2/4 both to the mask of LDO2, and the LDO4 voltage configuration is left untouched. This leads to conflict when LDO2/4 are both in use. Fix this issue by setting different vsel_mask to both regulators. Fixes: db4a555f7c4c ("regulator: axp20x: use defines for masks") Signed-off-by: Icenowy Zheng <icenowy@aosc.io> Link: https://lore.kernel.org/r/20200923005142.147135-1-icenowy@aosc.io Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-24treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva1-4/+4
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-05-08regulator: use linear_ranges helperMatti Vaittinen1-8/+8
Change the regulator helpers to use common linear_ranges code. Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Reviewed-by: Mark Brown <broonie@kernel.org> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Link: https://lore.kernel.org/r/64f01d5e381b8631a271616b7790f9d5640974fb.1588944082.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-02-24regulator: axp20x: Fix misleading use of negationOndrej Jirman1-4/+2
It works incidentally, because AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN is non-zero, but the false branch value really should be just 0. Signed-off-by: Ondrej Jirman <megous@megous.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200222235634.243805-1-megous@megous.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-25regulator: axp20x: Fix axp20x_set_ramp_delayAxel Lin1-3/+6
Current code set incorrect bits when set ramp_delay for AXP20X_DCDC2, fix it. Fixes: d29f54df8b16 ("regulator: axp20x: add support for set_ramp_delay for AXP209") Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20191221081049.32490-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-18regulator: axp20x: Fix AXP22x ELDO2 regulator enable bitmaskChen-Yu Tsai1-1/+1
A copy-paste error was introduced when bitmasks were converted to macros, incorrectly setting the enable bitmask for ELDO2 to the one for ELDO1 for the AXP22x units. Fix it by using the correct macro. On affected boards, ELDO1 and/or ELDO2 are used to power the camera, which is currently unsupported. Fixes: db4a555f7c4c ("regulator: axp20x: use defines for masks") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20191218044720.21990-1-wens@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-16regulator: axp20x: fix DCDC5 and DCDC6 for AXP803Jernej Skrabec1-2/+2
Refactoring of axp20x driver introduced a bug in AXP803's DCDC6 regulator definition. AXP803_DCDC6_1120mV_STEPS was obtained by subtracting 0x47 and 0x33. This should be 0x14 (hex) and not 14 (dec). Refactoring also carried over a bug in DCDC5 regulator definition. Number of possible voltages must be for 1 bigger than maximum valid voltage index, because 0 is also valid and it means lowest voltage. Fixes: 1dbe0ccb0631 ("regulator: axp20x-regulator: add support for AXP803") Fixes: db4a555f7c4c ("regulator: axp20x: use defines for masks") Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Link: https://lore.kernel.org/r/20190713090717.347-3-jernej.skrabec@siol.net Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-16regulator: axp20x: fix DCDCA and DCDCD for AXP806Jernej Skrabec1-3/+3
Refactoring of the driver introduced bugs in AXP806's DCDCA and DCDCD regulator definitions. In DCDCA case, AXP806_DCDCA_1120mV_STEPS was obtained by subtracting 0x47 and 0x33. This should be 0x14 (hex) and not 14 (dec). In DCDCD case, axp806_dcdcd_ranges[] contains two ranges with same start and end macros, which is clearly wrong. Second range starts at 1.6V so it should use AXP806_DCDCD_1600mV_[START|END] macros. They are already defined but unused. Fixes: db4a555f7c4c ("regulator: axp20x: use defines for masks") Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Link: https://lore.kernel.org/r/20190713090717.347-2-jernej.skrabec@siol.net Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-20regulator: axp20x: Mark expected switch fall-throughsGustavo A. R. Silva1-3/+3
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. This patch fixes the following warnings: drivers/regulator/axp20x-regulator.c: In function ‘axp20x_set_dcdc_freq’: drivers/regulator/axp20x-regulator.c:1023:7: warning: this statement may fall through [-Wimplicit-fallthrough=] reg = AXP803_DCDC_FREQ_CTRL; drivers/regulator/axp20x-regulator.c:1025:2: note: here case AXP806_ID: ^~~~ drivers/regulator/axp20x-regulator.c: In function ‘axp20x_set_dcdc_workmode’: drivers/regulator/axp20x-regulator.c:1115:7: warning: this statement may fall through [-Wimplicit-fallthrough=] reg = AXP806_DCDC_MODE_CTRL2; drivers/regulator/axp20x-regulator.c:1121:2: note: here case AXP221_ID: ^~~~ Notice that in this particular case, I moved the whole comment "Fall through to the check below.", which contains the "Fall through" comment, at the bottom of the case, which is what GCC is expecting to find. Warning level 3 was used: -Wimplicit-fallthrough=3 This patch is part of the ongoing efforts to enable -Wimplicit-fallthrough. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-19regulator: axp20x: Use rdev_get_id at appropriate placesAxel Lin1-9/+5
Use rdev_get_id() to simplify the code a bit. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-19regulator: axp20x: Remove unneeded NULL test against rdevAxel Lin1-3/+0
rdev won't be NULL in .enable callback. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-19regulator: axp20x: remove a redundant null check on rdevColin Ian King1-3/+0
Currently rdev is dereferenced when assigning desc before rdev is null checked, this is leading to static analysis warnings. However, rdev can never be null, so the null check is redundant and can be removed. Detected by CoverityScan, CID#1476031 ("Dereference before null check") Fixes: 77e3e3b165db ("regulator: axp20x: add software based soft_start for AXP209 LDO3") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-19Merge branch 'regulator-5.0' into regulator-5.1 stpmic1 const/rangeMark Brown1-6/+6
2019-02-18regulator: axp20x: fix DCDCB and BLDO2 definitions for AXP806Ondrej Jirman1-2/+2
This fixes another set of errors from the refactoring of literals to mask preproccesor definitions. Found by debugging a broken voltage setup on Orange Pi One Plus. Fixes: db4a555f7c4cf ("regulator: axp20x: use defines for masks") Signed-off-by: Ondrej Jirman <megous@megous.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-04regulator: axp20x: fix ALDO2, DLDO2 and ELDO3 definitions for AXP803Vasily Khoruzhick1-3/+3
Looks like refactoring didn't go well and left ALDO2, DLDO2 and ELDO3 definitions broken for AXP803 - now they are using register address instead of mask. Fix it by using mask where necessary. Fixes: db4a555f7c4cf ("regulator: axp20x: use defines for masks") Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-28regulator: axp20x: Fix incorrect vsel_mask settingsAxel Lin1-4/+4
Fix copy-paste mistake while converting to use defines for masks. Fixes: db4a555f7c4cf ("regulator: axp20x: use defines for masks") Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-28regulator: axp20x: fix ALDO2, DLDO2 and ELDO3 definitions for AXP803Vasily Khoruzhick1-3/+3
Looks like refactoring didn't go well and left ALDO2, DLDO2 and ELDO3 definitions broken for AXP803 - now they are using register address instead of mask. Fix it by using mask where necessary. Fixes: db4a555f7c4cf ("regulator: axp20x: use defines for masks") Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-09regulator: axp20x: check rdev is null before dereferencing itColin Ian King1-2/+6
Currently rdev is dereferenced when assigning desc before rdev is null checked, hence there is a potential null pointer dereference on rdev. Fix this by null checking rdev first. Detected by CoverityScan, CID#1476031 ("Dereference before null check") Fixes: 77e3e3b165db ("regulator: axp20x: add software based soft_start for AXP209 LDO3") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-17regulator: axp20x: fix set_ramp_delay for AXP209/dcdc2Priit Laes1-0/+1
Initial commit of set_ramp_delay feature was missing an assignment which should have populated slew_rate table for dcdc2 regulator. Add it. Fixes: d29f54df8b16 ("regulator: axp20x: add support for set_ramp_delay for AXP209") Signed-off-by: Priit Laes <plaes@plaes.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-13regulator: axp20x: add software based soft_start for AXP209 LDO3Olliver Schinagl1-1/+56
In the past, there have been words on various lists that if LDO3 is disabled in u-boot, but enabled in the DTS, the axp209 driver would fail to continue/hang. Several enable/disable patches have been issues to devicetree's in both the kernel and u-boot to address this issue. What really happened however, was that the AXP209 shuts down without a notice and without setting an interrupt. This is caused when LDO3 gets overloaded, for example with large capacitors on the LDO3 output. Normally, we would expect that AXP209 would source 200 mA as per datasheet and set and trigger an interrupt when being overloaded. For some reason however, this does not happen. As a work-around, we use the soft-start constraint of the regulator node to first bring up the LDO3 to the lowest possible voltage and then enable the LDO. After that, we can set the requested voltage as usual. Combining this setting with the regulator-ramp-delay allows LDO3 to enable voltage slowly and staggered, potentially reducing overall inrush current. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> Signed-off-by: Priit Laes <plaes@plaes.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-13regulator: axp20x: add support for set_ramp_delay for AXP209Olliver Schinagl1-0/+85
The AXP209 supports ramping up voltages on several regulators such as DCDC2 and LDO3. This patch adds preliminary support for the regulator-ramp-delay property for these 2 regulators. Note that the voltage ramp only works when regulator is already enabled. E.g. when going from say 0.7 V to 3.6 V. When turning on the regulator, no voltage ramp is performed in hardware. What this means, is that if the bootloader brings up the voltage at 0.7 V, the ramp delay property is properly applied. If however, the bootloader leaves the power off, no ramp delay is applied when the power is enabled by the regulator framework. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> Signed-off-by: Priit Laes <plaes@plaes.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-28regulator: axp20x: use defines for masksOlliver Schinagl1-178/+555
The AXP20X driver currently has several masks defined throughout the code. Use nice defines to make them clean and more descriptive. Additionally include bitops.h, which was missing before, and sort headers. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> Signed-off-by: Priit Laes <plaes@plaes.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-04regulator: axp20x: Mark expected switch fall-throughsGustavo A. R. Silva1-1/+2
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Notice that in this particular case, I moved the whole comment "Fall through to the check below.", which contains the "Fall through" comment, at the bottom of the case, which is what GCC is expecting to find. Addresses-Coverity-ID: 1436594 ("Missing break in switch") Addresses-Coverity-ID: 1364475 ("Missing break in switch") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-23regulator: axp20x: add drivevbus support for axp803Jagan Teki1-0/+2
Like axp221, axp223, axp813 the axp803 is also supporting external regulator to drive the OTG VBus through N_VBUSEN PMIC pin. Add support for it. Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Reviewed-by: Rob Herring <robh@kernel.org> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-18regulator: axp20x: Simplify axp20x_is_polyphase_slave implementationAxel Lin1-11/+1
The code to handle AXP803_ID and AXP813_ID cases are exactly the same. Make the switch-case fall through to avoid duplicate code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04regulator: axp20x: Add support for AXP813 regulatorsChen-Yu Tsai1-4/+98
The AXP813 PMIC has 7 DC-DC buck regulators, 16 LDOs (including the fixed RTC LDO and 2 GPIO LDOs), and 1 switchable. The drive-vbus feature is also supported. All the hardware details are very similar to the AXP803, with the following exceptions: - Extra DCDC7 buck regulator, with the same range as DCDC6 - SWitch now has a separate supply pin, instead of being chained internaly from DCDC1 - RTC LDO output voltage is now 1.8V - FLDO3 is an LDO with switchable supplies, but unconfigurable output voltage. The voltage is always half that of its supply. Support for FLDO3 is currently unimplemented, as it requires runtime switching of its supplies, something the regulator subsystem does not support. It is not used in either the reference designs nor actually produced boards available. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04regulator: axp20x: Fix poly-phase bit offset for AXP803 DCDC5/6Chen-Yu Tsai1-1/+1
The bit offset used to check if DCDC5 and DCDC6 are tied together in poly-phase output is wrong. It was checking against a reserved bit, which is always false. In reality, neither the reference design layout nor actually produced boards tie these two buck regulators together. But we should still fix it, just in case. Fixes: 1dbe0ccb0631 ("regulator: axp20x-regulator: add support for AXP803") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-07regulator: axp20x: add NULL check on devm_kzalloc() return valueGustavo A. R. Silva1-0/+6
Check return value from call to devm_kzalloc() in order to prevent a NULL pointer dereference. This issue was detected using Coccinelle and the following semantic patch: @@ expression x; identifier fld; @@ * x = devm_kzalloc(...); ... when != x == NULL x->fld Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-19regulator: axp20x-regulator: add support for AXP803Icenowy Zheng1-22/+131
AXP803 PMIC also have a series of regulators (DCDCs and LDOs) controllable via I2C/RSB bus. Add support for them. Signed-off-by: Icenowy Zheng <icenowy@aosc.io> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-02-19Merge remote-tracking branches 'regulator/topic/anatop', ↵Mark Brown1-4/+4
'regulator/topic/arizona', 'regulator/topic/as3711' and 'regulator/topic/bcm590xx' into regulator-next
2017-01-31regulator: axp20x-regulator: constify regulator_ops structureBhumika Goyal1-4/+4
Declare regulator_ops structure as const as it is only stored in the ops field of a regulator_desc structure. This field is of type const, so regulator_ops structures having this property can be made const too. File size before: drivers/regulator/axp20x-regulator.o text data bss dec hex filename 16848 1232 0 18080 46a0 regulator/axp20x-regulator.o File size after: drivers/regulator/axp20x-regulator.o text data bss dec hex filename 17888 192 0 18080 46a0 regulator/axp20x-regulator.o Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-01-23regulator: axp20x: AXP806: Fix dcdcb being set instead of dcdceRask Ingemann Lambertsen1-1/+1
A typo or copy-paste bug means that the register access intended for regulator dcdce goes to dcdcb instead. This patch corrects it. Fixes: 2ca342d391e3 (regulator: axp20x: Support AXP806 variant) Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2016-11-11regulator: axp20x: Fix axp809 ldo_io registration error on cold bootChen-Yu Tsai1-2/+10
The maximum supported voltage for ldo_io# is 3.3V, but on cold boot the selector comes up at 0x1f, which maps to 3.8V. This was previously corrected by Allwinner's U-boot, which set all regulators on the PMICs to some pre-configured voltage. With recent progress in U-boot SPL support, this is no longer the case. In any case we should handle this quirk in the kernel driver as well. This invalid setting causes _regulator_get_voltage() to fail with -EINVAL which causes regulator registration to fail when constrains are used: [ 1.054181] vcc-pg: failed to get the current voltage(-22) [ 1.059670] axp20x-regulator axp20x-regulator.0: Failed to register ldo_io0 [ 1.069749] axp20x-regulator: probe of axp20x-regulator.0 failed with error -22 This commits makes the axp20x regulator driver accept the 0x1f register value, fixing this. The datasheet does not guarantee reliable operation above 3.3V, so on boards where this regulator is used the regulator-max-microvolt setting must be 3.3V or less. This is essentially the same as the commit f40d4896bf32 ("regulator: axp20x: Fix axp22x ldo_io registration error on cold boot") for AXP22x PMICs. Fixes: a51f9f4622a3 ("regulator: axp20x: support AXP809 variant") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-09-13regulator: axp20x: Support AXP806 variantChen-Yu Tsai1-7/+111
The X-Powers AXP806 PMIC has a new set of buck and LDO regulators, and also a switch. The buck regulators support teaming into multi-phase groups, with A+B, A+B+C, D+E groupings. Some registers controlling DCDC converter work settings are at different offsets. Deal with them as well. Add support for this new variant. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-06-06regulator: axp20x: Add support for the (external) drivebus regulatorHans de Goede1-0/+30
The axp20x pmics have 2 power inputs, one called ACIN which is intended for to be supplied via a powerbarrel on the board and one called VBUS which is intended to be supplied via an otg connector. In the VBUS case the pmic needs to know if the board is supplying power to the otg connector, because then it should not take any power from its VBUS pin. The axp209 pmic has a N_VBUSEN input pin via which the board can signal to the pmic whether the board is supplying power to the otg connector or not. On the axp221/axp223 this pin can alternatively be used as an output which controls an external regulator which (optionally) supplies power to the otg connector from the board. When the pin is used as output it is called DRIVEVBUS in the datasheet. This commit adds support for the DRIVEVBUS pin as an extra pmic controlled regulator. Since this is optional a new x-powers,drivebus dt property is added. When this is present the misc-control register is written to change the N_VBUSEN input pin to DRIVEVBUS output pin mode and the extra drivebus regulator is registered with the regulator subsystem. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-05-31regulator: axp20x: support AXP809 variantChen-Yu Tsai1-29/+90
The X-Powers AXP809 PMIC has a similar set of regulators as the AXP221, though a few LDOs were removed, and a new switch output added. Like the AXP221, AXP809 also has DC1SW and DC5LDO, which are internally chained to DCDC1 and DCDC5, respectively. Add support for this new variant. Also remove the "axp22x_" prefix from DC1SW/DC5LDO supply handling code, as the AXP809 uses it as well. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-04-29regulator: axp20x: Fix axp22x ldo_io registration error on cold bootHans de Goede1-2/+6
The maximum supported voltage for ldo_io# is 3.3V, but on cold boot the selector comes up at 0x1f, which maps to 3.8V. This causes _regulator_get_voltage() to fail with -EINVAL which causes regulator registration to fail when constrains are used: [ 1.467788] vcc-touchscreen: failed to get the current voltage(-22) [ 1.474209] axp20x-regulator axp20x-regulator: Failed to register ldo_io1 [ 1.483363] axp20x-regulator: probe of axp20x-regulator failed with error -22 This commits makes the axp20x regulator driver accept the 0x1f register value, fixing this. The datasheet does not guarantee reliable operation above 3.3V, so on boards where this regulator is used the regulator-max-microvolt setting must be 3.3V or less. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-04-27regulator: axp20x: Fix axp22x ldo_io voltage rangesHans de Goede1-2/+2
The minium voltage of 1800mV is a copy and paste error from the axp20x regulator info. The correct minimum voltage for the ldo_io regulators on the axp22x is 700mV. Fixes: 1b82b4e4f954 ("regulator: axp20x: Add support for AXP22X regulators") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-04-26regulator: axp20x: Fix LDO4 linear voltage rangeMaxime Ripard1-1/+3
The current linear voltage range for the LDO4 regulator found in the APX20X PMICs assumes that the voltage is linear between 2.5 and 3.1V. However, the PMIC can output up to 3.3V on that regulator by skipping the 2.6V and 2.9V steps. Fix the ranges to read and set the proper voltages. Fixes: 13d57e64352a ("regulator: axp20x: Use linear voltage ranges for AXP20X LDO4") Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-03-18Merge tag 'mfd-for-linus-4.6' of ↵Linus Torvalds1-0/+3
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd Pull MFD updates from Lee Jones: "New Drivers: - Freescale Touch Screen ADC - X-Powers AXP PMIC with RSB - TI TPS65086 Power Management IC (PMIC) New Device Support: - Supply device PCI IDs for Intel Broxton Fix-ups: - Move to clkdev_create() API; intel_quark_i2c_gpio - Complete re-write of TI's TPS65912 Power Management IC (PMIC) - Remove unnecessary function argument; axp20x - Separate out bus related code; axp20x - Coding Style changes; axp20x - Allow more drivers to be compiled as modules - Work around false positive 'used uninitialised' warning; db8500-prcmu Bug Fixes: - Remove do_div(); fsl-imx25-gcq - Fix driver init when built-in; tps65010 - Fix clock-unregister leak; intel-lpss" * tag 'mfd-for-linus-4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (53 commits) mfd: intel-lpss: Pass I2C configuration via properties on BXT mfd: imx6sx: Add PCIe register definitions for iomuxc gpr mfd: ipaq-micro: Use __maybe_unused to hide pm functions mfd: max77686: Add max77802 to I2C device ID table mfd: max77686: Export OF module alias information mfd: max77686: Allow driver to be built as a module mfd: stmpe: Add the proper PWM resources mfd: tps65090: Set regmap config reg counts properly mfd: syscon: Return ENOTSUPP instead of ENOSYS when disabled mfd: as3711: Set regmap config reg counts properly mfd: rc5t583: Set regmap config reg counts properly gpio: tps65086: Add GPO driver for the TPS65086 PMIC mfd: mt6397: Add platform device ID table mfd: da9063: Fix missing volatile registers in the core regmap_range volatile lists mfd: mt6397: Add MT6323 support to MT6397 driver mfd: mt6397: Add support for different Slave types mfd: mt6397: int_con and int_status may vary in location dt-bindings: mfd: Add bindings for the MediaTek MT6323 PMIC mfd: da9062: Fix missing volatile registers in the core regmap_range volatile lists mfd: Add documentation for ACT8945A DT bindings ...
2016-02-15regulator: axp20x: Use of_match name as default regulator nameChen-Yu Tsai1-5/+5
Originally the helper macros used uppercase regulator names, which are primarily used to expand to the regulator ID enum, as the default names. This is aestheticly unpleasent. Since the of_match bits are the same, just lowercase, use that as the default names instead. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-02-12regulator: axp20x: Support new AXP223 PMICChen-Yu Tsai1-0/+3
The AXP223 is a new PMIC commonly paired with Allwinner A23/A33 SoCs. It is functionally identical to AXP221; only the regulator default voltage/status and the external host interface are different. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-02-03regulator: axp20x: Use linear voltage ranges for AXP20X LDO4Chen-Yu Tsai1-15/+17
AXP20X datasheet lists the possible voltage settings for LDO4, so it was implemented using a voltage table. Upon closer examination, the valid voltages can be mapped into 3 linear ranges. Move AXP20X LDO4 to use linear ranges. The supporting code can be reused with later AXP8xx PMICs, which have a number of regulators that have 2 linear ranges. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-02-03regulator: axp20x: Remove voltage readout support for switch regulatorsChen-Yu Tsai1-11/+3
Switch-type regulators, such as DC1SW on AXP22X, are a secondary output from DCDC1. They are just an on/off switch, and the driver should not try to read its voltage directly from the DCDC1 control registers. Instead, the core will pass down the voltage from the regulator supply chain. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-12-23regulator: axp20x: Fix GPIO LDO enable value for AXP22xChen-Yu Tsai1-2/+2
The enable/disable values for GPIO LDOs are reversed. It seems no one noticed as AXP22x support was introduced recently, and no one was using the GPIO LDOs, either because no designs actually use them or board support hasn't caught up. Fixes: 1b82b4e4f954 ("regulator: axp20x: Add support for AXP22X regulators") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
2015-11-04Merge remote-tracking branches 'regulator/topic/act8865', ↵Mark Brown1-4/+50
'regulator/topic/anatop', 'regulator/topic/arizona', 'regulator/topic/axp20x' and 'regulator/topic/bcm590xx' into regulator-next
2015-10-05regulator: axp20x: set supply names for AXP22X DC1SW/DC5LDO internallyChen-Yu Tsai1-4/+50
The DC1SW and DC5LDO regulators in the AXP22X are internally chained to DCDC1 and DCDC5, hence the names. The original bindings used the parent regulator names for the supply regulator property. Since they are internally connected, the relationship should not be represented in the device tree, but handled internally by the driver. This patch has the driver remember the regulator names for the parent DCDC1/DCDC5, and use them as supply names for DC1SW/DC5LDO. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>