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 are taken from Linux, then modified and simplified for
U-Boot. The original Linux drivers contain 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. This unused
code is removed before finally adjusting the drivers to properly build
for U-Boot and use its device model.

The U-Boot version of the driver supports a single ACTIVE_ONLY TCS and
waits for it to be cleared after use. We don't support programming
low power states.

To: Tom Rini <tr...@konsulko.com>
To: Caleb Connolly <caleb.conno...@linaro.org>
To: Neil Armstrong <neil.armstr...@linaro.org>
To: Sumit Garg <sumit.g...@linaro.org>
To: Jaehoon Chung <jh80.ch...@samsung.com>
To: Simon Glass <s...@chromium.org>
Cc: u-boot@lists.denx.de
Cc: u-boot-q...@groups.io

Changes in v6:
- Use the driver model for cmd-db
- Extend dm_extended_scan() to scan nodes under /reserved-memory so that
  cmd-db will be bound.
- Link to v5: 
https://lore.kernel.org/r/20240711-b4-qcom-rpmh-v5-0-fbf04ce6a...@linaro.org

Changes in v5:
- Add Kconfig / Makefiles after introducing drivers to avoid breaking
  compilation when bisecting (Thanks Neil).
- Link to v4: 
https://lore.kernel.org/r/20240709-b4-qcom-rpmh-v4-0-c06d0a266...@linaro.org

Changes in v4:
- Denote original Linux version in bitmap.h patch
- Rebased on Linux 6.10-rc6 and re-apply U-Boot changes preserving git
  history. Allowing for future changes to the Linux drivers to be ported
  over more easily.
- Add missing check to wait for the TCS to be cleared after use (seems
  we were just racing the RPMh before, oops!).
- Fix missing n_modes in pmic5_pldo regulator.
- Link to v3: 
https://lore.kernel.org/r/20240708-b4-qcom-rpmh-v3-0-846cc6c5b...@linaro.org

Changes in v3:
- Don't call dm_scan_fdt_dev(), since DM core will scan.
- Link to v2: 
https://lore.kernel.org/r/20240708-b4-qcom-rpmh-v2-0-8bc765606...@linaro.org

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-bd2336923...@linaro.org

---
Caleb Connolly (24):
      dm: core: scan reserved-memory nodes
      linux/bitmap.h: add bitmap_empty helper
      soc: qcom: import rpmh and cmd-db drivers from Linux
      soc: qcom: cmd-db: adjust headers for U-Boot
      soc: qcom: cmd-db: drop unused functions
      soc: qcom: cmd-db: adjust probe for U-Boot
      soc: qcom: cmd-db: adjust for U-Boot API
      soc: qcom: rpmh-rsc: drop unused multi-threading and non-active TCS 
support
      soc: qcom: rpmh-rsc: adjust headers for U-Boot
      soc: qcom: rpmh-rsc: adjust probe for U-Boot
      soc: qcom: rpmh-rsc: remaining U-Boot API changes
      soc: qcom: rpmh: adjust headers for U-Boot
      soc: qcom: rpmh: drop unused functions
      soc: qcom: rpmh: U-Boot API changes
      soc: qcom: add build infrastructure
      power: regulator: import qcom-rpmh-regulator from Linux
      power: regulator: qcom-rpmh-regulator: adjust headers for U-Boot
      power: regulator: qcom-rpmh-regulator: port over lineage_range helpers
      power: regulator: qcom-rpmh-regulator: adjust structs for U-Boot
      power: regulator: qcom-rpmh-regulator: remove unused regulators
      power: regulator: qcom-rpmh-regulator: port ops to U-Boot
      power: regulator: qcom-rpmh-regulator: adjust probe for U-Boot
      power: regulator: qcom-rpmh-regulator: add build infra
      qcom_defconfig: enable rpmh regulators

 configs/qcom_defconfig                        |   5 +
 drivers/core/root.c                           |   3 +-
 drivers/power/regulator/Kconfig               |   8 +
 drivers/power/regulator/Makefile              |   1 +
 drivers/power/regulator/qcom-rpmh-regulator.c | 544 ++++++++++++++++++++++++++
 drivers/soc/Kconfig                           |   1 +
 drivers/soc/Makefile                          |   1 +
 drivers/soc/qcom/Kconfig                      |  27 ++
 drivers/soc/qcom/Makefile                     |   4 +
 drivers/soc/qcom/cmd-db.c                     | 225 +++++++++++
 drivers/soc/qcom/rpmh-internal.h              | 138 +++++++
 drivers/soc/qcom/rpmh-rsc.c                   | 505 ++++++++++++++++++++++++
 drivers/soc/qcom/rpmh.c                       | 110 ++++++
 include/linux/bitmap.h                        |   8 +
 include/soc/qcom/cmd-db.h                     |  30 ++
 include/soc/qcom/rpmh.h                       |  28 ++
 include/soc/qcom/tcs.h                        |  81 ++++
 17 files changed, 1718 insertions(+), 1 deletion(-)
---
change-id: 20240611-b4-qcom-rpmh-fcfd32ac2940
base-commit: 834df20b4ef50cda26936fbc435689fa0c5d47b1

// Caleb (they/them)

Reply via email to