summaryrefslogtreecommitdiff
path: root/drivers/regulator
AgeCommit message (Collapse)AuthorFilesLines
2023-04-12regulator: da9063: add voltage monitoring registersBenjamin Bara1-0/+29
Add the definitions for the registers responsible for voltage monitoring. Add a voltage monitor enable bitfield per regulator. Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Adam Ward <DLG-Adam.Ward.opensource@dm.renesas.com> Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com> Link: https://lore.kernel.org/r/20230403-da9063-disable-unused-v3-1-cc4dc698864c@skidata.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11Add support for Rockchip RK860X regulatorsMark Brown2-48/+157
Merge series from Cristian Ciocaltea <cristian.ciocaltea@collabora.com>: This patch series introduces support for the Rockchip RK860X regulators, while also providing a few fixes and improvements to the existing fan53555 driver. RK8600/RK8601 are quite similar to the FAN53555 regulators. RK8602/RK8603 are a bit different, having a wider output voltage selection range, from 0.5 V to 1.5 V in 6.25 mV steps. They are used in the Rock 5B board to power the ARM Cortex-A76 cores and the NPU.
2023-04-11regulator: fan53555: Add support for RK860XCristian Ciocaltea1-3/+118
Extend the existing fan53555 driver to support the Rockchip RK860X regulators. RK8600/RK8601 are pretty similar to the FAN53555 regulators. RK8602/RK8603 are a bit different, having a wider output voltage selection range, from 0.5 V to 1.5 V in 6.25 mV steps. They also use additional VSEL0/VSEL1 registers for the voltage selector, but the enable and mode bits are still located in the original FAN53555 specific VSEL0/VSEL1 registers. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230406194158.963352-9-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11regulator: fan53555: Use dev_err_probeCristian Ciocaltea1-26/+21
Use dev_err_probe() instead of dev_err() in the probe function, which ensures the error code is always printed and, additionally, simplifies the code a bit. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20230406194158.963352-8-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11regulator: fan53555: Improve vsel_mask computationCristian Ciocaltea1-2/+2
In preparation for introducing support for additional regulators which do not use the maximum number of voltage selectors available for a given mask, improve the mask computation formula by using fls(). Note fls() requires the bitops header, hence include it explicitly and drop bits.h which is already pulled by bitops.h. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20230406194158.963352-7-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11regulator: fan53555: Make use of the bit macrosCristian Ciocaltea1-9/+9
For consistency and improved clarity, use BIT() and GENMASK() macros for defining the bitfields inside the registers. No functional changes intended. While here, also fix DIE_{ID,REV} inconsistent indentation. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20230406194158.963352-6-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11regulator: fan53555: Remove unused *_SLEW_SHIFT definitionsCristian Ciocaltea1-2/+0
Commit b61ac767db4d ("regulator: fan53555: Convert to use regulator_set_ramp_delay_regmap") removed the slew_shift member from struct fan53555_device_info, hence the {CTL,TCS}_SLEW_SHIFT definitions remained unused. Drop them. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20230406194158.963352-5-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11regulator: sm5703: Fix missing n_voltages for fixed regulatorsAxel Lin1-0/+2
Set n_voltages = 1 for fixed regulators. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Markuss Broks <markuss.broks@gmail.com> Link: https://lore.kernel.org/r/20230409025529.241699-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-11regulator: qcom_smd: Add MP5496 S1 regulatorDevi Priya1-2/+3
Adding support for MP5496 S1 regulator on IPQ9574 SoC. Co-developed-by: Praveenkumar I <quic_ipkumar@quicinc.com> Signed-off-by: Praveenkumar I <quic_ipkumar@quicinc.com> Signed-off-by: Devi Priya <quic_devipriy@quicinc.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20230407155727.20615-3-quic_devipriy@quicinc.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-06regulator: fan53555: Fix wrong TCS_SLEW_MASKCristian Ciocaltea1-1/+1
The support for TCS4525 regulator has been introduced with a wrong ramp-rate mask, which has been defined as a logical expression instead of a bit shift operation. For clarity, fix it using GENMASK() macro. Fixes: 914df8faa7d6 ("regulator: fan53555: Add TCS4525 DCDC support") Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20230406171806.948290-4-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-06regulator: fan53555: Explicitly include bits headerCristian Ciocaltea1-5/+6
Since commit f2a9eb975ab2 ("regulator: fan53555: Add support for FAN53526") the driver makes use of the BIT() macro, but relies on the bits header being implicitly included. Explicitly pull the header in to avoid potential build failures in some configurations. While here, reorder include directives alphabetically. Fixes: f2a9eb975ab2 ("regulator: fan53555: Add support for FAN53526") Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20230406171806.948290-3-cristian.ciocaltea@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-06regulator: qcom-rpmh: add support for pmm8654au regulatorsBartosz Golaszewski1-0/+55
Add the RPMH regulators exposed by the PMM8654au PMIC and its variants. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20230406192811.460888-3-brgl@bgdev.pl Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-06regulator: core: Avoid lockdep reports when resolving suppliesDouglas Anderson1-8/+83
An automated bot told me that there was a potential lockdep problem with regulators. This was on the chromeos-5.15 kernel, but I see nothing that would be different downstream compared to upstream. The bot said: ============================================ WARNING: possible recursive locking detected 5.15.104-lockdep-17461-gc1e499ed6604 #1 Not tainted -------------------------------------------- kworker/u16:4/115 is trying to acquire lock: ffffff8083110170 (regulator_ww_class_mutex){+.+.}-{3:3}, at: create_regulator+0x398/0x7ec but task is already holding lock: ffffff808378e170 (regulator_ww_class_mutex){+.+.}-{3:3}, at: ww_mutex_trylock+0x3c/0x7b8 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(regulator_ww_class_mutex); lock(regulator_ww_class_mutex); *** DEADLOCK *** May be due to missing lock nesting notation 4 locks held by kworker/u16:4/115: #0: ffffff808006a948 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x520/0x1348 #1: ffffffc00e0a7cc0 ((work_completion)(&entry->work)){+.+.}-{0:0}, at: process_one_work+0x55c/0x1348 #2: ffffff80828a2260 (&dev->mutex){....}-{3:3}, at: __device_attach_async_helper+0xd0/0x2a4 #3: ffffff808378e170 (regulator_ww_class_mutex){+.+.}-{3:3}, at: ww_mutex_trylock+0x3c/0x7b8 stack backtrace: CPU: 2 PID: 115 Comm: kworker/u16:4 Not tainted 5.15.104-lockdep-17461-gc1e499ed6604 #1 9292e52fa83c0e23762b2b3aa1bacf5787a4d5da Hardware name: Google Quackingstick (rev0+) (DT) Workqueue: events_unbound async_run_entry_fn Call trace: dump_backtrace+0x0/0x4ec show_stack+0x34/0x50 dump_stack_lvl+0xdc/0x11c dump_stack+0x1c/0x48 __lock_acquire+0x16d4/0x6c74 lock_acquire+0x208/0x750 __mutex_lock_common+0x11c/0x11f8 ww_mutex_lock+0xc0/0x440 create_regulator+0x398/0x7ec regulator_resolve_supply+0x654/0x7c4 regulator_register_resolve_supply+0x30/0x120 class_for_each_device+0x1b8/0x230 regulator_register+0x17a4/0x1f40 devm_regulator_register+0x60/0xd0 reg_fixed_voltage_probe+0x728/0xaec platform_probe+0x150/0x1c8 really_probe+0x274/0xa20 __driver_probe_device+0x1dc/0x3f4 driver_probe_device+0x78/0x1c0 __device_attach_driver+0x1ac/0x2c8 bus_for_each_drv+0x11c/0x190 __device_attach_async_helper+0x1e4/0x2a4 async_run_entry_fn+0xa0/0x3ac process_one_work+0x638/0x1348 worker_thread+0x4a8/0x9c4 kthread+0x2e4/0x3a0 ret_from_fork+0x10/0x20 The problem was first reported soon after we made many of the regulators probe asynchronously, though nothing I've seen implies that the problems couldn't have also happened even without that. I haven't personally been able to reproduce the lockdep issue, but the issue does look somewhat legitimate. Specifically, it looks like in regulator_resolve_supply() we are holding a "rdev" lock while calling set_supply() -> create_regulator() which grabs the lock of a _different_ "rdev" (the one for our supply). This is not necessarily safe from a lockdep perspective since there is no documented ordering between these two locks. In reality, we should always be locking a regulator before the supplying regulator, so I don't expect there to be any real deadlocks in practice. However, the regulator framework in general doesn't express this to lockdep. Let's fix the issue by simply grabbing the two locks involved in the same way we grab multiple locks elsewhere in the regulator framework: using the "wound/wait" mechanisms. Fixes: eaa7995c529b ("regulator: core: avoid regulator_resolve_supply() race condition") Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230329143317.RFC.v2.2.I30d8e1ca10cfbe5403884cdd192253a2e063eb9e@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-06regulator: core: Consistently set mutex_owner when using ww_mutex_lock_slow()Douglas Anderson1-0/+2
When a codepath locks a rdev using ww_mutex_lock_slow() directly then that codepath is responsible for incrementing the "ref_cnt" and also setting the "mutex_owner" to "current". The regulator core consistently got that right for "ref_cnt" but didn't always get it right for "mutex_owner". Let's fix this. It's unlikely that this truly matters because the "mutex_owner" is only needed if we're going to do subsequent locking of the same rdev. However, even though it's not truly needed it seems less surprising if we consistently set "mutex_owner" properly. Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230329143317.RFC.v2.1.I4e9d433ea26360c06dd1381d091c82bb1a4ce843@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-29regulator: Add Richtek RT4803 boost regulatorChiYuan Huang3-0/+227
RT4803 is a boost converter that integrates an internal bypass FET. It will automatically transform the operation mode between bypass and boost based on the voltage difference of the input and output voltage. Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> Link: https://lore.kernel.org/r/1680050606-461-2-git-send-email-cy_huang@richtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-27regulator: Handle deferred clkChristophe JAILLET1-1/+1
devm_clk_get() can return -EPROBE_DEFER. So it is better to return the error code from devm_clk_get(), instead of a hard coded -ENOENT. This gives more opportunities to successfully probe the driver. Fixes: 8959e5324485 ("regulator: fixed: add possibility to enable by clock") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/18459fae3d017a66313699c7c8456b28158b2dd0.1679819354.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-24regulator: qcom-rpmh: Revert "regulator: qcom-rpmh: Use PROBE_FORCE_SYNCHRONOUS"Douglas Anderson1-1/+1
This reverts commit 58973046c1bf ("regulator: qcom-rpmh: Use PROBE_FORCE_SYNCHRONOUS"). Further digging into the problems that prompted the us to switch to synchronous probe showed that the root cause was a missing "rootwait" in the kernel command line arguments. Let's reinstate asynchronous probe. Fixes: 58973046c1bf ("regulator: qcom-rpmh: Use PROBE_FORCE_SYNCHRONOUS") Cc: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230324063357.1.Ifdf3625a3c5c9467bd87bfcdf726c884ad220a35@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-24regulator: qcom-rpmh: Use PROBE_FORCE_SYNCHRONOUSMarek Szyprowski1-1/+1
Restore synchronous probing for 'qcom,pm8150-rpmh-regulators' because otherwise the UFSHC device is not properly initialized on QRB5165-RB5 board. Fixes: ed6962cc3e05 ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 4.14 and 4.19") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://lore.kernel.org/r/20230323220518.3247530-1-m.szyprowski@samsung.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-23regulator: arizona-micsupp: Use PROBE_FORCE_SYNCHRONOUSCharles Keepax1-2/+2
Restore synchronous probing for Arizona regulators as the main MFD relies on the ordering of the devices probing. As these regulators are built into the CODEC and typically have no DT representation the regulator framework is unaware of their existence until the driver probes. These means the probing of the driver needs to be synchronous to ensure the regulators are not substitued for the dummy later when the users request them. Fixes: 259b93b21a9f ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230323132047.833737-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-23regulator: arizona-ldo1: Use PROBE_FORCE_SYNCHRONOUSCharles Keepax1-2/+2
Restore synchronous probing for Arizona regulators because otherwise the main MFD driver will not find its core supplies. As these regulators are built into the CODEC and typically have no DT representation the regulator framework is unaware of their existence until the driver probes. These means the probing of the driver needs to be synchronous to ensure the regulators are not substitued for the dummy later when the users request them. Fixes: 259b93b21a9f ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230323132047.833737-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-23regulator: wm8994: Use PROBE_FORCE_SYNCHRONOUSMarek Szyprowski1-1/+1
Restore synchronous probing for wm8994 regulators because otherwise the sound device is never initialized on Exynos5250-based Arndale board. Fixes: 259b93b21a9f ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230323083312.199189-1-m.szyprowski@samsung.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that are newer than 6.1Douglas Anderson4-0/+4
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") but changes regulators that were not present in kernel 6.1. Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.7.I31771918f1d8dbe4bfb9f1fef7ff987f2b7504b5@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.15 and 6.1Douglas Anderson12-0/+12
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") but changes regulators didn't exist in Linux 5.15 but did exist in Linux 6.1. Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.6.Ibc8a86ddd5055ebbbe487a529199db7b36ccad1a@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.10 and 5.15Douglas Anderson15-0/+15
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") but changes regulators didn't exist in Linux 5.10 but did exist in Linux 5.15. Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.5.Ia0e6d859bdfe42ea5c187fb1eb4705c1b5ea23a1@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.4 and 5.10Douglas Anderson18-1/+19
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") but changes regulators didn't exist in Linux 5.4 but did exist in Linux 5.10. Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.4.I01f21c98901641a009890590ddc1354c0f294e5e@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 4.19 and 5.4Douglas Anderson11-0/+11
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") but changes regulators didn't exist in Linux 4.19 but did exist in Linux 5.4. Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.3.I45bf925ca9537da5f647e2acb0ad207c0c98af81@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 4.14 and 4.19Douglas Anderson6-0/+6
This follows on the change ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") but changes regulators didn't exist in Linux 4.14 but did exist in Linux 4.19. NOTE: from a quick "git cherry-pick" it looks as if "bd718x7-regulator.c" didn't actually exist in v4.19. In 4.19 it was named "bd71837-regulator.c". See commit 2ece646c90c5 ("regulator: bd718xx: rename bd71837 to 718xx") Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.2.Iad1f25517bb46a6c7fca8d8c80ed4fc258a79ed9@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14Douglas Anderson114-1/+121
Probing of regulators can be a slow operation and can contribute to slower boot times. This is especially true if a regulator is turned on at probe time (with regulator-boot-on or regulator-always-on) and the regulator requires delays (off-on-time, ramp time, etc). While the overall kernel is not ready to switch to async probe by default, as per the discussion on the mailing lists [1] it is believed that the regulator subsystem is in good shape and we can move regulator drivers over wholesale. There is no way to just magically opt in all regulators (regulators are just normal drivers like platform_driver), so we set PROBE_PREFER_ASYNCHRONOUS for all regulators found in 'drivers/regulator' individually. Given the number of drivers touched and the impossibility to test this ahead of time, it wouldn't be shocking at all if this caused a regression for someone. If there is a regression caused by this patch, it's likely to be one of the cases talked about in [1]. As a "quick fix", drivers involved in the regression could be fixed by changing them to PROBE_FORCE_SYNCHRONOUS. That being said, the correct fix would be to directly fix the problem that caused the issue with async probe. The approach here follows a similar approach that was used for the mmc subsystem several years ago [2]. In fact, I ran nearly the same python script to auto-generate the changes. The only thing I changed was to search for "i2c_driver", "spmi_driver", and "spi_driver" in addition to "platform_driver". [1] https://lore.kernel.org/r/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk [2] https://lore.kernel.org/r/20200903232441.2694866-1-dianders@chromium.org/ Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230316125351.1.I2a4677392a38db5758dee0788b2cea5872562a82@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-14regulator: core: Shorten off-on-delay-us for always-on/boot-on by time since ↵Douglas Anderson1-4/+3
booted This is very close to a straight revert of commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"). We've identified that patch as causing a boot speed regression on sc7180-trogdor boards. While boot speed certainly isn't more important than making sure that power sequencing is correct, looking closely at the original change it doesn't seem to have been fully justified. It mentions "cycling issues" without describing exactly what the issues were. That means it's possible that the cycling issues were really a problem that should be fixed in a different way. Let's take a careful look at how we should handle regulators that have an off-on-delay and that are boot-on or always-on. Linux currently doesn't have any way to identify whether a GPIO regulator was already on when the kernel booted. That means that when the kernel boots we probe a regulator, see that it wants boot-on / always-on we, and then turn the regulator on. We could be in one of two cases when we do this: a) The regulator might have been left on by the bootloader and we're ensuring that it stays on. b) The regulator might have been left off by the bootloader and we're just now turning it on. For case a) we definitely don't need any sort of delay. For case b) we _might_ need some delay in case the bootloader turned the regulator off _right_ before booting the kernel. To get the proper delay for case b) then we can just assume a `last_off` of 0, which is what it gets initialized to by default. As per above, we can't tell whether we're in case a) or case b) so we'll assume the longer delay (case b). This basically puts the code to how it was before commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"). However, we add one important change: we make sure that the delay is actually honored if `last_off` is 0. Though the original "cycling issues" cited were vague, I'm hopeful that this important extra change will be enough to fix the issues that the initial commit mentioned. With this fix, I've confined that on a sc7180-trogdor board the delay at boot goes down from 500 ms to ~250 ms. That's not as good as the 0 ms that we had prior to commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"), but it's probably safer because we don't know if the bootloader turned the regulator off right before booting. One note is that it's possible that we could be in a state that's not a) or b) if there are other issues in the kernel. The only one I can think of is related to pinctrl. If the pinctrl driver being used on a board isn't careful about avoiding glitches when setting up a pin then it's possible that setting up a pin could cause the regulator to "turn off" briefly immediately before the regulator probes. If this is indeed causing problems then the pinctrl driver should be fixed, perhaps in a similar way to what was done in commit d21f4b7ffc22 ("pinctrl: qcom: Avoid glitching lines when we first mux to output") Fixes: 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators") Cc: Christian Kohlschütter <christian@kohlschutter.com> Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20230313111806.1.I2eaad872be0932a805c239a7c7a102233fb0b03b@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-13regulator: mt6397-regulator: Mark OF related data as maybe unusedKrzysztof Kozlowski1-1/+1
The driver can be compile tested with !CONFIG_OF making certain data unused: drivers/regulator/mt6397-regulator.c:400:34: error: ‘mt6397_of_match’ defined but not used [-Werror=unused-const-variable=] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230310214553.275450-4-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-13regulator: mp8859: Mark OF related data as maybe unusedKrzysztof Kozlowski1-1/+1
The driver can be compile tested with !CONFIG_OF making certain data unused: drivers/regulator/mp8859.c:132:34: error: ‘mp8859_dt_id’ defined but not used [-Werror=unused-const-variable=] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230310214553.275450-3-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-13regulator: max20086: Mark OF related data as maybe unusedKrzysztof Kozlowski1-1/+1
The driver can be compile tested with !CONFIG_OF making certain data unused: drivers/regulator/max20086-regulator.c:289:34: error: ‘max20086_dt_ids’ defined but not used [-Werror=unused-const-variable=] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: https://lore.kernel.org/r/20230310214553.275450-2-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-13regulator: lp872x: Mark OF related data as maybe unusedKrzysztof Kozlowski1-1/+1
The driver can be compile tested with !CONFIG_OF making certain data unused: drivers/regulator/lp872x.c:931:34: error: ‘lp872x_dt_ids’ defined but not used [-Werror=unused-const-variable=] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230310214553.275450-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-11regulator: Use of_property_read_bool() for boolean propertiesRob Herring7-36/+17
It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. Convert reading boolean properties to to of_property_read_bool(). Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230310144722.1544843-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-11regulator: Use of_property_present() for testing DT property presenceRob Herring4-7/+7
It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230310144721.1544756-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-07regulator: rt5739: Spelling s/Rcihtek/Richtek/Geert Uytterhoeven1-1/+1
Fix a misspelling of "Richtek". Fixes: 4536f3b93a3373ca ("regulator: Add support for Richtek RT5739 voltage regulator") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/05f26d8e1e527f8b3fd2828f75ce2174e19c69e7.1678188171.git.geert+renesas@glider.be Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-06regulator: Add support for Richtek RT5739 voltage regulatorChiYuan Huang3-0/+304
The RT5739 is a step-down switching voltage regulator that supports output voltage ragne from 300mV to 1300mV with the wide input supply voltage range from 2.5V to 5.5V. Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> Link: https://lore.kernel.org/r/1676599618-24819-3-git-send-email-cy_huang@richtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-03thermal/core: Use the thermal zone 'devdata' accessor in remaining driversDaniel Lezcano1-1/+1
The thermal zone device structure is exposed to the different drivers and obviously they access the internals while that should be restricted to the core thermal code. In order to self-encapsulate the thermal core code, we need to prevent the drivers accessing directly the thermal zone structure and provide accessor functions to deal with. Use the devdata accessor introduced in the previous patch. No functional changes intended. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Mark Brown <broonie@kernel.org> Reviewed-by: Ido Schimmel <idosch@nvidia.com> #mlxsw Acked-by: Gregory Greenman <gregory.greenman@intel.com> #iwlwifi Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> #power_supply Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> #ahci Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-03-02Merge tag 'regulator-fix-v6.3' of ↵Linus Torvalds2-4/+4
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator Pull regulator fixes from Mark Brown: "Two fixes here, one driver fix for incorrect error codes and a fix in the core to use ktime_get_boottime() in order to fix accounting of the time regulators have been powered down over suspend. ktime_get() pauses over suspend which is not what we want" * tag 'regulator-fix-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: core: Use ktime_get_boottime() to determine how long a regulator was off regulator: max597x: Fix error return code in max597x_get_status
2023-02-23regulator: core: Use ktime_get_boottime() to determine how long a regulator ↵Matthias Kaehlcke1-3/+3
was off For regulators with 'off-on-delay-us' the regulator framework currently uses ktime_get() to determine how long the regulator has been off before re-enabling it (after a delay if needed). A problem with using ktime_get() is that it doesn't account for the time the system is suspended. As a result a regulator with a longer 'off-on-delay' (e.g. 500ms) that was switched off during suspend might still incurr in a delay on resume before it is re-enabled, even though the regulator might have been off for hours. ktime_get_boottime() accounts for suspend time, use it instead of ktime_get(). Fixes: a8ce7bd89689 ("regulator: core: Fix off_on_delay handling") Cc: stable@vger.kernel.org # 5.13+ Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20230223003301.v2.1.I9719661b8eb0a73b8c416f9c26cf5bd8c0563f99@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-22Merge tag 'regulator-v6.3' of ↵Linus Torvalds11-66/+247
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator Pull regulator updates from Mark Brown: "This has been a very quiet release for the regulator API: there's one new driver for the Maxim MAX20411, some DT schema conversions and some small tweaks and improvements but really nothing major at all" * tag 'regulator-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (22 commits) regulator: max597x: Align for simple_mfd_i2c driver regulator: max20411: Fix off-by-one for n_voltages setting regulator: max597x: Remove unused variable regulator: tps65219: use generic set_bypass() regulator: s5m8767: Bounds check id indexing into arrays regulator: max77802: Bounds check regulator id against opmode regulator: max20411: Convert to i2c's .probe_new() regulator: scmi: Allow for zero voltage domains regulator: max20411: Directly include bitfield.h regulator: Introduce Maxim MAX20411 Step-Down converter regulator: dt-bindings: Describe Maxim MAX20411 regulator: dt-bindings: qcom-labibb: Allow regulator-common properties regulator: dt-bindings: fixed-regulator: allow gpios property regulator: tps65219: use IS_ERR() to detect an error pointer regulator: mcp16502: add enum MCP16502_REG_HPM description regulator: fixed-helper: use the correct function name in comment regulator: act8945a: fix non-kernel-doc comments dt-bindings: regulators: convert non-smd RPM Regulators bindings to dt-schema regulator: dt-bindings: Convert Fairchild FAN53555 to DT schema regulator: dt-bindings: qcom,usb-vbus-regulator: change node name ...
2023-02-20regulator: max597x: Fix error return code in max597x_get_statusAxel Lin1-1/+1
REGULATOR_FAILED_RETRY should not be used in max597x_get_status error path. Othewise, the regulator core will treat it as REGULATOR_STATUS_ON. Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20230220105614.356187-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-16regulator: max597x: Align for simple_mfd_i2c driverNaresh Solanki1-14/+32
Use regmap provided by simple_mfd_i2c driver and remove unused variable. Identify device variant by checking compatible property in DT. Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230216075302.68935-1-Naresh.Solanki@9elements.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-13regulator: max20411: Fix off-by-one for n_voltages settingAxel Lin1-1/+1
Otherwise regulator_list_voltage returns -EINVAL for MAX20411_MAX_SEL. Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20230211150019.1545542-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-10regulator: max597x: Remove unused variableNaresh Solanki1-6/+0
max597x_regmap_config isn't used & hence remove the same. Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230210163225.1208035-1-Naresh.Solanki@9elements.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-03regulator: tps65219: use generic set_bypass()Jerome Neanne1-19/+1
Due to wrong interpretation of the specification, custom implementation was used instead of standard regmap helper. LINK: https://lore.kernel.org/all/c2014039-f1e8-6976-33d6-52e2dd4e7b66@baylibre.com/ Fixes: c12ac5fc3e0a ("regulator: drivers: Add TI TPS65219 PMIC regulators support") Regulator does NOT require to be off to be switched to bypass mode. Signed-off-by: Jerome Neanne <jneanne@baylibre.com> Link: https://lore.kernel.org/r/20230203140119.13029-1-jneanne@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-01-28regulator: s5m8767: Bounds check id indexing into arraysKees Cook1-1/+5
The compiler has no way to know if "id" is within the array bounds of the regulators array. Add a check for this and a build-time check that the regulators and reg_voltage_map arrays are sized the same. Seen with GCC 13: ../drivers/regulator/s5m8767.c: In function 's5m8767_pmic_probe': ../drivers/regulator/s5m8767.c:936:35: warning: array subscript [0, 36] is outside array bounds of 'struct regulator_desc[37]' [-Warray-bounds=] 936 | regulators[id].vsel_reg = | ~~~~~~~~~~^~~~ Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: linux-samsung-soc@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230128005358.never.313-kees@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-01-28regulator: max77802: Bounds check regulator id against opmodeKees Cook1-10/+24
Explicitly bounds-check the id before accessing the opmode array. Seen with GCC 13: ../drivers/regulator/max77802-regulator.c: In function 'max77802_enable': ../drivers/regulator/max77802-regulator.c:217:29: warning: array subscript [0, 41] is outside array bounds of 'unsigned int[42]' [-Warray-bounds=] 217 | if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) | ~~~~~~~~~~~~~~~~^~~~ ../drivers/regulator/max77802-regulator.c:62:22: note: while referencing 'opmode' 62 | unsigned int opmode[MAX77802_REG_MAX]; | ^~~~~~ Cc: Javier Martinez Canillas <javier@dowhile0.org> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20230127225203.never.864-kees@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-01-27regulator: max20411: Convert to i2c's .probe_new()Uwe Kleine-König1-3/+2
The probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230127101726.1313927-1-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
2023-01-27regulator: scmi: Allow for zero voltage domainsCristian Marussi1-10/+6
SCMI Voltage protocol allows the platform to report no voltage domains on discovery, while warning the user about such an odd configuration. As a consequence this condition should not be treated as error by the SCMI regulator driver either. Allow SCMI regulator driver to probe successfully even when no voltage domains are discovered. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Link: https://lore.kernel.org/r/20230126180511.766373-1-cristian.marussi@arm.com Signed-off-by: Mark Brown <broonie@kernel.org>