source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/hab/3128/bhab_3128_priv.h

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

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