Exemplo n.º 1
0
/*******************************************************************************
* mvCntmrCtrlGet -
*
* DESCRIPTION:
*  	Get the Control value of a given counter/timer
*
* INPUT:
*       countNum - counter number
*		pCtrl - pointer to MV_CNTMR_CTRL structure
*
* OUTPUT:
*       Counter\Timer control value
*
* RETURN:
*       MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess
*******************************************************************************/
MV_STATUS mvCntmrCtrlGet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl)
{
	MV_U32 cntmrCtrl;

	if (countNum >= MV_CNTMR_MAX_COUNTER) {
		DB(mvOsPrintf(("mvCntmrCtrlGet: Err. illegal counter number \n")));
		return MV_BAD_PARAM;;
	}

	/* read control register */
	cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG(countNum));

	/* enable counter\timer */
	if (cntmrCtrl & (CTCR_ARM_TIMER_EN(countNum)))
		pCtrl->enable = MV_TRUE;
	else
		pCtrl->enable = MV_FALSE;

	/* counter mode */
	if (cntmrCtrl & (CTCR_ARM_TIMER_AUTO_EN(countNum)))
		pCtrl->autoEnable = MV_TRUE;
	else
		pCtrl->autoEnable = MV_FALSE;
	if (cntmrHalData.ctrlFamily==MV_78XX0)
	{
		pCtrl->Ratio = (cntmrCtrl & (CTCR_ARM_TIMER_RATIO_MASK(countNum))) / (1 << (CTCR_ARM_TIMER_RATIO_OFFS(countNum)));
		pCtrl->enable_25Mhz = (cntmrCtrl & CTCR_ARM_TIMER_25MhzFRQ_MASK(countNum)) ? MV_TRUE : MV_FALSE;
	}
	return MV_OK;
}
Exemplo n.º 2
0
/*******************************************************************************
* mvCntmrCtrlSet -
*
* DESCRIPTION:
*  	Set the Control to a given counter/timer
*
* INPUT:
*       countNum - counter number
*		pCtrl - pointer to MV_CNTMR_CTRL structure
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess
*******************************************************************************/
MV_STATUS mvCntmrCtrlSet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl)
{
	MV_U32 cntmrCtrl;

	if (countNum >= MV_CNTMR_MAX_COUNTER) {
		DB(mvOsPrintf(("mvCntmrCtrlSet: Err. illegal counter number \n")));
		return MV_BAD_PARAM;;
	}

	/* read control register */
	cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG(countNum));
	cntmrCtrl &= ~((CTCR_ARM_TIMER_EN_MASK(countNum)) | (CTCR_ARM_TIMER_AUTO_MASK(countNum)));

	if (pCtrl->enable)	/* enable counter\timer */
		cntmrCtrl |= (CTCR_ARM_TIMER_EN(countNum));

	if (pCtrl->autoEnable)	/* Auto mode */
		cntmrCtrl |= (CTCR_ARM_TIMER_AUTO_EN(countNum));

#ifndef MV88F78X60_Z1
	cntmrCtrl &= ~((CTCR_ARM_TIMER_RATIO_MASK(countNum)) | (CTCR_ARM_TIMER_25MhzFRQ_MASK(countNum)));

	cntmrCtrl |= (pCtrl->Ratio & 0x7) << (CTCR_ARM_TIMER_RATIO_OFFS(countNum));

	if (pCtrl->enable_25Mhz)	/* 25Mhz enable */
		cntmrCtrl |= (CTCR_ARM_TIMER_25MhzFRQ_EN(countNum));

