source: svn/newcon3bcm2_21bu/magnum/portinginterface/tnr/7552ob/btnr_ob_3x7x.c

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

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

  • Property svn:executable set to *
File size: 8.7 KB
Line 
1/*************************************************************************
2*     (c)2005-2011 Broadcom Corporation
3
4*  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5*  and may only be used, duplicated, modified or distributed pursuant to the terms and
6*  conditions of a separate, written license agreement executed between you and Broadcom
7*  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8*  no license (express or implied), right to use, or waiver of any kind with respect to the
9*  Software, and Broadcom expressly reserves all rights in and to the Software and all
10*  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11*  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12*  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. 
13*   
14* $brcm_Workfile: btnr_ob_3x7x.c $
15* $brcm_Revision: Hydra_Software_Devel/3 $
16* $brcm_Date: 3/12/12 1:07p $
17*
18* [File Description:]
19*
20* Revision History:
21*
22 * $brcm_Log: /magnum/portinginterface/tnr/7552ob/btnr_ob_3x7x.c $
23 *
24 * Hydra_Software_Devel/3   3/12/12 1:07p farshidf
25 * SW3461-1: add the AOB to tuner callback
26 *
27 * Hydra_Software_Devel/2   12/14/11 2:48p farshidf
28 * SW7552-170: remove the tuner power hard code values
29 *
30 * Hydra_Software_Devel/1   12/8/11 11:28p farshidf
31 * SW7552-170: first version of OOB tuner for B0 verification
32*
33***************************************************************************/
34#include "bstd.h"
35#include "bkni.h"
36#include "btnr.h"
37#include "bdbg.h"
38#include "bmem.h"
39#include "btnr_priv.h"
40#include "btmr.h"
41#include "btnr_ob_3x7x.h"
42#include "btnr_ob_3x7x_priv.h"
43#include "bchp_ufe.h"
44#include "bchp_ufe_afe.h"
45#include "bchp_sdadc.h"
46#include "bchp_ufe_misc2.h"
47#include "btnr_ob_tune.h"
48#include "btnr_ob_struct.h"
49
50
51
52BDBG_MODULE(btnr_ob_3x7x);
53
54#define DEV_MAGIC_ID                    ((BERR_TNR_ID<<16) | 0xFACE)
55
56/******************************************************************************
57* BTNR_Ob_3x7x_Open()
58******************************************************************************/
59BERR_Code BTNR_Ob_3x7x_Open(
60    BTNR_Handle *phDev,                 /* [output] Returns handle */
61    BTNR_Ob_3x7x_Settings *pSettings, /* [Input] settings structure */ 
62        BREG_Handle hRegister
63    )
64{
65    BERR_Code retCode = BERR_SUCCESS;
66    BTNR_Ob_3x7x_Handle h3x7xDev;
67        BTMR_Settings sTimerSettings;
68    BTNR_Handle hDev;
69        uint32_t BufSrc;
70
71    BDBG_ENTER(BTNR_Ob_3x7x_Open);
72
73        BDBG_MSG(("BTNR_Ob_3x7x_Open"));
74   
75    hDev = NULL;
76    /* Alloc memory from the system heap */
77    h3x7xDev = (BTNR_Ob_3x7x_Handle) BKNI_Malloc( sizeof( BTNR_Ob_P_3x7x_Handle ) );
78    if( h3x7xDev == NULL )
79    {
80        retCode = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
81        BDBG_ERR(("BTNR_Ob_3x7x_Open: BKNI_malloc() failed\n"));
82        goto done;
83    }
84    BKNI_Memset( h3x7xDev, 0x00, sizeof( BTNR_Ob_P_3x7x_Handle ) );
85
86    hDev = (BTNR_Handle) BKNI_Malloc( sizeof( BTNR_P_Handle ) );
87    if( hDev == NULL )
88    {
89        retCode = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
90        BDBG_ERR(("BTNR_Ob_3x7x_Open: BKNI_malloc() failed\n"));
91        BKNI_Free( h3x7xDev );
92        goto done;
93    }
94    BKNI_Memset( hDev, 0x00, sizeof( BTNR_P_Handle ) );
95
96        h3x7xDev->pTunerParams = (BTNR_Ob_3x7x_TuneParams_t *)BMEM_AllocAligned(pSettings->hHeap, sizeof(BTNR_Ob_3x7x_TuneParams_t), 0, 0 );
97        if (! h3x7xDev->pTunerParams )
98        {
99                        BDBG_ERR(("BTNR_Ob_Open: BKNI_malloc() failed"));
100                        goto done;
101        }
102        BMEM_ConvertAddressToOffset(pSettings->hHeap, h3x7xDev->pTunerParams, &BufSrc );
103        BKNI_Memset( h3x7xDev->pTunerParams, 0x00, sizeof( BTNR_Ob_3x7x_TuneParams_t ) );
104        h3x7xDev->pTunerParams->BTNR_Ob_BBS_Params.BBSAddress = BufSrc;
105
106        h3x7xDev->pTunerStatus = (BTNR_Ob_3x7x_TuneStatus_t *)BMEM_AllocAligned(pSettings->hHeap, sizeof(BTNR_Ob_3x7x_TuneStatus_t), 0, 0 ); 
107        if (! h3x7xDev->pTunerStatus )
108        {
109                        BDBG_ERR(("BTNR_Ob_Open: BKNI_malloc() failed"));
110                        goto done;
111        }
112        BKNI_Memset( h3x7xDev->pTunerStatus, 0x00, sizeof( BTNR_Ob_3x7x_TuneStatus_t ) );
113        h3x7xDev->magicId = DEV_MAGIC_ID;
114        h3x7xDev->hHeap = pSettings->hHeap;
115        h3x7xDev->hRegister = hRegister;
116
117        hDev->hDevImpl = (void *) h3x7xDev;
118        hDev->magicId = DEV_MAGIC_ID;
119        hDev->pSetRfFreq = (BTNR_SetRfFreqFunc) BTNR_Ob_3x7x_SetRfFreq;
120        hDev->pGetRfFreq = (BTNR_GetRfFreqFunc) BTNR_Ob_3x7x_GetRfFreq;
121        hDev->pGetAgcRegVal = (BTNR_GetAgcRegValFunc) NULL;
122        hDev->pSetAgcRegVal = (BTNR_SetAgcRegValFunc) NULL;
123        hDev->pGetInfo = (BTNR_GetInfoFunc) BTNR_Ob_3x7x_GetInfo;
124        hDev->pClose = (BTNR_CloseFunc) BTNR_Ob_3x7x_Close;
125        hDev->pGetPowerSaver = (BTNR_GetPowerSaverFunc) BTNR_Ob_3x7x_GetPowerSaver;
126        hDev->pSetPowerSaver = (BTNR_SetPowerSaverFunc) BTNR_Ob_3x7x_SetPowerSaver;
127        hDev->pGetSettings = (BTNR_GetSettingsFunc) BTNR_Ob_3x7x_GetSettings;
128    hDev->pSetSettings = (BTNR_SetSettingsFunc) BTNR_Ob_3x7x_SetSettings;   
129
130        BKNI_CreateEvent(&(h3x7xDev->hInterruptEvent));
131
132         /* Create timer for status lock check */
133    BTMR_GetDefaultTimerSettings(&sTimerSettings);
134    sTimerSettings.type = BTMR_Type_ePeriodic;
135    sTimerSettings.cb_isr = (BTMR_CallbackFunc)BTNR_Ob_3x7x_P_TimerFunc;
136    sTimerSettings.pParm1 = (void*)hDev;
137    sTimerSettings.parm2 = 0;
138    sTimerSettings.exclusive = false;
139
140    retCode = BTMR_CreateTimer (pSettings->hTmr, &h3x7xDev->hTimer, &sTimerSettings);
141    if ( retCode != BERR_SUCCESS )
142    {
143        BDBG_ERR(("BTHD_Open: Create Timer Failed"));
144        retCode = BERR_TRACE(retCode);
145        goto done;
146    }
147
148        h3x7xDev->pTunerStatus->PowerStatus = BTNR_Ob_ePower_Off;
149done:
150    *phDev = hDev;
151    BDBG_LEAVE(BTNR_Ob_3x7x_Open);
152    return( retCode );
153}
154
155
156/******************************************************************************
157* BTNR_Ob_3x7x_GetDefaultSettings
158******************************************************************************/
159BERR_Code BTNR_Ob_3x7x_GetDefaultSettings(
160    BTNR_Ob_3x7x_Settings *pDefSettings  /* [out] Returns default setting */
161    )
162{
163    BDBG_ASSERT(NULL != pDefSettings);
164    BKNI_Memset(pDefSettings, 0, sizeof(*pDefSettings));
165    return BERR_SUCCESS;
166}
167
168
169/******************************************************************************
170  BTNR_Ob_3x7x_P_TimerFunc()
171 ******************************************************************************/
172BERR_Code BTNR_Ob_3x7x_P_TimerFunc(void *myParam1, int myParam2)
173{
174    BTNR_Handle hDev = (BTNR_Handle)myParam1;
175        BTNR_Ob_P_3x7x_Handle *p3x7x = (BTNR_Ob_P_3x7x_Handle *)(hDev->hDevImpl);
176        BSTD_UNUSED(myParam2);
177        BKNI_SetEvent(p3x7x->hInterruptEvent); 
178        return BERR_SUCCESS;
179}
180
181/******************************************************************************
182  BTNR_Ob_3x7x_GetInterruptEventHandle()
183 ******************************************************************************/
184BERR_Code BTNR_Ob_3x7x_GetInterruptEventHandle(BTNR_Handle h, BKNI_EventHandle* hEvent)
185{
186    *hEvent = ((BTNR_Ob_P_3x7x_Handle *)(h->hDevImpl))->hInterruptEvent;
187    return BERR_SUCCESS;
188}
189
190/******************************************************************************
191  BTNR_Ob_3x7x_ProcessInterruptEvent()
192 ******************************************************************************/
193BERR_Code BTNR_Ob_3x7x_ProcessInterruptEvent(BTNR_Handle hTnrDev)
194{
195
196  BTNR_Ob_P_3x7x_Handle *hDev = (BTNR_Ob_P_3x7x_Handle *)(hTnrDev->hDevImpl);
197
198  if (hDev->pTunerStatus->PowerStatus != BTNR_Ob_ePower_On)
199  {
200        BDBG_ERR(("BTNR_Ob_3x7x_ProcessInterruptEvent: power is still off  "));
201        return BERR_NOT_INITIALIZED;
202  }
203
204  BDBG_MSG(("BTNR_Ob_3x7x_ProcessInterruptEvent %0x  ", hDev->pTunerParams->BTNR_Ob_BBS_Params.BBSConnectMode ));
205
206  if (hDev->pTunerParams->BTNR_Ob_BBS_Params.BBSConnectMode & BTNR_Ob_BBSConnectMode_Tune)
207  {
208        hDev->pTunerParams->BTNR_Ob_BBS_Params.BBSConnectMode &= (~BTNR_Ob_BBSConnectMode_Tune);
209        BTNR_Ob_3x7x_SetRfFreq(hDev, hDev->pTunerParams->BTNR_Ob_BBS_Params.rfFreq, BTNR_TunerMode_eDigital);
210  }
211
212  return BERR_SUCCESS;
213
214}
215
216/******************************************************************************
217  BTNR_3x7x_Get_RF_Status()
218 ******************************************************************************/
219BERR_Code BTNR_Ob_3x7x_Get_RF_Status(BTNR_Handle hTnrDev, BTNR_Ob_3x7x_RfStatus_t *RfCallbackStatus)
220{
221        BTNR_Ob_P_3x7x_Handle *p3x7x = (BTNR_Ob_P_3x7x_Handle *)(hTnrDev->hDevImpl);
222
223    if (p3x7x->pTunerStatus->PowerStatus != BTNR_Ob_ePower_On)
224    {
225                BDBG_ERR(("BTNR_Ob_3x7x_Get_RF_Status: power is still off  "));
226                return BERR_NOT_INITIALIZED;
227    }
228        /* BTNR_P_Oob_TunerStatus(p3x7x); */
229    RfCallbackStatus->Total_Mix_After_ADC = p3x7x->pTunerStatus->Total_Mix_After_ADC;
230    RfCallbackStatus->PreADC_Gain_x256db  = p3x7x->pTunerStatus->PreADC_Gain_x256db;
231    RfCallbackStatus->PostADC_Gain_x256db = p3x7x->pTunerStatus->PostADC_Gain_x256db;
232    RfCallbackStatus->External_Gain_x256db = p3x7x->pTunerStatus->External_Gain_x256db; 
233
234        return BERR_SUCCESS;
235}
236
237
238
239
240
241
242
243
244
245
Note: See TracBrowser for help on using the repository browser.