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 54 and 56

Show entire file | Details | Blame | View Log

Rev 54 Rev 56
Line 298... Line 298...
    write_memory32( (u32*)((u8*)brd->m_BAR1.virtual_address + RelativePort), VirtualAddress, DwordsCount);
    write_memory32( (u32*)((u8*)brd->m_BAR1.virtual_address + RelativePort), VirtualAddress, DwordsCount);
}
}
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
void TimeoutTimerCallback(unsigned long arg )
 
{
 
    struct pex_device *pDevice = (struct pex_device*) arg;
 
    atomic_set(&pDevice->m_IsTimeout, 1);
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
void SetRelativeTimer ( struct timer_list *timer, int timeout, void *data )
 
{
 
    struct pex_device *dev = (struct pex_device*)data;
 
 
 
    if (!dev)
 
        return;
 
 
 
    atomic_set( &dev->m_IsTimeout, 0 );
 
 
 
    timer->data = ( unsigned long ) data;
 
    timer->function = TimeoutTimerCallback;
 
    timer->expires = ( jiffies +  timeout * HZ / 1000);
 
 
 
    add_timer ( timer );
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
void CancelTimer ( struct timer_list *timer )
 
{
 
    del_timer( timer );
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
int WaitCmdReady(struct pex_device *brd, u32 AdmNumber, u32 StatusAddress)
int WaitCmdReady(struct pex_device *brd, u32 AdmNumber, u32 StatusAddress)
{
{
    u32 cmd_rdy;
    u32 cmd_rdy = 0;
 
    u32 timeout = 1;
 
    u32 pass = 0;
 
 
    atomic_set(&brd->m_IsTimeout, 0);
    while(1) {
 
 
    SetRelativeTimer(&brd->m_TimeoutTimer, 1000, (void*)brd); // wait 1 sec
 
 
 
    do {
 
        cmd_rdy = ReadAmbReg(brd, AdmNumber, StatusAddress);
        cmd_rdy = ReadAmbReg(brd, AdmNumber, StatusAddress);
        cmd_rdy &= AMB_statCMDRDY; //HOST_statCMDRDY;
        cmd_rdy &= AMB_statCMDRDY; //HOST_statCMDRDY;
    } while(!atomic_read(&brd->m_IsTimeout) && !cmd_rdy);
 
 
 
    CancelTimer(&brd->m_TimeoutTimer);
        if(cmd_rdy)
 
            break;
 
 
    if (atomic_read(&brd->m_IsTimeout))
        wait_event_interruptible_timeout(brd->m_WaitQueue, (cmd_rdy != 0), msecs_to_jiffies(timeout));
        return -1;
 
 
 
 
        pass++;
 
 
 
        if(pass > 99)
 
            return -1;
 
    }
    return 0;
    return 0;
}
}
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 

powered by: WebSVN 2.1.0

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