Blame view

arch/x86/kernel/quirks.c 15 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
  /*
   * This file contains work-arounds for x86 and x86_64 platform bugs.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
5
  #include <linux/pci.h>
  #include <linux/irq.h>
d54bd57d6   Venki Pallipadi   x86: HPET force e...
6
  #include <asm/hpet.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
  #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
a86f34b49   Andrew Morton   [PATCH] x86: reve...
8
  static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
  {
38175051f   Sergei Shtylyov   x86, quirks: Use ...
10
  	u8 config;
9585ca02f   Matthew Wilcox   Use proper abstra...
11
  	u16 word;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
14
15
16
17
  
  	/* BIOS may enable hardware IRQ balancing for
  	 * E7520/E7320/E7525(revision ID 0x9 and below)
  	 * based platforms.
  	 * Disable SW irqbalance/affinity on those platforms.
  	 */
38175051f   Sergei Shtylyov   x86, quirks: Use ...
18
  	if (dev->revision > 0x9)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
  		return;
a86f34b49   Andrew Morton   [PATCH] x86: reve...
20
21
22
  	/* enable access to config space*/
  	pci_read_config_byte(dev, 0xf4, &config);
  	pci_write_config_byte(dev, 0xf4, config|0x2);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23

9585ca02f   Matthew Wilcox   Use proper abstra...
24
25
26
27
28
  	/*
  	 * read xTPR register.  We may not have a pci_dev for device 8
  	 * because it might be hidden until the above write.
  	 */
  	pci_bus_read_config_word(dev->bus, PCI_DEVFN(8, 0), 0x4c, &word);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
30
  
  	if (!(word & (1 << 13))) {
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
31
32
33
  		dev_info(&dev->dev, "Intel E7520/7320/7525 detected; "
  			"disabling irq balancing and affinity
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
36
37
38
  		noirqdebug_setup("");
  #ifdef CONFIG_PROC_FS
  		no_irq_affinity = 1;
  #endif
  	}
a86f34b49   Andrew Morton   [PATCH] x86: reve...
39
  	/* put back the original value for config space*/
da9bb1d27   Alan Cox   [PATCH] EDAC: cor...
40
  	if (!(config & 0x2))
a86f34b49   Andrew Morton   [PATCH] x86: reve...
41
  		pci_write_config_byte(dev, 0xf4, config);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
  }
764922376   Thomas Gleixner   x86: quirk.c triv...
43
44
45
46
47
48
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH,
  			quirk_intel_irqbalance);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH,
  			quirk_intel_irqbalance);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH,
  			quirk_intel_irqbalance);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
  #endif
d54bd57d6   Venki Pallipadi   x86: HPET force e...
50
51
52
  
  #if defined(CONFIG_HPET_TIMER)
  unsigned long force_hpet_address;
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
53
54
55
  static enum {
  	NONE_FORCE_HPET_RESUME,
  	OLD_ICH_FORCE_HPET_RESUME,
b196884e2   Udo A. Steinberg   x86: force enable...
56
  	ICH_FORCE_HPET_RESUME,
d79a5f80d   Carlos Corbacho   x86: Force enable...
57
58
  	VT8237_FORCE_HPET_RESUME,
  	NVIDIA_FORCE_HPET_RESUME,
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
59
  	ATI_FORCE_HPET_RESUME,
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
60
  } force_hpet_resume_type;
d54bd57d6   Venki Pallipadi   x86: HPET force e...
61
  static void __iomem *rcba_base;
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
62
  static void ich_force_hpet_resume(void)
