/* Attempt to flush the FIFO until the IRQ is cleared. */ do { while (sun6i_msgbox_peek_data(chan))
readl(mbox->regs + MSG_DATA_REG(n));
writel(RX_IRQ(n), mbox->regs + LOCAL_IRQ_STAT_REG);
} while (readl(mbox->regs + LOCAL_IRQ_STAT_REG) & RX_IRQ(n));
}
staticbool sun6i_msgbox_last_tx_done(struct mbox_chan *chan)
{ struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); int n = channel_number(chan);
/* * The hardware allows snooping on the remote user's IRQ statuses. * We consider a message to be acknowledged only once the receive IRQ * for that channel is cleared. Since the receive IRQ for a channel * cannot be cleared until the FIFO for that channel is empty, this * ensures that the message has actually been read. It also gives the * recipient an opportunity to perform minimal processing before * acknowledging the message.
*/ return !(readl(mbox->regs + REMOTE_IRQ_STAT_REG) & RX_IRQ(n));
}
staticbool sun6i_msgbox_peek_data(struct mbox_chan *chan)
{ struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); int n = channel_number(chan);
mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); if (!mbox) return -ENOMEM;
chans = devm_kcalloc(dev, NUM_CHANS, sizeof(*chans), GFP_KERNEL); if (!chans) return -ENOMEM;
for (i = 0; i < NUM_CHANS; ++i)
chans[i].con_priv = mbox;
mbox->clk = devm_clk_get(dev, NULL); if (IS_ERR(mbox->clk)) {
ret = PTR_ERR(mbox->clk);
dev_err(dev, "Failed to get clock: %d\n", ret); return ret;
}
ret = clk_prepare_enable(mbox->clk); if (ret) {
dev_err(dev, "Failed to enable clock: %d\n", ret); return ret;
}
reset = devm_reset_control_get_exclusive(dev, NULL); if (IS_ERR(reset)) {
ret = PTR_ERR(reset);
dev_err(dev, "Failed to get reset control: %d\n", ret); goto err_disable_unprepare;
}
/* * NOTE: We rely on platform firmware to preconfigure the channel * directions, and we share this hardware block with other firmware * that runs concurrently with Linux (e.g. a trusted monitor). * * Therefore, we do *not* assert the reset line if probing fails or * when removing the device.
*/
ret = reset_control_deassert(reset); if (ret) {
dev_err(dev, "Failed to deassert reset: %d\n", ret); goto err_disable_unprepare;
}
mbox->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mbox->regs)) {
ret = PTR_ERR(mbox->regs);
dev_err(dev, "Failed to map MMIO resource: %d\n", ret); goto err_disable_unprepare;
}
/* Disable all IRQs for this end of the msgbox. */
writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
sun6i_msgbox_irq, 0, dev_name(dev), mbox); if (ret) {
dev_err(dev, "Failed to register IRQ handler: %d\n", ret); goto err_disable_unprepare;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.