19 #define PCI_COUNTERS 1
21 #include <linux/types.h>
22 #include <linux/pci.h>
25 #if defined(CONFIG_PROC_FS) && defined(PCI_COUNTERS)
30 #include <linux/kernel.h>
33 #include <asm/byteorder.h>
34 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
44 #define PCI_ACCESS_READ 0
45 #define PCI_ACCESS_WRITE 1
47 #if defined(CONFIG_PROC_FS) && defined(PCI_COUNTERS)
48 static char proc_init;
50 unsigned int pci_int_count[32];
52 static void pci_proc_init(
void);
74 static int read_msp_pci_counts(
char *
page,
char **
start,
off_t off,
79 unsigned int intcount, total = 0;
81 for (i = 0; i < 32; ++
i) {
82 intcount = pci_int_count[
i];
84 len +=
sprintf(page + len,
"[%d] = %u\n", i, intcount);
89 len +=
sprintf(page + len,
"total = %u\n", total);
126 static int gen_pci_cfg_wr(
char *page,
char **start,
off_t off,
127 int count,
int *eof,
void *data)
129 unsigned char where = 0;
130 unsigned char bus_num = 0;
131 unsigned char dev_fn = 0xF;
132 u32 wr_data = 0xFF00AA00;
138 len +=
sprintf(page + len,
"PMC MSP PCI: Beginning\n");
140 if (proc_init == 0) {
145 len +=
sprintf(page + len,
"PMC MSP PCI: Before Cfg Wr\n");
171 len +=
sprintf(page + len,
"PMC MSP PCI: After Cfg Wr\n");
174 if (len <= off+count)
200 static void pci_proc_init(
void)
202 create_proc_read_entry(
"pmc_msp_pci_rd_cnt", 0,
NULL,
203 read_msp_pci_counts,
NULL);
204 create_proc_read_entry(
"pmc_msp_pci_cfg_wr", 0,
NULL,
205 gen_pci_cfg_wr,
NULL);
250 static struct resource pci_io_resource = {
251 .name =
"pci IO space",
285 static struct resource pci_mem_resource = {
286 .name =
"pci memory space",
316 #if defined(CONFIG_PROC_FS) && defined(PCI_COUNTERS)
318 for (i = 0; i < 32; ++
i) {
382 unsigned char bus_num = bus->
number;
383 unsigned char dev_fn = (
unsigned char)devfn;
387 static char pciirqflag;
389 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
390 unsigned int vpe_status;
393 #if defined(CONFIG_PROC_FS) && defined(PCI_COUNTERS)
394 if (proc_init == 0) {
405 if (pciirqflag == 0) {
416 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
471 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
475 spin_unlock_irqrestore(&bpci_lock, flags);
481 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
485 spin_unlock_irqrestore(&bpci_lock, flags);
515 msp_pcibios_read_config_byte(
struct pci_bus *
bus,
533 *val = (data >> ((where & 3) << 3)) & 0x0ff;
563 msp_pcibios_read_config_word(
struct pci_bus *bus,
576 if ((where & 3) == 3) {
592 *val = (data >> ((where & 3) << 3)) & 0x0ffff;
620 msp_pcibios_read_config_dword(
struct pci_bus *bus,
673 msp_pcibios_write_config_byte(
struct pci_bus *bus,
686 data = (data & ~(0xff << ((where & 3) << 3))) |
687 (val << ((where & 3) << 3));
722 msp_pcibios_write_config_word(
struct pci_bus *bus,
730 if ((where & 3) == 3)
739 data = (data & ~(0xffff << ((where & 3) << 3))) |
740 (val << ((where & 3) << 3));
774 msp_pcibios_write_config_dword(
struct pci_bus *bus,
823 if (msp_pcibios_read_config_byte(bus, devfn, where, val)) {
826 }
else if (size == 2) {
827 if (msp_pcibios_read_config_word(bus, devfn, where, val)) {
830 }
else if (size == 4) {
831 if (msp_pcibios_read_config_dword(bus, devfn, where, val)) {
874 if (msp_pcibios_write_config_byte(bus, devfn,
875 where, (
u8)(0xFF & val))) {
878 }
else if (size == 2) {
879 if (msp_pcibios_write_config_word(bus, devfn,
880 where, (
u16)(0xFFFF & val))) {
883 }
else if (size == 4) {
884 if (msp_pcibios_write_config_dword(bus, devfn, where, val)) {
945 .mem_resource = &pci_mem_resource,
948 .io_resource = &pci_io_resource,