summaryrefslogtreecommitdiffstats
path: root/include/linux/soc
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2018-12-12 16:32:27 -0500
committerOlof Johansson <olof@lixom.net>2018-12-12 16:32:27 -0500
commit8986f4c2172f9d31f3eaa4e0e4a1efb2a7cbefb5 (patch)
treeec5dd27c15f77c3b011400010ee3832a3bfc16f4 /include/linux/soc
parentbb7ece5fc43fb597ff965c79ddd62c3806f3e319 (diff)
parent576f1b4bc80220e1f88f1de5ecb25d99a6e9fa04 (diff)
Merge tag 'v4.20-next-soc' of https://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux into next/drivers
add helper functions to create and send commands to the global command engine (GCE) device using the command queue driver (cmdq). * tag 'v4.20-next-soc' of https://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux: soc: mediatek: Add Mediatek CMDQ helper Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'include/linux/soc')
-rw-r--r--include/linux/soc/mediatek/mtk-cmdq.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
new file mode 100644
index 000000000000..54ade13a9b15
--- /dev/null
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -0,0 +1,133 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2018 MediaTek Inc.
4 *
5 */
6
7#ifndef __MTK_CMDQ_H__
8#define __MTK_CMDQ_H__
9
10#include <linux/mailbox_client.h>
11#include <linux/mailbox/mtk-cmdq-mailbox.h>
12#include <linux/timer.h>
13
14#define CMDQ_NO_TIMEOUT 0xffffffffu
15
16/** cmdq event maximum */
17#define CMDQ_MAX_EVENT 0x3ff
18
19struct cmdq_pkt;
20
21struct cmdq_client {
22 spinlock_t lock;
23 u32 pkt_cnt;
24 struct mbox_client client;
25 struct mbox_chan *chan;
26 struct timer_list timer;
27 u32 timeout_ms; /* in unit of microsecond */
28};
29
30/**
31 * cmdq_mbox_create() - create CMDQ mailbox client and channel
32 * @dev: device of CMDQ mailbox client
33 * @index: index of CMDQ mailbox channel
34 * @timeout: timeout of a pkt execution by GCE, in unit of microsecond, set
35 * CMDQ_NO_TIMEOUT if a timer is not used.
36 *
37 * Return: CMDQ mailbox client pointer
38 */
39struct cmdq_client *cmdq_mbox_create(struct device *dev, int index,
40 u32 timeout);
41
42/**
43 * cmdq_mbox_destroy() - destroy CMDQ mailbox client and channel
44 * @client: the CMDQ mailbox client
45 */
46void cmdq_mbox_destroy(struct cmdq_client *client);
47
48/**
49 * cmdq_pkt_create() - create a CMDQ packet
50 * @client: the CMDQ mailbox client
51 * @size: required CMDQ buffer size
52 *
53 * Return: CMDQ packet pointer
54 */
55struct cmdq_pkt *cmdq_pkt_create(struct cmdq_client *client, size_t size);
56
57/**
58 * cmdq_pkt_destroy() - destroy the CMDQ packet
59 * @pkt: the CMDQ packet
60 */
61void cmdq_pkt_destroy(struct cmdq_pkt *pkt);
62
63/**
64 * cmdq_pkt_write() - append write command to the CMDQ packet
65 * @pkt: the CMDQ packet
66 * @value: the specified target register value
67 * @subsys: the CMDQ sub system code
68 * @offset: register offset from CMDQ sub system
69 *
70 * Return: 0 for success; else the error code is returned
71 */
72int cmdq_pkt_write(struct cmdq_pkt *pkt, u32 value, u32 subsys, u32 offset);
73
74/**
75 * cmdq_pkt_write_mask() - append write command with mask to the CMDQ packet
76 * @pkt: the CMDQ packet
77 * @value: the specified target register value
78 * @subsys: the CMDQ sub system code
79 * @offset: register offset from CMDQ sub system
80 * @mask: the specified target register mask
81 *
82 * Return: 0 for success; else the error code is returned
83 */
84int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u32 value,
85 u32 subsys, u32 offset, u32 mask);
86
87/**
88 * cmdq_pkt_wfe() - append wait for event command to the CMDQ packet
89 * @pkt: the CMDQ packet
90 * @event: the desired event type to "wait and CLEAR"
91 *
92 * Return: 0 for success; else the error code is returned
93 */
94int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u32 event);
95
96/**
97 * cmdq_pkt_clear_event() - append clear event command to the CMDQ packet
98 * @pkt: the CMDQ packet
99 * @event: the desired event to be cleared
100 *
101 * Return: 0 for success; else the error code is returned
102 */
103int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u32 event);
104
105/**
106 * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ
107 * packet and call back at the end of done packet
108 * @pkt: the CMDQ packet
109 * @cb: called at the end of done packet
110 * @data: this data will pass back to cb
111 *
112 * Return: 0 for success; else the error code is returned
113 *
114 * Trigger CMDQ to asynchronously execute the CMDQ packet and call back
115 * at the end of done packet. Note that this is an ASYNC function. When the
116 * function returned, it may or may not be finished.
117 */
118int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb,
119 void *data);
120
121/**
122 * cmdq_pkt_flush() - trigger CMDQ to execute the CMDQ packet
123 * @pkt: the CMDQ packet
124 *
125 * Return: 0 for success; else the error code is returned
126 *
127 * Trigger CMDQ to execute the CMDQ packet. Note that this is a
128 * synchronous flush function. When the function returned, the recorded
129 * commands have been done.
130 */
131int cmdq_pkt_flush(struct cmdq_pkt *pkt);
132
133#endif /* __MTK_CMDQ_H__ */