d54bd57d6   Venki Pallipadi   x86: HPET force e...
63
64
65
66
67
  {
  	u32 val;
  
  	if (!force_hpet_address)
  		return;
8c5dfd255   Stoyan Gaydarov   x86: BUG to BUG_O...
68
  	BUG_ON(rcba_base == NULL);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
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
  
  	/* read the Function Disable register, dword mode only */
  	val = readl(rcba_base + 0x3404);
  	if (!(val & 0x80)) {
  		/* HPET disabled in HPTC. Trying to enable */
  		writel(val | 0x80, rcba_base + 0x3404);
  	}
  
  	val = readl(rcba_base + 0x3404);
  	if (!(val & 0x80))
  		BUG();
  	else
  		printk(KERN_DEBUG "Force enabled HPET at resume
  ");
  
  	return;
  }
  
  static void ich_force_enable_hpet(struct pci_dev *dev)
  {
  	u32 val;
  	u32 uninitialized_var(rcba);
  	int err = 0;
  
  	if (hpet_address || force_hpet_address)
  		return;
  
  	pci_read_config_dword(dev, 0xF0, &rcba);
  	rcba &= 0xFFFFC000;
  	if (rcba == 0) {
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
99
100
101
  		dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; "
  			"cannot force enable HPET
  ");
d54bd57d6   Venki Pallipadi   x86: HPET force e...
102
103
104
105
106
107
  		return;
  	}
  
  	/* use bits 31:14, 16 kB aligned */
  	rcba_base = ioremap_nocache(rcba, 0x4000);
  	if (rcba_base == NULL) {
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
108
109
110
  		dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; "
  			"cannot force enable HPET
  ");
d54bd57d6   Venki Pallipadi   x86: HPET force e...
111
112
113
114
115
116
117
118
119
120
  		return;
  	}
  
  	/* read the Function Disable register, dword mode only */
  	val = readl(rcba_base + 0x3404);
  
  	if (val & 0x80) {
  		/* HPET is enabled in HPTC. Just not reported by BIOS */
  		val = val & 0x3;
  		force_hpet_address = 0xFED00000 | (val << 12);
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
121
122
123
  		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  			"0x%lx
  ", force_hpet_address);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  		iounmap(rcba_base);
  		return;
  	}
  
  	/* HPET disabled in HPTC. Trying to enable */
  	writel(val | 0x80, rcba_base + 0x3404);
  
  	val = readl(rcba_base + 0x3404);
  	if (!(val & 0x80)) {
  		err = 1;
  	} else {
  		val = val & 0x3;
  		force_hpet_address = 0xFED00000 | (val << 12);
  	}
  
  	if (err) {
  		force_hpet_address = 0;
  		iounmap(rcba_base);
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
142
143
144
  		dev_printk(KERN_DEBUG, &dev->dev,
  			"Failed to force enable HPET
  ");
d54bd57d6   Venki Pallipadi   x86: HPET force e...
145
  	} else {
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
146
  		force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
147
148
149
  		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  			"0x%lx
  ", force_hpet_address);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
150
151
152
153
  	}
  }
  
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0,
764922376   Thomas Gleixner   x86: quirk.c triv...
154
  			 ich_force_enable_hpet);
74e411cb6   Krzysztof Oledzki   x86: add another ...
155
156
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0,
  			 ich_force_enable_hpet);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
157
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1,
764922376   Thomas Gleixner   x86: quirk.c triv...
158
  			 ich_force_enable_hpet);
ed6fb174e   Venki Pallipadi   x86: HPET add ano...
159
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0,
764922376   Thomas Gleixner   x86: quirk.c triv...
160
  			 ich_force_enable_hpet);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
161
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1,
764922376   Thomas Gleixner   x86: quirk.c triv...
162
  			 ich_force_enable_hpet);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
163
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31,
764922376   Thomas Gleixner   x86: quirk.c triv...
164
  			 ich_force_enable_hpet);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
165
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1,
764922376   Thomas Gleixner   x86: quirk.c triv...
166
  			 ich_force_enable_hpet);
bacbe9994   Janne Kulmala   x86: enable HPET ...
167
168
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_4,
  			 ich_force_enable_hpet);
dff244af0   Alistair John Strachan   x86: force enable...
169
170
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_7,
  			 ich_force_enable_hpet);
42bb8cc5e   Andi Kleen   x86: hpet: allow ...
171
172
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x3a16,	/* ICH10 */
  			 ich_force_enable_hpet);
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
173
174
  
  static struct pci_dev *cached_dev;
