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 55

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 54 v.karak
#include <linux/version.h>
6 2 dsmv
#include <linux/types.h>
7
#include <linux/ioport.h>
8
#include <linux/pci.h>
9
#include <linux/pagemap.h>
10
#include <linux/interrupt.h>
11
#include <linux/proc_fs.h>
12 54 v.karak
#include <linux/seq_file.h>
13 2 dsmv
#include <asm/io.h>
14
 
15 54 v.karak
 
16 2 dsmv
#include "pexmodule.h"
17
#include "pexproc.h"
18
#include "ambpexregs.h"
19
#include "hardware.h"
20
 
21
//--------------------------------------------------------------------
22
 
23 54 v.karak
#define print_info(p, S...) seq_printf(p, S)
24 2 dsmv
 
25
//--------------------------------------------------------------------
26
 
27 54 v.karak
void pex_brd_capabilities(struct pex_device *brd, struct seq_file *p)
28 2 dsmv
{
29 33 v.karak
    int i = 0;
30
    int res = 0;
31
    u8 cap = 0;
32
    u32 cap_id = 0;
33 6 v.karak
 
34 44 v.karak
    struct pci_dev *m_pci = brd->m_pci;
35 43 v.karak
    if(!m_pci) {
36
        goto err_exit;
37
    }
38
 
39 54 v.karak
    print_info(p,"\n" );
40 44 v.karak
 
41 43 v.karak
    res = pci_read_config_byte(m_pci, 0x34, &cap);
42 6 v.karak
    if(res < 0) {
43 54 v.karak
        print_info(p, "  Error read capabilities pointer\n");
44 6 v.karak
        goto err_exit;
45
    }
46
 
47 54 v.karak
    print_info(p, "  Capability pointer: 0x%x\n", cap);
48 33 v.karak
 
49
    while(1) {
50
 
51 43 v.karak
        res = pci_read_config_dword(m_pci, cap, &cap_id);
52 33 v.karak
        if(res < 0) {
53 54 v.karak
            print_info(p, "  Error read capabilities id\n");
54 6 v.karak
            goto err_exit;
55
        }
56 33 v.karak
 
57 54 v.karak
        print_info(p, "  Capability ID: 0x%x\n", cap_id);
58 33 v.karak
 
59
        if((cap_id & 0xff) == 0x10) {
60
            break;
61
        }
62
 
63
        cap = ((cap_id >> 8) & 0xff);
64
        if(!cap)
65
            break;
66 6 v.karak
    }
67
 
68 33 v.karak
    if((cap_id & 0xff) != 0x10) {
69 54 v.karak
        print_info(p, "  Can't find PCI Express capabilities\n");
70 6 v.karak
        goto err_exit;
71
    }
72
 
73 54 v.karak
    print_info(p,"\n" );
74
    print_info(p, "  PCI Express Capability Register Set\n");
75
    print_info(p,"\n" );
76 33 v.karak
 
77 6 v.karak
    for(i=0; i<9; i++) {
78 33 v.karak
        u32 reg = 0;
79
        int j = cap + 4*i;
80 43 v.karak
        res = pci_read_config_dword(m_pci, j, &reg);
81 33 v.karak
        if(res < 0) {
82 54 v.karak
            print_info(p, "  Error read capabilities sructure: offset %x\n", j);
83 6 v.karak
            goto err_exit;
84
        }
85 54 v.karak
        print_info(p, "  0x%x:  0x%X\n", j, reg);
86 6 v.karak
    }
87
 
88 54 v.karak
    return;
89
 
90 33 v.karak
err_exit:
91 54 v.karak
    print_info(p, "  Error print info\n");
92 6 v.karak
}
93
 
94 54 v.karak
//--------------------------------------------------------------------
95
 
96
void pex_brd_info(struct pex_device *brd, struct seq_file *p)
97 2 dsmv
{
98 6 v.karak
    int iBlock = 0;
99
    if(!brd) {
100 54 v.karak
        print_info(p,"  Invalid device pointer\n" );
101
        return;
102 6 v.karak
    }
103 2 dsmv
 
104 54 v.karak
    pex_brd_capabilities(brd, p);
105 2 dsmv
 
106 54 v.karak
    print_info(p,"\n" );
107
    print_info(p,"  Device information\n" );
108
    print_info(p, "  m_TotalIRQ = %d\n", atomic_read(&brd->m_TotalIRQ));
109 2 dsmv
 
110 6 v.karak
    for(iBlock = 0; iBlock < brd->m_BlockCnt; iBlock++)
111
    {
112
        u32 FifoAddr = 0;
113
        u16 val = 0;
114 2 dsmv
 
115 6 v.karak
        FifoAddr = (iBlock + 1) * PE_FIFO_ADDR;
116
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_ID + FifoAddr);
117 2 dsmv
 
118 6 v.karak
        if((val & 0x0FFF) != PE_EXT_FIFO_ID)
119
            continue;
120 2 dsmv
 
121 54 v.karak
        print_info(p,"\n" );
122
        print_info(p,"  PE_EXT_FIFO %d\n", iBlock+1 );
123
        print_info(p,"\n" );
124 6 v.karak
 
125 54 v.karak
        print_info(p,"  BLOCK_ID = %x\n", (val & 0x0FFF) );
126 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_BLOCK_VER + FifoAddr);
127 54 v.karak
        print_info(p,"  BLOCK_VER = %x\n", (val & 0xFFFF) );
