Skip to content

Commit 266f357

Browse files
Jason-JH LinAngeloGioacchino Del Regno
authored andcommitted
mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction
Add the cmdq_mbox_priv structure to store the private data of GCE, such as the shift bits of the physical address. Then, include the cmdq_mbox_priv structure within the cmdq_pkt structure. This allows CMDQ users to utilize the private data in cmdq_pkt to generate GCE instructions when needed. Additionally, having cmdq_mbox_priv makes it easier to expand and reference other GCE private data in the future. Add cmdq_get_mbox_priv() for CMDQ users to get all the private data into the cmdq_mbox_priv of the cmdq_pkt. Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Acked-by: Jassi Brar <jassisinghbrar@gmail.com> Acked-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
1 parent 3da293d commit 266f357

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/mailbox/mtk-cmdq-mailbox.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ static inline dma_addr_t cmdq_revert_gce_addr(u32 addr, const struct gce_plat *p
104104
return (dma_addr_t)addr << pdata->shift;
105105
}
106106

107+
void cmdq_get_mbox_priv(struct mbox_chan *chan, struct cmdq_mbox_priv *priv)
108+
{
109+
struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);
110+
111+
priv->shift_pa = cmdq->pdata->shift;
112+
}
113+
EXPORT_SYMBOL(cmdq_get_mbox_priv);
114+
107115
u8 cmdq_get_shift_pa(struct mbox_chan *chan)
108116
{
109117
struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);

include/linux/mailbox/mtk-cmdq-mailbox.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,31 @@ struct cmdq_cb_data {
7070
struct cmdq_pkt *pkt;
7171
};
7272

73+
struct cmdq_mbox_priv {
74+
u8 shift_pa;
75+
};
76+
7377
struct cmdq_pkt {
7478
void *va_base;
7579
dma_addr_t pa_base;
7680
size_t cmd_buf_size; /* command occupied size */
7781
size_t buf_size; /* real buffer size */
82+
struct cmdq_mbox_priv priv; /* for generating instruction */
7883
};
7984

85+
/**
86+
* cmdq_get_mbox_priv() - get the private data of mailbox channel
87+
* @chan: mailbox channel
88+
* @priv: pointer to store the private data of mailbox channel
89+
*
90+
* While generating the GCE instruction to command buffer, the private data
91+
* of GCE hardware may need to be referenced, such as the shift bits of
92+
* physical address.
93+
*
94+
* This function should be called before generating the GCE instruction.
95+
*/
96+
void cmdq_get_mbox_priv(struct mbox_chan *chan, struct cmdq_mbox_priv *priv);
97+
8098
/**
8199
* cmdq_get_shift_pa() - get the shift bits of physical address
82100
* @chan: mailbox channel

0 commit comments

Comments
 (0)