]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/blobdiff - arch/arm/plat-omap/mailbox.c
omap: mailbox: Add an API for flushing the FIFO
[sitara-epos/sitara-epos-kernel.git] / arch / arm / plat-omap / mailbox.c
index ad80112c22751defaaa4cb5b9aefe11eac27e6be..4ebacb2739adbea564a3620eb524c15bae0164fc 100644 (file)
@@ -59,6 +59,14 @@ static inline int mbox_fifo_full(struct omap_mbox *mbox)
 {
        return mbox->ops->fifo_full(mbox);
 }
+static inline int mbox_fifo_needs_flush(struct omap_mbox *mbox)
+{
+       return mbox->ops->fifo_needs_flush(mbox);
+}
+static inline mbox_msg_t mbox_fifo_readback(struct omap_mbox *mbox)
+{
+       return mbox->ops->fifo_readback(mbox);
+}
 
 /* Mailbox IRQ handle functions */
 static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
@@ -116,6 +124,28 @@ out:
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);
 
+/*
+ * Flush the Rx FIFO by reading back the messages
+ * Since the normal expectation is that the Rx will do the
+ * reading, add a debug message to indicate if we really flush
+ * returns the no. of messages read back
+ */
+int omap_mbox_msg_rx_flush(struct omap_mbox *mbox)
+{
+       int ret = 0;
+       mbox_msg_t msg;
+
+       while (!mbox_fifo_needs_flush(mbox)) {
+               ret++;
+               msg = mbox_fifo_readback(mbox);
+       }
+       if (!ret)
+               pr_info("Flushed %s Rx FIFO by reading back\n", mbox->name);
+
+       return ret;
+}
+EXPORT_SYMBOL(omap_mbox_msg_rx_flush);
+
 static void mbox_tx_tasklet(unsigned long tx_data)
 {
        struct omap_mbox *mbox = (struct omap_mbox *)tx_data;