Unverified Commit 22ce09ce authored by Jason-JH Lin's avatar Jason-JH Lin Committed by AngeloGioacchino Del Regno
Browse files

soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM addresses



Since GCE has been moved to MMINFRA in MT8196, all transactions from
MMINFRA to DRAM will have their addresses adjusted by subtracting a
mminfra_offset.

Therefore, the CMDQ helper driver needs to get the mminfra_offset value
of the SoC from cmdq_mbox_priv of cmdq_pkt and then add it to the DRAM
address when generating instructions to ensure GCE accesses the correct
DRAM address. CMDQ users can then call CMDQ helper APIs as usual.

Signed-off-by: default avatarJason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: default avatarJassi Brar <jassisinghbrar@gmail.com>
Acked-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
parent 40dc5bba
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ int cmdq_pkt_mem_move(struct cmdq_pkt *pkt, dma_addr_t src_addr, dma_addr_t dst_
	int ret;

	/* read the value of src_addr into high_addr_reg_idx */
	src_addr += pkt->priv.mminfra_offset;
	ret = cmdq_pkt_assign(pkt, high_addr_reg_idx, CMDQ_ADDR_HIGH(src_addr));
	if (ret < 0)
		return ret;
@@ -380,6 +381,7 @@ int cmdq_pkt_mem_move(struct cmdq_pkt *pkt, dma_addr_t src_addr, dma_addr_t dst_
		return ret;

	/* write the value of value_reg_idx into dst_addr */
	dst_addr += pkt->priv.mminfra_offset;
	ret = cmdq_pkt_assign(pkt, high_addr_reg_idx, CMDQ_ADDR_HIGH(dst_addr));
	if (ret < 0)
		return ret;
@@ -505,7 +507,7 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32 value, u32 mas
	inst.op = CMDQ_CODE_MASK;
	inst.dst_t = CMDQ_REG_TYPE;
	inst.sop = CMDQ_POLL_ADDR_GPR;
	inst.value = addr;
	inst.value = addr + pkt->priv.mminfra_offset;
	ret = cmdq_pkt_append_command(pkt, inst);
	if (ret < 0)
		return ret;
@@ -565,7 +567,7 @@ int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
	struct cmdq_instruction inst = {
		.op = CMDQ_CODE_JUMP,
		.offset = CMDQ_JUMP_ABSOLUTE,
		.value = addr >> shift_pa
		.value = (addr +  pkt->priv.mminfra_offset) >> pkt->priv.shift_pa
	};
	return cmdq_pkt_append_command(pkt, inst);
}