Beispiel #1
0
void
bsp_init()
{
	/* map memory for padconf */
	bsp_padconf_init();

	/* map memory for rtc */
	omap3_rtc_init();

	/* map memory for reset control */
	bsp_reset_init();

	/* disable watchdog */
	bsp_disable_watchdog();
}
/* 
** API	  : zarlinkInitDevice()
** Desp	  :	Init Zarlink device
** input  : Realtek device obj pointer
** return : SUCCESS/FAILED
*/
BOOL zarlinkInitDevice( RTKDevObj *pDev )
{
   	int ch;
	BOOL rtn;
	VpProfilePtrType dev_profile;
	VpStatusType status;
	VpTermType term_type;

   	PRINT_MSG("Initializing device 0x%x\n", pDev->dev_id);

	/* Create the API-2 device */
	status = VpMakeDeviceObject( pDev->VpDevType, 
								 (VpDeviceIdType) pDev->dev_id, 
								 pDev->pDevCtx,	
								 pDev->pDevObj	
							  );

	if ( status != VP_STATUS_SUCCESS ) {
	  	PRINT_R("Error: VpMakeDeviceObject (status %d) \n", status);
	  	return FAILED;
	}

	for (ch=0; ch < pDev->max_line; ch++) {

		if (pDev->pLine[ch]->line_type == LINE_FXS ) 
			 term_type = VP_TERM_FXS_GENERIC;
		else term_type = VP_TERM_FXO_GENERIC;

		/* Create line objects */
		status = VpMakeLineObject( term_type, 
							   pDev->pLine[ch]->channelId,	
							   pDev->pLine[ch]->pLineCtx,
							   pDev->pLine[ch]->pLineObj,
							   pDev->pDevCtx		
							);
		if ( status != VP_STATUS_SUCCESS ) {
	  		PRINT_R("Error: VpMakeLineObject ch %d term=%d(status %d) \n", 
				ch, term_type, status);
	  		return FAILED;
		}
	}

	dev_profile = pDev->pDev_profile;

	PRINT_MSG("tick rate %d ms\n", dev_profile[DEVICE_PROFILE_TICK_RATE_IDX]);

	/* Avoid taking to long to init device */
#ifdef CONFIG_RTL865X_WTDOG
	plat_disable_watchdog();
	PRINT_MSG("Disable watchdog\n" );
#elif defined( CONFIG_RTL_WTDOG )
	bsp_disable_watchdog();
	PRINT_MSG("Disable watchdog\n" );
#endif	

	/* Initialize the device */
	status = VpInitDevice(  pDev->pDevCtx,		
						   	pDev->pDev_profile,
						   	pDev->pAC_profile,
						   	pDev->pDC_profile,
						   	pDev->pRing_profile,
						   	pDev->pACFxoLC_profile,
						   	pDev->pFxoDial_profile
						);

	if ( status != VP_STATUS_SUCCESS ) {
		PRINT_R("Error: VpInitDevice (status %d)\n", status );
		goto DONE;
	}

	/* Check if VP_DEV_EVID_DEV_INIT_CMP occurred */
	if( TRUE != zarlinkWaitForEvent( pDev->pDevCtx, 
		VP_EVCAT_RESPONSE, VP_DEV_EVID_DEV_INIT_CMP ) ) {
		PRINT_R("Error: Device %d initialization was not complete\n",pDev->dev_id);
		status = VP_STATUS_FAILURE;
		goto DONE;
	}

	PRINT_MSG("DEV%x initialized OK\n",pDev->dev_id);
	pDev->dev_st = DEV_S_READY;

	/* Initialize API-2 line settings */
	for (ch=0; ch < pDev->max_line; ch++) {
		if (pDev->pLine[ch]->line_type == LINE_FXS)	{
			rtn = RtkInitFxsLine(pDev->pLine[ch]);

		} else if (pDev->pLine[ch]->line_type == LINE_FXO) {
			rtn = RtkInitFxoLine(pDev->pLine[ch]);

		} else {
			PRINT_R("Error: unknow line_type %d\n",pDev->pLine[ch]->line_type);
			goto DONE;
		}
	}

DONE:
#ifdef CONFIG_RTL865X_WTDOG
	plat_enable_watchdog();
	PRINT_MSG("Enable watchdog\n");
#elif defined( CONFIG_RTL_WTDOG )
	bsp_enable_watchdog();
	PRINT_MSG("Enable watchdog\n");
#endif
	if ( status != VP_STATUS_SUCCESS )	return FAILED;

	return SUCCESS;
}