Skip to content

Commit 11c7842

Browse files
Dennis YC Hsiehmbgg
authored andcommitted
soc: mediatek: cmdq: add write_s_mask function
add write_s_mask function in cmdq helper functions which writes value contains in internal register to address with mask and large dma access support. Signed-off-by: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com> Link: https://lore.kernel.org/r/1594136714-11650-4-git-send-email-dennis-yc.hsieh@mediatek.com Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
1 parent 5f6e560 commit 11c7842

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,29 @@ int cmdq_pkt_write_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
242242
}
243243
EXPORT_SYMBOL(cmdq_pkt_write_s);
244244

245+
int cmdq_pkt_write_s_mask(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
246+
u16 addr_low, u16 src_reg_idx, u32 mask)
247+
{
248+
struct cmdq_instruction inst = {};
249+
int err;
250+
251+
inst.op = CMDQ_CODE_MASK;
252+
inst.mask = ~mask;
253+
err = cmdq_pkt_append_command(pkt, inst);
254+
if (err < 0)
255+
return err;
256+
257+
inst.mask = 0;
258+
inst.op = CMDQ_CODE_WRITE_S_MASK;
259+
inst.src_t = CMDQ_REG_TYPE;
260+
inst.sop = high_addr_reg_idx;
261+
inst.offset = addr_low;
262+
inst.src_reg = src_reg_idx;
263+
264+
return cmdq_pkt_append_command(pkt, inst);
265+
}
266+
EXPORT_SYMBOL(cmdq_pkt_write_s_mask);
267+
245268
int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event)
246269
{
247270
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
@@ -61,6 +61,7 @@ enum cmdq_code {
6161
CMDQ_CODE_WFE = 0x20,
6262
CMDQ_CODE_EOC = 0x40,
6363
CMDQ_CODE_WRITE_S = 0x90,
64+
CMDQ_CODE_WRITE_S_MASK = 0x91,
6465
CMDQ_CODE_LOGIC = 0xa0,
6566
};
6667

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
121121
int cmdq_pkt_write_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
122122
u16 addr_low, u16 src_reg_idx);
123123

124+
/**
125+
* cmdq_pkt_write_s_mask() - append write_s with mask command to the CMDQ packet
126+
* @pkt: the CMDQ packet
127+
* @high_addr_reg_idx: internal register ID which contains high address of pa
128+
* @addr_low: low address of pa
129+
* @src_reg_idx: the CMDQ internal register ID which cache source value
130+
* @mask: the specified target address mask, use U32_MAX if no need
131+
*
132+
* Return: 0 for success; else the error code is returned
133+
*
134+
* Support write value to physical address without subsys. Use CMDQ_ADDR_HIGH()
135+
* to get high address and call cmdq_pkt_assign() to assign value into internal
136+
* reg. Also use CMDQ_ADDR_LOW() to get low address for addr_low parameter when
137+
* call to this function.
138+
*/
139+
int cmdq_pkt_write_s_mask(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
140+
u16 addr_low, u16 src_reg_idx, u32 mask);
141+
124142
/**
125143
* cmdq_pkt_wfe() - append wait for event command to the CMDQ packet
126144
* @pkt: the CMDQ packet

0 commit comments

Comments
 (0)