source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/hab/3520/bhab_3520_priv.c

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

first commit

  • Property svn:executable set to *
File size: 34.3 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2008, 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_3520_priv.c $
11 * $brcm_Revision: Hydra_Software_Devel/2 $
12 * $brcm_Date: 10/27/08 11:11a $
13 *
14 *
15 * Revision History:
16 *
17 * $brcm_Log: /magnum/basemodules/hab/3520/bhab_3520_priv.c $
18 *
19 * Hydra_Software_Devel/2   10/27/08 11:11a gmohile
20 * PR 47386 : Add temination byte for send hab command
21 *
22 * Hydra_Software_Devel/1   10/20/08 2:51p gmohile
23 * PR 47386 : Checkin initial version
24 *
25 ***************************************************************************/
26
27#include "bhab_3520_priv.h"
28
29BDBG_MODULE(BHAB);
30
31/******************************************************************************
32 BHAB_3520_Open()
33******************************************************************************/
34BERR_Code BHAB_3520_Open(
35        BHAB_Handle *handle,     /* [out] BHAB handle */
36        void        *pReg,       /* [in] pointer ot i2c or spi handle */
37        const BHAB_Settings *pDefSettings /* [in] Default Settings */
38)
39{
40        BERR_Code retCode;
41        BHAB_Handle hDev;
42        BHAB_3520_P_Handle *h3520Dev;
43        unsigned i;
44
45        BDBG_ASSERT(pDefSettings->interruptEnableFunc);
46
47        hDev = (BHAB_Handle)BKNI_Malloc(sizeof(BHAB_P_Handle));
48        BDBG_ASSERT(hDev);
49        h3520Dev = (BHAB_3520_P_Handle *)BKNI_Malloc(sizeof(BHAB_3520_P_Handle));
50        BDBG_ASSERT(h3520Dev);
51        hDev->pImpl = (void*)h3520Dev;
52       
53        h3520Dev->hRegister = (BREG_I2C_Handle)pReg;
54        BKNI_Memcpy((void*)(&(hDev->settings)), (void*)pDefSettings, sizeof(BHAB_Settings));
55
56        /* create events */
57        BHAB_CHK_RETCODE(BKNI_CreateEvent(&(h3520Dev->hInterruptEvent)));
58        BHAB_CHK_RETCODE(BKNI_CreateEvent(&(h3520Dev->hApiEvent)));
59        BHAB_CHK_RETCODE(BKNI_CreateEvent(&(h3520Dev->hLockChangeEvent)));
60        BHAB_CHK_RETCODE(BKNI_CreateEvent(&(h3520Dev->hInitDoneEvent)));
61        BHAB_CHK_RETCODE(BKNI_CreateEvent(&(h3520Dev->hHabDoneEvent)));
62        BHAB_CHK_RETCODE(BKNI_CreateMutex(&(h3520Dev->hMutex)));
63
64        h3520Dev->last_page_16_15 = 0xFF;
65        h3520Dev->last_page_14_7 = 0xFF;
66        h3520Dev->last_mbox_15_8 = 0xFF;       
67
68        for(i=0; i<BHAB_DevId_eMax; i++){
69                h3520Dev->InterruptCallbackInfo[i].func = NULL;
70                h3520Dev->InterruptCallbackInfo[i].pParm1 = NULL;
71                h3520Dev->InterruptCallbackInfo[i].parm2 = (int)NULL;
72        }
73
74        retCode = BHAB_3520_P_DisableInterrupts(hDev);
75        *handle = hDev;
76
77 done:
78        return retCode;
79}
80
81
82/******************************************************************************
83 BHAB_3520_Close()
84******************************************************************************/
85BERR_Code BHAB_3520_Close(BHAB_Handle handle)
86{
87        BERR_Code retCode;
88        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
89
90        BDBG_ASSERT(handle);
91   
92        retCode = BHAB_3520_P_DisableInterrupts(handle);
93        BKNI_DestroyEvent(p3520->hInterruptEvent);
94        BKNI_DestroyEvent(p3520->hApiEvent);
95        BKNI_DestroyEvent(p3520->hLockChangeEvent);
96        BKNI_DestroyEvent(p3520->hInitDoneEvent);
97        BKNI_DestroyEvent(p3520->hHabDoneEvent);
98        BKNI_DestroyMutex(p3520->hMutex);
99
100        BKNI_Free((void*)3520);
101        BKNI_Free((void*)handle);
102
103        return retCode;
104}
105
106
107/******************************************************************************
108 BHAB_3520_P_InitAp()
109******************************************************************************/
110BERR_Code BHAB_3520_InitAp(
111        BHAB_Handle handle,       /* [in] BHAB handle */
112        const uint8_t *pHexImage  /* [in] pointer to BCM3520 microcode image */
113)
114{
115        BERR_Code retCode;
116        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
117        uint16_t n, addr;
118        const uint8_t *pImage;
119        uint8_t sb, retries;
120
121        /* disable interrupts */       
122        BHAB_CHK_RETCODE(BHAB_3520_P_DisableInterrupts(handle));
123        BHAB_CHK_RETCODE(BHAB_3520_P_EnableHostInterrupt(handle, false));
124
125        /* reset the AP before downloading the microcode */
126        BHAB_CHK_RETCODE(BHAB_3520_P_ResetAp(handle));
127
128        /* download to RAM */
129        pImage = pHexImage;
130        while (1)
131        {
132                n = (*pImage++ << 8);
133                n |= *pImage++;
134               
135                if (n == 0)
136                        break;
137               
138                addr = (*pImage++ << 8);
139                addr |= *pImage++;
140               
141                for (retries = 0; retries < 3; retries++)
142                {
143                        BHAB_CHK_RETCODE(BHAB_3520_WriteMemory(handle, addr, (uint8_t *)pImage, n));
144                        pImage += n;
145                       
146                        /* check for host transfer error */
147                        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT1), &sb, 1));                       
148                        if ((sb & DEVICE(STAT1_H_ER)) == 0)
149                                break;
150                       
151                        BDBG_WRN(("host transfer error\n"));
152                        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT1), &sb, 1));                       
153                }
154        }
155       
156        /* enable init done interrupt */
157        BHAB_CHK_RETCODE(BHAB_3520_P_EnableInitDoneInterrupt(handle));
158       
159        /* clear H_STAT1 */
160        sb = 0xFF;
161        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT1), &sb, 1));       
162       
163        /* start running the AP */
164        if ((retCode = BHAB_3520_P_RunAp(handle)) != BERR_SUCCESS)
165                goto done;
166       
167        /* wait for init done interrupt */
168        if (BHAB_3520_P_WaitForEvent(handle, p3520->hInitDoneEvent, 10) != BERR_SUCCESS)
169        {
170                BDBG_ERR(("AP initialization timeout\n")); 
171                BERR_TRACE(retCode = BHAB_ERR_AP_NOT_INIT);           
172        }
173       
174
175
176 done:
177        return retCode;
178}
179
180
181/******************************************************************************
182 BHAB_3520_GetApStatus()
183******************************************************************************/
184BERR_Code BHAB_3520_GetApStatus(
185   BHAB_Handle handle,      /* [in] HAB device handle */
186   BHAB_ApStatus *pStatus   /* [out] AP status */
187)
188{
189        BERR_Code retCode;
190        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
191        uint8_t buf[3];
192
193        *pStatus = 0;
194        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), buf, 3));
195        *pStatus = buf[0] | (buf[1] << 8) | (buf[2] << 16);
196   
197 done:
198        return retCode;
199}
200
201
202/******************************************************************************
203 BHAB_3520_GetApVersion()
204******************************************************************************/
205BERR_Code BHAB_3520_GetApVersion(
206        BHAB_Handle handle,          /* [in] BHAB handle */
207        uint16_t    *pChipId,   /* [out] BHAB chip ID */
208        uint16_t    *pChipVer,  /* [out] chip revision number */
209        uint8_t     *pApVer,    /* [out] AP microcode version */
210        uint8_t     *pScrVer,   /* [out] acquisition script version */
211        uint8_t     *pCfgVer    /* [out] host configuration version */
212)
213{
214        BERR_Code retCode;
215        uint8_t buf[16];
216
217        buf[0] = 0x09;
218        buf[14] = 0x00;
219        BHAB_CHK_RETCODE(BHAB_3520_SendHabCommand(handle, buf, 15, buf, 14, true, false));
220
221        *pChipId = ((buf[1] << 8) | buf[2]);
222        *pChipVer = ((buf[3] << 8) | buf[4]);
223        *pApVer = buf[5];
224        *pScrVer = buf[6];
225        *pCfgVer = buf[7];
226
227 done:
228        return retCode;
229}
230
231
232/******************************************************************************
233 BHAB_3520_ReadRegister()
234******************************************************************************/
235BERR_Code BHAB_3520_ReadRegister(
236        BHAB_Handle handle,     /* [in] BHAB handle */
237        uint32_t    reg,   /* [in] address of register to read */
238        uint32_t    *val   /* [in] contains data that was read */
239)
240{
241        BERR_Code retCode;
242        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
243        uint8_t sb;
244
245        if ((reg >= 0x80) && (reg <= 0xFF))
246        {
247                /* accessing host register space */
248                BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, reg, &sb, 1));     
249                *val = (uint32_t)sb;
250        }
251        else
252        {
253                /* accessing internal registers through io_mbox */
254                BHAB_CHK_RETCODE(BHAB_3520_ReadMbox(handle, (uint16_t)reg, val));
255        }
256
257 done:
258        return retCode;
259}
260
261
262/******************************************************************************
263 BHAB_3520_WriteRegister()
264******************************************************************************/
265BERR_Code BHAB_3520_WriteRegister(
266        BHAB_Handle handle,     /* [in] BHAB handle */
267        uint32_t    reg,   /* [in] address of register to read */
268        uint32_t    *val   /* [in] contains data that was read */
269)
270{
271        BERR_Code retCode;
272        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
273        uint8_t sb;
274
275        if ((reg >= 0x80) && (reg <= 0xFF))
276        {
277                /* accessing host register space */
278                sb = (uint8_t)(*val);
279                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, reg, &sb, 1));     
280        }
281        else
282        {
283                /* accessing internal registers through io_mbox */
284                BHAB_CHK_RETCODE(BHAB_3520_WriteMbox(handle, (uint16_t)reg, val));
285        }
286
287 done:
288        return retCode;
289}
290
291
292/******************************************************************************
293 BHAB_3520_ReadMemory()
294******************************************************************************/
295BERR_Code BHAB_3520_ReadMemory(BHAB_Handle handle, uint16_t addr, uint8_t *buf, uint16_t n)
296{   
297        BERR_Code retCode;
298        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
299
300        if (((uint32_t)addr + (uint32_t)n) > BHAB_MEM_SIZE)
301                return BERR_TRACE(BERR_INVALID_PARAMETER);
302
303        BHAB_CHK_RETCODE(BHAB_3520_P_SetApWindow(handle, BHAB_WINDOW_IRAM + addr));
304        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, addr & 0x7F, buf, n));   
305
306 done:
307        return retCode;
308}
309
310
311/******************************************************************************
312 BHAB_3520_WriteMemory()
313******************************************************************************/
314BERR_Code BHAB_3520_WriteMemory(BHAB_Handle handle, uint16_t addr, uint8_t *buf, uint16_t n)
315{   
316        BERR_Code retCode = BERR_SUCCESS;
317        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
318        uint16_t  curr_addr, nbytes, bytes_left;
319
320        if ((addr >= BHAB_IRAM_SIZE) || (n >= BHAB_IRAM_SIZE))
321                return BERR_TRACE(BERR_INVALID_PARAMETER);
322        if ((addr + n) > BHAB_IRAM_SIZE)
323                return BERR_TRACE(BERR_INVALID_PARAMETER);
324
325        curr_addr = addr;
326        bytes_left = n;
327        while (bytes_left > 0)
328        {
329                BHAB_CHK_RETCODE(BHAB_3520_P_SetApWindow(handle, BHAB_WINDOW_IRAM + curr_addr));
330                nbytes = 128 - (curr_addr % 128);
331                if (nbytes > bytes_left)
332                        nbytes = bytes_left;
333                bytes_left -= nbytes;
334                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, curr_addr & 0x7F, buf, nbytes));
335                curr_addr += nbytes;
336                buf += nbytes;
337        }
338
339 done:
340        return retCode;
341}
342
343
344/******************************************************************************
345 BHAB_3520_ReadMbox()
346******************************************************************************/
347BERR_Code BHAB_3520_ReadMbox(
348        BHAB_Handle handle,    /* [in] BHAB PI Handle */
349        uint16_t    reg,  /* [in] RBUS register address */
350        uint32_t    *val  /* [out] value read from register */
351)
352{   
353        BERR_Code retCode;
354        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
355        uint8_t sb, i, buf[4];
356
357        /* update bits 15:8 of mbox address if changed */
358        sb = reg >> 8;
359        if (sb != p3520->last_mbox_15_8)
360        {
361                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_IO_MBOX_A_15_8), &sb, 1));   
362                p3520->last_mbox_15_8 = sb;
363        }
364
365        /* read from mbox */
366        sb = reg & 0xFC;
367        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_IO_MBOX_CMD), &sb, 1));
368
369        /* check for mbox transfer complete */
370        for (i = 0; i < 3; i++)
371        {
372                BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_IO_MBOX_STATUS), &sb, 1));       
373                if ((sb & 0x80) == 0)
374                {
375                        if (sb & 0x40)
376                        {
377                                BERR_TRACE(retCode = BHAB_ERR_IOMB_XFER);
378                                goto done;
379                        }
380                        else
381                        {
382                                /* transfer completed - now get the data */
383                                BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_IO_MBOX_D_31_24), buf, 4));
384                                *val = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
385                        }
386                        break;
387                }
388        }
389
390        if (i >= 3)
391        {
392                /* this should not happen */
393                BERR_TRACE(retCode = BHAB_ERR_IOMB_BUSY);
394                BDBG_ERR(("IO_MBOX busy\n"));
395        }
396
397 done:
398        return retCode;
399}
400
401
402/******************************************************************************
403 BHAB_3520_WriteMbox()
404******************************************************************************/
405BERR_Code BHAB_3520_WriteMbox(
406        BHAB_Handle handle,    /* [in] BHAB PI Handle */
407        uint16_t    reg,  /* [in] RBUS register address */
408        uint32_t    *val  /* [in] value to write */
409)
410{       
411        BERR_Code retCode;
412        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
413        uint8_t buf[6], sb, i;
414
415        /* write addr, data, and cmd in one i2c transaction */
416        buf[0] = reg >> 8;
417        buf[1] = *val >> 24;
418        buf[2] = *val >> 16;
419        buf[3] = *val >> 8;
420        buf[4] = *val & 0xFF; 
421        buf[5] = (reg & 0xFC) | 0x01;
422        i = (buf[0] != p3520->last_mbox_15_8) ? 0 : 1;
423        p3520->last_mbox_15_8 = buf[0];
424        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, i ? DEVICE(SH_SFR_IO_MBOX_D_31_24) : DEVICE(SH_SFR_IO_MBOX_A_15_8), &buf[i], 6-i));
425
426        for (i = 0; i < 3; i++)
427        {
428                /* check for mbox transfer complete */
429                BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_IO_MBOX_STATUS), &sb, 1));
430               
431                if ((sb & 0x80) == 0)
432                {
433                        if (sb & 0x40)
434                        {
435                                BERR_TRACE(retCode = BHAB_ERR_IOMB_XFER);
436                        }
437                        goto done;
438                }
439        }
440
441        if (sb & 0x80)
442        {
443                /* this should not happen */
444                BERR_TRACE(retCode = BHAB_ERR_IOMB_BUSY);
445                BDBG_ERR(("IO_MBOX busy\n"));
446        }
447
448 done:
449        return retCode;
450}
451
452
453/******************************************************************************
454 BHAB_3520_HandleInterrupt_isr()
455******************************************************************************/
456BERR_Code BHAB_3520_HandleInterrupt_isr(
457        BHAB_Handle handle /* [in] BHAB handle */
458)
459{
460        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
461
462        BDBG_ASSERT(handle);
463   
464        handle->settings.interruptEnableFunc(false, handle->settings.interruptEnableFuncParam);
465        BKNI_SetEvent(p3520->hApiEvent);   
466        BKNI_SetEvent(p3520->hInterruptEvent); 
467
468        return BERR_SUCCESS;
469}
470
471
472/******************************************************************************
473 BHAB_3520_ProcessInterruptEvent()
474******************************************************************************/
475BERR_Code BHAB_3520_ProcessInterruptEvent(
476        BHAB_Handle handle  /* [in] BHAB handle */
477)
478{
479        BERR_Code retCode;
480   
481        BDBG_ASSERT(handle);
482        BHAB_CHK_RETCODE(BHAB_3520_P_DecodeInterrupt(handle));
483        BHAB_3520_P_EnableHostInterrupt(handle, true);
484   
485 done:
486        return retCode;
487}
488
489
490/******************************************************************************
491 BHAB_3520_EnableLockInterrupt()
492******************************************************************************/ 
493BERR_Code BHAB_3520_EnableLockInterrupt(
494        BHAB_Handle handle,  /* [in] BHAB handle */
495        BHAB_DevId eDevId,    /* [in] Device ID */
496        bool bEnable   /* [in] true = enable Lock  interrupt */
497)
498{
499        BERR_Code retCode;
500        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
501        uint8_t sb;
502
503        BSTD_UNUSED(eDevId);
504
505        BHAB_3520_P_EnableHostInterrupt(handle, false);
506        sb = bEnable ? DEVICE(STAT2_LOCK_MASK) : 0;
507        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT2), &sb, 1));                               
508        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE2), &sb, 1));                 
509        BHAB_3520_P_EnableHostInterrupt(handle, true);
510
511 done:
512        return retCode;   
513}
514       
515
516/******************************************************************************
517 BHAB_3520_InstallInterruptCallback()
518******************************************************************************/ 
519BERR_Code BHAB_3520_InstallInterruptCallback(
520        BHAB_Handle handle,  /* [in] BHAB handle */
521        BHAB_DevId eDevId,    /* [in] Device ID */
522        BHAB_InterruptType eInterruptType, /* [in] Id for Interrupt to install the callback*/
523        BHAB_IntCallbackFunc fCallBack,
524        void * pParm1, 
525        int parm2
526)
527{
528        BHAB_P_CallbackInfo *callback;
529        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
530
531        BDBG_ASSERT(handle);
532       
533        if (eInterruptType >= BHAB_Interrupt_eMax) {
534                return BERR_TRACE(BERR_INVALID_PARAMETER);
535        }
536        /*TODO : setup bitmask to enable/disable interrupt callabcks*/
537
538        if (eDevId >= BHAB_DevId_eMax) {
539                return BERR_TRACE(BERR_INVALID_PARAMETER);
540        }
541
542        callback = &p3520->InterruptCallbackInfo[eDevId];
543
544        callback->func = fCallBack;
545        callback->pParm1 = pParm1;
546        callback->parm2 = parm2;
547
548        return BERR_TRACE(BERR_SUCCESS);
549}
550
551
552/******************************************************************************
553 BHAB_3520_UnInstallInterruptCallback()
554******************************************************************************/ 
555BERR_Code BHAB_3520_UnInstallInterruptCallback(
556        BHAB_Handle handle,  /* [in] BHAB handle */
557        BHAB_DevId eDevId,    /* [in] Device ID */
558        BHAB_InterruptType eInterruptType /* [in] Id for Interrupt to install the callback*/
559)
560{
561        BHAB_P_CallbackInfo *callback;
562        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
563
564        BDBG_ASSERT(handle);
565       
566        if (eInterruptType >= BHAB_Interrupt_eMax) {
567                return BERR_TRACE(BERR_INVALID_PARAMETER);
568        }
569
570        if (eDevId >= BHAB_DevId_eMax) {
571                return BERR_TRACE(BERR_INVALID_PARAMETER);
572        }
573
574        callback = &p3520->InterruptCallbackInfo[eDevId];
575
576        callback->func = NULL;
577        callback->pParm1 = NULL;
578        callback->parm2 = (int)NULL;
579
580        return BERR_TRACE(BERR_SUCCESS);
581}       
582       
583
584/******************************************************************************
585 BHAB_3520_SendHabCommand()
586******************************************************************************/
587BERR_Code BHAB_3520_SendHabCommand(
588        BHAB_Handle handle, /* [in] BHAB PI Handle */
589        uint8_t *write_buf, /* [in] specifies the HAB command to send */
590        uint8_t write_len,  /* [in] number of bytes in the HAB command */ 
591        uint8_t *read_buf,  /* [out] holds the data read from the HAB */ 
592        uint8_t read_len,   /* [in] number of bytes to read from the HAB */
593        bool bCheckForAck,  /* [in] true = determine if the AP has serviced the command */
594        bool bInsertTermination /* [in] true = insert termination byte 0x00 in write buffer at read_len position */
595)
596{
597        BERR_Code retCode;
598
599        BHAB_P_ACQUIRE_MUTEX(handle);
600   
601        if ((write_len > 127) || (read_len > 127) || (write_len == 0))
602                return (BERR_TRACE(BERR_INVALID_PARAMETER));
603
604        BHAB_CHK_RETCODE(BHAB_3520_P_CheckHab(handle));
605 
606        /* write the command to the HAB */
607        BHAB_CHK_RETCODE(BHAB_3520_P_WriteHab(handle, 0, write_buf, write_len));
608
609        if(bInsertTermination){
610                BDBG_ASSERT(read_len<write_len);
611                write_buf[read_len] = 0x00;
612                BHAB_CHK_RETCODE(BHAB_3520_P_WriteHab(handle, read_len, &write_buf[read_len], 1));
613        }
614
615
616        /* wait for the AP to service the HAB, and then read any return data */
617        BHAB_CHK_RETCODE(BHAB_3520_P_ServiceHab(handle, read_buf, read_len, bCheckForAck, write_buf[0] | 0x80));
618 
619 done:
620        BHAB_P_RELEASE_MUTEX(handle);
621
622        return retCode;
623}
624
625
626/******************************************************************************
627 BHAB_3520_GetLockStateChangeEventHandle()
628******************************************************************************/
629BERR_Code BHAB_3520_GetLockStateChangeEventHandle(
630        BHAB_Handle handle,            /* [in] BHAB handle */
631        BKNI_EventHandle *hEvent       /* [out] lock event handle */
632)
633{
634        *hEvent = ((BHAB_3520_P_Handle *)(handle->pImpl))->hLockChangeEvent;
635        return BERR_SUCCESS;
636}
637
638
639/******************************************************************************
640 BHAB_3520_GetInterruptEventHandle()
641******************************************************************************/
642BERR_Code BHAB_3520_GetInterruptEventHandle(
643        BHAB_Handle handle,            /* [in] BHAB handle */
644        BKNI_EventHandle *hEvent       /* [out] interrupt event handle */
645)
646{
647        *hEvent = ((BHAB_3520_P_Handle *)(handle->pImpl))->hInterruptEvent;
648        return BERR_SUCCESS;
649}
650
651
652
653/****************************Private Functions*********************************/
654
655
656
657
658/******************************************************************************
659 BHAB_3520_P_EnableHostInterrupt()
660******************************************************************************/
661BERR_Code BHAB_3520_P_EnableHostInterrupt(
662        BHAB_Handle handle, /* [in] HAB handle */
663        bool bEnable        /* [in] true=enables the L1 interrupt on the host processor */
664)
665{
666        BKNI_EnterCriticalSection();
667        handle->settings.interruptEnableFunc(bEnable, handle->settings.interruptEnableFuncParam);
668        BKNI_LeaveCriticalSection();   
669
670        return BERR_SUCCESS;
671}
672
673
674/******************************************************************************
675 BHAB_3520_P_DisableInterrupts()
676******************************************************************************/ 
677BERR_Code BHAB_3520_P_DisableInterrupts(
678        BHAB_Handle handle   /* [in] BHAB Handle */
679)
680{   
681        BERR_Code err;
682        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
683        const uint8_t val[4] = {0, 0, 0, 0};
684   
685        /* clear IEx registers */
686        err = BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE1), val, 4);
687        return err;   
688}
689
690
691/******************************************************************************
692 BHAB_3520_P_EnableInitDoneInterrupt()
693******************************************************************************/ 
694BERR_Code BHAB_3520_P_EnableHabDoneInterrupt(
695        BHAB_Handle handle /* [in] BHAB PI Handle */
696)
697{ 
698        BERR_Code retCode;     
699        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
700        uint8_t sb;
701   
702        sb = DEVICE(STAT1_HAB_DONE);
703        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT1), &sb, 1));
704        sb = DEVICE(STAT1_HAB_DONE);
705        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE1), &sb, 1));
706   
707 done:
708        return retCode;
709}
710
711
712/******************************************************************************
713 BHAB_3520_P_EnableInitDoneInterrupt()
714******************************************************************************/ 
715BERR_Code BHAB_3520_P_EnableInitDoneInterrupt(
716        BHAB_Handle handle /* [in] BHAB PI Handle */
717)
718{ 
719        BERR_Code retCode;
720        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
721        uint8_t sb;
722   
723        sb = DEVICE(STAT2_INIT_DONE);
724        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT2), &sb, 1));       
725        sb = DEVICE(STAT2_INIT_DONE);
726        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE2), &sb, 1));
727   
728 done:
729        return retCode;
730}
731
732
733/******************************************************************************
734 BERR_3520_Code BHAB_P_WaitForEvent()
735******************************************************************************/
736BERR_Code BHAB_3520_P_WaitForEvent(
737        BHAB_Handle handle,             /* [in] BHAB PI Handle */
738        BKNI_EventHandle hEvent,   /* [in] event to wait on */
739        int timeoutMsec            /* [in] timeout in milliseconds */
740)
741{       
742        BERR_Code retCode = BERR_SUCCESS;
743        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
744
745        while (1)
746        {   
747                BHAB_3520_P_EnableHostInterrupt(handle, true);
748                if ((retCode = BKNI_WaitForEvent(p3520->hApiEvent, timeoutMsec)) == BERR_TIMEOUT)
749                        break;
750               
751                BHAB_3520_P_DecodeInterrupt(handle);
752                if ((retCode = BKNI_WaitForEvent(hEvent, 0)) == BERR_SUCCESS)
753                        break;
754        }
755
756        BHAB_3520_P_EnableHostInterrupt(handle, true);
757   
758        return retCode;
759
760}
761
762
763/******************************************************************************
764 BHAB_3520_P_RunAp()
765******************************************************************************/
766BERR_Code BHAB_3520_P_RunAp(BHAB_Handle handle)
767{
768        BERR_Code retCode;
769        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
770        uint8_t   sb, sb2;
771
772        /* check if the AP is currently running */
773        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), &sb, 1));
774
775        if ((sb & DEVICE(AP_MASK)) != DEVICE(AP_RUN))
776        {
777                /* start running the AP */
778                sb2 = DEVICE(AP_RUN);
779                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), &sb2, 1));               
780
781                /* verify that the AP is running */
782                BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), &sb, 1));         
783                if ((sb & DEVICE(AP_MASK)) != DEVICE(AP_RUN))
784                {
785                        BDBG_ERR(("unable to run the AP\n"));
786                        BERR_TRACE(retCode = BHAB_ERR_AP_FAIL);
787                        goto done;
788                }
789
790                /* clear AP_change state bit */
791                sb2 = DEVICE(STAT1_AP_OP_CHG);
792                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT1), &sb2, 1));     
793        }
794        else
795        {
796                BDBG_WRN(("BHAB_P_RunAp(): AP already running\n"));
797        }
798
799 done:
800        return retCode;
801}
802
803
804/******************************************************************************
805 BHAB_3520_P_ResetAp()
806******************************************************************************/
807BERR_Code BHAB_3520_P_ResetAp(BHAB_Handle handle)
808{   
809        BERR_Code retCode;
810        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
811        uint8_t i, sb, buf[4];
812
813        /* initialize JDEC */
814        sb = DEVICE(JDEC_RAM);
815        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_JDEC), &sb, 1));   
816
817        /* reset the AP */
818        sb = DEVICE(AP_RESET);
819        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), &sb, 1));
820
821        /* reset AP status */
822        sb = 0x0B;
823        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_AP_CMD), &sb, 1));
824
825        /* reset all interrupt status */
826        for (i = 0; i < 4; i++)
827                buf[i] = 0xFF;
828        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT1), buf, 4));
829
830        /* clear MSGx registers */
831        buf[0] = buf[1] = 0x00;
832        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_MSG1), buf, 2));
833
834        /* verify that AP is reset */
835        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), &sb, 1));   
836        if ((sb & DEVICE(AP_MASK)) != DEVICE(AP_RESET))
837        {
838                BDBG_ERR(("unable to reset the AP\n"));
839                BERR_TRACE(retCode = BHAB_ERR_AP_FAIL);
840        }
841
842 done:
843        p3520->last_page_16_15 = 0xFF;
844        p3520->last_page_14_7 = 0xFF;
845
846        return retCode;
847}
848
849
850/******************************************************************************
851 BHAB_3520_P_SetApWindow()
852******************************************************************************/
853BERR_Code BHAB_3520_P_SetApWindow(
854        BHAB_Handle handle,    /* [in] BHAB PI Handle */
855        uint32_t window   /* [in] base address of the 128-byte window */
856)
857{   
858        BERR_Code retCode = BERR_SUCCESS;
859        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
860        uint8_t   haddr_16_15 = (window >> 15) & 0x03;
861        uint8_t   haddr_14_7 = (window >> 7) & 0xFF;
862        uint8_t   buf[2];
863
864        if (p3520->last_page_16_15 != haddr_16_15)
865        {
866                buf[0] = haddr_16_15;
867                buf[1] = haddr_14_7;
868                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_H_ADR_16_15), buf, 2));
869                p3520->last_page_16_15 = haddr_16_15;
870                p3520->last_page_14_7 = haddr_14_7;
871        }
872        else if (p3520->last_page_14_7 != haddr_14_7)
873        {
874                BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_SFR_H_ADR_14_7), &haddr_14_7, 1));     
875                p3520->last_page_14_7 = haddr_14_7;
876        }
877
878 done:
879        return retCode;
880}
881
882
883/******************************************************************************
884 BHAB_3520_P_ReadHab()
885******************************************************************************/
886BERR_Code BHAB_3520_P_ReadHab(BHAB_Handle handle, uint8_t addr, uint8_t *buf, uint8_t n)
887{
888   
889        BERR_Code retCode;
890        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
891
892        if ((addr & BHAB_HAB_SIZE) || (n & BHAB_HAB_SIZE))
893                return BERR_TRACE(BERR_INVALID_PARAMETER);
894
895        if ((addr + n) > BHAB_HAB_SIZE)
896                return BERR_TRACE(BERR_INVALID_PARAMETER);
897
898        BHAB_CHK_RETCODE(BHAB_3520_P_SetApWindow(handle, BHAB_WINDOW_HAB));
899        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, addr, buf, n));
900
901 done:
902        return retCode;
903}
904
905
906/******************************************************************************
907 BHAB_3520_P_WriteHab()
908******************************************************************************/
909BERR_Code BHAB_3520_P_WriteHab(BHAB_Handle handle, uint8_t addr, uint8_t *buf, uint8_t n)
910{
911        BERR_Code retCode;
912        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
913
914        if ((addr & BHAB_HAB_SIZE) || (n & BHAB_HAB_SIZE))
915                return BERR_TRACE(BERR_INVALID_PARAMETER);
916
917        if ((addr + n) > BHAB_HAB_SIZE)
918                return BERR_TRACE(BERR_INVALID_PARAMETER);
919
920        BHAB_CHK_RETCODE(BHAB_3520_P_SetApWindow(handle, BHAB_WINDOW_HAB));
921        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, addr, buf, n));
922
923 done:
924        return retCode;
925}
926
927
928/******************************************************************************
929 BHAB_3520_P_ServiceHab()
930******************************************************************************/
931BERR_Code BHAB_3520_P_ServiceHab(
932        BHAB_Handle handle,   /* [in] BHAB PI Handle */
933        uint8_t *read_buf,  /* [out] holds the data read from the HAB */ 
934        uint8_t read_len,   /* [in] number of bytes to read from the HAB */
935        bool bCheckForAck,  /* [in] true = determine if the AP has serviced the command */
936        uint8_t ack_byte    /* [in] value of the ack byte to expect */
937)
938{   
939        BERR_Code retCode;
940        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
941        uint8_t   sb, ie2, buf[2];
942       
943        BHAB_3520_P_EnableHostInterrupt(handle, false);
944   
945        /* save ie2 */
946        if((retCode = BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE2), &ie2, 1)) != BERR_SUCCESS )
947                return retCode;
948   
949        /* clear ie2 */
950        buf[0] = buf[1] = 0;
951        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE1), buf, 2));
952
953        BKNI_WaitForEvent(p3520->hHabDoneEvent, 0);     
954
955   
956        /* send the command */
957        sb = DEVICE(AP_HABR);
958        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_CTL1), &sb, 1));
959           
960
961        /* enable the hab done interrupt mask */       
962        BHAB_CHK_RETCODE(BHAB_3520_P_EnableHabDoneInterrupt(handle));
963       
964        /* wait for HAB done interrupt */ 
965        if (BHAB_3520_P_WaitForEvent(handle, p3520->hHabDoneEvent, 100) == BERR_TIMEOUT)
966        {
967                BDBG_ERR(("HAB timeout\n"));   
968                sb = 0;
969                BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE1), &sb, 1);   
970                BERR_TRACE(retCode = BHAB_ERR_HAB_TIMEOUT);
971                goto done;
972        }
973
974
975        if (read_len > 0)
976        {
977                BHAB_CHK_RETCODE(BHAB_3520_P_ReadHab(handle, 0, read_buf, read_len));
978                if (bCheckForAck)
979                {
980                        if (ack_byte != read_buf[0])
981                        {
982                                BDBG_ERR(("HAB command not serviced!\n"));
983                                BERR_TRACE(retCode = BHAB_ERR_HAB_NO_ACK);
984                        }
985                }
986        }
987       
988 done:
989        BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE2), &ie2, 1);
990
991        return retCode;
992}
993
994
995/******************************************************************************
996 BHAB_3520_P_DecodeInterrupt()
997******************************************************************************/
998BERR_Code BHAB_3520_P_DecodeInterrupt(BHAB_Handle handle)
999{ 
1000        BERR_Code retCode;
1001        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
1002        uint8_t   h_ie[2], h_fstat[2], new_stat2;
1003       
1004        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_FSTAT1), h_fstat, 2));
1005        BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE1), h_ie, 2));
1006       
1007        new_stat2 = 0;
1008       
1009        if (!h_fstat[0] && !h_fstat[1])
1010        {
1011                return BERR_SUCCESS;
1012        }
1013   
1014        /*HAB DONE INTERRUPT*/
1015        if (h_fstat[0] & DEVICE(STAT1_HAB_DONE))
1016        {
1017                h_ie[0] = 0;
1018                BKNI_SetEvent(p3520->hHabDoneEvent);                           
1019        }
1020   
1021        /*INIT DONE INTERRUPT*/
1022        if (h_fstat[1] & DEVICE(STAT2_INIT_DONE))
1023        {
1024                h_ie[1] &= ~DEVICE(STAT2_INIT_DONE);           
1025                BKNI_SetEvent(p3520->hInitDoneEvent);
1026        }
1027     
1028        /*LOCK INTERRUPT*/
1029        if (h_fstat[1] & DEVICE(STAT2_LOCK_MASK))
1030        {
1031                new_stat2 |= DEVICE(STAT2_LOCK_MASK);
1032                h_ie[1] &= ~DEVICE(STAT2_LOCK_MASK);
1033                if(p3520->InterruptCallbackInfo[BHAB_DevId_eVSB0].func){
1034                        p3520->InterruptCallbackInfo[BHAB_DevId_eVSB0].func(
1035                                p3520->InterruptCallbackInfo[BHAB_DevId_eVSB0].pParm1,
1036                                p3520->InterruptCallbackInfo[BHAB_DevId_eVSB0].parm2);
1037                }
1038                BKNI_SetEvent(p3520->hLockChangeEvent);
1039                if (h_fstat[1] & DEVICE(STAT2_IN_LOCK))
1040                {
1041                        BDBG_MSG(("locked"));
1042                        h_ie[1] |= DEVICE(STAT2_OUT_OF_LOCK);
1043                }
1044                else
1045                {
1046                        h_ie[1] |= DEVICE(STAT2_IN_LOCK); 
1047                        BDBG_MSG(("not locked"));                       
1048                }
1049        }
1050         
1051        /* clear the interrupt status */
1052        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_IE1), h_ie, 2));   
1053        BHAB_CHK_RETCODE(BREG_I2C_Write(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_STAT2), &new_stat2, 1));
1054   
1055 done:
1056        return retCode;
1057}
1058
1059
1060/******************************************************************************
1061 BHAB_3520_P_DecodeError()
1062******************************************************************************/
1063BERR_Code BHAB_3520_P_DecodeError(
1064        BHAB_Handle handle,           /* [in] BHAB PI Handle */
1065        BHAB_ApStatus *pApStatus /* [in] AP status returned by BHAB_GetApStatus */
1066)
1067{
1068        BERR_Code retCode = BERR_SUCCESS;
1069        BHAB_3520_P_Handle *p3520 = (BHAB_3520_P_Handle *)(handle->pImpl);
1070        uint8_t sb;
1071
1072        if (*pApStatus & BHAB_APSTATUS_HAB_ERR)
1073                retCode = BHAB_ERR_HABAV;
1074        else if (*pApStatus & BHAB_APSTATUS_MEM_ERR)
1075                retCode = BHAB_ERR_MEMAV;
1076        else if (*pApStatus & BHAB_APSTATUS_H_ERR)
1077                retCode = BHAB_ERR_HOST_XFER;
1078        else if (*pApStatus & BHAB_APSTATUS_IOMB_ERR)
1079                retCode = BHAB_ERR_IOMB_XFER;
1080        else if (*pApStatus & BHAB_APSTATUS_HABCMD_ERR)
1081                retCode = BHAB_ERR_HAB_ERR;
1082        else if (*pApStatus & BHAB_APSTATUS_AP_ERR)
1083        {
1084                BHAB_CHK_RETCODE(BREG_I2C_Read(p3520->hRegister, handle->settings.chipAddr, DEVICE(SH_AP_SFR_H_MSG1), &sb, 1));         
1085                switch (sb)
1086                {
1087                case 1:
1088                  retCode = BHAB_ERR_AP_BSC;
1089                  break;
1090
1091                case 2:
1092                  retCode = BHAB_ERR_AP_STACK;
1093                  break;
1094
1095                case 3:
1096                  retCode = BHAB_ERR_AP_WD;
1097                  break;
1098
1099                case 4:
1100                  retCode = BHAB_ERR_AP_ISB;
1101                  break;
1102
1103                case 5:
1104                  retCode = BHAB_ERR_AP_SCR;
1105                  break;
1106
1107                case 6:
1108                  retCode = BHAB_ERR_AP_IRQ;
1109                  break;
1110
1111                case 7:
1112                  retCode = BHAB_ERR_AP_COPY;
1113                  break;
1114
1115                case 8:
1116                  retCode = BHAB_ERR_AP_EEPROM;
1117                  break;
1118
1119                case 9:
1120                  retCode = BHAB_ERR_AP_HABAV;
1121                  break;
1122
1123                default:
1124                  BDBG_ERR(("unknown MSG1 (=0x%02X)\n", sb));
1125                  retCode = BHAB_ERR_AP_UNKNOWN;
1126                  break;
1127                }
1128        }
1129
1130 done:
1131        return retCode;
1132}
1133
1134
1135/******************************************************************************
1136 BHAB_3520_P_CheckHab()
1137******************************************************************************/
1138BERR_Code BHAB_3520_P_CheckHab(
1139        BHAB_Handle handle    /* [in] BHAB Handle */
1140)
1141{
1142        BERR_Code retCode;
1143        BHAB_ApStatus status;
1144
1145        BHAB_CHK_RETCODE(BHAB_3520_GetApStatus(handle, &status));
1146        if ((status & BHAB_APSTATUS_HAB_MASK) == BHAB_APSTATUS_HAB_READY)
1147                retCode = BERR_SUCCESS;
1148        else
1149        {
1150                BDBG_ERR(("AP status = 0x%08X\n", (uint32_t)status));
1151                BERR_TRACE(retCode = BHAB_3520_P_DecodeError(handle, &status));
1152        }
1153       
1154 done:
1155        return retCode;
1156}
Note: See TracBrowser for help on using the repository browser.