Subversion Repositories shark

Rev

Rev 587 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
587 giacomo 1
/*
2
 * Exceptions for specific devices. Usually work-arounds for fatal design flaws.
3
 */
4
 
5
#include <linuxcomp.h>
6
 
7
#include <linux/pci.h>
8
#include <linux/init.h>
9
#include "pci2.h"
10
 
11
 
12
static void __devinit pci_fixup_i450nx(struct pci_dev *d)
13
{
14
        /*
15
         * i450NX -- Find and scan all secondary buses on all PXB's.
16
         */
17
        int pxb, reg;
18
        u8 busno, suba, subb;
19
 
20
        printk(KERN_WARNING "PCI: Searching for i450NX host bridges on %s\n", pci_name(d));
21
        reg = 0xd0;
22
        for(pxb=0; pxb<2; pxb++) {
23
                pci_read_config_byte(d, reg++, &busno);
24
                pci_read_config_byte(d, reg++, &suba);
25
                pci_read_config_byte(d, reg++, &subb);
26
                DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb);
27
                if (busno)
28
                        pci_scan_bus(busno, &pci_root_ops, NULL);       /* Bus A */
29
                if (suba < subb)
30
                        pci_scan_bus(suba+1, &pci_root_ops, NULL);      /* Bus B */
31
        }
32
        pcibios_last_bus = -1;
33
}
34
 
35
static void __devinit pci_fixup_i450gx(struct pci_dev *d)
36
{
37
        /*
38
         * i450GX and i450KX -- Find and scan all secondary buses.
39
         * (called separately for each PCI bridge found)
40
         */
41
        u8 busno;
42
        pci_read_config_byte(d, 0x4a, &busno);
43
        printk(KERN_INFO "PCI: i440KX/GX host bridge %s: secondary bus %02x\n", pci_name(d), busno);
44
        pci_scan_bus(busno, &pci_root_ops, NULL);
45
        pcibios_last_bus = -1;
46
}
47
 
48
static void __devinit  pci_fixup_umc_ide(struct pci_dev *d)
49
{
50
        /*
51
         * UM8886BF IDE controller sets region type bits incorrectly,
52
         * therefore they look like memory despite of them being I/O.
53
         */
54
        int i;
55
 
56
        printk(KERN_WARNING "PCI: Fixing base address flags for device %s\n", pci_name(d));
57
        for(i=0; i<4; i++)
58
                d->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO;
59
}
60
 
61
static void __devinit  pci_fixup_ncr53c810(struct pci_dev *d)
62
{
63
        /*
64
         * NCR 53C810 returns class code 0 (at least on some systems).
65
         * Fix class to be PCI_CLASS_STORAGE_SCSI
66
         */
67
        if (!d->class) {
68
                printk(KERN_WARNING "PCI: fixing NCR 53C810 class code for %s\n", pci_name(d));
69
                d->class = PCI_CLASS_STORAGE_SCSI << 8;
70
        }
71
}
72
 
73
static void __devinit pci_fixup_ide_bases(struct pci_dev *d)
74
{
75
        int i;
76
 
77
        /*
78
         * PCI IDE controllers use non-standard I/O port decoding, respect it.
79
         */
80
        if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
81
                return;
82
        DBG("PCI: IDE base address fixup for %s\n", pci_name(d));
83
        for(i=0; i<4; i++) {
84
                struct resource *r = &d->resource[i];
85
                if ((r->start & ~0x80) == 0x374) {
86
                        r->start |= 2;
87
                        r->end = r->start;
88
                }
89
        }
90
}
91
 
92
static void __devinit  pci_fixup_ide_trash(struct pci_dev *d)
93
{
94
        int i;
95
 
96
        /*
97
         * There exist PCI IDE controllers which have utter garbage
98
         * in first four base registers. Ignore that.
99
         */
100
        DBG("PCI: IDE base address trash cleared for %s\n", pci_name(d));
101
        for(i=0; i<4; i++)
102
                d->resource[i].start = d->resource[i].end = d->resource[i].flags = 0;
103
}
104
 
105
static void __devinit  pci_fixup_latency(struct pci_dev *d)
106
{
107
        /*
108
         *  SiS 5597 and 5598 chipsets require latency timer set to
109
         *  at most 32 to avoid lockups.
110
         */
111
        DBG("PCI: Setting max latency to 32\n");
112
        pcibios_max_latency = 32;
113
}
114
 
115
static void __devinit pci_fixup_piix4_acpi(struct pci_dev *d)
116
{
117
        /*
118
         * PIIX4 ACPI device: hardwired IRQ9
119
         */
120
        d->irq = 9;
121
}
122
 
