* [PATCH v2 0/9] google: Add support for Laguna CPM
@ 2026-11-25 0:03 Brian Norris
2026-11-25 0:03 ` [PATCH v2 1/9] dt-bindings: power: google: Add Google Tensor CPM Brian Norris
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc
== External Dependencies ==
This series depends on the bindings and mailbox-payload-definitions from
this series:
https://lore.kernel.org/all/20261023235408.3063350-1-dianders@chromium.org/
[PATCH v2 0/4] mailbox: Improve the mbox core then introduce the goog-mba driver
So this series cannot be applied as-is yet. Based on past feedback, I
expect the relevant dependencies shouldn't change much more before
landing.
== Internal Dependencies ==
While this series includes drivers for several subsystems, I deemed it
appropriate to keep together, because they're highly interdependent. For
example, clk, reset, and pmdomain share many of the same protocol family
details (CPM_COMMON_LPCM_SERVICE), and so it has proved useful to review
them together, to determine sensible sharing and separation strategies.
Additionally, none of pmdomain/clk/reset/irqchip (patches 3-6) build
without patch 2, and clk/pmdomain depend on the binding macros from
patch 1.
== Merge Proposal ==
Generally, Google Tensor SoC support should go through Peter Griffin's
new Tensor SoC tree
(git.kernel.org/pub/scm/linux/kernel/git/griffinp/linux.git), while
clk, pmdomain, irqchip, and reset have their own subsystem trees.
1) This series requires include/linux/mailbox/goog-mba-message.h from
the External Dependency "mailbox: goog-mba: Introduce the goog-mba
mailbox driver"
This should be up to the mailbox maintainer to provide an immutable
branch.
2) Patches 1-2 should land in Peter's Tensor tree, with an immutable
branch for other submaintainers.
3) Patches 3-6 are independent of each other, but depend on patches 1-2.
Subsystem maintainers should take these patches once the branch
exists for #2.
4) Patches 7-9 should go through Peter's tree.
Alternatively, if the process is slow enough, we may not need an
immutable branch for #1.
== Description ==
The Central Power Manager (CPM) is a co-processor on the Google Tensor
SoCs, as used on Pixel phones. CPM supports power-management and a
number of other features.
The Application Processor communicates with CPM over a pair of mailbox
channels. CPM provides clock, power-domain, reset, and interrupt
services.
This series adds device tree bindings, DTS, and drivers to support CPM,
and several of the basic services provided by CPM. These services are a
minimal set needed to bootstrap many other components on the SoC --
e.g., I have a working proof-of-concept PCIe driver running on top of
this series + pinctrl (not included here). CPM provides some other
components not yet included in this series (e.g., PMIC, RTC).
This series has been tested on a Pixel 10 Pro XL (a.k.a., Mustang) both
as-is (plus the aforementioned mailbox patches), and also with minimal
additional local patches to get other components running on top
(pinctrl, PCIe, PMIC, RTC, USB), to prove out some more realistic use
cases.
- Brian
Changes in v2:
* Move bindings to power/, not soc/
* Make binding prefix/suffix pattern consistent (no LGA_*; put type
first (CLK_*, PD_*))
* Consistent naming for dt-bindings headers
* Drop unneeded IRQ number dt-binding header (these were simply naming
documentation, at best; I inline these into the DTS instead)
* Drop unneeded reset number dt-binding header (these were simply
naming documentation; I move the macro definitions directly into the
dts/ folder instead)
* Flatten clock IDs to a single-cell binding, as the mappings are
complex; the mapping from clock to firmware-protocol is better done
in the driver
* Move more protocol details from client drivers (reset, clock,
pmdomain) into core CPM driver
* Simplify to a thin 'cpm_handle' for transmit-only clients
* Support separate API to register a receive-enabled client
* Move pmdomain per-SoC info from .h to .c file
* Remove custom pmdomain debugfs 'state' (get/set on/off) file
* Restructure pmdomain SoC tables for simplicity and readability
* Simplify clock driver, to avoid memorizing rate tables and clock
topology that is owned by the remote CPM firmware
* Drop clock .set_rate() for now
* Cc new google-soc@lists.linux.dev mailing list (pending MAINTAINERS
update, separately)
* Drop linux-samsung-soc@vger.kernel.org (this is historical, for
earlier Tensor SoCs based on Samsung designs)
* Added Peter's Tested-by only for 1 patch; the rest have changed
quite a bit
Brian Norris (7):
dt-bindings: power: google: Add Google Tensor CPM
pmdomain: google: Add CPM power-domain driver
clk: google: Add CPM clock driver
reset: google: Add CPM reset driver
arm64: dts: google: Add Laguna CPM mailbox array
arm64: dts: google: Add Laguna CPM node
MAINTAINERS: Add entries for CPM drivers used on Tensor SoCs
Jim Wylder (1):
irqchip/google-cpm: Add CPM IRQ driver
Lucas Wei (1):
soc: google: Add CPM over MailBox Array driver
.../bindings/power/google,lga-cpm.yaml | 68 ++
MAINTAINERS | 10 +-
arch/arm64/boot/dts/google/lga-cpm-reset.h | 175 ++++
arch/arm64/boot/dts/google/lga-lpcm.h | 54 +
arch/arm64/boot/dts/google/lga.dtsi | 50 +
drivers/clk/Kconfig | 1 +
drivers/clk/Makefile | 1 +
drivers/clk/google/Kconfig | 13 +
drivers/clk/google/Makefile | 3 +
drivers/clk/google/clk-cpm-internal.h | 35 +
drivers/clk/google/clk-cpm-lga.c | 223 ++++
drivers/clk/google/clk-cpm-lga.h | 194 ++++
drivers/clk/google/clk-cpm.c | 385 +++++++
drivers/irqchip/Kconfig | 10 +
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-google-cpm.c | 131 +++
drivers/pmdomain/Kconfig | 1 +
drivers/pmdomain/Makefile | 1 +
drivers/pmdomain/google/Kconfig | 14 +
drivers/pmdomain/google/Makefile | 3 +
drivers/pmdomain/google/cpm-power-lga.c | 365 +++++++
drivers/pmdomain/google/cpm-power-trace.h | 80 ++
drivers/pmdomain/google/cpm-power.c | 458 +++++++++
drivers/pmdomain/google/cpm-power.h | 42 +
drivers/reset/Kconfig | 1 +
drivers/reset/Makefile | 1 +
drivers/reset/google/Kconfig | 11 +
drivers/reset/google/Makefile | 2 +
drivers/reset/google/reset-cpm.c | 154 +++
drivers/soc/Kconfig | 1 +
drivers/soc/Makefile | 1 +
drivers/soc/google/Kconfig | 13 +
drivers/soc/google/Makefile | 3 +
drivers/soc/google/google-cpm-mba-trace.h | 163 +++
drivers/soc/google/google-cpm-mba.c | 956 ++++++++++++++++++
include/dt-bindings/clock/google,lga-cpm.h | 173 ++++
include/dt-bindings/power/google,lga-cpm.h | 79 ++
include/soc/google/cpm-service-ids.h | 84 ++
include/soc/google/google-cpm-mba.h | 168 +++
include/soc/google/lga-lpcm-ids.h | 54 +
40 files changed, 4181 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/power/google,lga-cpm.yaml
create mode 100644 arch/arm64/boot/dts/google/lga-cpm-reset.h
create mode 100644 arch/arm64/boot/dts/google/lga-lpcm.h
create mode 100644 drivers/clk/google/Kconfig
create mode 100644 drivers/clk/google/Makefile
create mode 100644 drivers/clk/google/clk-cpm-internal.h
create mode 100644 drivers/clk/google/clk-cpm-lga.c
create mode 100644 drivers/clk/google/clk-cpm-lga.h
create mode 100644 drivers/clk/google/clk-cpm.c
create mode 100644 drivers/irqchip/irq-google-cpm.c
create mode 100644 drivers/pmdomain/google/Kconfig
create mode 100644 drivers/pmdomain/google/Makefile
create mode 100644 drivers/pmdomain/google/cpm-power-lga.c
create mode 100644 drivers/pmdomain/google/cpm-power-trace.h
create mode 100644 drivers/pmdomain/google/cpm-power.c
create mode 100644 drivers/pmdomain/google/cpm-power.h
create mode 100644 drivers/reset/google/Kconfig
create mode 100644 drivers/reset/google/Makefile
create mode 100644 drivers/reset/google/reset-cpm.c
create mode 100644 drivers/soc/google/Kconfig
create mode 100644 drivers/soc/google/Makefile
create mode 100644 drivers/soc/google/google-cpm-mba-trace.h
create mode 100644 drivers/soc/google/google-cpm-mba.c
create mode 100644 include/dt-bindings/clock/google,lga-cpm.h
create mode 100644 include/dt-bindings/power/google,lga-cpm.h
create mode 100644 include/soc/google/cpm-service-ids.h
create mode 100644 include/soc/google/google-cpm-mba.h
create mode 100644 include/soc/google/lga-lpcm-ids.h
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/9] dt-bindings: power: google: Add Google Tensor CPM
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 2/9] soc: google: Add CPM over MailBox Array driver Brian Norris
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
The Central Power Manager (CPM) is a co-processor on the Google Tensor
SoCs, as used on Pixel phones. CPM supports power-management and a
number of other features.
The Application Processor communicates with CPM over a pair of mailbox
channels. CPM provides clock, power-domain, reset, and interrupt
services.
Notable features of this binding:
* Resets and interrupts have a naive mapping to their underlying
resource on the remote (firmware) end, so they directly utilize the
firmware indexing (LPCM ID + reset ID, #reset-cells = <2>; and
interrupt ID, #interrupt-cells = <1>)
* Clocks and power domains also map relatively directly to CPM firmware
IDs (LPCM ID and object ID), but they have a more complicated
hierarchy, non-uniform characteristics, and even covering multiple
service protocols (especially for power-domains). So these use a
1-cell identifier, leaving software to perform the DT-to-firmware
mapping.
Notably, CPM manages other services that are not yet included in this
binding -- some attached PMICs, an RTC, and more. For simplicity, we
don't try to describe and support all features all at once.
Because it may be useful both for reviewers familiar with the downstream
Linux support for these devices, or for future developers looking at
adapting/improving/adding further features later on, it's worth noting
some major deviations from downstream bindings:
* CPM does not sit on the soc bus, and does not have any IO/reg region
of its own. The downstream bindings included some not-quite-related
hardware resources in the same "device", to aid doing some similar
things in the same driver. For instance, some power domains
(specifically, the GPU) are not managed by CPM, and instead are left
for direct-register-access. Such a domain should be described
separately, and not within the CPM node.
* Downstream bindings tended to describe every CPM-using service as its
own node, with a (fake) mailbox-phandle back to the CPM node. We try
as much as possible here to avoid separate nodes if we can help it.
And see the next point:
* Downstream bindings tended to describe every individual clock, reset,
and power-domain as their own sub-node, with various
software-describing properties as part of each node. These properties
are inherent to the SoC, however, so we avoid sub-nodes and instead
just provide appropriate #{clock,power-domain,reset}-cells, and leave
the per-{power-domain,clock} properties to the driver.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v2:
* Move bindings to power/, not soc/
* Make binding prefix/suffix pattern consistent (no LGA_*; put type
first (CLK_*, PD_*))
* Consistent naming for dt-bindings headers
* Drop unneeded IRQ number dt-binding header (these were simply naming
documentation, at best; I inline these into the DTS instead)
* Drop unneeded reset number dt-binding header (these were simply
naming documentation; I move the macro definitions directly into the
dts/ folder instead)
* List properties in alphabetical order
* Flatten clock IDs to 1 cell
.../bindings/power/google,lga-cpm.yaml | 68 +++++++
include/dt-bindings/clock/google,lga-cpm.h | 173 ++++++++++++++++++
include/dt-bindings/power/google,lga-cpm.h | 79 ++++++++
3 files changed, 320 insertions(+)
create mode 100644 Documentation/devicetree/bindings/power/google,lga-cpm.yaml
create mode 100644 include/dt-bindings/clock/google,lga-cpm.h
create mode 100644 include/dt-bindings/power/google,lga-cpm.h
diff --git a/Documentation/devicetree/bindings/power/google,lga-cpm.yaml b/Documentation/devicetree/bindings/power/google,lga-cpm.yaml
new file mode 100644
index 000000000000..a11b76df23fe
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/google,lga-cpm.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/google,lga-cpm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Google Central Power Manager (CPM)
+
+maintainers:
+ - Brian Norris <briannorris@chromium.org>
+
+description:
+ The Central Power Manager (CPM) is an on-chip power management subsystem
+ found on Google Tensor SoCs. It has a variety of responsibilities, from DVFS
+ and power management to resets, PMIC control, and even RTC management. The
+ Application Processor communicates with CPM over a set of mailbox channels.
+
+properties:
+ compatible:
+ const: google,lga-cpm
+
+ '#clock-cells':
+ const: 1
+ description: See <dt-bindings/clock/google,lga-cpm.h> for clock IDs.
+
+ '#interrupt-cells':
+ const: 1
+ description: Interrupt identifiers are assigned by CPM firmware.
+
+ interrupt-controller: true
+
+ mboxes:
+ items:
+ - description: TX mailbox channel for sending requests to CPM
+ - description: RX mailbox channel for receiving responses from CPM
+
+ '#power-domain-cells':
+ const: 1
+ description: See <dt-bindings/power/google,lga-cpm.h> for power domain IDs.
+
+ '#reset-cells':
+ const: 2
+ description:
+ Each reset is specified by an LPCM ID (cell 1) and a reset ID (cell 2).
+ LPCM and reset IDs are assigned by CPM firmware.
+
+required:
+ - compatible
+ - '#clock-cells'
+ - '#interrupt-cells'
+ - interrupt-controller
+ - mboxes
+ - '#power-domain-cells'
+ - '#reset-cells'
+
+additionalProperties: false
+
+examples:
+ - |
+ power-controller {
+ compatible = "google,lga-cpm";
+ mboxes = <&cpm_ap_ns_req_mba>, <&cpm_ap_ns_resp_mba>;
+ #clock-cells = <1>;
+ #power-domain-cells = <1>;
+ #reset-cells = <2>;
+ #interrupt-cells = <1>;
+ interrupt-controller;
+ };
diff --git a/include/dt-bindings/clock/google,lga-cpm.h b/include/dt-bindings/clock/google,lga-cpm.h
new file mode 100644
index 000000000000..a390297449d7
--- /dev/null
+++ b/include/dt-bindings/clock/google,lga-cpm.h
@@ -0,0 +1,173 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef __DT_BINDINGS_CLOCK_GOOGLE_LGA_CPM_H
+#define __DT_BINDINGS_CLOCK_GOOGLE_LGA_CPM_H
+
+/* CPU */
+#define CLK_CPU_SSWRP_TSS 0
+
+/* DPU */
+#define CLK_DPU_DP0_PIX 1
+#define CLK_DPU_DP1_PIX 2
+#define CLK_DPU_DSI0_PIX 3
+#define CLK_DPU_DSI1_PIX 4
+#define CLK_DPU_DSI1_PHY 5
+
+/* GPCM */
+#define CLK_GPCM_DPU_PLL_DP 6
+#define CLK_GPCM_HSIO_N_PLL_DP 7
+
+/* HSIO_N */
+#define CLK_HSIO_N_USB 8
+#define CLK_HSIO_N_DP0 9
+#define CLK_HSIO_N_DP1 10
+#define CLK_HSIO_N_PHY_FW 11
+#define CLK_HSIO_N_USBDP_SUSPEND 12
+#define CLK_HSIO_N_USBC_NON_STICKY 13
+#define CLK_HSIO_N_USBC_STICKY 14
+#define CLK_HSIO_N_USB_DRD_BUS 15
+#define CLK_HSIO_N_USB_TOP_CSR 16
+#define CLK_HSIO_N_U2PHY_APB 17
+#define CLK_HSIO_N_USB2_PHY_RESET 18
+#define CLK_HSIO_N_USB3DP_PHY_RESET 19
+#define CLK_HSIO_N_EBU 20
+
+/* HSIO_S */
+#define CLK_HSIO_S_GPIO_REF_TCX0 21
+#define CLK_HSIO_S_SYS 22
+#define CLK_HSIO_S_UFS_CFG 23
+#define CLK_HSIO_S_PHY_FW 24
+#define CLK_HSIO_S_MPHY_REF_TCX0 25
+#define CLK_HSIO_S_AUX 26
+
+/* LSIO_E */
+#define CLK_LSIO_E_GPIO 27
+#define CLK_LSIO_E_SPMI 28
+#define CLK_LSIO_E_CLI7_CFG 29
+#define CLK_LSIO_E_CLI8_CFG 30
+#define CLK_LSIO_E_CLI9_CFG 31
+#define CLK_LSIO_E_CLI10_CFG 32
+#define CLK_LSIO_E_CLI11_CFG 33
+#define CLK_LSIO_E_CLI12_CFG 34
+#define CLK_LSIO_E_CLI13_CFG 35
+#define CLK_LSIO_E_CLI14_CFG 36
+#define CLK_LSIO_E_CLI7_SPI 37
+#define CLK_LSIO_E_CLI8_SPI 38
+#define CLK_LSIO_E_CLI9_SPI 39
+#define CLK_LSIO_E_CLI10_SPI 40
+#define CLK_LSIO_E_CLI11_SPI 41
+#define CLK_LSIO_E_CLI12_SPI 42
+#define CLK_LSIO_E_CLI13_SPI 43
+#define CLK_LSIO_E_CLI14_SPI 44
+#define CLK_LSIO_E_CLI7_I2C 45
+#define CLK_LSIO_E_CLI8_I2C 46
+#define CLK_LSIO_E_CLI9_I2C 47
+#define CLK_LSIO_E_CLI10_I2C 48
+#define CLK_LSIO_E_CLI11_I2C 49
+#define CLK_LSIO_E_CLI12_I2C 50
+#define CLK_LSIO_E_CLI13_I2C 51
+#define CLK_LSIO_E_CLI14_I2C 52
+#define CLK_LSIO_E_CLI7_UART 53
+#define CLK_LSIO_E_CLI8_UART 54
+#define CLK_LSIO_E_CLI9_UART 55
+#define CLK_LSIO_E_CLI10_UART 56
+#define CLK_LSIO_E_CLI11_UART 57
+#define CLK_LSIO_E_CLI12_UART 58
+#define CLK_LSIO_E_CLI13_UART 59
+#define CLK_LSIO_E_CLI14_UART 60
+#define CLK_LSIO_E_CLI7_I3C 61
+#define CLK_LSIO_E_CLI8_I3C 62
+#define CLK_LSIO_E_CLI9_I3C 63
+#define CLK_LSIO_E_CLI10_I3C 64
+#define CLK_LSIO_E_CLI11_I3C 65
+#define CLK_LSIO_E_CLI12_I3C 66
+#define CLK_LSIO_E_CLI13_I3C 67
+#define CLK_LSIO_E_CLI14_I3C 68
+
+/* LSIO_N */
+#define CLK_LSIO_N_GPIO 69
+#define CLK_LSIO_N_CLI15_CFG 70
+#define CLK_LSIO_N_CLI16_CFG 71
+#define CLK_LSIO_N_CLI15_I2C 72
+#define CLK_LSIO_N_CLI16_I2C 73
+#define CLK_LSIO_N_CLI15_UART 74
+#define CLK_LSIO_N_CLI16_UART 75
+#define CLK_LSIO_N_CLI15_SPI 76
+#define CLK_LSIO_N_CLI16_SPI 77
+#define CLK_LSIO_N_CLI15_I3C 78
+#define CLK_LSIO_N_CLI16_I3C 79
+#define CLK_LSIO_N_CLI_INT0_I2C 80
+#define CLK_LSIO_N_CLI_INT0_I3C 81
+#define CLK_LSIO_N_CLI_INT0_UART 82
+#define CLK_LSIO_N_CLI_INT0_SPI 83
+#define CLK_LSIO_N_CLI_INT0_CFG 84
+#define CLK_LSIO_N_CLI_INT1_I2C 85
+#define CLK_LSIO_N_CLI_INT1_I3C 86
+#define CLK_LSIO_N_CLI_INT1_UART 87
+#define CLK_LSIO_N_CLI_INT1_SPI 88
+#define CLK_LSIO_N_CLI_INT1_CFG 89
+#define CLK_LSIO_N_CLI_INT2_I2C 90
+#define CLK_LSIO_N_CLI_INT2_I3C 91
+#define CLK_LSIO_N_CLI_INT2_UART 92
+#define CLK_LSIO_N_CLI_INT2_SPI 93
+#define CLK_LSIO_N_CLI_INT2_CFG 94
+#define CLK_LSIO_N_CLI_INT3_I2C 95
+#define CLK_LSIO_N_CLI_INT3_I3C 96
+#define CLK_LSIO_N_CLI_INT3_UART 97
+#define CLK_LSIO_N_CLI_INT3_SPI 98
+#define CLK_LSIO_N_CLI_INT3_CFG 99
+#define CLK_LSIO_N_CLI_INT4_I2C 100
+#define CLK_LSIO_N_CLI_INT4_I3C 101
+#define CLK_LSIO_N_CLI_INT4_UART 102
+#define CLK_LSIO_N_CLI_INT4_SPI 103
+#define CLK_LSIO_N_CLI_INT4_CFG 104
+
+/* LSIO_S */
+#define CLK_LSIO_S_GPIO 105
+#define CLK_LSIO_S_MCLK0 106
+#define CLK_LSIO_S_MCLK1 107
+#define CLK_LSIO_S_MCLK2 108
+#define CLK_LSIO_S_MCLK3 109
+#define CLK_LSIO_S_MCLK4 110
+#define CLK_LSIO_S_MCLK5 111
+#define CLK_LSIO_S_MCLK6 112
+#define CLK_LSIO_S_MCLK7 113
+#define CLK_LSIO_S_PWM 114
+#define CLK_LSIO_S_PWM_CFG 115
+#define CLK_LSIO_S_CLI0_CFG 116
+#define CLK_LSIO_S_CLI1_CFG 117
+#define CLK_LSIO_S_CLI2_CFG 118
+#define CLK_LSIO_S_CLI3_CFG 119
+#define CLK_LSIO_S_CLI4_CFG 120
+#define CLK_LSIO_S_CLI5_CFG 121
+#define CLK_LSIO_S_CLI6_CFG 122
+#define CLK_LSIO_S_CLI0_SPI 123
+#define CLK_LSIO_S_CLI1_SPI 124
+#define CLK_LSIO_S_CLI2_SPI 125
+#define CLK_LSIO_S_CLI3_SPI 126
+#define CLK_LSIO_S_CLI4_SPI 127
+#define CLK_LSIO_S_CLI5_SPI 128
+#define CLK_LSIO_S_CLI6_SPI 129
+#define CLK_LSIO_S_CLI0_I2C 130
+#define CLK_LSIO_S_CLI1_I2C 131
+#define CLK_LSIO_S_CLI2_I2C 132
+#define CLK_LSIO_S_CLI3_I2C 133
+#define CLK_LSIO_S_CLI4_I2C 134
+#define CLK_LSIO_S_CLI5_I2C 135
+#define CLK_LSIO_S_CLI6_I2C 136
+#define CLK_LSIO_S_CLI0_UART 137
+#define CLK_LSIO_S_CLI1_UART 138
+#define CLK_LSIO_S_CLI2_UART 139
+#define CLK_LSIO_S_CLI3_UART 140
+#define CLK_LSIO_S_CLI4_UART 141
+#define CLK_LSIO_S_CLI5_UART 142
+#define CLK_LSIO_S_CLI6_UART 143
+#define CLK_LSIO_S_CLI0_I3C 144
+#define CLK_LSIO_S_CLI1_I3C 145
+#define CLK_LSIO_S_CLI2_I3C 146
+#define CLK_LSIO_S_CLI3_I3C 147
+#define CLK_LSIO_S_CLI4_I3C 148
+#define CLK_LSIO_S_CLI5_I3C 149
+#define CLK_LSIO_S_CLI6_I3C 150
+
+#endif /* __DT_BINDINGS_CLOCK_GOOGLE_LGA_CPM_H */
diff --git a/include/dt-bindings/power/google,lga-cpm.h b/include/dt-bindings/power/google,lga-cpm.h
new file mode 100644
index 000000000000..b9c5037728f9
--- /dev/null
+++ b/include/dt-bindings/power/google,lga-cpm.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef __DT_BINDINGS_POWER_GOOGLE_LGA_CPM_H
+#define __DT_BINDINGS_POWER_GOOGLE_LGA_CPM_H
+
+/* AOC */
+#define PD_SSWRP_AOC 0
+#define PD_AOC_CORE 1
+
+/* AURORA */
+#define PD_SSWRP_AURORA 2
+
+/* CODEC_3P */
+#define PD_SSWRP_CODEC_3P 3
+
+/* DPU */
+#define PD_DPU_DP 4
+#define PD_SSWRP_DPU 5
+#define PD_DPU_FE0 6
+#define PD_DPU_FE1 7
+#define PD_DPU_DSI0 8
+#define PD_DPU_DSI1 9
+
+/* EH */
+#define PD_SSWRP_EH 10
+
+/* G2D */
+#define PD_SSWRP_G2D 11
+#define PD_G2D_CORE 12
+
+/* GPDMA */
+#define PD_SSWRP_GPDMA 13
+
+/* GPU */
+#define PD_SSWRP_GPU 14
+
+/* GSW */
+#define PD_SSWRP_GSW 15
+
+/* HSIO_N */
+#define PD_SSWRP_HSIO_N 16
+#define PD_HSIO_N_USB 17
+#define PD_HSIO_N_USB_PSW 18
+#define PD_HSIO_N_PCIE 19
+#define PD_HSIO_N_DP 20
+#define PD_HSIO_N_EBU 21
+#define PD_HSIO_N_EBU_CORE 22
+
+/* HSIO_S */
+#define PD_SSWRP_HSIO_S 23
+#define PD_HSIO_S_UFS_PREP 24
+#define PD_HSIO_S_UFS 25
+#define PD_HSIO_S_PCIE 26
+#define PD_HSIO_S_SD 27
+
+/* ISPBE */
+#define PD_SSWRP_ISPBE 28
+
+/* ISPFE */
+#define PD_SSWRP_ISPFE 29
+#define PD_ISPFE_PIPE 30
+#define PD_ISPFE_CSIS 31
+
+/* LSIO_E */
+#define PD_SSWRP_LSIO_E 32
+#define PD_LSIO_E_CLI_GPIO 33
+
+/* LSIO_N */
+#define PD_SSWRP_LSIO_N 34
+#define PD_LSIO_N_CLI_GPIO 35
+
+/* LSIO_S */
+#define PD_SSWRP_LSIO_S 36
+#define PD_LSIO_S_CLI_GPIO 37
+
+/* TPU */
+#define PD_SSWRP_TPU 38
+
+#endif /* __DT_BINDINGS_POWER_GOOGLE_LGA_CPM_H */
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 2/9] soc: google: Add CPM over MailBox Array driver
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
2026-11-25 0:03 ` [PATCH v2 1/9] dt-bindings: power: google: Add Google Tensor CPM Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 3/9] pmdomain: google: Add CPM power-domain driver Brian Norris
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
From: Lucas Wei <lucaswei@google.com>
The Central Power Manager (CPM) is a co-processor on the Google Tensor
SoCs, as used on Pixel phones. CPM supports power-management and a
number of other features.
The Application Processor communicates with CPM over a pair of mailbox
channels (the "MailBox Array" (MBA)). CPM provides clock, power-domain,
reset, interrupt services, and more.
It's difficult to support all of these services within a single driver,
in part because it's a lot of code to manage, but also because there can
be complex relationships between the individual services. For example,
clocks may have dependencies on power-domains. Instead, the CPM driver
only handles some basic initialization, and otherwise creates child
auxiliary_bus devices to handle each service. It also provides API
wrappers around the mailbox protocol, so clients don't have to worry
about most of the details. This API assumes all users are children of
the CPM device.
Implementation note about the "session" handling: the mailbox API
doesn't provide any timeouts or guarantees about a response message, but
CPM clients would like an (optional) timeout. So there's a little bit of
complexity around reference-counting a "session" (i.e., outstanding
request still waiting on a response), as that session may outlive the
client's timeout.
Quick note about hardware queueing: this is implemented in our mailbox
driver by allowing clients to request the "same" channel multiple times.
A client is expected to keep requesting the channel until it sees
-EBUSY, meaning we've requested all of them. We then utilize those
channels in a round-robin fashion.
Because it may be useful both for reviewers familiar with the downstream
Linux support for these devices, or for future developers looking at
adapting/improving/adding further features later on, it's worth noting
some major deviations from the downstream drivers:
* This driver doesn't contain much of the queueing complexity from the
downstream driver. The mailbox driver was significantly rewritten
beneath us, to support most of the queueing there, and thus exposes a
simpler API to us.
* No session pool; we just allocate sessions on-demand, enough to
handle timeouts while a response is still pending.
* Use auxiliary_bus, with CPM services represented as child devices on
this bus. Downstream services tended to be a bunch of artificial
platform devices, with fake-mailbox phandles to the CPM "interface"
node. This is an atypical device tree structure, and most of those
platform devices came from device nodes that were less for describing
the hardware, and more for describing how we wanted software to look.
So far, I haven't found services that don't work as child auxiliary
devices. If we later have examples that need some combination of both
iomem resources and CPM resources (and so may need to live on the
platform bus), I'm sure we can add support for non-child (e.g.,
phandle) interface methods.
* Add devm_* client helpers, to make it easier for clients to clean up
properly. (Hint: most downstream clients did not clean up properly.)
* Reduce the surface area of exposed (EXPORTed, or header definitions)
protocol details, such as goog_mba_q_*() methods. Many such details
aren't used outside the CPM driver, so it's probably best to keep
them local until proven otherwise.
* Drop RESPONSE_MSG; this is entirely unused on the Application
Processor side, and simply adds complexity and dead code.
* Separate transmit-only client handling from receive-support APIs.
Most clients only need a stateless handle for transmission; it
provides better clarity to keep these separate.
Signed-off-by: Lucas Wei <lucaswei@google.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Based on a WIP mailbox API from:
https://lore.kernel.org/all/20261023165211.v2.4.I5cef580a62c86ba6c3465ad336fa509afbdf1476@changeid/
[PATCH v2 4/4] mailbox: goog-mba: Introduce the goog-mba mailbox driver
which is part of this series:
https://lore.kernel.org/all/20261023235408.3063350-1-dianders@chromium.org/
[PATCH v2 0/4] mailbox: Improve the mbox core then introduce the goog-mba driver
That API consists of:
1) a header (<linux/mailbox/goog-mba-message.h>), which so far seems
typical and uncontroversial and
2) a strategy for supporting hardware queueing -- where the current
proposal is described in the commit message. I suppose this strategy
could still change, although it was discussed at length in v1 of
that series.
Anyway, this patch should not be accepted until the above series is
settled.
Changes in v2:
* Move more protocol details from client drivers (reset, clock,
pmdomain) into core CPM driver
* Simplify to a thin 'cpm_handle' for transmit-only clients
* Support separate API to register a receive-enabled client
* Update author/SoB to retain downstream heritage
* Add initialization timeout
drivers/soc/Kconfig | 1 +
drivers/soc/Makefile | 1 +
drivers/soc/google/Kconfig | 13 +
drivers/soc/google/Makefile | 3 +
drivers/soc/google/google-cpm-mba-trace.h | 163 ++++
drivers/soc/google/google-cpm-mba.c | 956 ++++++++++++++++++++++
include/soc/google/cpm-service-ids.h | 84 ++
include/soc/google/google-cpm-mba.h | 168 ++++
include/soc/google/lga-lpcm-ids.h | 54 ++
9 files changed, 1443 insertions(+)
create mode 100644 drivers/soc/google/Kconfig
create mode 100644 drivers/soc/google/Makefile
create mode 100644 drivers/soc/google/google-cpm-mba-trace.h
create mode 100644 drivers/soc/google/google-cpm-mba.c
create mode 100644 include/soc/google/cpm-service-ids.h
create mode 100644 include/soc/google/google-cpm-mba.h
create mode 100644 include/soc/google/lga-lpcm-ids.h
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 483cbdcae153..fbe6460424c7 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -10,6 +10,7 @@ source "drivers/soc/canaan/Kconfig"
source "drivers/soc/cirrus/Kconfig"
source "drivers/soc/fsl/Kconfig"
source "drivers/soc/fujitsu/Kconfig"
+source "drivers/soc/google/Kconfig"
source "drivers/soc/hisilicon/Kconfig"
source "drivers/soc/imx/Kconfig"
source "drivers/soc/ixp4xx/Kconfig"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 5a3efd68355c..6241e543dad7 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_MACH_DOVE) += dove/
obj-y += fsl/
obj-y += fujitsu/
obj-$(CONFIG_ARCH_GEMINI) += gemini/
+obj-y += google/
obj-y += hisilicon/
obj-y += imx/
obj-y += ixp4xx/
diff --git a/drivers/soc/google/Kconfig b/drivers/soc/google/Kconfig
new file mode 100644
index 000000000000..9cd04be63b23
--- /dev/null
+++ b/drivers/soc/google/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config GOOGLE_CPM_MBA
+ tristate "Google Tensor CPM MailBox Array Interface"
+ depends on ARCH_GOOGLE || COMPILE_TEST
+ depends on MAILBOX
+ select AUXILIARY_BUS
+ help
+ Driver for interfacing with the Central Power Manager (CPM) MailBox
+ Array (MBA) found on Google Tensor SoCs. The driver provides APIs for
+ communication between the Application Processor and the CPM, and
+ is required by CPM client drivers such as clock, reset, power
+ domain, and more.
diff --git a/drivers/soc/google/Makefile b/drivers/soc/google/Makefile
new file mode 100644
index 000000000000..78f69932a377
--- /dev/null
+++ b/drivers/soc/google/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_GOOGLE_CPM_MBA) += google-cpm-mba.o
diff --git a/drivers/soc/google/google-cpm-mba-trace.h b/drivers/soc/google/google-cpm-mba-trace.h
new file mode 100644
index 000000000000..0e643d2894be
--- /dev/null
+++ b/drivers/soc/google/google-cpm-mba-trace.h
@@ -0,0 +1,163 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2025-2026 Google LLC
+ */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM google_cpm_mba
+
+#if !defined(_GOOGLE_CPM_MBA_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _GOOGLE_CPM_MBA_TRACE_H
+
+#include <linux/string.h>
+#include <linux/tracepoint.h>
+#include <linux/types.h>
+#include <soc/google/google-cpm-mba.h>
+
+#ifdef CREATE_TRACE_POINTS
+static inline void cpm_trace_clone_payload(u32 *header, u32 *payloads,
+ const struct cpm_payload *payload)
+{
+ *header = payload->header;
+ memcpy(payloads, payload->payload, GOOG_MBA_PAYLOAD_SIZE * sizeof(*payloads));
+}
+#endif
+
+TRACE_EVENT(
+ cpm_req_enqueue,
+
+ TP_PROTO(struct cpm_session *session, const struct cpm_request *req),
+
+ TP_ARGS(session, req),
+
+ TP_STRUCT__entry(
+ __field(void *, session)
+ __field(unsigned long, tout_ms)
+ __field(u8, src_id)
+ ),
+
+ TP_fast_assign(
+ __entry->tout_ms = req->tout_ms;
+ __entry->session = session;
+ __entry->src_id = req->src_id;
+ ),
+
+ TP_printk("session=%p src_id=%u tout_ms=%lu",
+ __entry->session, __entry->src_id, __entry->tout_ms)
+);
+
+TRACE_EVENT(
+ cpm_submit_msg,
+
+ TP_PROTO(struct cpm_session *session, const struct cpm_payload *payload),
+
+ TP_ARGS(session, payload),
+
+ TP_STRUCT__entry(
+ __field(void *, session)
+ __field(u32, header)
+ __array(u32, payloads, GOOG_MBA_PAYLOAD_SIZE)
+ ),
+
+ TP_fast_assign(
+ __entry->session = session;
+ cpm_trace_clone_payload(&__entry->header, __entry->payloads, payload);
+ ),
+
+ TP_printk("session=%p: %#010x %#010x %#010x %#010x",
+ __entry->session, __entry->header,
+ __entry->payloads[0], __entry->payloads[1], __entry->payloads[2])
+);
+
+TRACE_EVENT(
+ cpm_req_tx_done,
+
+ TP_PROTO(struct cpm_session *session),
+
+ TP_ARGS(session),
+
+ TP_STRUCT__entry(
+ __field(void *, session)
+ ),
+
+ TP_fast_assign(
+ __entry->session = session;
+ ),
+
+ TP_printk("session=%p", __entry->session)
+);
+
+TRACE_EVENT(
+ cpm_resp_cb,
+
+ TP_PROTO(struct cpm_session *session, const struct cpm_payload *payload),
+
+ TP_ARGS(session, payload),
+
+ TP_STRUCT__entry(
+ __field(void *, session)
+ __field(u32, header)
+ __array(u32, payloads, GOOG_MBA_PAYLOAD_SIZE)
+ ),
+
+ TP_fast_assign(
+ __entry->session = session;
+ cpm_trace_clone_payload(&__entry->header, __entry->payloads, payload);
+ ),
+
+ TP_printk("session=%p: %#010x %#010x %#010x %#010x",
+ __entry->session, __entry->header,
+ __entry->payloads[0], __entry->payloads[1], __entry->payloads[2])
+);
+
+TRACE_EVENT(
+ cpm_send_message,
+
+ TP_PROTO(struct cpm_session *session, int ret),
+
+ TP_ARGS(session, ret),
+
+ TP_STRUCT__entry(
+ __field(void *, session)
+ __field(int, ret)
+ ),
+
+ TP_fast_assign(
+ __entry->session = session;
+ __entry->ret = ret;
+ ),
+
+ TP_printk("session=%p ret=%d",
+ __entry->session, __entry->ret)
+);
+
+TRACE_EVENT(
+ cpm_handle_host_tx,
+
+ TP_PROTO(u8 dst_id, const struct cpm_payload *payload),
+
+ TP_ARGS(dst_id, payload),
+
+ TP_STRUCT__entry(
+ __field(u8, dst_id)
+ __field(u32, header)
+ __array(u32, payloads, GOOG_MBA_PAYLOAD_SIZE)
+ ),
+
+ TP_fast_assign(
+ __entry->dst_id = dst_id;
+ cpm_trace_clone_payload(&__entry->header, __entry->payloads, payload);
+ ),
+
+ TP_printk("dst_id=%u: %#010x %#010x %#010x %#010x",
+ __entry->dst_id, __entry->header, __entry->payloads[0],
+ __entry->payloads[1], __entry->payloads[2])
+);
+
+#endif /* _GOOGLE_CPM_MBA_TRACE_H */
+
+/* This part must be outside protection */
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../drivers/soc/google/
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE google-cpm-mba-trace
+#include <trace/define_trace.h>
diff --git a/drivers/soc/google/google-cpm-mba.c b/drivers/soc/google/google-cpm-mba.c
new file mode 100644
index 000000000000..432f0da0cd99
--- /dev/null
+++ b/drivers/soc/google/google-cpm-mba.c
@@ -0,0 +1,956 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Google MailBox Array (MBA) CPM Interface
+ *
+ * Copyright 2023-2026 Google LLC
+ */
+
+#include <linux/array_size.h>
+#include <linux/auxiliary_bus.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/bug.h>
+#include <linux/cleanup.h>
+#include <linux/completion.h>
+#include <linux/container_of.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/gfp_types.h>
+#include <linux/jiffies.h>
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/lockdep.h>
+#include <linux/mailbox/goog-mba-message.h>
+#include <linux/mailbox_client.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/printk.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#include <soc/google/cpm-service-ids.h>
+#include <soc/google/google-cpm-mba.h>
+
+/*
+ * Header of queue mode message defines fields for type, src_id and dst_id.
+ *
+ * 31 30 29 24 20 16 8 0
+ * +---+------+---+-------+-----+-----+-----+
+ * | V | Type | R | Token | Seq | Src | Dst |
+ * +---+------+---+-------+-----+-----+-----+
+ *
+ * Bit 31 is valid bit: Must be 1.
+ * Bits 30-29 are type: The message type can be one of the following values:
+ * 0x0 One-way message
+ * 0x1 Requests (expect response)
+ * 0x2 Response (to a previous request)
+ * Bits 28-24 are reserved.
+ * Bits 23-20 are token: Reserved for transport layer module.
+ * Bits 19-16 are seq: Reserved for transport layer module.
+ * Bits 15-8 are source id.
+ * Bits 7-0 are destination id.
+ */
+
+#define GOOG_MBA_Q_DST_ID_MASK GENMASK(7, 0)
+#define GOOG_MBA_Q_SRC_ID_MASK GENMASK(15, 8)
+#define GOOG_MBA_Q_SEQ_MASK GENMASK(19, 16)
+#define GOOG_MBA_Q_TOKEN_MASK GENMASK(23, 20)
+#define GOOG_MBA_Q_TYPE_MASK GENMASK(30, 29)
+#define GOOG_MBA_Q_VALID_MASK GENMASK(31, 31)
+
+#define GOOG_MBA_Q_MIN_SEQ_VAL 1
+#define GOOG_MBA_Q_MAX_SEQ_VAL 13
+#define GOOG_MBA_Q_MAX_TOKEN_VAL 16
+
+#define GOOG_MBA_Q_INIT_PROTO_VAL 0x100
+
+#define GOOG_MBA_Q_TYPE_ONEWAY 0x0
+#define GOOG_MBA_Q_TYPE_REQUEST 0x1
+#define GOOG_MBA_Q_TYPE_RESPONSE 0x2
+
+#define CPM_SEND_TIMEOUT_MS 3000
+
+/* CPM_COMMON_LPCM_SERVICE */
+#define LPCM_OP_ID_MASK GENMASK(31, 24)
+#define LPCM_OBJ_ID_MASK GENMASK(23, 16)
+#define LPCM_ID_MASK GENMASK(15, 8)
+#define LPCM_REQ_ID_MASK GENMASK(7, 0)
+
+#define LK_NO_ERROR 0
+#define LK_ERR_GENERIC (-1)
+#define LK_ERR_UNAVAILABLE (-3)
+#define LK_ERR_INVALID_ARGS (-8)
+#define LK_ERR_TIMED_OUT (-13)
+#define LK_ERR_NOT_SUPPORTED (-24)
+
+/* CPM_COMMON_LPB_SERVICE */
+#define CPM_COMMON_PROT_NO_ERR 0xf
+
+static inline u32 goog_mba_q_get_dst_id(const u32 *msg)
+{
+ return FIELD_GET(GOOG_MBA_Q_DST_ID_MASK, *msg);
+}
+
+static inline u32 goog_mba_q_get_token(const u32 *msg)
+{
+ return FIELD_GET(GOOG_MBA_Q_TOKEN_MASK, *msg);
+}
+
+static inline u32 goog_mba_q_get_type(const u32 *msg)
+{
+ return FIELD_GET(GOOG_MBA_Q_TYPE_MASK, *msg);
+}
+
+static inline void goog_mba_q_set_seq(u32 *msg, u32 seq)
+{
+ *msg &= ~GOOG_MBA_Q_SEQ_MASK;
+ *msg |= FIELD_PREP(GOOG_MBA_Q_SEQ_MASK, seq);
+}
+
+static inline void goog_mba_q_set_token(u32 *msg, u32 token)
+{
+ *msg &= ~GOOG_MBA_Q_TOKEN_MASK;
+ *msg |= FIELD_PREP(GOOG_MBA_Q_TOKEN_MASK, token);
+}
+
+static inline u32 goog_mba_q_create_hdr(u8 src_id, u8 dst_id, u8 seq, u8 token, u8 type)
+{
+ return FIELD_PREP(GOOG_MBA_Q_SRC_ID_MASK, src_id) |
+ FIELD_PREP(GOOG_MBA_Q_DST_ID_MASK, dst_id) |
+ FIELD_PREP(GOOG_MBA_Q_SEQ_MASK, seq) |
+ FIELD_PREP(GOOG_MBA_Q_TOKEN_MASK, token) |
+ FIELD_PREP(GOOG_MBA_Q_TYPE_MASK, type) |
+ FIELD_PREP(GOOG_MBA_Q_VALID_MASK, 1);
+}
+
+struct cpm_session {
+ struct kref refcount;
+ struct completion complete;
+ struct cpm_payload req_msg;
+ struct cpm_payload resp_msg;
+ struct goog_mba_tx_msg req_mba_msg;
+};
+
+#define CREATE_TRACE_POINTS
+#include "google-cpm-mba-trace.h"
+
+#define MBOX_IDX_REQ 0
+#define MBOX_IDX_RESP 1
+
+struct cpm_mbox_chan_info {
+ struct mbox_client client;
+ struct mbox_chan *chan;
+ struct list_head entry;
+};
+
+struct cpm_rx_client {
+ struct cpm_handle *cpm;
+ u8 src_id;
+ cpm_rx_cb_t cb;
+ void *priv;
+ struct list_head entry;
+};
+
+/**
+ * struct cpm_handle - Core handle and state for the CPM interface
+ * @dev: The device structure associated with this CPM interface.
+ * @rx_clients: List of registered RX callback clients.
+ * @lock: Spinlock for protecting critical sections.
+ * @seq_num: Sequence number for debugging.
+ * @resp_pending: Array for sessions awaiting responses from the CPM host.
+ * @req_chans: Circular list of request mailbox channels (rotated round-robin).
+ * @resp_chan: Response mailbox channel.
+ */
+struct cpm_handle {
+ struct device *dev;
+ struct list_head rx_clients;
+
+ /*
+ * Protect queue operations including rx_clients, token, resp_pending,
+ * req_chans, and resp_chan.
+ */
+ spinlock_t lock;
+ int seq_num;
+ struct cpm_session *resp_pending[GOOG_MBA_Q_MAX_TOKEN_VAL];
+ struct list_head req_chans;
+ struct cpm_mbox_chan_info resp_chan;
+};
+
+static const struct of_device_id cpm_of_match_table[] = {
+ { .compatible = "google,lga-cpm" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, cpm_of_match_table);
+
+static inline bool cpm_is_request_msg(const struct cpm_request *req)
+{
+ return req->msg_type == REQUEST_MSG;
+}
+
+static inline bool cpm_is_oneway_msg(const struct cpm_request *req)
+{
+ return req->msg_type == ONEWAY_MSG;
+}
+
+static inline bool cpm_is_request_header(const void *msg)
+{
+ return goog_mba_q_get_type(msg) == GOOG_MBA_Q_TYPE_REQUEST;
+}
+
+static inline bool cpm_is_oneway_header(const void *msg)
+{
+ return goog_mba_q_get_type(msg) == GOOG_MBA_Q_TYPE_ONEWAY;
+}
+
+static inline bool cpm_is_response_header(const void *msg)
+{
+ return goog_mba_q_get_type(msg) == GOOG_MBA_Q_TYPE_RESPONSE;
+}
+
+static inline bool cpm_is_init_header(const void *msg)
+{
+ return *(const u32 *)msg == GOOG_MBA_Q_INIT_PROTO_VAL;
+}
+
+static void cpm_session_release(struct kref *kref)
+{
+ struct cpm_session *session = container_of(kref, struct cpm_session, refcount);
+
+ kfree(session);
+}
+
+DEFINE_FREE(session_put, struct cpm_session *, if (_T) kref_put(&_T->refcount, cpm_session_release))
+
+/**
+ * cpm_add_pending_resp - add session to pending table to wait for host response
+ * @cpm: Core driver data.
+ * @session: Client's session waiting for response.
+ *
+ * Return: 0 on success, -EBUSY if no token is available.
+ */
+static int cpm_add_pending_resp(struct cpm_handle *cpm, struct cpm_session *session)
+{
+ struct device *dev = cpm->dev;
+ int token;
+
+ lockdep_assert_held(&cpm->lock);
+
+ for (token = 0; token < GOOG_MBA_Q_MAX_TOKEN_VAL; token++) {
+ if (!cpm->resp_pending[token]) {
+ goog_mba_q_set_token(&session->req_msg.header, token);
+ kref_get(&session->refcount);
+ cpm->resp_pending[token] = session;
+ return 0;
+ }
+ }
+
+ dev_err_ratelimited(dev, "Failed to find available entries in resp_pending (header=%#010x)\n",
+ session->req_msg.header);
+
+ return -EBUSY;
+}
+
+/**
+ * cpm_remove_pending_resp - remove session entry from pending table after received response
+ * @cpm: Core driver data.
+ * @msg_payload: Used to resolve embedded token value to remove corresponding
+ * entry of pending table.
+ *
+ * Return: True if a matching session was found and removed, false otherwise.
+ */
+static bool
+cpm_remove_pending_resp(struct cpm_handle *cpm,
+ const struct cpm_payload *msg_payload)
+{
+ struct cpm_session *session;
+ int token = goog_mba_q_get_token(&msg_payload->header);
+
+ lockdep_assert_held(&cpm->lock);
+
+ session = cpm->resp_pending[token];
+ if (!session)
+ return false;
+
+ cpm->resp_pending[token] = NULL;
+
+ if (cpm_is_response_header(msg_payload)) {
+ trace_cpm_resp_cb(session, msg_payload);
+ session->resp_msg = *msg_payload;
+ complete(&session->complete);
+ }
+
+ kref_put(&session->refcount, cpm_session_release);
+
+ return true;
+}
+
+static void
+cpm_remove_pending_by_session(struct cpm_handle *cpm,
+ struct cpm_session *session)
+{
+ int token;
+
+ lockdep_assert_held(&cpm->lock);
+
+ for (token = 0; token < GOOG_MBA_Q_MAX_TOKEN_VAL; token++) {
+ if (cpm->resp_pending[token] == session) {
+ cpm->resp_pending[token] = NULL;
+ kref_put(&session->refcount, cpm_session_release);
+ return;
+ }
+ }
+}
+
+/**
+ * cpm_set_seq_number - assign sequential number in valid range
+ * @cpm: Core driver data.
+ * @req_msg: Request payload to write sequence number to.
+ */
+static inline void cpm_set_seq_number(struct cpm_handle *cpm,
+ struct cpm_payload *req_msg)
+{
+ int seq_num;
+
+ seq_num = cpm->seq_num;
+ goog_mba_q_set_seq(&req_msg->header, seq_num);
+ if (seq_num == GOOG_MBA_Q_MAX_SEQ_VAL)
+ cpm->seq_num = GOOG_MBA_Q_MIN_SEQ_VAL;
+ else
+ cpm->seq_num++;
+}
+
+static struct cpm_rx_client *
+cpm_search_rx_client(struct cpm_handle *cpm, u8 src_id)
+{
+ struct cpm_rx_client *rx_client;
+
+ list_for_each_entry(rx_client, &cpm->rx_clients, entry) {
+ if (rx_client->src_id == src_id)
+ return rx_client;
+ }
+
+ return NULL;
+}
+
+static void cpm_put_dev(void *data)
+{
+ struct device *cpm_dev = data;
+
+ put_device(cpm_dev);
+}
+
+struct cpm_handle *devm_cpm_get_handle(struct device *dev)
+{
+ struct device *cpm_dev = dev->parent;
+ struct cpm_handle *cpm;
+ int ret;
+
+ if (!cpm_dev ||
+ WARN_ON(!of_match_node(cpm_of_match_table, cpm_dev->of_node))) {
+ dev_err(dev, "Parent device is not CPM: %s\n",
+ cpm_dev ? dev_name(cpm_dev) : "(none)");
+ return ERR_PTR(-EINVAL);
+ }
+
+ cpm = dev_get_drvdata(cpm_dev);
+ if (WARN_ON(!cpm))
+ return ERR_PTR(-ENODEV);
+
+ get_device(cpm_dev);
+ ret = devm_add_action_or_reset(dev, cpm_put_dev, cpm_dev);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return cpm;
+}
+EXPORT_SYMBOL_GPL(devm_cpm_get_handle);
+
+static void cpm_unregister_rx_callback(void *data)
+{
+ struct cpm_rx_client *rx_client = data;
+ struct cpm_handle *cpm = rx_client->cpm;
+
+ scoped_guard(spinlock_irqsave, &cpm->lock)
+ list_del(&rx_client->entry);
+
+ kfree(rx_client);
+}
+
+int devm_cpm_register_rx_callback(struct device *dev,
+ struct cpm_handle *handle, u8 src_id,
+ cpm_rx_cb_t cb, void *priv)
+{
+ struct cpm_rx_client *rx_client;
+
+ if (!src_id || !cb)
+ return -EINVAL;
+
+ rx_client = kzalloc_obj(*rx_client, GFP_KERNEL);
+ if (!rx_client)
+ return -ENOMEM;
+
+ INIT_LIST_HEAD(&rx_client->entry);
+ rx_client->cpm = handle;
+ rx_client->src_id = src_id;
+ rx_client->cb = cb;
+ rx_client->priv = priv;
+
+ scoped_guard(spinlock_irqsave, &handle->lock) {
+ if (cpm_search_rx_client(handle, src_id)) {
+ kfree(rx_client);
+ return -EBUSY;
+ }
+
+ list_add(&rx_client->entry, &handle->rx_clients);
+ }
+
+ return devm_add_action_or_reset(dev, cpm_unregister_rx_callback,
+ rx_client);
+}
+EXPORT_SYMBOL_GPL(devm_cpm_register_rx_callback);
+
+static u32 cpm_req_get_header(const struct cpm_request *cpm_req)
+{
+ if (cpm_is_oneway_msg(cpm_req))
+ return goog_mba_q_create_hdr(cpm_req->src_id, cpm_req->dst_id,
+ 0, 0, GOOG_MBA_Q_TYPE_ONEWAY);
+ if (cpm_is_request_msg(cpm_req))
+ return goog_mba_q_create_hdr(cpm_req->src_id, cpm_req->dst_id,
+ 0, 0, GOOG_MBA_Q_TYPE_REQUEST);
+
+ return 0;
+}
+
+static int cpm_try_submit(struct cpm_handle *cpm, struct cpm_session *session)
+{
+ struct device *dev = cpm->dev;
+ struct cpm_payload *req_msg = &session->req_msg;
+ struct cpm_mbox_chan_info *mbox_chan_info;
+ int ret;
+
+ lockdep_assert_held(&cpm->lock);
+
+ if (!cpm_is_init_header(req_msg)) {
+ session->req_mba_msg.init = false;
+ if (cpm_is_request_header(req_msg)) {
+ ret = cpm_add_pending_resp(cpm, session);
+ if (ret < 0)
+ return ret;
+ }
+ cpm_set_seq_number(cpm, req_msg);
+ } else {
+ session->req_mba_msg.init = true;
+ }
+
+ mbox_chan_info = list_first_entry(&cpm->req_chans,
+ struct cpm_mbox_chan_info, entry);
+
+ /* Get ref for request channel TX completion before submit */
+ kref_get(&session->refcount);
+
+ session->req_mba_msg.payload = (u32 *)req_msg;
+ session->req_mba_msg.payload_words =
+ sizeof(*req_msg) / sizeof(*session->req_mba_msg.payload);
+
+ ret = mbox_send_message(mbox_chan_info->chan, &session->req_mba_msg);
+ if (ret < 0) {
+ dev_err_ratelimited(dev,
+ "Failed to send mailbox message (header=%#010x, payload=[%#010x, %#010x, %#010x]): %d\n",
+ req_msg->header, req_msg->payload[0],
+ req_msg->payload[1], req_msg->payload[2],
+ ret);
+ if (!cpm_is_init_header(req_msg) && cpm_is_request_header(req_msg))
+ cpm_remove_pending_resp(cpm, req_msg);
+ /* Put ref for request channel since submit failed */
+ kref_put(&session->refcount, cpm_session_release);
+
+ return ret;
+ }
+
+ trace_cpm_submit_msg(session, req_msg);
+ list_rotate_left(&cpm->req_chans);
+
+ return 0;
+}
+
+static int __cpm_send_message(struct cpm_handle *cpm,
+ struct cpm_request *cpm_req,
+ u32 header)
+{
+ unsigned long wait = MAX_SCHEDULE_TIMEOUT;
+ int ret;
+
+ struct cpm_session *session __free(session_put) = kzalloc_obj(*session, GFP_KERNEL);
+ if (!session)
+ return -ENOMEM;
+
+ cpm_req->req_msg->header = header;
+
+ /* Initialize session */
+ kref_init(&session->refcount);
+ init_completion(&session->complete);
+
+ session->req_msg = *cpm_req->req_msg;
+
+ trace_cpm_req_enqueue(session, cpm_req);
+
+ scoped_guard(spinlock_irqsave, &cpm->lock) {
+ ret = cpm_try_submit(cpm, session);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (cpm_req->tout_ms)
+ wait = msecs_to_jiffies(cpm_req->tout_ms);
+
+ if (wait_for_completion_timeout(&session->complete, wait) == 0) {
+ ret = -ETIMEDOUT;
+ /* Clean up pending response mapping on timeout */
+ scoped_guard(spinlock_irqsave, &cpm->lock)
+ cpm_remove_pending_by_session(cpm, session);
+ } else if (cpm_is_request_msg(cpm_req) && cpm_req->resp_msg) {
+ *cpm_req->resp_msg = session->resp_msg;
+ }
+ trace_cpm_send_message(session, ret);
+
+ return ret;
+}
+
+static bool cpm_iface_is_valid_req(struct cpm_handle *cpm,
+ const struct cpm_request *cpm_req)
+{
+ struct device *dev = cpm->dev;
+
+ if (!cpm_req) {
+ dev_err(dev, "cpm_req is NULL\n");
+ return false;
+ }
+
+ if (!cpm_req->req_msg) {
+ dev_err(dev, "cpm_req->req_msg is NULL\n");
+ return false;
+ }
+
+ if (cpm_req->msg_type != ONEWAY_MSG &&
+ cpm_req->msg_type != REQUEST_MSG) {
+ dev_err(dev, "Invalid msg_type: %d\n", cpm_req->msg_type);
+ return false;
+ }
+
+ if (cpm_is_request_msg(cpm_req) && !cpm_req->resp_msg) {
+ dev_err(dev, "cpm_req->resp_msg is NULL when msg_type is REQUEST_MSG\n");
+ return false;
+ }
+
+ return true;
+}
+
+int cpm_send_message(struct cpm_handle *handle, struct cpm_request *cpm_req)
+{
+ u32 header;
+
+ if (!cpm_iface_is_valid_req(handle, cpm_req))
+ return -EINVAL;
+
+ header = cpm_req_get_header(cpm_req);
+ if (!header)
+ return -EINVAL;
+
+ return __cpm_send_message(handle, cpm_req, header);
+}
+EXPORT_SYMBOL_GPL(cpm_send_message);
+
+/* Translate Little Kernel error codes to Linux errno */
+static int cpm_lk_error_to_errno(int err)
+{
+ switch (err) {
+ case LK_NO_ERROR:
+ return 0;
+ case LK_ERR_GENERIC:
+ return -EREMOTEIO;
+ case LK_ERR_UNAVAILABLE:
+ return -ENODATA;
+ case LK_ERR_INVALID_ARGS:
+ return -EINVAL;
+ case LK_ERR_TIMED_OUT:
+ return -ETIMEDOUT;
+ case LK_ERR_NOT_SUPPORTED:
+ return -EOPNOTSUPP;
+ default:
+ return -EPROTO;
+ }
+}
+
+int cpm_send_lpcm_message(struct cpm_handle *handle,
+ const struct cpm_lpcm_message *msg)
+{
+ struct device *dev = handle->dev;
+ struct cpm_payload resp_msg;
+ struct cpm_payload req_msg = {};
+ struct cpm_request cpm_req = {
+ .msg_type = REQUEST_MSG,
+ .req_msg = &req_msg,
+ .resp_msg = &resp_msg,
+ .dst_id = CPM_COMMON_LPCM_SERVICE,
+ .tout_ms = CPM_SEND_TIMEOUT_MS,
+ };
+ s32 result;
+ int ret;
+
+ req_msg.payload[0] = FIELD_PREP(LPCM_REQ_ID_MASK, msg->cmd) |
+ FIELD_PREP(LPCM_ID_MASK, msg->lpcm_id) |
+ FIELD_PREP(LPCM_OBJ_ID_MASK, msg->obj_id) |
+ FIELD_PREP(LPCM_OP_ID_MASK, msg->opcode);
+ req_msg.payload[1] = msg->payload;
+
+ dev_dbg(dev, "lpcm_id %u, obj_id %u, cmd %u, opcode %u: send mba mail: [%#010x, %#010x, %#010x]\n",
+ msg->lpcm_id, msg->obj_id, msg->cmd, msg->opcode,
+ req_msg.payload[0], req_msg.payload[1], req_msg.payload[2]);
+
+ ret = cpm_send_message(handle, &cpm_req);
+ if (ret < 0) {
+ dev_err(dev, "lpcm_id %u, obj_id %u: failed to send request to CPM, ret=%d\n",
+ msg->lpcm_id, msg->obj_id, ret);
+ return ret;
+ }
+
+ result = resp_msg.payload[0];
+ if (result < 0) {
+ ret = cpm_lk_error_to_errno(result);
+ dev_err(dev, "lpcm_id %u, obj_id %u: error response from CPM: %pe\n",
+ msg->lpcm_id, msg->obj_id, ERR_PTR(ret));
+ return ret;
+ }
+
+ dev_dbg(dev, "got resp from %u, data %d\n", cpm_req.dst_id, result);
+
+ return result;
+}
+EXPORT_SYMBOL_GPL(cpm_send_lpcm_message);
+
+int cpm_send_lpb_message(struct cpm_handle *handle,
+ const struct cpm_lpb_message *msg)
+{
+ struct device *dev = handle->dev;
+ struct cpm_payload resp_msg;
+ struct cpm_payload req_msg = {};
+ struct cpm_request cpm_req = {
+ .msg_type = REQUEST_MSG,
+ .req_msg = &req_msg,
+ .resp_msg = &resp_msg,
+ .src_id = APC_COMMON_SERVICE_ID_POWER_CONTROLLER,
+ .dst_id = CPM_COMMON_LPB_SERVICE,
+ .tout_ms = CPM_SEND_TIMEOUT_MS,
+ };
+ s32 status;
+ int ret;
+
+ req_msg.payload[0] = msg->cmd;
+ req_msg.payload[1] = msg->sswrp_id;
+ req_msg.payload[2] = msg->data;
+
+ dev_dbg(dev, "LPB cmd %u, sswrp_id %u: send mba mail: [%#010x, %#010x, %#010x]\n",
+ msg->cmd, msg->sswrp_id, req_msg.payload[0],
+ req_msg.payload[1], req_msg.payload[2]);
+
+ ret = cpm_send_message(handle, &cpm_req);
+ if (ret < 0) {
+ dev_err(dev, "LPB cmd %u, sswrp_id %u: failed to send request to CPM, ret=%d\n",
+ msg->cmd, msg->sswrp_id, ret);
+ return ret;
+ }
+
+ dev_dbg(dev, "LPB response: [%#010x, %#010x, %#010x]\n",
+ resp_msg.payload[0], resp_msg.payload[1], resp_msg.payload[2]);
+
+ if (resp_msg.payload[0] != CPM_COMMON_PROT_NO_ERR) {
+ dev_err(dev, "LPB cmd %u, sswrp_id %u: error response from CPM: %u\n",
+ msg->cmd, msg->sswrp_id, resp_msg.payload[0]);
+ return -EPROTO;
+ }
+
+ status = resp_msg.payload[1];
+ if (status < 0)
+ return -EPROTO;
+
+ return status;
+}
+EXPORT_SYMBOL_GPL(cpm_send_lpb_message);
+
+/**
+ * cpm_req_tx_done - callback function from request channels
+ * @client: Pointer to the mailbox client structure.
+ * @msg: Pointer to the transmitted mailbox message.
+ * @r: Status of the transmission.
+ */
+static void cpm_req_tx_done(struct mbox_client *client, void *msg, int r)
+{
+ struct cpm_session *session;
+
+ if (!msg)
+ return;
+
+ session = container_of(msg, struct cpm_session, req_mba_msg);
+
+ trace_cpm_req_tx_done(session);
+
+ if (cpm_is_oneway_header(&session->req_msg))
+ complete(&session->complete);
+
+ kref_put(&session->refcount, cpm_session_release);
+}
+
+static void cpm_handle_host_tx(struct cpm_handle *cpm, const void *msg)
+{
+ struct device *dev = cpm->dev;
+ const struct cpm_payload *msg_payload = msg;
+ struct cpm_rx_client *rx_client;
+ u8 dst_id = goog_mba_q_get_dst_id(msg);
+
+ scoped_guard(spinlock_irqsave, &cpm->lock) {
+ rx_client = cpm_search_rx_client(cpm, dst_id);
+ if (!rx_client) {
+ dev_err(dev, "No available RX callback (id:%u).\n Payload Info:\n",
+ dst_id);
+ print_hex_dump(KERN_ERR, dev_name(dev), DUMP_PREFIX_NONE, 16, 4,
+ msg_payload, sizeof(*msg_payload), false);
+ return;
+ }
+
+ rx_client->cb(msg_payload, rx_client->priv);
+ }
+
+ trace_cpm_handle_host_tx(dst_id, msg_payload);
+}
+
+/**
+ * cpm_resp_cb - Handles incoming messages on response channels
+ * @mbox_client: Pointer to the mailbox client structure.
+ * @param: Pointer to the received mailbox message (&struct goog_mba_rx_msg).
+ *
+ * This callback is invoked when a message arrives on a response channel. It
+ * handles the following scenarios:
+ *
+ * 1. CPM Response to Client Request: Processes a response from the CPM to a
+ * previously issued client request.
+ * 2. CPM-Initiated Request: Processes a new request initiated by the CPM and
+ * dispatches it to the appropriate client handler.
+ * 3. Invalid Message Type: Handles unexpected message types.
+ */
+static void cpm_resp_cb(struct mbox_client *mbox_client, void *param)
+{
+ struct goog_mba_rx_msg *rx_msg = param;
+ const void *msg = rx_msg->payload;
+ struct cpm_mbox_chan_info *chan_info =
+ container_of(mbox_client, struct cpm_mbox_chan_info, client);
+ struct cpm_handle *cpm = container_of(chan_info, struct cpm_handle, resp_chan);
+ struct device *dev = cpm->dev;
+
+ if (cpm_is_init_header(msg)) {
+ /*
+ * This is unexpected. If we see this, we may need to initiate
+ * our own (re)init message -- cpm_init_q_mode().
+ */
+ dev_err(dev, "Reset message received from the remote\n");
+ return;
+ }
+
+ if (cpm_is_response_header(msg)) {
+ const struct cpm_payload *msg_payload = msg;
+ bool found;
+
+ scoped_guard(spinlock_irqsave, &cpm->lock)
+ found = cpm_remove_pending_resp(cpm, msg_payload);
+ if (!found)
+ dev_err(dev,
+ "No token:%u found for response payload: %#10x %#10x %#10x %#10x\n",
+ goog_mba_q_get_token(&msg_payload->header),
+ msg_payload->header, msg_payload->payload[0],
+ msg_payload->payload[1], msg_payload->payload[2]);
+ } else if (cpm_is_request_header(msg) || cpm_is_oneway_header(msg)) {
+ cpm_handle_host_tx(cpm, msg);
+ } else {
+ dev_err(dev, "Unknown message type: %u\n", goog_mba_q_get_type(msg));
+ }
+}
+
+static void cpm_iface_free_chan_action(void *data)
+{
+ struct cpm_mbox_chan_info *chan = data;
+
+ mbox_free_channel(chan->chan);
+}
+
+static int
+cpm_init_channel(struct cpm_handle *cpm,
+ struct cpm_mbox_chan_info *chan_info,
+ int idx,
+ void (*txdone_callback)(struct mbox_client *client, void *msg, int r),
+ void (*rx_callback)(struct mbox_client *client, void *msg))
+{
+ struct device *dev = cpm->dev;
+ struct mbox_client *client;
+
+ client = &chan_info->client;
+ client->dev = dev;
+ client->rx_callback = rx_callback;
+ client->tx_done = txdone_callback;
+
+ chan_info->chan = mbox_request_channel(client, idx);
+ if (IS_ERR(chan_info->chan))
+ return PTR_ERR(chan_info->chan);
+
+ return devm_add_action_or_reset(dev, cpm_iface_free_chan_action, chan_info);
+}
+
+/**
+ * cpm_init_req_channels - Request all available TX mailbox channels
+ * @cpm: Core driver data.
+ *
+ * The Linux mailbox core only allows a single in-flight message per channel.
+ * To utilize the underlying mailbox controller's hardware queue, the
+ * controller exposes one mailbox channel per hardware queue slot (N channels
+ * total) for the same devicetree node (with #mbox-cells = <0>) and hands out
+ * the next unbound channel on each mbox_request_channel() call. Repeatedly
+ * request MBOX_IDX_REQ until all hardware queue slots have been claimed
+ * (-EBUSY).
+ *
+ * cpm_try_submit() then rotates through @cpm->req_chans round-robin under
+ * @cpm->lock. Because the hardware queue is strictly FIFO, the m-th message is
+ * always assigned to channel (m mod N):
+ * - When fewer than N messages are in flight in hardware, the next channel in
+ * the rotation is guaranteed to already be idle and submits straight to
+ * hardware.
+ * - When all N hardware slots are busy, the next channel in the rotation holds
+ * the oldest in-flight message and will be the first to complete, so
+ * queuing into that channel's mailbox-core software queue drains messages
+ * into hardware in FIFO order.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+static int cpm_init_req_channels(struct cpm_handle *cpm)
+{
+ struct device *dev = cpm->dev;
+ int ret;
+
+ while (true) {
+ struct cpm_mbox_chan_info *chan_info;
+
+ chan_info = devm_kzalloc(dev, sizeof(*chan_info), GFP_KERNEL);
+ if (!chan_info)
+ return -ENOMEM;
+
+ ret = cpm_init_channel(cpm, chan_info, MBOX_IDX_REQ,
+ cpm_req_tx_done, NULL);
+ if (ret) {
+ devm_kfree(dev, chan_info);
+ if (ret == -EBUSY && !list_empty(&cpm->req_chans))
+ return 0;
+ return dev_err_probe(dev, ret,
+ "Failed to request TX mailbox channel\n");
+ }
+
+ list_add_tail(&chan_info->entry, &cpm->req_chans);
+ }
+}
+
+static int cpm_init_q_mode_proto(struct cpm_handle *cpm)
+{
+ struct cpm_payload msg_payload = {};
+ struct cpm_request req = {
+ .msg_type = ONEWAY_MSG,
+ .req_msg = &msg_payload,
+ /*
+ * Include extra-long timeout simply for completeness. If this
+ * fails, the system is probably in really bad shape.
+ */
+ .tout_ms = CPM_SEND_TIMEOUT_MS * 10,
+ };
+
+ return __cpm_send_message(cpm, &req, GOOG_MBA_Q_INIT_PROTO_VAL);
+}
+
+static int cpm_init_q_mode(struct cpm_handle *cpm)
+{
+ int ret;
+
+ ret = cpm_init_q_mode_proto(cpm);
+ if (ret < 0)
+ return ret;
+
+ cpm->seq_num = GOOG_MBA_Q_MIN_SEQ_VAL;
+
+ return 0;
+}
+
+static const char * const cpm_adev_names[] = {
+ "reset",
+ "power-controller",
+ "clk",
+ "irq",
+};
+
+static int cpm_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct cpm_handle *cpm;
+ int ret;
+
+ cpm = devm_kzalloc(dev, sizeof(*cpm), GFP_KERNEL);
+ if (!cpm)
+ return -ENOMEM;
+
+ cpm->dev = dev;
+ platform_set_drvdata(pdev, cpm);
+
+ spin_lock_init(&cpm->lock);
+ INIT_LIST_HEAD(&cpm->rx_clients);
+ INIT_LIST_HEAD(&cpm->req_chans);
+
+ ret = cpm_init_req_channels(cpm);
+ if (ret)
+ return ret;
+
+ ret = cpm_init_channel(cpm, &cpm->resp_chan, MBOX_IDX_RESP,
+ NULL, cpm_resp_cb);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to request RX mailbox channel\n");
+
+ ret = cpm_init_q_mode(cpm);
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Failed to initialize queue mode\n");
+
+ for (int i = 0; i < ARRAY_SIZE(cpm_adev_names); i++) {
+ struct auxiliary_device *adev;
+
+ adev = devm_auxiliary_device_create(dev, cpm_adev_names[i], NULL);
+ if (!adev)
+ return dev_err_probe(dev, -ENODEV,
+ "Failed to create %s auxiliary device\n",
+ cpm_adev_names[i]);
+ }
+
+ return 0;
+}
+
+static struct platform_driver cpm_driver = {
+ .probe = cpm_probe,
+ .driver = {
+ .name = "google-cpm-mba",
+ .of_match_table = cpm_of_match_table,
+ },
+};
+module_platform_driver(cpm_driver);
+
+MODULE_DESCRIPTION("Google MBA CPM interface");
+MODULE_AUTHOR("Lucas Wei <lucaswei@google.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/soc/google/cpm-service-ids.h b/include/soc/google/cpm-service-ids.h
new file mode 100644
index 000000000000..af90b88b759b
--- /dev/null
+++ b/include/soc/google/cpm-service-ids.h
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2022-2026 Google LLC
+ */
+
+#ifndef _SOC_GOOGLE_CPM_SERVICE_IDS_H
+#define _SOC_GOOGLE_CPM_SERVICE_IDS_H
+
+enum apc_common_mba_service_id {
+ APC_COMMON_SERVICE_FIRST = 0x0,
+ APC_COMMON_SERVICE_ID_RESERVED = 0x0,
+ APC_COMMON_SERVICE_ID_PING = 0x1,
+ APC_COMMON_SERVICE_ID_CPMLOG = 0x2,
+ APC_COMMON_SERVICE_ID_GMC = 0x3,
+ APC_COMMON_SERVICE_ID_GSLC = 0x4,
+ APC_COMMON_SERVICE_ID_CPM_TRACEPOINT = 0x5,
+ APC_COMMON_SERVICE_ID_PF_STATE_CPM = 0x6,
+ APC_COMMON_SERVICE_ID_POWER_CONTROLLER = 0x7,
+ APC_COMMON_SERVICE_ID_MIPM = 0x8,
+ APC_COMMON_SERVICE_LAST = 0x37,
+};
+
+#define MBA_COMMON_MIN_SERVICE_ID 0x38
+#define MBA_COMMON_MAX_SERVICE_ID 0x70
+
+enum cpm_common_mba_service_id {
+ CPM_COMMON_SERVICE_FIRST = 0x0,
+ /* Test service */
+ CPM_COMMON_PING_SERVICE = 0x0,
+ /* Used for extracting logs */
+ CPM_AP_COMMON_LOG_SERVICE = 0x1,
+ /* Interact with tracepoint library */
+ CPM_AP_COMMON_TRACEPOINT_SERVICE = 0x2,
+ /* Control GSLC CPM functions */
+ CPM_AP_COMMON_GSLC_MB_SERVICE = 0x3,
+ /* Control GMCCPM functions */
+ CPM_AP_COMMON_GMC_MB_SERVICE = 0x4,
+ /* Control LPB peripheral */
+ CPM_COMMON_LPB_SERVICE = 0x5,
+ /* System reset service */
+ CPM_COMMON_RESET_SERVICE = 0x6,
+ /* ODPM API service for AP */
+ CPM_AP_COMMON_ODPM_MB_SERVICE = 0x7,
+ /* LPCM service. */
+ CPM_COMMON_LPCM_SERVICE = 0x8,
+ /* Control and modify SoC power states */
+ CPM_COMMON_POWER_STATE_SERVICE = 0x9,
+ /* PMIC related services */
+ CPM_COMMON_PMIC_SERVICE = 0xA,
+ /* MIPM interface */
+ CPM_COMMON_MIPM_SERVICE = 0xB,
+ /* Thermal services - emul temps, loops, config, etc */
+ CPM_COMMON_THERMAL_SERVICE = 0xC,
+ /* Pull PIF history status over LMF. */
+ CPM_COMMON_PIF_HISTORY_SERVICE = 0xD,
+ /* Pwrblk/SSWRP based service */
+ CPM_COMMON_PWRBLK_SERVICE = 0xE,
+ /* CPM command line service */
+ CPM_COMMON_COMMAND_LINE_SERVICE = 0xF,
+ /* GDMC->CPM special message */
+ CPM_GDMC_PMIC_SERVICE = 0x10,
+ /* SMMU initial register configuration service */
+ CPM_SMMU_SERVICE = 0x11,
+ /* BCL service */
+ CPM_COMMON_BCL_SERVICE = 0x12,
+ CPM_COMMON_THERMAL_V2_SERVICE = 0x15,
+ /* Pixel firmware tracepoint service */
+ CPM_COMMON_FWTP_SERVICE = 0x17,
+ CPM_COMMON_SERVICE_LAST = 0x37,
+};
+
+enum cpm_ap_ns_mba_service_id {
+ CPM_AP_NS_MAILBOX_SERVICE_LAST = 0x38,
+ CPM_AP_NS_SSRAM_SERVICE = 0x66,
+ CPM_AP_NS_SPMI_SERVICE = 0x67,
+ CPM_AP_NS_POWER_DASH_MB_SERVICE = 0x68,
+ CPM_AP_NS_ODPM_MB_SERVICE = 0x69,
+ CPM_AP_NS_IRQ_SERVICE = 0x6E,
+ /* Control latency library CPM functions */
+ CPM_AP_NS_LTC_MB_SERVICE = 0x70,
+ CPM_AP_NS_MAILBOX_SERVICE_FIRST = 0x70,
+};
+
+#endif /* _SOC_GOOGLE_CPM_SERVICE_IDS_H */
diff --git a/include/soc/google/google-cpm-mba.h b/include/soc/google/google-cpm-mba.h
new file mode 100644
index 000000000000..ce46e6f6b6b8
--- /dev/null
+++ b/include/soc/google/google-cpm-mba.h
@@ -0,0 +1,168 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#ifndef _GOOGLE_CPM_MBA_H_
+#define _GOOGLE_CPM_MBA_H_
+
+#include <linux/types.h>
+
+struct cpm_handle;
+struct device;
+
+/**
+ * enum cpm_msg_type - Specifies the type of message for CPM interface transactions
+ * @ONEWAY_MSG: A one-way message that does not expect a response. The @resp_msg
+ * field in &struct cpm_request is ignored.
+ * @REQUEST_MSG: A request message that expects a response.
+ */
+enum cpm_msg_type {
+ ONEWAY_MSG,
+ REQUEST_MSG,
+};
+
+#define GOOG_MBA_PAYLOAD_SIZE 3
+
+/**
+ * struct cpm_payload - Represents a payload for CPM messages
+ * @header: A header containing message metadata (e.g., type, destination).
+ * Client shouldn't fill the header.
+ * @payload: An array of 32-bit words representing the actual payload data.
+ */
+struct cpm_payload {
+ u32 header;
+ u32 payload[GOOG_MBA_PAYLOAD_SIZE];
+};
+
+/**
+ * struct cpm_request - Represents a request within the CPM interface
+ * @msg_type: Specifies the message type (see &enum cpm_msg_type).
+ * @req_msg: The request message payload.
+ * @resp_msg: Buffer to receive a response (effective when @msg_type is REQUEST_MSG).
+ * @src_id: Source service ID of the AP caller; typically optional, for use
+ * when RX callbacks may be needed.
+ * @dst_id: Destination service ID within the CPM host.
+ * @tout_ms: Request timeout in milliseconds (0 indicates no timeout).
+ */
+struct cpm_request {
+ enum cpm_msg_type msg_type;
+ struct cpm_payload *req_msg;
+ struct cpm_payload *resp_msg;
+ u8 src_id;
+ u8 dst_id;
+ unsigned long tout_ms;
+};
+
+/**
+ * typedef cpm_rx_cb_t - Callback invoked for CPM-initiated messages
+ * @msg: Pointer to the message payload received from the CPM host.
+ * @priv: Consumer private data registered via devm_cpm_register_rx_callback().
+ *
+ * Callbacks may be called in an atomic context.
+ */
+typedef void (*cpm_rx_cb_t)(const struct cpm_payload *msg, void *priv);
+
+/**
+ * devm_cpm_get_handle() - Acquire a managed handle to the parent CPM device
+ * @dev: Consumer device structure (must be a child of the CPM device).
+ *
+ * Return: A &struct cpm_handle pointer on success, or an ERR_PTR() on failure.
+ */
+struct cpm_handle *devm_cpm_get_handle(struct device *dev);
+
+/**
+ * devm_cpm_register_rx_callback() - Register a managed callback for CPM-initiated messages
+ * @dev: Consumer device that owns the callback registration lifetime.
+ * @handle: CPM handle obtained from devm_cpm_get_handle().
+ * @src_id: Consumer service ID (1 to 255) matched against incoming message
+ * destination IDs.
+ * @cb: Callback function invoked when CPM sends a message to @src_id.
+ * @priv: Consumer private data passed to @cb (optional).
+ *
+ * Return: 0 on success, or a negative errno on failure.
+ */
+int devm_cpm_register_rx_callback(struct device *dev,
+ struct cpm_handle *handle, u8 src_id,
+ cpm_rx_cb_t cb, void *priv);
+
+/**
+ * cpm_send_message() - Send a payload to CPM host
+ * @handle: CPM handle obtained from devm_cpm_get_handle().
+ * @cpm_req: Request structure containing message parameters.
+ *
+ * This function enables consumers to transmit messages to the CPM host:
+ *
+ * * **One-way Messages:** Returns after TX done or timeout.
+ * * **Request Messages:** Returns after receiving a response or timeout.
+ *
+ * Important Notes:
+ * * The first word of the request payload is used by the transport layer.
+ * * For request messages, the `resp_msg` field will hold the CPM host's response.
+ * * Do not call this function from atomic contexts due to potential blocking.
+ *
+ * Return: 0 on success; negative error code on failure.
+ */
+int cpm_send_message(struct cpm_handle *handle, struct cpm_request *cpm_req);
+
+#define LPCM_CMD_SET_GEN_PD 0x1
+#define LPCM_CMD_SET_LCM_CLK 0x2
+#define LPCM_CMD_SET_RST 0x4
+
+/**
+ * struct cpm_lpcm_message - Message descriptor for the CPM LPCM service
+ * @cmd: LPCM command ID (e.g., %LPCM_CMD_SET_GEN_PD, %LPCM_CMD_SET_LCM_CLK,
+ * %LPCM_CMD_SET_RST).
+ * @opcode: Command-specific operation ID.
+ * @lpcm_id: Target LPCM domain ID.
+ * @obj_id: Target object ID within the LPCM domain (e.g., subdomain, clock, or
+ * reset ID).
+ * @payload: Command parameter word (0 if unused).
+ */
+struct cpm_lpcm_message {
+ u8 cmd;
+ u8 opcode;
+ u8 lpcm_id;
+ u8 obj_id;
+ u32 payload;
+};
+
+/**
+ * cpm_send_lpcm_message() - Send a command to the CPM LPCM service
+ * @handle: CPM handle obtained from devm_cpm_get_handle().
+ * @msg: LPCM message descriptor.
+ *
+ * Return: Non-negative response value from CPM on success; negative errno on
+ * transport or remote LPCM error.
+ */
+int cpm_send_lpcm_message(struct cpm_handle *handle,
+ const struct cpm_lpcm_message *msg);
+
+#define LPB_CMD_SSWRP_STATE_SET 0x2
+#define LPB_CMD_SSWRP_STATE_GET 0x3
+
+/**
+ * struct cpm_lpb_message - Message descriptor for the CPM LPB service
+ * @cmd: LPB command ID (e.g., %LPB_CMD_SSWRP_STATE_SET,
+ * %LPB_CMD_SSWRP_STATE_GET).
+ * @sswrp_id: Target LPB SSWRP ID.
+ * @data: Command parameter word (0 if unused).
+ */
+struct cpm_lpb_message {
+ u32 cmd;
+ u32 sswrp_id;
+ u32 data;
+};
+
+/**
+ * cpm_send_lpb_message() - Send a command to the CPM LPB service
+ * @handle: CPM handle obtained from devm_cpm_get_handle().
+ * @msg: LPB message descriptor.
+ *
+ * Return: Non-negative command status/state word from CPM on success;
+ * negative errno on transport or remote LPB protocol error.
+ */
+int cpm_send_lpb_message(struct cpm_handle *handle,
+ const struct cpm_lpb_message *msg);
+
+#endif /* _GOOGLE_CPM_MBA_H_ */
diff --git a/include/soc/google/lga-lpcm-ids.h b/include/soc/google/lga-lpcm-ids.h
new file mode 100644
index 000000000000..27b8c6cb8e77
--- /dev/null
+++ b/include/soc/google/lga-lpcm-ids.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef _SOC_GOOGLE_LGA_LPCM_IDS_H
+#define _SOC_GOOGLE_LGA_LPCM_IDS_H
+
+/*
+ * LPCM IDs of each SSWRP.
+ */
+#define LPCM_CPM 0
+#define LPCM_AOC 1
+#define LPCM_LSIO_E 2
+#define LPCM_LSIO_N 3
+#define LPCM_LSIO_S 4
+#define LPCM_HSIO_N 5
+#define LPCM_HSIO_S 6
+#define LPCM_GPCA 7
+#define LPCM_FABHBW 8
+#define LPCM_MEMSS 9
+#define LPCM_FABMED 10
+#define LPCM_FABRT 11
+#define LPCM_FABSTBY 12
+#define LPCM_FABSYSS 13
+#define LPCM_CPU 14
+#define LPCM_CPU_MAIN 15
+#define LPCM_CPU_CCM0 16
+#define LPCM_CPU_CCM1A 17
+#define LPCM_CPU_CCM1B 18
+#define LPCM_CPU_CCM2 19
+#define LPCM_EH 20
+#define LPCM_AURORA 21
+#define LPCM_CODEC_3P 22
+#define LPCM_G2D 23
+#define LPCM_GSW 24
+#define LPCM_ISPBE 25
+#define LPCM_ISPFE 26
+#define LPCM_INF_TCU 27
+#define LPCM_GPU 28
+#define LPCM_GPU_REMOTE_FLL 29
+#define LPCM_GPU_REMOTE_SENSOR 30
+#define LPCM_TPU 31
+#define LPCM_TPU_REMOTE 32
+#define LPCM_BMSM 33
+#define LPCM_CPUACC 34
+#define LPCM_DPU 35
+#define LPCM_GDMC 36
+#define LPCM_GMC0 37
+#define LPCM_GMC1 38
+#define LPCM_GMC2 39
+#define LPCM_GMC3 40
+#define LPCM_GPCM 41
+#define LPCM_GPDMA 42
+#define LPCM_GSA 43
+
+#endif /* _SOC_GOOGLE_LGA_LPCM_IDS_H */
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 3/9] pmdomain: google: Add CPM power-domain driver
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
2026-11-25 0:03 ` [PATCH v2 1/9] dt-bindings: power: google: Add Google Tensor CPM Brian Norris
2026-11-25 0:03 ` [PATCH v2 2/9] soc: google: Add CPM over MailBox Array driver Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 4/9] clk: google: Add CPM clock driver Brian Norris
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
The Central Power Manager (CPM) is a co-processor on the Google Tensor
SoCs, as used on Pixel phones. Among other features, CPM manages most of
the power domains on these SoCs. We talk to the CPM over a pair of
mailboxes, and we hide many of these details beneath a
cpm_send_message() API.
Tensor SoCs consist of various regions called Subsystem Wrappers
(SSWRP). SSWRPs and their sub-domains can be powered on and off by
interfacing with the Local Power and Clock Manager (LPCM) associated
with each SSWRP. Thus, the power-domain mapping tends to consist of a
"LPCM ID" (the SSWRP) and a "subdomain ID", although the mappings are
complicated enough we simply expose a single "power domain ID" in the
device tree binding, and figure out the rest of the details by per-SoC
tables.
Most of the complexity in this driver is in the hardware tables, and the
mappings between domains.
Because it may be useful both for reviewers familiar with the downstream
Linux support for these devices, or for future developers looking at
adapting/improving/adding further features later on, it's worth noting
some major deviations from the downstream drivers:
* Use auxiliary_bus. The whole CPM-interface structure was reworked for
upstream Linux, so rather than a bunch of DT nodes and platform
devices, most/all CPM services are simply instantiated as auxiliary
devices from the CPM driver, and share the same CPM DT node.
* As a corollary to the DT restructuring: we eliminate the use of
per-domain DT nodes. Downstream DTs would describe each power domain
as its own node (with #power-domain-cells = <0>), and a variety of
custom DT properties ("irq-safe", "always-on"). These are all encoded
in the driver's per-SoC tables instead, and devices simply use a
single cell (power domain ID) to refer to which domain they use.
* Use devm more heavily
* Drop 'no-auto-resume' feature. This was a Pixel optimization to avoid
excessive power-on latency during system resume. It required unsound
overrides to basic genpd functionality. I assume it should be
replaced by more aggressive use of direct-complete eventually.
* Drop CPM_LGA_LSIO_S_CLI_GPIO_IRQ_SAFE_ID,
CPM_LGA_LSIO_N_CLI_GPIO_IRQ_SAFE_ID, and
CPM_LGA_LSIO_E_CLI_GPIO_IRQ_SAFE_ID. They were not actually used
downstream.
* Drop debugfs test helpers
* Replace a downstream "GENPD_FLAG_ALWAYS_ON" (but only during system
suspend) feature with simply applying GENPD_FLAG_ACTIVE_WAKEUP to the
SSWRP_AOC domain. This domain is for an "Always On Compute" subsystem
on the SoC, but it also can be powered off temporarily for reset or
similar. Any drivers for this component should simply manage its
wakeup status properly, to ensure it stays "on" in the appropriate
system suspend states.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v2:
* Move pmdomain per-SoC info from .h to .c file
* Remove custom pmdomain debugfs 'state' (get/set on/off) file
* Restructure pmdomain SoC tables for simplicity and readability
* adapt to cpm_* interface changes (devm_cpm_register_rx_callback(),
...)
drivers/pmdomain/Kconfig | 1 +
drivers/pmdomain/Makefile | 1 +
drivers/pmdomain/google/Kconfig | 14 +
drivers/pmdomain/google/Makefile | 3 +
drivers/pmdomain/google/cpm-power-lga.c | 365 +++++++++++++++++
drivers/pmdomain/google/cpm-power-trace.h | 80 ++++
drivers/pmdomain/google/cpm-power.c | 458 ++++++++++++++++++++++
drivers/pmdomain/google/cpm-power.h | 42 ++
8 files changed, 964 insertions(+)
create mode 100644 drivers/pmdomain/google/Kconfig
create mode 100644 drivers/pmdomain/google/Makefile
create mode 100644 drivers/pmdomain/google/cpm-power-lga.c
create mode 100644 drivers/pmdomain/google/cpm-power-trace.h
create mode 100644 drivers/pmdomain/google/cpm-power.c
create mode 100644 drivers/pmdomain/google/cpm-power.h
diff --git a/drivers/pmdomain/Kconfig b/drivers/pmdomain/Kconfig
index 5341dff669be..aeda621411df 100644
--- a/drivers/pmdomain/Kconfig
+++ b/drivers/pmdomain/Kconfig
@@ -6,6 +6,7 @@ source "drivers/pmdomain/amlogic/Kconfig"
source "drivers/pmdomain/apple/Kconfig"
source "drivers/pmdomain/arm/Kconfig"
source "drivers/pmdomain/bcm/Kconfig"
+source "drivers/pmdomain/google/Kconfig"
source "drivers/pmdomain/imx/Kconfig"
source "drivers/pmdomain/marvell/Kconfig"
source "drivers/pmdomain/mediatek/Kconfig"
diff --git a/drivers/pmdomain/Makefile b/drivers/pmdomain/Makefile
index d7aee13ae571..608555ba5990 100644
--- a/drivers/pmdomain/Makefile
+++ b/drivers/pmdomain/Makefile
@@ -4,6 +4,7 @@ obj-y += amlogic/
obj-y += apple/
obj-y += arm/
obj-y += bcm/
+obj-y += google/
obj-y += imx/
obj-y += marvell/
obj-y += mediatek/
diff --git a/drivers/pmdomain/google/Kconfig b/drivers/pmdomain/google/Kconfig
new file mode 100644
index 000000000000..e2a9bf0a7c82
--- /dev/null
+++ b/drivers/pmdomain/google/Kconfig
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config GOOGLE_CPM_POWER
+ tristate "Google Tensor CPM power controller driver"
+ depends on ARCH_GOOGLE || COMPILE_TEST
+ depends on GOOGLE_CPM_MBA
+ select PM_GENERIC_DOMAINS
+ default ARCH_GOOGLE
+ help
+ This driver allows clients to power on/off power domains on Google
+ Tensor SoCs via the generic power domain framework. It uses SMC or
+ CPM mailbox array to request toggling the power domains.
+
+ Say Y or M here to support CPM power domains.
diff --git a/drivers/pmdomain/google/Makefile b/drivers/pmdomain/google/Makefile
new file mode 100644
index 000000000000..5e6a0530122d
--- /dev/null
+++ b/drivers/pmdomain/google/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_GOOGLE_CPM_POWER) += google-cpm-power.o
+google-cpm-power-y := cpm-power.o cpm-power-lga.o
diff --git a/drivers/pmdomain/google/cpm-power-lga.c b/drivers/pmdomain/google/cpm-power-lga.c
new file mode 100644
index 000000000000..7aff28ec1685
--- /dev/null
+++ b/drivers/pmdomain/google/cpm-power-lga.c
@@ -0,0 +1,365 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#include <dt-bindings/power/google,lga-cpm.h>
+#include <linux/array_size.h>
+#include <linux/pm_domain.h>
+
+#include "cpm-power.h"
+
+/* SSWRP IDs for the LPB service */
+enum lpb_sswrp_id {
+ LPB_ID_AOC,
+ LPB_ID_AURORA,
+ LPB_ID_CODEC_3P,
+ LPB_ID_CPU,
+ LPB_ID_CPUACC,
+ LPB_ID_DPU,
+ LPB_ID_EH,
+ LPB_ID_FABHBW,
+ LPB_ID_FABMED,
+ LPB_ID_FABRT,
+ LPB_ID_FABSTBY,
+ LPB_ID_FABSYSS,
+ LPB_ID_G2D,
+ LPB_ID_GMC0,
+ LPB_ID_GMC1,
+ LPB_ID_GMC2,
+ LPB_ID_GMC3,
+ LPB_ID_GPCA,
+ LPB_ID_GPCM,
+ LPB_ID_GPDMA,
+ LPB_ID_GPU,
+ LPB_ID_GSA,
+ LPB_ID_GSW,
+ LPB_ID_HSIO_N,
+ LPB_ID_HSIO_S,
+ LPB_ID_INF_TCU,
+ LPB_ID_ISPBE,
+ LPB_ID_ISPFE,
+ LPB_ID_LSIO_E,
+ LPB_ID_LSIO_N,
+ LPB_ID_LSIO_S,
+ LPB_ID_MEMSS,
+ LPB_ID_TPU,
+};
+
+/* Subdomain IDs */
+/* HSIO_N */
+#define SUB_HSIO_N_USB 0
+#define SUB_HSIO_N_PCIE 1
+#define SUB_HSIO_N_EBU 2
+#define SUB_HSIO_N_EBU_CORE 3
+#define SUB_HSIO_N_DP 4
+#define SUB_HSIO_N_USB_PSW 5
+
+/* HSIO_S */
+#define SUB_HSIO_S_UFS 0
+#define SUB_HSIO_S_PCIE 1
+#define SUB_HSIO_S_SD 2
+#define SUB_HSIO_S_UFS_PREP 3
+
+/* LSIO_{E,S,N} */
+#define SUB_LSIO_CLI_GPIO 0
+
+/* DPU */
+#define SUB_DPU_FE0 0
+#define SUB_DPU_FE1 1
+#define SUB_DPU_DSI0 2
+#define SUB_DPU_DSI1 3
+#define SUB_DPU_DP 4
+
+/* ISPFE */
+#define SUB_ISPFE_TOP 0
+#define SUB_ISPFE_PIPE 1
+#define SUB_ISPFE_CSIS 2
+
+/* G2D */
+#define SUB_G2D_CORE 0
+
+/* AOC */
+#define SUB_AOC_CORE 0
+
+#define LPCM_GENPD_SSWRP_DPU 0
+#define LPCM_GENPD_SSWRP_HSIO_S 1
+#define LPCM_GENPD_SSWRP_HSIO_N 2
+#define LPCM_GENPD_SSWRP_LSIO_S 3
+#define LPCM_GENPD_SSWRP_LSIO_N 4
+#define LPCM_GENPD_SSWRP_LSIO_E 5
+#define LPCM_GENPD_SSWRP_G2D 6
+#define LPCM_GENPD_SSWRP_GPDMA 7
+#define LPCM_GENPD_SSWRP_ISPFE 8
+#define LPCM_GENPD_SSWRP_AOC 9
+
+static const struct cpm_power_domain_desc lga_pm_domains[] = {
+ [PD_SSWRP_AOC] = {
+ .name = "sswrp-aoc-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_AOC,
+ .flags = GENPD_FLAG_ACTIVE_WAKEUP,
+ .on_at_init = true,
+ },
+ [PD_AOC_CORE] = {
+ .name = "aoc-core-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_AOC,
+ .subdomain_id = SUB_AOC_CORE,
+ .on_at_init = true,
+ .parent_id = PD_SSWRP_AOC,
+ },
+ [PD_SSWRP_AURORA] = {
+ .name = "sswrp-aurora-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_AURORA,
+ },
+ [PD_SSWRP_CODEC_3P] = {
+ .name = "sswrp-codec-3p-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_CODEC_3P,
+ },
+ [PD_DPU_DP] = {
+ .name = "dpu-dp-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_DPU,
+ .subdomain_id = SUB_DPU_DP,
+ .parent_id = PD_SSWRP_DPU,
+ },
+ [PD_SSWRP_DPU] = {
+ .name = "sswrp-dpu-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_DPU,
+ },
+ [PD_DPU_FE0] = {
+ .name = "dpu-fe0-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_DPU,
+ .subdomain_id = SUB_DPU_FE0,
+ .parent_id = PD_DPU_DSI0,
+ },
+ [PD_DPU_FE1] = {
+ .name = "dpu-fe1-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_DPU,
+ .subdomain_id = SUB_DPU_FE1,
+ .parent_id = PD_DPU_FE0,
+ },
+ [PD_DPU_DSI0] = {
+ .name = "dpu-dsi0-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_DPU,
+ .subdomain_id = SUB_DPU_DSI0,
+ .parent_id = PD_SSWRP_DPU,
+ },
+ [PD_DPU_DSI1] = {
+ .name = "dpu-dsi1-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_DPU,
+ .subdomain_id = SUB_DPU_DSI1,
+ .parent_id = PD_SSWRP_DPU,
+ },
+ [PD_SSWRP_EH] = {
+ .name = "sswrp-eh-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_EH,
+ },
+ [PD_SSWRP_G2D] = {
+ .name = "sswrp-g2d-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_G2D,
+ },
+ [PD_G2D_CORE] = {
+ .name = "g2d-core-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_G2D,
+ .subdomain_id = SUB_G2D_CORE,
+ .parent_id = PD_SSWRP_G2D,
+ },
+ [PD_SSWRP_GPDMA] = {
+ .name = "sswrp-gpdma-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_GPDMA,
+ .on_at_init = true,
+ },
+ [PD_SSWRP_GPU] = {
+ .name = "sswrp-gpu-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_GPU,
+ },
+ [PD_SSWRP_GSW] = {
+ .name = "sswrp-gsw-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_GSW,
+ },
+ [PD_SSWRP_HSIO_N] = {
+ .name = "sswrp-hsio-n-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_HSIO_N,
+ .on_at_init = true,
+ },
+ [PD_HSIO_N_USB] = {
+ .name = "hsio-n-usb-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_N,
+ .subdomain_id = SUB_HSIO_N_USB,
+ .flags = GENPD_FLAG_ACTIVE_WAKEUP,
+ .on_at_init = true,
+ .parent_id = PD_SSWRP_HSIO_N,
+ },
+ [PD_HSIO_N_USB_PSW] = {
+ .name = "hsio-n-usb-psw-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_N,
+ .subdomain_id = SUB_HSIO_N_USB_PSW,
+ .flags = GENPD_FLAG_ACTIVE_WAKEUP,
+ .on_at_init = true,
+ .parent_id = PD_HSIO_N_USB,
+ },
+ [PD_HSIO_N_PCIE] = {
+ .name = "hsio-n-pcie-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_N,
+ .subdomain_id = SUB_HSIO_N_PCIE,
+ .flags = GENPD_FLAG_ACTIVE_WAKEUP,
+ .parent_id = PD_SSWRP_HSIO_N,
+ },
+ [PD_HSIO_N_DP] = {
+ .name = "hsio-n-dp-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_N,
+ .subdomain_id = SUB_HSIO_N_DP,
+ .parent_id = PD_HSIO_N_USB_PSW,
+ },
+ [PD_HSIO_N_EBU] = {
+ .name = "hsio-n-ebu-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_N,
+ .subdomain_id = SUB_HSIO_N_EBU,
+ .parent_id = PD_HSIO_N_USB,
+ },
+ [PD_HSIO_N_EBU_CORE] = {
+ .name = "hsio-n-ebu-core-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_N,
+ .subdomain_id = SUB_HSIO_N_EBU_CORE,
+ .parent_id = PD_HSIO_N_EBU,
+ },
+ [PD_SSWRP_HSIO_S] = {
+ .name = "sswrp-hsio-s-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_HSIO_S,
+ .flags = GENPD_FLAG_RPM_ALWAYS_ON,
+ .on_at_init = true,
+ },
+ [PD_HSIO_S_UFS_PREP] = {
+ .name = "hsio-s-ufs-prep-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_S,
+ .subdomain_id = SUB_HSIO_S_UFS_PREP,
+ .on_at_init = true,
+ .parent_id = PD_SSWRP_HSIO_S,
+ },
+ [PD_HSIO_S_UFS] = {
+ .name = "hsio-s-ufs-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_S,
+ .subdomain_id = SUB_HSIO_S_UFS,
+ .flags = GENPD_FLAG_RPM_ALWAYS_ON,
+ .on_at_init = true,
+ .parent_id = PD_HSIO_S_UFS_PREP,
+ },
+ [PD_HSIO_S_PCIE] = {
+ .name = "hsio-s-pcie-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_S,
+ .subdomain_id = SUB_HSIO_S_PCIE,
+ .parent_id = PD_SSWRP_HSIO_S,
+ },
+ [PD_HSIO_S_SD] = {
+ .name = "hsio-s-sd-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_HSIO_S,
+ .subdomain_id = SUB_HSIO_S_SD,
+ .parent_id = PD_HSIO_S_UFS,
+ },
+ [PD_SSWRP_ISPBE] = {
+ .name = "sswrp-ispbe-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_ISPBE,
+ },
+ [PD_SSWRP_ISPFE] = {
+ .name = "sswrp-ispfe-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_ISPFE,
+ },
+ [PD_ISPFE_PIPE] = {
+ .name = "ispfe-pipe-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_ISPFE,
+ .subdomain_id = SUB_ISPFE_PIPE,
+ .parent_id = PD_SSWRP_ISPFE,
+ },
+ [PD_ISPFE_CSIS] = {
+ .name = "ispfe-csis-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_ISPFE,
+ .subdomain_id = SUB_ISPFE_CSIS,
+ .parent_id = PD_SSWRP_ISPFE,
+ },
+ [PD_SSWRP_LSIO_E] = {
+ .name = "sswrp-lsio-e-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_LSIO_E,
+ .flags = GENPD_FLAG_RPM_ALWAYS_ON,
+ .on_at_init = true,
+ },
+ [PD_LSIO_E_CLI_GPIO] = {
+ .name = "lsio-e-cli-gpio-pd",
+ .type = CPM_PD_SMC,
+ .smc_id = LPB_ID_LSIO_E,
+ .subdomain_id = SUB_LSIO_CLI_GPIO,
+ .flags = GENPD_FLAG_RPM_ALWAYS_ON,
+ .on_at_init = true,
+ .parent_id = PD_SSWRP_LSIO_E,
+ },
+ [PD_SSWRP_LSIO_N] = {
+ .name = "sswrp-lsio-n-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_LSIO_N,
+ .on_at_init = true,
+ },
+ [PD_LSIO_N_CLI_GPIO] = {
+ .name = "lsio-n-cli-gpio-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_LSIO_N,
+ .subdomain_id = SUB_LSIO_CLI_GPIO,
+ .on_at_init = true,
+ .parent_id = PD_SSWRP_LSIO_N,
+ },
+ [PD_SSWRP_LSIO_S] = {
+ .name = "sswrp-lsio-s-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_LSIO_S,
+ .on_at_init = true,
+ },
+ [PD_LSIO_S_CLI_GPIO] = {
+ .name = "lsio-s-cli-gpio-pd",
+ .type = CPM_PD_LPCM,
+ .lpcm_id = LPCM_GENPD_SSWRP_LSIO_S,
+ .subdomain_id = SUB_LSIO_CLI_GPIO,
+ .on_at_init = true,
+ .parent_id = PD_SSWRP_LSIO_S,
+ },
+ [PD_SSWRP_TPU] = {
+ .name = "sswrp-tpu-pd",
+ .type = CPM_PD_LPB,
+ .lpb_id = LPB_ID_TPU,
+ .flags = GENPD_FLAG_ACTIVE_WAKEUP,
+ },
+};
+
+const struct cpm_power_desc lga_cpm_power_desc = {
+ .domains = lga_pm_domains,
+ .num_domains = ARRAY_SIZE(lga_pm_domains),
+};
diff --git a/drivers/pmdomain/google/cpm-power-trace.h b/drivers/pmdomain/google/cpm-power-trace.h
new file mode 100644
index 000000000000..0c5e3c47b304
--- /dev/null
+++ b/drivers/pmdomain/google/cpm-power-trace.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM cpm_power
+
+#if !defined(_TRACE_CPM_POWER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_CPM_POWER_TRACE_H
+
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(cpm_power_send_mail_events,
+ TP_PROTO(struct cpm_power_domain *pd, bool on),
+ TP_ARGS(pd, on),
+ TP_STRUCT__entry(
+ __string(name, pd->name)
+ __field(unsigned char, sswrp_id)
+ __field(unsigned char, subdomain_id)
+ __field(bool, on)
+ ),
+ TP_fast_assign(
+ __assign_str(name);
+ __entry->sswrp_id = (pd->type == CPM_PD_LPB) ? pd->lpb_id : pd->lpcm_id;
+ __entry->subdomain_id = pd->subdomain_id;
+ __entry->on = on;
+ ),
+ TP_printk("\t%#04x.%02x:%s\ten:%d",
+ __entry->sswrp_id, __entry->subdomain_id,
+ __get_str(name), __entry->on)
+);
+DEFINE_EVENT(cpm_power_send_mail_events, send_mail_lpb,
+ TP_PROTO(struct cpm_power_domain *pd, bool on),
+ TP_ARGS(pd, on)
+);
+DEFINE_EVENT(cpm_power_send_mail_events, send_mail_lpcm,
+ TP_PROTO(struct cpm_power_domain *pd, bool on),
+ TP_ARGS(pd, on)
+);
+
+DECLARE_EVENT_CLASS(cpm_power_mail_result_events,
+ TP_PROTO(struct cpm_power_domain *pd, bool on, int result),
+ TP_ARGS(pd, on, result),
+ TP_STRUCT__entry(
+ __string(name, pd->name)
+ __field(unsigned char, sswrp_id)
+ __field(unsigned char, subdomain_id)
+ __field(bool, on)
+ __field(int, result)
+ ),
+ TP_fast_assign(
+ __assign_str(name);
+ __entry->sswrp_id = (pd->type == CPM_PD_LPB) ? pd->lpb_id : pd->lpcm_id;
+ __entry->subdomain_id = pd->subdomain_id;
+ __entry->on = on;
+ __entry->result = result;
+ ),
+ TP_printk("\t%#04x.%02x:%s\ten:%d (res:%d)",
+ __entry->sswrp_id, __entry->subdomain_id,
+ __get_str(name), __entry->on, __entry->result)
+);
+DEFINE_EVENT(cpm_power_mail_result_events, recv_result_lpb,
+ TP_PROTO(struct cpm_power_domain *pd, bool on, int result),
+ TP_ARGS(pd, on, result)
+);
+DEFINE_EVENT(cpm_power_mail_result_events, recv_result_lpcm,
+ TP_PROTO(struct cpm_power_domain *pd, bool on, int result),
+ TP_ARGS(pd, on, result)
+);
+
+#endif /* _TRACE_CPM_POWER_TRACE_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../drivers/pmdomain/google
+
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE cpm-power-trace
+
+#include <trace/define_trace.h>
diff --git a/drivers/pmdomain/google/cpm-power.c b/drivers/pmdomain/google/cpm-power.c
new file mode 100644
index 000000000000..e93013188aa2
--- /dev/null
+++ b/drivers/pmdomain/google/cpm-power.c
@@ -0,0 +1,458 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/atomic.h>
+#include <linux/auxiliary_bus.h>
+#include <linux/bug.h>
+#include <linux/completion.h>
+#include <linux/container_of.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gfp_types.h>
+#include <linux/jiffies.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/pm_domain.h>
+#include <linux/string_choices.h>
+#include <linux/types.h>
+#include <soc/google/cpm-service-ids.h>
+#include <soc/google/google-cpm-mba.h>
+
+#include "cpm-power.h"
+
+struct cpm_power_controller;
+
+struct cpm_power_domain {
+ struct cpm_power_controller *controller;
+ struct generic_pm_domain genpd;
+ const char *name;
+ enum cpm_pd_type type;
+ int id;
+ /* Firmware SSWRP ID used by CPM / EL3 depending on @type */
+ union {
+ int lpb_id;
+ int lpcm_id;
+ int smc_id;
+ };
+ int subdomain_id;
+ int parent_id;
+ atomic_t state;
+ struct completion cpm_resp_done;
+};
+
+struct cpm_power_controller {
+ struct device *dev;
+ struct cpm_handle *cpm;
+ struct cpm_power_domain *pds;
+ u32 pd_count;
+ struct genpd_onecell_data pd_data;
+};
+
+#define CREATE_TRACE_POINTS
+#include "cpm-power-trace.h"
+
+#define SIP_SVC_PD_CONTROL 0x82000701
+
+#define CPM_MBX_RECV_TIMEOUT_MS 3000
+
+/*
+ * LPB service command response status codes.
+ */
+enum lpb_service_cmd_status {
+ LPB_SERVICE_CMD_SUCCESS = 0xf,
+ LPB_SERVICE_CMD_FAIL,
+ LPB_SERVICE_PWRDN_STARTED,
+ LPB_SERVICE_PWRUP_STARTED,
+ LPB_SERVICE_NO_EFFECT,
+};
+
+static inline struct cpm_power_domain *to_power_domain(struct generic_pm_domain *d)
+{
+ return container_of(d, struct cpm_power_domain, genpd);
+}
+
+/*
+ * This callback is triggered when CPM signals the transition has finished.
+ */
+static void cpm_power_rx_callback(const struct cpm_payload *msg, void *priv)
+{
+ struct cpm_power_controller *pc = priv;
+ struct device *dev = pc->dev;
+ struct cpm_power_domain *pd = NULL;
+ u32 resource_sid = msg->payload[0];
+ int i;
+
+ dev_dbg(dev, "rx callback msg %d %d %d\n", msg->payload[0],
+ msg->payload[1], msg->payload[2]);
+
+ for (i = 0; i < pc->pd_count; i++) {
+ /* For MBA/LPB service */
+ if (pc->pds[i].type == CPM_PD_LPB &&
+ pc->pds[i].lpb_id == resource_sid) {
+ pd = &pc->pds[i];
+ break;
+ }
+ }
+ if (!pd) {
+ dev_err(dev, "cannot find corresponding power domain for ID: %d\n",
+ resource_sid);
+ return;
+ }
+
+ dev_dbg(dev, "%s: power transition completed\n", pd->name);
+ complete(&pd->cpm_resp_done);
+}
+
+static int send_lpb_request(struct cpm_power_domain *pd, bool on)
+{
+ struct device *dev = pd->controller->dev;
+ const struct cpm_lpb_message msg = {
+ .cmd = LPB_CMD_SSWRP_STATE_SET,
+ .sswrp_id = pd->lpb_id,
+ .data = on,
+ };
+ int ret;
+
+ dev_dbg(dev, "%s: power %s: sswrp_id = %d\n", pd->name, str_on_off(on),
+ pd->lpb_id);
+
+ reinit_completion(&pd->cpm_resp_done);
+
+ trace_send_mail_lpb(pd, on);
+ ret = cpm_send_lpb_message(pd->controller->cpm, &msg);
+ if (ret < 0)
+ return ret;
+
+ switch (ret) {
+ case LPB_SERVICE_CMD_SUCCESS:
+ /* Command requires no asynchronous processing -- we are done */
+ ret = 0;
+ break;
+ case LPB_SERVICE_PWRUP_STARTED:
+ case LPB_SERVICE_PWRDN_STARTED:
+ /*
+ * We have received the first response for power on/off. The
+ * final result will be received asynchronously.
+ */
+ if (!wait_for_completion_timeout(&pd->cpm_resp_done,
+ msecs_to_jiffies(CPM_MBX_RECV_TIMEOUT_MS))) {
+ dev_err(dev, "%s: power %s: wait for CPM response timeout\n",
+ pd->name, str_on_off(on));
+ ret = -ETIMEDOUT;
+ break;
+ }
+ ret = 0;
+ break;
+ case LPB_SERVICE_CMD_FAIL:
+ default:
+ /* Command got through but the result was failure */
+ dev_err(dev, "%s: power %s: CPM LPB services returned fail, err=%d\n",
+ pd->name, str_on_off(on), ret);
+ ret = -EPROTO;
+ break;
+ }
+
+ trace_recv_result_lpb(pd, on, ret);
+
+ return ret;
+}
+
+static int send_lpcm_request(struct cpm_power_domain *pd, bool on)
+{
+ struct device *dev = pd->controller->dev;
+ const struct cpm_lpcm_message msg = {
+ .cmd = LPCM_CMD_SET_GEN_PD,
+ .opcode = on,
+ .lpcm_id = pd->lpcm_id,
+ .obj_id = pd->subdomain_id,
+ };
+ int ret;
+
+ dev_dbg(dev, "%s: power %s: lpcm_id = %d\n", pd->name, str_on_off(on),
+ pd->lpcm_id);
+
+ trace_send_mail_lpcm(pd, on);
+ ret = cpm_send_lpcm_message(pd->controller->cpm, &msg);
+ trace_recv_result_lpcm(pd, on, ret);
+
+ return ret;
+}
+
+static inline int lpcm_smc(struct cpm_power_domain *pd, bool on)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SIP_SVC_PD_CONTROL, pd->smc_id,
+ pd->subdomain_id, on, 0, 0, 0, 0, &res);
+
+ WARN_ON(res.a0);
+ if ((unsigned long)res.a1) {
+ dev_err(pd->controller->dev, "Failed SMC call sswrp:%d sub-domain:%d, res.a1:%lu\n",
+ pd->smc_id, pd->subdomain_id, res.a1);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int cpm_set_power_state(struct generic_pm_domain *domain, bool on)
+{
+ struct cpm_power_domain *pd = to_power_domain(domain);
+ int ret;
+
+ switch (pd->type) {
+ case CPM_PD_LPB:
+ ret = send_lpb_request(pd, on);
+ break;
+ case CPM_PD_LPCM:
+ ret = send_lpcm_request(pd, on);
+ break;
+ case CPM_PD_SMC:
+ ret = lpcm_smc(pd, on);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (!ret)
+ atomic_set(&pd->state, on);
+
+ return ret;
+}
+
+static int cpm_power_on(struct generic_pm_domain *domain)
+{
+ return cpm_set_power_state(domain, true);
+}
+
+static int cpm_power_off(struct generic_pm_domain *domain)
+{
+ return cpm_set_power_state(domain, false);
+}
+
+static int cpm_power_apply_desc(struct cpm_power_domain *pd,
+ const struct cpm_power_domain_desc *domain)
+{
+ struct device *dev = pd->controller->dev;
+
+ if (domain->on_at_init)
+ atomic_set(&pd->state, true);
+
+ pd->genpd.flags |= domain->flags;
+
+ /* If we want it "always on", it must already be on. */
+ if (pd->genpd.flags & GENPD_FLAG_ALWAYS_ON) {
+ if (!atomic_read(&pd->state)) {
+ dev_err(dev, "%s: always-on PM domain is not on\n",
+ pd->name);
+ return -EINVAL;
+ }
+ }
+
+ /* If we want it "RPM always on", it must already be on. */
+ if (pd->genpd.flags & GENPD_FLAG_RPM_ALWAYS_ON) {
+ if (!atomic_read(&pd->state)) {
+ dev_err(dev, "%s: rpm-always-on PM domain is not on\n",
+ pd->name);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static struct cpm_power_domain *cpm_find_pd_by_id(struct cpm_power_controller *pc, int id)
+{
+ if (id >= 0 && id < pc->pd_count)
+ return &pc->pds[id];
+ return NULL;
+}
+
+static void cpm_genpd_remove_action(void *data)
+{
+ struct generic_pm_domain *genpd = data;
+
+ pm_genpd_remove(genpd);
+}
+
+static void cpm_genpd_remove_subdomain_action(void *data)
+{
+ struct cpm_power_domain *pd = data;
+ struct cpm_power_domain *parent_pd = cpm_find_pd_by_id(pd->controller, pd->parent_id);
+
+ pm_genpd_remove_subdomain(&parent_pd->genpd, &pd->genpd);
+}
+
+static const struct of_device_id cpm_power_of_match[] __maybe_unused = {
+ { .compatible = "google,lga-cpm", .data = &lga_cpm_power_desc },
+ {},
+};
+
+static int cpm_power_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id)
+{
+ struct device *dev = &auxdev->dev;
+ struct cpm_power_controller *controller;
+ const struct of_device_id *match;
+ const struct cpm_power_desc *desc;
+ int ret, i, pd_count;
+
+ match = of_match_node(cpm_power_of_match, dev->of_node);
+ if (!match) {
+ dev_err(dev, "unsupported CPM compatible\n");
+ return -ENODEV;
+ }
+ desc = match->data;
+
+ controller = devm_kzalloc(dev, sizeof(*controller), GFP_KERNEL);
+ if (!controller)
+ return -ENOMEM;
+
+ controller->dev = dev;
+
+ auxiliary_set_drvdata(auxdev, controller);
+
+ pd_count = desc->num_domains;
+ controller->pds = devm_kcalloc(dev, pd_count, sizeof(*controller->pds), GFP_KERNEL);
+ if (!controller->pds)
+ return -ENOMEM;
+ controller->pd_count = pd_count;
+
+ controller->pd_data.domains =
+ devm_kcalloc(dev, pd_count, sizeof(*controller->pd_data.domains),
+ GFP_KERNEL);
+ if (!controller->pd_data.domains)
+ return -ENOMEM;
+ controller->pd_data.num_domains = pd_count;
+
+ for (i = 0; i < pd_count; i++) {
+ const struct cpm_power_domain_desc *domain = &desc->domains[i];
+ struct cpm_power_domain *pd = &controller->pds[i];
+
+ pd->type = domain->type;
+ atomic_set(&pd->state, false);
+ pd->name = domain->name;
+ pd->controller = controller;
+ pd->genpd.name = domain->name;
+ pd->genpd.power_on = cpm_power_on;
+ pd->genpd.power_off = cpm_power_off;
+ pd->id = i;
+ pd->subdomain_id = domain->subdomain_id;
+ pd->parent_id = domain->parent_id;
+
+ switch (pd->type) {
+ case CPM_PD_LPB:
+ pd->lpb_id = domain->lpb_id;
+ break;
+ case CPM_PD_LPCM:
+ pd->lpcm_id = domain->lpcm_id;
+ break;
+ case CPM_PD_SMC:
+ pd->smc_id = domain->smc_id;
+ break;
+ default:
+ dev_err(dev, "%s: invalid power domain type %d\n",
+ pd->name, pd->type);
+ return -EINVAL;
+ }
+
+ init_completion(&pd->cpm_resp_done);
+
+ ret = cpm_power_apply_desc(pd, domain);
+ if (ret) {
+ dev_err(dev, "%s: failed to parse attributes\n",
+ pd->name);
+ return ret;
+ }
+ }
+
+ controller->cpm = devm_cpm_get_handle(dev);
+ if (IS_ERR(controller->cpm))
+ return dev_err_probe(dev, PTR_ERR(controller->cpm),
+ "failed to get CPM handle\n");
+
+ ret = devm_cpm_register_rx_callback(dev, controller->cpm,
+ APC_COMMON_SERVICE_ID_POWER_CONTROLLER,
+ cpm_power_rx_callback, controller);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to register CPM RX callback\n");
+
+ /* First, register all domains. */
+ for (i = 0; i < pd_count; i++) {
+ struct cpm_power_domain *pd = &controller->pds[i];
+
+ ret = pm_genpd_init(&pd->genpd, NULL, !atomic_read(&pd->state));
+ if (ret) {
+ dev_err(dev, "%s: failed to init power domain\n",
+ pd->name);
+ return ret;
+ }
+
+ ret = devm_add_action_or_reset(dev, cpm_genpd_remove_action, &pd->genpd);
+ if (ret)
+ return ret;
+
+ controller->pd_data.domains[i] = &pd->genpd;
+ }
+
+ /* Next, link subdomains to their parents. */
+ for (i = 0; i < pd_count; i++) {
+ struct cpm_power_domain *pd = &controller->pds[i];
+ struct cpm_power_domain *parent_pd;
+
+ /* LPB is only used for top-level domains. */
+ if (pd->type == CPM_PD_LPB)
+ continue;
+
+ parent_pd = cpm_find_pd_by_id(controller, pd->parent_id);
+ if (!parent_pd) {
+ dev_err(dev, "failed to find parent for %s\n", pd->name);
+ return -EINVAL;
+ }
+ ret = pm_genpd_add_subdomain(&parent_pd->genpd, &pd->genpd);
+ if (ret) {
+ dev_err(dev, "failed to add subdomain %s to %s: %d\n",
+ pd->name, parent_pd->name, ret);
+ return ret;
+ }
+ ret = devm_add_action_or_reset(dev, cpm_genpd_remove_subdomain_action, pd);
+ if (ret)
+ return ret;
+ }
+
+ ret = of_genpd_add_provider_onecell(dev->of_node, &controller->pd_data);
+ if (ret) {
+ dev_err(dev, "failed to add genpd provider: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void cpm_power_remove(struct auxiliary_device *auxdev)
+{
+ of_genpd_del_provider(auxdev->dev.of_node);
+}
+
+static const struct auxiliary_device_id cpm_power_id_table[] = {
+ { .name = "google_cpm_mba.power-controller" },
+ {},
+};
+MODULE_DEVICE_TABLE(auxiliary, cpm_power_id_table);
+
+static struct auxiliary_driver cpm_power_driver = {
+ .probe = cpm_power_probe,
+ .remove = cpm_power_remove,
+ .name = "cpm-power-controller",
+ .id_table = cpm_power_id_table,
+};
+module_auxiliary_driver(cpm_power_driver);
+
+MODULE_DESCRIPTION("Google Tensor CPM power controller driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/pmdomain/google/cpm-power.h b/drivers/pmdomain/google/cpm-power.h
new file mode 100644
index 000000000000..2453a8c52fc0
--- /dev/null
+++ b/drivers/pmdomain/google/cpm-power.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#ifndef _GOOGLE_CPM_POWER_H
+#define _GOOGLE_CPM_POWER_H
+
+#include <linux/types.h>
+
+enum cpm_pd_type {
+ CPM_PD_LPB = 1,
+ CPM_PD_LPCM,
+ CPM_PD_SMC,
+};
+
+struct cpm_power_domain_desc {
+ const char *name;
+ enum cpm_pd_type type;
+ union {
+ int lpb_id; /* SSWRP ID for LPB service */
+ int lpcm_id; /* SSWRP ID for LPCM service */
+ int smc_id; /* SSWRP ID for SMC */
+ };
+ /* Subdomain ID (ignored for CPM_PD_LPB). */
+ int subdomain_id;
+ /* GENPD_FLAG_* to apply. */
+ u32 flags;
+ /* Signifies that the power domain is already on at boot time. */
+ bool on_at_init;
+ /* Parent domain ID (ignored for CPM_PD_LPB). */
+ int parent_id;
+};
+
+struct cpm_power_desc {
+ const struct cpm_power_domain_desc *domains;
+ size_t num_domains;
+};
+
+extern const struct cpm_power_desc lga_cpm_power_desc;
+
+#endif /* _GOOGLE_CPM_POWER_H */
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 4/9] clk: google: Add CPM clock driver
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
` (2 preceding siblings ...)
2026-11-25 0:03 ` [PATCH v2 3/9] pmdomain: google: Add CPM power-domain driver Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 5/9] reset: google: Add CPM reset driver Brian Norris
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
Google Tensor SoCs (used on Pixel phones) manage many resources
(including most clocks) using a Central Power Manager (CPM)
co-processor. We communicate with CPM using mailboxes, abstracted in the
devm_cpm_get_handle(), etc., API.
== Clock topology ==
The clock topology is not represented by this driver, because
CPM hides most of the divider, mux, and parent details, instead
maintaining its own internal table of mappings for divider and mux
values.
== No .set_rate() ==
Many clocks can report their rate, and the firmware also supports a
SET_RATE operation. However, the firmware protocol does not enumerate
which rates are supported, nor does it actually support the alleged
ROUND_RATE operation found in its API definition. This makes it
difficult to support .set_rate() without memorizing the rate table (as
done in downstream drivers).
Fortunately, we don't need .set_rate() for the vast majority of CPM
clocks, as they only support a single rate. For now, we omit
.set_rate(), and leave configurable clocks for later.
This leaves a few follow-up items:
- Clocks not running at their expected rates: while many clocks
allegedly support only a single rate, some do not appear to
initialize at that rate by default. Such clocks may be utilized at a
lower rate, or else may need additional improvements on the firmware
side. Affected clocks:
CLK_HSIO_N_PHY_FW (USB PHY firmware)
CLK_LSIO_S_MCLK* (I2C camera sensor)
- Configurable clocks: it appears this is only necessary for DP.
== SMC ==
A few clocks are not managed by CPM, but instead utilize an SMC call for
lower latency. We still represent those within this driver, as they are
part of the same clock hierarchy.
== Downstream notes ==
For posterity, I list a summary of changes made relative to the
downstream Pixel driver:
* CPM clients use the auxiliary_bus, instead of individual platform
devices (and DT nodes) with phandles to a pseudo-mailbox
* Instead of device nodes for each clock (and therefore a provider for
each), we use a per-SoC table of clocks, register them all, and have
a single clock-cells==1 provider
* Use devm more heavily
* Drop ACG (auto-clock gating) and QCH (Q-Channel Mode) custom APIs;
these are mostly not expected to be used. We only support the
CLK_GATE feature.
* Add device objects for clocks that need a power domain, and attach
per-LPCM power domains to those clock devices. The downstream driver
had additional device tree properties for "power domains to turn on
during probe", relying on consumers to manage these domains
post-probe. I chose instead to simply attach these domains to the
clocks themselves.
* Drop all rate tables. Do not support .set_rate() for now.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v2:
* Simplify clock driver, to avoid memorizing rate tables and clock
topology that is owned by the remote CPM firmware
* Rename symbols from goog_cpm_clk* to cpm_clk*
* Moved shared protocol details to CPM driver
* Drop all rate/divider tables, and avoid representing clock topology
in driver -- it's owned by the remote firmware
* Don't support .set_rate(); this lacks full support for the DP
clocks, while everything else the kernel just uses as-is.
* Flatten the of_cells to use just 1 cell, and perform the
ID-to-firmware mapping in driver-contained tables
drivers/clk/Kconfig | 1 +
drivers/clk/Makefile | 1 +
drivers/clk/google/Kconfig | 13 +
drivers/clk/google/Makefile | 3 +
drivers/clk/google/clk-cpm-internal.h | 35 +++
drivers/clk/google/clk-cpm-lga.c | 223 +++++++++++++++
drivers/clk/google/clk-cpm-lga.h | 194 +++++++++++++
drivers/clk/google/clk-cpm.c | 385 ++++++++++++++++++++++++++
8 files changed, 855 insertions(+)
create mode 100644 drivers/clk/google/Kconfig
create mode 100644 drivers/clk/google/Makefile
create mode 100644 drivers/clk/google/clk-cpm-internal.h
create mode 100644 drivers/clk/google/clk-cpm-lga.c
create mode 100644 drivers/clk/google/clk-cpm-lga.h
create mode 100644 drivers/clk/google/clk-cpm.c
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 37a8e35d4178..23fa8698c54c 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -517,6 +517,7 @@ source "drivers/clk/bcm/Kconfig"
source "drivers/clk/cix/Kconfig"
source "drivers/clk/davinci/Kconfig"
source "drivers/clk/eswin/Kconfig"
+source "drivers/clk/google/Kconfig"
source "drivers/clk/hisilicon/Kconfig"
source "drivers/clk/imgtec/Kconfig"
source "drivers/clk/imx/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 52d138d4ffc8..0465ae1295b0 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -136,6 +136,7 @@ obj-$(CONFIG_ARCH_BERLIN) += berlin/
obj-y += cix/
obj-$(CONFIG_COMMON_CLK_DAVINCI) += davinci/
obj-$(CONFIG_COMMON_CLK_ESWIN) += eswin/
+obj-y += google/
obj-$(CONFIG_COMMON_CLK_HISI) += hisilicon/
obj-y += imgtec/
obj-y += imx/
diff --git a/drivers/clk/google/Kconfig b/drivers/clk/google/Kconfig
new file mode 100644
index 000000000000..638299829791
--- /dev/null
+++ b/drivers/clk/google/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config GOOGLE_CPM_CLK
+ tristate "Google CPM clock driver"
+ default ARCH_GOOGLE
+ depends on ARCH_GOOGLE || COMPILE_TEST
+ depends on GOOGLE_CPM_MBA
+ help
+ This driver allows clients to configure Google Tensor SoC LPCM clocks
+ via CPM using the common clock framework. This covers clocks that are
+ not supported by PFSM and PSM.
+
+ If unsure, say N.
diff --git a/drivers/clk/google/Makefile b/drivers/clk/google/Makefile
new file mode 100644
index 000000000000..32fdd5885299
--- /dev/null
+++ b/drivers/clk/google/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_GOOGLE_CPM_CLK) += google-clk-cpm.o
+google-clk-cpm-y := clk-cpm.o clk-cpm-lga.o
diff --git a/drivers/clk/google/clk-cpm-internal.h b/drivers/clk/google/clk-cpm-internal.h
new file mode 100644
index 000000000000..e1680df4df7d
--- /dev/null
+++ b/drivers/clk/google/clk-cpm-internal.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2026 Google LLC
+ */
+
+#ifndef _GOOGLE_CLK_CPM_INTERNAL_H
+#define _GOOGLE_CLK_CPM_INTERNAL_H
+
+#include <linux/types.h>
+
+struct cpm_clk_data {
+ /* LPCM ID the clock belongs to */
+ u32 lpcm_id;
+ /* Index of the clock within the given LPCM */
+ u32 clock_id;
+
+ const char *name;
+ bool use_smc;
+};
+
+struct cpm_clk_pd_map {
+ u32 lpcm_id;
+ u32 pd_id;
+};
+
+struct cpm_clk_soc_data {
+ const struct cpm_clk_data *clks;
+ size_t num_clks;
+ const struct cpm_clk_pd_map *pd_map;
+ size_t num_pd_map;
+};
+
+extern const struct cpm_clk_soc_data cpm_clk_lga_data;
+
+#endif /* _GOOGLE_CLK_CPM_INTERNAL_H */
diff --git a/drivers/clk/google/clk-cpm-lga.c b/drivers/clk/google/clk-cpm-lga.c
new file mode 100644
index 000000000000..f5f3ee97504e
--- /dev/null
+++ b/drivers/clk/google/clk-cpm-lga.c
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#include <dt-bindings/clock/google,lga-cpm.h>
+#include <dt-bindings/power/google,lga-cpm.h>
+#include <linux/array_size.h>
+#include <soc/google/lga-lpcm-ids.h>
+
+#include "clk-cpm-internal.h"
+#include "clk-cpm-lga.h"
+
+#define CPM_CLK_LGA(domain, id, n) \
+ [id] = { \
+ .lpcm_id = LPCM_##domain, \
+ .clock_id = LPCM_##id, \
+ .name = n, \
+ }
+
+#define CPM_CLK_LGA_SMC(domain, id, n) \
+ [id] = { \
+ .lpcm_id = LPCM_##domain, \
+ .clock_id = LPCM_##id, \
+ .name = n, \
+ .use_smc = true, \
+ }
+
+static const struct cpm_clk_data cpm_clks_lga[] = {
+ /* CPU */
+ CPM_CLK_LGA(CPU, CLK_CPU_SSWRP_TSS, "cpu-sswrp-tss-clk"),
+
+ /* DPU */
+ CPM_CLK_LGA(DPU, CLK_DPU_DP0_PIX, "dpu-dp0-pix-clk"),
+ CPM_CLK_LGA(DPU, CLK_DPU_DP1_PIX, "dpu-dp1-pix-clk"),
+ CPM_CLK_LGA(DPU, CLK_DPU_DSI0_PIX, "dpu-dsi0-pix-clk"),
+ CPM_CLK_LGA(DPU, CLK_DPU_DSI1_PIX, "dpu-dsi1-pix-clk"),
+ CPM_CLK_LGA(DPU, CLK_DPU_DSI1_PHY, "dpu-dsi1-phy-clk"),
+
+ /* GPCM */
+ CPM_CLK_LGA(GPCM, CLK_GPCM_DPU_PLL_DP, "gpcm-dpu-pll-dp-clk"),
+ CPM_CLK_LGA(GPCM, CLK_GPCM_HSIO_N_PLL_DP, "gpcm-hsio-n-pll-dp-clk"),
+
+ /* HSIO_N */
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USB, "hsio-n-usb-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_DP0, "hsio-n-dp0-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_DP1, "hsio-n-dp1-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_PHY_FW, "hsio-n-phy-fw-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USBDP_SUSPEND, "hsio-n-usbdp-suspend-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USBC_NON_STICKY, "hsio-n-usbc-non-sticky-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USBC_STICKY, "hsio-n-usbc-sticky-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USB_DRD_BUS, "hsio-n-usb-drd-bus-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USB_TOP_CSR, "hsio-n-usb-top-csr-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_U2PHY_APB, "hsio-n-u2phy-apb-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USB2_PHY_RESET, "hsio-n-usb2-phy-reset-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_USB3DP_PHY_RESET, "hsio-n-usb3dp-phy-reset-clk"),
+ CPM_CLK_LGA(HSIO_N, CLK_HSIO_N_EBU, "hsio-n-ebu-clk"),
+
+ /* HSIO_S */
+ CPM_CLK_LGA_SMC(HSIO_S, CLK_HSIO_S_GPIO_REF_TCX0, "hsio-s-gpio-ref-tcx0-clk"),
+ CPM_CLK_LGA(HSIO_S, CLK_HSIO_S_SYS, "hsio-s-sys-clk"),
+ CPM_CLK_LGA(HSIO_S, CLK_HSIO_S_UFS_CFG, "hsio-s-ufs-cfg-clk"),
+ CPM_CLK_LGA(HSIO_S, CLK_HSIO_S_PHY_FW, "hsio-s-phy-fw-clk"),
+ CPM_CLK_LGA(HSIO_S, CLK_HSIO_S_MPHY_REF_TCX0, "hsio-s-mphy-ref-clk"),
+ CPM_CLK_LGA_SMC(HSIO_S, CLK_HSIO_S_AUX, "hsio-s-aux-clk"),
+
+ /* LSIO_E */
+ CPM_CLK_LGA_SMC(LSIO_E, CLK_LSIO_E_GPIO, "lsio-e-gpio-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_SPMI, "lsio-e-spmi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI7_CFG, "lsio-e-cli7-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI8_CFG, "lsio-e-cli8-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI9_CFG, "lsio-e-cli9-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI10_CFG, "lsio-e-cli10-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI11_CFG, "lsio-e-cli11-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI12_CFG, "lsio-e-cli12-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI13_CFG, "lsio-e-cli13-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI14_CFG, "lsio-e-cli14-cfg-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI7_SPI, "lsio-e-cli7-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI8_SPI, "lsio-e-cli8-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI9_SPI, "lsio-e-cli9-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI10_SPI, "lsio-e-cli10-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI11_SPI, "lsio-e-cli11-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI12_SPI, "lsio-e-cli12-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI13_SPI, "lsio-e-cli13-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI14_SPI, "lsio-e-cli14-spi-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI7_I2C, "lsio-e-cli7-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI8_I2C, "lsio-e-cli8-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI9_I2C, "lsio-e-cli9-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI10_I2C, "lsio-e-cli10-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI11_I2C, "lsio-e-cli11-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI12_I2C, "lsio-e-cli12-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI13_I2C, "lsio-e-cli13-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI14_I2C, "lsio-e-cli14-i2c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI7_UART, "lsio-e-cli7-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI8_UART, "lsio-e-cli8-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI9_UART, "lsio-e-cli9-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI10_UART, "lsio-e-cli10-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI11_UART, "lsio-e-cli11-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI12_UART, "lsio-e-cli12-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI13_UART, "lsio-e-cli13-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI14_UART, "lsio-e-cli14-uart-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI7_I3C, "lsio-e-cli7-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI8_I3C, "lsio-e-cli8-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI9_I3C, "lsio-e-cli9-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI10_I3C, "lsio-e-cli10-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI11_I3C, "lsio-e-cli11-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI12_I3C, "lsio-e-cli12-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI13_I3C, "lsio-e-cli13-i3c-clk"),
+ CPM_CLK_LGA(LSIO_E, CLK_LSIO_E_CLI14_I3C, "lsio-e-cli14-i3c-clk"),
+
+ /* LSIO_N */
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_GPIO, "lsio-n-gpio-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI15_CFG, "lsio-n-cli15-cfg-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI16_CFG, "lsio-n-cli16-cfg-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI15_I2C, "lsio-n-cli15-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI16_I2C, "lsio-n-cli16-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI15_UART, "lsio-n-cli15-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI16_UART, "lsio-n-cli16-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI15_SPI, "lsio-n-cli15-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI16_SPI, "lsio-n-cli16-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI15_I3C, "lsio-n-cli15-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI16_I3C, "lsio-n-cli16-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT0_I2C, "lsio-n-cli-int0-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT0_I3C, "lsio-n-cli-int0-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT0_UART, "lsio-n-cli-int0-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT0_SPI, "lsio-n-cli-int0-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT0_CFG, "lsio-n-cli-int0-cfg-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT1_I2C, "lsio-n-cli-int1-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT1_I3C, "lsio-n-cli-int1-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT1_UART, "lsio-n-cli-int1-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT1_SPI, "lsio-n-cli-int1-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT1_CFG, "lsio-n-cli-int1-cfg-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT2_I2C, "lsio-n-cli-int2-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT2_I3C, "lsio-n-cli-int2-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT2_UART, "lsio-n-cli-int2-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT2_SPI, "lsio-n-cli-int2-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT2_CFG, "lsio-n-cli-int2-cfg-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT3_I2C, "lsio-n-cli-int3-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT3_I3C, "lsio-n-cli-int3-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT3_UART, "lsio-n-cli-int3-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT3_SPI, "lsio-n-cli-int3-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT3_CFG, "lsio-n-cli-int3-cfg-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT4_I2C, "lsio-n-cli-int4-i2c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT4_I3C, "lsio-n-cli-int4-i3c-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT4_UART, "lsio-n-cli-int4-uart-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT4_SPI, "lsio-n-cli-int4-spi-clk"),
+ CPM_CLK_LGA(LSIO_N, CLK_LSIO_N_CLI_INT4_CFG, "lsio-n-cli-int4-cfg-clk"),
+
+ /* LSIO_S */
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_GPIO, "lsio-s-gpio-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK0, "lsio-s-mclk0-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK1, "lsio-s-mclk1-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK2, "lsio-s-mclk2-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK3, "lsio-s-mclk3-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK4, "lsio-s-mclk4-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK5, "lsio-s-mclk5-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK6, "lsio-s-mclk6-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_MCLK7, "lsio-s-mclk7-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_PWM, "lsio-s-pwm-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_PWM_CFG, "lsio-s-pwm-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI0_CFG, "lsio-s-cli0-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI1_CFG, "lsio-s-cli1-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI2_CFG, "lsio-s-cli2-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI3_CFG, "lsio-s-cli3-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI4_CFG, "lsio-s-cli4-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI5_CFG, "lsio-s-cli5-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI6_CFG, "lsio-s-cli6-cfg-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI0_SPI, "lsio-s-cli0-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI1_SPI, "lsio-s-cli1-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI2_SPI, "lsio-s-cli2-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI3_SPI, "lsio-s-cli3-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI4_SPI, "lsio-s-cli4-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI5_SPI, "lsio-s-cli5-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI6_SPI, "lsio-s-cli6-spi-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI0_I2C, "lsio-s-cli0-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI1_I2C, "lsio-s-cli1-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI2_I2C, "lsio-s-cli2-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI3_I2C, "lsio-s-cli3-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI4_I2C, "lsio-s-cli4-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI5_I2C, "lsio-s-cli5-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI6_I2C, "lsio-s-cli6-i2c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI0_UART, "lsio-s-cli0-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI1_UART, "lsio-s-cli1-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI2_UART, "lsio-s-cli2-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI3_UART, "lsio-s-cli3-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI4_UART, "lsio-s-cli4-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI5_UART, "lsio-s-cli5-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI6_UART, "lsio-s-cli6-uart-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI0_I3C, "lsio-s-cli0-i3c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI1_I3C, "lsio-s-cli1-i3c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI2_I3C, "lsio-s-cli2-i3c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI3_I3C, "lsio-s-cli3-i3c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI4_I3C, "lsio-s-cli4-i3c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI5_I3C, "lsio-s-cli5-i3c-clk"),
+ CPM_CLK_LGA(LSIO_S, CLK_LSIO_S_CLI6_I3C, "lsio-s-cli6-i3c-clk"),
+};
+
+static const struct cpm_clk_pd_map lga_pd_map[] = {
+ { .lpcm_id = LPCM_AOC, .pd_id = PD_SSWRP_AOC },
+ { .lpcm_id = LPCM_AURORA, .pd_id = PD_SSWRP_AURORA },
+ { .lpcm_id = LPCM_CODEC_3P, .pd_id = PD_SSWRP_CODEC_3P },
+ { .lpcm_id = LPCM_DPU, .pd_id = PD_SSWRP_DPU },
+ { .lpcm_id = LPCM_EH, .pd_id = PD_SSWRP_EH },
+ { .lpcm_id = LPCM_G2D, .pd_id = PD_SSWRP_G2D },
+ { .lpcm_id = LPCM_GPDMA, .pd_id = PD_SSWRP_GPDMA },
+ { .lpcm_id = LPCM_GPU, .pd_id = PD_SSWRP_GPU },
+ { .lpcm_id = LPCM_GSW, .pd_id = PD_SSWRP_GSW },
+ { .lpcm_id = LPCM_HSIO_N, .pd_id = PD_SSWRP_HSIO_N },
+ { .lpcm_id = LPCM_HSIO_S, .pd_id = PD_SSWRP_HSIO_S },
+ { .lpcm_id = LPCM_ISPBE, .pd_id = PD_SSWRP_ISPBE },
+ { .lpcm_id = LPCM_ISPFE, .pd_id = PD_SSWRP_ISPFE },
+ { .lpcm_id = LPCM_LSIO_E, .pd_id = PD_SSWRP_LSIO_E },
+ { .lpcm_id = LPCM_LSIO_N, .pd_id = PD_SSWRP_LSIO_N },
+ { .lpcm_id = LPCM_LSIO_S, .pd_id = PD_SSWRP_LSIO_S },
+ { .lpcm_id = LPCM_TPU, .pd_id = PD_SSWRP_TPU },
+};
+
+const struct cpm_clk_soc_data cpm_clk_lga_data = {
+ .clks = cpm_clks_lga,
+ .num_clks = ARRAY_SIZE(cpm_clks_lga),
+ .pd_map = lga_pd_map,
+ .num_pd_map = ARRAY_SIZE(lga_pd_map),
+};
diff --git a/drivers/clk/google/clk-cpm-lga.h b/drivers/clk/google/clk-cpm-lga.h
new file mode 100644
index 000000000000..ea3e4fa32575
--- /dev/null
+++ b/drivers/clk/google/clk-cpm-lga.h
@@ -0,0 +1,194 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#ifndef _GOOGLE_CLK_CPM_LGA_H
+#define _GOOGLE_CLK_CPM_LGA_H
+
+/*
+ * LPCM clock IDs of each SSWRP
+ */
+
+#define LPCM_CLK_LSIO_S_GPIO 0
+#define LPCM_CLK_LSIO_S_MCLK0 1
+#define LPCM_CLK_LSIO_S_PWM 2
+#define LPCM_CLK_LSIO_S_PWM_CFG 3
+#define LPCM_CLK_LSIO_S_CLI0_CFG 4
+#define LPCM_CLK_LSIO_S_CLI1_CFG 5
+#define LPCM_CLK_LSIO_S_CLI2_CFG 6
+#define LPCM_CLK_LSIO_S_CLI3_CFG 7
+#define LPCM_CLK_LSIO_S_CLI4_CFG 8
+#define LPCM_CLK_LSIO_S_CLI5_CFG 9
+#define LPCM_CLK_LSIO_S_CLI6_CFG 10
+#define LPCM_CLK_LSIO_S_CLI0_SPI 11
+#define LPCM_CLK_LSIO_S_CLI1_SPI 12
+#define LPCM_CLK_LSIO_S_CLI2_SPI 13
+#define LPCM_CLK_LSIO_S_CLI3_SPI 14
+#define LPCM_CLK_LSIO_S_CLI4_SPI 15
+#define LPCM_CLK_LSIO_S_CLI5_SPI 16
+#define LPCM_CLK_LSIO_S_CLI6_SPI 17
+#define LPCM_CLK_LSIO_S_CLI0_I2C 18
+#define LPCM_CLK_LSIO_S_CLI1_I2C 19
+#define LPCM_CLK_LSIO_S_CLI2_I2C 20
+#define LPCM_CLK_LSIO_S_CLI3_I2C 21
+#define LPCM_CLK_LSIO_S_CLI4_I2C 22
+#define LPCM_CLK_LSIO_S_CLI5_I2C 23
+#define LPCM_CLK_LSIO_S_CLI6_I2C 24
+#define LPCM_CLK_LSIO_S_CLI0_UART 25
+#define LPCM_CLK_LSIO_S_CLI1_UART 26
+#define LPCM_CLK_LSIO_S_CLI2_UART 27
+#define LPCM_CLK_LSIO_S_CLI3_UART 28
+#define LPCM_CLK_LSIO_S_CLI4_UART 29
+#define LPCM_CLK_LSIO_S_CLI5_UART 30
+#define LPCM_CLK_LSIO_S_CLI6_UART 31
+#define LPCM_CLK_LSIO_S_CLI0_I3C 32
+#define LPCM_CLK_LSIO_S_CLI1_I3C 33
+#define LPCM_CLK_LSIO_S_CLI2_I3C 34
+#define LPCM_CLK_LSIO_S_CLI3_I3C 35
+#define LPCM_CLK_LSIO_S_CLI4_I3C 36
+#define LPCM_CLK_LSIO_S_CLI5_I3C 37
+#define LPCM_CLK_LSIO_S_CLI6_I3C 38
+#define LPCM_CLK_LSIO_S_MCLK1 39
+#define LPCM_CLK_LSIO_S_MCLK2 40
+#define LPCM_CLK_LSIO_S_MCLK3 41
+#define LPCM_CLK_LSIO_S_MCLK4 42
+#define LPCM_CLK_LSIO_S_MCLK5 43
+#define LPCM_CLK_LSIO_S_MCLK6 44
+#define LPCM_CLK_LSIO_S_MCLK7 45
+
+#define LPCM_CLK_LSIO_N_GPIO 0
+#define LPCM_CLK_LSIO_N_CLI_INT0_I2C 1
+#define LPCM_CLK_LSIO_N_CLI_INT0_I3C 2
+#define LPCM_CLK_LSIO_N_CLI_INT0_UART 3
+#define LPCM_CLK_LSIO_N_CLI_INT0_SPI 4
+#define LPCM_CLK_LSIO_N_CLI_INT0_CFG 5
+#define LPCM_CLK_LSIO_N_CLI_INT1_I2C 6
+#define LPCM_CLK_LSIO_N_CLI_INT1_I3C 7
+#define LPCM_CLK_LSIO_N_CLI_INT1_UART 8
+#define LPCM_CLK_LSIO_N_CLI_INT1_SPI 9
+#define LPCM_CLK_LSIO_N_CLI_INT1_CFG 10
+#define LPCM_CLK_LSIO_N_CLI_INT2_I2C 11
+#define LPCM_CLK_LSIO_N_CLI_INT2_I3C 12
+#define LPCM_CLK_LSIO_N_CLI_INT2_UART 13
+#define LPCM_CLK_LSIO_N_CLI_INT2_SPI 14
+#define LPCM_CLK_LSIO_N_CLI_INT2_CFG 15
+#define LPCM_CLK_LSIO_N_CLI_INT3_I2C 16
+#define LPCM_CLK_LSIO_N_CLI_INT3_I3C 17
+#define LPCM_CLK_LSIO_N_CLI_INT3_UART 18
+#define LPCM_CLK_LSIO_N_CLI_INT3_SPI 19
+#define LPCM_CLK_LSIO_N_CLI_INT3_CFG 20
+#define LPCM_CLK_LSIO_N_CLI_INT4_I2C 21
+#define LPCM_CLK_LSIO_N_CLI_INT4_I3C 22
+#define LPCM_CLK_LSIO_N_CLI_INT4_UART 23
+#define LPCM_CLK_LSIO_N_CLI_INT4_SPI 24
+#define LPCM_CLK_LSIO_N_CLI_INT4_CFG 25
+#define LPCM_CLK_LSIO_N_CLI15_CFG 26
+#define LPCM_CLK_LSIO_N_CLI16_CFG 27
+#define LPCM_CLK_LSIO_N_CLI15_I2C 28
+#define LPCM_CLK_LSIO_N_CLI16_I2C 29
+#define LPCM_CLK_LSIO_N_CLI15_SPI 30
+#define LPCM_CLK_LSIO_N_CLI16_SPI 31
+#define LPCM_CLK_LSIO_N_CLI15_UART 32
+#define LPCM_CLK_LSIO_N_CLI16_UART 33
+#define LPCM_CLK_LSIO_N_CLI15_I3C 34
+#define LPCM_CLK_LSIO_N_CLI16_I3C 35
+
+#define LPCM_CLK_LSIO_E_GPIO 0
+#define LPCM_CLK_LSIO_E_CLI7_CFG 1
+#define LPCM_CLK_LSIO_E_CLI8_CFG 2
+#define LPCM_CLK_LSIO_E_CLI9_CFG 3
+#define LPCM_CLK_LSIO_E_CLI10_CFG 4
+#define LPCM_CLK_LSIO_E_CLI11_CFG 5
+#define LPCM_CLK_LSIO_E_CLI12_CFG 6
+#define LPCM_CLK_LSIO_E_CLI13_CFG 7
+#define LPCM_CLK_LSIO_E_CLI14_CFG 8
+#define LPCM_CLK_LSIO_E_CLI7_SPI 9
+#define LPCM_CLK_LSIO_E_CLI8_SPI 10
+#define LPCM_CLK_LSIO_E_CLI9_SPI 11
+#define LPCM_CLK_LSIO_E_CLI10_SPI 12
+#define LPCM_CLK_LSIO_E_CLI11_SPI 13
+#define LPCM_CLK_LSIO_E_CLI12_SPI 14
+#define LPCM_CLK_LSIO_E_CLI13_SPI 15
+#define LPCM_CLK_LSIO_E_CLI14_SPI 16
+#define LPCM_CLK_LSIO_E_CLI7_I2C 17
+#define LPCM_CLK_LSIO_E_CLI8_I2C 18
+#define LPCM_CLK_LSIO_E_CLI9_I2C 19
+#define LPCM_CLK_LSIO_E_CLI10_I2C 20
+#define LPCM_CLK_LSIO_E_CLI11_I2C 21
+#define LPCM_CLK_LSIO_E_CLI12_I2C 22
+#define LPCM_CLK_LSIO_E_CLI13_I2C 23
+#define LPCM_CLK_LSIO_E_CLI14_I2C 24
+#define LPCM_CLK_LSIO_E_CLI7_UART 25
+#define LPCM_CLK_LSIO_E_CLI8_UART 26
+#define LPCM_CLK_LSIO_E_CLI9_UART 27
+#define LPCM_CLK_LSIO_E_CLI10_UART 28
+#define LPCM_CLK_LSIO_E_CLI11_UART 29
+#define LPCM_CLK_LSIO_E_CLI12_UART 30
+#define LPCM_CLK_LSIO_E_CLI13_UART 31
+#define LPCM_CLK_LSIO_E_CLI14_UART 32
+#define LPCM_CLK_LSIO_E_SPMI 33
+#define LPCM_CLK_LSIO_E_CLI7_I3C 34
+#define LPCM_CLK_LSIO_E_CLI8_I3C 35
+#define LPCM_CLK_LSIO_E_CLI9_I3C 36
+#define LPCM_CLK_LSIO_E_CLI10_I3C 37
+#define LPCM_CLK_LSIO_E_CLI11_I3C 38
+#define LPCM_CLK_LSIO_E_CLI12_I3C 39
+#define LPCM_CLK_LSIO_E_CLI13_I3C 40
+#define LPCM_CLK_LSIO_E_CLI14_I3C 41
+
+#define LPCM_CLK_HSIO_S_MPHY_REF_OSC 0
+#define LPCM_CLK_HSIO_S_MPHY_REF_TCX0 1
+#define LPCM_CLK_HSIO_S_GPIO_REF_OSC 2
+#define LPCM_CLK_HSIO_S_GPIO_REF_TCX0 3
+#define LPCM_CLK_HSIO_S_HCLK 4
+#define LPCM_CLK_HSIO_S_SYS 5
+#define LPCM_CLK_HSIO_S_T 6
+#define LPCM_CLK_HSIO_S_LP_T 7
+#define LPCM_CLK_HSIO_S_MPHY_CFG 8
+#define LPCM_CLK_HSIO_S_UFS_CFG 9
+#define LPCM_CLK_HSIO_S_PHY_FW 10
+#define LPCM_CLK_HSIO_S_PCIE_REF 11
+#define LPCM_CLK_HSIO_S_UFS_RESET 12
+#define LPCM_CLK_HSIO_S_UFS_LP_RESET 13
+#define LPCM_CLK_HSIO_S_UFS_ARESET 14
+#define LPCM_CLK_HSIO_S_UFS_PHY_RESET 15
+#define LPCM_CLK_HSIO_S_AUX 16
+
+#define LPCM_CLK_HSIO_N_USB 0
+#define LPCM_CLK_HSIO_N_DP0 1
+#define LPCM_CLK_HSIO_N_DP1 2
+#define LPCM_CLK_HSIO_N_PHY_FW 3
+#define LPCM_CLK_HSIO_N_PCIE_REF 4
+#define LPCM_CLK_HSIO_N_U2PHY_REF 5
+#define LPCM_CLK_HSIO_N_USBDP_SUSPEND 6
+#define LPCM_CLK_HSIO_N_USBC_NON_STICKY 7
+#define LPCM_CLK_HSIO_N_USBC_STICKY 8
+#define LPCM_CLK_HSIO_N_USB_DRD_BUS 9
+#define LPCM_CLK_HSIO_N_CSR 10
+#define LPCM_CLK_HSIO_N_USB_TOP_CSR 11
+#define LPCM_CLK_HSIO_N_DP_PCLK 12
+#define LPCM_CLK_HSIO_N_DP_CFG 13
+#define LPCM_CLK_HSIO_N_U2PHY_APB 14
+#define LPCM_CLK_HSIO_N_DP_VCC 15
+#define LPCM_CLK_HSIO_N_U3PHY_REF 16
+#define LPCM_CLK_HSIO_N_USB2_PHY_RESET 17
+#define LPCM_CLK_HSIO_N_USB3DP_PHY_RESET 18
+#define LPCM_CLK_HSIO_N_EBU 19
+
+#define LPCM_CLK_DPU_DP0_PIX 0
+#define LPCM_CLK_DPU_DP1_PIX 1
+#define LPCM_CLK_DPU_DSI0_PIX 2
+#define LPCM_CLK_DPU_DSI1_PIX 3
+#define LPCM_CLK_DPU_DSI1_PHY 4
+#define LPCM_CLK_DPU_FE0 5
+#define LPCM_CLK_DPU_FE1 6
+#define LPCM_CLK_DPU_BE 7
+#define LPCM_CLK_DPU_AON 8
+
+#define LPCM_CLK_GPCM_DPU_PLL_DP 0
+#define LPCM_CLK_GPCM_HSIO_N_PLL_DP 1
+
+#define LPCM_CLK_CPU_SSWRP_TSS 1
+
+#endif /* _GOOGLE_CLK_CPM_LGA_H */
diff --git a/drivers/clk/google/clk-cpm.c b/drivers/clk/google/clk-cpm.c
new file mode 100644
index 000000000000..9f3c3ea6ec56
--- /dev/null
+++ b/drivers/clk/google/clk-cpm.c
@@ -0,0 +1,385 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2023-2026 Google LLC
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/auxiliary_bus.h>
+#include <linux/bug.h>
+#include <linux/clk-provider.h>
+#include <linux/container_of.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gfp_types.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/overflow.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include <soc/google/google-cpm-mba.h>
+
+#include "clk-cpm-internal.h"
+
+#define PREPARE_OP_ID 0
+#define UNPREPARE_OP_ID 1
+#define IS_ENABLE_OP_ID 2
+#define RECALC_RATE_OP_ID 3
+#define ROUND_RATE_OP_ID 4 /* Not implemented */
+#define SET_RATE_OP_ID 5
+
+/* PREPARE_OP_ID / UNPREPARE_OP_ID */
+#define CLK_GATE 1
+
+#define SIP_SVC_CLK_CONTROL 0x82000702
+
+#define to_cpm_clk(_hw) container_of(_hw, struct cpm_clk, hw)
+
+struct cpm_clk {
+ struct clk_hw hw;
+ struct cpm_clk_dev_data *dev_data;
+ const char *name;
+
+ unsigned int lpcm_id;
+ unsigned int clock_id;
+ bool use_smc;
+};
+
+struct cpm_clk_dev_data {
+ struct device *dev;
+ struct cpm_handle *cpm;
+};
+
+static void cpm_clk_pd_dev_release(struct device *dev)
+{
+ kfree(dev);
+}
+
+static void cpm_clk_unregister_pd_dev(void *data)
+{
+ struct device *clk_dev = data;
+
+ pm_runtime_disable(clk_dev);
+ pm_genpd_remove_device(clk_dev);
+ device_unregister(clk_dev);
+}
+
+static void cpm_clk_hw_unregister(void *data)
+{
+ struct clk_hw *hw = data;
+
+ clk_hw_unregister(hw);
+}
+
+static int cpm_clk_send_mbox_msg_set_gate(struct cpm_clk *cpm_clk, bool enable)
+{
+ const struct cpm_lpcm_message msg = {
+ .cmd = LPCM_CMD_SET_LCM_CLK,
+ .opcode = enable ? PREPARE_OP_ID : UNPREPARE_OP_ID,
+ .lpcm_id = cpm_clk->lpcm_id,
+ .obj_id = cpm_clk->clock_id,
+ .payload = CLK_GATE,
+ };
+
+ return cpm_send_lpcm_message(cpm_clk->dev_data->cpm, &msg);
+}
+
+static unsigned long cpm_clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct cpm_clk *cpm_clk = to_cpm_clk(hw);
+ const struct cpm_lpcm_message msg = {
+ .cmd = LPCM_CMD_SET_LCM_CLK,
+ .opcode = RECALC_RATE_OP_ID,
+ .lpcm_id = cpm_clk->lpcm_id,
+ .obj_id = cpm_clk->clock_id,
+ };
+ int ret;
+
+ dev_dbg(cpm_clk->dev_data->dev, "%s: lpcm_id %d, clock_id %d: get rate\n",
+ cpm_clk->name, cpm_clk->lpcm_id, cpm_clk->clock_id);
+ ret = cpm_send_lpcm_message(cpm_clk->dev_data->cpm, &msg);
+ if (ret < 0)
+ return 0;
+
+ return ret;
+}
+
+static inline int lpcm_smc(struct clk_hw *hw, bool enable)
+{
+ struct cpm_clk *cpm_clk = to_cpm_clk(hw);
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SIP_SVC_CLK_CONTROL, cpm_clk->lpcm_id, cpm_clk->clock_id,
+ enable, 0, 0, 0, 0, &res);
+
+ WARN_ON(res.a0);
+ if ((unsigned long)res.a1) {
+ dev_err(cpm_clk->dev_data->dev,
+ "Failed LPCM SMC: %d clk_id: %d, enable: %d res.a1: %lu\n",
+ cpm_clk->lpcm_id, cpm_clk->clock_id, enable, res.a1);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int cpm_clk_prepare(struct clk_hw *hw)
+{
+ struct cpm_clk *cpm_clk = to_cpm_clk(hw);
+
+ dev_dbg(cpm_clk->dev_data->dev, "%s: lpcm_id %d, clock_id %d: enable\n",
+ cpm_clk->name, cpm_clk->lpcm_id, cpm_clk->clock_id);
+
+ return cpm_clk_send_mbox_msg_set_gate(cpm_clk, true);
+}
+
+static void cpm_clk_unprepare(struct clk_hw *hw)
+{
+ struct cpm_clk *cpm_clk = to_cpm_clk(hw);
+
+ dev_dbg(cpm_clk->dev_data->dev, "%s: lpcm_id %d, clock_id %d: disable\n",
+ cpm_clk->name, cpm_clk->lpcm_id, cpm_clk->clock_id);
+
+ cpm_clk_send_mbox_msg_set_gate(cpm_clk, false);
+}
+
+static int cpm_clk_smc_enable(struct clk_hw *hw)
+{
+ struct cpm_clk *cpm_clk = to_cpm_clk(hw);
+
+ dev_dbg(cpm_clk->dev_data->dev, "%s: lpcm_id %d, clock_id %d: enable\n",
+ cpm_clk->name, cpm_clk->lpcm_id, cpm_clk->clock_id);
+
+ return lpcm_smc(hw, true);
+}
+
+static void cpm_clk_smc_disable(struct clk_hw *hw)
+{
+ struct cpm_clk *cpm_clk = to_cpm_clk(hw);
+
+ dev_dbg(cpm_clk->dev_data->dev, "%s: lpcm_id %d, clock_id %d: disable\n",
+ cpm_clk->name, cpm_clk->lpcm_id, cpm_clk->clock_id);
+
+ lpcm_smc(hw, false);
+}
+
+static const struct clk_ops cpm_clk_ops = {
+ .recalc_rate = cpm_clk_recalc_rate,
+ .prepare = cpm_clk_prepare,
+ .unprepare = cpm_clk_unprepare,
+};
+
+static const struct clk_ops cpm_gate_smc_clk_ops = {
+ .enable = cpm_clk_smc_enable,
+ .disable = cpm_clk_smc_disable,
+};
+
+static struct device *cpm_clk_attach_pd(struct device *dev, const char *name,
+ int pd_id)
+{
+ struct of_phandle_args genpdspec = {
+ .np = dev->of_node,
+ .args_count = 1,
+ .args[0] = pd_id,
+ };
+ struct device *clk_dev;
+ int err;
+
+ /*
+ * No need for a new device if there's no domain to attach. Just reuse
+ * the controller device.
+ */
+ if (pd_id < 0)
+ return dev;
+
+ clk_dev = kzalloc_obj(*clk_dev, GFP_KERNEL);
+ if (!clk_dev)
+ return ERR_PTR(-ENOMEM);
+
+ device_initialize(clk_dev);
+ clk_dev->parent = dev;
+ clk_dev->release = cpm_clk_pd_dev_release;
+ dev_set_name(clk_dev, "%s:%s", dev_name(dev), name);
+
+ err = device_add(clk_dev);
+ if (err) {
+ put_device(clk_dev);
+ return ERR_PTR(err);
+ }
+
+ err = of_genpd_add_device(&genpdspec, clk_dev);
+ if (err) {
+ device_unregister(clk_dev);
+ if (err == -ENOENT)
+ err = -EPROBE_DEFER;
+ return ERR_PTR(dev_err_probe(dev, err,
+ "failed to attach %s to power domain %d\n",
+ name, pd_id));
+ }
+
+ pm_runtime_enable(clk_dev);
+
+ err = devm_add_action_or_reset(dev, cpm_clk_unregister_pd_dev, clk_dev);
+ if (err)
+ return ERR_PTR(err);
+
+ return clk_dev;
+}
+
+static int cpm_clk_lookup_pd(const struct cpm_clk_soc_data *soc_data,
+ u32 lpcm_id)
+{
+ size_t i;
+
+ for (i = 0; i < soc_data->num_pd_map; i++) {
+ if (soc_data->pd_map[i].lpcm_id == lpcm_id)
+ return soc_data->pd_map[i].pd_id;
+ }
+
+ return -1;
+}
+
+static struct cpm_clk *
+cpm_clk_register_clk(struct device *dev,
+ const struct cpm_clk_data *clk_data,
+ const struct cpm_clk_soc_data *soc_data,
+ struct cpm_clk_dev_data *dev_data)
+{
+ struct cpm_clk *cpm_clk;
+ struct clk_init_data init = {};
+ const char *name = clk_data->name;
+ struct device *clk_dev;
+ int pd_id;
+ int err;
+
+ cpm_clk = devm_kzalloc(dev, sizeof(*cpm_clk), GFP_KERNEL);
+ if (!cpm_clk)
+ return ERR_PTR(-ENOMEM);
+
+ cpm_clk->name = name;
+ cpm_clk->lpcm_id = clk_data->lpcm_id;
+ cpm_clk->clock_id = clk_data->clock_id;
+ cpm_clk->use_smc = clk_data->use_smc;
+ cpm_clk->dev_data = dev_data;
+
+ pd_id = cpm_clk_lookup_pd(soc_data, clk_data->lpcm_id);
+ clk_dev = cpm_clk_attach_pd(dev, name, pd_id);
+ if (IS_ERR(clk_dev))
+ return ERR_CAST(clk_dev);
+
+ init.name = name;
+ init.flags = CLK_GET_RATE_NOCACHE;
+ if (cpm_clk->use_smc)
+ init.ops = &cpm_gate_smc_clk_ops;
+ else
+ init.ops = &cpm_clk_ops;
+ cpm_clk->hw.init = &init;
+
+ err = clk_hw_register(clk_dev, &cpm_clk->hw);
+ if (err) {
+ dev_err(dev, "%s: failed to register clk hw: %d\n", name, err);
+ return ERR_PTR(err);
+ }
+
+ /*
+ * Attach teardown to the controller dev (not clk_dev) so the clock is
+ * unregistered with driver teardown, not with (late) device cleanup.
+ */
+ err = devm_add_action_or_reset(dev, cpm_clk_hw_unregister, &cpm_clk->hw);
+ if (err)
+ return ERR_PTR(err);
+
+ return cpm_clk;
+}
+
+static const struct of_device_id cpm_clk_of_match[] __maybe_unused = {
+ { .compatible = "google,lga-cpm", .data = &cpm_clk_lga_data },
+ { }
+};
+
+static int cpm_clk_controller_probe(struct auxiliary_device *auxdev,
+ const struct auxiliary_device_id *id)
+{
+ struct device *dev = &auxdev->dev;
+ struct device_node *node = dev->of_node;
+ struct cpm_clk_dev_data *dev_data;
+ struct clk_hw_onecell_data *hw_data;
+ const struct of_device_id *match;
+ const struct cpm_clk_soc_data *soc_data;
+ int ret, i;
+
+ if (!node) {
+ dev_err(dev, "No device tree node associated with device\n");
+ return -ENODEV;
+ }
+
+ match = of_match_node(cpm_clk_of_match, node);
+ if (!match) {
+ dev_err(dev, "unsupported CPM compatible\n");
+ return -ENODEV;
+ }
+ soc_data = match->data;
+
+ dev_data = devm_kzalloc(dev, sizeof(*dev_data), GFP_KERNEL);
+ if (!dev_data)
+ return -ENOMEM;
+
+ dev_data->dev = dev;
+
+ dev_data->cpm = devm_cpm_get_handle(dev);
+ if (IS_ERR(dev_data->cpm))
+ return dev_err_probe(dev, PTR_ERR(dev_data->cpm),
+ "Failed to get CPM handle\n");
+
+ hw_data = devm_kzalloc(dev, struct_size(hw_data, hws, soc_data->num_clks),
+ GFP_KERNEL);
+ if (!hw_data)
+ return -ENOMEM;
+
+ hw_data->num = soc_data->num_clks;
+
+ for (i = 0; i < soc_data->num_clks; i++) {
+ struct cpm_clk *cpm_clk;
+
+ if (!soc_data->clks[i].name) {
+ hw_data->hws[i] = ERR_PTR(-ENOENT);
+ continue;
+ }
+
+ cpm_clk = cpm_clk_register_clk(dev, &soc_data->clks[i], soc_data, dev_data);
+ if (IS_ERR(cpm_clk))
+ return PTR_ERR(cpm_clk);
+
+ hw_data->hws[i] = &cpm_clk->hw;
+ }
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, hw_data);
+ if (ret) {
+ dev_err(dev, "failed to add clock provider: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct auxiliary_device_id cpm_clk_id_table[] = {
+ { .name = "google_cpm_mba.clk" },
+ {},
+};
+MODULE_DEVICE_TABLE(auxiliary, cpm_clk_id_table);
+
+static struct auxiliary_driver cpm_clk_driver = {
+ .probe = cpm_clk_controller_probe,
+ .name = "google-clk-cpm",
+ .id_table = cpm_clk_id_table,
+};
+module_auxiliary_driver(cpm_clk_driver);
+
+MODULE_DESCRIPTION("Google CPM Clock Driver");
+MODULE_LICENSE("GPL");
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 5/9] reset: google: Add CPM reset driver
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
` (3 preceding siblings ...)
2026-11-25 0:03 ` [PATCH v2 4/9] clk: google: Add CPM clock driver Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 8:48 ` Philipp Zabel
2026-11-25 0:03 ` [PATCH v2 6/9] irqchip/google-cpm: Add CPM IRQ driver Brian Norris
` (3 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
Google Tensor SoCs (used on Pixel phones) manage many resources
(including resets) using a Central Power Manager (CPM) co-processor. We
communicate with CPM using mailboxes, abstracted in the
devm_cpm_get_handle(), etc., API.
For posterity, I list a summary of changes made relative to the
downstream Pixel driver:
* Switch to auxiliary bus, as a child of a CPM device
* Use devm more heavily
* Avoid representing each reset as its own Device Tree node.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v2:
* Rename symbols from goog_cpm_rst_* to cpm_reset_*
* Moved shared protocol details to CPM driver
* Remove custom reset debugfs interface and .remove callback.
* Remove per-SoC table; we only need naive translation of firmware IDs
drivers/reset/Kconfig | 1 +
drivers/reset/Makefile | 1 +
drivers/reset/google/Kconfig | 11 +++
drivers/reset/google/Makefile | 2 +
drivers/reset/google/reset-cpm.c | 154 +++++++++++++++++++++++++++++++
5 files changed, 169 insertions(+)
create mode 100644 drivers/reset/google/Kconfig
create mode 100644 drivers/reset/google/Makefile
create mode 100644 drivers/reset/google/reset-cpm.c
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 673bca1e594e..64c12b479b2c 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -475,6 +475,7 @@ config RESET_ZYNQMP
This enables the reset controller driver for Xilinx ZynqMP SoCs.
source "drivers/reset/amlogic/Kconfig"
+source "drivers/reset/google/Kconfig"
source "drivers/reset/hisilicon/Kconfig"
source "drivers/reset/realtek/Kconfig"
source "drivers/reset/spacemit/Kconfig"
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 2fe527a7be8e..a151fe63905e 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += core.o
obj-y += amlogic/
+obj-y += google/
obj-y += hisilicon/
obj-y += realtek/
obj-y += spacemit/
diff --git a/drivers/reset/google/Kconfig b/drivers/reset/google/Kconfig
new file mode 100644
index 000000000000..38431b4f9001
--- /dev/null
+++ b/drivers/reset/google/Kconfig
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config RESET_CPM
+ tristate "Google CPM Reset Controller"
+ depends on ARCH_GOOGLE || COMPILE_TEST
+ depends on GOOGLE_CPM_MBA
+ help
+ Driver support for reset controllers found on Google Tensor SoCs,
+ operating over the CPM mailbox interface. This allows peripheral
+ drivers to assert and deassert resets on LPCM hardware blocks.
+
+ If unsure, say N.
diff --git a/drivers/reset/google/Makefile b/drivers/reset/google/Makefile
new file mode 100644
index 000000000000..437c19459464
--- /dev/null
+++ b/drivers/reset/google/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_RESET_CPM) += reset-cpm.o
diff --git a/drivers/reset/google/reset-cpm.c b/drivers/reset/google/reset-cpm.c
new file mode 100644
index 000000000000..ef0863f25cac
--- /dev/null
+++ b/drivers/reset/google/reset-cpm.c
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Device driver to control Google SoC LPCM resets via CPM.
+ * Copyright 2023-2026 Google LLC
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/container_of.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gfp_types.h>
+#include <linux/limits.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/reset-controller.h>
+#include <linux/types.h>
+#include <soc/google/google-cpm-mba.h>
+
+#define ASSERT_OP_ID 0
+#define DEASSERT_OP_ID 1
+
+#define CPM_RST_LPCM_ID_MASK GENMASK(31, 16)
+#define CPM_RST_ID_MASK GENMASK(15, 0)
+/* Object fields are 8 bits */
+#define CPM_RST_ID_MAX U8_MAX
+
+static inline unsigned long to_rstc_idx(u32 lpcm_id, u32 rst_id)
+{
+ return FIELD_PREP(CPM_RST_LPCM_ID_MASK, lpcm_id) |
+ FIELD_PREP(CPM_RST_ID_MASK, rst_id);
+}
+
+static inline u32 lpcm_from_idx(unsigned long idx)
+{
+ return FIELD_GET(CPM_RST_LPCM_ID_MASK, idx);
+}
+
+static inline u32 rst_from_idx(unsigned long idx)
+{
+ return FIELD_GET(CPM_RST_ID_MASK, idx);
+}
+
+struct cpm_reset_provider {
+ struct reset_controller_dev rcdev;
+ struct cpm_handle *cpm;
+};
+
+static inline struct cpm_reset_provider *to_provider(struct reset_controller_dev *rcdev)
+{
+ return container_of(rcdev, struct cpm_reset_provider, rcdev);
+}
+
+static int cpm_reset_send_lpcm(struct reset_controller_dev *rcdev,
+ unsigned long idx, u8 opcode)
+{
+ struct cpm_reset_provider *provider = to_provider(rcdev);
+ const struct cpm_lpcm_message msg = {
+ .cmd = LPCM_CMD_SET_RST,
+ .opcode = opcode,
+ .lpcm_id = lpcm_from_idx(idx),
+ .obj_id = rst_from_idx(idx),
+ };
+
+ return cpm_send_lpcm_message(provider->cpm, &msg);
+}
+
+static int cpm_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long idx)
+{
+ return cpm_reset_send_lpcm(rcdev, idx, ASSERT_OP_ID);
+}
+
+static int cpm_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long idx)
+{
+ return cpm_reset_send_lpcm(rcdev, idx, DEASSERT_OP_ID);
+}
+
+static const struct reset_control_ops cpm_reset_ops = {
+ .assert = cpm_reset_assert,
+ .deassert = cpm_reset_deassert,
+};
+
+static int cpm_reset_of_xlate(struct reset_controller_dev *rcdev,
+ const struct of_phandle_args *reset_spec)
+{
+ u32 lpcm_id, rst_id;
+
+ if (reset_spec->args_count != 2)
+ return -EINVAL;
+
+ lpcm_id = reset_spec->args[0];
+ rst_id = reset_spec->args[1];
+
+ if (lpcm_id > CPM_RST_ID_MAX)
+ return -EINVAL;
+ if (rst_id > CPM_RST_ID_MAX)
+ return -EINVAL;
+
+ return to_rstc_idx(lpcm_id, rst_id);
+}
+
+static int cpm_reset_probe(struct auxiliary_device *auxdev,
+ const struct auxiliary_device_id *id)
+{
+ struct device *dev = &auxdev->dev;
+ struct cpm_reset_provider *provider;
+ int ret;
+
+ provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL);
+ if (!provider)
+ return -ENOMEM;
+
+ provider->cpm = devm_cpm_get_handle(dev);
+ if (IS_ERR(provider->cpm))
+ return dev_err_probe(dev, PTR_ERR(provider->cpm),
+ "Failed to get CPM handle\n");
+
+ provider->rcdev.dev = dev;
+ provider->rcdev.owner = THIS_MODULE;
+ provider->rcdev.of_node = dev->of_node;
+ provider->rcdev.ops = &cpm_reset_ops;
+ provider->rcdev.of_reset_n_cells = 2;
+ provider->rcdev.of_xlate = cpm_reset_of_xlate;
+
+ ret = devm_reset_controller_register(dev, &provider->rcdev);
+ if (ret < 0) {
+ dev_err(dev, "failed to register reset controller: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct auxiliary_device_id cpm_reset_id_table[] = {
+ { .name = "google_cpm_mba.reset" },
+ {}
+};
+MODULE_DEVICE_TABLE(auxiliary, cpm_reset_id_table);
+
+static struct auxiliary_driver cpm_reset_driver = {
+ .probe = cpm_reset_probe,
+ .name = "google-reset-cpm",
+ .id_table = cpm_reset_id_table,
+};
+module_auxiliary_driver(cpm_reset_driver);
+
+MODULE_DESCRIPTION("Google CPM Reset Driver");
+MODULE_LICENSE("GPL");
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 6/9] irqchip/google-cpm: Add CPM IRQ driver
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
` (4 preceding siblings ...)
2026-11-25 0:03 ` [PATCH v2 5/9] reset: google: Add CPM reset driver Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 7/9] arm64: dts: google: Add Laguna CPM mailbox array Brian Norris
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
From: Jim Wylder <jwylder@google.com>
The Central Power Manager (CPM) on Google Tensor SoCs can signal
events/interrupts over its mailbox communication protocol. Today, the
downstream driver for these chips only supports interrupt notification,
although the CPM firmware may also have mask/unmask support (not
currently used) that could be added later if needed.
In practice, this driver is used for RTC alarms and for events driven by
the Always-on Compute (AoC) subsystem.
Signed-off-by: Jim Wylder <jwylder@google.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v2:
* Formatting requests from v1 review
* Adapt to devm_cpm_register_rx_callback()
* Update author/SoB to retain downstream heritage
drivers/irqchip/Kconfig | 10 +++
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-google-cpm.c | 131 +++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+)
create mode 100644 drivers/irqchip/irq-google-cpm.c
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 8aee8f731848..ceaad2ab04f6 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -556,6 +556,16 @@ config CSKY_APB_INTC
by C-SKY single core SOC system. It uses mmio map apb-bus to visit
the controller's register.
+config GOOGLE_CPM_IRQ
+ tristate "Google Tensor CPM interrupt controller"
+ depends on GOOGLE_CPM_MBA
+ depends on ARCH_GOOGLE || COMPILE_TEST
+ select IRQ_DOMAIN
+ help
+ Support for the Central Power Manager (CPM) interrupt controller
+ found on Google Tensor SoCs. This controller routes interrupts from
+ the CPM to the Application Processor.
+
config IMX_IRQSTEER
tristate "i.MX IRQSTEER support"
depends on ARCH_MXC || ARCH_S32 || COMPILE_TEST
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index eb539d41251e..ac6352d3b797 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o
obj-$(CONFIG_QCOM_MPM) += irq-qcom-mpm.o
obj-$(CONFIG_CSKY_MPINTC) += irq-csky-mpintc.o
obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o
+obj-$(CONFIG_GOOGLE_CPM_IRQ) += irq-google-cpm.o
obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o
obj-$(CONFIG_RISCV_APLIC) += irq-riscv-aplic-main.o irq-riscv-aplic-direct.o
obj-$(CONFIG_RISCV_APLIC_MSI) += irq-riscv-aplic-msi.o
diff --git a/drivers/irqchip/irq-google-cpm.c b/drivers/irqchip/irq-google-cpm.c
new file mode 100644
index 000000000000..ce960b48f271
--- /dev/null
+++ b/drivers/irqchip/irq-google-cpm.c
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Google CPM IRQ chip driver
+ *
+ * Copyright 2023-2026 Google LLC
+ */
+#include <linux/auxiliary_bus.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gfp_types.h>
+#include <linux/irq.h>
+#include <linux/irqdesc.h>
+#include <linux/irqdomain.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/property.h>
+#include <linux/types.h>
+#include <soc/google/cpm-service-ids.h>
+#include <soc/google/google-cpm-mba.h>
+
+#define CPM_IRQ_COUNT 512
+
+struct cpm_irq_info {
+ struct device *dev;
+ struct irq_domain *domain;
+};
+
+static void cpm_irq_process_irq_status(struct cpm_irq_info *info, u32 irq_number)
+{
+ int ret = generic_handle_domain_irq_safe(info->domain, irq_number);
+
+ if (ret)
+ dev_err(info->dev, "Error handling IRQ %u, error code %d\n", irq_number, ret);
+}
+
+static void cpm_irq_rx_callback(const struct cpm_payload *msg, void *priv)
+{
+ struct cpm_irq_info *info = priv;
+ u32 irq_number = msg->payload[0];
+
+ cpm_irq_process_irq_status(info, irq_number);
+}
+
+static void cpm_irq_domain_remove_action(void *data)
+{
+ struct irq_domain *domain = data;
+ unsigned int hwirq;
+
+ for (hwirq = 0; hwirq < CPM_IRQ_COUNT; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(domain, hwirq));
+
+ irq_domain_remove(domain);
+}
+
+static int cpm_irq_domain_map(struct irq_domain *d, unsigned int virq,
+ irq_hw_number_t hwirq)
+{
+ struct cpm_irq_info *info = d->host_data;
+
+ if (hwirq >= CPM_IRQ_COUNT)
+ return -EINVAL;
+
+ irq_set_chip_data(virq, info);
+ irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
+
+ dev_dbg(info->dev, "Mapped hwirq %lu to virq %u\n", hwirq, virq);
+
+ return 0;
+}
+
+static const struct irq_domain_ops cpm_irq_domain_ops = {
+ .map = cpm_irq_domain_map,
+ .xlate = irq_domain_xlate_onecell,
+};
+
+static int cpm_irq_probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id)
+{
+ struct device *dev = &adev->dev;
+ struct cpm_irq_info *info;
+ struct cpm_handle *cpm;
+ int ret;
+
+ info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ info->dev = dev;
+ auxiliary_set_drvdata(adev, info);
+
+ info->domain = irq_domain_create_tree(dev_fwnode(dev), &cpm_irq_domain_ops, info);
+ if (!info->domain) {
+ dev_err(dev, "Unable to add irq domain\n");
+ return -ENODEV;
+ }
+
+ ret = devm_add_action_or_reset(dev, cpm_irq_domain_remove_action, info->domain);
+ if (ret) {
+ dev_err(dev, "Failed to add irq domain removal action\n");
+ return ret;
+ }
+
+ cpm = devm_cpm_get_handle(dev);
+ if (IS_ERR(cpm))
+ return dev_err_probe(dev, PTR_ERR(cpm), "Failed to get CPM handle\n");
+
+ ret = devm_cpm_register_rx_callback(dev, cpm, CPM_AP_NS_IRQ_SERVICE,
+ cpm_irq_rx_callback, info);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to register CPM RX callback\n");
+
+ return 0;
+}
+
+static const struct auxiliary_device_id cpm_irq_id_table[] = {
+ { .name = "google_cpm_mba.irq" },
+ { },
+};
+MODULE_DEVICE_TABLE(auxiliary, cpm_irq_id_table);
+
+static struct auxiliary_driver cpm_irq_driver = {
+ .name = "cpm-irq-chip",
+ .probe = cpm_irq_probe,
+ .id_table = cpm_irq_id_table,
+};
+module_auxiliary_driver(cpm_irq_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jim Wylder <jwylder@google.com>");
+MODULE_DESCRIPTION("Google CPM IRQ chip driver");
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 7/9] arm64: dts: google: Add Laguna CPM mailbox array
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
` (5 preceding siblings ...)
2026-11-25 0:03 ` [PATCH v2 6/9] irqchip/google-cpm: Add CPM IRQ driver Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 8/9] arm64: dts: google: Add Laguna CPM node Brian Norris
2026-11-25 0:03 ` [PATCH v2 9/9] MAINTAINERS: Add entries for CPM drivers used on Tensor SoCs Brian Norris
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
These are the request and response channels used for communicating with
the Central Power Manager (CPM) found on the Google Tensor SoC known as
Laguna.
Tested-by: Peter Griffin <peter.griffin@linaro.org> (Blazer/Frankel)
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Based on WIP bindings from:
https://lore.kernel.org/all/20261023165211.v2.3.Ia186a29119b4b5c409815b755e0c2c3965b0495f@changeid/
[PATCH v2 3/4] dt-bindings: mailbox: goog-mba: Add goog-mba mailbox bindings
which is part of this series:
https://lore.kernel.org/all/20261023235408.3063350-1-dianders@chromium.org/
[PATCH v2 0/4] mailbox: Improve the mbox core then introduce the goog-mba driver
The binding is still under review, but I include this anyway to help
prove out a working solution. This patch should not be accepted until
the binding is settled.
Changes in v2:
* Move later in the series
* Add Peter's Tested-by
arch/arm64/boot/dts/google/lga.dtsi | 30 +++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/arch/arm64/boot/dts/google/lga.dtsi b/arch/arm64/boot/dts/google/lga.dtsi
index 3e670e524c4c..6ceb9ea6a100 100644
--- a/arch/arm64/boot/dts/google/lga.dtsi
+++ b/arch/arm64/boot/dts/google/lga.dtsi
@@ -365,6 +365,36 @@ soc: soc@0 {
#address-cells = <2>;
#size-cells = <2>;
+ cpm_ap_ns_mba: mailbox-array@5240000 {
+ compatible = "google,lga-mailbox-array";
+ reg = <0x0 0x05240000 0x0 0x00010000>,
+ <0x0 0x05250000 0x0 0x00010000>;
+ ranges = <0x0 0x0 0x05260000 0x00020000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ cpm_ap_ns_req_mba: mailbox@0 {
+ reg = <0x00000 0x1000>;
+ interrupts = <GIC_SPI 250 IRQ_TYPE_LEVEL_HIGH 0>;
+
+ #mbox-cells = <0>;
+
+ google,tx-payload-words = <4>;
+ google,mba-queue-mode;
+ };
+
+ cpm_ap_ns_resp_mba: mailbox@1000 {
+ reg = <0x01000 0x1000>;
+ interrupts = <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH 0>;
+
+ #mbox-cells = <0>;
+
+ google,rx-payload-words = <4>;
+ google,mba-queue-mode;
+ };
+ };
+
gic: interrupt-controller@5880000 {
compatible = "arm,gic-v3";
reg = <0x0 0x05880000 0x0 0x10000>,
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 8/9] arm64: dts: google: Add Laguna CPM node
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
` (6 preceding siblings ...)
2026-11-25 0:03 ` [PATCH v2 7/9] arm64: dts: google: Add Laguna CPM mailbox array Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
2026-11-25 0:03 ` [PATCH v2 9/9] MAINTAINERS: Add entries for CPM drivers used on Tensor SoCs Brian Norris
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
The Central Power Manager (CPM) is a co-processor on the Google Tensor
SoCs, as used on Pixel phones. CPM supports power-management and a
number of other features.
The Application Processor communicates with CPM over a pair of mailbox
channels. CPM provides clock, power-domain, reset, and interrupt
services, so we include the appropriate cell-definitions for those.
Because this also adds clock, reset, and power-domain support, we add
them to the UART node at the same time.
Note the use of dts-local headers:
- lga-lpcm.h: these are firmware IDs as defined by the CPM firmware,
for use in #reset-cells specifiers. They are not strictly a
"binding", so they don't belong in include/dt-bindings/ -- they are
used for naming documentation.
Notably, these are also used by the clock driver (where there's more
complexity, and so the firmware addressing is kept out of the device
tree), so we'll have a duplicate copy there too.
- lga-cpm-reset.h: these are also defined by the CPM firmware. We keep
them in a header here for naming documentation.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
Changes in v2:
* Rename cpm node to power-controller
* Switch to #clock-cells = <1>
* Add lga-lpcm.h instead of keeping them in dt-bindings/
* Move reset IDs to a dts-local header; these are only for naming
documentation, not really a "binding"
arch/arm64/boot/dts/google/lga-cpm-reset.h | 175 +++++++++++++++++++++
arch/arm64/boot/dts/google/lga-lpcm.h | 54 +++++++
arch/arm64/boot/dts/google/lga.dtsi | 20 +++
3 files changed, 249 insertions(+)
create mode 100644 arch/arm64/boot/dts/google/lga-cpm-reset.h
create mode 100644 arch/arm64/boot/dts/google/lga-lpcm.h
diff --git a/arch/arm64/boot/dts/google/lga-cpm-reset.h b/arch/arm64/boot/dts/google/lga-cpm-reset.h
new file mode 100644
index 000000000000..0628247ede55
--- /dev/null
+++ b/arch/arm64/boot/dts/google/lga-cpm-reset.h
@@ -0,0 +1,175 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef __DTS_GOOGLE_LGA_CPM_RESET_H
+#define __DTS_GOOGLE_LGA_CPM_RESET_H
+
+/* HSIO_N */
+#define RST_HSIO_N_PCIE_PERST 0
+#define RST_HSIO_N_PCIE_APP_HOLD_PHY 1
+#define RST_HSIO_N_PCIE_INIT 2
+#define RST_HSIO_N_PCIE_PWR_UP 3
+#define RST_HSIO_N_USB_DP_CFG 4
+#define RST_HSIO_N_DP_PCLK 5
+#define RST_HSIO_N_USB_TOP_CSR 6
+#define RST_HSIO_N_PIXEL_CK0 7
+#define RST_HSIO_N_PIXEL_CK1 8
+#define RST_HSIO_N_U2PHY_APB 9
+#define RST_HSIO_N_USBC_NON_STICKY 10
+#define RST_HSIO_N_USBC_STICKY 11
+#define RST_HSIO_N_USB_DRD_BUS 12
+#define RST_HSIO_N_USB2_PHY 13
+#define RST_HSIO_N_USB3DP_PHY 14
+#define RST_HSIO_N_EBU 15
+
+/* HSIO_S */
+#define RST_HSIO_S_PCIE_PERST 0
+#define RST_HSIO_S_PCIE_APP_HOLD_PHY 1
+#define RST_HSIO_S_PCIE_PWR_UP 2
+#define RST_HSIO_S_UFS_PHY 3
+#define RST_HSIO_S_PCIE_INIT 4
+
+/* LSIO_S */
+#define RST_LSIO_S_CLI0_I2C_IC_CFG 0
+#define RST_LSIO_S_CLI0_I3C_IC_CFG 1
+#define RST_LSIO_S_CLI0_UART_IC_CFG 2
+#define RST_LSIO_S_CLI0_SPI_IC_CFG 3
+#define RST_LSIO_S_CLI1_I2C_IC_CFG 4
+#define RST_LSIO_S_CLI1_I3C_IC_CFG 5
+#define RST_LSIO_S_CLI1_UART_IC_CFG 6
+#define RST_LSIO_S_CLI1_SPI_IC_CFG 7
+#define RST_LSIO_S_CLI2_I2C_IC_CFG 8
+#define RST_LSIO_S_CLI2_I3C_IC_CFG 9
+#define RST_LSIO_S_CLI2_UART_IC_CFG 10
+#define RST_LSIO_S_CLI2_SPI_IC_CFG 11
+#define RST_LSIO_S_CLI3_I2C_IC_CFG 12
+#define RST_LSIO_S_CLI3_I3C_IC_CFG 13
+#define RST_LSIO_S_CLI3_UART_IC_CFG 14
+#define RST_LSIO_S_CLI3_SPI_IC_CFG 15
+#define RST_LSIO_S_CLI4_I2C_IC_CFG 16
+#define RST_LSIO_S_CLI4_I3C_IC_CFG 17
+#define RST_LSIO_S_CLI4_UART_IC_CFG 18
+#define RST_LSIO_S_CLI4_SPI_IC_CFG 19
+#define RST_LSIO_S_CLI5_I2C_IC_CFG 20
+#define RST_LSIO_S_CLI5_I3C_IC_CFG 21
+#define RST_LSIO_S_CLI5_UART_IC_CFG 22
+#define RST_LSIO_S_CLI5_SPI_IC_CFG 23
+#define RST_LSIO_S_CLI6_I2C_IC_CFG 24
+#define RST_LSIO_S_CLI6_I3C_IC_CFG 25
+#define RST_LSIO_S_CLI6_UART_IC_CFG 26
+#define RST_LSIO_S_CLI6_SPI_IC_CFG 27
+#define RST_LSIO_S_CLI0_SPI_IC 28
+#define RST_LSIO_S_CLI1_SPI_IC 29
+#define RST_LSIO_S_CLI2_SPI_IC 30
+#define RST_LSIO_S_CLI3_SPI_IC 31
+#define RST_LSIO_S_CLI4_SPI_IC 32
+#define RST_LSIO_S_CLI5_SPI_IC 33
+#define RST_LSIO_S_CLI6_SPI_IC 34
+#define RST_LSIO_S_CLI0_SPI_CFG 35
+#define RST_LSIO_S_CLI1_SPI_CFG 36
+#define RST_LSIO_S_CLI2_SPI_CFG 37
+#define RST_LSIO_S_CLI3_SPI_CFG 38
+#define RST_LSIO_S_CLI4_SPI_CFG 39
+#define RST_LSIO_S_CLI5_SPI_CFG 40
+#define RST_LSIO_S_CLI6_SPI_CFG 41
+#define RST_LSIO_S_PWM_IC 42
+#define RST_LSIO_S_PWM_CFG 43
+#define RST_LSIO_S_GPIO_IC 44
+
+/* LSIO_N */
+#define RST_LSIO_N_CLI15_I2C_IC_CFG 0
+#define RST_LSIO_N_CLI15_I3C_IC_CFG 1
+#define RST_LSIO_N_CLI15_UART_IC_CFG 2
+#define RST_LSIO_N_CLI15_SPI_IC_CFG 3
+#define RST_LSIO_N_CLI16_I2C_IC_CFG 4
+#define RST_LSIO_N_CLI16_I3C_IC_CFG 5
+#define RST_LSIO_N_CLI16_UART_IC_CFG 6
+#define RST_LSIO_N_CLI16_SPI_IC_CFG 7
+#define RST_LSIO_N_CLI17_INT0_I2C_IC_CFG 8
+#define RST_LSIO_N_CLI17_INT0_I3C_IC_CFG 9
+#define RST_LSIO_N_CLI17_INT0_UART_IC_CFG 10
+#define RST_LSIO_N_CLI17_INT0_SPI_IC_CFG 11
+#define RST_LSIO_N_CLI18_INT1_I2C_IC_CFG 12
+#define RST_LSIO_N_CLI18_INT1_I3C_IC_CFG 13
+#define RST_LSIO_N_CLI18_INT1_UART_IC_CFG 14
+#define RST_LSIO_N_CLI18_INT1_SPI_IC_CFG 15
+#define RST_LSIO_N_CLI19_INT2_I2C_IC_CFG 16
+#define RST_LSIO_N_CLI19_INT2_I3C_IC_CFG 17
+#define RST_LSIO_N_CLI19_INT2_UART_IC_CFG 18
+#define RST_LSIO_N_CLI19_INT2_SPI_IC_CFG 19
+#define RST_LSIO_N_CLI20_INT3_I2C_IC_CFG 20
+#define RST_LSIO_N_CLI20_INT3_I3C_IC_CFG 21
+#define RST_LSIO_N_CLI20_INT3_UART_IC_CFG 22
+#define RST_LSIO_N_CLI20_INT3_SPI_IC_CFG 23
+#define RST_LSIO_N_CLI21_INT4_I2C_IC_CFG 24
+#define RST_LSIO_N_CLI21_INT4_I3C_IC_CFG 25
+#define RST_LSIO_N_CLI21_INT4_UART_IC_CFG 26
+#define RST_LSIO_N_CLI21_INT4_SPI_IC_CFG 27
+#define RST_LSIO_N_CLI15_SPI_IC 28
+#define RST_LSIO_N_CLI16_SPI_IC 29
+#define RST_LSIO_N_CLI17_INT0_SPI_IC 30
+#define RST_LSIO_N_CLI18_INT1_SPI_IC 31
+#define RST_LSIO_N_CLI19_INT2_SPI_IC 32
+#define RST_LSIO_N_CLI20_INT3_SPI_IC 33
+#define RST_LSIO_N_CLI21_INT4_SPI_IC 34
+#define RST_LSIO_N_CLI15_SPI_CFG 35
+#define RST_LSIO_N_CLI16_SPI_CFG 36
+#define RST_LSIO_N_CLI17_INT0_SPI_CFG 37
+#define RST_LSIO_N_CLI18_INT1_SPI_CFG 38
+#define RST_LSIO_N_CLI19_INT2_SPI_CFG 39
+#define RST_LSIO_N_CLI20_INT3_SPI_CFG 40
+#define RST_LSIO_N_CLI21_INT4_SPI_CFG 41
+#define RST_LSIO_N_GPIO_IC 42
+
+/* LSIO_E */
+#define RST_LSIO_E_CLI7_I2C_IC_CFG 0
+#define RST_LSIO_E_CLI7_I3C_IC_CFG 1
+#define RST_LSIO_E_CLI7_UART_IC_CFG 2
+#define RST_LSIO_E_CLI7_SPI_IC_CFG 3
+#define RST_LSIO_E_CLI8_I2C_IC_CFG 4
+#define RST_LSIO_E_CLI8_I3C_IC_CFG 5
+#define RST_LSIO_E_CLI8_UART_IC_CFG 6
+#define RST_LSIO_E_CLI8_SPI_IC_CFG 7
+#define RST_LSIO_E_CLI9_I2C_IC_CFG 8
+#define RST_LSIO_E_CLI9_I3C_IC_CFG 9
+#define RST_LSIO_E_CLI9_UART_IC_CFG 10
+#define RST_LSIO_E_CLI9_SPI_IC_CFG 11
+#define RST_LSIO_E_CLI10_I2C_IC_CFG 12
+#define RST_LSIO_E_CLI10_I3C_IC_CFG 13
+#define RST_LSIO_E_CLI10_UART_IC_CFG 14
+#define RST_LSIO_E_CLI10_SPI_IC_CFG 15
+#define RST_LSIO_E_CLI11_I2C_IC_CFG 16
+#define RST_LSIO_E_CLI11_I3C_IC_CFG 17
+#define RST_LSIO_E_CLI11_UART_IC_CFG 18
+#define RST_LSIO_E_CLI11_SPI_IC_CFG 19
+#define RST_LSIO_E_CLI12_I2C_IC_CFG 20
+#define RST_LSIO_E_CLI12_I3C_IC_CFG 21
+#define RST_LSIO_E_CLI12_UART_IC_CFG 22
+#define RST_LSIO_E_CLI12_SPI_IC_CFG 23
+#define RST_LSIO_E_CLI13_I2C_IC_CFG 24
+#define RST_LSIO_E_CLI13_I3C_IC_CFG 25
+#define RST_LSIO_E_CLI13_UART_IC_CFG 26
+#define RST_LSIO_E_CLI13_SPI_IC_CFG 27
+#define RST_LSIO_E_CLI14_I2C_IC_CFG 28
+#define RST_LSIO_E_CLI14_I3C_IC_CFG 29
+#define RST_LSIO_E_CLI14_UART_IC_CFG 30
+#define RST_LSIO_E_CLI14_SPI_IC_CFG 31
+#define RST_LSIO_E_CLI7_SPI_IC 32
+#define RST_LSIO_E_CLI8_SPI_IC 33
+#define RST_LSIO_E_CLI9_SPI_IC 34
+#define RST_LSIO_E_CLI10_SPI_IC 35
+#define RST_LSIO_E_CLI11_SPI_IC 36
+#define RST_LSIO_E_CLI12_SPI_IC 37
+#define RST_LSIO_E_CLI13_SPI_IC 38
+#define RST_LSIO_E_CLI14_SPI_IC 39
+#define RST_LSIO_E_CLI7_SPI_CFG 40
+#define RST_LSIO_E_CLI8_SPI_CFG 41
+#define RST_LSIO_E_CLI9_SPI_CFG 42
+#define RST_LSIO_E_CLI10_SPI_CFG 43
+#define RST_LSIO_E_CLI11_SPI_CFG 44
+#define RST_LSIO_E_CLI12_SPI_CFG 45
+#define RST_LSIO_E_CLI13_SPI_CFG 46
+#define RST_LSIO_E_CLI14_SPI_CFG 47
+#define RST_LSIO_E_GPIO_IC 48
+#define RST_LSIO_E_SPMI 49
+
+#endif /* __DTS_GOOGLE_LGA_CPM_RESET_H */
diff --git a/arch/arm64/boot/dts/google/lga-lpcm.h b/arch/arm64/boot/dts/google/lga-lpcm.h
new file mode 100644
index 000000000000..4180c1f0175f
--- /dev/null
+++ b/arch/arm64/boot/dts/google/lga-lpcm.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef __DTS_GOOGLE_LGA_LPCM_H
+#define __DTS_GOOGLE_LGA_LPCM_H
+
+/*
+ * LPCM IDs of each SSWRP.
+ */
+#define LPCM_CPM 0
+#define LPCM_AOC 1
+#define LPCM_LSIO_E 2
+#define LPCM_LSIO_N 3
+#define LPCM_LSIO_S 4
+#define LPCM_HSIO_N 5
+#define LPCM_HSIO_S 6
+#define LPCM_GPCA 7
+#define LPCM_FABHBW 8
+#define LPCM_MEMSS 9
+#define LPCM_FABMED 10
+#define LPCM_FABRT 11
+#define LPCM_FABSTBY 12
+#define LPCM_FABSYSS 13
+#define LPCM_CPU 14
+#define LPCM_CPU_MAIN 15
+#define LPCM_CPU_CCM0 16
+#define LPCM_CPU_CCM1A 17
+#define LPCM_CPU_CCM1B 18
+#define LPCM_CPU_CCM2 19
+#define LPCM_EH 20
+#define LPCM_AURORA 21
+#define LPCM_CODEC_3P 22
+#define LPCM_G2D 23
+#define LPCM_GSW 24
+#define LPCM_ISPBE 25
+#define LPCM_ISPFE 26
+#define LPCM_INF_TCU 27
+#define LPCM_GPU 28
+#define LPCM_GPU_REMOTE_FLL 29
+#define LPCM_GPU_REMOTE_SENSOR 30
+#define LPCM_TPU 31
+#define LPCM_TPU_REMOTE 32
+#define LPCM_BMSM 33
+#define LPCM_CPUACC 34
+#define LPCM_DPU 35
+#define LPCM_GDMC 36
+#define LPCM_GMC0 37
+#define LPCM_GMC1 38
+#define LPCM_GMC2 39
+#define LPCM_GMC3 40
+#define LPCM_GPCM 41
+#define LPCM_GPDMA 42
+#define LPCM_GSA 43
+
+#endif /* __DTS_GOOGLE_LGA_LPCM_H */
diff --git a/arch/arm64/boot/dts/google/lga.dtsi b/arch/arm64/boot/dts/google/lga.dtsi
index 6ceb9ea6a100..5213745b9366 100644
--- a/arch/arm64/boot/dts/google/lga.dtsi
+++ b/arch/arm64/boot/dts/google/lga.dtsi
@@ -7,8 +7,13 @@
/dts-v1/;
+#include <dt-bindings/clock/google,lga-cpm.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/power/google,lga-cpm.h>
+
+#include "lga-cpm-reset.h"
+#include "lga-lpcm.h"
/ {
#address-cells = <2>;
@@ -356,6 +361,16 @@ abl@be000000 {
};
};
+ cpm: power-controller {
+ compatible = "google,lga-cpm";
+ #clock-cells = <1>;
+ #power-domain-cells = <1>;
+ #reset-cells = <2>;
+ interrupt-controller;
+ #interrupt-cells = <1>;
+ mboxes = <&cpm_ap_ns_req_mba>, <&cpm_ap_ns_resp_mba>;
+ };
+
soc: soc@0 {
compatible = "simple-bus";
ranges = <0x0 0x0 0x0 0x0 0x10 0x0>;
@@ -423,9 +438,14 @@ lsion_cli16_uart: serial@db62000 {
reg = <0x0 0x0db62000 0x0 0x100>;
clock-frequency = <200000000>;
+ clocks = <&cpm CLK_LSIO_N_CLI16_UART>,
+ <&cpm CLK_LSIO_N_CLI16_CFG>;
+ clock-names = "baudclk", "apb_pclk";
interrupts = <GIC_SPI 688 IRQ_TYPE_LEVEL_HIGH 0>;
+ power-domains = <&cpm PD_LSIO_N_CLI_GPIO>;
reg-io-width = <4>;
reg-shift = <2>;
+ resets = <&cpm LPCM_LSIO_N RST_LSIO_N_CLI16_UART_IC_CFG>;
status = "disabled";
};
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 9/9] MAINTAINERS: Add entries for CPM drivers used on Tensor SoCs
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
` (7 preceding siblings ...)
2026-11-25 0:03 ` [PATCH v2 8/9] arm64: dts: google: Add Laguna CPM node Brian Norris
@ 2026-11-25 0:03 ` Brian Norris
8 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2026-11-25 0:03 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Philipp Zabel, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc, Brian Norris
The Google Tensor SoC known as Laguna introduces a variety of new
drivers, with Google-designed IP. Add entries to the GOOGLE TENSOR SoC
SUPPORT entry to cover the new drivers that interface with the Central
Power Manager (CPM).
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
(no changes since v1)
MAINTAINERS | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 84b47bbc0d74..ae2b8e8e004d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11509,18 +11509,26 @@ C: irc://irc.oftc.net/pixel6-kernel-dev
F: Documentation/devicetree/bindings/clock/google,gs101-clock.yaml
F: Documentation/devicetree/bindings/mailbox/google,lga-mailbox-array.yaml
F: Documentation/devicetree/bindings/phy/google,lga-usb-phy.yaml
+F: Documentation/devicetree/bindings/power/google,*
F: Documentation/devicetree/bindings/soc/google/google,gs101-pmu-intr-gen.yaml
F: Documentation/devicetree/bindings/usb/google,lga-dwc3.yaml
F: arch/arm64/boot/dts/exynos/google/
F: arch/arm64/boot/dts/google/
+F: drivers/clk/google/
F: drivers/clk/samsung/clk-gs101.c
+F: drivers/irqchip/irq-google-*
F: drivers/mailbox/goog-mba*
F: drivers/phy/phy-google-usb.c
+F: drivers/pmdomain/google/
+F: drivers/reset/google/
+F: drivers/soc/google/
F: drivers/soc/samsung/gs101-pmu.c
F: drivers/phy/samsung/phy-gs101-ufs.c
F: drivers/usb/dwc3/dwc3-google.c
-F: include/dt-bindings/clock/google,gs101*
+F: include/dt-bindings/clock/google,*
+F: include/dt-bindings/power/google,*
F: include/linux/mailbox/goog-mba-message.h
+F: include/soc/google/
K: [gG]oogle.?[tT]ensor
GPD FAN DRIVER
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 5/9] reset: google: Add CPM reset driver
2026-11-25 0:03 ` [PATCH v2 5/9] reset: google: Add CPM reset driver Brian Norris
@ 2026-11-25 8:48 ` Philipp Zabel
2026-11-25 11:43 ` Uwe Kleine-König
0 siblings, 1 reply; 12+ messages in thread
From: Philipp Zabel @ 2026-11-25 8:48 UTC (permalink / raw)
To: Brian Norris, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Stephen Boyd, Brian Masney, Jerome Brunet, Thomas Gleixner,
Ulf Hansson, Peter Griffin
Cc: Tudor Ambarus, André Draszik, linux-arm-kernel,
linux-kernel, Radu Rendec, Jakub Głowacki, linux-clk,
Douglas Anderson, devicetree, linux-pm, Mariano Marciello,
google-soc
On Di, 2026-11-24 at 16:03 -0800, Brian Norris wrote:
> Google Tensor SoCs (used on Pixel phones) manage many resources
> (including resets) using a Central Power Manager (CPM) co-processor. We
> communicate with CPM using mailboxes, abstracted in the
> devm_cpm_get_handle(), etc., API.
>
> For posterity, I list a summary of changes made relative to the
> downstream Pixel driver:
>
> * Switch to auxiliary bus, as a child of a CPM device
>
> * Use devm more heavily
>
> * Avoid representing each reset as its own Device Tree node.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v2:
> * Rename symbols from goog_cpm_rst_* to cpm_reset_*
> * Moved shared protocol details to CPM driver
> * Remove custom reset debugfs interface and .remove callback.
> * Remove per-SoC table; we only need naive translation of firmware IDs
>
> drivers/reset/Kconfig | 1 +
> drivers/reset/Makefile | 1 +
> drivers/reset/google/Kconfig | 11 +++
> drivers/reset/google/Makefile | 2 +
> drivers/reset/google/reset-cpm.c | 154 +++++++++++++++++++++++++++++++
> 5 files changed, 169 insertions(+)
> create mode 100644 drivers/reset/google/Kconfig
> create mode 100644 drivers/reset/google/Makefile
> create mode 100644 drivers/reset/google/reset-cpm.c
>
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index 673bca1e594e..64c12b479b2c 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -475,6 +475,7 @@ config RESET_ZYNQMP
> This enables the reset controller driver for Xilinx ZynqMP SoCs.
>
> source "drivers/reset/amlogic/Kconfig"
> +source "drivers/reset/google/Kconfig"
> source "drivers/reset/hisilicon/Kconfig"
> source "drivers/reset/realtek/Kconfig"
> source "drivers/reset/spacemit/Kconfig"
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 2fe527a7be8e..a151fe63905e 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -1,6 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
> obj-y += core.o
> obj-y += amlogic/
> +obj-y += google/
> obj-y += hisilicon/
> obj-y += realtek/
> obj-y += spacemit/
> diff --git a/drivers/reset/google/Kconfig b/drivers/reset/google/Kconfig
> new file mode 100644
> index 000000000000..38431b4f9001
> --- /dev/null
> +++ b/drivers/reset/google/Kconfig
> @@ -0,0 +1,11 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +config RESET_CPM
> + tristate "Google CPM Reset Controller"
> + depends on ARCH_GOOGLE || COMPILE_TEST
> + depends on GOOGLE_CPM_MBA
> + help
> + Driver support for reset controllers found on Google Tensor SoCs,
> + operating over the CPM mailbox interface. This allows peripheral
> + drivers to assert and deassert resets on LPCM hardware blocks.
> +
> + If unsure, say N.
> diff --git a/drivers/reset/google/Makefile b/drivers/reset/google/Makefile
> new file mode 100644
> index 000000000000..437c19459464
> --- /dev/null
> +++ b/drivers/reset/google/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +obj-$(CONFIG_RESET_CPM) += reset-cpm.o
> diff --git a/drivers/reset/google/reset-cpm.c b/drivers/reset/google/reset-cpm.c
> new file mode 100644
> index 000000000000..ef0863f25cac
> --- /dev/null
> +++ b/drivers/reset/google/reset-cpm.c
> @@ -0,0 +1,154 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Device driver to control Google SoC LPCM resets via CPM.
> + * Copyright 2023-2026 Google LLC
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> +#include <linux/container_of.h>
> +#include <linux/dev_printk.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/errno.h>
> +#include <linux/gfp_types.h>
> +#include <linux/limits.h>
> +#include <linux/mod_devicetable.h>
Please include the specific <linux/device-id/*.h> that is needed
instead of all of <linux/mod_devicetable.h>.
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/reset-controller.h>
> +#include <linux/types.h>
> +#include <soc/google/google-cpm-mba.h>
> +
> +#define ASSERT_OP_ID 0
> +#define DEASSERT_OP_ID 1
> +
> +#define CPM_RST_LPCM_ID_MASK GENMASK(31, 16)
> +#define CPM_RST_ID_MASK GENMASK(15, 0)
Why are these fields 16 bits wide when one line below it says:
> +/* Object fields are 8 bits */
> +#define CPM_RST_ID_MAX U8_MAX
> +
> +static inline unsigned long to_rstc_idx(u32 lpcm_id, u32 rst_id)
> +{
> + return FIELD_PREP(CPM_RST_LPCM_ID_MASK, lpcm_id) |
> + FIELD_PREP(CPM_RST_ID_MASK, rst_id);
> +}
> +
> +static inline u32 lpcm_from_idx(unsigned long idx)
> +{
> + return FIELD_GET(CPM_RST_LPCM_ID_MASK, idx);
> +}
> +
> +static inline u32 rst_from_idx(unsigned long idx)
> +{
> + return FIELD_GET(CPM_RST_ID_MASK, idx);
> +}
> +
> +struct cpm_reset_provider {
> + struct reset_controller_dev rcdev;
> + struct cpm_handle *cpm;
> +};
> +
> +static inline struct cpm_reset_provider *to_provider(struct reset_controller_dev *rcdev)
> +{
> + return container_of(rcdev, struct cpm_reset_provider, rcdev);
> +}
> +
> +static int cpm_reset_send_lpcm(struct reset_controller_dev *rcdev,
> + unsigned long idx, u8 opcode)
> +{
> + struct cpm_reset_provider *provider = to_provider(rcdev);
> + const struct cpm_lpcm_message msg = {
> + .cmd = LPCM_CMD_SET_RST,
> + .opcode = opcode,
> + .lpcm_id = lpcm_from_idx(idx),
> + .obj_id = rst_from_idx(idx),
> + };
> +
> + return cpm_send_lpcm_message(provider->cpm, &msg);
> +}
> +
> +static int cpm_reset_assert(struct reset_controller_dev *rcdev,
> + unsigned long idx)
> +{
> + return cpm_reset_send_lpcm(rcdev, idx, ASSERT_OP_ID);
> +}
> +
> +static int cpm_reset_deassert(struct reset_controller_dev *rcdev,
> + unsigned long idx)
> +{
> + return cpm_reset_send_lpcm(rcdev, idx, DEASSERT_OP_ID);
> +}
> +
> +static const struct reset_control_ops cpm_reset_ops = {
> + .assert = cpm_reset_assert,
> + .deassert = cpm_reset_deassert,
> +};
> +
> +static int cpm_reset_of_xlate(struct reset_controller_dev *rcdev,
> + const struct of_phandle_args *reset_spec)
> +{
> + u32 lpcm_id, rst_id;
> +
> + if (reset_spec->args_count != 2)
> + return -EINVAL;
> +
> + lpcm_id = reset_spec->args[0];
> + rst_id = reset_spec->args[1];
> +
> + if (lpcm_id > CPM_RST_ID_MAX)
This looks a bit weird.
Maybe add a CPM_LPCM_ID_MAX, directly use U8_MAX here, or rename the
constant to not include RST_ID?
> + return -EINVAL;
> + if (rst_id > CPM_RST_ID_MAX)
> + return -EINVAL;
> +
> + return to_rstc_idx(lpcm_id, rst_id);
> +}
> +
> +static int cpm_reset_probe(struct auxiliary_device *auxdev,
> + const struct auxiliary_device_id *id)
> +{
> + struct device *dev = &auxdev->dev;
> + struct cpm_reset_provider *provider;
> + int ret;
> +
> + provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL);
devm_kzalloc_obj()
> + if (!provider)
> + return -ENOMEM;
> +
> + provider->cpm = devm_cpm_get_handle(dev);
> + if (IS_ERR(provider->cpm))
> + return dev_err_probe(dev, PTR_ERR(provider->cpm),
> + "Failed to get CPM handle\n");
> +
> + provider->rcdev.dev = dev;
> + provider->rcdev.owner = THIS_MODULE;
> + provider->rcdev.of_node = dev->of_node;
> + provider->rcdev.ops = &cpm_reset_ops;
> + provider->rcdev.of_reset_n_cells = 2;
> + provider->rcdev.of_xlate = cpm_reset_of_xlate;
> +
> + ret = devm_reset_controller_register(dev, &provider->rcdev);
> + if (ret < 0) {
> + dev_err(dev, "failed to register reset controller: %d\n", ret);
dev_err_probe()
regards
Philipp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 5/9] reset: google: Add CPM reset driver
2026-11-25 8:48 ` Philipp Zabel
@ 2026-11-25 11:43 ` Uwe Kleine-König
0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2026-11-25 11:43 UTC (permalink / raw)
To: Brian Norris, Philipp Zabel
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Gleixner, Ulf Hansson,
Peter Griffin, Tudor Ambarus, André Draszik,
linux-arm-kernel, linux-kernel, Radu Rendec, Jakub Głowacki,
linux-clk, Douglas Anderson, devicetree, linux-pm,
Mariano Marciello, google-soc
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
On Wed, Nov 25, 2026 at 09:48:04AM +0100, Philipp Zabel wrote:
> > +#include <linux/mod_devicetable.h>
>
> Please include the specific <linux/device-id/*.h> that is needed
> instead of all of <linux/mod_devicetable.h>.
Or better still, rely on the bus headers to provide the needed
*_device_id structures. (That is <linux/platform_device.h> provides
of_device_id (for patch #2) and <linux/auxiliary_bus.h> provides
auxiliary_device_id and of_device_id (for patches #3 - #6)).
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-11-25 11:43 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 0:03 [PATCH v2 0/9] google: Add support for Laguna CPM Brian Norris
2026-11-25 0:03 ` [PATCH v2 1/9] dt-bindings: power: google: Add Google Tensor CPM Brian Norris
2026-11-25 0:03 ` [PATCH v2 2/9] soc: google: Add CPM over MailBox Array driver Brian Norris
2026-11-25 0:03 ` [PATCH v2 3/9] pmdomain: google: Add CPM power-domain driver Brian Norris
2026-11-25 0:03 ` [PATCH v2 4/9] clk: google: Add CPM clock driver Brian Norris
2026-11-25 0:03 ` [PATCH v2 5/9] reset: google: Add CPM reset driver Brian Norris
2026-11-25 8:48 ` Philipp Zabel
2026-11-25 11:43 ` Uwe Kleine-König
2026-11-25 0:03 ` [PATCH v2 6/9] irqchip/google-cpm: Add CPM IRQ driver Brian Norris
2026-11-25 0:03 ` [PATCH v2 7/9] arm64: dts: google: Add Laguna CPM mailbox array Brian Norris
2026-11-25 0:03 ` [PATCH v2 8/9] arm64: dts: google: Add Laguna CPM node Brian Norris
2026-11-25 0:03 ` [PATCH v2 9/9] MAINTAINERS: Add entries for CPM drivers used on Tensor SoCs Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®