Skip to content

Commit 613c2e2

Browse files
Dennis YC Hsiehmbgg
authored andcommitted
soc: mediatek: cmdq: add assign function
Add assign function in cmdq helper which assign constant value into internal register by index. Signed-off-by: Dennis YC Hsieh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Matthias Brugger <[email protected]>
1 parent b3a9e3b commit 613c2e2

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

drivers/soc/mediatek/mtk-cmdq-helper.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define CMDQ_WRITE_ENABLE_MASK BIT(0)
1313
#define CMDQ_POLL_ENABLE_MASK BIT(0)
1414
#define CMDQ_EOC_IRQ_EN BIT(0)
15+
#define CMDQ_REG_TYPE 1
1516

1617
struct cmdq_instruction {
1718
union {
@@ -21,8 +22,17 @@ struct cmdq_instruction {
2122
union {
2223
u16 offset;
2324
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+
};
2435
};
25-
u8 subsys;
2636
u8 op;
2737
};
2838

@@ -278,6 +288,18 @@ int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
278288
}
279289
EXPORT_SYMBOL(cmdq_pkt_poll_mask);
280290

291+
int 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+
}
301+
EXPORT_SYMBOL(cmdq_pkt_assign);
302+
281303
static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
282304
{
283305
struct cmdq_instruction inst = { {0} };

include/linux/mailbox/mtk-cmdq-mailbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ enum cmdq_code {
5959
CMDQ_CODE_JUMP = 0x10,
6060
CMDQ_CODE_WFE = 0x20,
6161
CMDQ_CODE_EOC = 0x40,
62+
CMDQ_CODE_LOGIC = 0xa0,
6263
};
6364

6465
enum cmdq_cb_status {

include/linux/soc/mediatek/mtk-cmdq.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys,
152152
*/
153153
int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
154154
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+
*/
167+
int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value);
168+
155169
/**
156170
* cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ
157171
* packet and call back at the end of done packet

0 commit comments

Comments
 (0)