]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/usb/musb/cppi_dma.h
6e6e09cdd842b59826f9a4c4281f9d9372c002ad
[linux-2.6-omap-h63xx.git] / drivers / usb / musb / cppi_dma.h
1 /* Copyright (C) 2005-2006 by Texas Instruments */
2
3 #ifndef _CPPI_DMA_H_
4 #define _CPPI_DMA_H_
5
6 #include <linux/slab.h>
7 #include <linux/list.h>
8 #include <linux/smp_lock.h>
9 #include <linux/errno.h>
10 #include <linux/dmapool.h>
11
12 #include "musb_dma.h"
13 #include "musb_core.h"
14 #include "davinci.h"
15
16
17 /* hOptions bit masks for CPPI BDs */
18 #define CPPI_SOP_SET    ((u32)(1 << 31))
19 #define CPPI_EOP_SET    ((u32)(1 << 30))
20 #define CPPI_OWN_SET    ((u32)(1 << 29))        /* owned by cppi */
21 #define CPPI_EOQ_MASK   ((u32)(1 << 28))
22 #define CPPI_ZERO_SET   ((u32)(1 << 23))        /* rx saw zlp; tx issues one */
23 #define CPPI_RXABT_MASK ((u32)(1 << 19))        /* need more rx buffers */
24
25 #define CPPI_RECV_PKTLEN_MASK 0xFFFF
26 #define CPPI_BUFFER_LEN_MASK 0xFFFF
27
28 #define CPPI_TEAR_READY ((u32)(1 << 31))
29
30 /* CPPI data structure definitions */
31
32 #define CPPI_DESCRIPTOR_ALIGN   16      /* bytes; 5-dec docs say 4-byte align */
33
34 struct cppi_descriptor {
35         /* Hardware Overlay */
36         u32 hNext;      /* Next(hardware) Buffer Descriptor Pointer */
37         u32 buffPtr;    /* Buffer Pointer (dma_addr_t) */
38         u32 bOffBLen;   /* Buffer_offset16,buffer_length16 */
39         u32 hOptions;   /* Option fields for SOP,EOP etc*/
40
41         struct cppi_descriptor *next;
42         dma_addr_t dma;         /* address of this descriptor */
43
44         /* for Rx Desc, track original Buffer len to detect short packets */
45         u32 enqBuffLen;
46 } __attribute__ ((aligned(CPPI_DESCRIPTOR_ALIGN)));
47
48
49 struct cppi;
50
51 /**
52  *  Channel Control Structure
53  *
54  * CPPI  Channel Control structure. Using he same for Tx/Rx. If need be
55  * derive out of this later.
56  */
57 struct cppi_channel {
58         /* First field must be dma_channel for easy type casting
59          * FIXME just use container_of() and be typesafe instead!
60          */
61         struct dma_channel Channel;
62
63         /* back pointer to the Dma Controller structure */
64         struct cppi             *controller;
65
66         /* which direction of which endpoint? */
67         struct musb_hw_ep       *hw_ep;
68         bool                    transmit;
69         u8                      chNo;
70
71         /* DMA modes:  RNDIS or "transparent" */
72         u8                      bLastModeRndis;
73
74         /* book keeping for current transfer request */
75         dma_addr_t              startAddr;
76         u32                     transferSize;
77         u32                     pktSize;
78         u32                     currOffset;     /* requested segments */
79         u32                     actualLen;      /* completed (Channel.actual) */
80
81         void __iomem            *stateRam;      /* CPPI state */
82
83         /* BD management fields */
84         struct cppi_descriptor  *bdPoolHead;
85         struct cppi_descriptor  *activeQueueHead;
86         struct cppi_descriptor  *activeQueueTail;
87         struct cppi_descriptor  *lastHwBDProcessed;
88
89         /* use tx_complete in host role to track endpoints waiting for
90          * FIFONOTEMPTY to clear.
91          */
92         struct list_head        tx_complete;
93 };
94
95 /**
96  *  CPPI Dma Controller Object
97  *
98  *  CPPI Dma controller object.Encapsulates all bookeeping and Data
99  *  structures pertaining to the CPPI Dma Controller.
100  */
101 struct cppi {
102         struct dma_controller           Controller;
103         struct musb                     *musb;
104         void __iomem                    *pCoreBase;
105
106         struct cppi_channel             txCppi[MUSB_C_NUM_EPT - 1];
107         struct cppi_channel             rxCppi[MUSB_C_NUM_EPR - 1];
108
109         struct dma_pool                 *pool;
110
111         struct list_head                tx_complete;
112 };
113
114 /* irq handling hook */
115 extern void cppi_completion(struct musb *, u32 rx, u32 tx);
116
117 #endif                          /* end of ifndef _CPPI_DMA_H_ */