128 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_ID + FifoAddr);
129 54 v.karak
        print_info(p,"  FIFO_ID = %x\n", (val & 0xFFFF) );
130 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_NUM + FifoAddr);
131 54 v.karak
        print_info(p,"  FIFO_NUMBER = %x\n", (val & 0xFFFF) );
132 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_SIZE + FifoAddr);
133 54 v.karak
        print_info(p,"  RESOURCE = %x\n", (val & 0xFFFF) );
134 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_CTRL + FifoAddr);
135 54 v.karak
        print_info(p,"  DMA_MODE = %x\n", (val & 0xFFFF) );
136 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_DMA_CTRL + FifoAddr);
137 54 v.karak
        print_info(p,"  DMA_CTRL = %x\n", (val & 0xFFFF) );
138 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_FIFO_STATUS + FifoAddr);
139 54 v.karak
        print_info(p,"  FIFO_STATUS = %x\n", (val & 0xFFFF) );
140 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_FLAG_CLR + FifoAddr);
141 54 v.karak
        print_info(p,"  FLAG_CLR = %x\n", (val & 0xFFFF) );
142 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRL + FifoAddr);
143 54 v.karak
        print_info(p,"  PCI_ADRL = %x\n", (val & 0xFFFF) );
144 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_PCI_ADDRH + FifoAddr);
145 54 v.karak
        print_info(p,"  PCI_ADRH = %x\n", (val & 0xFFFF) );
146 6 v.karak
        val = ReadOperationWordReg(brd, PEFIFOadr_LOCAL_ADR + FifoAddr);
147 54 v.karak
        print_info(p,"  LOCAL_ADR = %x\n", (val & 0xFFFF) );
148 6 v.karak
    }
149 54 v.karak
}
150 6 v.karak
 
151 54 v.karak
//--------------------------------------------------------------------
152 6 v.karak
 
153 54 v.karak
static int pex_proc_show(struct seq_file *m, void *v)
154
{
155
    struct pex_device *brd = m->private;
156
 
157
    pex_brd_info(brd, m);
158
 
159
    return 0;
160 2 dsmv
}
161
 
162
//--------------------------------------------------------------------
163 54 v.karak
 
164
static int pex_proc_open(struct inode *inode, struct file *file)
165
{
166
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
167
    struct pex_device* brd = PDE_DATA(inode);
168
#else
169
    struct pex_device* brd = PDE(inode)->data;
170
#endif
171
 
172
    return single_open(file, pex_proc_show, brd);
173
}
174
 
175
//--------------------------------------------------------------------
176
 
177
static int pex_proc_release(struct inode *inode, struct file *file)
178
{
179
    return single_release(inode, file);
180
}
181
 
182
//--------------------------------------------------------------------
183
 
184
static const struct file_operations pex_proc_fops = {
185
    .owner          = THIS_MODULE,
186
    .open           = pex_proc_open,
187
    .read           = seq_read,
188
    .llseek         = seq_lseek,
189
    .release        = pex_proc_release,
190
};
191
 
192
//--------------------------------------------------------------------
193
 
194
void pex_register_proc( char *name, void *fptr, void *data )
195
{
196
    struct pex_device *brd = (struct pex_device *)data;
197
 
198
    if(!brd) {
199
        dbg_msg( dbg_trace, "%s(): Invalid driver pointer\n", __FUNCTION__ );
200
        return;
201
    }
202
 
203
    if(!proc_create_data(name, S_IRUGO, NULL, &pex_proc_fops, brd)) {
204
        dbg_msg(1, "%s(): Error register proc entry: /proc/%s\n", __FUNCTION__, name);
205
    }
206
}
207
 
208
//--------------------------------------------------------------------
209
 
210
void pex_remove_proc( char *name )
211
{
212
    remove_proc_entry(name, NULL);
213
}
214
 
215
//--------------------------------------------------------------------

powered by: WebSVN 2.1.0

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