Skip to content

Commit c9ab55f

Browse files
GuEe-GUIRbb666
authored andcommitted
[DM/MAILBOX] Support PIC mailbox in AMP
Should registers clean by master in AMP. Signed-off-by: GuEe-GUI <[email protected]>
1 parent 07b114a commit c9ab55f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

components/drivers/mailbox/mailbox-pic.c

+12
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static rt_err_t pic_mbox_request(struct rt_mbox_chan *chan)
6666
struct pic_mbox *pic_mbox = raw_to_pic_mbox(chan->ctrl);
6767

6868
HWREG32(pic_mbox->regs + MAILBOX_IMASK) &= ~RT_BIT(index);
69+
HWREG32(pic_mbox->regs + MAILBOX_ISTATE) = 0;
6970

7071
return RT_EOK;
7172
}
@@ -89,6 +90,11 @@ static rt_err_t pic_mbox_send(struct rt_mbox_chan *chan, const void *data)
8990
rt_thread_yield();
9091
}
9192

93+
if (HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) & RT_BIT(index))
94+
{
95+
return -RT_ERROR;
96+
}
97+
9298
level = rt_spin_lock_irqsave(&pic_mbox->lock);
9399

94100
HWREG32(pic_mbox->regs + MAILBOX_MSG(index)) = *(rt_uint32_t *)data;
@@ -187,6 +193,12 @@ static rt_err_t pic_mbox_probe(struct rt_platform_device *pdev)
187193
}
188194

189195
pic_mbox->peer_regs = pic_mbox->regs + size / 2;
196+
197+
/* Init by the captain */
198+
HWREG32(pic_mbox->regs + MAILBOX_IMASK) = 0xffffffff;
199+
HWREG32(pic_mbox->regs + MAILBOX_ISTATE) = 0;
200+
HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) = 0xffffffff;
201+
HWREG32(pic_mbox->peer_regs + MAILBOX_ISTATE) = 0;
190202
}
191203
else
192204
{

0 commit comments

Comments
 (0)