#endif


	MV_REG_WRITE(CNTMR_CTRL_REG(countNum), cntmrCtrl);

	return MV_OK;

}
Exemplo n.º 3
0
/*******************************************************************************
* mvCntmrCtrlGet -
*
* DESCRIPTION:
*	Get the Control value of a given counter/timer
*
* INPUT:
*       countNum - counter number
*		pCtrl - pointer to MV_CNTMR_CTRL structure
*
* OUTPUT:
*       Counter\Timer control value
*
* RETURN:
*       MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess
*******************************************************************************/
MV_STATUS mvCntmrCtrlGet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl)
{
	MV_U32 cntmrCtrl;

	if (countNum >= MV_CNTMR_MAX_COUNTER )
	{
		DB(mvOsPrintf(("mvCntmrCtrlGet: Err. Illigal counter number \n")));
		return MV_BAD_PARAM;;
	}

	/* read control register */
	cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG);

	/* enable counter\timer */
	if (cntmrCtrl & CTCR_ARM_TIMER_EN(countNum))
	{
		pCtrl->enable = MV_TRUE;
	}
	else
	{
		pCtrl->enable = MV_FALSE;
	}

	/* counter mode */
	if (cntmrCtrl & CTCR_ARM_TIMER_AUTO_EN(countNum))
	{
		pCtrl->autoEnable = MV_TRUE;
	}
	else
	{
		pCtrl->autoEnable = MV_FALSE;
	}

	return MV_OK;
}
Exemplo n.º 4
0
/*******************************************************************************
* mvCntmrCtrlSet -
*
* DESCRIPTION:
*  	Set the Control to a given counter/timer
*
* INPUT:
*       countNum - counter number
*		pCtrl - pointer to MV_CNTMR_CTRL structure
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess
*******************************************************************************/
MV_STATUS mvCntmrCtrlSet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl)
{
	MV_U32 cntmrCtrl;

	if (countNum >= MV_CNTMR_MAX_COUNTER) {
		DB(mvOsPrintf(("mvCntmrCtrlSet: Err. illegal counter number \n")));
		return MV_BAD_PARAM;;
	}

	/* read control register */
	cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG(countNum));
	if (pCtrl->enable)	/* enable counter\timer */
		cntmrCtrl |= (CTCR_ARM_TIMER_EN(countNum));
	else			/* disable counter\timer */
		cntmrCtrl &= ~(CTCR_ARM_TIMER_EN(countNum));

	if (pCtrl->autoEnable)	/* Auto mode */
		cntmrCtrl |= (CTCR_ARM_TIMER_AUTO_EN(countNum));
	else			/* no auto mode */
		cntmrCtrl &= ~(CTCR_ARM_TIMER_AUTO_EN(countNum));
		
	if ((cntmrHalData.ctrlFamily == MV_78XX0) ||
	    (cntmrHalData.ctrlFamily == MV_BOBCAT2_DEV_ID)) {
		cntmrCtrl &= ~(CTCR_ARM_TIMER_RATIO_MASK(countNum));
		cntmrCtrl |= (pCtrl->Ratio & 0x7) << (CTCR_ARM_TIMER_RATIO_OFFS(countNum));

		if (pCtrl->enable_25Mhz)	/* 25Mhz enable */
			cntmrCtrl |= (CTCR_ARM_TIMER_25MhzFRQ_EN(countNum));
		else
			cntmrCtrl &= ~(CTCR_ARM_TIMER_25MhzFRQ_EN(countNum));
	}

	MV_REG_WRITE(CNTMR_CTRL_REG(countNum), cntmrCtrl);

	return MV_OK;

}
Exemplo n.º 5
0
/*
 * init the counter
 */
int timer_init(void)
{
	unsigned int cntmrctrl;

	/* load value into timer */
	writel(TIMER_LOAD_VAL, CNTMR_RELOAD_REG(UBOOT_CNTR));
	writel(TIMER_LOAD_VAL, CNTMR_VAL_REG(UBOOT_CNTR));

	/* enable timer in auto reload mode */
	cntmrctrl = readl(CNTMR_CTRL_REG);
	cntmrctrl |= CTCR_ARM_TIMER_EN(UBOOT_CNTR);
	cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR);
	writel(cntmrctrl, CNTMR_CTRL_REG);
	return 0;
}
Exemplo n.º 6
0
/*******************************************************************************
* mvCntmrDisable -
*
* DESCRIPTION:
*  	Stop the counter/timer running, and returns its Value
*
* INPUT:
*       countNum - counter number
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_U32 counter\timer value
*******************************************************************************/
MV_STATUS mvCntmrDisable(MV_U32 countNum)
{
	MV_U32 cntmrCtrl;

	if (countNum >= MV_CNTMR_MAX_COUNTER) {

		DB(mvOsPrintf(("mvCntmrDisable: Err. illegal counter number \n")));
		return MV_BAD_PARAM;;

	}

	/* read control register */
	cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG(countNum));

	/* disable counter\timer */
	cntmrCtrl &= ~(CTCR_ARM_TIMER_EN(countNum));

	MV_REG_WRITE(CNTMR_CTRL_REG(countNum), cntmrCtrl);

	return MV_OK;
}
Exemplo n.º 7
0
/*******************************************************************************
* mvCntmrCtrlSet -
*
* DESCRIPTION:
*	Set the Control to a given counter/timer
*
* INPUT:
*       countNum - counter number
*		pCtrl - pointer to MV_CNTMR_CTRL structure
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess
*******************************************************************************/
MV_STATUS mvCntmrCtrlSet(MV_U32 countNum, MV_CNTMR_CTRL *pCtrl)
{
	MV_U32 cntmrCtrl;

	if (countNum >= MV_CNTMR_MAX_COUNTER )
	{

		DB(mvOsPrintf(("mvCntmrCtrlSet: Err. Illigal counter number \n")));
		return MV_BAD_PARAM;;

	}

	/* read control register */
	cntmrCtrl = MV_REG_READ(CNTMR_CTRL_REG);


	if (pCtrl->enable)	/* enable counter\timer */
	{
		cntmrCtrl |= CTCR_ARM_TIMER_EN(countNum);
	}
	else	/* disable counter\timer */
	{
		cntmrCtrl &= ~CTCR_ARM_TIMER_EN(countNum);
	}

	if ( pCtrl->autoEnable ) /* Auto mode */
	{
		cntmrCtrl |= CTCR_ARM_TIMER_AUTO_EN(countNum);

	}
	else	/* no auto mode */
	{
		cntmrCtrl &= ~CTCR_ARM_TIMER_AUTO_EN(countNum);
	}

	MV_REG_WRITE(CNTMR_CTRL_REG,cntmrCtrl);

	return MV_OK;

}