1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
This file is based on:
$XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
Modified for readability by Nick Kurshev
*/
static int pci_config_type( void )
{
unsigned long tmplong1, tmplong2;
unsigned char tmp1, tmp2;
int retval;
retval = 0;
OUTPORT8(PCI_MODE2_ENABLE_REG, 0x00);
OUTPORT8(PCI_MODE2_FORWARD_REG, 0x00);
tmp1 = INPORT8(PCI_MODE2_ENABLE_REG);
tmp2 = INPORT8(PCI_MODE2_FORWARD_REG);
if ((tmp1 == 0x00) && (tmp2 == 0x00)) {
retval = 2;
/*printf("PCI says configuration type 2\n");*/
} else {
tmplong1 = INPORT32(PCI_MODE1_ADDRESS_REG);
OUTPORT32(PCI_MODE1_ADDRESS_REG, PCI_EN);
tmplong2 = INPORT32(PCI_MODE1_ADDRESS_REG);
OUTPORT32(PCI_MODE1_ADDRESS_REG, tmplong1);
if (tmplong2 == PCI_EN) {
retval = 1;
/*printf("PCI says configuration type 1\n");*/
} else {
/*printf("No PCI !\n");*/
disable_app_io();
/*exit(1);*/
retval = 0xFFFF;
}
}
return retval;
}
static int pci_get_vendor(
unsigned char bus,
unsigned char dev,
int func)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd);
return INPORT32(PCI_MODE1_DATA_REG);
}
static long pci_config_read_long(
unsigned char bus,
unsigned char dev,
int func,
unsigned cmd)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd);
return INPORT32(PCI_MODE1_DATA_REG);
}
static long pci_config_read_word(
unsigned char bus,
unsigned char dev,
int func,
unsigned cmd)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd);
return INPORT16(PCI_MODE1_DATA_REG);
}
static long pci_config_read_byte(
unsigned char bus,
unsigned char dev,
int func,
unsigned cmd)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd);
return INPORT8(PCI_MODE1_DATA_REG);
}
static void pci_config_write_long(
unsigned char bus,
unsigned char dev,
int func,
unsigned cmd,
long val)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd);
OUTPORT32(PCI_MODE1_DATA_REG,val);
}
static void pci_config_write_word(
unsigned char bus,
unsigned char dev,
int func,
unsigned cmd,
long val)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd);
OUTPORT16(PCI_MODE1_DATA_REG,val);
}
static void pci_config_write_byte(
unsigned char bus,
unsigned char dev,
int func,
unsigned cmd,
long val)
{
unsigned long config_cmd;
config_cmd = PCI_EN | (bus<<16) | (dev<<11) | (func<<8);
OUTPORT32(PCI_MODE1_ADDRESS_REG, config_cmd | cmd);
OUTPORT8(PCI_MODE1_DATA_REG,val);
}
|