History

soc: mediatek: cmdq: add polling function

add polling function in cmdq helper functions

Bibby Hsieh committed 6 years ago

Commit b2ff2351 parent 5c8b7183 files · +69 −0Browse files

Unified · Split

3 files
  1. drivers/soc/mediatek/mtk-cmdq-helper.c +36 −0
  2. include/linux/mailbox/mtk-cmdq-mailbox.h +1 −0
  3. include/linux/soc/mediatek/mtk-cmdq.h +32 −0
drivers/soc/mediatek/mtk-cmdq-helper.c+36−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
10#include <linux/soc/mediatek/mtk-cmdq.h>10#include <linux/soc/mediatek/mtk-cmdq.h>
11 11
12#define CMDQ_WRITE_ENABLE_MASK BIT(0)12#define CMDQ_WRITE_ENABLE_MASK BIT(0)
13#define CMDQ_POLL_ENABLE_MASK BIT(0)
13#define CMDQ_EOC_IRQ_EN BIT(0)14#define CMDQ_EOC_IRQ_EN BIT(0)
14#define CMDQ_EOC_CMD ((u64)((CMDQ_CODE_EOC << CMDQ_OP_CODE_SHIFT)) \15#define CMDQ_EOC_CMD ((u64)((CMDQ_CODE_EOC << CMDQ_OP_CODE_SHIFT)) \
15 << 32 | CMDQ_EOC_IRQ_EN)16 << 32 | CMDQ_EOC_IRQ_EN)
@@ -214,6 +215,41 @@ int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event) · 198 unmodified lines
214}215}
215EXPORT_SYMBOL(cmdq_pkt_clear_event);216EXPORT_SYMBOL(cmdq_pkt_clear_event);
216 217
218int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys,
219 u16 offset, u32 value)
220{
221 struct cmdq_instruction inst = { {0} };
222 int err;
223
224 inst.op = CMDQ_CODE_POLL;
225 inst.value = value;
226 inst.offset = offset;
227 inst.subsys = subsys;
228 err = cmdq_pkt_append_command(pkt, inst);
229
230 return err;
231}
232EXPORT_SYMBOL(cmdq_pkt_poll);
233
234int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
235 u16 offset, u32 value, u32 mask)
236{
237 struct cmdq_instruction inst = { {0} };
238 int err;
239
240 inst.op = CMDQ_CODE_MASK;
241 inst.mask = ~mask;
242 err = cmdq_pkt_append_command(pkt, inst);
243 if (err < 0)
244 return err;
245
246 offset = offset | CMDQ_POLL_ENABLE_MASK;
247 err = cmdq_pkt_poll(pkt, subsys, offset, value);
248
249 return err;
250}
251EXPORT_SYMBOL(cmdq_pkt_poll_mask);
252
217static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)253static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
218{254{
219 struct cmdq_instruction inst = { {0} };255 struct cmdq_instruction inst = { {0} };
include/linux/mailbox/mtk-cmdq-mailbox.h+1−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
55enum cmdq_code {55enum cmdq_code {
56 CMDQ_CODE_MASK = 0x02,56 CMDQ_CODE_MASK = 0x02,
57 CMDQ_CODE_WRITE = 0x04,57 CMDQ_CODE_WRITE = 0x04,
58 CMDQ_CODE_POLL = 0x08,
58 CMDQ_CODE_JUMP = 0x10,59 CMDQ_CODE_JUMP = 0x10,
59 CMDQ_CODE_WFE = 0x20,60 CMDQ_CODE_WFE = 0x20,
60 CMDQ_CODE_EOC = 0x40,61 CMDQ_CODE_EOC = 0x40,
include/linux/soc/mediatek/mtk-cmdq.h+32−0
@@ -99,6 +99,38 @@ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event); · 98 unmodified lines
99 */99 */
100int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event);100int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event);
101 101
102/**
103 * cmdq_pkt_poll() - Append polling command to the CMDQ packet, ask GCE to
104 * execute an instruction that wait for a specified
105 * hardware register to check for the value w/o mask.
106 * All GCE hardware threads will be blocked by this
107 * instruction.
108 * @pkt: the CMDQ packet
109 * @subsys: the CMDQ sub system code
110 * @offset: register offset from CMDQ sub system
111 * @value: the specified target register value
112 *
113 * Return: 0 for success; else the error code is returned
114 */
115int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys,
116 u16 offset, u32 value);
117
118/**
119 * cmdq_pkt_poll_mask() - Append polling command to the CMDQ packet, ask GCE to
120 * execute an instruction that wait for a specified
121 * hardware register to check for the value w/ mask.
122 * All GCE hardware threads will be blocked by this
123 * instruction.
124 * @pkt: the CMDQ packet
125 * @subsys: the CMDQ sub system code
126 * @offset: register offset from CMDQ sub system
127 * @value: the specified target register value
128 * @mask: the specified target register mask
129 *
130 * Return: 0 for success; else the error code is returned
131 */
132int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
133 u16 offset, u32 value, u32 mask);
102/**134/**
103 * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ135 * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ
104 * packet and call back at the end of done packet136 * packet and call back at the end of done packet