mbox series

[0/9] Add exynos_pmu_update/read/write() APIs to exynos-pmu

Message ID 20240122225710.1952066-1-peter.griffin@linaro.org
Headers show
Series Add exynos_pmu_update/read/write() APIs to exynos-pmu | expand

Message

Peter Griffin Jan. 22, 2024, 10:57 p.m. UTC
Hi folks,

This series adds 4 new exynos_pmu_update/read/write() APIs to the exynos-pmu
driver. The APIs are intended to be used by drivers that need to read and
write PMU registers on Exynos based SoCs.

Examples of such Exynos drivers are:
* watchdog
* usb phy
* mipi phy
* ufs phy

Currently upstream most drivers that require PMU register access have a phandle
to the pmu_system_controller in their dt node and obtain a regmap using the
syscon_regmap_lookup_by_phandle() API.

On newer Exynos SoCs this approach is insufficient, for the following reasons

1) Newer Exynos Socs have special set/clear bit hardware on PMU registers.
The intention is this should be used when the register can be accessed by
multiple masters. Support is added for this hw via the QUIRK_HAS_ATOMIC_BITSETHW
and is implemented in exynos_pmu_set_bit_atomic() function.

2) On some SoCs the PMU registers can only be written from secure state (el3).
As Linux needs to write some of these registers a SMC read/write interface
is provided in the secure monitor, and the register offset is checked against
an allowlist. This is done for security hardenning reasons so that normal world
can't tamper with the power to root of trust IPs. Support for this is added
via QUIRK_PMU_ALIVE_WRITE_SEC. This SMC interface is known to be implemented on
gs101 and derivative based SoCs firmware.

The above (2) is a similar mechanism to what drivers/soc/tegra/pmc.c is
providing for it's SoCs where PMC registers can only be accessed from secure
state on some SoCs.

As an example of a consumer of these APIs I have updated the s3c2410_wdt
watchdog driver to use these new exynos_pmu_*() APIs. As the
samsung,syscon-phandle logic has been removed from the s3c2410_wdt.c driver
I have also updated the bindings documentation to mark this as deprecated, and
updated all existing platforms DT to remove samsung,syscon-phandle from the
Watchdog DT node. Please let me know if there is alternative process I should
follow with regards to to deprecating this and updating existing platforms.

This series has been tested on Pixel 6 / gs101. If the various maintainers/
contributors of fsd, exynos850, exynosautov9 etc can test these patches on
your respective systems that would also be most appreciated!

The expectation is this series would be merged via Krzysztofs Samsung Exynos
tree.

Many thanks,

Peter.

Peter Griffin (9):
  dt-bindings: watchdog: samsung-wdt: deprecate samsung,syscon-phandle
  soc: samsung: exynos-pmu: Add exynos_pmu_update/read/write APIs and
    SoC quirks
  watchdog: s3c2410_wdt: update to use new exynos_pmu_*() apis
  arm64: dts: fsd: remove deprecated samsung,syscon-phandle
  arm64: dts: exynosautov9: remove deprecated samsung,syscon-phandle
  arm64: dts: exynos850: remove deprecated samsung,syscon-phandle
  arm64: dts: exynos7: remove deprecated samsung,syscon-phandle
  ARM: dts: samsung: exynos4: remove deprecated samsung,syscon-phandle
  ARM: dts: exynos5250: remove deprecated samsung,syscon-phandle

 .../bindings/watchdog/samsung-wdt.yaml        |  15 +-
 arch/arm/boot/dts/samsung/exynos4x12.dtsi     |   1 -
 arch/arm/boot/dts/samsung/exynos5250.dtsi     |   1 -
 arch/arm64/boot/dts/exynos/exynos7.dtsi       |   1 -
 arch/arm64/boot/dts/exynos/exynos850.dtsi     |   2 -
 arch/arm64/boot/dts/exynos/exynosautov9.dtsi  |   2 -
 arch/arm64/boot/dts/tesla/fsd.dtsi            |   3 -
 drivers/soc/samsung/exynos-pmu.c              | 209 +++++++++++++++++-
 drivers/soc/samsung/exynos-pmu.h              |   4 +
 drivers/watchdog/Kconfig                      |   1 +
 drivers/watchdog/s3c2410_wdt.c                |  25 +--
 include/linux/soc/samsung/exynos-pmu.h        |  28 +++
 12 files changed, 245 insertions(+), 47 deletions(-)