7c4728f4a   Thomas Gleixner   x86: print info a...
175
176
177
178
179
180
  static void hpet_print_force_info(void)
  {
  	printk(KERN_INFO "HPET not enabled in BIOS. "
  	       "You might try hpet=force boot option
  ");
  }
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
  static void old_ich_force_hpet_resume(void)
  {
  	u32 val;
  	u32 uninitialized_var(gen_cntl);
  
  	if (!force_hpet_address || !cached_dev)
  		return;
  
  	pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
  	gen_cntl &= (~(0x7 << 15));
  	gen_cntl |= (0x4 << 15);
  
  	pci_write_config_dword(cached_dev, 0xD0, gen_cntl);
  	pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
  	val = gen_cntl >> 15;
  	val &= 0x7;
  	if (val == 0x4)
  		printk(KERN_DEBUG "Force enabled HPET at resume
  ");
  	else
  		BUG();
  }
  
  static void old_ich_force_enable_hpet(struct pci_dev *dev)
  {
  	u32 val;
  	u32 uninitialized_var(gen_cntl);
  
  	if (hpet_address || force_hpet_address)
  		return;
  
  	pci_read_config_dword(dev, 0xD0, &gen_cntl);
  	/*
  	 * Bit 17 is HPET enable bit.
  	 * Bit 16:15 control the HPET base address.
  	 */
  	val = gen_cntl >> 15;
  	val &= 0x7;
  	if (val & 0x4) {
  		val &= 0x3;
  		force_hpet_address = 0xFED00000 | (val << 12);
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
222
223
224
  		dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx
  ",
  			force_hpet_address);
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
  		return;
  	}
  
  	/*
  	 * HPET is disabled. Trying enabling at FED00000 and check
  	 * whether it sticks
  	 */
  	gen_cntl &= (~(0x7 << 15));
  	gen_cntl |= (0x4 << 15);
  	pci_write_config_dword(dev, 0xD0, gen_cntl);
  
  	pci_read_config_dword(dev, 0xD0, &gen_cntl);
  
  	val = gen_cntl >> 15;
  	val &= 0x7;
  	if (val & 0x4) {
  		/* HPET is enabled in HPTC. Just not reported by BIOS */
  		val &= 0x3;
  		force_hpet_address = 0xFED00000 | (val << 12);
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
244
245
246
  		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  			"0x%lx
  ", force_hpet_address);
32a2da64c   Venki Pallipadi   x86: HPET force e...
247
  		cached_dev = dev;
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
248
249
250
  		force_hpet_resume_type = OLD_ICH_FORCE_HPET_RESUME;
  		return;
  	}
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
251
252
  	dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET
  ");
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
253
  }
158ad3260   Udo A. Steinberg   x86: enable HPET ...
254
255
256
257
258
259
260
261
262
  /*
   * Undocumented chipset features. Make sure that the user enforced
   * this.
   */
  static void old_ich_force_enable_hpet_user(struct pci_dev *dev)
  {
  	if (hpet_force_user)
  		old_ich_force_enable_hpet(dev);
  }
4c2a997c3   Joe Buehler   x86: add PCI ID f...
263
264
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,
  			 old_ich_force_enable_hpet_user);
158ad3260   Udo A. Steinberg   x86: enable HPET ...
265
266
267
268
269
270
271
272
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,
  			 old_ich_force_enable_hpet_user);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
  			 old_ich_force_enable_hpet_user);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
  			 old_ich_force_enable_hpet_user);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,
  			 old_ich_force_enable_hpet_user);
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
273
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,
764922376   Thomas Gleixner   x86: quirk.c triv...
274
  			 old_ich_force_enable_hpet);
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
275
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_12,
764922376   Thomas Gleixner   x86: quirk.c triv...
276
  			 old_ich_force_enable_hpet);
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
277

