예제 #1
0
/*******************************************************************************
* mvWriteEnable - serialize the write enable sequence
*
* DESCRIPTION:
*       transmit the sequence for write enable
*
********************************************************************************/
static MV_STATUS mvWriteEnable(MV_SFLASH_INFO * pFlinfo)
{
	MV_U8 cmd[MV_SFLASH_WREN_CMND_LENGTH];


    cmd[0] = sflash[pFlinfo->index].opcdWREN;

	return mvSpiWriteThenRead(cmd, MV_SFLASH_WREN_CMND_LENGTH, NULL, 0, 0);
}
예제 #2
0
/*******************************************************************************
* mvSysSflashDataRead
*
* DESCRIPTION:
*	System interface for reading SPI flash data.
*
* INPUT:
*       flashHandle: Handle passed by OS glue by which an SPI flash is
*		     identified.
*	dataBuff:    Buffer to read the data into.
*	dataLen:     Number of bytes to read.
*	dummyBytes:  Number of dummy bytes to read before reading the real
*		     data.
*	transType:   Bitmask describing the transaction type, see
*		     SYS_SFLASH_TRANS_XX for details.
*
* OUTPUT:
*	dataBuff: The data as read from flash.
*
* RETURN:
*	MV_OK on success,
*	MV_ERROR otherwise.
*
*******************************************************************************/
MV_STATUS mvSysSflashDataRead(MV_VOID *flashHandle, MV_U8* dataBuff, MV_U32 dataLen,
                              MV_U32 dummyBytes, MV_U8 transType)
{
    MV_STATUS  ret;

    if (!(mvSysSflashCmd.transType & SYS_SFLASH_TRANS_START))
        return MV_ERROR;

    ret = mvSpiWriteThenRead (0, mvSysSflashCmd.buf, mvSysSflashCmd.bufLen,
                              dataBuff, dataLen, dummyBytes);
    if (transType & SYS_SFLASH_TRANS_END)
        memset(&mvSysSflashCmd,0,sizeof(mvSysSflashCmd));
    return ret;
}
예제 #3
0
/*******************************************************************************
* mvStatusRegGet - Retrieve the value of the status register
*
* DESCRIPTION:
*       perform the RDSR sequence to get the 8bit status register
*
********************************************************************************/
static MV_STATUS mvStatusRegGet(MV_SFLASH_INFO * pFlinfo, MV_U8 * pStatReg)
{
    MV_STATUS ret;
	MV_U8 cmd[MV_SFLASH_RDSR_CMND_LENGTH];
	MV_U8 sr[MV_SFLASH_RDSR_REPLY_LENGTH];




	cmd[0] = sflash[pFlinfo->index].opcdRDSR;

	if ((ret = mvSpiWriteThenRead(cmd, MV_SFLASH_RDSR_CMND_LENGTH, sr,
                                         MV_SFLASH_RDSR_REPLY_LENGTH,0)) != MV_OK)
        return ret;

    *pStatReg = sr[0];

    return MV_OK;
}
예제 #4
0
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 */
}