source: svn/newcon3bcm2_21bu/magnum/basemodules/hab/3461/bhab_3461_priv.h

Last change on this file 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) 2005-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: bhab_3461_priv.h $
11 * $brcm_Revision: Hydra_Software_Devel/3 $
12 * $brcm_Date: 5/27/11 4:28p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/basemodules/hab/3461/bhab_3461_priv.h $
19 *
20 * Hydra_Software_Devel/3   5/27/11 4:28p atanugul
21 * SW3461-3: Added BHAB_GetConfigSettings() and BHAB_SetConfigSettings()
22 *
23 * Hydra_Software_Devel/2   3/31/11 11:25a atanugul
24 * SW3461-3: Update GetStatus, DecodeInterrupt and code cleanup
25 *
26 * Hydra_Software_Devel/1   3/16/11 3:33p atanugul
27 * SW3461-3: Add support for BCM3461
28 *
29 *
30 ***************************************************************************/
31#ifndef BHAB_3461_PRIV_H
32#define BHAB_3461_PRIV_H
33
34#include "bstd.h"
35#include "bi2c.h"
36#include "bkni.h"
37#include "bkni_multi.h"
38#include "bhab_priv.h"
39
40/* Defines raw HAB test mesg hdr (struct) */
41#define HAB_MSG_HDR(OPCODE,N,CORE_TYPE,CORE_ID) \
42    { ((uint8_t)(((uint16_t)(OPCODE)) >> 2)), \
43    (((uint8_t)(0x03 & (OPCODE)) << 6) | ((uint8_t)((N)>>4))), \
44    ((((uint8_t)(((N)& 0x0F) << 4))) | ((uint8_t)(0x0F & (CORE_TYPE)))), \
45    ((uint8_t)(CORE_ID)) }
46   
47#define BHAB_CORE_TYPE                  0xF
48#define BHAB_CORE_ID                    0x0
49#define BHAB_GETVERSION             0xB9
50#define BHAB_READ_DAISY             0xC0
51#define BHAB_WRITE_DAISY            0x20
52
53#define BHAB_WINDOW_IRAM            0x00000000
54#define BHAB_WINDOW_IROM            0x00008000
55#define BHAB_WINDOW_HAB             0x00010000
56#define BHAB_WINDOW_IDATA           0x00010400
57
58#define BHAB_IRAM_SIZE              0xffff
59#define BHAB_IROM_SIZE              0x8000
60#define BHAB_MEM_SIZE               0x00010000
61#define BHAB_CPU_RUNNIG             0x40
62#define BHAB_HAB_SIZE               0x80
63#define BHAB_INIT_RETRIES           0x14
64
65#define PAYLOAD_LEN                 0x00
66#define CORE_TYPE                   0x00
67#define CORE_ID                     0x00
68
69#define BHAB_HAB_DONE                0x00000001
70#define BHAB_AP_ERROR                0x00000004
71#define BHAB_AP_INIT_DONE            0x00000008
72#define BHAB_ADS_STATUS_RDY          0x00000010
73#define BHAB_OOB_STATUS_RDY          0x00000020
74#define BHAB_THD_STATUS_RDY          0x00000040
75#define BHAB_T2_STATUS_RDY           0x00000080
76#define BHAB_C2_STATUS_RDY           0x00000100
77#define BHAB_TNR_STATUS_RDY          0x00000200
78#define BHAB_THD_IN_LOCK             0x00000400
79#define BHAB_THD_OUT_OF_LOCK         0x00000800
80#define BHAB_T2_IN_LOCK              0x00001000
81#define BHAB_T2_OUT_OF_LOCK          0x00002000
82#define BHAB_OOB_IN_LOCK             0x00004000
83#define BHAB_OOB_OUT_OF_LOCK         0x00008000
84#define BHAB_ADS_CHN0_IN_LOCK        0x00010000
85#define BHAB_ADS_CHN0_OUT_OF_LOCK    0x00020000
86#define BHAB_ADS_CHN1_IN_LOCK        0x00040000
87#define BHAB_ADS_CHN1_OUT_OF_LOCK    0x00080000
88#define BHAB_ADS_CHN2_IN_LOCK        0x00100000
89#define BHAB_ADS_CHN2_OUT_OF_LOCK    0x00200000
90#define BHAB_ADS_CHN3_IN_LOCK        0x00400000
91#define BHAB_ADS_CHN3_OUT_OF_LOCK    0x00800000
92#define BHAB_ADS_CHN4_IN_LOCK        0x01000000
93#define BHAB_ADS_CHN4_OUT_OF_LOCK    0x02000000
94#define BHAB_ADS_CHN5_IN_LOCK        0x04000000
95#define BHAB_ADS_CHN5_OUT_OF_LOCK    0x08000000
96#define BHAB_ADS_CHN6_IN_LOCK        0x10000000
97#define BHAB_ADS_CHN6_OUT_OF_LOCK    0x20000000
98#define BHAB_ADS_CHN7_IN_LOCK        0x40000000
99#define BHAB_ADS_CHN7_OUT_OF_LOCK    0x80000000
100
101#define BHAB_P_ACQUIRE_MUTEX(handle) BKNI_AcquireMutex(((BHAB_3461_P_Handle *)(handle->pImpl))->hMutex)
102#define BHAB_P_RELEASE_MUTEX(handle) BKNI_ReleaseMutex(((BHAB_3461_P_Handle *)(handle->pImpl))->hMutex)
103
104
105typedef struct BHAB_P_CallbackInfo
106{
107    BHAB_IntCallbackFunc func;
108    void * pParm1;
109    int parm2 ;
110} BHAB_P_CallbackInfo;
111
112
113typedef struct BHAB_3461_P_Handle
114{
115    BREG_I2C_Handle  hRegister;         /* handle to the master I2C device used to access registers */     
116    BKNI_EventHandle hInterruptEvent;   /* interrupt event handle */   
117    BKNI_EventHandle hApiEvent;         /* API event handle */   
118    BKNI_EventHandle hInitDoneEvent;    /* AP initialization done event handle */
119    BKNI_EventHandle hHabDoneEvent;     /* HAB done event handle */
120    BKNI_MutexHandle hMutex;            /* Mutex handle for serialization */
121    BHAB_P_CallbackInfo InterruptCallbackInfo[BHAB_DevId_eMax];
122    BHAB_WatchDogTimerSettings wdtSettings;
123    BHAB_NmiSettings nmiSettings;
124    bool loadAP;                                                  /* Load(ed) Acquisition Processor microcode when starting. */
125    BHAB_RfDaisyChain daisyChain;   /* daisy chain output*/     
126} BHAB_3461_P_Handle;
127
128
129
130/******************************************************************************
131 Summary:
132   I2c Read for 3461.
133
134Description:
135   I2c Read for 3461.
136   
137Returns:
138   BERR_Code
139******************************************************************************/
140BERR_Code BREG_I2C_P_Read3461(
141    BREG_I2C_Handle i2cHandle,    /* [in] BREG_I2C Handle */
142    uint16_t chipAddr, 
143    uint8_t subAddr, 
144    uint8_t *pData, 
145    size_t length
146);
147
148
149/******************************************************************************
150Summary:
151   Enables/Disables the L1 host interrupt.
152Description:
153   Enables/Disables the L1 host interrupt by calling the application-supplied
154   callback routine the the BHAB settings.
155Returns:
156   BERR_Code
157******************************************************************************/
158BERR_Code BHAB_3461_P_EnableHostInterrupt(
159    BHAB_Handle handle, /* [in] BHAB PI handle */
160    bool bEnable   /* [in] true=enables the L1 interrupt on the host processor */
161);
162
163
164/******************************************************************************
165Summary:
166   Disables all host interrupts.
167Description:
168   This function clears the host interrupt enable bits on the BCM3461.
169Returns:
170   BERR_Code
171******************************************************************************/
172BERR_Code BHAB_3461_P_DisableInterrupts(
173   BHAB_Handle handle   /* [in] BHAB Handle */
174);
175
176
177/******************************************************************************
178Summary:
179   Enables the AP initialization done interrupt.
180Description:
181   This function is called by the BHAB_InitAp().
182Returns:
183   BERR_Code
184******************************************************************************/
185BERR_Code BHAB_3461_P_EnableInitDoneInterrupt(
186   BHAB_Handle handle  /* [in] BHAB Handle */
187);
188
189
190/******************************************************************************
191Summary:
192   Waits for a BHAB event.
193Description:
194   This function waits for an interrupt within the given timeout period.  Any
195   interrupts are then decoded via I2C.  If the given event has been signaled,
196   then this function returns BERR_SUCCESS.
197Returns:
198   BERR_Code
199******************************************************************************/
200BERR_Code BHAB_3461_P_WaitForEvent(
201    BHAB_Handle handle,             /* [in] BHAB Handle */
202    BKNI_EventHandle hEvent,   /* [in] event to wait on */
203    int timeoutMsec            /* [in] timeout in milliseconds */
204);
205
206
207/******************************************************************************
208Summary:
209   Runs the AP.
210Description:
211   This function takes the AP to out of reset/idle state and starts running.
212Returns:
213   BERR_Code
214******************************************************************************/
215BERR_Code BHAB_3461_P_RunAp(
216    BHAB_Handle handle   /* [in] BHAB PI Handle */
217);
218
219
220/******************************************************************************
221Summary:
222   Resets the AP.
223Description:
224   This function puts the AP in reset state.
225Returns:
226   BERR_Code
227******************************************************************************/
228BERR_Code BHAB_3461_P_ResetAp(
229    BHAB_Handle handle   /* [in] BHAB PI Handle */
230);
231
232
233/******************************************************************************
234Summary:
235   Reads from the host access buffer.
236Description:
237   This function positions the 128 byte window in the AP address space to the
238   host access buffer area.  (n) bytes are then read into (buf) starting from
239   the given HAB (offset) address.
240Returns:
241   BERR_Code
242******************************************************************************/
243BERR_Code BHAB_3461_P_ReadHab(
244    BHAB_Handle handle,   /* [in] BHAB PI Handle */
245    uint8_t offset,  /* [in] starting offset within the HAB to read */
246    uint8_t *buf,    /* [out] holds the data read */
247    uint8_t n        /* [in] number of bytes to read */ 
248);
249
250
251/******************************************************************************
252Summary:
253   Writes to the host access buffer.
254Description:
255   This function positions the 128 byte window in the AP address space to the
256   host access buffer area.  (n) bytes in (buf) are then written starting from
257   the given HAB (offset) address.
258Returns:
259   BERR_Code
260******************************************************************************/
261BERR_Code BHAB_3461_P_WriteHab(
262    BHAB_Handle handle,   /* [in] BHAB PI Handle */
263    uint8_t offset,  /* [in] starting offset in the HAB to write */
264    uint8_t *buf,    /* [in] specifies the data to write */
265    uint8_t n        /* [in] number of bytes to write */
266);
267
268
269/******************************************************************************
270Summary:
271   This function sends the command already written in the HAB.
272Description:
273   This function asserts HABR, waits for the AP to release the HAB, then
274   optionally checks for a service acknowlegement from the AP.  If bCheckForAck
275   is true, then read_len must be greater than 0.  This function is called by
276   BHAB_P_SendHabCommand().
277Returns:
278   BERR_Code
279******************************************************************************/
280BERR_Code BHAB_3461_P_ServiceHab(
281    BHAB_Handle h,   /* [in] BHAB Handle */
282    uint8_t *read_buf,  /* [out] holds the data read from the HAB */ 
283    uint8_t read_len,   /* [in] number of bytes to read from the HAB */
284    bool bCheckForAck,  /* [in] true = determine if the AP has serviced the command */
285    uint8_t ack_byte    /* [in] value of the ack byte to expect */
286);
287
288
289/******************************************************************************
290Summary:
291   Sets certain BKNI_Events based on the source of the BCM3461 host interrupt.
292Description:
293   This function reads and clears the BCM3461 interrupt status registers,
294   clears the enable mask of the interrupts, and sets BKNI_Events based on the
295   interrupt sources.
296Returns:
297   BERR_Code
298******************************************************************************/
299BERR_Code BHAB_3461_P_DecodeInterrupt(
300    BHAB_Handle handle /* [in] BHAB Handle */
301);
302
303
304
305/******************************************************************************
306Summary:
307   Returns the BERR_Code corresponding to the given BHAB_ApStatus.
308Description:
309   This function returns ths BERR_Code of any errors in the given BHAB_ApStatus.
310Returns:
311   BERR_Code
312******************************************************************************/
313BERR_Code BHAB_3461_P_DecodeError(
314   BHAB_Handle h,           /* [in] BHAB PI Handle */
315   BHAB_ApStatus *pApStatus /* [in] AP status returned by BHAB_GetApStatus */
316);
317
318
319/******************************************************************************
320Summary:
321   This function checks if the host is currently permitted to send an HAB
322   command.
323Description:
324   The HAB is available to the host if all 3 conditions currently apply:
325   1) The AP is running.
326   2) The AP has initialized.
327   3) The AP is not currently servicing the HAB (i.e. HABR bit is 0)
328Returns:
329   BERR_Code - BERR_SUCCESS if HAB is available, otherwise BERR_Code is reason
330   why HAB is not available
331******************************************************************************/
332BERR_Code BHAB_3461_P_CheckHab(
333   BHAB_Handle h  /* [in] BHAB PI Handle */
334);
335
336
337
338/****************** BCM3461 implementation of API functions *****************/
339
340
341
342BERR_Code BHAB_3461_Open(
343    BHAB_Handle *handle,     /* [out] BHAB handle */
344    void        *pReg,       /* [in] pointer ot i2c or spi handle */
345    const BHAB_Settings *pDefSettings /* [in] Default Settings */
346);
347
348BERR_Code BHAB_3461_Close(
349    BHAB_Handle h   /* [in] BHAB handle */
350);
351
352BERR_Code BHAB_3461_InitAp(
353    BHAB_Handle   h,       /* [in] BHAB handle */
354    const uint8_t *pImage  /* [in] pointer to AP microcode image */
355);
356
357BERR_Code BHAB_3461_GetApStatus(
358    BHAB_Handle   handle,    /* [in] HAB device handle */
359    BHAB_ApStatus *pStatus   /* [out] AP status */
360);
361
362BERR_Code BHAB_3461_GetApVersion(
363    BHAB_Handle    handle,     /* [in]  BHAB handle */
364    uint16_t       *pChipId,   /* [out] chip id */
365    uint16_t       *pChipVer,  /* [out] chip revision number */
366    uint8_t        *pApVer,    /* [out] AP microcode version */
367    uint8_t        *pScrVer,   /* [out] acquisition script version */
368    uint8_t        *pCfgVer    /* [out] host configuration version */
369);
370
371BERR_Code BHAB_3461_ReadRegister(
372    BHAB_Handle handle,  /* [in] BHAB handle */
373    uint32_t    reg,     /* [in] address of register to read */
374    uint32_t    *val     /* [in] contains data that was read */
375);
376
377BERR_Code BHAB_3461_WriteRegister(
378    BHAB_Handle handle,  /* [in] BHAB handle */
379    uint32_t    reg,     /* [in] address of register to read */
380    uint32_t    *val     /* [in] contains data that was read */
381);
382
383BERR_Code BHAB_3461_ReadMemory(
384    BHAB_Handle h,  /* [in] BHAB PI Handle */
385    uint32_t addr,  /* [in] starting address */
386    uint8_t *buf,   /* [out] holds the data read */
387    uint32_t n      /* [in] number of bytes to read */
388);
389
390BERR_Code BHAB_3461_WriteMemory(
391    BHAB_Handle handle, /* [in] BHAB PI Handle */ 
392    uint32_t addr, /* [in] starting address in AP RAM */
393    const uint8_t *buf,  /* [in] specifies the data to write */
394    uint32_t n     /* [in] number of bytes to write */
395);
396
397BERR_Code BHAB_3461_ReadMbox(
398    BHAB_Handle handle,    /* [in] BHAB PI Handle */
399    uint32_t    reg,  /* [in] RBUS register address */
400    uint32_t    *val  /* [out] value read from register */
401);
402
403BERR_Code BHAB_3461_WriteMbox(
404    BHAB_Handle handle,    /* [in] BHAB PI Handle */
405    uint32_t    reg,  /* [in] RBUS register address */
406    uint32_t    *val  /* [in] value to write */
407);
408
409BERR_Code BHAB_3461_HandleInterrupt_isr(
410    BHAB_Handle handle   /* [in] BHAB handle */
411);
412
413BERR_Code BHAB_3461_ProcessInterruptEvent(
414    BHAB_Handle handle  /* [in] HAB device handle */
415);
416
417BERR_Code BHAB_3461_EnableLockInterrupt(
418    BHAB_Handle handle, /* [in] BHAB Handle */
419    BHAB_DevId eDevId,    /* [in] Device ID */
420    bool bEnable   /* [in] true = enable lock interrupts, false = disables lock interrupts */
421);
422
423BERR_Code BHAB_3461_InstallInterruptCallback(
424    BHAB_Handle handle,                /* [in] BHAB handle */
425    BHAB_DevId eDevId,    /* [in] Device ID */
426    BHAB_IntCallbackFunc fCallBack,    /* [in] Callback function pointer */
427    void * pParm1,                     /* [in] Paramater1 for callback function*/
428    int parm2                          /* [in] Paramater2 for callback function*/
429); 
430
431BERR_Code BHAB_3461_UnInstallInterruptCallback(
432    BHAB_Handle handle,  /* [in] BHAB handle */
433    BHAB_DevId eDevId    /* [in] Device ID */
434);
435
436BERR_Code BHAB_3461_SendHabCommand(
437    BHAB_Handle h,      /* [in] BHAB PI Handle */
438    uint8_t *write_buf, /* [in] specifies the HAB command to send */
439    uint8_t write_len,  /* [in] number of bytes in the HAB command */ 
440    uint8_t *read_buf,  /* [out] holds the data read from the HAB */ 
441    uint8_t read_len,   /* [in] number of bytes to read from the HAB */
442    bool bCheckForAck,  /* [in] true = determine if the AP has serviced the command */
443    bool bInsertTermination, /* [in] true = insert termination byte 0x00 in write buffer at read_len position */
444    uint8_t command_len
445);
446
447BERR_Code BHAB_3461_GetInterruptEventHandle(
448    BHAB_Handle handle,            /* [in] BHAB handle */
449    BKNI_EventHandle *hEvent       /* [out] interrupt event handle */
450);
451
452BERR_Code BHAB_3461_GetWatchDogTimer(
453    BHAB_Handle handle,    /* [in] BHAB Handle */
454    BHAB_WatchDogTimerSettings *wdtSettings
455);
456
457BERR_Code BHAB_3461_SetWatchDogTimer(
458    BHAB_Handle handle,    /* [in] BHAB Handle */
459    const BHAB_WatchDogTimerSettings *wdtSettings
460);
461
462BERR_Code BHAB_3461_GetNmiConfig(
463    BHAB_Handle handle,    /* [in] BHAB Handle */
464    BHAB_NmiSettings *nmiSettings
465);
466
467BERR_Code BHAB_3461_SetNmiConfig(
468    BHAB_Handle handle,    /* [in] BHAB Handle */
469    const BHAB_NmiSettings *nmiSettings
470);
471
472BERR_Code BHAB_3461_GetConfigSettings(
473    BHAB_Handle handle,           /* [in] Device handle */
474    BHAB_ConfigSettings *settings     /* [out] HAB config settings. */
475);
476
477BERR_Code BHAB_3461_SetConfigSettings(
478    BHAB_Handle handle,           /* [in] Device handle */
479    const BHAB_ConfigSettings *settings     /* [in] HAB config settings. */
480);
481
482#endif
Note: See TracBrowser for help on using the repository browser.