Skip to content

Commit d3b04aa

Browse files
Dennis YC Hsiehmbgg
authored andcommitted
soc: mediatek: cmdq: add read_s function
Add read_s function in cmdq helper functions which support read value from register or dma physical address into gce internal register. Signed-off-by: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com> Link: https://lore.kernel.org/r/1594136714-11650-5-git-send-email-dennis-yc.hsieh@mediatek.com Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
1 parent 11c7842 commit d3b04aa

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,21 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
227227
}
228228
EXPORT_SYMBOL(cmdq_pkt_write_mask);
229229

230+
int cmdq_pkt_read_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx, u16 addr_low,
231+
u16 reg_idx)
232+
{
233+
struct cmdq_instruction inst = {};
234+
235+
inst.op = CMDQ_CODE_READ_S;
236+
inst.dst_t = CMDQ_REG_TYPE;
237+
inst.sop = high_addr_reg_idx;
238+
inst.reg_dst = reg_idx;
239+
inst.src_reg = addr_low;
240+
241+
return cmdq_pkt_append_command(pkt, inst);
242+
}
243+
EXPORT_SYMBOL(cmdq_pkt_read_s);
244+
230245
int cmdq_pkt_write_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
231246
u16 addr_low, u16 src_reg_idx)
232247
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum cmdq_code {
6060
CMDQ_CODE_JUMP = 0x10,
6161
CMDQ_CODE_WFE = 0x20,
6262
CMDQ_CODE_EOC = 0x40,
63+
CMDQ_CODE_READ_S = 0x80,
6364
CMDQ_CODE_WRITE_S = 0x90,
6465
CMDQ_CODE_WRITE_S_MASK = 0x91,
6566
CMDQ_CODE_LOGIC = 0xa0,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value);
104104
int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
105105
u16 offset, u32 value, u32 mask);
106106

107+
/*
108+
* cmdq_pkt_read_s() - append read_s command to the CMDQ packet
109+
* @pkt: the CMDQ packet
110+
* @high_addr_reg_idx: internal register ID which contains high address of pa
111+
* @addr_low: low address of pa
112+
* @reg_idx: the CMDQ internal register ID to cache read data
113+
*
114+
* Return: 0 for success; else the error code is returned
115+
*/
116+
int cmdq_pkt_read_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx, u16 addr_low,
117+
u16 reg_idx);
118+
107119
/**
108120
* cmdq_pkt_write_s() - append write_s command to the CMDQ packet
109121
* @pkt: the CMDQ packet

0 commit comments

Comments
 (0)