source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/hab/bhab.c @ 2

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

first commit

  • Property svn:executable set to *
File size: 16.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.c $
11 * $brcm_Revision: Hydra_Software_Devel/14 $
12 * $brcm_Date: 11/9/11 2:57p $
13 *
14 *
15 * Revision History:
16 *
17 * $brcm_Log: /magnum/basemodules/hab/bhab.c $
18 *
19 * Hydra_Software_Devel/14   11/9/11 2:57p atanugul
20 * SW3128-68: Add BHAB_ReadSlave() and BHAB_ReadSlave() API to 3128
21 *
22 * Hydra_Software_Devel/13   11/2/11 4:42p atanugul
23 * SW3461-3: Update BHAB_GetApVersion to include familyId, AP major
24 * version, minor version and remove script version and configuration
25 * version
26 *
27 * Hydra_Software_Devel/12   10/18/11 3:20p atanugul
28 * SW3461-67: change write_len, read_len and command_len in
29 * BHAB_SendHabCommand() from type uint8_t to uint16_t
30 *
31 * Hydra_Software_Devel/11   5/27/11 4:27p atanugul
32 * SW3461-3: Added BHAB_GetConfigSettings() and BHAB_SetConfigSettings()
33 *
34 * Hydra_Software_Devel/10   3/2/11 6:07p atanugul
35 * SW3128-2: Add Support for BCM3128
36 *
37 * Hydra_Software_Devel/9   2/1/11 5:40p VISHK
38 * SW7422-171: Nexus support for the 3128 (8 ADS core + tuner on daughter
39 * board) plug on 7422 board  Read and write memory modified to 32 bit
40 * addressing to support 3128 chipset as it has 32 bit memory addressing.
41 *
42 * Hydra_Software_Devel/8   10/11/10 5:23p jgarrett
43 * SW7125-630: Merge to main branch
44 *
45 * Hydra_Software_Devel/SW7125-630/1   10/1/10 5:47p jgarrett
46 * SW7125-630: Adding debug checks
47 *
48 * Hydra_Software_Devel/7   6/22/10 6:02p vishk
49 * SW7420-839: Add support to program AGC gain to 31xx TNR PI
50 *
51 * Hydra_Software_Devel/6   10/5/09 10:44a vishk
52 * SW7405-2851: 31xx: Add support to configure the Watchdog feature of
53 * 31xx.
54 *
55 * Hydra_Software_Devel/5   1/29/09 7:16p vishk
56 * PR 46431: ADS PI: Add support for BCM3117, BCM3114, and BCM3112.
57 * PR 46436: AOB PI: Add support for BCM3117 and BCM3114
58 *
59 * Hydra_Software_Devel/4   1/17/09 2:35p vishk
60 * PR 46431: ADS PI: Add support for BCM3117, BCM3114, and BCM3112.
61 * PR 46436: AOB PI: Add support for BCM3117 and BCM3114.
62 *
63 * Added comment.
64 *
65 * Hydra_Software_Devel/3   1/16/09 7:11p vishk
66 * PR 46431: ADS PI: Add support for BCM3117, BCM3114, and BCM3112.
67 * PR 46436: AOB PI: Add support for BCM3117 and BCM3114
68 *
69 * Hydra_Software_Devel/2   10/27/08 11:11a gmohile
70 * PR 47386 : Add temination byte for send hab command
71 *
72 * Hydra_Software_Devel/1   10/20/08 2:52p gmohile
73 * PR 47386 : Checkin initial version
74 *
75 ***************************************************************************/
76
77#include "bstd.h"
78#include "bi2c.h"
79#include "bhab.h"
80#include "bhab_priv.h"
81
82BDBG_MODULE(BHAB);
83
84/******************************************************************************
85 BHAB_Open()
86******************************************************************************/
87BERR_Code BHAB_Open(
88        BHAB_Handle *handle,     /* [out] BHAB handle */
89        void        *pReg,       /* [in] pointer ot i2c or spi handle */
90        const BHAB_Settings *pDefSettings /* [in] Default Settings */
91)
92{
93
94        BDBG_ASSERT(handle);
95        BDBG_ASSERT(pReg);
96        BDBG_ASSERT(pDefSettings);
97
98        return (pDefSettings->api.Open(handle, pReg, pDefSettings));   
99}
100
101
102/******************************************************************************
103 BHAB_Close()
104******************************************************************************/
105BERR_Code BHAB_Close(BHAB_Handle handle)
106{
107
108        BDBG_ASSERT(handle);
109        return (handle->settings.api.Close(handle));   
110}
111
112
113/******************************************************************************
114 BHAB_3520_P_InitAp()
115******************************************************************************/
116BERR_Code BHAB_InitAp(
117        BHAB_Handle handle,       /* [in] BHAB handle */
118        const uint8_t *pHexImage  /* [in] pointer to BCM3520 microcode image */
119)
120{
121        BDBG_ASSERT(handle);
122        return (handle->settings.api.InitAp(handle, pHexImage));       
123}
124
125
126/******************************************************************************
127 BHAB_GetApStatus()
128******************************************************************************/
129BERR_Code BHAB_GetApStatus(
130        BHAB_Handle handle,      /* [in] HAB device handle */
131        BHAB_ApStatus *pStatus   /* [out] AP status */
132)
133{
134        BDBG_ASSERT(handle);
135        return (handle->settings.api.GetApStatus(handle, pStatus));     
136}
137
138
139/******************************************************************************
140 BHAB_GetApVersion()
141******************************************************************************/
142BERR_Code BHAB_GetApVersion(
143        BHAB_Handle handle,          /* [in] BHAB handle */
144    uint32_t    *pFamilyId, /* [out] Chip Family id */   
145    uint32_t    *pChipId,   /* [out] BHAB chip ID */
146        uint16_t    *pChipVer,  /* [out] chip revision number */
147    uint8_t     *pMajApVer, /* [out] AP microcode major version */
148    uint8_t     *pMinApVer  /* [out] AP microcode minor version */   
149)
150{
151        BDBG_ASSERT(handle);
152        return (handle->settings.api.GetApVersion(handle, pFamilyId, pChipId, pChipVer, pMajApVer, pMinApVer)); 
153}
154
155
156/******************************************************************************
157 BHAB_ReadRegister()
158******************************************************************************/
159BERR_Code BHAB_ReadRegister(
160        BHAB_Handle handle,     /* [in] BHAB handle */
161        uint32_t    reg,   /* [in] address of register to read */
162        uint32_t    *val   /* [in] contains data that was read */
163)
164{
165        BDBG_ASSERT(handle);
166        return (handle->settings.api.ReadRegister(handle, reg, val));   
167}
168
169
170/******************************************************************************
171 BHAB_WriteRegister()
172******************************************************************************/
173BERR_Code BHAB_WriteRegister(
174        BHAB_Handle handle,     /* [in] BHAB handle */
175        uint32_t    reg,   /* [in] address of register to read */
176        uint32_t    *val   /* [in] contains data that was read */
177)
178{
179        BDBG_ASSERT(handle);
180        return (handle->settings.api.WriteRegister(handle, reg, val));   
181}
182
183
184/******************************************************************************
185 BHAB_ReadMemory()
186******************************************************************************/
187BERR_Code BHAB_ReadMemory(BHAB_Handle handle, uint32_t addr, uint8_t *buf, uint32_t n)
188{   
189        BDBG_ASSERT(handle);
190        return (handle->settings.api.ReadMemory(handle, addr, buf, n));         
191}
192
193
194/******************************************************************************
195 BHAB_WriteMemory()
196******************************************************************************/
197BERR_Code BHAB_WriteMemory(BHAB_Handle handle, uint32_t addr, uint8_t *buf, uint32_t n)
198{   
199        BDBG_ASSERT(handle);
200        return (handle->settings.api.WriteMemory(handle, addr, buf, n));   
201}
202
203
204/******************************************************************************
205 BHAB_ReadMbox()
206******************************************************************************/
207BERR_Code BHAB_ReadMbox(
208        BHAB_Handle handle,    /* [in] BHAB PI Handle */
209        uint32_t    reg,  /* [in] RBUS register address */
210        uint32_t    *val  /* [out] value read from register */
211)
212{   
213        BDBG_ASSERT(handle);
214        return (handle->settings.api.ReadMbox(handle, reg, val)); 
215}
216
217
218/******************************************************************************
219 BHAB_WriteMbox()
220******************************************************************************/
221BERR_Code BHAB_WriteMbox(
222        BHAB_Handle handle,    /* [in] BHAB PI Handle */
223        uint32_t    reg,  /* [in] RBUS register address */
224        uint32_t    *val  /* [in] value to write */
225)
226{       
227        BDBG_ASSERT(handle);
228        return (handle->settings.api.WriteMbox(handle, reg, val)); 
229}
230
231
232/******************************************************************************
233 BHAB_HandleInterrupt_isr()
234******************************************************************************/
235BERR_Code BHAB_HandleInterrupt_isr(
236        BHAB_Handle handle /* [in] BHAB handle */
237)
238{
239        BDBG_ASSERT(handle);
240    BKNI_ASSERT_ISR_CONTEXT();
241        return (handle->settings.api.HandleInterrupt_isr(handle)); 
242}
243
244
245/******************************************************************************
246 BHAB_ProcessInterruptEvent()
247******************************************************************************/
248BERR_Code BHAB_ProcessInterruptEvent(
249        BHAB_Handle handle  /* [in] BHAB handle */
250)
251{
252        BDBG_ASSERT(handle);
253        return (handle->settings.api.ProcessInterruptEvent(handle)); 
254}
255
256
257/******************************************************************************
258 BHAB_EnableLockInterrupt()
259******************************************************************************/ 
260BERR_Code BHAB_EnableLockInterrupt(
261        BHAB_Handle handle,  /* [in] BHAB handle */
262        BHAB_DevId eDevId,    /* [in] Device ID */
263        bool bEnable   /* [in] true = enable Lock  interrupt */
264)
265{
266        BDBG_ASSERT(handle);
267        return (handle->settings.api.EnableLockInterrupt(handle, eDevId, bEnable)); 
268}
269       
270
271/******************************************************************************
272 BHAB_InstallInterruptCallback()
273******************************************************************************/ 
274BERR_Code BHAB_InstallInterruptCallback(
275        BHAB_Handle handle,  /* [in] BHAB handle */
276        BHAB_DevId eDevId,    /* [in] Device ID */
277        BHAB_IntCallbackFunc fCallBack,
278        void * pParm1, 
279        int parm2
280)
281{
282        BDBG_ASSERT(handle);
283        return (handle->settings.api.InstallInterruptCallback(handle, eDevId, fCallBack, pParm1, parm2)); 
284}
285
286/******************************************************************************
287 BHAB_UnInstallInterruptCallback()
288******************************************************************************/ 
289BERR_Code BHAB_UnInstallInterruptCallback(
290        BHAB_Handle handle,  /* [in] BHAB handle */
291        BHAB_DevId eDevId    /* [in] Device ID */
292)
293{
294        BDBG_ASSERT(handle);
295        return (handle->settings.api.UnInstallInterruptCallback(handle, eDevId)); 
296}       
297       
298
299/******************************************************************************
300 BHAB_SendHabCommand()
301******************************************************************************/
302BERR_Code BHAB_SendHabCommand(
303        BHAB_Handle handle, /* [in] BHAB PI Handle */
304        uint8_t *write_buf, /* [in] specifies the HAB command to send */
305        uint16_t write_len,  /* [in] number of bytes of the HAB command to be written using either I2c or SPI. */ 
306        uint8_t *read_buf,  /* [out] holds the data read from the HAB */ 
307        uint16_t read_len,   /* [in] number of bytes to read from the HAB */
308        bool bCheckForAck,  /* [in] true = determine if the AP has serviced the command */
309        bool bInsertTermination, /* [in] true = insert termination byte 0x00 in write buffer at read_len position */
310        uint16_t command_len /* [in] Total number of bytes in the HAB command so that the termination byte is inserted at the right HAB location. */
311)
312{
313        BDBG_ASSERT(handle);
314        return (handle->settings.api.SendHabCommand(handle, write_buf, write_len, read_buf, read_len, bCheckForAck, bInsertTermination, command_len)); 
315}
316/******************************************************************************
317 BHAB_GetInterruptEventHandle()
318******************************************************************************/
319BERR_Code BHAB_GetInterruptEventHandle(
320        BHAB_Handle handle,     /* [out] BHAB handle */
321        BKNI_EventHandle *event
322)
323{
324
325        BDBG_ASSERT(handle);
326
327        return (handle->settings.api.GetInterruptEventHandle(handle, event));           
328}
329
330/******************************************************************************
331Summary:
332   Gets the watch dog timer configuration.
333   
334Description:
335
336Returns:
337   BERR_Code
338******************************************************************************/
339BERR_Code BHAB_GetWatchDogTimer(BHAB_Handle handle,      /* [in] BHAB PI Handle */ 
340        BHAB_WatchDogTimerSettings *wdtSettings)
341{
342        BDBG_ASSERT(handle);
343       
344        return (handle->settings.api.GetWatchDogTimer(handle, wdtSettings));
345}
346
347/******************************************************************************
348Summary:
349   Sets the watch dog timer configuration.
350   
351Description:
352   
353Returns:
354   BERR_Code
355******************************************************************************/
356BERR_Code BHAB_SetWatchDogTimer(BHAB_Handle handle,      /* [in] BHAB PI Handle */
357        const BHAB_WatchDogTimerSettings *wdtSettings)
358{
359        BDBG_ASSERT(handle);
360       
361        return (handle->settings.api.SetWatchDogTimer(handle, wdtSettings));
362}
363
364
365/******************************************************************************
366Summary:
367   Gets the 31xx non maskable interrupt configuration.
368
369Description:
370   
371Returns:
372   BERR_Code
373******************************************************************************/
374BERR_Code BHAB_GetNmiConfig(BHAB_Handle handle,      /* [in] BHAB PI Handle */
375        BHAB_NmiSettings *nmiSettings)
376{
377        BDBG_ASSERT(handle);
378       
379        return (handle->settings.api.GetNmiConfig(handle, nmiSettings));
380}
381
382/******************************************************************************
383Summary:
384   Sets the 31xx non maskable interrupt configuration.
385
386Description:
387
388Returns:
389   BERR_Code
390******************************************************************************/
391BERR_Code BHAB_SetNmiConfig(BHAB_Handle handle,      /* [in] BHAB PI Handle */
392        const BHAB_NmiSettings *nmiSettings)
393{
394        BDBG_ASSERT(handle);
395       
396        return (handle->settings.api.SetNmiConfig(handle, nmiSettings));
397}
398
399/***************************************************************************
400Summary:
401    This function gets HAB settings.
402
403Description:
404    This function returns the current HAB Settings.
405   
406Returns:
407    BERR_Code
408
409****************************************************************************/
410BERR_Code BHAB_GetConfigSettings(
411    BHAB_Handle handle,           /* [in] Device handle */
412    BHAB_ConfigSettings *settings)     /* [out] HAB config settings. */
413{
414        BDBG_ASSERT(handle);
415       
416        return (handle->settings.api.GetConfigSettings(handle, settings));
417}
418   
419/***************************************************************************
420Summary:
421    This function sets HAB settings.
422
423Description:
424    This function sets the current HAB Settings.
425   
426Returns:
427    BERR_Code
428
429****************************************************************************/
430BERR_Code BHAB_SetConfigSettings(
431    BHAB_Handle handle,           /* [in] Device handle */
432    const BHAB_ConfigSettings *settings)     /* [in] HAB config settings. */
433{
434        BDBG_ASSERT(handle);
435       
436        return (handle->settings.api.SetConfigSettings(handle, settings));
437}
438       
439/******************************************************************************
440Summary:
441   This function allows the reading from a slave device attached to the demod chip.
442Description:
443 
444Returns:
445   BERR_Code
446******************************************************************************/
447BERR_Code BHAB_ReadSlave(
448    BHAB_Handle handle,     /* [in] Device channel handle */
449        uint8_t chipAddr,       /* [in] chip addr of the i2c slave device */
450        uint32_t subAddr,       /* [in] sub addr of the register to read from the slave device */
451        uint32_t *data,         /* [out] ptr to the data that we will read from the slave device */
452        uint8_t dataLen)        /* [in] how many bytes are we going to read? one to four, For 3412 LNA, this should be in multiples of 4-bytes*/
453{
454        BDBG_ASSERT(handle);
455       
456        return (handle->settings.api.ReadSlave(handle, chipAddr, subAddr, data, dataLen));
457}
458
459/******************************************************************************
460Summary:
461   This function allows the writing to a slave device attached to the demod chip.
462Description:
463 
464Returns:
465   BERR_Code
466******************************************************************************/
467BERR_Code BHAB_WriteSlave(
468    BHAB_Handle handle,     /* [in] Device channel handle */
469        uint8_t chipAddr,       /* [in] chip addr of the i2c slave device */
470        uint32_t subAddr,       /* [in] sub addr of the register to read from the slave device */
471        uint32_t *data,         /* [out] ptr to the data that we will read from the slave device */
472        uint8_t dataLen)        /* [in] how many bytes are we going to read? one to four, For 3412 LNA, this should be in multiples of 4-bytes*/
473{
474        BDBG_ASSERT(handle);
475       
476        return (handle->settings.api.WriteSlave(handle, chipAddr, subAddr, data, dataLen));
477}
478
Note: See TracBrowser for help on using the repository browser.