Skip to content

Commit 7247e1f

Browse files
committed
Merge tag 'v5.8-next-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux into arm/drivers
add new functions to cmdq helper functions - assign value to register - export finalize function and don't call explicitely from flush async - set specific event * tag 'v5.8-next-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux: soc: mediatek: cmdq: add set event function soc: mediatek: cmdq: export finalize function soc: mediatek: cmdq: add assign function Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 409d01f + 7de796c commit 7247e1f

File tree

4 files changed

+74
-6
lines changed

4 files changed

+74
-6
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
492492
cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event);
493493
cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event);
494494
mtk_crtc_ddp_config(crtc, cmdq_handle);
495+
cmdq_pkt_finalize(cmdq_handle);
495496
cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
496497
}
497498
#endif

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

Lines changed: 40 additions & 6 deletions
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

@@ -243,6 +253,21 @@ int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event)
243253
}
244254
EXPORT_SYMBOL(cmdq_pkt_clear_event);
245255

256+
int cmdq_pkt_set_event(struct cmdq_pkt *pkt, u16 event)
257+
{
258+
struct cmdq_instruction inst = {};
259+
260+
if (event >= CMDQ_MAX_EVENT)
261+
return -EINVAL;
262+
263+
inst.op = CMDQ_CODE_WFE;
264+
inst.value = CMDQ_WFE_UPDATE | CMDQ_WFE_UPDATE_VALUE;
265+
inst.event = event;
266+
267+
return cmdq_pkt_append_command(pkt, inst);
268+
}
269+
EXPORT_SYMBOL(cmdq_pkt_set_event);
270+
246271
int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys,
247272
u16 offset, u32 value)
248273
{
@@ -278,7 +303,19 @@ int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
278303
}
279304
EXPORT_SYMBOL(cmdq_pkt_poll_mask);
280305

281-
static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
306+
int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value)
307+
{
308+
struct cmdq_instruction inst = {};
309+
310+
inst.op = CMDQ_CODE_LOGIC;
311+
inst.dst_t = CMDQ_REG_TYPE;
312+
inst.reg_dst = reg_idx;
313+
inst.value = value;
314+
return cmdq_pkt_append_command(pkt, inst);
315+
}
316+
EXPORT_SYMBOL(cmdq_pkt_assign);
317+
318+
int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
282319
{
283320
struct cmdq_instruction inst = { {0} };
284321
int err;
@@ -297,6 +334,7 @@ static int cmdq_pkt_finalize(struct cmdq_pkt *pkt)
297334

298335
return err;
299336
}
337+
EXPORT_SYMBOL(cmdq_pkt_finalize);
300338

301339
static void cmdq_pkt_flush_async_cb(struct cmdq_cb_data data)
302340
{
@@ -331,10 +369,6 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb,
331369
unsigned long flags = 0;
332370
struct cmdq_client *client = (struct cmdq_client *)pkt->cl;
333371

334-
err = cmdq_pkt_finalize(pkt);
335-
if (err < 0)
336-
return err;
337-
338372
pkt->cb.cb = cb;
339373
pkt->cb.data = data;
340374
pkt->async_cb.cb = cmdq_pkt_flush_async_cb;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define CMDQ_JUMP_PASS CMDQ_INST_SIZE
1818

1919
#define CMDQ_WFE_UPDATE BIT(31)
20+
#define CMDQ_WFE_UPDATE_VALUE BIT(16)
2021
#define CMDQ_WFE_WAIT BIT(15)
2122
#define CMDQ_WFE_WAIT_VALUE 0x1
2223

@@ -59,6 +60,7 @@ enum cmdq_code {
5960
CMDQ_CODE_JUMP = 0x10,
6061
CMDQ_CODE_WFE = 0x20,
6162
CMDQ_CODE_EOC = 0x40,
63+
CMDQ_CODE_LOGIC = 0xa0,
6264
};
6365

6466
enum cmdq_cb_status {

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event);
120120
*/
121121
int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event);
122122

123+
/**
124+
* cmdq_pkt_set_event() - append set event command to the CMDQ packet
125+
* @pkt: the CMDQ packet
126+
* @event: the desired event to be set
127+
*
128+
* Return: 0 for success; else the error code is returned
129+
*/
130+
int cmdq_pkt_set_event(struct cmdq_pkt *pkt, u16 event);
131+
123132
/**
124133
* cmdq_pkt_poll() - Append polling command to the CMDQ packet, ask GCE to
125134
* execute an instruction that wait for a specified
@@ -152,6 +161,28 @@ int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys,
152161
*/
153162
int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,
154163
u16 offset, u32 value, u32 mask);
164+
165+
/**
166+
* cmdq_pkt_assign() - Append logic assign command to the CMDQ packet, ask GCE
167+
* to execute an instruction that set a constant value into
168+
* internal register and use as value, mask or address in
169+
* read/write instruction.
170+
* @pkt: the CMDQ packet
171+
* @reg_idx: the CMDQ internal register ID
172+
* @value: the specified value
173+
*
174+
* Return: 0 for success; else the error code is returned
175+
*/
176+
int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value);
177+
178+
/**
179+
* cmdq_pkt_finalize() - Append EOC and jump command to pkt.
180+
* @pkt: the CMDQ packet
181+
*
182+
* Return: 0 for success; else the error code is returned
183+
*/
184+
int cmdq_pkt_finalize(struct cmdq_pkt *pkt);
185+
155186
/**
156187
* cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ
157188
* packet and call back at the end of done packet

0 commit comments

Comments
 (0)