Skip to content

Commit 5f6e560

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

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct cmdq_instruction {
1818
union {
1919
u32 value;
2020
u32 mask;
21+
struct {
22+
u16 arg_c;
23+
u16 src_reg;
24+
};
2125
};
2226
union {
2327
u16 offset;
@@ -223,6 +227,21 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
223227
}
224228
EXPORT_SYMBOL(cmdq_pkt_write_mask);
225229

230+
int cmdq_pkt_write_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
231+
u16 addr_low, u16 src_reg_idx)
232+
{
233+
struct cmdq_instruction inst = {};
234+
235+
inst.op = CMDQ_CODE_WRITE_S;
236+
inst.src_t = CMDQ_REG_TYPE;
237+
inst.sop = high_addr_reg_idx;
238+
inst.offset = addr_low;
239+
inst.src_reg = src_reg_idx;
240+
241+
return cmdq_pkt_append_command(pkt, inst);
242+
}
243+
EXPORT_SYMBOL(cmdq_pkt_write_s);
244+
226245
int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event)
227246
{
228247
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
@@ -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_WRITE_S = 0x90,
6364
CMDQ_CODE_LOGIC = 0xa0,
6465
};
6566

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <linux/timer.h>
1313

1414
#define CMDQ_NO_TIMEOUT 0xffffffffu
15+
#define CMDQ_ADDR_HIGH(addr) ((u32)(((addr) >> 16) & GENMASK(31, 0)))
16+
#define CMDQ_ADDR_LOW(addr) ((u16)(addr) | BIT(1))
1517

1618
struct cmdq_pkt;
1719

@@ -102,6 +104,23 @@ int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value);
102104
int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
103105
u16 offset, u32 value, u32 mask);
104106

107+
/**
108+
* cmdq_pkt_write_s() - append write_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+
* @src_reg_idx: the CMDQ internal register ID which cache source value
113+
*
114+
* Return: 0 for success; else the error code is returned
115+
*
116+
* Support write value to physical address without subsys. Use CMDQ_ADDR_HIGH()
117+
* to get high address and call cmdq_pkt_assign() to assign value into internal
118+
* reg. Also use CMDQ_ADDR_LOW() to get low address for addr_low parameter when
119+
* call to this function.
120+
*/
121+
int cmdq_pkt_write_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
122+
u16 addr_low, u16 src_reg_idx);
123+
105124
/**
106125
* cmdq_pkt_wfe() - append wait for event command to the CMDQ packet
107126
* @pkt: the CMDQ packet

0 commit comments

Comments
 (0)