OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [soft/] [linux/] [driver/] [pexdrv/] [hardware.c] - Diff between revs 19 and 30

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 19 Rev 30
Line 14... Line 14...
#include "pexmodule.h"
#include "pexmodule.h"
#include "hardware.h"
#include "hardware.h"
#include "ambpexregs.h"
#include "ambpexregs.h"
#include "memory.h"
#include "memory.h"
 
 
 
 
 
int g_isAdm=0;
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
int set_device_name(struct pex_device *brd, u16 dev_id, int index)
int set_device_name(struct pex_device *brd, u16 dev_id, int index)
{
{
    if(!brd)
    if(!brd)
        return -1;
        return -1;
 
 
    switch(dev_id) {
    switch(dev_id) {
    case AMBPEX5_DEVID: snprintf(brd->m_name, 128, "%s%d", "AMBPEX5", index); break;
    case AMBPEX5_DEVID: snprintf(brd->m_name, 128, "%s%d", "AMBPEX5", index); break;
    case AMBPEX8_DEVID: snprintf(brd->m_name, 128, "%s%d", "AMBPEX8", index); break;
 
    case ADP201X1AMB_DEVID: snprintf(brd->m_name, 128, "%s%d", "ADP201X1AMB", index); break;
 
    case ADP201X1DSP_DEVID: snprintf(brd->m_name, 128, "%s%d", "ADP201X1DSP", index); break;
 
    case AMBPEXARM_DEVID: snprintf(brd->m_name, 128, "%s%d", "D2XT005", index); break;
 
    case AMBFMC106P_DEVID: snprintf(brd->m_name, 128, "%s%d", "AMBFMC106P", index); break;
 
    case AMBFMC114V_DEVID: snprintf(brd->m_name, 128, "%s%d", "AMBFMC114V", index); break;
 
    case AMBKU_SSCOS_DEVID: snprintf(brd->m_name, 128, "%s%d", "AMBKU_SSCOS", index); break;
 
    default:
    default:
        snprintf(brd->m_name, sizeof(brd->m_name), "%s%d", "Unknown", index); break;
        snprintf(brd->m_name, sizeof(brd->m_name), "%s%d", "Unknown", index); break;
    }
    }
 
 
    return 0;
    return 0;
Line 81... Line 77...
    deviceID = ReadOperationWordReg(brd, PEMAINadr_DEVICE_ID);
    deviceID = ReadOperationWordReg(brd, PEMAINadr_DEVICE_ID);
    deviceRev = ReadOperationWordReg(brd, PEMAINadr_DEVICE_REV);
    deviceRev = ReadOperationWordReg(brd, PEMAINadr_DEVICE_REV);
 
 
    dbg_msg(dbg_trace, "%s(): DeviceID = 0x%X, DeviceRev = 0x%X.\n", __FUNCTION__, deviceID, deviceRev);
    dbg_msg(dbg_trace, "%s(): DeviceID = 0x%X, DeviceRev = 0x%X.\n", __FUNCTION__, deviceID, deviceRev);
 
 
    if((AMBPEX8_DEVID != deviceID) &&
 
            (ADP201X1AMB_DEVID != deviceID) &&
 
            (AMBPEX5_DEVID != deviceID) &&
 
            (AMBPEXARM_DEVID != deviceID) &&
 
            (AMBFMC114V_DEVID != deviceID)) {
 
 
 
        dbg_msg(dbg_trace, "%s(): Unsupported device id: 0x%X.\n", __FUNCTION__, deviceID);
 
        return -ENODEV;
 
    }
 
 
 
    temp = ReadOperationWordReg(brd, PEMAINadr_PLD_VER);
    temp = ReadOperationWordReg(brd, PEMAINadr_PLD_VER);
 
 
    dbg_msg(dbg_trace, "%s(): PldVER = 0x%X.\n", __FUNCTION__, temp);
    dbg_msg(dbg_trace, "%s(): PldVER = 0x%X.\n", __FUNCTION__, temp);
 
 
Line 137... Line 125...
        }
        }
    }
    }
 
 
    dbg_msg(dbg_trace, "%s(): m_DmaChanMask = 0x%X\n", __FUNCTION__, brd->m_DmaChanMask);
    dbg_msg(dbg_trace, "%s(): m_DmaChanMask = 0x%X\n", __FUNCTION__, brd->m_DmaChanMask);
 
 
 
 
    // подготовим к работе ПЛИС ADM
    // подготовим к работе ПЛИС ADM
    dbg_msg(dbg_trace, "%s(): Prepare ADM PLD.\n", __FUNCTION__);
    dbg_msg(dbg_trace, "%s(): Prepare ADM PLD.\n", __FUNCTION__);
    WriteOperationWordReg(brd,PEMAINadr_BRD_MODE, 0);
    WriteOperationWordReg(brd,PEMAINadr_BRD_MODE, 0);
    ToPause(100);       // pause ~ 100 msec
    ToPause(100);       // pause ~ 100 msec
    for(i = 0; i < 10; i++)
    for(i = 0; i < 10; i++)
