Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / dma_engine / src / desc.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /************************************************************************/
36 /*  Copyright (c) 2013 Qualcomm Atheros, All Rights Reserved.           */
37 /*                                                                      */
38 /*  Module Name : desc_def.h                                            */
39 /*                                                                      */
40 /*  Abstract                                                            */
41 /*      This module contains DMA descriptor related definitions.        */
42 /*                                                                      */
43 /*  NOTES                                                               */
44 /*      None                                                            */
45 /*                                                                      */
46 /************************************************************************/
47
48 #ifndef _DESC_DEFS_H
49 #define _DESC_DEFS_H
50
51 #if 0
52 #define BIG_ENDIAN
53
54 struct zsDmaDesc
55 {
56 #ifdef BIG_ENDIAN
57
58     volatile u16_t      ctrl;       // Descriptor control
59     volatile u16_t      status;     // Descriptor status
60
61     volatile u16_t      totalLen;   // Total length
62     volatile u16_t      dataSize;   // Data size
63
64 #else
65     volatile u16_t      status;     // Descriptor status
66     volatile u16_t      ctrl;       // Descriptor control
67     volatile u16_t      dataSize;   // Data size
68     volatile u16_t      totalLen;   // Total length
69 #endif
70     struct zsDmaDesc*   lastAddr;   // Last address of this chain
71     volatile u32_t      dataAddr;   // Data buffer address
72     struct zsDmaDesc*   nextAddr;   // Next TD address
73 };
74 #endif
75
76 /* Tx5 Dn Rx Up Int */
77 #if 0
78 #define ZM_TERMINATOR_NUMBER_B  8
79
80 #if ZM_BAR_AUTO_BA == 1
81 #define ZM_TERMINATOR_NUMBER_BAR        1
82 #else
83 #define ZM_TERMINATOR_NUMBER_BAR        0
84 #endif
85
86 #if ZM_INT_USE_EP2 == 1
87 #define ZM_TERMINATOR_NUMBER_INT        1
88 #else
89 #define ZM_TERMINATOR_NUMBER_INT        0
90 #endif
91
92 #define ZM_TX_DELAY_DESC_NUM    16
93 #define ZM_TERMINATOR_NUMBER (8 + ZM_TERMINATOR_NUMBER_BAR + \
94                                   ZM_TERMINATOR_NUMBER_INT + \
95                                                               ZM_TX_DELAY_DESC_NUM)
96
97
98 #define ZM_BLOCK_SIZE           (256+64)
99 #define ZM_DESCRIPTOR_SIZE      (sizeof(struct zsDmaDesc))
100 #endif
101
102 //#define ZM_FRAME_MEMORY_BASE    0x100000
103 #if 0
104 #if 1
105 /* 64k */
106 //#define ZM_FRAME_MEMROY_SIZE    0xf000
107 /* 96k */
108 //#define ZM_FRAME_MEMROY_SIZE    0x17000
109
110 #else
111 /* fake phy */
112 /* 128k / 96k */
113 #define ZM_FRAME_MEMROY_SIZE    (ZM_BLOCK_SIZE+ZM_DESCRIPTOR_SIZE)*(160+60) + \
114                                 (ZM_DESCRIPTOR_SIZE*ZM_TERMINATOR_NUMBER)+64
115 #endif
116
117 #define ZM_BLOCK_NUMBER         ((ZM_FRAME_MEMROY_SIZE-(ZM_DESCRIPTOR_SIZE* \
118                                 ZM_TERMINATOR_NUMBER)-64)/(ZM_BLOCK_SIZE \
119                                 +ZM_DESCRIPTOR_SIZE))
120 #define ZM_DESC_NUMBER          (ZM_BLOCK_NUMBER + ZM_TERMINATOR_NUMBER)
121
122 #define ZM_DESCRIPTOR_BASE              ZM_FRAME_MEMORY_BASE
123 #define ZM_BLOCK_BUFFER_BASE    (((((ZM_BLOCK_NUMBER+ZM_TERMINATOR_NUMBER) \
124                                 *ZM_DESCRIPTOR_SIZE) >> 6) << 6) + 0x40 \
125                                 + ZM_FRAME_MEMORY_BASE)
126
127 #define ZM_DOWN_BLOCK_RATIO     2
128 #define ZM_RX_BLOCK_RATIO       1
129 /* Tx 16*2 = 32 packets => 32*(5*320) */
130 #define ZM_TX_BLOCK_NUMBER      ZM_BLOCK_NUMBER * ZM_DOWN_BLOCK_RATIO / \
131                                 (ZM_RX_BLOCK_RATIO + ZM_DOWN_BLOCK_RATIO)
132 #define ZM_RX_BLOCK_NUMBER      ZM_BLOCK_NUMBER-ZM_TX_BLOCK_NUMBER
133                                 //ZM_BLOCK_NUMBER * ZM_RX_BLOCK_RATIO / \
134                                 //(ZM_RX_BLOCK_RATIO + ZM_DOWN_BLOCK_RATIO)
135
136
137 #define ZM_TX_DELAY_DESC_BASE   ZM_FRAME_MEMORY_BASE + ZM_DESCRIPTOR_SIZE*(ZM_TERMINATOR_NUMBER-ZM_TX_DELAY_DESC_NUM)
138 #endif
139
140 /* Erro code */
141 #define ZM_ERR_FS_BIT           1
142 #define ZM_ERR_LS_BIT           2
143 #define ZM_ERR_OWN_BITS         3
144 #define ZM_ERR_DATA_SIZE        4
145 #define ZM_ERR_TOTAL_LEN        5
146 #define ZM_ERR_DATA             6
147 #define ZM_ERR_SEQ              7
148 #define ZM_ERR_LEN              8
149
150 /* Status bits definitions */
151 /* Own bits definitions */
152 #define ZM_OWN_BITS_MASK        0x3
153 #define ZM_OWN_BITS_SW          0x0
154 #define ZM_OWN_BITS_HW          0x1
155 #define ZM_OWN_BITS_SE          0x2
156
157 /* Control bits definitions */
158 /* First segament bit */
159 #define ZM_LS_BIT               0x100
160 /* Last segament bit */
161 #define ZM_FS_BIT               0x200
162
163 #if 0
164 struct zsDmaQueue
165 {
166     struct zsDmaDesc* head;
167     struct zsDmaDesc* terminator;
168 };
169 #endif
170
171 struct zsDmaQueue;
172 struct szDmaDesc;
173
174 extern struct zsDmaDesc* zfDmaGetPacket(struct zsDmaQueue* q);
175 extern void zfDmaReclaimPacket(struct zsDmaQueue* q, struct zsDmaDesc* desc);
176 extern void zfDmaPutPacket(struct zsDmaQueue* q, struct zsDmaDesc* desc);
177
178 #endif /* #ifndef _DESC_DEFS_H */