b196884e2   Udo A. Steinberg   x86: force enable...
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
  
  static void vt8237_force_hpet_resume(void)
  {
  	u32 val;
  
  	if (!force_hpet_address || !cached_dev)
  		return;
  
  	val = 0xfed00000 | 0x80;
  	pci_write_config_dword(cached_dev, 0x68, val);
  
  	pci_read_config_dword(cached_dev, 0x68, &val);
  	if (val & 0x80)
  		printk(KERN_DEBUG "Force enabled HPET at resume
  ");
  	else
  		BUG();
  }
  
  static void vt8237_force_enable_hpet(struct pci_dev *dev)
  {
  	u32 uninitialized_var(val);
7c4728f4a   Thomas Gleixner   x86: print info a...
300
301
302
303
304
  	if (hpet_address || force_hpet_address)
  		return;
  
  	if (!hpet_force_user) {
  		hpet_print_force_info();
b196884e2   Udo A. Steinberg   x86: force enable...
305
  		return;
7c4728f4a   Thomas Gleixner   x86: print info a...
306
  	}
b196884e2   Udo A. Steinberg   x86: force enable...
307
308
309
310
311
312
313
314
  
  	pci_read_config_dword(dev, 0x68, &val);
  	/*
  	 * Bit 7 is HPET enable bit.
  	 * Bit 31:10 is HPET base address (contrary to what datasheet claims)
  	 */
  	if (val & 0x80) {
  		force_hpet_address = (val & ~0x3ff);
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
315
316
317
  		dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx
  ",
  			force_hpet_address);
b196884e2   Udo A. Steinberg   x86: force enable...
318
319
320
321
322
323
324
325
326
327
328
329
330
  		return;
  	}
  
  	/*
  	 * HPET is disabled. Trying enabling at FED00000 and check
  	 * whether it sticks
  	 */
  	val = 0xfed00000 | 0x80;
  	pci_write_config_dword(dev, 0x68, val);
  
  	pci_read_config_dword(dev, 0x68, &val);
  	if (val & 0x80) {
  		force_hpet_address = (val & ~0x3ff);
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
331
332
333
  		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  			"0x%lx
  ", force_hpet_address);
b196884e2   Udo A. Steinberg   x86: force enable...
334
335
336
337
  		cached_dev = dev;
  		force_hpet_resume_type = VT8237_FORCE_HPET_RESUME;
  		return;
  	}
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
338
339
  	dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET
  ");
b196884e2   Udo A. Steinberg   x86: force enable...
340
341
342
343
344
345
  }
  
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
  			 vt8237_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
  			 vt8237_force_enable_hpet);
892df7f81   Udo van den Heuvel   x86: HPET force e...
346
347
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700,
  			 vt8237_force_enable_hpet);
b196884e2   Udo A. Steinberg   x86: force enable...
348