Line 455... Line 444...
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
int DmaEnable(struct pex_device *brd, u32 AdmNumber, u32 TetrNumber)
int DmaEnable(struct pex_device *brd, u32 AdmNumber, u32 TetrNumber)
{
{
    int Status = 0;
    int Status = 0;
    u32 Value = 0;
    //u32 Value = 0;
    Status = ReadRegData(brd, AdmNumber, TetrNumber, 0, &Value);
    //Status = ReadRegData(brd, AdmNumber, TetrNumber, 0, &Value);
    if(Status != 0) return Status;
    //if(Status != 0) return Status;
    Value |= 0x8; // DRQ enable
    //Value |= 0x8; // DRQ enable
    Status = WriteRegData(brd, AdmNumber, TetrNumber, 0, Value);
    //Status = WriteRegData(brd, AdmNumber, TetrNumber, 0, Value);
    //err_msg(err_trace, "%s: MODE0 = 0x%X.\n", __FUNCTION__, Value);
    //err_msg(err_trace, "%s: MODE0 = 0x%X.\n", __FUNCTION__, Value);
    return Status;
    return Status;
}
}
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
int DmaDisable(struct pex_device *brd, u32 AdmNumber, u32 TetrNumber)
int DmaDisable(struct pex_device *brd, u32 AdmNumber, u32 TetrNumber)
{
{
    int Status = 0;
    int Status = 0;
    u32 Value = 0;
    //u32 Value = 0;
    Status = ReadRegData(brd, AdmNumber, TetrNumber, 0, &Value);
    //Status = ReadRegData(brd, AdmNumber, TetrNumber, 0, &Value);
    if(Status != 0) return Status;
    //if(Status != 0) return Status;
    Value &= 0xfff7; // DRQ disable
    //Value &= 0xfff7; // DRQ disable
    Status = WriteRegData(brd, AdmNumber, TetrNumber, 0, Value);
    //Status = WriteRegData(brd, AdmNumber, TetrNumber, 0, Value);
    return Status;
    return Status;
}
}
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
Line 613... Line 602...
        if(brd->m_DmaChanEnbl[i])
        if(brd->m_DmaChanEnbl[i])
            enbl = 1;
            enbl = 1;
    brd->m_DmaIrqEnbl = enbl;
    brd->m_DmaIrqEnbl = enbl;
 
 
    tetr_num = GetTetrNum(brd->m_DmaChannel[NumberOfChannel]);
    tetr_num = GetTetrNum(brd->m_DmaChannel[NumberOfChannel]);
    Status = DmaDisable(brd, 0, tetr_num);
    //Status = DmaDisable(brd, 0, tetr_num);
    CompleteDmaTransfer(brd->m_DmaChannel[NumberOfChannel]);
    CompleteDmaTransfer(brd->m_DmaChannel[NumberOfChannel]);
 
 
    return Status;
    return Status;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.