summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlacour2007-05-03 12:30:31 +0000
committerlacour2007-05-03 12:30:31 +0000
commit5b6dbd5292ccf6aa65bc5aa4cde3db50c278fe3a (patch)
treef100db5a927fa7be79733d347e8c3f4e8df4bbdb
parent35f523a79d7c3bba8339e82615df8b1f07ec4a57 (diff)
commit 'bridgedma.h' in hal_phy group
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@86 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--hal/phy/bridgedma.h154
1 files changed, 154 insertions, 0 deletions
diff --git a/hal/phy/bridgedma.h b/hal/phy/bridgedma.h
new file mode 100644
index 0000000000..fff5e1dde1
--- /dev/null
+++ b/hal/phy/bridgedma.h
@@ -0,0 +1,154 @@
+#ifndef hal_phy_bridgedma_h
+#define hal_phy_bridgedma_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/bridgedma.h
+ * \brief HAL Phy BRIDGE DMA public interface.
+ * \ingroup hal_phy
+ */
+
+
+/** BRIDGE DMA job structure */
+struct phy_bridgedma_job_t
+{
+ /** Pointer to the next job descriptor. */
+ u32 *next;
+ /** Address of data in ethernet buffer.(not word aligned) */
+ u32 data_addr;
+
+ BITFIELDS_WORD(
+ /** Mac frame header length */
+ u32 header_len:4;,
+ u32 12;,
+ /** Length of data in ethernet buffer. max 1538 */
+ u32 data_len:11;,
+ u32 :5;
+ )
+ /** Pointer to the pb descriptor list head */
+ u32 first_pb_desc;
+
+ BITFIELDS_WORD(
+ /** Start offset in first pb descriptor */
+ u32 first_pb_offset:16;,
+ /** length of segmentation block default = 512 */
+ u32 segment_len:16;
+ )
+
+ BITFIELDS_WORD(
+ /** indication of last job. If set, bridge will stop after this one */
+ u32 last:1;,
+ /** transfer direction: 0 for Segmentation (TX), 1 for Reassembly(RX) */
+ u32 direction:1;,
+ /** crc_error:
+ * Reassembly : set by HW. 0 for crc ok, 1 for crc ko.
+ * Segmentation : set by SW. 0 to compute crc, 1 to copy crc from bridgedma
+ * icv substitution register.
+ */
+ u32 crc_error:1;,
+ /** Reset crc computation before transfer */
+ u32 crc_reset:1;,
+ /** presence of crc : set by SW.
+ * Reassembly : 0 for no crc, 1 for crc after data.
+ * Segmentation : 0 to not add crc after data, 1 else.
+ */
+ u32 crc_store:1;,
+ /** append zero after data+crc */
+ u32 append_zero:1;,
+ /** interrupt mask : if 0, HW will not throw interruption at the end of
+ * job.
+ */
+ u32 job_it:1;,
+ /** defines a rollover mask for ethernet buffer.
+ * Used for circular buffer, this is the MSB of 32 bit mask which defines
+ * which address bits are constant and which should be incremented on each
+ * word
+ */
+ eth_buffer_mask:25;
+ )
+ /** mac frame header part 1 */
+ u32 mf_header1;
+ /** mac frame header part 2 */
+ u32 mf_header2;
+};
+typedef struct phy_bridgedma_job_t phy_bridgedma_job_t;
+
+/** BRIDGE DMA control and configuration */
+struct phy_bridgedma_ctrl_t
+{
+ BITFIELDS_WORD(
+ /** host set start bit and BRIDGE DMA reset it when finish */
+ u32 start:1;,
+ /** ethernet buffer endian : TBD if 0, little endian */
+ u32 eth_endian:1;,
+ /** segment endian : TBD if 0, little endian */
+ u32 pb_endian:1;,
+ u32 1;,
+ /** hprot cf HW specification */
+ u32 hprot:4;,
+ u32 24;)
+}
+typedef struct phy__bridgedma_ctrl_t phy_bridgedma_ctrl_t;
+
+
+
+/** BRIDGE DMA status given back after a interrupt. */
+struct phy_bridgedma_status_t
+{
+ BITFIELDS_WORD(
+ /** AHB response error */
+ u32 ahb_response_error:1;,
+ /** Debug : ctrl fsm */
+ u32 ctrl_fsm:2;,
+ /** running bit sets when bridge dma works */
+ u32 running:1;,
+ /** Correspond to the stop bit in job descriptor. It means that dma will or has stop */
+ u32 stop:1;)
+};
+typedef struct phy_bridgedma_status_t phy_bridgedma_status_t;
+
+/** initialized by SW before a new start */
+u32 phy_bridgedma_first_job_reg;
+/** set by HW and set the job descriptor stop bit if current job is the last */
+u32 phy_bridgedma_current_job_reg;
+/** register for the substitution of ICV : Used if direction=TX and
+ * crc_error=1 */
+u32 phy_bridgedma_crc_substitution_reg;
+
+
+/**
+ * BRIDGE DMA callback called when an interrupt occurs.
+ * \param user user data
+ * \param status_word status read from PB DMA
+ * \return true if a DSR is requested
+ */
+typedef bool (*phy_bridgedma_cb_t) (void *user, u32 status_word);
+
+/** Cast a u32 word to the \c phy_pbdma_status_t structure. The reason behind
+ * this macro is that the callback receive the status as a u32 in order to use
+ * a register, not a pointer, to pass the parameter. */
+#define PHY_BRIDGEDMA_STATUS(w) (*(phy_bridgedma_status_t *) (void *) &(w))
+
+BEGIN_DECLS
+
+/**
+ * Start a BRIDGE transfer.
+ * \param ctx phy context
+ * \param first_job_desc
+ * The transfer will be started if bridge dma is stopped and a new job has to be
+ * done.
+ */
+void
+phy_bridgedma_start (phy_t *ctx, phy_bridgedma_job_t *first_job);
+
+
+
+END_DECLS
+
+#endif /* hal_phy_bridgedma_h */
+