0001
0002
0003
0004 #ifndef _CPPI_DMA_H_
0005 #define _CPPI_DMA_H_
0006
0007 #include <linux/slab.h>
0008 #include <linux/list.h>
0009 #include <linux/errno.h>
0010 #include <linux/dmapool.h>
0011 #include <linux/dmaengine.h>
0012
0013 #include "musb_core.h"
0014 #include "musb_dma.h"
0015
0016
0017
0018 struct cppi_tx_stateram {
0019 u32 tx_head;
0020 u32 tx_buf;
0021 u32 tx_current;
0022 u32 tx_buf_current;
0023 u32 tx_info;
0024 u32 tx_rem_len;
0025 u32 tx_dummy;
0026 u32 tx_complete;
0027 };
0028
0029 struct cppi_rx_stateram {
0030 u32 rx_skipbytes;
0031 u32 rx_head;
0032 u32 rx_sop;
0033 u32 rx_current;
0034 u32 rx_buf_current;
0035 u32 rx_len_len;
0036 u32 rx_cnt_cnt;
0037 u32 rx_complete;
0038 };
0039
0040
0041 #define CPPI_SOP_SET ((u32)(1 << 31))
0042 #define CPPI_EOP_SET ((u32)(1 << 30))
0043 #define CPPI_OWN_SET ((u32)(1 << 29))
0044 #define CPPI_EOQ_MASK ((u32)(1 << 28))
0045 #define CPPI_ZERO_SET ((u32)(1 << 23))
0046 #define CPPI_RXABT_MASK ((u32)(1 << 19))
0047
0048 #define CPPI_RECV_PKTLEN_MASK 0xFFFF
0049 #define CPPI_BUFFER_LEN_MASK 0xFFFF
0050
0051 #define CPPI_TEAR_READY ((u32)(1 << 31))
0052
0053
0054
0055 #define CPPI_DESCRIPTOR_ALIGN 16
0056
0057 struct cppi_descriptor {
0058
0059 u32 hw_next;
0060 u32 hw_bufp;
0061 u32 hw_off_len;
0062 u32 hw_options;
0063
0064 struct cppi_descriptor *next;
0065 dma_addr_t dma;
0066 u32 buflen;
0067 } __attribute__ ((aligned(CPPI_DESCRIPTOR_ALIGN)));
0068
0069
0070 struct cppi;
0071
0072
0073 struct cppi_channel {
0074 struct dma_channel channel;
0075
0076
0077 struct cppi *controller;
0078
0079
0080 struct musb_hw_ep *hw_ep;
0081 bool transmit;
0082 u8 index;
0083
0084
0085 u8 is_rndis;
0086
0087
0088 dma_addr_t buf_dma;
0089 u32 buf_len;
0090 u32 maxpacket;
0091 u32 offset;
0092
0093 void __iomem *state_ram;
0094
0095 struct cppi_descriptor *freelist;
0096
0097
0098 struct cppi_descriptor *head;
0099 struct cppi_descriptor *tail;
0100 struct cppi_descriptor *last_processed;
0101
0102
0103
0104
0105 struct list_head tx_complete;
0106 };
0107
0108
0109 struct cppi {
0110 struct dma_controller controller;
0111 void __iomem *mregs;
0112 void __iomem *tibase;
0113
0114 int irq;
0115
0116 struct cppi_channel tx[4];
0117 struct cppi_channel rx[4];
0118
0119 struct dma_pool *pool;
0120
0121 struct list_head tx_complete;
0122 };
0123
0124
0125 extern irqreturn_t cppi_interrupt(int, void *);
0126
0127 struct cppi41_dma_channel {
0128 struct dma_channel channel;
0129 struct cppi41_dma_controller *controller;
0130 struct musb_hw_ep *hw_ep;
0131 struct dma_chan *dc;
0132 dma_cookie_t cookie;
0133 u8 port_num;
0134 u8 is_tx;
0135 u8 is_allocated;
0136 u8 usb_toggle;
0137
0138 dma_addr_t buf_addr;
0139 u32 total_len;
0140 u32 prog_len;
0141 u32 transferred;
0142 u32 packet_sz;
0143 struct list_head tx_check;
0144 int tx_zlp;
0145 };
0146
0147 #endif