MV_VOID mvVbSpiRead(MV_U16 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_READ_CONTROL_BYTE << 1; /* 2 channels */ } else /* dedicated CS */ { control = DAA_READ_CONTROL_BYTE; } val1 = (MV_U32)((address<<8) | control); cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV; } else /* MV_LINE_FXS */ { address |= 0x80; if(spiMode) { val1 = (MV_U32)((address<<8) | (1 << lineId)); cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV; } else { val1 = address; cmd = TRANSFER_BYTES(1) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV; } } mvTdmSpiRead(val1, val2, cmd, lineId, data); #else /* MV_TDM_32CHANNELS */ /* TBD - Fix dedicated SPI driver APIs */ #endif /* MV_TDM_2CHANNELS */ }
unsigned char readDaaDirectReg(unsigned int daa_dev, unsigned char address) { unsigned char data, control = 0; MV_DAA_DEV *pDaaDev = (MV_DAA_DEV *)daa_dev; unsigned int val1 = 0, val2 = 0, cmd = 0; control |= 0x60; if(work_mode) control |= pDaaDev->ch; val1 = (unsigned int)((address<<8) | control); cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV; mvTdmSpiRead(val1, val2, cmd, pDaaDev->ch, &data); return data; }
MV_VOID mvSysTdmSpiRead(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 > 4) || (dataSize > MAX_DATA_LENGTH)) { mvOsPrintf("Error, exceeded max size of command(%d) or data(%d)\n", cmdSize, dataSize); return; } mvTdmSpiRead(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 != mvSpiWriteThenRead (mvBoardTdmSpiIdGet(), cmdBuff, cmdSize, dataBuff, dataSize, 0)) printk("SPI read failed !!!\n"); #endif /* MV_TDM_SUPPORT */ }
static int mp_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg) { MV_PHONE *mp = get_mp(iminor(inode) & 0xf); int retval = 0; TRC_REC("->%s ch%d\n",__FUNCTION__,mp->ch); /* check ioctls only root can use */ if (!capable(CAP_SYS_ADMIN)) { return -EPERM; } disable_irq(mp->irq); switch (cmd) { #ifdef MV_88F5181L case PHONE_REC_START: TRC_REC("PHONE_REC_START\n"); mvTdmChRxEnable(mp->ch_info); break; case PHONE_REC_STOP: TRC_REC("PHONE_REC_STOP\n"); mvTdmChRxDisable(mp->ch_info); break; case PHONE_PLAY_START: TRC_REC("PHONE_PLAY_START\n"); mvTdmChTxEnable(mp->ch_info); break; case PHONE_PLAY_STOP: TRC_REC("PHONE_PLAY_STOP\n"); mvTdmChTxDisable(mp->ch_info); break; #else case PHONE_REC_START: case PHONE_PLAY_START: TRC_REC("PHONE_REC/PLAY_START\n"); mvTdmChEnable(mp->ch_info); break; case PHONE_REC_STOP: case PHONE_PLAY_STOP: TRC_REC("PHONE_REC/PLAY_STOP\n"); mvTdmChDisable(mp->ch_info); break; #endif case PHONE_DIALTONE: TRC_REC("PHONE_DIALTONE\n"); mvTdmChDialTone(mp->ch_info); break; case PHONE_BUSY: TRC_REC("PHONE_BUSY\n"); mvTdmChBusyTone(mp->ch_info); break; case PHONE_CPT_STOP: TRC_REC("PHONE_CPT_STOP\n"); mvTdmChStopTone(mp->ch_info); break; case PHONE_RING_START: TRC_REC("PHONE_RING_START\n"); mvTdmChStartRing(mp->ch_info); break; case PHONE_RING_STOP: TRC_REC("PHONE_RING_STOP\n"); mvTdmChStopRing(mp->ch_info); break; case PHONE_EXCEPTION: { MV_U8 offhook; union telephony_exception ex; TRC_REC("PHONE_EXCEPTION\n"); ex.bytes = 0; mvTdmChEventGet(mp->ch_info, &offhook); if(offhook) { TRC_REC("off hook\n"); ex.bits.hookstate = 1; } else { TRC_REC("on hook\n"); } retval = ex.bytes; } break; case PHONE_RINGBACK: TRC_REC("PHONE_RINGBACK\n"); mvTdmChRingBackTone(mp->ch_info); break; case PHONE_MV_READ_SLIC_REG: #ifdef MV_IOCTL mvTdmSpiRead(arg, (MV_U8*)&retval); #else printk("Driver is not configured to support this IOCTL\n"); retval = -1; #endif break; case PHONE_MV_WRITE_SLIC_REG: #ifdef MV_IOCTL mvTdmSpiWrite((arg>>16)&0xff,arg&0xff); #else printk("Driver is not configured to support this IOCTL\n"); retval = -1; #endif break; case PHONE_MV_READ_REG: #ifdef MV_IOCTL retval = *((unsigned int*)(0xf1000000|arg)); #else printk("Driver is not configured to support this IOCTL\n"); retval = -1; #endif break; case PHONE_MV_WRITE_REG: #ifdef MV_IOCTL printk("not implemented yet\n"); #else printk("Driver is not configured to support this IOCTL\n"); retval = -1; #endif break; case PHONE_MV_SPI_TEST: #ifdef MV_IOCTL mvTdmChSpiTest(10000); #else printk("Driver is not configured to support this IOCTL\n"); retval = -1; #endif break; default: printk("%s: Unsupported IOCTL\n",__FUNCTION__); } TRC_REC("<-%s\n",__FUNCTION__); enable_irq(mp->irq); return retval; }