e8aa4667b   Andreas Herrmann   x86: enable hpet=...
349
350
351
352
353
354
  static void ati_force_hpet_resume(void)
  {
  	pci_write_config_dword(cached_dev, 0x14, 0xfed00000);
  	printk(KERN_DEBUG "Force enabled HPET at resume
  ");
  }
e7250b8ae   Andreas Herrmann   x86: hpet: modify...
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
  static u32 ati_ixp4x0_rev(struct pci_dev *dev)
  {
  	u32 d;
  	u8  b;
  
  	pci_read_config_byte(dev, 0xac, &b);
  	b &= ~(1<<5);
  	pci_write_config_byte(dev, 0xac, b);
  	pci_read_config_dword(dev, 0x70, &d);
  	d |= 1<<8;
  	pci_write_config_dword(dev, 0x70, d);
  	pci_read_config_dword(dev, 0x8, &d);
  	d &= 0xff;
  	dev_printk(KERN_DEBUG, &dev->dev, "SB4X0 revision 0x%x
  ", d);
  	return d;
  }
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
372
373
  static void ati_force_enable_hpet(struct pci_dev *dev)
  {
e7250b8ae   Andreas Herrmann   x86: hpet: modify...
374
375
  	u32 d, val;
  	u8  b;
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
376

7c4728f4a   Thomas Gleixner   x86: print info a...
377
378
379
380
381
  	if (hpet_address || force_hpet_address)
  		return;
  
  	if (!hpet_force_user) {
  		hpet_print_force_info();
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
382
  		return;
7c4728f4a   Thomas Gleixner   x86: print info a...
383
  	}
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
384

e7250b8ae   Andreas Herrmann   x86: hpet: modify...
385
386
387
388
389
  	d = ati_ixp4x0_rev(dev);
  	if (d  < 0x82)
  		return;
  
  	/* base address */
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
390
391
  	pci_write_config_dword(dev, 0x14, 0xfed00000);
  	pci_read_config_dword(dev, 0x14, &val);
e7250b8ae   Andreas Herrmann   x86: hpet: modify...
392
393
394
395
396
397
398
399
400
401
402
403
404
405
  
  	/* enable interrupt */
  	outb(0x72, 0xcd6); b = inb(0xcd7);
  	b |= 0x1;
  	outb(0x72, 0xcd6); outb(b, 0xcd7);
  	outb(0x72, 0xcd6); b = inb(0xcd7);
  	if (!(b & 0x1))
  		return;
  	pci_read_config_dword(dev, 0x64, &d);
  	d |= (1<<10);
  	pci_write_config_dword(dev, 0x64, d);
  	pci_read_config_dword(dev, 0x64, &d);
  	if (!(d & (1<<10)))
  		return;
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
406
407
408
409
410
411
  	force_hpet_address = val;
  	force_hpet_resume_type = ATI_FORCE_HPET_RESUME;
  	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx
  ",
  		   force_hpet_address);
  	cached_dev = dev;
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
412
413
414
  }
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
  			 ati_force_enable_hpet);
d79a5f80d   Carlos Corbacho   x86: Force enable...
415
416
417
418
419
420
421
422
423
424
425
426
427
  /*
   * Undocumented chipset feature taken from LinuxBIOS.
   */
  static void nvidia_force_hpet_resume(void)
  {
  	pci_write_config_dword(cached_dev, 0x44, 0xfed00001);
  	printk(KERN_DEBUG "Force enabled HPET at resume
  ");
  }
  
  static void nvidia_force_enable_hpet(struct pci_dev *dev)
  {
  	u32 uninitialized_var(val);
7c4728f4a   Thomas Gleixner   x86: print info a...
428
429
430
431
432
  	if (hpet_address || force_hpet_address)
  		return;
  
  	if (!hpet_force_user) {
  		hpet_print_force_info();
d79a5f80d   Carlos Corbacho   x86: Force enable...
433
  		return;
7c4728f4a   Thomas Gleixner   x86: print info a...
434
  	}
d79a5f80d   Carlos Corbacho   x86: Force enable...
435
436
437
438
439
  
  	pci_write_config_dword(dev, 0x44, 0xfed00001);
  	pci_read_config_dword(dev, 0x44, &val);
  	force_hpet_address = val & 0xfffffffe;
  	force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
9ed885541   bjorn.helgaas@hp.com   PCI: use dev_prin...
440
441
  	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx
  ",
d79a5f80d   Carlos Corbacho   x86: Force enable...
442
443
444
445
446
447
448
449
450
451
  		force_hpet_address);
  	cached_dev = dev;
  	return;
  }
  
  /* ISA Bridges */
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
  			nvidia_force_enable_hpet);
b196884e2   Udo A. Steinberg   x86: force enable...
452

1b82ba6e4   Carlos Corbacho   x86: Add HPET for...
453
  /* LPC bridges */
96bcf458c   Zbigniew Luszpinski   x86: hpet clock e...
454
455
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0260,
  			nvidia_force_enable_hpet);
