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] - Blame information for rev 15

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
 
2
#include <linux/kernel.h>
3
#define __NO_VERSION__
4
#include <linux/module.h>
5
#include <linux/types.h>
6
#include <linux/ioport.h>
7
#include <linux/pci.h>
8
#include <linux/pagemap.h>
9
#include <linux/interrupt.h>
10
#include <linux/proc_fs.h>
11
#include <asm/io.h>
12
 
13
#include "pexmodule.h"
14
#include "pexproc.h"
15
#include "ambpexregs.h"
16
#include "hardware.h"
17
 
18
//--------------------------------------------------------------------
19
 
20
void pex_register_proc( char *name, void *fptr, void *data )
21
{
22 6 v.karak
    create_proc_read_entry( name, 0, NULL, fptr, data );
23 2 dsmv
}
24
 
25
//--------------------------------------------------------------------
26
 
27
void pex_remove_proc( char *name )
28
{
29 6 v.karak
    remove_proc_entry( name, NULL );
30 2 dsmv
}
31
 
32
//--------------------------------------------------------------------
33
 
34 6 v.karak
int pex_show_capabilities( char *buf, struct pex_device *brd )
35
{
36
    int i = 0, res = -1;
37
    char *p = buf;
38
    u8 cap;
39
    u8 cap_id;
40
 
41
    p += sprintf(p,"\n" );
42
    p += sprintf(p,"  Device capabilities\n" );
43
    p += sprintf(p,"\n" );
44
 
45
    res = pci_read_config_byte(brd->m_pci, 0x34, &cap);
46
    if(res < 0) {
47
        p += sprintf(p, "  Error read capabilities pointer\n");
48
        goto err_exit;
49
    }
50
 
51
    res = pci_read_config_byte(brd->m_pci, cap, &cap_id);
52
    if(res < 0) {
53
        p += sprintf(p, "  Error read capabilities id\n");
54
        goto err_exit;
55
    }
56
 
57
    if(cap_id != 0x10) { //not PCI Express capabilities
58
 
59
        res = pci_read_config_byte(brd->m_pci, cap+1, &cap);
60
        if(res < 0) {
61
            p += sprintf(p, "  Error read capabilities id\n");
62
            goto err_exit;
63
        }
64
    }
65
 
66
    res = pci_read_config_byte(brd->m_pci, cap, &cap_id);
67
    if(res < 0) {
68
        p += sprintf(p, "  Error read capabilities id\n");
69
        goto err_exit;
70
    } else {
71
        p += sprintf(p, "  CAP_ID = 0x%X\n", cap_id);
72
    }
73
 
74
    if(cap_id != 0x10) {
75
        p += sprintf(p, "  Can't find PCI Express capabilities\n");
76
        goto err_exit;
77
    }
78
 
79
    for(i=0; i<9; i++) {
80
        u32 reg = 0;
81
        int j = cap + 4*i;
82
        res = pci_read_config_dword(brd->m_pci, j, &reg);
83
        if(res < 0) {
84
            p += sprintf(p, "  Error read capabilities sructure: offset %x\n", j);
85
            goto err_exit;
86
        }
87
        p += sprintf(p, "  %x: = 0x%X\n", j, reg);
88
    }
89
 
90
    err_exit:
91
 
92
    return (p-buf);
93
}
94
 
95
//--------------------------------------------------------------------
96
 
97 2 dsmv
int pex_proc_info(  char *buf,
98
                    char **start,
99
                    off_t off,
100
                    int count,
101
                    int *eof,
102
                    void *data )
103
{
104 6 v.karak
    int iBlock = 0;
105
    char *p = buf;
106
    struct pex_device *brd = (struct pex_device*)data;
107 2 dsmv
 
108 6 v.karak
    if(!brd) {
109
        p += sprintf(p,"  Invalid device pointer\n" );
110
        *eof = 1;
111
        return p - buf;
112
    }
113 2 dsmv
 
114 6 v.karak
    p += pex_show_capabilities(p, brd);
115 2 dsmv
 
116 6 v.karak
    p += sprintf(p,"\n" );
117
    p += sprintf(p,"  Device information\n" );
118 2 dsmv
 
119 6 v.karak
    p += sprintf(p, "  m_TotalIRQ = %d\n", atomic_read(&brd->m_TotalIRQ));
120 2 dsmv
 
121
 
122
 
123 6 v.karak
    for(iBlock = 0; iBlock < brd->m_BlockCnt; iBlock++)
124
    {
125
        u32 FifoAddr = 0;
126
        u16 val = 0;
127 2 dsmv
 
128 6 v.karak
        FifoAddr = (iBlock + 1) * PE_FIFO_ADDR;
129
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_ID + FifoAddr);
130 2 dsmv
 
131 6 v.karak
        if((val & 0x0FFF) != PE_EXT_FIFO_ID)
132
            continue;
133 2 dsmv
 
134 6 v.karak
        p += sprintf(p,"\n" );
135
        p += sprintf(p,"  PE_EXT_FIFO %d\n", iBlock+1 );
136
        p += sprintf(p,"\n" );
137
 
138
        p += sprintf(p,"  BLOCK_ID = %x\n", (val & 0x0FFF) );
139
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_VER + FifoAddr);
140
        p += sprintf(p,"  BLOCK_VER = %x\n", (val & 0xFFFF) );
141
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_ID + FifoAddr);
142
        p += sprintf(p,"  FIFO_ID = %x\n", (val & 0xFFFF) );
143
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_NUM + FifoAddr);
144
        p += sprintf(p,"  FIFO_NUMBER = %x\n", (val & 0xFFFF) );
145
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_SIZE + FifoAddr);
146
        p += sprintf(p,"  RESOURCE = %x\n", (val & 0xFFFF) );
147
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_CTRL + FifoAddr);
148
        p += sprintf(p,"  DMA_MODE = %x\n", (val & 0xFFFF) );
149
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_CTRL + FifoAddr);
150
        p += sprintf(p,"  DMA_CTRL = %x\n", (val & 0xFFFF) );
151
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_STATUS + FifoAddr);
152
        p += sprintf(p,"  FIFO_STATUS = %x\n", (val & 0xFFFF) );
153
        val = ReadOperationWordReg(brd, PEFIFOadr_FLAG_CLR + FifoAddr);
154
        p += sprintf(p,"  FLAG_CLR = %x\n", (val & 0xFFFF) );
155
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRL + FifoAddr);
156
        p += sprintf(p,"  PCI_ADRL = %x\n", (val & 0xFFFF) );
157
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRH + FifoAddr);
158
        p += sprintf(p,"  PCI_ADRH = %x\n", (val & 0xFFFF) );
159
        val = ReadOperationWordReg(brd, PEFIFOadr_LOCAL_ADR + FifoAddr);
160
        p += sprintf(p,"  LOCAL_ADR = %x\n", (val & 0xFFFF) );
161
    }
162
 
163
    *eof = 1;
164
 
165
    return p - buf;
166 2 dsmv
}
167
 
168
//--------------------------------------------------------------------

powered by: WebSVN 2.1.0

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