[PATCH v2 1/8] soc: qcom: add QDCP client library
From: Jie Gan
Date: Mon Nov 30 2026 - 02:12:27 EST
On the Qualcomm Hawi and Maili SoCs, part of the CoreSight trace
hardware is owned by the Qualcomm Embedded Co-Processor (QECP). The
control registers of these blocks are protected by access control and
cannot be accessed from the application processor; the QECP firmware
programs them on request instead. The requests are carried by the
Qualcomm Debug Control Protocol (QDCP), a QMI service provided by the
QECP firmware.
Add a client library for QDCP, selected by the drivers of the
QECP-owned blocks. Each driver creates its own QMI client with
devm_qdcp_client_get(), passing the QMI service, version and instance
of the QDCP server, which are fixed by the platform firmware. The
server may register after the driver probes, so
qdcp_client_wait_for_service() lets a driver wait for it. The client is
released after the driver's remove callback, so that a driver can still
stop its block from there.
The firmware identifies each block by the base address of its
registers. The library provides:
- requests common to all trace sources and sinks, taking their type:
qdcp_source_set_atid() sets the trace ID of a source, and
qdcp_source_{enable,disable}() and qdcp_sink_{enable,disable}()
start and stop a source or a sink;
- requests specific to a block type: qdcp_stm_set_port_mask() and
qdcp_stm_get_param() for the STM, and qdcp_tmc_etr_configure(),
qdcp_tmc_get_param() and qdcp_tmc_{begin,end}_read() for the TMC,
which program the buffer mode, trace buffer and FFCR of an ETR, read
TMC registers and parameters such as DEVID, STS and the read and
write pointers, and flush and stop a TMC before its trace data is
read.
The requests sleep and must not be issued from atomic context. A failed
or timed out request may still have been executed by the firmware, so
the caller has to stop the block again before releasing any resource
the block may still use.
Signed-off-by: Jie Gan <jie.gan@xxxxxxxxxxxxxxxx>
---
drivers/soc/qcom/Kconfig | 10 +
drivers/soc/qcom/Makefile | 1 +
drivers/soc/qcom/qcom_qdcp.c | 1118 +++++++++++++++++++++++++++++++++++++++++
include/linux/soc/qcom/qdcp.h | 120 +++++
4 files changed, 1249 insertions(+)
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 535c8619197b..6f20a0ecde0a 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -330,6 +330,16 @@ config QCOM_QMI_TMD
TMD messaging and handles QMI communication with remote processors
to exchange mitigation state and apply thermal mitigation requests.
+config QCOM_QDCP
+ tristate
+ depends on NET
+ select QCOM_QMI_HELPERS
+ help
+ Client library for the Qualcomm Debug Control Protocol (QDCP), the
+ QMI service used to control debug and trace blocks owned by the
+ Qualcomm Embedded Co-Processor (QECP) firmware. Drivers for such
+ blocks select it.
+
config QCOM_UBWC_CONFIG
tristate
depends on QCOM_SMEM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index bddd6f0a5836..5c2b4e1c67dc 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -17,6 +17,7 @@ CFLAGS_pmic_pdcharger_ulog.o := -I$(src)
obj-$(CONFIG_QCOM_QMI_TMD) += qmi_tmd.o
obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o
qmi_helpers-y += qmi_encdec.o qmi_interface.o
+obj-$(CONFIG_QCOM_QDCP) += qcom_qdcp.o
obj-$(CONFIG_QCOM_RAMP_CTRL) += ramp_controller.o
obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o
obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o
diff --git a/drivers/soc/qcom/qcom_qdcp.c b/drivers/soc/qcom/qcom_qdcp.c
new file mode 100644
index 000000000000..28be1480e21e
--- /dev/null
+++ b/drivers/soc/qcom/qcom_qdcp.c
@@ -0,0 +1,1118 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * Client library for the Qualcomm Debug Control Protocol (QDCP), the QMI
+ * service used to control debug and trace blocks owned by the Qualcomm
+ * Embedded Co-Processor (QECP) firmware.
+ */
+
+#include <linux/device.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/soc/qcom/qdcp.h>
+#include <linux/soc/qcom/qmi.h>
+#include <linux/wait.h>
+
+#define QDCP_TIMEOUT_MS 10000
+#define QDCP_MAX_ATIDS 8
+
+#define QDCP_STM_SET_STATE 0x0003
+#define QDCP_STM_SET_PARAM 0x0007
+#define QDCP_STM_GET_PARAM 0x0008
+#define QDCP_TMC_SET_STATE 0x002b
+#define QDCP_TMC_ASSIGN_BUFFER 0x002d
+#define QDCP_TMC_BEGIN_READ 0x0030
+#define QDCP_TMC_END_READ 0x0032
+#define QDCP_TMC_SET_PARAM 0x0033
+#define QDCP_TMC_GET_PARAM 0x0034
+#define QDCP_ATID_SET 0x0036
+
+/*
+ * Maximum encoded request lengths. Each top level element is a TLV with a
+ * 1 byte type and a 2 byte length in front of its payload.
+ */
+#define QDCP_STATE_REQ_MAX_LEN 18
+#define QDCP_STM_SET_PARAM_REQ_MAX_LEN 25
+#define QDCP_STM_GET_PARAM_REQ_MAX_LEN 18
+#define QDCP_ATID_SET_REQ_MAX_LEN 30
+#define QDCP_TMC_ASSIGN_BUFFER_REQ_MAX_LEN 38
+#define QDCP_TMC_ID_REQ_MAX_LEN 11
+#define QDCP_TMC_SET_PARAM_REQ_MAX_LEN 29
+#define QDCP_TMC_GET_PARAM_REQ_MAX_LEN 18
+
+/*
+ * Maximum size of a message from the QDCP server, as defined by the QDCP
+ * interface, used as the size of the QMI receive buffer.
+ */
+#define QDCP_RECV_MAX_LEN 16401
+
+struct qdcp_trace_source_v01 {
+ s32 type;
+ u64 id;
+};
+
+/*
+ * Every QDCP response starts with the mandatory QMI result TLV;
+ * qdcp_send_resp() relies on that to check the result.
+ */
+struct qdcp_resp_v01 {
+ struct qmi_response_type_v01 resp;
+};
+
+struct qdcp_state_req_v01 {
+ u64 id;
+ s32 state;
+};
+
+struct qdcp_stm_set_param_req_v01 {
+ u64 source_id;
+ u32 param;
+ u32 value;
+};
+
+struct qdcp_stm_get_param_req_v01 {
+ u64 source_id;
+ u32 param;
+};
+
+struct qdcp_stm_get_param_resp_v01 {
+ struct qmi_response_type_v01 resp;
+ u8 value_valid;
+ u32 value;
+};
+
+struct qdcp_atid_set_req_v01 {
+ struct qdcp_trace_source_v01 trace_source;
+ u8 atids[QDCP_MAX_ATIDS];
+ u8 num_atids;
+};
+
+struct qdcp_tmc_buffer_v01 {
+ u64 paddr;
+ u64 iaddr;
+ u64 size;
+};
+
+struct qdcp_tmc_assign_buffer_req_v01 {
+ u64 tmc_id;
+ struct qdcp_tmc_buffer_v01 buffer;
+};
+
+struct qdcp_tmc_id_req_v01 {
+ u64 tmc_id;
+};
+
+struct qdcp_tmc_begin_read_resp_v01 {
+ struct qmi_response_type_v01 resp;
+ u8 write_ptr_valid;
+ u64 write_ptr;
+ u8 status_valid;
+ u32 status;
+};
+
+struct qdcp_tmc_set_param_req_v01 {
+ u64 tmc_id;
+ u32 param;
+ u64 value;
+};
+
+struct qdcp_tmc_get_param_req_v01 {
+ u64 tmc_id;
+ u32 param;
+};
+
+struct qdcp_tmc_get_param_resp_v01 {
+ struct qmi_response_type_v01 resp;
+ u8 value_valid;
+ u64 value;
+};
+
+static_assert(offsetof(struct qdcp_resp_v01, resp) == 0);
+static_assert(offsetof(struct qdcp_tmc_get_param_resp_v01, resp) == 0);
+static_assert(offsetof(struct qdcp_stm_get_param_resp_v01, resp) == 0);
+static_assert(offsetof(struct qdcp_tmc_begin_read_resp_v01, resp) == 0);
+
+/**
+ * struct qdcp_client - QDCP connection owned by a client device
+ * @dev: client device.
+ * @qmi: QMI handle.
+ * @lock: protects @sq and @connected.
+ * @sq: address of the QDCP server.
+ * @connected: the QDCP server is available.
+ * @wait: woken up when the QDCP server becomes available.
+ */
+struct qdcp_client {
+ struct device *dev;
+ struct qmi_handle qmi;
+ /* Protects @sq and @connected */
+ struct mutex lock;
+ struct sockaddr_qrtr sq;
+ bool connected;
+ wait_queue_head_t wait;
+};
+
+static const struct qmi_elem_info qdcp_resp_ei[] = {
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qmi_response_type_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_resp_v01, resp),
+ .ei_array = qmi_response_type_v01_ei,
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_state_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_state_req_v01, id),
+ },
+ {
+ .data_type = QMI_SIGNED_4_BYTE_ENUM,
+ .elem_len = 1,
+ .elem_size = sizeof(s32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_state_req_v01, state),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_stm_set_param_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_stm_set_param_req_v01, source_id),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_stm_set_param_req_v01, param),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_stm_set_param_req_v01, value),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_trace_source_ei[] = {
+ {
+ .data_type = QMI_SIGNED_4_BYTE_ENUM,
+ .elem_len = 1,
+ .elem_size = sizeof(s32),
+ .array_type = NO_ARRAY,
+ .tlv_type = QMI_COMMON_TLV_TYPE,
+ .offset = offsetof(struct qdcp_trace_source_v01, type),
+ },
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = QMI_COMMON_TLV_TYPE,
+ .offset = offsetof(struct qdcp_trace_source_v01, id),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_atid_set_req_ei[] = {
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qdcp_trace_source_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_atid_set_req_v01, trace_source),
+ .ei_array = qdcp_trace_source_ei,
+ },
+ {
+ .data_type = QMI_UNSIGNED_1_BYTE,
+ .elem_len = QDCP_MAX_ATIDS,
+ .elem_size = sizeof(u8),
+ .array_type = STATIC_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_atid_set_req_v01, atids),
+ },
+ {
+ .data_type = QMI_UNSIGNED_1_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_atid_set_req_v01, num_atids),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_tmc_buffer_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = QMI_COMMON_TLV_TYPE,
+ .offset = offsetof(struct qdcp_tmc_buffer_v01, paddr),
+ },
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = QMI_COMMON_TLV_TYPE,
+ .offset = offsetof(struct qdcp_tmc_buffer_v01, iaddr),
+ },
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = QMI_COMMON_TLV_TYPE,
+ .offset = offsetof(struct qdcp_tmc_buffer_v01, size),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_tmc_assign_buffer_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_tmc_assign_buffer_req_v01, tmc_id),
+ },
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qdcp_tmc_buffer_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_tmc_assign_buffer_req_v01, buffer),
+ .ei_array = qdcp_tmc_buffer_ei,
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_tmc_get_param_resp_ei[] = {
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qmi_response_type_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_tmc_get_param_resp_v01, resp),
+ .ei_array = qmi_response_type_v01_ei,
+ },
+ {
+ .data_type = QMI_OPT_FLAG,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_tmc_get_param_resp_v01,
+ value_valid),
+ },
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_tmc_get_param_resp_v01, value),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_tmc_set_param_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_tmc_set_param_req_v01, tmc_id),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_tmc_set_param_req_v01, param),
+ },
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_tmc_set_param_req_v01, value),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_tmc_get_param_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_tmc_get_param_req_v01, tmc_id),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_tmc_get_param_req_v01, param),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_stm_get_param_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_stm_get_param_req_v01, source_id),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_stm_get_param_req_v01, param),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_stm_get_param_resp_ei[] = {
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qmi_response_type_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_stm_get_param_resp_v01, resp),
+ .ei_array = qmi_response_type_v01_ei,
+ },
+ {
+ .data_type = QMI_OPT_FLAG,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_stm_get_param_resp_v01,
+ value_valid),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_stm_get_param_resp_v01, value),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static const struct qmi_elem_info qdcp_tmc_id_req_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct qdcp_tmc_id_req_v01, tmc_id),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+/*
+ * The write pointer and status in the reply are not used, but must be
+ * described as qmi_decode_message() rejects unknown mandatory TLVs.
+ */
+static const struct qmi_elem_info qdcp_tmc_begin_read_resp_ei[] = {
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qmi_response_type_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct qdcp_tmc_begin_read_resp_v01, resp),
+ .ei_array = qmi_response_type_v01_ei,
+ },
+ {
+ .data_type = QMI_OPT_FLAG,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_tmc_begin_read_resp_v01,
+ write_ptr_valid),
+ },
+ {
+ .data_type = QMI_UNSIGNED_8_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u64),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x03,
+ .offset = offsetof(struct qdcp_tmc_begin_read_resp_v01, write_ptr),
+ },
+ {
+ .data_type = QMI_OPT_FLAG,
+ .elem_len = 1,
+ .elem_size = sizeof(u8),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x04,
+ .offset = offsetof(struct qdcp_tmc_begin_read_resp_v01,
+ status_valid),
+ },
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(u32),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x04,
+ .offset = offsetof(struct qdcp_tmc_begin_read_resp_v01, status),
+ },
+ {
+ .data_type = QMI_EOTI,
+ },
+};
+
+static int qdcp_check_resp(struct qdcp_client *client,
+ const struct qmi_response_type_v01 *resp)
+{
+ if (resp->result == QMI_RESULT_SUCCESS_V01)
+ return 0;
+
+ dev_err(client->dev, "QDCP request failed: result=%u error=%u\n",
+ resp->result, resp->error);
+ return -EIO;
+}
+
+static int qdcp_send_resp(struct qdcp_client *client, unsigned int msg_id,
+ const struct qmi_elem_info *req_ei, const void *req,
+ size_t req_len, const struct qmi_elem_info *resp_ei,
+ void *resp, size_t resp_len)
+{
+ /* @resp starts with the QMI result TLV, see struct qdcp_resp_v01 */
+ struct qmi_response_type_v01 *qmi_resp = resp;
+ struct sockaddr_qrtr sq;
+ struct qmi_txn txn;
+ bool connected;
+ int ret;
+
+ /*
+ * Don't hold the lock across qmi_txn_wait(): the server callbacks
+ * take it on the QMI workqueue, which must also deliver the response.
+ */
+ mutex_lock(&client->lock);
+ connected = client->connected;
+ sq = client->sq;
+ mutex_unlock(&client->lock);
+
+ if (!connected)
+ return -EAGAIN;
+
+ /*
+ * qmi_decode_message() does not fail on a missing TLV, so poison the
+ * result to make a reply without the result TLV read as a failure.
+ */
+ memset(resp, 0, resp_len);
+ qmi_resp->result = QMI_RESULT_FAILURE_V01;
+ qmi_resp->error = QMI_ERR_MALFORMED_MSG_V01;
+
+ ret = qmi_txn_init(&client->qmi, &txn, resp_ei, resp);
+ if (ret < 0)
+ return ret;
+
+ ret = qmi_send_request(&client->qmi, &sq, &txn, msg_id, req_len,
+ req_ei, req);
+ if (ret < 0) {
+ qmi_txn_cancel(&txn);
+ return ret;
+ }
+
+ ret = qmi_txn_wait(&txn, msecs_to_jiffies(QDCP_TIMEOUT_MS));
+ if (ret < 0)
+ return ret;
+
+ return qdcp_check_resp(client, qmi_resp);
+}
+
+static int qdcp_send(struct qdcp_client *client, unsigned int msg_id,
+ const struct qmi_elem_info *req_ei, const void *req,
+ size_t req_len)
+{
+ struct qdcp_resp_v01 resp;
+
+ return qdcp_send_resp(client, msg_id, req_ei, req, req_len,
+ qdcp_resp_ei, &resp, sizeof(resp));
+}
+
+static int qdcp_set_state(struct qdcp_client *client, unsigned int msg_id,
+ u64 id, bool enable)
+{
+ struct qdcp_state_req_v01 req = {
+ .id = id,
+ .state = enable,
+ };
+
+ return qdcp_send(client, msg_id, qdcp_state_req_ei, &req,
+ QDCP_STATE_REQ_MAX_LEN);
+}
+
+static int qdcp_set_atid(struct qdcp_client *client,
+ enum qdcp_source_type type, u64 source_id, u8 atid)
+{
+ struct qdcp_atid_set_req_v01 req = {
+ .trace_source = {
+ .type = type,
+ .id = source_id,
+ },
+ .atids = { atid },
+ .num_atids = 1,
+ };
+
+ return qdcp_send(client, QDCP_ATID_SET, qdcp_atid_set_req_ei, &req,
+ QDCP_ATID_SET_REQ_MAX_LEN);
+}
+
+/* SET_STATE message of each source and sink type */
+static const u16 qdcp_source_set_state[] = {
+ [QDCP_SOURCE_STM] = QDCP_STM_SET_STATE,
+};
+
+static const u16 qdcp_sink_set_state[] = {
+ [QDCP_SINK_ETR] = QDCP_TMC_SET_STATE,
+};
+
+static unsigned int qdcp_source_msg(enum qdcp_source_type type)
+{
+ if (type >= ARRAY_SIZE(qdcp_source_set_state))
+ return 0;
+
+ return qdcp_source_set_state[type];
+}
+
+static unsigned int qdcp_sink_msg(enum qdcp_sink_type type)
+{
+ if (type >= ARRAY_SIZE(qdcp_sink_set_state))
+ return 0;
+
+ return qdcp_sink_set_state[type];
+}
+
+/**
+ * qdcp_source_set_atid() - set the trace ID of a firmware owned trace source
+ * @client: QDCP client.
+ * @type: type of the trace source.
+ * @source_id: firmware identifier of the source, the base address of its
+ * registers.
+ * @atid: trace ID to tag the trace with, or 0 to clear it.
+ *
+ * Return: 0 on success, -EINVAL for an unknown @type, -EAGAIN if the QDCP
+ * server is not available, or another negative error code.
+ */
+int qdcp_source_set_atid(struct qdcp_client *client,
+ enum qdcp_source_type type, u64 source_id, u8 atid)
+{
+ if (!qdcp_source_msg(type))
+ return -EINVAL;
+
+ return qdcp_set_atid(client, type, source_id, atid);
+}
+EXPORT_SYMBOL_GPL(qdcp_source_set_atid);
+
+/**
+ * qdcp_source_enable() - enable a firmware owned trace source
+ * @client: QDCP client.
+ * @type: type of the trace source.
+ * @source_id: firmware identifier of the source, the base address of its
+ * registers.
+ *
+ * The trace ID and any source specific configuration must be set before.
+ *
+ * Return: 0 on success, -EINVAL for an unknown @type, -EAGAIN if the QDCP
+ * server is not available, or another negative error code.
+ */
+int qdcp_source_enable(struct qdcp_client *client, enum qdcp_source_type type,
+ u64 source_id)
+{
+ unsigned int msg_id = qdcp_source_msg(type);
+
+ if (!msg_id)
+ return -EINVAL;
+
+ return qdcp_set_state(client, msg_id, source_id, true);
+}
+EXPORT_SYMBOL_GPL(qdcp_source_enable);
+
+/**
+ * qdcp_source_disable() - disable a firmware owned trace source
+ * @client: QDCP client.
+ * @type: type of the trace source.
+ * @source_id: firmware identifier of the source, the base address of its
+ * registers.
+ *
+ * Return: 0 once firmware confirmed the source is stopped, -EINVAL for an
+ * unknown @type, or another negative error code.
+ */
+int qdcp_source_disable(struct qdcp_client *client, enum qdcp_source_type type,
+ u64 source_id)
+{
+ unsigned int msg_id = qdcp_source_msg(type);
+
+ if (!msg_id)
+ return -EINVAL;
+
+ return qdcp_set_state(client, msg_id, source_id, false);
+}
+EXPORT_SYMBOL_GPL(qdcp_source_disable);
+
+/**
+ * qdcp_stm_set_port_mask() - set the stimulus ports of a firmware owned STM
+ * @client: QDCP client.
+ * @source_id: firmware identifier of the STM, the base address of its
+ * registers.
+ * @port_mask: stimulus port enable mask, 0 disables all the ports.
+ *
+ * Return: 0 on success, -EAGAIN if the QDCP server is not available, or
+ * another negative error code.
+ */
+int qdcp_stm_set_port_mask(struct qdcp_client *client, u64 source_id,
+ u32 port_mask)
+{
+ struct qdcp_stm_set_param_req_v01 req = {
+ .source_id = source_id,
+ .param = QDCP_STM_PARAM_PORT_ENABLE,
+ .value = port_mask,
+ };
+
+ return qdcp_send(client, QDCP_STM_SET_PARAM, qdcp_stm_set_param_req_ei,
+ &req, QDCP_STM_SET_PARAM_REQ_MAX_LEN);
+}
+EXPORT_SYMBOL_GPL(qdcp_stm_set_port_mask);
+
+/**
+ * qdcp_stm_get_param() - read an STM parameter from firmware
+ * @client: QDCP client.
+ * @source_id: firmware identifier of the STM, the base address of its
+ * registers.
+ * @param: parameter to read.
+ * @value: returned parameter value.
+ *
+ * Return: 0 on success, -EAGAIN if the QDCP server is not available,
+ * -EPROTO if the reply has no value, or another negative error code.
+ */
+int qdcp_stm_get_param(struct qdcp_client *client, u64 source_id,
+ enum qdcp_stm_param param, u32 *value)
+{
+ struct qdcp_stm_get_param_req_v01 req = {
+ .source_id = source_id,
+ .param = param,
+ };
+ struct qdcp_stm_get_param_resp_v01 resp;
+ int ret;
+
+ ret = qdcp_send_resp(client, QDCP_STM_GET_PARAM,
+ qdcp_stm_get_param_req_ei, &req,
+ QDCP_STM_GET_PARAM_REQ_MAX_LEN,
+ qdcp_stm_get_param_resp_ei, &resp, sizeof(resp));
+ if (ret)
+ return ret;
+
+ if (!resp.value_valid)
+ return -EPROTO;
+
+ *value = resp.value;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(qdcp_stm_get_param);
+
+/**
+ * qdcp_sink_enable() - enable a firmware owned trace sink
+ * @client: QDCP client.
+ * @type: type of the trace sink.
+ * @sink_id: firmware identifier of the sink, the base address of its
+ * registers.
+ *
+ * Any sink specific configuration must be done before. A failed or timed
+ * out request may still have been executed by firmware, so the caller must
+ * call qdcp_sink_disable() before releasing the resources used by the sink.
+ *
+ * Return: 0 on success, -EINVAL for an unknown @type, -EAGAIN if the QDCP
+ * server is not available, or another negative error code.
+ */
+int qdcp_sink_enable(struct qdcp_client *client, enum qdcp_sink_type type,
+ u64 sink_id)
+{
+ unsigned int msg_id = qdcp_sink_msg(type);
+
+ if (!msg_id)
+ return -EINVAL;
+
+ return qdcp_set_state(client, msg_id, sink_id, true);
+}
+EXPORT_SYMBOL_GPL(qdcp_sink_enable);
+
+/**
+ * qdcp_sink_disable() - disable a firmware owned trace sink
+ * @client: QDCP client.
+ * @type: type of the trace sink.
+ * @sink_id: firmware identifier of the sink, the base address of its
+ * registers.
+ *
+ * Return: 0 once firmware confirmed the sink is stopped, -EINVAL for an
+ * unknown @type, or another negative error code, in which case firmware may
+ * still be using the resources of the sink, such as its trace buffer.
+ */
+int qdcp_sink_disable(struct qdcp_client *client, enum qdcp_sink_type type,
+ u64 sink_id)
+{
+ unsigned int msg_id = qdcp_sink_msg(type);
+
+ if (!msg_id)
+ return -EINVAL;
+
+ return qdcp_set_state(client, msg_id, sink_id, false);
+}
+EXPORT_SYMBOL_GPL(qdcp_sink_disable);
+
+static int qdcp_tmc_set_param(struct qdcp_client *client, u64 tmc_id,
+ enum qdcp_tmc_param param, u64 value)
+{
+ struct qdcp_tmc_set_param_req_v01 req = {
+ .tmc_id = tmc_id,
+ .param = param,
+ .value = value,
+ };
+
+ return qdcp_send(client, QDCP_TMC_SET_PARAM, qdcp_tmc_set_param_req_ei,
+ &req, QDCP_TMC_SET_PARAM_REQ_MAX_LEN);
+}
+
+/**
+ * qdcp_tmc_get_param() - read a TMC parameter from firmware
+ * @client: QDCP client.
+ * @tmc_id: firmware identifier of the TMC, the base address of its
+ * registers.
+ * @param: parameter to read.
+ * @value: returned parameter value.
+ *
+ * Return: 0 on success, -EAGAIN if the QDCP server is not available,
+ * -EPROTO if the reply has no value, or another negative error code.
+ */
+int qdcp_tmc_get_param(struct qdcp_client *client, u64 tmc_id,
+ enum qdcp_tmc_param param, u64 *value)
+{
+ struct qdcp_tmc_get_param_req_v01 req = {
+ .tmc_id = tmc_id,
+ .param = param,
+ };
+ struct qdcp_tmc_get_param_resp_v01 resp;
+ int ret;
+
+ ret = qdcp_send_resp(client, QDCP_TMC_GET_PARAM,
+ qdcp_tmc_get_param_req_ei, &req,
+ QDCP_TMC_GET_PARAM_REQ_MAX_LEN,
+ qdcp_tmc_get_param_resp_ei, &resp, sizeof(resp));
+ if (ret)
+ return ret;
+
+ if (!resp.value_valid)
+ return -EPROTO;
+
+ *value = resp.value;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(qdcp_tmc_get_param);
+
+static int qdcp_tmc_assign_buffer(struct qdcp_client *client, u64 tmc_id,
+ phys_addr_t paddr, dma_addr_t iaddr,
+ size_t size)
+{
+ struct qdcp_tmc_assign_buffer_req_v01 req = {
+ .tmc_id = tmc_id,
+ .buffer = {
+ .paddr = paddr,
+ .iaddr = iaddr,
+ .size = size,
+ },
+ };
+
+ return qdcp_send(client, QDCP_TMC_ASSIGN_BUFFER,
+ qdcp_tmc_assign_buffer_req_ei, &req,
+ QDCP_TMC_ASSIGN_BUFFER_REQ_MAX_LEN);
+}
+
+/**
+ * qdcp_tmc_etr_configure() - configure a firmware owned TMC ETR
+ * @client: QDCP client.
+ * @tmc_id: firmware identifier of the TMC, the base address of its
+ * registers.
+ * @cfg: ETR configuration.
+ *
+ * Program the buffer mode, the trace buffer and the FFCR. The ETR is then
+ * enabled with qdcp_sink_enable(). The configuration is not rolled back on
+ * failure.
+ *
+ * Return: 0 on success, -EAGAIN if the QDCP server is not available, or
+ * another negative error code.
+ */
+int qdcp_tmc_etr_configure(struct qdcp_client *client, u64 tmc_id,
+ const struct qdcp_tmc_cfg *cfg)
+{
+ int ret;
+
+ ret = qdcp_tmc_set_param(client, tmc_id, QDCP_TMC_PARAM_SG_MODE,
+ cfg->sg_mode);
+ if (ret)
+ return ret;
+
+ ret = qdcp_tmc_assign_buffer(client, tmc_id, cfg->paddr, cfg->iaddr,
+ cfg->size);
+ if (ret)
+ return ret;
+
+ return qdcp_tmc_set_param(client, tmc_id, QDCP_TMC_PARAM_FFCR,
+ cfg->ffcr);
+}
+EXPORT_SYMBOL_GPL(qdcp_tmc_etr_configure);
+
+static int qdcp_tmc_send_id(struct qdcp_client *client, unsigned int msg_id,
+ u64 tmc_id, const struct qmi_elem_info *resp_ei,
+ void *resp, size_t resp_len)
+{
+ struct qdcp_tmc_id_req_v01 req = {
+ .tmc_id = tmc_id,
+ };
+
+ return qdcp_send_resp(client, msg_id, qdcp_tmc_id_req_ei, &req,
+ QDCP_TMC_ID_REQ_MAX_LEN, resp_ei, resp, resp_len);
+}
+
+/**
+ * qdcp_tmc_begin_read() - flush and stop a firmware owned TMC for reading
+ * @client: QDCP client.
+ * @tmc_id: firmware identifier of the TMC, the base address of its
+ * registers.
+ *
+ * Flush and stop the TMC, so that its read and write pointers describe the
+ * trace data. qdcp_tmc_end_read() is called before the TMC is enabled again
+ * for the same session.
+ *
+ * Return: 0 on success, -EAGAIN if the QDCP server is not available, or
+ * another negative error code.
+ */
+int qdcp_tmc_begin_read(struct qdcp_client *client, u64 tmc_id)
+{
+ struct qdcp_tmc_begin_read_resp_v01 resp;
+
+ return qdcp_tmc_send_id(client, QDCP_TMC_BEGIN_READ, tmc_id,
+ qdcp_tmc_begin_read_resp_ei, &resp,
+ sizeof(resp));
+}
+EXPORT_SYMBOL_GPL(qdcp_tmc_begin_read);
+
+/**
+ * qdcp_tmc_end_read() - end reading a firmware owned TMC
+ * @client: QDCP client.
+ * @tmc_id: firmware identifier of the TMC, the base address of its
+ * registers.
+ *
+ * Return: 0 on success, -EAGAIN if the QDCP server is not available, or
+ * another negative error code.
+ */
+int qdcp_tmc_end_read(struct qdcp_client *client, u64 tmc_id)
+{
+ struct qdcp_resp_v01 resp;
+
+ return qdcp_tmc_send_id(client, QDCP_TMC_END_READ, tmc_id,
+ qdcp_resp_ei, &resp, sizeof(resp));
+}
+EXPORT_SYMBOL_GPL(qdcp_tmc_end_read);
+
+static int qdcp_new_server(struct qmi_handle *qmi, struct qmi_service *svc)
+{
+ struct qdcp_client *client = container_of(qmi, struct qdcp_client,
+ qmi);
+
+ mutex_lock(&client->lock);
+ client->sq.sq_family = AF_QIPCRTR;
+ client->sq.sq_node = svc->node;
+ client->sq.sq_port = svc->port;
+ WRITE_ONCE(client->connected, true);
+ svc->priv = client;
+ mutex_unlock(&client->lock);
+
+ wake_up_all(&client->wait);
+ dev_dbg(client->dev, "QDCP server %u:%u available\n", svc->node,
+ svc->port);
+ return 0;
+}
+
+static void qdcp_del_server(struct qmi_handle *qmi, struct qmi_service *svc)
+{
+ struct qdcp_client *client = svc->priv;
+
+ if (!client)
+ return;
+
+ mutex_lock(&client->lock);
+ /*
+ * A firmware restart can announce the new server before the old one
+ * is removed, so only disconnect if this is the current server.
+ */
+ if (client->connected && client->sq.sq_node == svc->node &&
+ client->sq.sq_port == svc->port) {
+ WRITE_ONCE(client->connected, false);
+ memset(&client->sq, 0, sizeof(client->sq));
+ dev_dbg(client->dev, "QDCP server %u:%u removed\n", svc->node,
+ svc->port);
+ }
+ mutex_unlock(&client->lock);
+}
+
+static void qdcp_net_reset(struct qmi_handle *qmi)
+{
+ struct qdcp_client *client = container_of(qmi, struct qdcp_client,
+ qmi);
+
+ mutex_lock(&client->lock);
+ WRITE_ONCE(client->connected, false);
+ memset(&client->sq, 0, sizeof(client->sq));
+ mutex_unlock(&client->lock);
+}
+
+static const struct qmi_ops qdcp_qmi_ops = {
+ .new_server = qdcp_new_server,
+ .del_server = qdcp_del_server,
+ .net_reset = qdcp_net_reset,
+};
+
+static void qdcp_client_release(void *data)
+{
+ struct qdcp_client *client = data;
+
+ qmi_handle_release(&client->qmi);
+}
+
+/**
+ * devm_qdcp_client_get() - create a QDCP client for a device
+ * @dev: client device.
+ * @svc: QDCP service to connect to.
+ *
+ * Create a QMI handle and look up the QDCP server described by @svc. The
+ * server may become available later, see qdcp_client_wait_for_service().
+ * The client is released when @dev is unbound, after its remove callback,
+ * so the driver can still stop the blocks it controls from there.
+ *
+ * Return: the client, or an error pointer on failure.
+ */
+struct qdcp_client *devm_qdcp_client_get(struct device *dev,
+ const struct qdcp_service *svc)
+{
+ struct qdcp_client *client;
+ int ret;
+
+ client = devm_kzalloc(dev, sizeof(*client), GFP_KERNEL);
+ if (!client)
+ return ERR_PTR(-ENOMEM);
+
+ client->dev = dev;
+ init_waitqueue_head(&client->wait);
+ ret = devm_mutex_init(dev, &client->lock);
+ if (ret)
+ return ERR_PTR(ret);
+
+ ret = qmi_handle_init(&client->qmi, QDCP_RECV_MAX_LEN, &qdcp_qmi_ops,
+ NULL);
+ if (ret)
+ return ERR_PTR(ret);
+
+ ret = devm_add_action_or_reset(dev, qdcp_client_release, client);
+ if (ret)
+ return ERR_PTR(ret);
+
+ ret = qmi_add_lookup(&client->qmi, svc->service_id, svc->version,
+ svc->instance_id);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return client;
+}
+EXPORT_SYMBOL_GPL(devm_qdcp_client_get);
+
+/**
+ * qdcp_client_wait_for_service() - wait for the QDCP server
+ * @client: QDCP client.
+ * @timeout_ms: maximum time to wait in milliseconds.
+ *
+ * Return: 0 if the server is available, -ETIMEDOUT otherwise.
+ */
+int qdcp_client_wait_for_service(struct qdcp_client *client,
+ unsigned int timeout_ms)
+{
+ if (!wait_event_timeout(client->wait, READ_ONCE(client->connected),
+ msecs_to_jiffies(timeout_ms)))
+ return -ETIMEDOUT;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(qdcp_client_wait_for_service);
+
+MODULE_DESCRIPTION("Qualcomm Debug Control Protocol client library");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/soc/qcom/qdcp.h b/include/linux/soc/qcom/qdcp.h
new file mode 100644
index 000000000000..4218a9ff63c6
--- /dev/null
+++ b/include/linux/soc/qcom/qdcp.h
@@ -0,0 +1,120 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef _LINUX_SOC_QCOM_QDCP_H
+#define _LINUX_SOC_QCOM_QDCP_H
+
+#include <linux/types.h>
+
+struct device;
+struct qdcp_client;
+
+/**
+ * struct qdcp_service - QMI service implementing QDCP for a set of blocks
+ * @service_id: QMI service identifier.
+ * @version: QMI service version.
+ * @instance_id: QMI service instance identifier.
+ *
+ * The service is fixed by the platform firmware, so drivers provide it
+ * from their SoC specific match data. The blocks controlled through the
+ * service are identified by the base address of their registers: the
+ * source ID of a trace source such as the STM, and the TMC ID of a TMC.
+ */
+struct qdcp_service {
+ u32 service_id;
+ u32 version;
+ u32 instance_id;
+};
+
+/**
+ * enum qdcp_source_type - firmware owned trace source types
+ * @QDCP_SOURCE_STM: System Trace Macrocell.
+ *
+ * The values are used by the firmware to identify the type of a source.
+ */
+enum qdcp_source_type {
+ QDCP_SOURCE_STM = 0,
+};
+
+/**
+ * enum qdcp_sink_type - firmware owned trace sink types
+ * @QDCP_SINK_ETR: TMC configured as an Embedded Trace Router.
+ */
+enum qdcp_sink_type {
+ QDCP_SINK_ETR,
+};
+
+/*
+ * QDCP STM parameter identifiers used in QDCP_STM_GET_PARAM/SET_PARAM
+ * requests. Register parameters use the offset of the STM register, the
+ * firmware reads or writes the register on behalf of the caller.
+ */
+enum qdcp_stm_param {
+ QDCP_STM_PARAM_SPFEAT2R = 0xea4,
+ QDCP_STM_PARAM_DEVID = 0xfc8,
+ QDCP_STM_PARAM_PORT_ENABLE = 0x1002,
+};
+
+/*
+ * QDCP TMC parameter identifiers used in QDCP_TMC_GET_PARAM/SET_PARAM
+ * requests. Register parameters use the offset of the TMC register, the
+ * firmware reads or writes the register on behalf of the caller. SG_MODE,
+ * RRP and RWP are firmware only parameter IDs.
+ */
+enum qdcp_tmc_param {
+ QDCP_TMC_PARAM_STS = 0x00c,
+ QDCP_TMC_PARAM_TRG = 0x01c,
+ QDCP_TMC_PARAM_FFCR = 0x304,
+ QDCP_TMC_PARAM_AUTHSTATUS = 0xfb8,
+ QDCP_TMC_PARAM_DEVID = 0xfc8,
+ QDCP_TMC_PARAM_SG_MODE = 0x1002,
+ QDCP_TMC_PARAM_RRP = 0x1003,
+ QDCP_TMC_PARAM_RWP = 0x1004,
+};
+
+/**
+ * struct qdcp_tmc_cfg - TMC ETR configuration passed to firmware
+ * @paddr: physical address of the trace buffer.
+ * @iaddr: DMA address of the trace buffer as seen by the ETR.
+ * @size: size of the trace buffer in bytes.
+ * @sg_mode: the buffer uses the TMC ETR scatter-gather table format.
+ * @ffcr: formatter and flush control register value.
+ */
+struct qdcp_tmc_cfg {
+ phys_addr_t paddr;
+ dma_addr_t iaddr;
+ size_t size;
+ bool sg_mode;
+ u32 ffcr;
+};
+
+struct qdcp_client *devm_qdcp_client_get(struct device *dev,
+ const struct qdcp_service *svc);
+int qdcp_client_wait_for_service(struct qdcp_client *client,
+ unsigned int timeout_ms);
+
+int qdcp_source_set_atid(struct qdcp_client *client,
+ enum qdcp_source_type type, u64 source_id, u8 atid);
+int qdcp_source_enable(struct qdcp_client *client, enum qdcp_source_type type,
+ u64 source_id);
+int qdcp_source_disable(struct qdcp_client *client, enum qdcp_source_type type,
+ u64 source_id);
+int qdcp_stm_set_port_mask(struct qdcp_client *client, u64 source_id,
+ u32 port_mask);
+int qdcp_stm_get_param(struct qdcp_client *client, u64 source_id,
+ enum qdcp_stm_param param, u32 *value);
+
+int qdcp_sink_enable(struct qdcp_client *client, enum qdcp_sink_type type,
+ u64 sink_id);
+int qdcp_sink_disable(struct qdcp_client *client, enum qdcp_sink_type type,
+ u64 sink_id);
+int qdcp_tmc_etr_configure(struct qdcp_client *client, u64 tmc_id,
+ const struct qdcp_tmc_cfg *cfg);
+int qdcp_tmc_get_param(struct qdcp_client *client, u64 tmc_id,
+ enum qdcp_tmc_param param, u64 *value);
+int qdcp_tmc_begin_read(struct qdcp_client *client, u64 tmc_id);
+int qdcp_tmc_end_read(struct qdcp_client *client, u64 tmc_id);
+
+#endif
--
2.34.1