summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcdrv/inc/ipmbox.h
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/devkit/plcdrv/inc/ipmbox.h')
-rw-r--r--cleopatre/devkit/plcdrv/inc/ipmbox.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/cleopatre/devkit/plcdrv/inc/ipmbox.h b/cleopatre/devkit/plcdrv/inc/ipmbox.h
new file mode 100644
index 0000000000..3128e495ef
--- /dev/null
+++ b/cleopatre/devkit/plcdrv/inc/ipmbox.h
@@ -0,0 +1,116 @@
+#ifndef inc_ipmbox_h
+#define inc_ipmbox_h
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file inc/ipmbox.h
+ * \brief Interfaces for IPMBox layer.
+ * \ingroup plcdrv
+ *
+ * This file contains interfaces used to access the different queues defined
+ * for IPMBox: DATA, EMPTY_BUF and MBX (all existing in TX and RX).
+ */
+
+#include <linux/types.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+
+#include "common/ipmbox/queue.h"
+#include "common/ipmbox/registers.h"
+
+/**
+ * Budget for RX part.
+ */
+#define IPMBOX_RX_BUDGET 64
+
+/**
+ * IPMBox context.
+ */
+typedef struct ipmbox_ctx_t
+{
+ /** Queues, by types & directions. */
+ ipmbox_queue_t queue[IPMBOX_QUEUE_TYPE_NB][IPMBOX_QUEUE_DIRECTION_NB];
+ /** IPMBox hardware registers. */
+ volatile ipmbox_registers_t *regs;
+ /** Shared memory virtual start pointer. */
+ uint32_t *shared_mem_virt_base_ptr;
+ /** Shared memory physical start address. */
+ dma_addr_t shared_mem_phy_base_addr;
+ /** Shared memory size. */
+ size_t shared_mem_size;
+ /** Only needed lock for A2L mbx queue. */
+ spinlock_t a2l_mbx_queue_lock;
+} ipmbox_ctx_t;
+
+/**
+ * Initialize the IPMBox layer.
+ * \param ctx IPMBox context
+ * \param dev netdevice structure
+ * \param it_mbx_handler handler for mailbox interrupt
+ * \param it_wd_handler handler for watchdog interrupt
+ * \return error code
+ */
+int
+ipmbox_init (ipmbox_ctx_t *ctx, struct net_device *dev,
+ irq_handler_t it_mbx_handler, irq_handler_t it_wd_handler);
+
+/**
+ * Un-initialize the IPMBox layer.
+ * \param ctx IPMBox context
+ * \param dev netdevice structure
+ */
+void
+ipmbox_uninit (ipmbox_ctx_t *ctx, struct net_device *dev);
+
+/**
+ * Check if IPMBox has been synchronized by firmware.
+ * \param ctx IPMBox context
+ * \return true if synchronized, false otherwise
+ */
+bool
+ipmbox_is_synchronized (ipmbox_ctx_t *ctx);
+
+/**
+ * Receive messages from IPMBox queues.
+ * \param napi NAPI context
+ * \param budget RX budget in messages (only for data & mbx)
+ * \return total number of messages treated
+ */
+int
+ipmbox_receive (struct napi_struct *napi, int budget);
+
+/**
+ * Send empty buffer(s) to firmware.
+ * \param ctx IPMBox context
+ * \param buffer_addr buffers' addresses to send
+ * \param buffer_nb number of buffer to send
+ */
+void
+ipmbox_send_empty_buf (ipmbox_ctx_t *ctx, uint32_t buffer_addr[],
+ unsigned int buffer_nb);
+
+/**
+ * Send a data frame to firmware.
+ * \param ctx IPMBox context
+ * \param buffer_addr buffer address to send
+ * \param header corresponding data header
+ */
+void
+ipmbox_send_data (ipmbox_ctx_t *ctx, uint32_t buffer_addr, uint32_t header);
+
+/**
+ * Send a mailbox message to firmware.
+ * \param ctx IPMBox context
+ * \param buffer_addr buffer address to send
+ * \param header corresponding mailbox header
+ */
+void
+ipmbox_send_mbx (ipmbox_ctx_t *ctx, uint32_t buffer_addr, uint32_t header);
+
+#endif /* inc_ipmbox_h */