* [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support
[not found] <CGME20250303145917eucas1p171f8fcccadddc035f5773f7026a281e3@eucas1p1.samsung.com>
@ 2025-03-03 14:58 ` Michal Wilczynski
2025-03-03 14:58 ` [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node Michal Wilczynski
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-03 14:58 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski
This patch series introduces and documents power management (PM) support and
the AON firmware driver for the T-Head TH1520 SoC, as used on the LicheePi 4A
board. While part of a larger effort to enable the Imagination BXM-4-64 GPU
upstream, these patches can merge independently.
Bigger series cover letter:
https://lore.kernel.org/all/20250219140239.1378758-1-m.wilczynski@samsung.com/
Michal Wilczynski (5):
dt-bindings: firmware: thead,th1520: Add support for firmware node
firmware: thead: Add AON firmware protocol driver
dt-bindings: power: Add TH1520 SoC power domains
pmdomain: thead: Add power-domain driver for TH1520
riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs
.../bindings/firmware/thead,th1520-aon.yaml | 53 ++++
MAINTAINERS | 5 +
arch/riscv/Kconfig.socs | 1 +
drivers/firmware/Kconfig | 9 +
drivers/firmware/Makefile | 1 +
drivers/firmware/thead,th1520-aon.c | 247 ++++++++++++++++++
drivers/pmdomain/Kconfig | 1 +
drivers/pmdomain/Makefile | 1 +
drivers/pmdomain/thead/Kconfig | 12 +
drivers/pmdomain/thead/Makefile | 2 +
drivers/pmdomain/thead/th1520-pm-domains.c | 209 +++++++++++++++
.../dt-bindings/power/thead,th1520-power.h | 19 ++
.../linux/firmware/thead/thead,th1520-aon.h | 200 ++++++++++++++
13 files changed, 760 insertions(+)
create mode 100644 Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
create mode 100644 drivers/firmware/thead,th1520-aon.c
create mode 100644 drivers/pmdomain/thead/Kconfig
create mode 100644 drivers/pmdomain/thead/Makefile
create mode 100644 drivers/pmdomain/thead/th1520-pm-domains.c
create mode 100644 include/dt-bindings/power/thead,th1520-power.h
create mode 100644 include/linux/firmware/thead/thead,th1520-aon.h
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
@ 2025-03-03 14:58 ` Michal Wilczynski
2025-03-03 17:42 ` Krzysztof Kozlowski
2025-03-03 14:58 ` [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver Michal Wilczynski
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-03 14:58 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski, Krzysztof Kozlowski
The kernel communicates with the E902 core through the mailbox
transport using AON firmware protocol. Add dt-bindings to document it
the dt node.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
.../bindings/firmware/thead,th1520-aon.yaml | 53 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 54 insertions(+)
create mode 100644 Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
diff --git a/Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml b/Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
new file mode 100644
index 000000000000..bbc183200400
--- /dev/null
+++ b/Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/firmware/thead,th1520-aon.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: T-HEAD TH1520 AON (Always-On) Firmware
+
+description: |
+ The Always-On (AON) subsystem in the TH1520 SoC is responsible for managing
+ low-power states, system wakeup events, and power management tasks. It is
+ designed to operate independently in a dedicated power domain, allowing it to
+ remain functional even during the SoC's deep sleep states.
+
+ At the heart of the AON subsystem is the E902, a low-power core that executes
+ firmware responsible for coordinating tasks such as power domain control,
+ clock management, and system wakeup signaling. Communication between the main
+ SoC and the AON subsystem is handled through a mailbox interface, which
+ enables message-based interactions with the AON firmware.
+
+maintainers:
+ - Michal Wilczynski <m.wilczynski@samsung.com>
+
+properties:
+ compatible:
+ const: thead,th1520-aon
+
+ mboxes:
+ maxItems: 1
+
+ mbox-names:
+ items:
+ - const: aon
+
+ "#power-domain-cells":
+ const: 1
+
+required:
+ - compatible
+ - mboxes
+ - mbox-names
+ - "#power-domain-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ aon: aon {
+ compatible = "thead,th1520-aon";
+ mboxes = <&mbox_910t 1>;
+ mbox-names = "aon";
+ #power-domain-cells = <1>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 8e0736dc2ee0..46745cfe9d1f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20427,6 +20427,7 @@ L: linux-riscv@lists.infradead.org
S: Maintained
T: git https://github.com/pdp7/linux.git
F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml
+F: Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml
F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
2025-03-03 14:58 ` [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node Michal Wilczynski
@ 2025-03-03 14:58 ` Michal Wilczynski
2025-03-06 0:04 ` kernel test robot
` (2 more replies)
2025-03-03 14:58 ` [PATCH v1 3/5] dt-bindings: power: Add TH1520 SoC power domains Michal Wilczynski
` (3 subsequent siblings)
5 siblings, 3 replies; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-03 14:58 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski
The T-Head TH1520 SoC uses an E902 co-processor running Always-On (AON)
firmware to manage power, clock, and other system resources [1]. This
patch introduces a driver implementing the AON firmware protocol,
allowing the Linux kernel to communicate with the firmware via mailbox
channels. Through an RPC-based interface, the kernel can initiate power
state transitions, update resource configurations, and perform other
AON-related tasks.
Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1]
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
MAINTAINERS | 2 +
drivers/firmware/Kconfig | 9 +
drivers/firmware/Makefile | 1 +
drivers/firmware/thead,th1520-aon.c | 247 ++++++++++++++++++
.../linux/firmware/thead/thead,th1520-aon.h | 200 ++++++++++++++
5 files changed, 459 insertions(+)
create mode 100644 drivers/firmware/thead,th1520-aon.c
create mode 100644 include/linux/firmware/thead/thead,th1520-aon.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 46745cfe9d1f..c446fed8ff96 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20433,10 +20433,12 @@ F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml
F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml
F: arch/riscv/boot/dts/thead/
F: drivers/clk/thead/clk-th1520-ap.c
+F: drivers/firmware/thead,th1520-aon.c
F: drivers/mailbox/mailbox-th1520.c
F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
F: drivers/pinctrl/pinctrl-th1520.c
F: include/dt-bindings/clock/thead,th1520-clk-ap.h
+F: include/linux/firmware/thead/thead,th1520-aon.h
RNBD BLOCK DRIVERS
M: Md. Haris Iqbal <haris.iqbal@ionos.com>
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 9f35f69e0f9e..52c145097770 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -212,6 +212,15 @@ config SYSFB_SIMPLEFB
If unsure, say Y.
+config TH1520_AON_PROTOCOL
+ tristate "Always-On firmware protocol"
+ depends on ARCH_THEAD || COMPILE_TEST
+ help
+ Power, clock, and resource management capabilities on the TH1520 SoC are
+ managed by the E902 core. Firmware running on this core communicates with
+ the kernel through the Always-On protocol, using hardware mailbox as a medium.
+ Say yes if you need such capabilities.
+
config TI_SCI_PROTOCOL
tristate "TI System Control Interface (TISCI) Message Protocol"
depends on TI_MESSAGE_MANAGER
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 7a8d486e718f..5db9c042430c 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o
obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o
obj-$(CONFIG_SYSFB) += sysfb.o
obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o
+obj-$(CONFIG_TH1520_AON_PROTOCOL) += thead,th1520-aon.o
obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o
obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o
diff --git a/drivers/firmware/thead,th1520-aon.c b/drivers/firmware/thead,th1520-aon.c
new file mode 100644
index 000000000000..48e1bd986768
--- /dev/null
+++ b/drivers/firmware/thead,th1520-aon.c
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Alibaba Group Holding Limited.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Author: Michal Wilczynski <m.wilczynski@samsung.com>
+ */
+
+#include <linux/device.h>
+#include <linux/firmware/thead/thead,th1520-aon.h>
+#include <linux/mailbox_client.h>
+#include <linux/mailbox_controller.h>
+
+#define MAX_RX_TIMEOUT (msecs_to_jiffies(3000))
+#define MAX_TX_TIMEOUT 500
+
+struct th1520_aon_chan {
+ struct mbox_chan *ch;
+ struct th1520_aon_rpc_ack_common ack_msg;
+ struct mbox_client cl;
+ struct completion done;
+
+ /* make sure only one RPC is performed at a time */
+ struct mutex transaction_lock;
+};
+
+struct th1520_aon_msg_req_set_resource_power_mode {
+ struct th1520_aon_rpc_msg_hdr hdr;
+ u16 resource;
+ u16 mode;
+ u16 reserved[10];
+} __packed __aligned(1);
+
+/*
+ * This type is used to indicate error response for most functions.
+ */
+enum th1520_aon_error_codes {
+ LIGHT_AON_ERR_NONE = 0, /* Success */
+ LIGHT_AON_ERR_VERSION = 1, /* Incompatible API version */
+ LIGHT_AON_ERR_CONFIG = 2, /* Configuration error */
+ LIGHT_AON_ERR_PARM = 3, /* Bad parameter */
+ LIGHT_AON_ERR_NOACCESS = 4, /* Permission error (no access) */
+ LIGHT_AON_ERR_LOCKED = 5, /* Permission error (locked) */
+ LIGHT_AON_ERR_UNAVAILABLE = 6, /* Unavailable (out of resources) */
+ LIGHT_AON_ERR_NOTFOUND = 7, /* Not found */
+ LIGHT_AON_ERR_NOPOWER = 8, /* No power */
+ LIGHT_AON_ERR_IPC = 9, /* Generic IPC error */
+ LIGHT_AON_ERR_BUSY = 10, /* Resource is currently busy/active */
+ LIGHT_AON_ERR_FAIL = 11, /* General I/O failure */
+ LIGHT_AON_ERR_LAST
+};
+
+static int th1520_aon_linux_errmap[LIGHT_AON_ERR_LAST] = {
+ 0, /* LIGHT_AON_ERR_NONE */
+ -EINVAL, /* LIGHT_AON_ERR_VERSION */
+ -EINVAL, /* LIGHT_AON_ERR_CONFIG */
+ -EINVAL, /* LIGHT_AON_ERR_PARM */
+ -EACCES, /* LIGHT_AON_ERR_NOACCESS */
+ -EACCES, /* LIGHT_AON_ERR_LOCKED */
+ -ERANGE, /* LIGHT_AON_ERR_UNAVAILABLE */
+ -EEXIST, /* LIGHT_AON_ERR_NOTFOUND */
+ -EPERM, /* LIGHT_AON_ERR_NOPOWER */
+ -EPIPE, /* LIGHT_AON_ERR_IPC */
+ -EBUSY, /* LIGHT_AON_ERR_BUSY */
+ -EIO, /* LIGHT_AON_ERR_FAIL */
+};
+
+static inline int th1520_aon_to_linux_errno(int errno)
+{
+ if (errno >= LIGHT_AON_ERR_NONE && errno < LIGHT_AON_ERR_LAST)
+ return th1520_aon_linux_errmap[errno];
+
+ return -EIO;
+}
+
+static void th1520_aon_rx_callback(struct mbox_client *c, void *rx_msg)
+{
+ struct th1520_aon_chan *aon_chan =
+ container_of(c, struct th1520_aon_chan, cl);
+ struct th1520_aon_rpc_msg_hdr *hdr =
+ (struct th1520_aon_rpc_msg_hdr *)rx_msg;
+ u8 recv_size = sizeof(struct th1520_aon_rpc_msg_hdr) + hdr->size;
+
+ if (recv_size != sizeof(struct th1520_aon_rpc_ack_common)) {
+ dev_err(c->dev, "Invalid ack size, not completing\n");
+ return;
+ }
+
+ memcpy(&aon_chan->ack_msg, rx_msg, recv_size);
+ complete(&aon_chan->done);
+}
+
+/**
+ * th1520_aon_call_rpc() - Send an RPC request to the TH1520 AON subsystem
+ * @aon_chan: Pointer to the AON channel structure
+ * @msg: Pointer to the message (RPC payload) that will be sent
+ *
+ * This function sends an RPC message to the TH1520 AON subsystem via mailbox.
+ * It takes the provided @msg buffer, formats it with version and service flags,
+ * then blocks until the RPC completes or times out. The completion is signaled
+ * by the `aon_chan->done` completion, which is waited upon for a duration
+ * defined by `MAX_RX_TIMEOUT`.
+ *
+ * Return:
+ * * 0 on success
+ * * -ETIMEDOUT if the RPC call times out
+ * * A negative error code if the mailbox send fails or if AON responds with
+ * a non-zero error code (converted via th1520_aon_to_linux_errno()).
+ */
+int th1520_aon_call_rpc(struct th1520_aon_chan *aon_chan, void *msg)
+{
+ struct th1520_aon_rpc_msg_hdr *hdr = msg;
+ int ret;
+
+ mutex_lock(&aon_chan->transaction_lock);
+ reinit_completion(&aon_chan->done);
+
+ RPC_SET_VER(hdr, TH1520_AON_RPC_VERSION);
+ RPC_SET_SVC_ID(hdr, hdr->svc);
+ RPC_SET_SVC_FLAG_MSG_TYPE(hdr, RPC_SVC_MSG_TYPE_DATA);
+ RPC_SET_SVC_FLAG_ACK_TYPE(hdr, RPC_SVC_MSG_NEED_ACK);
+
+ ret = mbox_send_message(aon_chan->ch, msg);
+ if (ret < 0) {
+ dev_err(aon_chan->cl.dev, "RPC send msg failed: %d\n", ret);
+ goto out;
+ }
+
+ if (!wait_for_completion_timeout(&aon_chan->done, MAX_RX_TIMEOUT)) {
+ dev_err(aon_chan->cl.dev, "RPC send msg timeout\n");
+ mutex_unlock(&aon_chan->transaction_lock);
+ return -ETIMEDOUT;
+ }
+
+ ret = aon_chan->ack_msg.err_code;
+
+out:
+ mutex_unlock(&aon_chan->transaction_lock);
+
+ return th1520_aon_to_linux_errno(ret);
+}
+EXPORT_SYMBOL_GPL(th1520_aon_call_rpc);
+
+/**
+ * th1520_aon_power_update() - Change power state of a resource via TH1520 AON
+ * @aon_chan: Pointer to the AON channel structure
+ * @rsrc: Resource ID whose power state needs to be updated
+ * @power_on: Boolean indicating whether the resource should be powered on (true)
+ * or powered off (false)
+ *
+ * This function requests the TH1520 AON subsystem to set the power mode of the
+ * given resource (@rsrc) to either on or off. It constructs the message in
+ * `struct th1520_aon_msg_req_set_resource_power_mode` and then invokes
+ * th1520_aon_call_rpc() to make the request. If the AON call fails, an error
+ * message is logged along with the specific return code.
+ *
+ * Return:
+ * * 0 on success
+ * * A negative error code in case of failures (propagated from
+ * th1520_aon_call_rpc()).
+ */
+int th1520_aon_power_update(struct th1520_aon_chan *aon_chan, u16 rsrc,
+ bool power_on)
+{
+ struct th1520_aon_msg_req_set_resource_power_mode msg = {};
+ struct th1520_aon_rpc_msg_hdr *hdr = &msg.hdr;
+ int ret;
+
+ hdr->svc = TH1520_AON_RPC_SVC_PM;
+ hdr->func = TH1520_AON_PM_FUNC_SET_RESOURCE_POWER_MODE;
+ hdr->size = TH1520_AON_RPC_MSG_NUM;
+
+ RPC_SET_BE16(&msg.resource, 0, rsrc);
+ RPC_SET_BE16(&msg.resource, 2,
+ (power_on ? TH1520_AON_PM_PW_MODE_ON :
+ TH1520_AON_PM_PW_MODE_OFF));
+
+ ret = th1520_aon_call_rpc(aon_chan, &msg);
+ if (ret)
+ dev_err(aon_chan->cl.dev, "failed to power %s resource %d ret %d\n",
+ power_on ? "up" : "off", rsrc, ret);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(th1520_aon_power_update);
+
+/**
+ * th1520_aon_init() - Initialize TH1520 AON firmware protocol interface
+ * @dev: Device pointer for the AON subsystem
+ *
+ * This function initializes the TH1520 AON firmware protocol interface by:
+ * - Allocating and initializing the AON channel structure
+ * - Setting up the mailbox client
+ * - Requesting the AON mailbox channel
+ * - Initializing synchronization primitives
+ *
+ * Return:
+ * * Valid pointer to th1520_aon_chan structure on success
+ * * ERR_PTR(-ENOMEM) if memory allocation fails
+ * * ERR_PTR() with other negative error codes from mailbox operations
+ */
+struct th1520_aon_chan *th1520_aon_init(struct device *dev)
+{
+ struct th1520_aon_chan *aon_chan;
+ struct mbox_client *cl;
+
+ aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
+ if (!aon_chan)
+ return ERR_PTR(-ENOMEM);
+
+ cl = &aon_chan->cl;
+ cl->dev = dev;
+ cl->tx_block = true;
+ cl->tx_tout = MAX_TX_TIMEOUT;
+ cl->rx_callback = th1520_aon_rx_callback;
+
+ aon_chan->ch = mbox_request_channel_byname(cl, "aon");
+ if (IS_ERR(aon_chan->ch)) {
+ dev_err(dev, "Failed to request aon mbox chan\n");
+ kfree(aon_chan);
+ return ERR_CAST(aon_chan->ch);
+ }
+
+ mutex_init(&aon_chan->transaction_lock);
+ init_completion(&aon_chan->done);
+
+ return aon_chan;
+}
+EXPORT_SYMBOL_GPL(th1520_aon_init);
+
+/**
+ * th1520_aon_deinit() - Clean up TH1520 AON firmware protocol interface
+ * @aon_chan: Pointer to the AON channel structure to clean up
+ *
+ * This function cleans up resources allocated by th1520_aon_init():
+ * - Frees the mailbox channel
+ * - Frees the AON channel
+ */
+void th1520_aon_deinit(struct th1520_aon_chan *aon_chan)
+{
+ mbox_free_channel(aon_chan->ch);
+ kfree(aon_chan);
+}
+EXPORT_SYMBOL_GPL(th1520_aon_deinit);
+
+MODULE_AUTHOR("Michal Wilczynski <m.wilczynski@samsung.com>");
+MODULE_DESCRIPTION("T-HEAD TH1520 Always-On firmware protocol library");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/firmware/thead/thead,th1520-aon.h b/include/linux/firmware/thead/thead,th1520-aon.h
new file mode 100644
index 000000000000..dae132b66873
--- /dev/null
+++ b/include/linux/firmware/thead/thead,th1520-aon.h
@@ -0,0 +1,200 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 Alibaba Group Holding Limited.
+ */
+
+#ifndef _THEAD_AON_H
+#define _THEAD_AON_H
+
+#include <linux/device.h>
+#include <linux/types.h>
+
+#define AON_RPC_MSG_MAGIC (0xef)
+#define TH1520_AON_RPC_VERSION 2
+#define TH1520_AON_RPC_MSG_NUM 7
+
+struct th1520_aon_chan;
+
+enum th1520_aon_rpc_svc {
+ TH1520_AON_RPC_SVC_UNKNOWN = 0,
+ TH1520_AON_RPC_SVC_PM = 1,
+ TH1520_AON_RPC_SVC_MISC = 2,
+ TH1520_AON_RPC_SVC_AVFS = 3,
+ TH1520_AON_RPC_SVC_SYS = 4,
+ TH1520_AON_RPC_SVC_WDG = 5,
+ TH1520_AON_RPC_SVC_LPM = 6,
+ TH1520_AON_RPC_SVC_MAX = 0x3F,
+};
+
+enum th1520_aon_misc_func {
+ TH1520_AON_MISC_FUNC_UNKNOWN = 0,
+ TH1520_AON_MISC_FUNC_SET_CONTROL = 1,
+ TH1520_AON_MISC_FUNC_GET_CONTROL = 2,
+ TH1520_AON_MISC_FUNC_REGDUMP_CFG = 3,
+};
+
+enum th1520_aon_wdg_func {
+ TH1520_AON_WDG_FUNC_UNKNOWN = 0,
+ TH1520_AON_WDG_FUNC_START = 1,
+ TH1520_AON_WDG_FUNC_STOP = 2,
+ TH1520_AON_WDG_FUNC_PING = 3,
+ TH1520_AON_WDG_FUNC_TIMEOUTSET = 4,
+ TH1520_AON_WDG_FUNC_RESTART = 5,
+ TH1520_AON_WDG_FUNC_GET_STATE = 6,
+ TH1520_AON_WDG_FUNC_POWER_OFF = 7,
+ TH1520_AON_WDG_FUNC_AON_WDT_ON = 8,
+ TH1520_AON_WDG_FUNC_AON_WDT_OFF = 9,
+};
+
+enum th1520_aon_sys_func {
+ TH1520_AON_SYS_FUNC_UNKNOWN = 0,
+ TH1520_AON_SYS_FUNC_AON_RESERVE_MEM = 1,
+};
+
+enum th1520_aon_lpm_func {
+ TH1520_AON_LPM_FUNC_UNKNOWN = 0,
+ TH1520_AON_LPM_FUNC_REQUIRE_STR = 1,
+ TH1520_AON_LPM_FUNC_RESUME_STR = 2,
+ TH1520_AON_LPM_FUNC_REQUIRE_STD = 3,
+ TH1520_AON_LPM_FUNC_CPUHP = 4,
+ TH1520_AON_LPM_FUNC_REGDUMP_CFG = 5,
+};
+
+enum th1520_aon_pm_func {
+ TH1520_AON_PM_FUNC_UNKNOWN = 0,
+ TH1520_AON_PM_FUNC_SET_RESOURCE_REGULATOR = 1,
+ TH1520_AON_PM_FUNC_GET_RESOURCE_REGULATOR = 2,
+ TH1520_AON_PM_FUNC_SET_RESOURCE_POWER_MODE = 3,
+ TH1520_AON_PM_FUNC_PWR_SET = 4,
+ TH1520_AON_PM_FUNC_PWR_GET = 5,
+ TH1520_AON_PM_FUNC_CHECK_FAULT = 6,
+ TH1520_AON_PM_FUNC_GET_TEMPERATURE = 7,
+};
+
+struct th1520_aon_rpc_msg_hdr {
+ u8 ver; /* version of msg hdr */
+ u8 size; /* msg size ,uinit in bytes,the size includes rpc msg header self */
+ u8 svc; /* rpc main service id */
+ u8 func; /* rpc sub func id of specific service, sent by caller */
+} __packed __aligned(1);
+
+struct th1520_aon_rpc_ack_common {
+ struct th1520_aon_rpc_msg_hdr hdr;
+ u8 err_code;
+} __packed __aligned(1);
+
+#define RPC_SVC_MSG_TYPE_DATA 0
+#define RPC_SVC_MSG_TYPE_ACK 1
+#define RPC_SVC_MSG_NEED_ACK 0
+#define RPC_SVC_MSG_NO_NEED_ACK 1
+
+#define RPC_GET_VER(MESG) ((MESG)->ver)
+#define RPC_SET_VER(MESG, VER) ((MESG)->ver = (VER))
+#define RPC_GET_SVC_ID(MESG) ((MESG)->svc & 0x3F)
+#define RPC_SET_SVC_ID(MESG, ID) ((MESG)->svc |= 0x3F & (ID))
+#define RPC_GET_SVC_FLAG_MSG_TYPE(MESG) (((MESG)->svc & 0x80) >> 7)
+#define RPC_SET_SVC_FLAG_MSG_TYPE(MESG, TYPE) ((MESG)->svc |= (TYPE) << 7)
+#define RPC_GET_SVC_FLAG_ACK_TYPE(MESG) (((MESG)->svc & 0x40) >> 6)
+#define RPC_SET_SVC_FLAG_ACK_TYPE(MESG, ACK) ((MESG)->svc |= (ACK) << 6)
+
+#define RPC_SET_BE64(MESG, OFFSET, SET_DATA) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ u64 _offset = (OFFSET); \
+ u64 _set_data = (SET_DATA); \
+ data[_offset + 7] = _set_data & 0xFF; \
+ data[_offset + 6] = (_set_data & 0xFF00) >> 8; \
+ data[_offset + 5] = (_set_data & 0xFF0000) >> 16; \
+ data[_offset + 4] = (_set_data & 0xFF000000) >> 24; \
+ data[_offset + 3] = (_set_data & 0xFF00000000) >> 32; \
+ data[_offset + 2] = (_set_data & 0xFF0000000000) >> 40; \
+ data[_offset + 1] = (_set_data & 0xFF000000000000) >> 48; \
+ data[_offset + 0] = (_set_data & 0xFF00000000000000) >> 56; \
+ } while (0)
+
+#define RPC_SET_BE32(MESG, OFFSET, SET_DATA) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ u64 _offset = (OFFSET); \
+ u64 _set_data = (SET_DATA); \
+ data[_offset + 3] = (_set_data) & 0xFF; \
+ data[_offset + 2] = (_set_data & 0xFF00) >> 8; \
+ data[_offset + 1] = (_set_data & 0xFF0000) >> 16; \
+ data[_offset + 0] = (_set_data & 0xFF000000) >> 24; \
+ } while (0)
+
+#define RPC_SET_BE16(MESG, OFFSET, SET_DATA) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ u64 _offset = (OFFSET); \
+ u64 _set_data = (SET_DATA); \
+ data[_offset + 1] = (_set_data) & 0xFF; \
+ data[_offset + 0] = (_set_data & 0xFF00) >> 8; \
+ } while (0)
+
+#define RPC_SET_U8(MESG, OFFSET, SET_DATA) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ data[OFFSET] = (SET_DATA) & 0xFF; \
+ } while (0)
+
+#define RPC_GET_BE64(MESG, OFFSET, PTR) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ u64 _offset = (OFFSET); \
+ *(u32 *)(PTR) = \
+ (data[_offset + 7] | data[_offset + 6] << 8 | \
+ data[_offset + 5] << 16 | data[_offset + 4] << 24 | \
+ data[_offset + 3] << 32 | data[_offset + 2] << 40 | \
+ data[_offset + 1] << 48 | data[_offset + 0] << 56); \
+ } while (0)
+
+#define RPC_GET_BE32(MESG, OFFSET, PTR) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ u64 _offset = (OFFSET); \
+ *(u32 *)(PTR) = \
+ (data[_offset + 3] | data[_offset + 2] << 8 | \
+ data[_offset + 1] << 16 | data[_offset + 0] << 24); \
+ } while (0)
+
+#define RPC_GET_BE16(MESG, OFFSET, PTR) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ u64 _offset = (OFFSET); \
+ *(u16 *)(PTR) = (data[_offset + 1] | data[_offset + 0] << 8); \
+ } while (0)
+
+#define RPC_GET_U8(MESG, OFFSET, PTR) \
+ do { \
+ u8 *data = (u8 *)(MESG); \
+ *(u8 *)(PTR) = (data[OFFSET]); \
+ } while (0)
+
+/*
+ * Defines for SC PM Power Mode
+ */
+#define TH1520_AON_PM_PW_MODE_OFF 0 /* Power off */
+#define TH1520_AON_PM_PW_MODE_STBY 1 /* Power in standby */
+#define TH1520_AON_PM_PW_MODE_LP 2 /* Power in low-power */
+#define TH1520_AON_PM_PW_MODE_ON 3 /* Power on */
+
+/*
+ * Defines for AON power islands
+ */
+#define TH1520_AON_AUDIO_PD 0
+#define TH1520_AON_VDEC_PD 1
+#define TH1520_AON_NPU_PD 2
+#define TH1520_AON_VENC_PD 3
+#define TH1520_AON_GPU_PD 4
+#define TH1520_AON_DSP0_PD 5
+#define TH1520_AON_DSP1_PD 6
+
+struct th1520_aon_chan *th1520_aon_init(struct device *dev);
+void th1520_aon_deinit(struct th1520_aon_chan *aon_chan);
+
+int th1520_aon_call_rpc(struct th1520_aon_chan *aon_chan, void *msg);
+int th1520_aon_power_update(struct th1520_aon_chan *aon_chan, u16 rsrc,
+ bool power_on);
+
+#endif /* _THEAD_AON_H */
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 3/5] dt-bindings: power: Add TH1520 SoC power domains
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
2025-03-03 14:58 ` [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node Michal Wilczynski
2025-03-03 14:58 ` [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver Michal Wilczynski
@ 2025-03-03 14:58 ` Michal Wilczynski
2025-03-03 14:59 ` [PATCH v1 4/5] pmdomain: thead: Add power-domain driver for TH1520 Michal Wilczynski
` (2 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-03 14:58 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski, Krzysztof Kozlowski
Add power domain ID's for the TH1520 SoC power domains.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
MAINTAINERS | 1 +
.../dt-bindings/power/thead,th1520-power.h | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 include/dt-bindings/power/thead,th1520-power.h
diff --git a/MAINTAINERS b/MAINTAINERS
index c446fed8ff96..b2b32e431f35 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20438,6 +20438,7 @@ F: drivers/mailbox/mailbox-th1520.c
F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
F: drivers/pinctrl/pinctrl-th1520.c
F: include/dt-bindings/clock/thead,th1520-clk-ap.h
+F: include/dt-bindings/power/thead,th1520-power.h
F: include/linux/firmware/thead/thead,th1520-aon.h
RNBD BLOCK DRIVERS
diff --git a/include/dt-bindings/power/thead,th1520-power.h b/include/dt-bindings/power/thead,th1520-power.h
new file mode 100644
index 000000000000..8395bd1459f3
--- /dev/null
+++ b/include/dt-bindings/power/thead,th1520-power.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2022 Alibaba Group Holding Limited.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Author: Michal Wilczynski <m.wilczynski@samsung.com>
+ */
+
+#ifndef __DT_BINDINGS_POWER_TH1520_H
+#define __DT_BINDINGS_POWER_TH1520_H
+
+#define TH1520_AUDIO_PD 0
+#define TH1520_VDEC_PD 1
+#define TH1520_NPU_PD 2
+#define TH1520_VENC_PD 3
+#define TH1520_GPU_PD 4
+#define TH1520_DSP0_PD 5
+#define TH1520_DSP1_PD 6
+
+#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 4/5] pmdomain: thead: Add power-domain driver for TH1520
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
` (2 preceding siblings ...)
2025-03-03 14:58 ` [PATCH v1 3/5] dt-bindings: power: Add TH1520 SoC power domains Michal Wilczynski
@ 2025-03-03 14:59 ` Michal Wilczynski
2025-03-03 14:59 ` [PATCH v1 5/5] riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs Michal Wilczynski
2025-03-05 8:04 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
5 siblings, 0 replies; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-03 14:59 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski
The T-Head TH1520 SoC contains multiple power islands that can be
programmatically turned on and off using the AON (Always-On) protocol
and a hardware mailbox [1]. The relevant mailbox driver has already been
merged into the mainline kernel in commit 5d4d263e1c6b ("mailbox:
Introduce support for T-head TH1520 Mailbox driver");
Introduce a power-domain driver for the TH1520 SoC, which is using AON
firmware protocol to communicate with E902 core through the hardware
mailbox. This way it can send power on/off commands to the E902 core.
The interaction with AUDIO power island e.g trying to turn it OFF proved
to crash the firmware running on the E902 core. Introduce the workaround
to disable interacting with the power island.
Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1]
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
MAINTAINERS | 1 +
drivers/pmdomain/Kconfig | 1 +
drivers/pmdomain/Makefile | 1 +
drivers/pmdomain/thead/Kconfig | 12 ++
drivers/pmdomain/thead/Makefile | 2 +
drivers/pmdomain/thead/th1520-pm-domains.c | 209 +++++++++++++++++++++
6 files changed, 226 insertions(+)
create mode 100644 drivers/pmdomain/thead/Kconfig
create mode 100644 drivers/pmdomain/thead/Makefile
create mode 100644 drivers/pmdomain/thead/th1520-pm-domains.c
diff --git a/MAINTAINERS b/MAINTAINERS
index b2b32e431f35..e240602f0931 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20437,6 +20437,7 @@ F: drivers/firmware/thead,th1520-aon.c
F: drivers/mailbox/mailbox-th1520.c
F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
F: drivers/pinctrl/pinctrl-th1520.c
+F: drivers/pmdomain/thead/
F: include/dt-bindings/clock/thead,th1520-clk-ap.h
F: include/dt-bindings/power/thead,th1520-power.h
F: include/linux/firmware/thead/thead,th1520-aon.h
diff --git a/drivers/pmdomain/Kconfig b/drivers/pmdomain/Kconfig
index 23c64851a5b0..91f04ace35d4 100644
--- a/drivers/pmdomain/Kconfig
+++ b/drivers/pmdomain/Kconfig
@@ -16,6 +16,7 @@ source "drivers/pmdomain/st/Kconfig"
source "drivers/pmdomain/starfive/Kconfig"
source "drivers/pmdomain/sunxi/Kconfig"
source "drivers/pmdomain/tegra/Kconfig"
+source "drivers/pmdomain/thead/Kconfig"
source "drivers/pmdomain/ti/Kconfig"
source "drivers/pmdomain/xilinx/Kconfig"
diff --git a/drivers/pmdomain/Makefile b/drivers/pmdomain/Makefile
index a68ece2f4c68..7030f44a49df 100644
--- a/drivers/pmdomain/Makefile
+++ b/drivers/pmdomain/Makefile
@@ -14,6 +14,7 @@ obj-y += st/
obj-y += starfive/
obj-y += sunxi/
obj-y += tegra/
+obj-y += thead/
obj-y += ti/
obj-y += xilinx/
obj-y += core.o governor.o
diff --git a/drivers/pmdomain/thead/Kconfig b/drivers/pmdomain/thead/Kconfig
new file mode 100644
index 000000000000..c7a1ac0c61dc
--- /dev/null
+++ b/drivers/pmdomain/thead/Kconfig
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config TH1520_PM_DOMAINS
+ tristate "Support TH1520 Power Domains"
+ depends on TH1520_AON_PROTOCOL || !TH1520_AON_PROTOCOL
+ select REGMAP_MMIO
+ help
+ This driver enables power domain management for the T-HEAD
+ TH-1520 SoC. On this SoC there are number of power domains,
+ which can be managed independently. For example GPU, NPU,
+ and DPU reside in their own power domains which can be
+ turned on/off.
diff --git a/drivers/pmdomain/thead/Makefile b/drivers/pmdomain/thead/Makefile
new file mode 100644
index 000000000000..adfdf5479c68
--- /dev/null
+++ b/drivers/pmdomain/thead/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_TH1520_PM_DOMAINS) += th1520-pm-domains.o
diff --git a/drivers/pmdomain/thead/th1520-pm-domains.c b/drivers/pmdomain/thead/th1520-pm-domains.c
new file mode 100644
index 000000000000..7c78cf3955d2
--- /dev/null
+++ b/drivers/pmdomain/thead/th1520-pm-domains.c
@@ -0,0 +1,209 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Alibaba Group Holding Limited.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Author: Michal Wilczynski <m.wilczynski@samsung.com>
+ */
+
+#include <linux/firmware/thead/thead,th1520-aon.h>
+#include <linux/slab.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
+
+#include <dt-bindings/power/thead,th1520-power.h>
+
+struct th1520_power_domain {
+ struct th1520_aon_chan *aon_chan;
+ struct generic_pm_domain genpd;
+ u32 rsrc;
+};
+
+struct th1520_power_info {
+ const char *name;
+ u32 rsrc;
+ bool disabled;
+};
+
+/*
+ * The AUDIO power domain is marked as disabled to prevent the driver from
+ * managing its power state. Direct AON firmware calls to control this power
+ * island trigger a firmware bug causing system instability. Until this
+ * firmware issue is resolved, the AUDIO power domain must remain disabled
+ * to avoid crashes.
+ */
+static const struct th1520_power_info th1520_pd_ranges[] = {
+ [TH1520_AUDIO_PD] = {"audio", TH1520_AON_AUDIO_PD, true },
+ [TH1520_VDEC_PD] = { "vdec", TH1520_AON_VDEC_PD, false },
+ [TH1520_NPU_PD] = { "npu", TH1520_AON_NPU_PD, false },
+ [TH1520_VENC_PD] = { "venc", TH1520_AON_VENC_PD, false },
+ [TH1520_GPU_PD] = { "gpu", TH1520_AON_GPU_PD, false },
+ [TH1520_DSP0_PD] = { "dsp0", TH1520_AON_DSP0_PD, false },
+ [TH1520_DSP1_PD] = { "dsp1", TH1520_AON_DSP1_PD, false }
+};
+
+static inline struct th1520_power_domain *
+to_th1520_power_domain(struct generic_pm_domain *genpd)
+{
+ return container_of(genpd, struct th1520_power_domain, genpd);
+}
+
+static int th1520_pd_power_on(struct generic_pm_domain *domain)
+{
+ struct th1520_power_domain *pd = to_th1520_power_domain(domain);
+
+ return th1520_aon_power_update(pd->aon_chan, pd->rsrc, true);
+}
+
+static int th1520_pd_power_off(struct generic_pm_domain *domain)
+{
+ struct th1520_power_domain *pd = to_th1520_power_domain(domain);
+
+ return th1520_aon_power_update(pd->aon_chan, pd->rsrc, false);
+}
+
+static struct generic_pm_domain *th1520_pd_xlate(const struct of_phandle_args *spec,
+ void *data)
+{
+ struct generic_pm_domain *domain = ERR_PTR(-ENOENT);
+ struct genpd_onecell_data *pd_data = data;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(th1520_pd_ranges); i++) {
+ struct th1520_power_domain *pd;
+
+ if (th1520_pd_ranges[i].disabled)
+ continue;
+
+ pd = to_th1520_power_domain(pd_data->domains[i]);
+ if (pd->rsrc == spec->args[0]) {
+ domain = &pd->genpd;
+ break;
+ }
+ }
+
+ return domain;
+}
+
+static struct th1520_power_domain *
+th1520_add_pm_domain(struct device *dev, const struct th1520_power_info *pi)
+{
+ struct th1520_power_domain *pd;
+ int ret;
+
+ pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return ERR_PTR(-ENOMEM);
+
+ pd->rsrc = pi->rsrc;
+ pd->genpd.power_on = th1520_pd_power_on;
+ pd->genpd.power_off = th1520_pd_power_off;
+ pd->genpd.name = pi->name;
+
+ ret = pm_genpd_init(&pd->genpd, NULL, true);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return pd;
+}
+
+static void th1520_pd_init_all_off(struct generic_pm_domain **domains,
+ struct device *dev)
+{
+ int ret;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(th1520_pd_ranges); i++) {
+ struct th1520_power_domain *pd;
+
+ if (th1520_pd_ranges[i].disabled)
+ continue;
+
+ pd = to_th1520_power_domain(domains[i]);
+
+ ret = th1520_aon_power_update(pd->aon_chan, pd->rsrc, false);
+ if (ret)
+ dev_err(dev,
+ "Failed to initially power down power domain %s\n",
+ pd->genpd.name);
+ }
+}
+
+static int th1520_pd_probe(struct platform_device *pdev)
+{
+ struct generic_pm_domain **domains;
+ struct genpd_onecell_data *pd_data;
+ struct th1520_aon_chan *aon_chan;
+ struct device *dev = &pdev->dev;
+ int i;
+
+ aon_chan = th1520_aon_init(dev);
+ if (IS_ERR(aon_chan))
+ return dev_err_probe(dev, PTR_ERR(aon_chan),
+ "Failed to get AON channel\n");
+
+ platform_set_drvdata(pdev, aon_chan);
+
+ domains = devm_kcalloc(dev, ARRAY_SIZE(th1520_pd_ranges),
+ sizeof(*domains), GFP_KERNEL);
+ if (!domains)
+ return -ENOMEM;
+
+ pd_data = devm_kzalloc(dev, sizeof(*pd_data), GFP_KERNEL);
+ if (!pd_data)
+ return -ENOMEM;
+
+ for (i = 0; i < ARRAY_SIZE(th1520_pd_ranges); i++) {
+ struct th1520_power_domain *pd;
+
+ if (th1520_pd_ranges[i].disabled)
+ continue;
+
+ pd = th1520_add_pm_domain(dev, &th1520_pd_ranges[i]);
+ if (IS_ERR(pd))
+ return PTR_ERR(pd);
+
+ pd->aon_chan = aon_chan;
+ domains[i] = &pd->genpd;
+ dev_dbg(dev, "added power domain %s\n", pd->genpd.name);
+ }
+
+ pd_data->domains = domains;
+ pd_data->num_domains = ARRAY_SIZE(th1520_pd_ranges);
+ pd_data->xlate = th1520_pd_xlate;
+
+ /*
+ * Initialize all power domains to off to ensure they start in a
+ * low-power state. This allows device drivers to manage power
+ * domains by turning them on or off as needed.
+ */
+ th1520_pd_init_all_off(domains, dev);
+
+ return of_genpd_add_provider_onecell(dev->of_node, pd_data);
+}
+
+static void th1520_pd_remove(struct platform_device *pdev)
+{
+ struct th1520_aon_chan *aon_chan = platform_get_drvdata(pdev);
+
+ th1520_aon_deinit(aon_chan);
+}
+
+static const struct of_device_id th1520_pd_match[] = {
+ { .compatible = "thead,th1520-aon" },
+ { /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, th1520_pd_match);
+
+static struct platform_driver th1520_pd_driver = {
+ .driver = {
+ .name = "th1520-pd",
+ .of_match_table = th1520_pd_match,
+ },
+ .probe = th1520_pd_probe,
+ .remove = th1520_pd_remove,
+};
+module_platform_driver(th1520_pd_driver);
+
+MODULE_AUTHOR("Michal Wilczynski <m.wilczynski@samsung.com>");
+MODULE_DESCRIPTION("T-HEAD TH1520 SoC power domain controller");
+MODULE_LICENSE("GPL");
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 5/5] riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
` (3 preceding siblings ...)
2025-03-03 14:59 ` [PATCH v1 4/5] pmdomain: thead: Add power-domain driver for TH1520 Michal Wilczynski
@ 2025-03-03 14:59 ` Michal Wilczynski
2025-03-05 8:04 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
5 siblings, 0 replies; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-03 14:59 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski
T-Head SoCs feature separate power domains (power islands) for major
components like the GPU, Audio, and NPU. To manage the power states of
these components effectively, the kernel requires generic power domain
support.
This commit enables `CONFIG_PM_GENERIC_DOMAINS` for T-Head SoCs,
allowing the power domain driver for these components to be compiled and
integrated. This ensures proper power management and energy efficiency
on T-Head platforms.
By selecting `PM_GENERIC_DOMAINS`, we provide the necessary framework
for the power domain drivers to function correctly on RISC-V
architecture with T-Head SoCs.
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
arch/riscv/Kconfig.socs | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs
index 1916cf7ba450..83833ded8908 100644
--- a/arch/riscv/Kconfig.socs
+++ b/arch/riscv/Kconfig.socs
@@ -53,6 +53,7 @@ config ARCH_THEAD
bool "T-HEAD RISC-V SoCs"
depends on MMU && !XIP_KERNEL
select ERRATA_THEAD
+ select PM_GENERIC_DOMAINS if PM
help
This enables support for the RISC-V based T-HEAD SoCs.
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-03 14:58 ` [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node Michal Wilczynski
@ 2025-03-03 17:42 ` Krzysztof Kozlowski
2025-03-03 17:46 ` Krzysztof Kozlowski
0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-03 17:42 UTC (permalink / raw)
To: Michal Wilczynski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Krzysztof Kozlowski
On 03/03/2025 15:58, Michal Wilczynski wrote:
> The kernel communicates with the E902 core through the mailbox
> transport using AON firmware protocol. Add dt-bindings to document it
> the dt node.
>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
How is this possible? That's v1 and I never review outside of mailing list.
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
> .../bindings/firmware/thead,th1520-aon.yaml | 53 +++++++++++++++++++
> MAINTAINERS | 1 +
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-03 17:42 ` Krzysztof Kozlowski
@ 2025-03-03 17:46 ` Krzysztof Kozlowski
2025-03-04 7:43 ` Michal Wilczynski
0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-03 17:46 UTC (permalink / raw)
To: Michal Wilczynski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Krzysztof Kozlowski
On 03/03/2025 18:42, Krzysztof Kozlowski wrote:
> On 03/03/2025 15:58, Michal Wilczynski wrote:
>> The kernel communicates with the E902 core through the mailbox
>> transport using AON firmware protocol. Add dt-bindings to document it
>> the dt node.
>>
>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>
>
> How is this possible? That's v1 and I never review outside of mailing list.
>
OK, I found v5:
https://lore.kernel.org/all/20250219140239.1378758-4-m.wilczynski@samsung.com/
so is this the same?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-03 17:46 ` Krzysztof Kozlowski
@ 2025-03-04 7:43 ` Michal Wilczynski
2025-03-04 7:45 ` Krzysztof Kozlowski
0 siblings, 1 reply; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-04 7:43 UTC (permalink / raw)
To: Krzysztof Kozlowski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Krzysztof Kozlowski
On 3/3/25 18:46, Krzysztof Kozlowski wrote:
> On 03/03/2025 18:42, Krzysztof Kozlowski wrote:
>> On 03/03/2025 15:58, Michal Wilczynski wrote:
>>> The kernel communicates with the E902 core through the mailbox
>>> transport using AON firmware protocol. Add dt-bindings to document it
>>> the dt node.
>>>
>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>
>>
>> How is this possible? That's v1 and I never review outside of mailing list.
>>
> OK, I found v5:
> https://lore.kernel.org/all/20250219140239.1378758-4-m.wilczynski@samsung.com/
>
> so is this the same?
Yeah, I thought by splitting the patchset and creating new sub-series I
should start versioning from v1 again, and leave that bigger patchset as
a reference, I've linked it in each cover letter for each sub-series.
>
> Best regards,
> Krzysztof
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-04 7:43 ` Michal Wilczynski
@ 2025-03-04 7:45 ` Krzysztof Kozlowski
2025-03-04 7:52 ` Michal Wilczynski
0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-04 7:45 UTC (permalink / raw)
To: Michal Wilczynski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Krzysztof Kozlowski
On 04/03/2025 08:43, Michal Wilczynski wrote:
>
>
> On 3/3/25 18:46, Krzysztof Kozlowski wrote:
>> On 03/03/2025 18:42, Krzysztof Kozlowski wrote:
>>> On 03/03/2025 15:58, Michal Wilczynski wrote:
>>>> The kernel communicates with the E902 core through the mailbox
>>>> transport using AON firmware protocol. Add dt-bindings to document it
>>>> the dt node.
>>>>
>>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>>
>>>
>>> How is this possible? That's v1 and I never review outside of mailing list.
>>>
>> OK, I found v5:
>> https://lore.kernel.org/all/20250219140239.1378758-4-m.wilczynski@samsung.com/
>>
>> so is this the same?
>
> Yeah, I thought by splitting the patchset and creating new sub-series I
> should start versioning from v1 again, and leave that bigger patchset as
What was unclear in my "keep versioning and keep changelog"? How this
can lead to "start new versioning"?
> a reference, I've linked it in each cover letter for each sub-series.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-04 7:45 ` Krzysztof Kozlowski
@ 2025-03-04 7:52 ` Michal Wilczynski
2025-03-04 14:24 ` Krzysztof Kozlowski
0 siblings, 1 reply; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-04 7:52 UTC (permalink / raw)
To: Krzysztof Kozlowski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv,
Krzysztof Kozlowski
On 3/4/25 08:45, Krzysztof Kozlowski wrote:
> On 04/03/2025 08:43, Michal Wilczynski wrote:
>>
>>
>> On 3/3/25 18:46, Krzysztof Kozlowski wrote:
>>> On 03/03/2025 18:42, Krzysztof Kozlowski wrote:
>>>> On 03/03/2025 15:58, Michal Wilczynski wrote:
>>>>> The kernel communicates with the E902 core through the mailbox
>>>>> transport using AON firmware protocol. Add dt-bindings to document it
>>>>> the dt node.
>>>>>
>>>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>>>
>>>>
>>>> How is this possible? That's v1 and I never review outside of mailing list.
>>>>
>>> OK, I found v5:
>>> https://lore.kernel.org/all/20250219140239.1378758-4-m.wilczynski@samsung.com/
>>>
>>> so is this the same?
>>
>> Yeah, I thought by splitting the patchset and creating new sub-series I
>> should start versioning from v1 again, and leave that bigger patchset as
>
> What was unclear in my "keep versioning and keep changelog"? How this
> can lead to "start new versioning"?
OK, my bad misunderstood you. I don't want to spam too much so maybe I
should wait if there will be any comments before re-sending with the proper
changelog and version.
>
>> a reference, I've linked it in each cover letter for each sub-series.
>
> Best regards,
> Krzysztof
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node
2025-03-04 7:52 ` Michal Wilczynski
@ 2025-03-04 14:24 ` Krzysztof Kozlowski
0 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-04 14:24 UTC (permalink / raw)
To: Michal Wilczynski, Krzysztof Kozlowski, robh, krzk+dt, conor+dt,
drew, guoren, wefu, paul.walmsley, palmer, aou, alex, jszhang,
ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv
On 04/03/2025 08:52, Michal Wilczynski wrote:
>
>
> On 3/4/25 08:45, Krzysztof Kozlowski wrote:
>> On 04/03/2025 08:43, Michal Wilczynski wrote:
>>>
>>>
>>> On 3/3/25 18:46, Krzysztof Kozlowski wrote:
>>>> On 03/03/2025 18:42, Krzysztof Kozlowski wrote:
>>>>> On 03/03/2025 15:58, Michal Wilczynski wrote:
>>>>>> The kernel communicates with the E902 core through the mailbox
>>>>>> transport using AON firmware protocol. Add dt-bindings to document it
>>>>>> the dt node.
>>>>>>
>>>>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>>>>
>>>>>
>>>>> How is this possible? That's v1 and I never review outside of mailing list.
>>>>>
>>>> OK, I found v5:
>>>> https://lore.kernel.org/all/20250219140239.1378758-4-m.wilczynski@samsung.com/
>>>>
>>>> so is this the same?
>>>
>>> Yeah, I thought by splitting the patchset and creating new sub-series I
>>> should start versioning from v1 again, and leave that bigger patchset as
>>
>> What was unclear in my "keep versioning and keep changelog"? How this
>> can lead to "start new versioning"?
>
> OK, my bad misunderstood you. I don't want to spam too much so maybe I
> should wait if there will be any comments before re-sending with the proper
> changelog and version.
Just provide changelog as response to your cover letter.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
` (4 preceding siblings ...)
2025-03-03 14:59 ` [PATCH v1 5/5] riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs Michal Wilczynski
@ 2025-03-05 8:04 ` Michal Wilczynski
5 siblings, 0 replies; 16+ messages in thread
From: Michal Wilczynski @ 2025-03-05 8:04 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, drew, guoren, wefu, paul.walmsley,
palmer, aou, alex, jszhang, ulf.hansson, m.szyprowski
Cc: linux-pm, devicetree, linux-kernel, linux-riscv
On 3/3/25 15:58, Michal Wilczynski wrote:
> This patch series introduces and documents power management (PM) support and
> the AON firmware driver for the T-Head TH1520 SoC, as used on the LicheePi 4A
> board. While part of a larger effort to enable the Imagination BXM-4-64 GPU
> upstream, these patches can merge independently.
>
> Bigger series cover letter:
> https://lore.kernel.org/all/20250219140239.1378758-1-m.wilczynski@samsung.com/
This series should be versioned as v6, to maintain continuity with the
bigger patchset it is a subseries of. Please find below a changelog for
the AON & power-domain:
v6:
- split the firmware & power-domain patches into a separate series
v5:
- changed the AON driver to be a set of library functions rather than a
standalone driver
v4:
- added workaround to disable AUDIO power domain to prevent firmware crashes
v3:
- consolidated device tree representation by merging aon and power-domain nodes
while maintaining separate drivers internally
- power-domain driver is now instantiated from within the aon driver
- fixed optional module dependencies in Kconfig
- added kernel-doc comments for all exported functions
- implemented th1520_aon_remove() to properly clean up mailbox channel
resources
v2:
- introduced a new firmware driver to manage power-related operations.
- rewrote the power-domain driver to function alongside the firmware driver.
These nodes in the device tree lack direct address spaces, despite
representing HW blocks. Control is achieved via firmware protocol messages
transmitted through a mailbox to the E902 core.
- added new dt-bindings for power and firmware nodes.
- ran dtbs_check and dt_binding_check to ensure compliance.
>
> Michal Wilczynski (5):
> dt-bindings: firmware: thead,th1520: Add support for firmware node
> firmware: thead: Add AON firmware protocol driver
> dt-bindings: power: Add TH1520 SoC power domains
> pmdomain: thead: Add power-domain driver for TH1520
> riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs
>
> .../bindings/firmware/thead,th1520-aon.yaml | 53 ++++
> MAINTAINERS | 5 +
> arch/riscv/Kconfig.socs | 1 +
> drivers/firmware/Kconfig | 9 +
> drivers/firmware/Makefile | 1 +
> drivers/firmware/thead,th1520-aon.c | 247 ++++++++++++++++++
> drivers/pmdomain/Kconfig | 1 +
> drivers/pmdomain/Makefile | 1 +
> drivers/pmdomain/thead/Kconfig | 12 +
> drivers/pmdomain/thead/Makefile | 2 +
> drivers/pmdomain/thead/th1520-pm-domains.c | 209 +++++++++++++++
> .../dt-bindings/power/thead,th1520-power.h | 19 ++
> .../linux/firmware/thead/thead,th1520-aon.h | 200 ++++++++++++++
> 13 files changed, 760 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
> create mode 100644 drivers/firmware/thead,th1520-aon.c
> create mode 100644 drivers/pmdomain/thead/Kconfig
> create mode 100644 drivers/pmdomain/thead/Makefile
> create mode 100644 drivers/pmdomain/thead/th1520-pm-domains.c
> create mode 100644 include/dt-bindings/power/thead,th1520-power.h
> create mode 100644 include/linux/firmware/thead/thead,th1520-aon.h
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
2025-03-03 14:58 ` [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver Michal Wilczynski
@ 2025-03-06 0:04 ` kernel test robot
2025-03-06 7:07 ` kernel test robot
2025-03-06 13:15 ` kernel test robot
2 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2025-03-06 0:04 UTC (permalink / raw)
To: Michal Wilczynski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: oe-kbuild-all, linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski
Hi Michal,
kernel test robot noticed the following build warnings:
[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.14-rc5 next-20250305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Michal-Wilczynski/dt-bindings-firmware-thead-th1520-Add-support-for-firmware-node/20250303-230224
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link: https://lore.kernel.org/r/20250303145901.446791-3-m.wilczynski%40samsung.com
patch subject: [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
config: arc-allmodconfig (https://download.01.org/0day-ci/archive/20250306/202503060707.a8CwuQbH-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250306/202503060707.a8CwuQbH-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503060707.a8CwuQbH-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/firmware/thead,th1520-aon.c: In function 'th1520_aon_init':
drivers/firmware/thead,th1520-aon.c:206:20: error: implicit declaration of function 'kzalloc' [-Werror=implicit-function-declaration]
206 | aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
| ^~~~~~~
>> drivers/firmware/thead,th1520-aon.c:206:18: warning: assignment to 'struct th1520_aon_chan *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
206 | aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
| ^
drivers/firmware/thead,th1520-aon.c:219:17: error: implicit declaration of function 'kfree' [-Werror=implicit-function-declaration]
219 | kfree(aon_chan);
| ^~~~~
cc1: some warnings being treated as errors
vim +206 drivers/firmware/thead,th1520-aon.c
185
186 /**
187 * th1520_aon_init() - Initialize TH1520 AON firmware protocol interface
188 * @dev: Device pointer for the AON subsystem
189 *
190 * This function initializes the TH1520 AON firmware protocol interface by:
191 * - Allocating and initializing the AON channel structure
192 * - Setting up the mailbox client
193 * - Requesting the AON mailbox channel
194 * - Initializing synchronization primitives
195 *
196 * Return:
197 * * Valid pointer to th1520_aon_chan structure on success
198 * * ERR_PTR(-ENOMEM) if memory allocation fails
199 * * ERR_PTR() with other negative error codes from mailbox operations
200 */
201 struct th1520_aon_chan *th1520_aon_init(struct device *dev)
202 {
203 struct th1520_aon_chan *aon_chan;
204 struct mbox_client *cl;
205
> 206 aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
207 if (!aon_chan)
208 return ERR_PTR(-ENOMEM);
209
210 cl = &aon_chan->cl;
211 cl->dev = dev;
212 cl->tx_block = true;
213 cl->tx_tout = MAX_TX_TIMEOUT;
214 cl->rx_callback = th1520_aon_rx_callback;
215
216 aon_chan->ch = mbox_request_channel_byname(cl, "aon");
217 if (IS_ERR(aon_chan->ch)) {
218 dev_err(dev, "Failed to request aon mbox chan\n");
219 kfree(aon_chan);
220 return ERR_CAST(aon_chan->ch);
221 }
222
223 mutex_init(&aon_chan->transaction_lock);
224 init_completion(&aon_chan->done);
225
226 return aon_chan;
227 }
228 EXPORT_SYMBOL_GPL(th1520_aon_init);
229
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
2025-03-03 14:58 ` [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver Michal Wilczynski
2025-03-06 0:04 ` kernel test robot
@ 2025-03-06 7:07 ` kernel test robot
2025-03-06 13:15 ` kernel test robot
2 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2025-03-06 7:07 UTC (permalink / raw)
To: Michal Wilczynski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: llvm, oe-kbuild-all, linux-pm, devicetree, linux-kernel,
linux-riscv, Michal Wilczynski
Hi Michal,
kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.14-rc5 next-20250305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Michal-Wilczynski/dt-bindings-firmware-thead-th1520-Add-support-for-firmware-node/20250303-230224
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link: https://lore.kernel.org/r/20250303145901.446791-3-m.wilczynski%40samsung.com
patch subject: [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20250306/202503061453.DvzBlKdM-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250306/202503061453.DvzBlKdM-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503061453.DvzBlKdM-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/firmware/thead,th1520-aon.c:206:13: error: call to undeclared function 'kzalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
206 | aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
| ^
>> drivers/firmware/thead,th1520-aon.c:206:11: error: incompatible integer to pointer conversion assigning to 'struct th1520_aon_chan *' from 'int' [-Wint-conversion]
206 | aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/thead,th1520-aon.c:219:3: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
219 | kfree(aon_chan);
| ^
drivers/firmware/thead,th1520-aon.c:241:2: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
241 | kfree(aon_chan);
| ^
4 errors generated.
vim +206 drivers/firmware/thead,th1520-aon.c
185
186 /**
187 * th1520_aon_init() - Initialize TH1520 AON firmware protocol interface
188 * @dev: Device pointer for the AON subsystem
189 *
190 * This function initializes the TH1520 AON firmware protocol interface by:
191 * - Allocating and initializing the AON channel structure
192 * - Setting up the mailbox client
193 * - Requesting the AON mailbox channel
194 * - Initializing synchronization primitives
195 *
196 * Return:
197 * * Valid pointer to th1520_aon_chan structure on success
198 * * ERR_PTR(-ENOMEM) if memory allocation fails
199 * * ERR_PTR() with other negative error codes from mailbox operations
200 */
201 struct th1520_aon_chan *th1520_aon_init(struct device *dev)
202 {
203 struct th1520_aon_chan *aon_chan;
204 struct mbox_client *cl;
205
> 206 aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
207 if (!aon_chan)
208 return ERR_PTR(-ENOMEM);
209
210 cl = &aon_chan->cl;
211 cl->dev = dev;
212 cl->tx_block = true;
213 cl->tx_tout = MAX_TX_TIMEOUT;
214 cl->rx_callback = th1520_aon_rx_callback;
215
216 aon_chan->ch = mbox_request_channel_byname(cl, "aon");
217 if (IS_ERR(aon_chan->ch)) {
218 dev_err(dev, "Failed to request aon mbox chan\n");
> 219 kfree(aon_chan);
220 return ERR_CAST(aon_chan->ch);
221 }
222
223 mutex_init(&aon_chan->transaction_lock);
224 init_completion(&aon_chan->done);
225
226 return aon_chan;
227 }
228 EXPORT_SYMBOL_GPL(th1520_aon_init);
229
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
2025-03-03 14:58 ` [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver Michal Wilczynski
2025-03-06 0:04 ` kernel test robot
2025-03-06 7:07 ` kernel test robot
@ 2025-03-06 13:15 ` kernel test robot
2 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2025-03-06 13:15 UTC (permalink / raw)
To: Michal Wilczynski, robh, krzk+dt, conor+dt, drew, guoren, wefu,
paul.walmsley, palmer, aou, alex, jszhang, ulf.hansson,
m.szyprowski
Cc: oe-kbuild-all, linux-pm, devicetree, linux-kernel, linux-riscv,
Michal Wilczynski
Hi Michal,
kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.14-rc5 next-20250306]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Michal-Wilczynski/dt-bindings-firmware-thead-th1520-Add-support-for-firmware-node/20250303-230224
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link: https://lore.kernel.org/r/20250303145901.446791-3-m.wilczynski%40samsung.com
patch subject: [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver
config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20250306/202503062029.bHmgxF2Q-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250306/202503062029.bHmgxF2Q-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503062029.bHmgxF2Q-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/firmware/thead,th1520-aon.c: In function 'th1520_aon_init':
>> drivers/firmware/thead,th1520-aon.c:206:20: error: implicit declaration of function 'kzalloc' [-Wimplicit-function-declaration]
206 | aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
| ^~~~~~~
>> drivers/firmware/thead,th1520-aon.c:206:18: error: assignment to 'struct th1520_aon_chan *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
206 | aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
| ^
>> drivers/firmware/thead,th1520-aon.c:219:17: error: implicit declaration of function 'kfree'; did you mean 'kvfree'? [-Wimplicit-function-declaration]
219 | kfree(aon_chan);
| ^~~~~
| kvfree
vim +206 drivers/firmware/thead,th1520-aon.c
185
186 /**
187 * th1520_aon_init() - Initialize TH1520 AON firmware protocol interface
188 * @dev: Device pointer for the AON subsystem
189 *
190 * This function initializes the TH1520 AON firmware protocol interface by:
191 * - Allocating and initializing the AON channel structure
192 * - Setting up the mailbox client
193 * - Requesting the AON mailbox channel
194 * - Initializing synchronization primitives
195 *
196 * Return:
197 * * Valid pointer to th1520_aon_chan structure on success
198 * * ERR_PTR(-ENOMEM) if memory allocation fails
199 * * ERR_PTR() with other negative error codes from mailbox operations
200 */
201 struct th1520_aon_chan *th1520_aon_init(struct device *dev)
202 {
203 struct th1520_aon_chan *aon_chan;
204 struct mbox_client *cl;
205
> 206 aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
207 if (!aon_chan)
208 return ERR_PTR(-ENOMEM);
209
210 cl = &aon_chan->cl;
211 cl->dev = dev;
212 cl->tx_block = true;
213 cl->tx_tout = MAX_TX_TIMEOUT;
214 cl->rx_callback = th1520_aon_rx_callback;
215
216 aon_chan->ch = mbox_request_channel_byname(cl, "aon");
217 if (IS_ERR(aon_chan->ch)) {
218 dev_err(dev, "Failed to request aon mbox chan\n");
> 219 kfree(aon_chan);
220 return ERR_CAST(aon_chan->ch);
221 }
222
223 mutex_init(&aon_chan->transaction_lock);
224 init_completion(&aon_chan->done);
225
226 return aon_chan;
227 }
228 EXPORT_SYMBOL_GPL(th1520_aon_init);
229
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-03-06 13:16 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20250303145917eucas1p171f8fcccadddc035f5773f7026a281e3@eucas1p1.samsung.com>
2025-03-03 14:58 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
2025-03-03 14:58 ` [PATCH v1 1/5] dt-bindings: firmware: thead,th1520: Add support for firmware node Michal Wilczynski
2025-03-03 17:42 ` Krzysztof Kozlowski
2025-03-03 17:46 ` Krzysztof Kozlowski
2025-03-04 7:43 ` Michal Wilczynski
2025-03-04 7:45 ` Krzysztof Kozlowski
2025-03-04 7:52 ` Michal Wilczynski
2025-03-04 14:24 ` Krzysztof Kozlowski
2025-03-03 14:58 ` [PATCH v1 2/5] firmware: thead: Add AON firmware protocol driver Michal Wilczynski
2025-03-06 0:04 ` kernel test robot
2025-03-06 7:07 ` kernel test robot
2025-03-06 13:15 ` kernel test robot
2025-03-03 14:58 ` [PATCH v1 3/5] dt-bindings: power: Add TH1520 SoC power domains Michal Wilczynski
2025-03-03 14:59 ` [PATCH v1 4/5] pmdomain: thead: Add power-domain driver for TH1520 Michal Wilczynski
2025-03-03 14:59 ` [PATCH v1 5/5] riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs Michal Wilczynski
2025-03-05 8:04 ` [PATCH v1 0/5] TH1520 SoC: Add AON firmware & power-domain support Michal Wilczynski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).