1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/init.h>
15#include <linux/pci.h>
16
17#include <loongson.h>
18
19
20static u8 sb_slot = 5;
21
22int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
23{
24 int irq = 0;
25
26 if (slot == sb_slot) {
27 switch (PCI_FUNC(dev->devfn)) {
28 case 2:
29 irq = 10;
30 break;
31 case 3:
32 irq = 11;
33 break;
34 case 5:
35 irq = 9;
36 break;
37 }
38 } else {
39 irq = LOONGSON_IRQ_BASE + 25 + pin;
40 }
41 return irq;
42
43}
44
45
46int pcibios_plat_dev_init(struct pci_dev *dev)
47{
48 return 0;
49}
50
51static void __init loongson2e_nec_fixup(struct pci_dev *pdev)
52{
53 unsigned int val;
54
55
56 pci_read_config_dword(pdev, 0xe0, &val);
57 pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x4);
58
59
60 pci_write_config_dword(pdev, 0xe4, 1 << 5);
61}
62
63static void __init loongson2e_686b_func0_fixup(struct pci_dev *pdev)
64{
65 unsigned char c;
66
67 sb_slot = PCI_SLOT(pdev->devfn);
68
69 printk(KERN_INFO "via686b fix: ISA bridge\n");
70
71
72 pci_write_config_byte(pdev, 0x40, 0x08);
73
74
75 pci_write_config_byte(pdev, 0x41, 0x01);
76
77
78 pci_write_config_byte(pdev, 0x45, 0x00);
79
80
81 pci_write_config_byte(pdev, 0x46, 0xe0);
82
83
84
85
86
87
88
89
90 pci_write_config_byte(pdev, 0x47, 0xe6);
91
92
93
94
95
96 outb(0x2e, 0x4d1);
97
98
99 pci_write_config_byte(pdev, 0x48, 0x01);
100
101
102 pci_write_config_byte(pdev, 0x4a, 0x84);
103
104
105
106
107
108
109 pci_write_config_byte(pdev, 0x50, 0x0e);
110
111
112
113
114
115
116 pci_write_config_byte(pdev, 0x51, 0x76);
117
118
119 pci_write_config_byte(pdev, 0x52, 0x34);
120
121
122 pci_write_config_byte(pdev, 0x54, 0x00);
123
124
125 pci_write_config_byte(pdev, 0x55, 0x90);
126 pci_write_config_byte(pdev, 0x56, 0xba);
127
128 pci_write_config_byte(pdev, 0x57, 0xd0);
129
130
131 pci_read_config_byte(pdev, 0x85, &c);
132 c &= ~(0x3 << 2);
133 pci_write_config_byte(pdev, 0x85, c);
134
135 printk(KERN_INFO"via686b fix: ISA bridge done\n");
136}
137
138static void __init loongson2e_686b_func1_fixup(struct pci_dev *pdev)
139{
140 printk(KERN_INFO"via686b fix: IDE\n");
141
142
143 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 48);
144 pci_write_config_byte(pdev, PCI_COMMAND,
145 PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
146 PCI_COMMAND_MASTER);
147 pci_write_config_byte(pdev, 0x40, 0x0b);
148
149 pci_write_config_byte(pdev, 0x42, 0x09);
150
151#if 1
152
153 pci_write_config_byte(pdev, 0x41, 0x02);
154
155
156 pci_write_config_byte(pdev, 0x43, 0x0a);
157 pci_write_config_byte(pdev, 0x44, 0x00);
158
159 pci_write_config_byte(pdev, 0x45, 0x00);
160#else
161 pci_write_config_byte(pdev, 0x41, 0xc2);
162 pci_write_config_byte(pdev, 0x43, 0x35);
163 pci_write_config_byte(pdev, 0x44, 0x1c);
164
165 pci_write_config_byte(pdev, 0x45, 0x10);
166#endif
167
168 printk(KERN_INFO"via686b fix: IDE done\n");
169}
170
171static void __init loongson2e_686b_func2_fixup(struct pci_dev *pdev)
172{
173
174 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 10);
175}
176
177static void __init loongson2e_686b_func3_fixup(struct pci_dev *pdev)
178{
179
180 pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, 11);
181}
182
183static void __init loongson2e_686b_func5_fixup(struct pci_dev *pdev)
184{
185 unsigned int val;
186 unsigned char c;
187
188
189 pci_write_config_byte(pdev, PCI_COMMAND,
190 PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
191 PCI_COMMAND_MASTER);
192 pci_read_config_dword(pdev, 0x4, &val);
193 pci_write_config_dword(pdev, 0x4, val | 1);
194
195
196 pci_write_config_byte(pdev, 0x3c, 9);
197
198 pci_read_config_byte(pdev, 0x8, &c);
199
200
201 pci_write_config_byte(pdev, 0x41, 0xcc);
202
203
204 pci_write_config_byte(pdev, 0x42, 0x20);
205
206
207 pci_write_config_word(pdev, 0x2c, 0x1005);
208 pci_write_config_word(pdev, 0x2e, 0x4710);
209 pci_read_config_dword(pdev, 0x2c, &val);
210
211 pci_write_config_byte(pdev, 0x42, 0x0);
212}
213
214DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686,
215 loongson2e_686b_func0_fixup);
216DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
217 loongson2e_686b_func1_fixup);
218DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2,
219 loongson2e_686b_func2_fixup);
220DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3,
221 loongson2e_686b_func3_fixup);
222DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5,
223 loongson2e_686b_func5_fixup);
224DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
225 loongson2e_nec_fixup);
226