@@ -167,9 +167,17 @@ static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask,
u32 tmp;
if (mmsys->cmdq_base.size && cmdq_pkt) {
- ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys,
- mmsys->cmdq_base.offset + offset, val,
- mask);
+ offset += mmsys->cmdq_base.offset;
+ if (mmsys->cmdq_base.subsys != CMDQ_SUBSYS_INVALID) {
+ ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys,
+ offset, val, mask);
+ } else {
+ /* only MMIO access, no need to check mminfro_offset */
+ ret = cmdq_pkt_assign(cmdq_pkt, CMDQ_THR_SPR_IDX0,
+ CMDQ_ADDR_HIGH(mmsys->cmdq_base.pa_base));
+ ret |= cmdq_pkt_write_s_mask_value(cmdq_pkt, CMDQ_THR_SPR_IDX0,
+ CMDQ_ADDR_LOW(offset), val, mask);
+ }
if (ret)
pr_debug("CMDQ unavailable: using CPU write\n");
else
@@ -963,6 +963,7 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt)
struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
mutex[mutex->id]);
struct cmdq_pkt *cmdq_pkt = (struct cmdq_pkt *)pkt;
+ dma_addr_t en_addr = mtx->addr + DISP_REG_MUTEX_EN(mutex->id);
WARN_ON(&mtx->mutex[mutex->id] != mutex);
@@ -971,8 +972,14 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt)
return -ENODEV;
}
- cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys,
- mtx->addr + DISP_REG_MUTEX_EN(mutex->id), 1);
+ if (mtx->cmdq_reg.subsys != CMDQ_SUBSYS_INVALID) {
+ cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys, en_addr, 1);
+ } else {
+ /* only MMIO access, no need to check mminfro_offset */
+ cmdq_pkt_assign(cmdq_pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(en_addr));
+ cmdq_pkt_write_s_value(cmdq_pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_LOW(en_addr), 1);
+ }
+
return 0;
}
EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq);
To support hardware without subsys IDs on new SoCs, add a programming flow that checks whether the subsys ID is valid. If the subsys ID is invalid, the flow will call 2 alternative CMDQ APIs: cmdq_pkt_assign() and cmdq_pkt_write_s_value() to achieve the same functionality. Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com> --- drivers/soc/mediatek/mtk-mmsys.c | 14 +++++++++++--- drivers/soc/mediatek/mtk-mutex.c | 11 +++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-)