Skip to content

Commit

Permalink
[DM/MAILBOX] Support PIC mailbox in AMP
Browse files Browse the repository at this point in the history
Should registers clean by master in AMP.

Signed-off-by: GuEe-GUI <[email protected]>
  • Loading branch information
GuEe-GUI authored and Rbb666 committed Dec 18, 2024
1 parent 07b114a commit c9ab55f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions components/drivers/mailbox/mailbox-pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static rt_err_t pic_mbox_request(struct rt_mbox_chan *chan)
struct pic_mbox *pic_mbox = raw_to_pic_mbox(chan->ctrl);

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

return RT_EOK;
}
Expand All @@ -89,6 +90,11 @@ static rt_err_t pic_mbox_send(struct rt_mbox_chan *chan, const void *data)
rt_thread_yield();
}

if (HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) & RT_BIT(index))
{
return -RT_ERROR;
}

level = rt_spin_lock_irqsave(&pic_mbox->lock);

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

pic_mbox->peer_regs = pic_mbox->regs + size / 2;

/* Init by the captain */
HWREG32(pic_mbox->regs + MAILBOX_IMASK) = 0xffffffff;
HWREG32(pic_mbox->regs + MAILBOX_ISTATE) = 0;
HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) = 0xffffffff;
HWREG32(pic_mbox->peer_regs + MAILBOX_ISTATE) = 0;
}
else
{
Expand Down

0 comments on commit c9ab55f

Please sign in to comment.