/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_ceoc.h'
*/
DSL_Error_t DSL_CEOC_Restart(DSL_Context_t *pContext)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;

   DSL_CHECK_POINTER(pContext, DSL_CEOC_CONTEXT(pContext));
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: Restarting CEOC module..."DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   /* Check CEOC module bRun flag*/
   if( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun == DSL_FALSE )
   {
      DSL_DRV_INIT_EVENT("ceocev_ne", DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent);

      /* Start CEOC module thread*/
      nErrCode = (DSL_Error_t)DSL_DRV_THREAD(&DSL_CEOC_CONTEXT(pContext)->ceocThread.Control,
                                 "ceocex_ne", DSL_CEOC_Thread, (DSL_uint32_t)pContext);

      if( nErrCode != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_MSG,
            (pContext, SYS_DBG_MSG"DSL[%02d]: ERROR - CEOC module thread start failed, retCode(%d)!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));
      }
   }
   else
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC thread should be stoped before restarting!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return nErrCode;
   }

   /* Call device specific CEOC restart stuff*/
   nErrCode = DSL_CEOC_DEV_Restart(pContext);
   if( nErrCode != DSL_SUCCESS )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC device specific restart failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return nErrCode;
   }

   return nErrCode;
}
/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_ceoc.h'
*/
DSL_Error_t DSL_CEOC_Start(DSL_Context_t *pContext)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_CEOC_Context_t *pCeocContext = DSL_NULL;

   DSL_CHECK_CTX_POINTER(pContext);
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module starting..." DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   if(pContext->CEOC != DSL_NULL)
   {
      DSL_DEBUG(DSL_DBG_WRN,
         (pContext, SYS_DBG_WRN"DSL[%02d]: WARNING - CEOC already started"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_SUCCESS;
   }

   /* Create CEOC context */
   pCeocContext = (DSL_CEOC_Context_t*)DSL_DRV_Malloc(sizeof(DSL_CEOC_Context_t));
   if(!pCeocContext)
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: DSL_CEOC_Start: no memory for internal context"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }
   memset(pCeocContext, 0, sizeof(DSL_CEOC_Context_t));

   /* Initialize pointer to the CEOC context in the DSL CPE context*/
   pContext->CEOC = (DSL_void_t*)pCeocContext;

   /* init CEOC module common mutex */
   DSL_DRV_MUTEX_INIT(DSL_CEOC_CONTEXT(pContext)->ceocMutex);

#ifdef INCLUDE_DSL_CEOC_INTERNAL_API
   /* init CEOC module internal API mutex */
   DSL_DRV_MUTEX_INIT(DSL_CEOC_CONTEXT(pContext)->ceocInternMutex);
#endif /* #ifdef INCLUDE_DSL_CEOC_INTERNAL_API*/

   /* Initialize CEOC module device specific parameters*/
   if( DSL_CEOC_DEV_Start(pContext) != DSL_SUCCESS )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module device specific init failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   DSL_CEOC_CONTEXT(pContext)->bInit = DSL_TRUE;

   /*
      Init CEOC module threads
   */
   DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE;
   DSL_CEOC_CONTEXT(pContext)->ceocThread.nThreadPollTime = DSL_CEOC_THREAD_POLLING_CYCLE;
   DSL_DRV_INIT_EVENT("ceocev_ne", DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent);

   /* Start CEOC module thread*/
   nErrCode = (DSL_Error_t)DSL_DRV_THREAD(&DSL_CEOC_CONTEXT(pContext)->ceocThread.Control,
                              "ceocex_ne", DSL_CEOC_Thread, (DSL_uint32_t)pContext);

   if( nErrCode != DSL_SUCCESS )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module thread start failed, retCode(%d)!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext), nErrCode));
   }
   else
   {
      DSL_DEBUG(DSL_DBG_MSG,
         (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module started..." DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));
   }

   return nErrCode;
}
Example #3
0
/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_led.h'
*/
DSL_Error_t DSL_DRV_LED_ModuleInit(
   DSL_Context_t *pContext)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_FwVersion_t *pVer = DSL_NULL;
     
   DSL_CHECK_POINTER(pContext, pContext->pDevCtx);
   DSL_CHECK_ERR_CODE();

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, "DSL[%02d]: IN - DSL_DRV_LED_ModuleInit"DSL_DRV_CRLF,
       DSL_DEV_NUM(pContext)));

   if (pContext->bLedInit)
   {
      DSL_DEBUG(DSL_DBG_WRN,
         (pContext, "DSL[%02d]: WARNING - LED module already started" DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));
         
      return DSL_SUCCESS;
   }

   if(DSL_DRV_MUTEX_LOCK(pContext->dataMutex))
   {
      DSL_DEBUG( DSL_DBG_ERR,
         (pContext, "DSL[%02d]: ERROR - Couldn't lock data mutex!"DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }

   pVer = &(pContext->pDevCtx->data.version.fwVersion);

   if (pVer->bValid == DSL_TRUE)
   {
      if (pVer->nMajorVersion != DSL_AMAZON_SE_FW_MAJOR_NUMBER &&
          pVer->nMajorVersion != DSL_AR9_FW_MAJOR_NUMBER && 
          pVer->nMajorVersion != DSL_DANUBE_FW_MAJOR_NUMBER)
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, "DSL[%02d]: ADSL Data LED handling included but not implemented for Danube!"
            DSL_DRV_CRLF,
            DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERR_NOT_IMPLEMENTED;
      }
   }
   else
   {
      DSL_DEBUG(DSL_DBG_ERR, (pContext,
         "DSL[%02d]: ERROR - No firmware version available" DSL_DRV_CRLF,
         DSL_DEV_NUM(pContext)));
            
      nErrCode = DSL_WRN_DEVICE_NO_DATA;
   }

   DSL_DRV_MUTEX_UNLOCK(pContext->dataMutex);   

   if (nErrCode != DSL_SUCCESS)
   {
      return nErrCode;
   }

   spin_lock_init(&dsl_led_lock);
   pGlobalContext = pContext;
   pContext->bLedNeedToFlash = DSL_FALSE;
   pContext->bLedStatusOn = DSL_FALSE;
#if !((DSL_DATA_LED_FLASH_FREQUENCY >= 1) && (DSL_DATA_LED_FLASH_FREQUENCY <= 32))
#error Please use --with-adsl-data-led-flash-frequency=[1-32] to define ADSL Data Flash Frequency
#endif
   DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: ADSL data led flashing at %d Hz" DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext), DSL_DATA_LED_FLASH_FREQUENCY));
   flash_freq = DSL_DATA_LED_FLASH_FREQUENCY;
   if (flash_freq == 16)
   {
      flash = (pVer->nMajorVersion == DSL_DANUBE_FW_MAJOR_NUMBER) ? 0x901 : 0xA01;
   }
   else
   {
      flash_freq = ((flash_freq * 2) << 2) & 0xFC;
      flash = (pVer->nMajorVersion == DSL_DANUBE_FW_MAJOR_NUMBER) ? 0x902 : 0xA02;
      flash |= flash_freq;
   }
   
   off = (pVer->nMajorVersion == DSL_DANUBE_FW_MAJOR_NUMBER) ? 0x900 : 0xA00;

   on  = off | 0x3;
   
   /* adsl led for led function */
   DSL_DRV_INIT_EVENT ("atm_led", pContext->ledPollingEvent);

#ifdef INCLUDE_DSL_DATA_LED_SIMULATOR
   pContext->nDataLedSimControlData.nLedBehavior  = DSL_DATA_LED_OFF;
   pContext->nDataLedSimControlData.nBlinkTimeout = 1000;
   DSL_DRV_INIT_EVENT ("led_sim", pContext->dataLedSimEvent);   
   if ( DSL_DRV_THREAD (
           &LedSim, "atm_led_sim",
           DSL_DRV_LED_Sim, (DSL_uint32_t)pContext))
   {
      DSL_DEBUG(DSL_DBG_ERR, (pContext, "DSL[%02d]: ADSL DATA LED Simulator task start failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_ERROR;
   }
#else
   DSL_BSP_ATMLedCBRegister (DSL_DRV_LED_Flash);
#endif /* INCLUDE_DSL_DATA_LED_SIMULATOR*/

   pContext->bLedInit = DSL_TRUE;

   return (DSL_Error_t)DSL_DRV_THREAD (&LedControl, "atm_led_completion", DSL_DRV_LED_Poll, (DSL_uint32_t)pContext);
}