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/] [pexproc.c] - Diff between revs 44 and 54

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

Rev 44 Rev 54
Line 1... Line 1...
 
 
#include <linux/kernel.h>
#include <linux/kernel.h>
#define __NO_VERSION__
#define __NO_VERSION__
#include <linux/module.h>
#include <linux/module.h>
 
#include <linux/version.h>
#include <linux/types.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/pci.h>
#include <linux/pagemap.h>
#include <linux/pagemap.h>
#include <linux/interrupt.h>
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/proc_fs.h>
 
#include <linux/seq_file.h>
#include <asm/io.h>
#include <asm/io.h>
 
 
 
 
#include "pexmodule.h"
#include "pexmodule.h"
#include "pexproc.h"
#include "pexproc.h"
#include "ambpexregs.h"
#include "ambpexregs.h"
#include "hardware.h"
#include "hardware.h"
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
void pex_register_proc( char *name, void *fptr, void *data )
#define print_info(p, S...) seq_printf(p, S)
{
 
    create_proc_read_entry( name, 0, NULL, fptr, data );
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
void pex_remove_proc( char *name )
 
{
 
    remove_proc_entry( name, NULL );
 
}
 
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
int pex_show_capabilities( char *buf, struct pex_device *brd )
void pex_brd_capabilities(struct pex_device *brd, struct seq_file *p)
{
{
    int i = 0;
    int i = 0;
    int res = 0;
    int res = 0;
    char *p = buf;
 
    u8 cap = 0;
    u8 cap = 0;
    u32 cap_id = 0;
    u32 cap_id = 0;
 
 
    struct pci_dev *m_pci = brd->m_pci;
    struct pci_dev *m_pci = brd->m_pci;
    if(!m_pci) {
    if(!m_pci) {
        goto err_exit;
        goto err_exit;
    }
    }
 
 
    if(!buf) {
    print_info(p,"\n" );
        goto err_exit;
 
    }
 
 
 
    p += sprintf(p,"\n" );
 
 
 
    res = pci_read_config_byte(m_pci, 0x34, &cap);
    res = pci_read_config_byte(m_pci, 0x34, &cap);
    if(res < 0) {
    if(res < 0) {
        p += sprintf(p, "  Error read capabilities pointer\n");
        print_info(p, "  Error read capabilities pointer\n");
        goto err_exit;
        goto err_exit;
    }
    }
 
 
    p += sprintf(p, "  Capability pointer: 0x%x\n", cap);
    print_info(p, "  Capability pointer: 0x%x\n", cap);
 
 
    while(1) {
    while(1) {
 
 
        res = pci_read_config_dword(m_pci, cap, &cap_id);
        res = pci_read_config_dword(m_pci, cap, &cap_id);
        if(res < 0) {
        if(res < 0) {
            p += sprintf(p, "  Error read capabilities id\n");
            print_info(p, "  Error read capabilities id\n");
            goto err_exit;
            goto err_exit;
        }
        }
 
 
        p += sprintf(p, "  Capability ID: 0x%x\n", cap_id);
        print_info(p, "  Capability ID: 0x%x\n", cap_id);
 
 
        if((cap_id & 0xff) == 0x10) {
        if((cap_id & 0xff) == 0x10) {
            break;
            break;
        }
        }
 
 
Line 76... Line 64...
        if(!cap)
        if(!cap)
            break;
            break;
    }
    }
 
 
    if((cap_id & 0xff) != 0x10) {
    if((cap_id & 0xff) != 0x10) {
        p += sprintf(p, "  Can't find PCI Express capabilities\n");
        print_info(p, "  Can't find PCI Express capabilities\n");
        goto err_exit;
        goto err_exit;
    }
    }
 
 
    p += sprintf(p,"\n" );
    print_info(p,"\n" );
    p += sprintf(p, "  PCI Express Capability Register Set\n");
    print_info(p, "  PCI Express Capability Register Set\n");
    p += sprintf(p,"\n" );
    print_info(p,"\n" );
 
 
    for(i=0; i<9; i++) {
    for(i=0; i<9; i++) {
        u32 reg = 0;
        u32 reg = 0;
        int j = cap + 4*i;
        int j = cap + 4*i;
        res = pci_read_config_dword(m_pci, j, &reg);
        res = pci_read_config_dword(m_pci, j, &reg);
        if(res < 0) {
        if(res < 0) {
            p += sprintf(p, "  Error read capabilities sructure: offset %x\n", j);
            print_info(p, "  Error read capabilities sructure: offset %x\n", j);
            goto err_exit;
            goto err_exit;
        }
        }
        p += sprintf(p, "  0x%x:  0x%X\n", j, reg);
        print_info(p, "  0x%x:  0x%X\n", j, reg);
    }
    }
 
 
err_exit:
    return;
 
 
    return (p-buf);
err_exit:
 
    print_info(p, "  Error print info\n");
}
}
 
 
int pex_proc_info(  char *buf,
//--------------------------------------------------------------------
                    char **start,
 
                    off_t off,
void pex_brd_info(struct pex_device *brd, struct seq_file *p)
                    int count,
 
                    int *eof,
 
                    void *data )
 
{
{
    int iBlock = 0;
    int iBlock = 0;
    char *p = buf;
 
    struct pex_device *brd = (struct pex_device*)data;
 
 
 
    if(!brd) {
    if(!brd) {
        p += sprintf(p,"  Invalid device pointer\n" );
        print_info(p,"  Invalid device pointer\n" );
        *eof = 1;
        return;
        return p - buf;
 
    }
    }
 
 
    p += pex_show_capabilities(p, brd);
    pex_brd_capabilities(brd, p);
 
 
    p += sprintf(p,"\n" );
 
    p += sprintf(p,"  Device information\n" );
 
 
 
    p += sprintf(p, "  m_TotalIRQ = %d\n", atomic_read(&brd->m_TotalIRQ));
 
 
 
 
 
 
    print_info(p,"\n" );
 
    print_info(p,"  Device information\n" );
 
    print_info(p, "  m_TotalIRQ = %d\n", atomic_read(&brd->m_TotalIRQ));
 
 
    for(iBlock = 0; iBlock < brd->m_BlockCnt; iBlock++)
    for(iBlock = 0; iBlock < brd->m_BlockCnt; iBlock++)
    {
    {
        u32 FifoAddr = 0;
        u32 FifoAddr = 0;
        u16 val = 0;
        u16 val = 0;
Line 137... Line 116...
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_ID + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_ID + FifoAddr);
 
 
        if((val & 0x0FFF) != PE_EXT_FIFO_ID)
        if((val & 0x0FFF) != PE_EXT_FIFO_ID)
            continue;
            continue;
 
 
        p += sprintf(p,"\n" );
        print_info(p,"\n" );
        p += sprintf(p,"  PE_EXT_FIFO %d\n", iBlock+1 );
        print_info(p,"  PE_EXT_FIFO %d\n", iBlock+1 );
        p += sprintf(p,"\n" );
        print_info(p,"\n" );
 
 
        p += sprintf(p,"  BLOCK_ID = %x\n", (val & 0x0FFF) );
        print_info(p,"  BLOCK_ID = %x\n", (val & 0x0FFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_VER + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_VER + FifoAddr);
        p += sprintf(p,"  BLOCK_VER = %x\n", (val & 0xFFFF) );
        print_info(p,"  BLOCK_VER = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_ID + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_ID + FifoAddr);
        p += sprintf(p,"  FIFO_ID = %x\n", (val & 0xFFFF) );
        print_info(p,"  FIFO_ID = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_NUM + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_NUM + FifoAddr);
        p += sprintf(p,"  FIFO_NUMBER = %x\n", (val & 0xFFFF) );
        print_info(p,"  FIFO_NUMBER = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_SIZE + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_SIZE + FifoAddr);
        p += sprintf(p,"  RESOURCE = %x\n", (val & 0xFFFF) );
        print_info(p,"  RESOURCE = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_CTRL + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_CTRL + FifoAddr);
        p += sprintf(p,"  DMA_MODE = %x\n", (val & 0xFFFF) );
        print_info(p,"  DMA_MODE = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_CTRL + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_CTRL + FifoAddr);
        p += sprintf(p,"  DMA_CTRL = %x\n", (val & 0xFFFF) );
        print_info(p,"  DMA_CTRL = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_STATUS + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_STATUS + FifoAddr);
        p += sprintf(p,"  FIFO_STATUS = %x\n", (val & 0xFFFF) );
        print_info(p,"  FIFO_STATUS = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_FLAG_CLR + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_FLAG_CLR + FifoAddr);
        p += sprintf(p,"  FLAG_CLR = %x\n", (val & 0xFFFF) );
        print_info(p,"  FLAG_CLR = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRL + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRL + FifoAddr);
        p += sprintf(p,"  PCI_ADRL = %x\n", (val & 0xFFFF) );
        print_info(p,"  PCI_ADRL = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRH + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRH + FifoAddr);
        p += sprintf(p,"  PCI_ADRH = %x\n", (val & 0xFFFF) );
        print_info(p,"  PCI_ADRH = %x\n", (val & 0xFFFF) );
        val = ReadOperationWordReg(brd, PEFIFOadr_LOCAL_ADR + FifoAddr);
        val = ReadOperationWordReg(brd, PEFIFOadr_LOCAL_ADR + FifoAddr);
        p += sprintf(p,"  LOCAL_ADR = %x\n", (val & 0xFFFF) );
        print_info(p,"  LOCAL_ADR = %x\n", (val & 0xFFFF) );
 
    }
    }
    }
 
 
    *eof = 1;
//--------------------------------------------------------------------
 
 
 
static int pex_proc_show(struct seq_file *m, void *v)
 
{
 
    struct pex_device *brd = m->private;
 
 
 
    pex_brd_info(brd, m);
 
 
    return p - buf;
    return 0;
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
static int pex_proc_open(struct inode *inode, struct file *file)
 
{
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
 
    struct pex_device* brd = PDE_DATA(inode);
 
#else
 
    struct pex_device* brd = PDE(inode)->data;
 
#endif
 
 
 
    return single_open(file, pex_proc_show, brd);
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
static int pex_proc_release(struct inode *inode, struct file *file)
 
{
 
    return single_release(inode, file);
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
static const struct file_operations pex_proc_fops = {
 
    .owner          = THIS_MODULE,
 
    .open           = pex_proc_open,
 
    .read           = seq_read,
 
    .llseek         = seq_lseek,
 
    .release        = pex_proc_release,
 
};
 
 
 
//--------------------------------------------------------------------
 
 
 
void pex_register_proc( char *name, void *fptr, void *data )
 
{
 
    struct pex_device *brd = (struct pex_device *)data;
 
 
 
    if(!brd) {
 
        dbg_msg( dbg_trace, "%s(): Invalid driver pointer\n", __FUNCTION__ );
 
        return;
 
    }
 
 
 
    if(!proc_create_data(name, S_IRUGO, NULL, &pex_proc_fops, brd)) {
 
        dbg_msg(1, "%s(): Error register proc entry: /proc/%s\n", __FUNCTION__, name);
 
    }
 
}
 
 
 
//--------------------------------------------------------------------
 
 
 
void pex_remove_proc( char *name )
 
{
 
    remove_proc_entry(name, NULL);
}
}
 
 
//--------------------------------------------------------------------
//--------------------------------------------------------------------
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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