source: svn/newcon3bcm2_21bu/magnum/portinginterface/mmd/7552/bmmd.h @ 76

Last change on this file since 76 was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 16.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bmmd.h $
11 * $brcm_Revision: Hydra_Software_Devel/7 $
12 * $brcm_Date: 11/8/11 5:55p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/mmd/7425/bmmd.h $
19 *
20 * Hydra_Software_Devel/7   11/8/11 5:55p jtna
21 * SW7425-1709: add standby/resume
22 *
23 * Hydra_Software_Devel/6   9/14/11 11:44a jtna
24 * SW7420-2046: add memory bounds
25 *
26 * Hydra_Software_Devel/5   6/29/11 4:31p jtna
27 * SW7422-416: update comment
28 *
29 * Hydra_Software_Devel/4   5/23/11 4:33p jtna
30 * SW7422-416: improve API-level documentation
31 *
32 * Hydra_Software_Devel/3   5/12/11 12:31p jtna
33 * SW7550-742: merge SHARF support
34 *
35 * Hydra_Software_Devel/2   4/15/11 5:50p jtna
36 * SW7422-416: merge to main
37 *
38 ***************************************************************************/
39
40#ifndef BMMD_H__
41#define BMMD_H__
42
43#include "bstd.h"
44#include "bkni.h"
45#include "bchp.h"
46#include "breg_mem.h"
47#include "bmem.h"
48#include "bint.h"
49#include "berr_ids.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55/*******************************************************************************
56Module Overview:
57    MMD is a Magnum portinginterface for mem-to-mem DMA transfers.
58    It is intended to replace the mem-to-mem functionality of BDMA.
59   
60    In MMD, DMA transfers are performed using one or more MMD "contexts"
61    (BMMD_ContextHandle). A MMD context represents a single DMA job that you
62    want to perform: a chain of DMA descriptors and its associated completion
63    callback.
64   
65    After a context has been created (BMMD_Context_Create()), it is "enqueued"
66    (BMMD_Context_Enqueue()), which queues up the context in the DMA HW.
67
68    A single MMD context can only be used for a single DMA job at a time.
69    That is, after a context has been enqueued, it cannot be enqueued again
70    before it has finished. To perform multiple DMA jobs in succession, you
71    create multiple contexts and enqueue them in the desired order.
72    As each context completes, the completion callback associated with that
73    context will fire.
74         
75    A MMD context can be enqueued while another context is currently active,
76    i.e. while the HW is currently busy. The new context's chain of descriptors
77    is appended to the last-enqueued descriptor in HW. The completion callback
78    of previously-enqueued contexts will still fire at their respective
79    completions.   
80*******************************************************************************/
81
82/*******************************************************************************
83Summary:
84    MMD return codes
85*******************************************************************************/
86#define BMMD_QUEUED   BERR_MAKE_CODE(BERR_MMD_ID, 0)
87
88
89/*******************************************************************************
90Summary:
91    MMD engine (HW) types
92*******************************************************************************/
93typedef enum BMMD_EngineType
94{
95    BMMD_EngineType_eDma = 0, /* MEM_DMA HW */
96    BMMD_EngineType_eSharf,   /* SHARF_DMA HW */
97    BMMD_EngineType_eMax
98} BMMD_EngineType;
99
100
101/*******************************************************************************
102Summary:
103    MMD settings
104*******************************************************************************/
105typedef struct BMMD_Settings
106{
107    BMMD_EngineType engineType; /* DMA or Sharf HW */
108    int engineIndex;            /* some platforms have more than one DMA or Sharf HW block.
109                                   index 0 opens the first HW block */
110} BMMD_Settings;
111
112
113/*******************************************************************************
114Summary:
115    Get default MMD settings
116*******************************************************************************/
117void BMMD_GetDefaultSettings(
118    BMMD_Settings *pSettings /* [out] */
119    );
120
121   
122/*******************************************************************************
123Summary:
124    Opaque MMD handle
125*******************************************************************************/
126typedef struct BMMD_Handle_Tag *BMMD_Handle;
127
128
129/*******************************************************************************
130Summary:
131    Create a MMD handle with MMD settings
132*******************************************************************************/
133BERR_Code BMMD_Open(
134    BCHP_Handle hChp,               /* chip handle */
135    BREG_Handle hReg,               /* register handle */
136    BMEM_Handle hMem,               /* memory handle */
137    BINT_Handle hInt,               /* interrupt handle */
138    const BMMD_Settings *pSettings, /* settings */
139    BMMD_Handle *phMmd              /* [out] MMD handle */
140    );
141
142   
143/*******************************************************************************
144Summary:
145    Endian format of source data to be read from memory
146*******************************************************************************/
147typedef enum BMMD_EndianMode
148{
149    BMMD_EndianMode_eLittle,
150    BMMD_EndianMode_eBig,
151    BMMD_EndianMode_eMax
152} BMMD_EndianMode;
153
154   
155/*******************************************************************************
156Summary:
157    Endian translation method of data to be written to memory
158*******************************************************************************/
159typedef enum BMMD_SwapMode
160{
161    BMMD_SwapMode_eNone,
162    BMMD_SwapMode_eWord, /* swap 16-bit words (0x00112233 -> 0x22330011) */
163    BMMD_SwapMode_eByte, /* swap  8-bit bytes (0x00112233 -> 0x33221100) */
164    BMMD_SwapMode_eMax
165} BMMD_SwapMode;
166
167
168/*******************************************************************************
169Summary:
170    Data scrambling mode
171
172Description:
173    This enum is only used with MEM_DMA HW (BMMD_EngineType_eDma)
174*******************************************************************************/
175typedef enum BMMD_ScramMode
176{
177    BMMD_ScramMode_eNone = 0, /* no scrambling */
178    BMMD_ScramMode_eBlock,    /* scramble all data as a generic block */
179    BMMD_ScramMode_eMpeg,     /* only scramble the payload of 188-byte MPEG2-TS packets.
180                                 192-byte MPEG2-TS packets are not supported */
181    BMMD_ScramMode_eDss,      /* only scramble the payload of 130-byte DSS packets */
182    BMMD_ScramMode_eMax
183} BMMD_ScramMode;
184
185
186/*******************************************************************************
187Summary:
188    Sharf scrambling mode
189
190Description:
191    This enum is only used with SHARF_DMA HW (BMMD_EngineType_eSharf)
192*******************************************************************************/
193typedef enum BMMD_SharfMode
194{
195    BMMD_SharfMode_ePassThrough = 0,
196    BMMD_SharfMode_eSha1,
197    BMMD_SharfMode_eAes128CbcDecrypt,
198    BMMD_SharfMode_eAes128CbcEncrypt,
199    BMMD_SharfMode_eCmac,
200    BMMD_SharfMode_eAes128EcbDecrypt,
201    BMMD_SharfMode_eAes128EcbEncrypt,
202    BMMD_SharfMode_eMax
203} BMMD_SharfMode;
204
205
206/*******************************************************************************
207Summary:
208    Context settings
209   
210See Also:
211    BMMD_ContextHandle   
212    BMMD_Context_Enqueue()
213*******************************************************************************/
214typedef struct BMMD_ContextSettings
215{
216    unsigned maxNumBlocks;      /* maximum number of blocks in this context.
217                                   this parameter is used to allocate memory from the system heap */
218
219    BMMD_EndianMode endianMode; /* data endianness */
220    BMMD_SwapMode swapMode;     /* endian translation method */
221    BMMD_ScramMode scramMode;   /* scrambling mode */
222    unsigned keyslot;           /* keyslot number. this is ignored if BMMD_ScramMode_eNone or
223                                   BMMD_EngineType_eSharf */
224
225    struct {
226        uint32_t offset; /* bounded memory offset (0=no bounds check) */
227        unsigned size;   /* bounded memory size  (0=no bounds check) */
228    } memoryBounds; /* used to verify that transfers do not violate memory bounds */
229
230    /* Sharf-specific settings */
231    struct {
232        bool useBspKey; /* if true, SHARF will use a secure key supplied by BSP directly
233                           for data encryption/decryption. if false, SHARF will use the key
234                           that prepends the descriptor data */
235        BMMD_SharfMode mode;
236        unsigned shaContext; /* SHARF HW can hold the intermediate or final SHA-1 digest
237                                for up to 3 contexts across all SHARF DMA channels. This
238                                allows interleaving SHARF DMA operations.
239                                Valid values are 0,1 or 2. */
240    } sharf;
241   
242    /* callback that fires in ISR-context when this MMD context has completed. can be NULL */
243    void (*callback_isr)(void *pParm1, int parm2);
244    void *pParm1;
245    int pParm2;
246} BMMD_ContextSettings;
247
248
249/*******************************************************************************
250Summary:
251    Get default context settings
252*******************************************************************************/
253void BMMD_Context_GetDefaultSettings(
254    BMMD_ContextSettings *pSettings /* [out] */
255    );
256     
257   
258/*******************************************************************************
259Summary:
260    Context block settings. A context block is a single DMA descriptor.
261*******************************************************************************/
262typedef struct BMMD_ContextBlockSettings
263{
264    uint32_t src;  /* source physical address */
265    uint32_t dst;  /* destination physical address */
266    unsigned size; /* block size in bytes */
267   
268    bool resetCrypto;  /* if true, discontinue crypto from previous block and re-initialize.
269                          this is ignored if BMMD_EngineType_eSharf */
270    bool sgScramStart; /* if true, then this block indicates the start of scatter-gather scrambling operation */
271    bool sgScramEnd;   /* if true, then this block indicates the end of scatter-gather scrambling operation */
272
273    /* Sharf-specific settings */
274    struct {
275        bool keyPresent;    /* if true, a crypto key prepends the data */
276        bool digestPresent; /* if true, a hash digest or MAC prepends the data */
277    } sharf;
278} BMMD_ContextBlockSettings;
279
280
281/*******************************************************************************
282Summary:
283    Get default context block settings
284*******************************************************************************/
285void BMMD_Context_GetDefaultBlockSettings(
286    BMMD_ContextBlockSettings *pSettings /* [out] */
287    );
288
289
290/*******************************************************************************
291Summary:
292    Opaque MMD context handle
293   
294Description:
295    A MMD context represents a single DMA job to be performed: a chain of
296    DMA descriptors and its associated completion callback.
297   
298    A single MMD context can only be used for a single DMA job at a time.
299    That is, after a context has been enqueued, it cannot be enqueued again
300    before it has finished. To perform multiple DMA jobs in succession, you
301    create multiple contexts and enqueue them in the desired order.
302   
303    There is no MMD-imposed limit to how many contexts can be created.
304*******************************************************************************/
305typedef struct BMMD_Context *BMMD_ContextHandle;
306   
307       
308/*******************************************************************************
309Summary:
310    Create a MMD context handle
311*******************************************************************************/
312BMMD_ContextHandle BMMD_Context_Create(
313    BMMD_Handle hMmd,
314    const BMMD_ContextSettings *pSettings
315    );
316
317
318/*******************************************************************************
319Summary:
320    Get current context settings
321*******************************************************************************/
322BERR_Code BMMD_Context_GetSettings(
323    BMMD_ContextHandle hCtx,
324    BMMD_ContextSettings *pSettings /* [out] */
325    );
326
327   
328/*******************************************************************************
329Summary:
330    Set new context settings
331
332Description:
333    Context settings can only be changed when the context is idle. Otherwise,
334    this function will fail.
335    Changing BMMD_ContextSettings.maxNumBlocks is not allowed. To change
336    maxNumBlocks, a new context must be created.
337*******************************************************************************/
338BERR_Code BMMD_Context_SetSettings(
339    BMMD_ContextHandle hCtx,
340    const BMMD_ContextSettings *pSettings
341    );
342
343   
344/*******************************************************************************
345Summary:
346    Enqueue a context with an array of context block settings
347
348Description:
349    If no other contexts are currently active, then the context starts
350    immediately.
351    Otherwise, the context is processed after all previously-queued contexts
352    have completed.
353   
354    The context has to be idle in order to be enqueued.
355
356Returns:
357    BERR_SUCCESS       if context was completed
358    BMMD_QUEUED        if context is in progress or is queued
359    BERR_NOT_SUPPORTED if context was not idle
360*******************************************************************************/
361BERR_Code BMMD_Context_Enqueue(
362    BMMD_ContextHandle hCtx,
363    const BMMD_ContextBlockSettings *pSettings, /* array of BMMD_ContextBlockSettings */
364    unsigned numBlocks                          /* number of BMMD_ContextBlockSettings elements.
365                                                   must be <= BMMD_ContextSettings.maxNumBlocks */
366    );
367
368
369/*******************************************************************************
370Summary:
371    Context state
372*******************************************************************************/
373typedef enum BMMD_ContextState
374{
375    BMMD_ContextState_eIdle,       /* idle or complete */
376    BMMD_ContextState_eInProgress  /* queued in HW. the HW may not yet have started
377                                      the context if there are other active contexts */
378} BMMD_ContextState;
379
380   
381/*******************************************************************************
382Summary:
383    Context status
384*******************************************************************************/
385typedef struct BMMD_ContextStatus
386{
387    BMMD_ContextState state;
388} BMMD_ContextStatus;
389
390
391/*******************************************************************************
392Summary:
393    Get current status of a MMD context
394*******************************************************************************/
395BERR_Code BMMD_Context_GetStatus(
396    BMMD_ContextHandle hCtx,
397    BMMD_ContextStatus *pStatus /* [out] */
398    );
399
400
401/*******************************************************************************
402Summary:
403    Destroy a MMD context
404   
405Description:
406    If there are no currently active MMD contexts, then the memory allocated
407    for DMA descriptors is freed immediately.
408   
409    If there are currently active MMD contexts, then this function does not wait
410    for them to finish. The completion callback will not fire. The contexts
411    may or may not finish; this behavior is undefined.   
412    The memory allocated for DMA descriptors may not be freed immediately.
413*******************************************************************************/
414void BMMD_Context_Destroy(
415    BMMD_ContextHandle hCtx
416    );   
417
418
419/*******************************************************************************
420Summary:
421    Close MMD handle
422   
423Description:
424    This function immediately stops the HW, destroys any undestroyed contexts,
425    and frees all resources.
426*******************************************************************************/
427void BMMD_Close(
428    BMMD_Handle hMmd
429    );
430
431/*******************************************************************************
432Summary:
433    Standby settings. Currently unused.
434*******************************************************************************/
435typedef struct BMMD_StandbySettings {
436    unsigned unused; /* dummy placeholder */
437} BMMD_StandbySettings;
438
439/*******************************************************************************
440Summary:
441    Enter standby
442
443Description:
444    MMD requires that there are no unfinished contexts before entering standby.
445    MMD does not require that opened contexts are destroyed before entering standby.
446*******************************************************************************/
447BERR_Code BMMD_Standby(
448    BMMD_Handle hMmd,
449    const BMMD_StandbySettings *pSettings /* optional */
450    );
451
452/*******************************************************************************
453Summary:
454    Exit standby
455
456Description:
457    Upon exitting standby, MMD programs the HW back to a state similar to
458    BMMD_Open, while retaining any opened contexts.
459*******************************************************************************/
460void BMMD_Resume(
461    BMMD_Handle hMmd
462    );
463
464#ifdef __cplusplus
465}
466#endif
467 
468#endif
Note: See TracBrowser for help on using the repository browser.