MV_VOID mvVbSpiWrite(MV_U32 lineId, MV_U8 address, mv_line_t lineType, MV_U8 data) { MV_U8 control = 0, spiMode; MV_U32 val1 = 0, val2 = 0, cmd = 0; #ifdef MV_TDM_2CHANNELS spiMode = mvBoardTdmSpiModeGet(); if(lineType == MV_LINE_FXO) { if(spiMode) /* daisy-chain */ { control = DAA_WRITE_CONTROL_BYTE << 1; /* 2 channels */ } else /* dedicated CS */ { control = DAA_WRITE_CONTROL_BYTE; } val1 = (MV_U32)((address<<8) | control); val2 = (MV_U32)data; cmd = TRANSFER_BYTES(3) | ENDIANESS_MSB_MODE | WR_MODE | CLK_SPEED_LO_DIV; } else /* MV_LINE_FXS */ { if(spiMode) { val1 = (MV_U32)((address<<8) | (1 << lineId)); val2 = data; cmd = TRANSFER_BYTES(3) | ENDIANESS_MSB_MODE | WR_MODE | CLK_SPEED_LO_DIV; } else { val1 = (data<<8) | address; cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | WR_MODE | CLK_SPEED_LO_DIV; } } mvTdmSpiWrite(val1, val2, cmd, lineId); #else /* MV_TDM_32CHANNELS */ /* TBD - Fix dedicated SPI driver APIs */ #endif /* MV_TDM_2CHANNELS */ }
void writeDaaDirectReg(unsigned int daa_dev, unsigned char address, unsigned char data) { /*unsigned short addr;*/ MV_DAA_DEV *pDaaDev = (MV_DAA_DEV *)daa_dev; unsigned char control = 0; unsigned int val1 = 0, val2 = 0, cmd = 0; control = 0x20; if(work_mode) control |= pDaaDev->ch; val1 = (unsigned int)((address<<8) | control); val2 = (unsigned int)data; cmd = TRANSFER_BYTES(3) | ENDIANESS_MSB_MODE | WR_MODE | CLK_SPEED_LO_DIV; mvTdmSpiWrite(val1, val2, cmd, pDaaDev->ch); }
/******************************************************************************* * mvSysTdmSpiWrite - telephony register write via SPI interface * * DESCRIPTION: * * INPUT: * None * OUTPUT: * None * RETURN: * None * *******************************************************************************/ MV_VOID mvSysTdmSpiWrite(MV_U16 lineId, MV_U8* cmdBuff, MV_U8 cmdSize, MV_U8* dataBuff, MV_U8 dataSize) { #if defined(MV_TDM_SUPPORT) && !defined(ZARLINK_SLIC_SUPPORT) if((cmdSize > 3) || (dataSize > MAX_DATA_LENGTH)) { mvOsPrintf("Error, exceeded max size of command(%d) or data(%d)\n", cmdSize, dataSize); return; } mvTdmSpiWrite(cmdBuff, cmdSize, dataBuff, dataSize, lineId); #else /* MV_COMM_UNIT_SUPPORT || ZARLINK_SLIC_SUPPORT */ /* Set SPI parameters(lineId = devId) */ mvSpiParamsSet(mvBoardTdmSpiIdGet(), mvBoardTdmSpiCsGet(lineId), SPI_TYPE_SLIC); if(MV_OK != mvSpiWriteThenWrite (mvBoardTdmSpiIdGet(), cmdBuff, cmdSize, dataBuff, dataSize)) printk("SPI write failed !!!\n"); #endif /* MV_TDM_SUPPORT */ }