mbox series

[v2,0/4] qcom: rpmh core and regulator support

Message ID 20240708-b4-qcom-rpmh-v2-0-8bc765606e56@linaro.org
Headers show
Series qcom: rpmh core and regulator support | expand

Message

Caleb Connolly July 8, 2024, 11:32 a.m. UTC
This series introduces support for the RPMh (Resource Power Manager
(hardened)) co-processor and associated regulator driver found on most
modern Qualcomm platforms (since ~2017).

Even though most regulators are controlled via SPMI, the specific
regions on the PMICs for controlling the regulators are restricted and
can't be accessed by the Applications Processor (AP/HLOS). Instead,
these resources are proxied via the RPMh where they can be voted on by
multiple subsystems (Linux, the modem, and the other DSPs). This is done
for security (to protect clocks, power domains, and regulators that are
specifically relevant for the trustzone) as well as to simplify the
management of shared peripherals and to allow for handover of
peripherals like the USB controller.

For U-Boot, our main concern is the regulators. Since all regulators on
the system are controlled via the RPMh, it is necessary to support it to
enable USB VBUS on some platforms, and may be needed for other
peripherals in the future.

Communicating with the RPMh additional requires accessing the cmd-db
shared memory region, this contains key/value maps to determine the
address of specific resources on the RPMh.

Introduce support for the cmd-db, the RPMh framework, and some of the
regulators that are necessary to enable USB VBUS on the RB5 development
board.

These drivers were originally taken from Linux, however they have been
heavily modified and simplified for U-Boot. Since the original Linux
drivers contained heavy optimisations related to multithreading and
asynchronous probing, as well as support for idle and suspend states
which we don't need to deal with here.

The U-Boot version of the driver supports a single TCS and always
requests a response from the RPMh, since we don't need to worry about
having multiple transactions in flight at once.

---
Changes in v2:
- Implement Neil's suggestions and fixes for SM8[56]50
- Slightly refactor cmd_db_init() for better abstraction.
- Improve logging (printf -> log_err/dev_err)
- Add missing error check in rpmh_regulators_bind()
- Link to v1: https://lore.kernel.org/r/20240617-b4-qcom-rpmh-v1-0-bd2336923e0a@linaro.org

---
Caleb Connolly (4):
      linux/bitmap.h: add bitmap_empty helper
      soc: qcom: rpmh and cmd-db drivers
      power: regulator: add qcom-rpmh-regulator
      qcom_defconfig: enable rpmh regulators

 configs/qcom_defconfig                        |   5 +
 drivers/power/regulator/Kconfig               |   8 +
 drivers/power/regulator/Makefile              |   1 +
 drivers/power/regulator/qcom-rpmh-regulator.c | 536 ++++++++++++++++++++++
 drivers/soc/Kconfig                           |   1 +
 drivers/soc/Makefile                          |   1 +
 drivers/soc/qcom/Kconfig                      |  25 +
 drivers/soc/qcom/Makefile                     |   4 +
 drivers/soc/qcom/cmd-db.c                     | 261 +++++++++++
 drivers/soc/qcom/rpmh-internal.h              | 141 ++++++
 drivers/soc/qcom/rpmh-rsc.c                   | 628 ++++++++++++++++++++++++++
 drivers/soc/qcom/rpmh.c                       | 112 +++++
 include/linux/bitmap.h                        |   8 +
 include/soc/qcom/cmd-db.h                     |  42 ++
 include/soc/qcom/rpmh.h                       |  29 ++
 include/soc/qcom/tcs.h                        |  78 ++++
 16 files changed, 1880 insertions(+)
---
change-id: 20240611-b4-qcom-rpmh-fcfd32ac2940
base-commit: 50adc932e7aa34e6d9c738ec13ed09382a9d109a

// Caleb (they/them)