]> git.ipfire.org Git - thirdparty/kernel/linux.git/blame - drivers/staging/tidspbridge/include/dspbridge/drv.h
Fix common misspellings
[thirdparty/kernel/linux.git] / drivers / staging / tidspbridge / include / dspbridge / drv.h
CommitLineData
6280238c
ORL
1/*
2 * drv.h
3 *
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5 *
6 * DRV Resource allocation module. Driver Object gets Created
7 * at the time of Loading. It holds the List of Device Objects
8 * in the system.
9 *
10 * Copyright (C) 2005-2006 Texas Instruments, Inc.
11 *
12 * This package is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 */
20
21#ifndef DRV_
22#define DRV_
23
24#include <dspbridge/devdefs.h>
25
0624f52f 26#include <linux/idr.h>
6280238c 27
157bc26d
AU
28/* Bridge Driver Object */
29struct drv_object;
30
6280238c
ORL
31/* Provide the DSP Internal memory windows that can be accessed from L3 address
32 * space */
33
34#define OMAP_GEM_BASE 0x107F8000
35#define OMAP_DSP_SIZE 0x00720000
36
37/* MEM1 is L2 RAM + L2 Cache space */
38#define OMAP_DSP_MEM1_BASE 0x5C7F8000
39#define OMAP_DSP_MEM1_SIZE 0x18000
6280238c
ORL
40
41/* MEM2 is L1P RAM/CACHE space */
42#define OMAP_DSP_MEM2_BASE 0x5CE00000
43#define OMAP_DSP_MEM2_SIZE 0x8000
6280238c
ORL
44
45/* MEM3 is L1D RAM/CACHE space */
46#define OMAP_DSP_MEM3_BASE 0x5CF04000
47#define OMAP_DSP_MEM3_SIZE 0x14000
6280238c
ORL
48
49#define OMAP_PER_CM_BASE 0x48005000
50#define OMAP_PER_CM_SIZE 0x1000
51
52#define OMAP_PER_PRM_BASE 0x48307000
53#define OMAP_PER_PRM_SIZE 0x1000
54
55#define OMAP_CORE_PRM_BASE 0x48306A00
56#define OMAP_CORE_PRM_SIZE 0x1000
57
6280238c
ORL
58#define OMAP_DMMU_BASE 0x5D000000
59#define OMAP_DMMU_SIZE 0x1000
60
6280238c
ORL
61/* GPP PROCESS CLEANUP Data structures */
62
63/* New structure (member of process context) abstracts NODE resource info */
64struct node_res_object {
ee4317f7 65 void *node;
6280238c
ORL
66 s32 node_allocated; /* Node status */
67 s32 heap_allocated; /* Heap status */
68 s32 streams_allocated; /* Streams status */
0624f52f 69 int id;
6280238c
ORL
70};
71
72/* used to cache dma mapping information */
73struct bridge_dma_map_info {
74 /* direction of DMA in action, or DMA_NONE */
75 enum dma_data_direction dir;
76 /* number of elements requested by us */
77 int num_pages;
78 /* number of elements returned from dma_map_sg */
79 int sg_num;
80 /* list of buffers used in this DMA action */
81 struct scatterlist *sg;
82};
83
84/* Used for DMM mapped memory accounting */
85struct dmm_map_object {
86 struct list_head link;
87 u32 dsp_addr;
88 u32 mpu_addr;
89 u32 size;
90 u32 num_usr_pgs;
91 struct page **pages;
92 struct bridge_dma_map_info dma_info;
93};
94
677f2ded
FC
95/* Used for DMM reserved memory accounting */
96struct dmm_rsv_object {
97 struct list_head link;
98 u32 dsp_reserved_addr;
99};
100
6280238c
ORL
101/* New structure (member of process context) abstracts stream resource info */
102struct strm_res_object {
103 s32 stream_allocated; /* Stream status */
ee4317f7 104 void *stream;
6280238c
ORL
105 u32 num_bufs;
106 u32 dir;
4ec09714 107 int id;
6280238c
ORL
108};
109
110/* Overall Bridge process resource usage state */
111enum gpp_proc_res_state {
112 PROC_RES_ALLOCATED,
113 PROC_RES_FREED
114};
115
116/* Bridge Data */
117struct drv_data {
118 char *base_img;
119 s32 shm_size;
120 int tc_wordswapon;
121 void *drv_object;
122 void *dev_object;
123 void *mgr_object;
124};
125
126/* Process Context */
127struct process_context {
128 /* Process State */
129 enum gpp_proc_res_state res_state;
130
131 /* Handle to Processor */
a534f17b 132 void *processor;
6280238c
ORL
133
134 /* DSP Node resources */
0624f52f 135 struct idr *node_id;
6280238c
ORL
136
137 /* DMM mapped memory resources */
138 struct list_head dmm_map_list;
139 spinlock_t dmm_map_lock;
140
a2890350
FC
141 /* DMM reserved memory resources */
142 struct list_head dmm_rsv_list;
143 spinlock_t dmm_rsv_lock;
144
6280238c 145 /* Stream resources */
4ec09714 146 struct idr *stream_id;
6280238c
ORL
147};
148
149/*
150 * ======== drv_create ========
151 * Purpose:
152 * Creates the Driver Object. This is done during the driver loading.
153 * There is only one Driver Object in the DSP/BIOS Bridge.
154 * Parameters:
e436d07d 155 * drv_obj: Location to store created DRV Object handle.
6280238c 156 * Returns:
25985edc 157 * 0: Success
6280238c
ORL
158 * -ENOMEM: Failed in Memory allocation
159 * -EPERM: General Failure
160 * Requires:
161 * DRV Initialized (refs > 0 )
e436d07d 162 * drv_obj != NULL.
6280238c 163 * Ensures:
e436d07d 164 * 0: - *drv_obj is a valid DRV interface to the device.
6280238c 165 * - List of DevObject Created and Initialized.
9b0131cb 166 * - List of dev_node String created and initialized.
6280238c
ORL
167 * - Registry is updated with the DRV Object.
168 * !0: DRV Object not created
169 * Details:
170 * There is one Driver Object for the Driver representing
171 * the driver itself. It contains the list of device
172 * Objects and the list of Device Extensions in the system.
25985edc 173 * Also it can hold other necessary
6280238c
ORL
174 * information in its storage area.
175 */
e436d07d 176extern int drv_create(struct drv_object **drv_obj);
6280238c
ORL
177
178/*
179 * ======== drv_destroy ========
180 * Purpose:
181 * destroys the Dev Object list, DrvExt list
182 * and destroy the DRV object
25985edc 183 * Called upon driver unLoading.or unsuccessful loading of the driver.
6280238c 184 * Parameters:
c8c1ad8c 185 * driver_obj: Handle to Driver object .
6280238c
ORL
186 * Returns:
187 * 0: Success.
188 * -EPERM: Failed to destroy DRV Object
189 * Requires:
190 * DRV Initialized (cRegs > 0 )
191 * hdrv_obj is not NULL and a valid DRV handle .
192 * List of DevObject is Empty.
193 * List of DrvExt is Empty
194 * Ensures:
195 * 0: - DRV Object destroyed and hdrv_obj is not a valid
196 * DRV handle.
197 * - Registry is updated with "0" as the DRV Object.
198 */
c8c1ad8c 199extern int drv_destroy(struct drv_object *driver_obj);
6280238c
ORL
200
201/*
202 * ======== drv_exit ========
203 * Purpose:
204 * Exit the DRV module, freeing any modules initialized in drv_init.
205 * Parameters:
206 * Returns:
207 * Requires:
208 * Ensures:
209 */
210extern void drv_exit(void);
211
212/*
213 * ======== drv_get_first_dev_object ========
214 * Purpose:
215 * Returns the Ptr to the FirstDev Object in the List
216 * Parameters:
217 * Requires:
218 * DRV Initialized
219 * Returns:
220 * dw_dev_object: Ptr to the First Dev Object as a u32
221 * 0 if it fails to retrieve the First Dev Object
222 * Ensures:
223 */
224extern u32 drv_get_first_dev_object(void);
225
226/*
227 * ======== drv_get_first_dev_extension ========
228 * Purpose:
229 * Returns the Ptr to the First Device Extension in the List
230 * Parameters:
231 * Requires:
232 * DRV Initialized
233 * Returns:
234 * dw_dev_extension: Ptr to the First Device Extension as a u32
235 * 0: Failed to Get the Device Extension
236 * Ensures:
237 */
238extern u32 drv_get_first_dev_extension(void);
239
240/*
241 * ======== drv_get_dev_object ========
242 * Purpose:
243 * Given a index, returns a handle to DevObject from the list
244 * Parameters:
245 * hdrv_obj: Handle to the Manager
e436d07d 246 * device_obj: Location to store the Dev Handle
6280238c
ORL
247 * Requires:
248 * DRV Initialized
249 * index >= 0
250 * hdrv_obj is not NULL and Valid DRV Object
e436d07d 251 * device_obj is not NULL
6280238c
ORL
252 * Device Object List not Empty
253 * Returns:
254 * 0: Success
255 * -EPERM: Failed to Get the Dev Object
256 * Ensures:
e436d07d
RS
257 * 0: *device_obj != NULL
258 * -EPERM: *device_obj = NULL
6280238c
ORL
259 */
260extern int drv_get_dev_object(u32 index,
261 struct drv_object *hdrv_obj,
e436d07d 262 struct dev_object **device_obj);
6280238c
ORL
263
264/*
265 * ======== drv_get_next_dev_object ========
266 * Purpose:
267 * Returns the Ptr to the Next Device Object from the the List
268 * Parameters:
269 * hdev_obj: Handle to the Device Object
270 * Requires:
271 * DRV Initialized
272 * hdev_obj != 0
273 * Returns:
274 * dw_dev_object: Ptr to the Next Dev Object as a u32
275 * 0: If it fail to get the next Dev Object.
276 * Ensures:
277 */
278extern u32 drv_get_next_dev_object(u32 hdev_obj);
279
280/*
281 * ======== drv_get_next_dev_extension ========
282 * Purpose:
283 * Returns the Ptr to the Next Device Extension from the the List
284 * Parameters:
e6890692 285 * dev_extension: Handle to the Device Extension
6280238c
ORL
286 * Requires:
287 * DRV Initialized
e6890692 288 * dev_extension != 0.
6280238c
ORL
289 * Returns:
290 * dw_dev_extension: Ptr to the Next Dev Extension
291 * 0: If it fail to Get the next Dev Extension
292 * Ensures:
293 */
e6890692 294extern u32 drv_get_next_dev_extension(u32 dev_extension);
6280238c
ORL
295
296/*
297 * ======== drv_init ========
298 * Purpose:
299 * Initialize the DRV module.
300 * Parameters:
301 * Returns:
302 * TRUE if success; FALSE otherwise.
303 * Requires:
304 * Ensures:
305 */
306extern int drv_init(void);
307
308/*
309 * ======== drv_insert_dev_object ========
310 * Purpose:
311 * Insert a DeviceObject into the list of Driver object.
312 * Parameters:
c8c1ad8c 313 * driver_obj: Handle to DrvObject
6280238c
ORL
314 * hdev_obj: Handle to DeviceObject to insert.
315 * Returns:
316 * 0: If successful.
317 * -EPERM: General Failure:
318 * Requires:
319 * hdrv_obj != NULL and Valid DRV Handle.
320 * hdev_obj != NULL.
321 * Ensures:
322 * 0: Device Object is inserted and the List is not empty.
323 */
c8c1ad8c 324extern int drv_insert_dev_object(struct drv_object *driver_obj,
6280238c
ORL
325 struct dev_object *hdev_obj);
326
327/*
328 * ======== drv_remove_dev_object ========
329 * Purpose:
330 * Search for and remove a Device object from the given list of Device Obj
331 * objects.
332 * Parameters:
c8c1ad8c 333 * driver_obj: Handle to DrvObject
6280238c
ORL
334 * hdev_obj: Handle to DevObject to Remove
335 * Returns:
336 * 0: Success.
337 * -EPERM: Unable to find dev_obj.
338 * Requires:
339 * hdrv_obj != NULL and a Valid DRV Handle.
340 * hdev_obj != NULL.
341 * List exists and is not empty.
342 * Ensures:
343 * List either does not exist (NULL), or is not empty if it does exist.
344 */
c8c1ad8c 345extern int drv_remove_dev_object(struct drv_object *driver_obj,
6280238c
ORL
346 struct dev_object *hdev_obj);
347
348/*
349 * ======== drv_request_resources ========
350 * Purpose:
351 * Assigns the Resources or Releases them.
352 * Parameters:
353 * dw_context: Path to the driver Registry Key.
aa09b091 354 * dev_node_strg: Ptr to dev_node String stored in the Device Ext.
6280238c
ORL
355 * Returns:
356 * TRUE if success; FALSE otherwise.
357 * Requires:
358 * Ensures:
359 * The Resources are assigned based on Bus type.
360 * The hardware is initialized. Resource information is
361 * gathered from the Registry(ISA, PCMCIA)or scanned(PCI)
362 * Resource structure is stored in the registry which will be
363 * later used by the CFG module.
364 */
9d7d0a52 365extern int drv_request_resources(u32 dw_context,
e6bf74f0 366 u32 *dev_node_strg);
6280238c
ORL
367
368/*
369 * ======== drv_release_resources ========
370 * Purpose:
371 * Assigns the Resources or Releases them.
372 * Parameters:
373 * dw_context: Path to the driver Registry Key.
374 * hdrv_obj: Handle to the Driver Object.
375 * Returns:
376 * TRUE if success; FALSE otherwise.
377 * Requires:
378 * Ensures:
379 * The Resources are released based on Bus type.
380 * Resource structure is deleted from the registry
381 */
9d7d0a52 382extern int drv_release_resources(u32 dw_context,
6280238c
ORL
383 struct drv_object *hdrv_obj);
384
385/**
386 * drv_request_bridge_res_dsp() - Reserves shared memory for bridge.
387 * @phost_resources: pointer to host resources.
388 */
389int drv_request_bridge_res_dsp(void **phost_resources);
390
b3d23688 391#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
6280238c
ORL
392void bridge_recover_schedule(void);
393#endif
394
395/*
396 * ======== mem_ext_phys_pool_init ========
397 * Purpose:
9e36261d 398 * Uses the physical memory chunk passed for internal consistent memory
6280238c
ORL
399 * allocations.
400 * physical address based on the page frame address.
401 * Parameters:
fb6aabb7
RS
402 * pool_phys_base starting address of the physical memory pool.
403 * pool_size size of the physical memory pool.
6280238c
ORL
404 * Returns:
405 * none.
406 * Requires:
407 * - MEM initialized.
408 * - valid physical address for the base and size > 0
409 */
9d7d0a52 410extern void mem_ext_phys_pool_init(u32 pool_phys_base, u32 pool_size);
6280238c
ORL
411
412/*
413 * ======== mem_ext_phys_pool_release ========
414 */
415extern void mem_ext_phys_pool_release(void);
416
417/* ======== mem_alloc_phys_mem ========
418 * Purpose:
419 * Allocate physically contiguous, uncached memory
420 * Parameters:
421 * byte_size: Number of bytes to allocate.
0cd343a4 422 * align_mask: Alignment Mask.
13b18c29 423 * physical_address: Physical address of allocated memory.
6280238c
ORL
424 * Returns:
425 * Pointer to a block of memory;
426 * NULL if memory couldn't be allocated, or if byte_size == 0.
427 * Requires:
428 * MEM initialized.
429 * Ensures:
430 * The returned pointer, if not NULL, points to a valid memory block of
431 * the size requested. Returned physical address refers to physical
432 * location of memory.
433 */
9d7d0a52 434extern void *mem_alloc_phys_mem(u32 byte_size,
e6bf74f0 435 u32 align_mask, u32 *physical_address);
6280238c
ORL
436
437/*
438 * ======== mem_free_phys_mem ========
439 * Purpose:
440 * Free the given block of physically contiguous memory.
441 * Parameters:
318b5df9 442 * virtual_address: Pointer to virtual memory region allocated
6280238c 443 * by mem_alloc_phys_mem().
13b18c29 444 * physical_address: Pointer to physical memory region allocated
6280238c
ORL
445 * by mem_alloc_phys_mem().
446 * byte_size: Size of the memory region allocated by mem_alloc_phys_mem().
447 * Returns:
448 * Requires:
449 * MEM initialized.
318b5df9 450 * virtual_address is a valid memory address returned by
6280238c
ORL
451 * mem_alloc_phys_mem()
452 * Ensures:
318b5df9 453 * virtual_address is no longer a valid pointer to memory.
6280238c 454 */
318b5df9 455extern void mem_free_phys_mem(void *virtual_address,
13b18c29 456 u32 physical_address, u32 byte_size);
6280238c
ORL
457
458/*
459 * ======== MEM_LINEAR_ADDRESS ========
460 * Purpose:
461 * Get the linear address corresponding to the given physical address.
462 * Parameters:
13b18c29 463 * phys_addr: Physical address to be mapped.
6280238c
ORL
464 * byte_size: Number of bytes in physical range to map.
465 * Returns:
466 * The corresponding linear address, or NULL if unsuccessful.
467 * Requires:
468 * MEM initialized.
469 * Ensures:
470 * Notes:
471 * If valid linear address is returned, be sure to call
472 * MEM_UNMAP_LINEAR_ADDRESS().
473 */
fb6aabb7 474#define MEM_LINEAR_ADDRESS(phy_addr, byte_size) phy_addr
6280238c
ORL
475
476/*
477 * ======== MEM_UNMAP_LINEAR_ADDRESS ========
478 * Purpose:
479 * Unmap the linear address mapped in MEM_LINEAR_ADDRESS.
480 * Parameters:
aa09b091 481 * base_addr: Ptr to mapped memory (as returned by MEM_LINEAR_ADDRESS()).
6280238c
ORL
482 * Returns:
483 * Requires:
484 * - MEM initialized.
aa09b091 485 * - base_addr is a valid linear address mapped in MEM_LINEAR_ADDRESS.
6280238c 486 * Ensures:
aa09b091 487 * - base_addr no longer points to a valid linear address.
6280238c 488 */
aa09b091 489#define MEM_UNMAP_LINEAR_ADDRESS(base_addr) {}
6280238c
ORL
490
491#endif /* DRV_ */