Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: mediatek: cmdq: add polling function

add polling function in cmdq helper functions

Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

authored by

Bibby Hsieh and committed by
Matthias Brugger
b2ff2356 5c8b718c

+69
+36
drivers/soc/mediatek/mtk-cmdq-helper.c
··· 10 10 #include <linux/soc/mediatek/mtk-cmdq.h> 11 11 12 12 #define CMDQ_WRITE_ENABLE_MASK BIT(0) 13 + #define CMDQ_POLL_ENABLE_MASK BIT(0) 13 14 #define CMDQ_EOC_IRQ_EN BIT(0) 14 15 #define CMDQ_EOC_CMD ((u64)((CMDQ_CODE_EOC << CMDQ_OP_CODE_SHIFT)) \ 15 16 << 32 | CMDQ_EOC_IRQ_EN) ··· 214 213 return cmdq_pkt_append_command(pkt, inst); 215 214 } 216 215 EXPORT_SYMBOL(cmdq_pkt_clear_event); 216 + 217 + int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, 218 + u16 offset, u32 value) 219 + { 220 + struct cmdq_instruction inst = { {0} }; 221 + int err; 222 + 223 + inst.op = CMDQ_CODE_POLL; 224 + inst.value = value; 225 + inst.offset = offset; 226 + inst.subsys = subsys; 227 + err = cmdq_pkt_append_command(pkt, inst); 228 + 229 + return err; 230 + } 231 + EXPORT_SYMBOL(cmdq_pkt_poll); 232 + 233 + int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys, 234 + u16 offset, u32 value, u32 mask) 235 + { 236 + struct cmdq_instruction inst = { {0} }; 237 + int err; 238 + 239 + inst.op = CMDQ_CODE_MASK; 240 + inst.mask = ~mask; 241 + err = cmdq_pkt_append_command(pkt, inst); 242 + if (err < 0) 243 + return err; 244 + 245 + offset = offset | CMDQ_POLL_ENABLE_MASK; 246 + err = cmdq_pkt_poll(pkt, subsys, offset, value); 247 + 248 + return err; 249 + } 250 + EXPORT_SYMBOL(cmdq_pkt_poll_mask); 217 251 218 252 static int cmdq_pkt_finalize(struct cmdq_pkt *pkt) 219 253 {
+1
include/linux/mailbox/mtk-cmdq-mailbox.h
··· 55 55 enum cmdq_code { 56 56 CMDQ_CODE_MASK = 0x02, 57 57 CMDQ_CODE_WRITE = 0x04, 58 + CMDQ_CODE_POLL = 0x08, 58 59 CMDQ_CODE_JUMP = 0x10, 59 60 CMDQ_CODE_WFE = 0x20, 60 61 CMDQ_CODE_EOC = 0x40,
+32
include/linux/soc/mediatek/mtk-cmdq.h
··· 100 100 int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event); 101 101 102 102 /** 103 + * cmdq_pkt_poll() - Append polling command to the CMDQ packet, ask GCE to 104 + * execute an instruction that wait for a specified 105 + * hardware register to check for the value w/o mask. 106 + * All GCE hardware threads will be blocked by this 107 + * instruction. 108 + * @pkt: the CMDQ packet 109 + * @subsys: the CMDQ sub system code 110 + * @offset: register offset from CMDQ sub system 111 + * @value: the specified target register value 112 + * 113 + * Return: 0 for success; else the error code is returned 114 + */ 115 + int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, 116 + u16 offset, u32 value); 117 + 118 + /** 119 + * cmdq_pkt_poll_mask() - Append polling command to the CMDQ packet, ask GCE to 120 + * execute an instruction that wait for a specified 121 + * hardware register to check for the value w/ mask. 122 + * All GCE hardware threads will be blocked by this 123 + * instruction. 124 + * @pkt: the CMDQ packet 125 + * @subsys: the CMDQ sub system code 126 + * @offset: register offset from CMDQ sub system 127 + * @value: the specified target register value 128 + * @mask: the specified target register mask 129 + * 130 + * Return: 0 for success; else the error code is returned 131 + */ 132 + int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys, 133 + u16 offset, u32 value, u32 mask); 134 + /** 103 135 * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ 104 136 * packet and call back at the end of done packet 105 137 * @pkt: the CMDQ packet