[PATCH v6 0/4] regulator: qcom-rpmh: Support RPMH address reads and use it for rpmh-regulators
Kamal Wadhwa <[email protected]> Sat, 01 Aug 2026 13:30:26 +0530
| Newsgroups | org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
This patch series adds a new `rpmh_read()` API to allow reading RPMH addresses. Using this API enhances the RPMH regulator driver by adding readback of the voltage/bypass/mode settings as they have been applied by APPS during the bootloader stage, so regulator framework can get them via `get_mode`, `get_bypass` & `get_voltage_selector` callbacks during regulator registration. This is needed because currently regulator framework does a unnecessary write with `min-microvolt` DT setting for all the RPMH regulators during regulator registration, because the first time after boot the value is seen as -ENOTRECOVERABLE, as there is no option to read these regulator settings. With this change this unnecessary write can be avoided and regulator framework gets a sense of the initial state set during the bootloader stage for all regulator settings. NOTE - During discussion on the v2 series - PATCH 3/4, reviewer had inquired about possible need for the use of the sync_state() to handle the "multiple" client case - for maintaining the regulator settings till all the clients are probed. This case was not covered in my previous series and had originally planned to do that series separately. But after the discussion decided to merge the 2 series as it seemed this would be a better approach. But after working on sync_state change. I realized a basic issue with using sync_state() for regulators - that its per-driver and not per-regulator resource. But we needed a sync_state callback for each regulator separately. I had been experimenting with few ideas but seems its going to need more time for me to close on the equivalent solution that has per-regulator sync_state or something to that effect. So I thought to close on this series and attend to that separately. Signed-off-by: Kamal Wadhwa <[email protected]> --- Changes in v6: - Dropped the `get_status()` callback and all associated status-tracking (vreg->status, rpmh_vreg_update_status(), rpmh_regulator_vrm_get_status()), as Mark pointed out get_status() must reflect actual hardware state, not a cached/driver-computed value, and the ENABLE/MODE/BYPASS registers are control/vote registers written by this driver rather than free-running status registers. Renamed determine_initial_status() to determine_initial_mode() accordingly; mode/bypass/voltage readback via get_mode()/get_bypass()/get_voltage_sel() is unaffected. - Link to v5: https://patch.msgid.link/[email protected] Changes in v5: - In `_rpmh_regulator_vrm_get_voltage()`, removed the min/max voltage range check that was suppressing out-of-range readback values, as suggested by Mark. The raw hardware-read voltage is now always reported to the regulator framework. A separate patch will be sent to handle out-of-range voltage constraint handling in core.c. - Sorted the `#include <linux/bits.h>` alphabetically with the rest of the include block, as pointed out by Konrad. - Removed the `rpmh_regulator_read_data()` wrapper (a oneliner around `rpmh_read()`) and inlined `rpmh_read()` at each call site instead, as suggested by Konrad. - Dropped the unnecessary `sts = 0` initialization in `rpmh_regulator_determine_initial_status()`, since it is always initialized before use, as pointed out by Konrad. - Added a blank line above the `return` statements in the `!pmic_mode` block of `rpmh_regulator_determine_initial_status()`, for consistency with the rest of the function, as pointed out by Konrad. - Link to v4: https://lore.kernel.org/all/[email protected]/ Changes in v4: - Modified the register mask macros to use GENMASK()/BIT() instead of numbers as suggested by reviewer. - Removed the unreachable code in the determine_initial_status() for XOB type regulators status update logic as suggested by reviewer. - Link to v3: https://lore.kernel.org/all/[email protected]/ Changes in v3: - Removed "bypass_supported" as that is not needed for regulators that don't have set_bypass implemented, as pointed by Dmitry. - Handled the corner case where the mode/bypass setting is read 0, but its unclear if the register has been set to 0 or its un-accessed. - Dropped `convert_mode_to_status()` and use the `regulator_mode_to_status()` instead. - Refactored some code to simplify the `status` update after every enable/mode/bypass setting change. - Corrected subject line of all patches to have `regulator: qcom-rpmh:` for all the `qcom-rpmh-regulator.c` file changes, as pointed by Bjorn. - Re-ordered the series to have the `rpmh.c` driver patches first and than `qcom-rpmh-regulator.c` driver patches as asked by Bjorn. - In the BOB5 bypass fix patch (PATCH 1/4 in previous series), added the fixes commit#, as it was missed earlier. - In the rpmh driver change(PATCH 2/4 in previous series), modified commit wording and removed linked as suggested by reviewer. - Fixed kernel test robot issues and other formatting issues in PATCH 3/4 of last series. - Corrected the checkpatch error fix PATCH 4/4 to keep to only one error in comment section which existed prior to this series. - Modified the subject line a little and added proper tags - Link to v2: https://lore.kernel.org/all/20251022-add-rpmh-read-support-v2-0-5c7a8e4df601@oss.qualcomm.com/ Changes in v2: - Fixed the BOB bypass mode handling (existing issue in current driver). This was needed for `get_status()` implementation. - Implemented `get_status()` callback. - Callbacks for `is_enabled()` & `get_mode()` will now be used as-is ie. v1 changes reverted. - Bootstrapped the read values for `mode` and `status` in probe, based on comments received from reviewer. - Callback for `get_voltage_sel()` has been modified to handle cases where read voltage is out-of-range defined in the regulator DT settings, this is needed to ensure backward compatibilty. Regulator probes may fail otherwise for some older targets. - This patch is rebased & tested on: https://lore.kernel.org/all/[email protected]/ to avoid any merge issues. - Fixed code style issues reported by checkpatch.pl script. - Link to v1: https://lore.kernel.org/r/20250623-add-rpmh-read-support-v1-0-ae583d260195@oss.qualcomm.com To: Bjorn Andersson <[email protected]> To: Konrad Dybcio <[email protected]> To: Liam Girdwood <[email protected]> To: Mark Brown <[email protected]> To: Vinod Koul <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kamal Wadhwa <[email protected]> --- Kamal Wadhwa (3): regulator: qcom-rpmh: Fix PMIC5 BOB bypass mode handling regulator: qcom-rpmh: readback voltage/bypass/mode set during bootup regulator: qcom-rpmh: Fix coding style issues Maulik Shah (1): soc: qcom: rpmh: Add support to read back resource settings drivers/regulator/qcom-rpmh-regulator.c | 128 +++++++++++++++++++++++++++++++- drivers/soc/qcom/rpmh-rsc.c | 13 +++- drivers/soc/qcom/rpmh.c | 47 +++++++++++- include/soc/qcom/rpmh.h | 5 ++ include/soc/qcom/tcs.h | 2 + 5 files changed, 187 insertions(+), 8 deletions(-) --- base-commit: 5c73cd9f0819c1c44e373e3dabb68318b1de1a12 change-id: 20260720-b4-read-rpmh-v5-bab1bd1cbe55 Best regards, -- Kamal Wadhwa <[email protected]>