Exemplo n.º 1
0
/*******************************************************************************
* mvSysTdmInit - Initialize the TDM subsystem
*
* DESCRIPTION:
*
* INPUT:
*       None
* OUTPUT:
*		None
* RETURN:
*       None
*
*******************************************************************************/
MV_STATUS mvSysTdmInit(MV_TDM_PARAMS* tdmParams)
{
	MV_TDM_HAL_DATA halData;
	MV_UNIT_WIN_INFO addrWinMap[MAX_TARGETS + 1];
	MV_STATUS status;

	status = mvCtrlAddrWinMapBuild(addrWinMap, MAX_TARGETS + 1);
	if(status == MV_OK)
#ifdef MV_TDM_SUPPORT
		status = mvTdmWinInit(addrWinMap);
#else
		status = mvCommUnitWinInit(addrWinMap);
#endif

	if(status == MV_OK) {
		halData.spiMode = mvBoardTdmSpiModeGet();
		halData.model = mvCtrlModelGet();
#ifdef MV_TDM_SUPPORT
		status = mvTdmHalInit (tdmParams, &halData);
#else
		halData.maxCs = mvBoardTdmDevicesCountGet();
		status = mvCommUnitHalInit (tdmParams, &halData);
		
		/* Issue SLIC reset */
		mvGppValueSet(0, BIT25, 0);
		mvOsDelay(1);
		mvGppValueSet(0, BIT25, BIT25);
#endif
	}

	return status;
}
Exemplo n.º 2
0
MV_STATUS tdm_if_init(tdm_if_register_ops_t* register_ops, tdm_if_params_t* tdm_if_params)
{
	MV_TDM_PARAMS tdm_params;
	
	printk("Loading Marvell Telephony Driver\n");

	/* Check if any SLIC module exists */
	if(mvBoardTdmDevicesCountGet() == 0) {
		mvCtrlPwrClckSet(TDM_2CH_UNIT_ID, 0, MV_FALSE);
		printk("%s: Warning, no SLIC module is connected\n",__FUNCTION__);
		return MV_OK;
	}

	/* Check that selected TDM unit is active */
	if (MV_FALSE == mvCtrlPwrClckGet(mvCtrlTdmUnitTypeGet(), 0)) {
		printk("%s: Warning, TDM is powered off\n",__FUNCTION__);
		return MV_OK;
	}


	if((register_ops == NULL) || (tdm_if_params == NULL)) {
		printk("%s: bad parameters\n",__FUNCTION__);
		return MV_ERROR;

	}

	/* Check callbacks */
	if(register_ops->tdm_if_pcm_ops.pcm_tx_callback == NULL ||
	   register_ops->tdm_if_pcm_ops.pcm_rx_callback == NULL ) {
		printk("%s: missing parameters\n",__FUNCTION__);
		return MV_ERROR;
	}

	/* Reset globals */
	rxBuff = txBuff = NULL;
#ifdef CONFIG_MV_TDM_SUPPORT
	pcm_enable = 0;
#else
	pcm_enable = 1;
#endif
	irq_init = 0;
	tdm_init = 0;

	/* Extract test enable */
	test_enable = tdm_if_params->test_enable;

	/* Calculate Rx/Tx buffer size(use in callbacks) */
	buff_size = (tdm_if_params->pcm_format * tdm_if_params->total_lines * 80 * 
				(tdm_if_params->sampling_period/MV_TDM_BASE_SAMPLING_PERIOD));

	/* Extract TDM irq number */
	irqnr = mvCtrlTdmUnitIrqGet();

	/* Start Marvell trace */
	TRC_START(); 
	TRC_INIT(NULL, NULL, 0, 0);
	TRC_REC("->%s\n",__FUNCTION__);

	/* Assign TDM parameters */
	memcpy(&tdm_params, tdm_if_params, sizeof(MV_TDM_PARAMS));

	/* Assign control callbacks */
	tdm_if_register_ops = register_ops;
	tdm_if_register_ops->tdm_if_ctl_ops.ctl_pcm_start = tdm_if_pcm_start;
	tdm_if_register_ops->tdm_if_ctl_ops.ctl_pcm_stop = tdm_if_pcm_stop;

	/* TDM init */
	if(mvSysTdmInit(&tdm_params) != MV_OK) {
			printk("%s: Error, TDM initialization failed !!!\n",__FUNCTION__);
			return MV_ERROR;
	}
	tdm_init = 1;

	/* Register TDM interrupt */
	if (request_irq(irqnr, tdm_if_isr, IRQF_DISABLED, "tdm", NULL)) {
		printk("%s: Failed to connect irq(%d)\n", __FUNCTION__, irqnr);
		return MV_ERROR;
	}
	irq_init = 1;

	/* Create TDM procFS statistics */
	tdm_stats = proc_mkdir("tdm", NULL);
	create_proc_read_entry("tdm_init", 0, tdm_stats, proc_tdm_init_read, NULL);
	create_proc_read_entry("rx_miss", 0, tdm_stats, proc_rx_miss_read, NULL);
	create_proc_read_entry("tx_miss", 0, tdm_stats, proc_tx_miss_read, NULL);
	create_proc_read_entry("rx_over", 0, tdm_stats, proc_rx_over_read, NULL);
	create_proc_read_entry("tx_under", 0, tdm_stats, proc_tx_under_read, NULL);

	TRC_REC("Marvell Telephony Driver Loaded Successfully\n");

#ifdef CONFIG_MV_COMM_UNIT_SUPPORT
	/* WA to stop the MCDMA gracefully after commUnit initialization */
	tdm_if_pcm_stop();
#endif

	TRC_REC("<-%s\n",__FUNCTION__);
	return MV_OK;
}