History

soc: mediatek: cmdq: add assign function

Add assign function in cmdq helper which assign constant value into internal register by index.

Dennis YC Hsieh committed 6 years ago

Commit 613c2e21 parent b3a9e3b3 files · +38 −1Browse files

Unified · Split

3 files
  1. drivers/soc/mediatek/mtk-cmdq-helper.c +23 −1
  2. include/linux/mailbox/mtk-cmdq-mailbox.h +1 −0
  3. include/linux/soc/mediatek/mtk-cmdq.h +14 −0
drivers/soc/mediatek/mtk-cmdq-helper.c+23−1
@@ -12,6 +12,7 @@ · 11 unmodified lines
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_POLL_ENABLE_MASK BIT(0)
14#define CMDQ_EOC_IRQ_EN BIT(0)14#define CMDQ_EOC_IRQ_EN BIT(0)
15#define CMDQ_REG_TYPE 1
15 16
16struct cmdq_instruction {17struct cmdq_instruction {
17 union {18 union {
@@ -21,8 +22,17 @@ struct cmdq_instruction { · 3 unmodified lines
21 union {22 union {
22 u16 offset;23 u16 offset;
23 u16 event;24 u16 event;
25 u16 reg_dst;
26 };
27 union {
28 u8 subsys;
29 struct {
30 u8 sop:5;
31 u8 arg_c_t:1;
32 u8 src_t:1;
33 u8 dst_t:1;
34 };
24 };35 };
25 u8 subsys;
26 u8 op;36 u8 op;
27};37};
28 38
@@ -278,6 +288,18 @@ int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys, · 249 unmodified lines
278}288}
279EXPORT_SYMBOL(cmdq_pkt_poll_mask);289EXPORT_SYMBOL(cmdq_pkt_poll_mask);
280 290
291int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value)
292{
293 struct cmdq_instruction inst = {};
294
295 inst.op = CMDQ_CODE_LOGIC;
296 inst.dst_t = CMDQ_REG_TYPE;
297 inst.reg_dst = reg_idx;
298 inst.value = value;
299 return cmdq_pkt_append_command(pkt, inst);
300}
301EXPORT_SYMBOL(cmdq_pkt_assign);
302
281static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)303static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
282{304{
283 struct cmdq_instruction inst = { {0} };305 struct cmdq_instruction inst = { {0} };
include/linux/mailbox/mtk-cmdq-mailbox.h+1−0
@@ -59,6 +59,7 @@ enum cmdq_code { · 58 unmodified lines
59 CMDQ_CODE_JUMP = 0x10,59 CMDQ_CODE_JUMP = 0x10,
60 CMDQ_CODE_WFE = 0x20,60 CMDQ_CODE_WFE = 0x20,
61 CMDQ_CODE_EOC = 0x40,61 CMDQ_CODE_EOC = 0x40,
62 CMDQ_CODE_LOGIC = 0xa0,
62};63};
63 64
64enum cmdq_cb_status {65enum cmdq_cb_status {
include/linux/soc/mediatek/mtk-cmdq.h+14−0
@@ -152,6 +152,20 @@ int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, · 151 unmodified lines
152 */152 */
153int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,153int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
154 u16 offset, u32 value, u32 mask);154 u16 offset, u32 value, u32 mask);
155
156/**
157 * cmdq_pkt_assign() - Append logic assign command to the CMDQ packet, ask GCE
158 * to execute an instruction that set a constant value into
159 * internal register and use as value, mask or address in
160 * read/write instruction.
161 * @pkt: the CMDQ packet
162 * @reg_idx: the CMDQ internal register ID
163 * @value: the specified value
164 *
165 * Return: 0 for success; else the error code is returned
166 */
167int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value);
168
155/**169/**
156 * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ170 * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ
157 * packet and call back at the end of done packet171 * packet and call back at the end of done packet