Staging: sep: Create a structure to hold all the current crap spewed about as globals
[linux-2.6/mini2440.git] / drivers / staging / sep / sep_driver_config.h
blob48f159179a14bd281295ddc4650990f98700b561
1 /*
3 * sep_driver_config.h - Security Processor Driver configuration
5 * Copyright(c) 2009 Intel Corporation. All rights reserved.
6 * Copyright(c) 2009 Discretix. All rights reserved.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * CONTACTS:
24 * Mark Allyn mark.a.allyn@intel.com
26 * CHANGES:
28 * 2009.06.26 Initial publish
32 #ifndef __SEP_DRIVER_CONFIG_H__
33 #define __SEP_DRIVER_CONFIG_H__
36 /*--------------------------------------
37 DRIVER CONFIGURATION FLAGS
38 -------------------------------------*/
40 /* if flag is on , then the driver is running in polling and
41 not interrupt mode */
42 #define SEP_DRIVER_POLLING_MODE 1
44 /* flag which defines if the shared area address should be
45 reconfiged (send to SEP anew) during init of the driver */
46 #define SEP_DRIVER_RECONFIG_MESSAGE_AREA 0
48 /* the mode for running on the ARM1172 Evaluation platform (flag is 1) */
49 #define SEP_DRIVER_ARM_DEBUG_MODE 0
51 /*-------------------------------------------
52 INTERNAL DATA CONFIGURATION
53 -------------------------------------------*/
55 /* flag for the input array */
56 #define SEP_DRIVER_IN_FLAG 0
58 /* flag for output array */
59 #define SEP_DRIVER_OUT_FLAG 1
61 /* maximum number of entries in one LLI tables */
62 #define SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP 8
65 /*--------------------------------------------------------
66 SHARED AREA memory total size is 36K
67 it is divided is following:
69 SHARED_MESSAGE_AREA 8K }
71 STATIC_POOL_AREA 4K } MAPPED AREA ( 24 K)
73 DATA_POOL_AREA 12K }
75 SYNCHRONIC_DMA_TABLES_AREA 5K
77 FLOW_DMA_TABLES_AREA 4K
79 SYSTEM_MEMORY_AREA 3k
81 SYSTEM_MEMORY total size is 3k
82 it is divided as following:
84 TIME_MEMORY_AREA 8B
85 -----------------------------------------------------------*/
90 the maximum length of the message - the rest of the message shared
91 area will be dedicated to the dma lli tables
93 #define SEP_DRIVER_MAX_MESSAGE_SIZE_IN_BYTES (8 * 1024)
95 /* the size of the message shared area in pages */
96 #define SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES (8 * 1024)
98 /* the size of the data pool static area in pages */
99 #define SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES (4 * 1024)
101 /* the size of the data pool shared area size in pages */
102 #define SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES (12 * 1024)
104 /* the size of the message shared area in pages */
105 #define SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES (1024 * 5)
108 /* the size of the data pool shared area size in pages */
109 #define SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES (1024 * 4)
111 /* system data (time, caller id etc') pool */
112 #define SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES 100
115 /* area size that is mapped - we map the MESSAGE AREA, STATIC POOL and
116 DATA POOL areas. area must be module 4k */
117 #define SEP_DRIVER_MMMAP_AREA_SIZE (1024 * 24)
120 /*-----------------------------------------------
121 offsets of the areas starting from the shared area start address
124 /* message area offset */
125 #define SEP_DRIVER_MESSAGE_AREA_OFFSET_IN_BYTES 0
127 /* static pool area offset */
128 #define SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES \
129 (SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES)
131 /* data pool area offset */
132 #define SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES \
133 (SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES + \
134 SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES)
136 /* synhronic dma tables area offset */
137 #define SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES \
138 (SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + \
139 SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES)
141 /* sep driver flow dma tables area offset */
142 #define SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES \
143 (SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES + \
144 SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES)
146 /* system memory offset in bytes */
147 #define SEP_DRIVER_SYSTEM_DATA_MEMORY_OFFSET_IN_BYTES \
148 (SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES + \
149 SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES)
151 /* offset of the time area */
152 #define SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES \
153 (SEP_DRIVER_SYSTEM_DATA_MEMORY_OFFSET_IN_BYTES)
157 /* start physical address of the SEP registers memory in HOST */
158 #define SEP_IO_MEM_REGION_START_ADDRESS 0x80000000
160 /* size of the SEP registers memory region in HOST (for now 100 registers) */
161 #define SEP_IO_MEM_REGION_SIZE (2 * 0x100000)
163 /* define the number of IRQ for SEP interrupts */
164 #define SEP_DIRVER_IRQ_NUM 1
166 /* maximum number of add buffers */
167 #define SEP_MAX_NUM_ADD_BUFFERS 100
169 /* number of flows */
170 #define SEP_DRIVER_NUM_FLOWS 4
172 /* maximum number of entries in flow table */
173 #define SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE 25
175 /* offset of the num entries in the block length entry of the LLI */
176 #define SEP_NUM_ENTRIES_OFFSET_IN_BITS 24
178 /* offset of the interrupt flag in the block length entry of the LLI */
179 #define SEP_INT_FLAG_OFFSET_IN_BITS 31
181 /* mask for extracting data size from LLI */
182 #define SEP_TABLE_DATA_SIZE_MASK 0xFFFFFF
184 /* mask for entries after being shifted left */
185 #define SEP_NUM_ENTRIES_MASK 0x7F
187 /* default flow id */
188 #define SEP_FREE_FLOW_ID 0xFFFFFFFF
190 /* temp flow id used during cretiong of new flow until receiving
191 real flow id from sep */
192 #define SEP_TEMP_FLOW_ID (SEP_DRIVER_NUM_FLOWS + 1)
194 /* maximum add buffers message length in bytes */
195 #define SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES (7 * 4)
197 /* maximum number of concurrent virtual buffers */
198 #define SEP_MAX_VIRT_BUFFERS_CONCURRENT 100
200 /* the token that defines the start of time address */
201 #define SEP_TIME_VAL_TOKEN 0x12345678
202 /* DEBUG LEVEL MASKS */
203 #define SEP_DEBUG_LEVEL_BASIC 0x1
205 #define SEP_DEBUG_LEVEL_REGISTERS 0x2
207 #define SEP_DEBUG_LEVEL_EXTENDED 0x4
210 /* FUNCTIONAL MACROS */
212 /* debug macro without paramaters */
213 #define DEBUG_PRINT_0(DEBUG_LEVEL , info) \
214 do { \
215 if (DEBUG_LEVEL & sepDebug) \
216 printk(KERN_WARNING info); \
217 } while (0)
219 /* debug macro with 1 paramater */
220 #define DEBUG_PRINT_1(DEBUG_LEVEL , info , param1) \
221 do { \
222 if (DEBUG_LEVEL & sepDebug) \
223 printk(KERN_WARNING info, param1); \
224 } while (0)
226 /* debug macro with 2 paramaters */
227 #define DEBUG_PRINT_2(DEBUG_LEVEL, info, param1, param2) \
228 do { \
229 if (DEBUG_LEVEL & sepDebug) \
230 printk(KERN_WARNING info , param1, param2); \
231 } while (0)
233 /* debug macro with 3 paramaters */
234 #define DEBUG_PRINT_3(DEBUG_LEVEL, info, param1, param2, param3) \
235 do { \
236 if (DEBUG_LEVEL & sepDebug) \
237 printk(KERN_WARNING info , param1, param2 , param3); \
238 } while (0)
240 /* debug macro with 4 paramaters */
241 #define DEBUG_PRINT_4(DEBUG_LEVEL, info, param1, param2, param3, param4) \
242 do { \
243 if (DEBUG_LEVEL & sepDebug) \
244 printk(KERN_WARNING info, param1, param2, param3, param4); \
245 } while (0)
247 #if 0
248 /* write register macro with option for debug print */
249 #define SEP_WRITE_REGISTER(address, value) \
250 do { \
251 if (sepDebug & SEP_DEBUG_LEVEL_REGISTERS) \
252 printk(KERN_WARNING "Write Register: address %lu value %lu\n", \
253 (unsigned long)(address), (unsigned long)(value)); \
254 writel((value), (void *)(address)); \
255 } while (0)
257 /* read register macro with option for debug print */
258 #define SEP_READ_REGISTER(address , value) \
259 do { \
260 (value) = readl((void *)(address)); \
261 if (sepDebug & SEP_DEBUG_LEVEL_REGISTERS) \
262 printk(KERN_WARNING "Read Register: address %lu value %lu\n", \
263 (address), (value)); \
264 } while (0)
265 #else
267 #if 1
269 #define SEP_WRITE_REGISTER(address, value) writel((value), (void *)(address))
270 #define SEP_READ_REGISTER(address, value) (value) = readl((void *)(address))
271 #endif
273 #endif
275 #if 0
276 #define SEP_WRITE_ROM(address, value) writel((value), (void *)(address))
278 #define SEP_WRITE_REGISTER(address, value) \
279 do { \
280 unsigned long i; \
281 for (i = 0; i < 1000; i++); \
282 writel((value), (void *)(address)); \
283 } while (0)
286 #define SEP_READ_REGISTER(address , value) \
287 do { \
288 unsigned long i; \
289 for (i = 0; i < 1000; i++); \
290 (value) = readl((void *) (address)); \
291 } while (0)
293 #endif
295 /* wait for SRAM write complete(indirect write */
296 #define SEP_WAIT_SRAM_WRITE_COMPLETE() \
297 do { \
298 unsigned long reg_val; \
299 do { \
300 SEP_READ_REGISTER(sep_dev->reg_base_address + \
301 HW_SRAM_DATA_READY_REG_ADDR, (reg_val)); \
302 } while (!(reg_val & 0x1)); \
303 } while (0)
305 #endif