123
/*
124
 * Addresses issues with problems in the memory write queue timer in
125
 * certain VIA Northbridges.  This bugfix is per VIA's specifications,
126
 * except for the KL133/KM133: clearing bit 5 on those Northbridges seems
127
 * to trigger a bug in its integrated ProSavage video card, which
128
 * causes screen corruption.  We only clear bits 6 and 7 for that chipset,
129
 * until VIA can provide us with definitive information on why screen
130
 * corruption occurs, and what exactly those bits do.
131
 *
132
 * VIA 8363,8622,8361 Northbridges:
133
 *  - bits  5, 6, 7 at offset 0x55 need to be turned off
134
 * VIA 8367 (KT266x) Northbridges:
135
 *  - bits  5, 6, 7 at offset 0x95 need to be turned off
136
 * VIA 8363 rev 0x81/0x84 (KL133/KM133) Northbridges:
137
 *  - bits     6, 7 at offset 0x55 need to be turned off
138
 */
139
 
140
#define VIA_8363_KL133_REVISION_ID 0x81
141
#define VIA_8363_KM133_REVISION_ID 0x84
142
 
143
static void __devinit pci_fixup_via_northbridge_bug(struct pci_dev *d)
144
{
145
        u8 v;
146
        u8 revision;
147
        int where = 0x55;
148
        int mask = 0x1f; /* clear bits 5, 6, 7 by default */
149
 
150
        pci_read_config_byte(d, PCI_REVISION_ID, &revision);
151
 
152
        if (d->device == PCI_DEVICE_ID_VIA_8367_0) {
153
                /* fix pci bus latency issues resulted by NB bios error
154
                   it appears on bug free^Wreduced kt266x's bios forces
155
                   NB latency to zero */
156
                pci_write_config_byte(d, PCI_LATENCY_TIMER, 0);
157
 
158
                where = 0x95; /* the memory write queue timer register is
159
                                different for the KT266x's: 0x95 not 0x55 */
160
        } else if (d->device == PCI_DEVICE_ID_VIA_8363_0 &&
161
                        (revision == VIA_8363_KL133_REVISION_ID ||
162
                        revision == VIA_8363_KM133_REVISION_ID)) {
163
                        mask = 0x3f; /* clear only bits 6 and 7; clearing bit 5
164
                                        causes screen corruption on the KL133/KM133 */
165
        }
166
 
167
        pci_read_config_byte(d, where, &v);
168
        if (v & ~mask) {
169
                printk(KERN_WARNING "Disabling VIA memory write queue (PCI ID %04x, rev %02x): [%02x] %02x & %02x -> %02x\n", \
170
                        d->device, revision, where, v, mask, v & mask);
171
                v &= mask;
172
                pci_write_config_byte(d, where, v);
173
        }
174
}
175
 
176
/*
177
 * For some reasons Intel decided that certain parts of their
178
 * 815, 845 and some other chipsets must look like PCI-to-PCI bridges
179
 * while they are obviously not. The 82801 family (AA, AB, BAM/CAM,
180
 * BA/CA/DB and E) PCI bridges are actually HUB-to-PCI ones, according
181
 * to Intel terminology. These devices do forward all addresses from
182
 * system to PCI bus no matter what are their window settings, so they are
183
 * "transparent" (or subtractive decoding) from programmers point of view.
184
 */
185
static void __devinit pci_fixup_transparent_bridge(struct pci_dev *dev)
186
{
187
        if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI &&
188
            (dev->device & 0xff00) == 0x2400)
189
                dev->transparent = 1;
190
}
191
 
192
struct pci_fixup pcibios_fixups[] = {
193
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82451NX,    pci_fixup_i450nx },
194
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82454GX,    pci_fixup_i450gx },
195
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_UMC,      PCI_DEVICE_ID_UMC_UM8886BF,     pci_fixup_umc_ide },
196
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_SI,       PCI_DEVICE_ID_SI_5513,          pci_fixup_ide_trash },
197
        { PCI_FIXUP_HEADER,     PCI_ANY_ID,             PCI_ANY_ID,                     pci_fixup_ide_bases },
198
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_SI,       PCI_DEVICE_ID_SI_5597,          pci_fixup_latency },
199
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_SI,       PCI_DEVICE_ID_SI_5598,          pci_fixup_latency },
200
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82371AB_3,  pci_fixup_piix4_acpi },
201
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82801CA_10, pci_fixup_ide_trash },
202
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82801CA_11, pci_fixup_ide_trash },
203
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82801DB_9,  pci_fixup_ide_trash },
204
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8363_0,       pci_fixup_via_northbridge_bug },
205
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8622,         pci_fixup_via_northbridge_bug },
206
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8361,         pci_fixup_via_northbridge_bug },
207
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_8367_0,       pci_fixup_via_northbridge_bug },
208
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_NCR,      PCI_DEVICE_ID_NCR_53C810,       pci_fixup_ncr53c810 },
209
        { PCI_FIXUP_HEADER,     PCI_VENDOR_ID_INTEL,    PCI_ANY_ID,                     pci_fixup_transparent_bridge },
210
        { 0 }
211
};