1b82ba6e4   Carlos Corbacho   x86: Add HPET for...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0360,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0361,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0362,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0363,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0364,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0365,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0366,
  			nvidia_force_enable_hpet);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0367,
  			nvidia_force_enable_hpet);
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
472
473
474
  void force_hpet_resume(void)
  {
  	switch (force_hpet_resume_type) {
4a5a77d10   Harvey Harrison   x86: trivial spar...
475
476
477
478
479
480
481
482
483
484
485
486
  	case ICH_FORCE_HPET_RESUME:
  		ich_force_hpet_resume();
  		return;
  	case OLD_ICH_FORCE_HPET_RESUME:
  		old_ich_force_hpet_resume();
  		return;
  	case VT8237_FORCE_HPET_RESUME:
  		vt8237_force_hpet_resume();
  		return;
  	case NVIDIA_FORCE_HPET_RESUME:
  		nvidia_force_hpet_resume();
  		return;
e8aa4667b   Andreas Herrmann   x86: enable hpet=...
487
488
489
  	case ATI_FORCE_HPET_RESUME:
  		ati_force_hpet_resume();
  		return;
4a5a77d10   Harvey Harrison   x86: trivial spar...
490
  	default:
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
491
492
493
  		break;
  	}
  }
73472a46b   Pallipadi, Venkatesh   x86: Disable HPET...
494
495
496
497
  
  /*
   * HPET MSI on some boards (ATI SB700/SB800) has side effect on
   * floppy DMA. Disable HPET MSI on such platforms.
fec84e330   Andreas Herrmann   x86, hpet: Add re...
498
499
500
   * See erratum #27 (Misinterpreted MSI Requests May Result in
   * Corrupted LPC DMA Data) in AMD Publication #46837,
   * "SB700 Family Product Errata", Rev. 1.0, March 2010.
73472a46b   Pallipadi, Venkatesh   x86: Disable HPET...
501
502
503
504
505
506
507
508
   */
  static void force_disable_hpet_msi(struct pci_dev *unused)
  {
  	hpet_msi_disable = 1;
  }
  
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
  			 force_disable_hpet_msi);
9b94b3a19   Andreas Herrmann   x86: fixup numa_n...
509
510
511
512
513
514
515
516
  #endif
  
  #if defined(CONFIG_PCI) && defined(CONFIG_NUMA)
  /* Set correct numa_node information for AMD NB functions */
  static void __init quirk_amd_nb_node(struct pci_dev *dev)
  {
  	struct pci_dev *nb_ht;
  	unsigned int devfn;
303fc0870   Prarit Bhargava   x86: AMD Northbri...
517
  	u32 node;
9b94b3a19   Andreas Herrmann   x86: fixup numa_n...
518
519
520
521
522
523
524
525
  	u32 val;
  
  	devfn = PCI_DEVFN(PCI_SLOT(dev->devfn), 0);
  	nb_ht = pci_get_slot(dev->bus, devfn);
  	if (!nb_ht)
  		return;
  
  	pci_read_config_dword(nb_ht, 0x60, &val);
303fc0870   Prarit Bhargava   x86: AMD Northbri...
526
527
528
529
530
531
532
  	node = val & 7;
  	/*
  	 * Some hardware may return an invalid node ID,
  	 * so check it first:
  	 */
  	if (node_online(node))
  		set_dev_node(&dev->dev, node);
748df9a4c   Jiri Slaby   x86/PCI: pci quir...
533
  	pci_dev_put(nb_ht);
9b94b3a19   Andreas Herrmann   x86: fixup numa_n...
534
  }
bfe0c1cc6   Venki Pallipadi   x86: HPET force e...
535

9b94b3a19   Andreas Herrmann   x86: fixup numa_n...
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MEMCTL,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_HT,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MAP,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_DRAM,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_LINK,
  			quirk_amd_nb_node);
f62ef5f3e   Andreas Herrmann   x86, amd: Fix up ...
554
555
556
557
558
559
560
561
562
563
564
565
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F0,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F1,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F2,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F3,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F4,
  			quirk_amd_nb_node);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F5,
  			quirk_amd_nb_node);
d54bd57d6   Venki Pallipadi   x86: HPET force e...
566
  #endif