From: Philipp Zabel <p.zabel@pengutronix.de>
To: Brian Norris <briannorris@chromium.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Thomas Gleixner <tglx@kernel.org>, Ulf Hansson <ulfh@kernel.org>,
Peter Griffin <peter.griffin@linaro.org>
Cc: "Tudor Ambarus" <tudor.ambarus@linaro.org>,
"André Draszik" <andre.draszik@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, "Radu Rendec" <radu@rendec.net>,
"Jakub Głowacki" <jglow@google.com>,
linux-clk@vger.kernel.org,
"Douglas Anderson" <dianders@chromium.org>,
devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
"Mariano Marciello" <mmarciello@google.com>,
google-soc@lists.linux.dev
Subject: Re: [PATCH v2 5/9] reset: google: Add CPM reset driver
Date: Wed, 25 Nov 2026 09:48:04 +0100 [thread overview]
Message-ID: <f89e293688feb3f9bcdce0f1b6fed0ee424e5cd8.camel@pengutronix.de> (raw)
In-Reply-To: <20261124160343.v2.5.I0b1ad34a718a9b5f667d2481041970ea45989dd3@changeid>
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
next prev parent reply other threads:[~2026-11-25 8:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f89e293688feb3f9bcdce0f1b6fed0ee424e5cd8.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=andre.draszik@linaro.org \
--cc=bmasney+clk@redhat.com \
--cc=briannorris@chromium.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=google-soc@lists.linux.dev \
--cc=jbrunet+clk@baylibre.com \
--cc=jglow@google.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mmarciello@google.com \
--cc=peter.griffin@linaro.org \
--cc=radu@rendec.net \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@kernel.org \
--cc=tudor.ambarus@linaro.org \
--cc=ulfh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®