1 #include <linux/config.h>
2 #include <linux/types.h>
3 #include <linux/kernel.h>
4 #include <linux/string.h>
5 #include <linux/init.h>
6 #include <linux/apm_bios.h>
7 #include <linux/slab.h>
8 #include <asm/acpi.h>
9 #include <asm/io.h>
10 #include <linux/pm.h>
11 #include <asm/keyboard.h>
12 #include <asm/system.h>
13 #include <linux/bootmem.h>
14 
15 #include "pci-i386.h"
16 
17 unsigned long dmi_broken;
18 int is_sony_vaio_laptop;
19 
20 struct dmi_header
21 {
22 	u8	type;
23 	u8	length;
24 	u16	handle;
25 };
26 
27 #ifdef DMI_DEBUG
28 #define dmi_printk(x) printk x
29 #else
30 #define dmi_printk(x)
31 #endif
32 
dmi_string(struct dmi_header * dm,u8 s)33 static char * __init dmi_string(struct dmi_header *dm, u8 s)
34 {
35 	u8 *bp=(u8 *)dm;
36 	bp+=dm->length;
37 	if(!s)
38 		return "";
39 	s--;
40 	while(s>0 && *bp)
41 	{
42 		bp+=strlen(bp);
43 		bp++;
44 		s--;
45 	}
46 	return bp;
47 }
48 
49 /*
50  *	We have to be cautious here. We have seen BIOSes with DMI pointers
51  *	pointing to completely the wrong place for example
52  */
53 
dmi_table(u32 base,int len,int num,void (* decode)(struct dmi_header *))54 static int __init dmi_table(u32 base, int len, int num, void (*decode)(struct dmi_header *))
55 {
56 	u8 *buf;
57 	struct dmi_header *dm;
58 	u8 *data;
59 	int i=0;
60 
61 	buf = bt_ioremap(base, len);
62 	if(buf==NULL)
63 		return -1;
64 
65 	data = buf;
66 
67 	/*
68  	 *	Stop when we see all the items the table claimed to have
69  	 *	OR we run off the end of the table (also happens)
70  	 */
71 
72 	while(i<num && data-buf+sizeof(struct dmi_header)<=len)
73 	{
74 		dm=(struct dmi_header *)data;
75 		/*
76 		 *  We want to know the total length (formated area and strings)
77 		 *  before decoding to make sure we won't run off the table in
78 		 *  dmi_decode or dmi_string
79 		 */
80 		data+=dm->length;
81 		while(data-buf<len-1 && (data[0] || data[1]))
82 			data++;
83 		if(data-buf<len-1)
84 			decode(dm);
85 		data+=2;
86 		i++;
87 	}
88 	bt_iounmap(buf, len);
89 	return 0;
90 }
91 
92 
dmi_checksum(u8 * buf)93 inline static int __init dmi_checksum(u8 *buf)
94 {
95 	u8 sum=0;
96 	int a;
97 
98 	for(a=0; a<15; a++)
99 		sum+=buf[a];
100 	return (sum==0);
101 }
102 
dmi_iterate(void (* decode)(struct dmi_header *))103 static int __init dmi_iterate(void (*decode)(struct dmi_header *))
104 {
105 	u8 buf[15];
106 	u32 fp=0xF0000;
107 
108 	while( fp < 0xFFFFF)
109 	{
110 		isa_memcpy_fromio(buf, fp, 15);
111 		if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf))
112 		{
113 			u16 num=buf[13]<<8|buf[12];
114 			u16 len=buf[7]<<8|buf[6];
115 			u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
116 
117 			/*
118 			 * DMI version 0.0 means that the real version is taken from
119 			 * the SMBIOS version, which we don't know at this point.
120 			 */
121 			if(buf[14]!=0)
122 				dmi_printk((KERN_INFO "DMI %d.%d present.\n",
123 					buf[14]>>4, buf[14]&0x0F));
124 			else
125 				dmi_printk((KERN_INFO "DMI present.\n"));
126 			dmi_printk((KERN_INFO "%d structures occupying %d bytes.\n",
127 				num, len));
128 			dmi_printk((KERN_INFO "DMI table at 0x%08X.\n",
129 				base));
130 			if(dmi_table(base,len, num, decode)==0)
131 				return 0;
132 		}
133 		fp+=16;
134 	}
135 	return -1;
136 }
137 
138 
139 enum
140 {
141 	DMI_BIOS_VENDOR,
142 	DMI_BIOS_VERSION,
143 	DMI_BIOS_DATE,
144 	DMI_SYS_VENDOR,
145 	DMI_PRODUCT_NAME,
146 	DMI_PRODUCT_VERSION,
147 	DMI_BOARD_VENDOR,
148 	DMI_BOARD_NAME,
149 	DMI_BOARD_VERSION,
150 	DMI_STRING_MAX
151 };
152 
153 static char *dmi_ident[DMI_STRING_MAX];
154 
155 /*
156  *	Save a DMI string
157  */
158 
dmi_save_ident(struct dmi_header * dm,int slot,int string)159 static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
160 {
161 	char *d = (char*)dm;
162 	char *p = dmi_string(dm, d[string]);
163 	if(p==NULL || *p == 0)
164 		return;
165 	if (dmi_ident[slot])
166 		return;
167 	dmi_ident[slot] = alloc_bootmem(strlen(p)+1);
168 	if(dmi_ident[slot])
169 		strcpy(dmi_ident[slot], p);
170 	else
171 		printk(KERN_ERR "dmi_save_ident: out of memory.\n");
172 }
173 
174 /*
175  *	DMI callbacks for problem boards
176  */
177 
178 struct dmi_strmatch
179 {
180 	u8 slot;
181 	char *substr;
182 };
183 
184 #define NONE	255
185 
186 struct dmi_blacklist
187 {
188 	int (*callback)(struct dmi_blacklist *);
189 	char *ident;
190 	struct dmi_strmatch matches[4];
191 };
192 
193 #define NO_MATCH	{ NONE, NULL}
194 #define MATCH(a,b)	{ a, b }
195 
196 /*
197  *	We have problems with IDE DMA on some platforms. In paticular the
198  *	KT7 series. On these it seems the newer BIOS has fixed them. The
199  *	rule needs to be improved to match specific BIOS revisions with
200  *	corruption problems
201 
202 static __init int disable_ide_dma(struct dmi_blacklist *d)
203 {
204 #ifdef CONFIG_BLK_DEV_IDE
205 	extern int noautodma;
206 	if(noautodma == 0)
207 	{
208 		noautodma = 1;
209 		printk(KERN_INFO "%s series board detected. Disabling IDE DMA.\n", d->ident);
210 	}
211 #endif
212 	return 0;
213 }
214  */
215 
216 /*
217  * Reboot options and system auto-detection code provided by
218  * Dell Computer Corporation so their systems "just work". :-)
219  */
220 
221 /*
222  * Some machines require the "reboot=b"  commandline option, this quirk makes that automatic.
223  */
set_bios_reboot(struct dmi_blacklist * d)224 static __init int set_bios_reboot(struct dmi_blacklist *d)
225 {
226 	extern int reboot_thru_bios;
227 	if (reboot_thru_bios == 0)
228 	{
229 		reboot_thru_bios = 1;
230 		printk(KERN_INFO "%s series board detected. Selecting BIOS-method for reboots.\n", d->ident);
231 	}
232 	return 0;
233 }
234 
235 /*
236  * Some machines require the "reboot=s"  commandline option, this quirk makes that automatic.
237  */
set_smp_reboot(struct dmi_blacklist * d)238 static __init int set_smp_reboot(struct dmi_blacklist *d)
239 {
240 #ifdef CONFIG_SMP
241 	extern int reboot_smp;
242 	if (reboot_smp == 0)
243 	{
244 		reboot_smp = 1;
245 		printk(KERN_INFO "%s series board detected. Selecting SMP-method for reboots.\n", d->ident);
246 	}
247 #endif
248 	return 0;
249 }
250 
251 /*
252  * Some machines require the "reboot=b,s"  commandline option, this quirk makes that automatic.
253  */
set_smp_bios_reboot(struct dmi_blacklist * d)254 static __init int set_smp_bios_reboot(struct dmi_blacklist *d)
255 {
256 	set_smp_reboot(d);
257 	set_bios_reboot(d);
258 	return 0;
259 }
260 
261 /*
262  * Some bioses have a broken protected mode poweroff and need to use realmode
263  */
264 
set_realmode_power_off(struct dmi_blacklist * d)265 static __init int set_realmode_power_off(struct dmi_blacklist *d)
266 {
267        if (apm_info.realmode_power_off == 0)
268        {
269                apm_info.realmode_power_off = 1;
270                printk(KERN_INFO "%s bios detected. Using realmode poweroff only.\n", d->ident);
271        }
272        return 0;
273 }
274 
275 
276 /*
277  * Some laptops require interrupts to be enabled during APM calls
278  */
279 
set_apm_ints(struct dmi_blacklist * d)280 static __init int set_apm_ints(struct dmi_blacklist *d)
281 {
282 	if (apm_info.allow_ints == 0)
283 	{
284 		apm_info.allow_ints = 1;
285 		printk(KERN_INFO "%s machine detected. Enabling interrupts during APM calls.\n", d->ident);
286 	}
287 	return 0;
288 }
289 
290 /*
291  * Some APM bioses corrupt memory or just plain do not work
292  */
293 
apm_is_horked(struct dmi_blacklist * d)294 static __init int apm_is_horked(struct dmi_blacklist *d)
295 {
296 	if (apm_info.disabled == 0)
297 	{
298 		apm_info.disabled = 1;
299 		printk(KERN_INFO "%s machine detected. Disabling APM.\n", d->ident);
300 	}
301 	return 0;
302 }
303 
apm_is_horked_d850md(struct dmi_blacklist * d)304 static __init int apm_is_horked_d850md(struct dmi_blacklist *d)
305 {
306 	if (apm_info.disabled == 0)
307 	{
308 		apm_info.disabled = 1;
309 		printk(KERN_ERR "%s machine detected. Disabling APM.\n", d->ident);
310 		printk(KERN_ERR "This bug is fixed in bios P15 which is available for \n");
311 		printk(KERN_ERR "download from support.intel.com \n");
312 	}
313 	return 0;
314 }
315 
316 /*
317  * Some APM bioses hang on APM idle calls
318  */
319 
apm_likes_to_melt(struct dmi_blacklist * d)320 static __init int apm_likes_to_melt(struct dmi_blacklist *d)
321 {
322 	if (apm_info.forbid_idle == 0)
323 	{
324 		apm_info.forbid_idle = 1;
325 		printk(KERN_INFO "%s machine detected. Disabling APM idle calls.\n", d->ident);
326 	}
327 	return 0;
328 }
329 
330 /*
331  *  Check for clue free BIOS implementations who use
332  *  the following QA technique
333  *
334  *      [ Write BIOS Code ]<------
335  *               |                ^
336  *      < Does it Compile >----N--
337  *               |Y               ^
338  *	< Does it Boot Win98 >-N--
339  *               |Y
340  *           [Ship It]
341  *
342  *	Phoenix A04  08/24/2000 is known bad (Dell Inspiron 5000e)
343  *	Phoenix A07  09/29/2000 is known good (Dell Inspiron 5000)
344  */
345 
broken_apm_power(struct dmi_blacklist * d)346 static __init int broken_apm_power(struct dmi_blacklist *d)
347 {
348 	apm_info.get_power_status_broken = 1;
349 	printk(KERN_WARNING "BIOS strings suggest APM bugs, disabling power status reporting.\n");
350 	return 0;
351 }
352 
353 /*
354  * Check for a Sony Vaio system
355  *
356  * On a Sony system we want to enable the use of the sonypi
357  * driver for Sony-specific goodies like the camera and jogdial.
358  * We also want to avoid using certain functions of the PnP BIOS.
359  */
360 
sony_vaio_laptop(struct dmi_blacklist * d)361 static __init int sony_vaio_laptop(struct dmi_blacklist *d)
362 {
363 	if (is_sony_vaio_laptop == 0)
364 	{
365 		is_sony_vaio_laptop = 1;
366 		printk(KERN_INFO "%s laptop detected.\n", d->ident);
367 	}
368 	return 0;
369 }
370 
371 /*
372  * This bios swaps the APM minute reporting bytes over (Many sony laptops
373  * have this problem).
374  */
375 
swab_apm_power_in_minutes(struct dmi_blacklist * d)376 static __init int swab_apm_power_in_minutes(struct dmi_blacklist *d)
377 {
378 	apm_info.get_power_status_swabinminutes = 1;
379 	printk(KERN_WARNING "BIOS strings suggest APM reports battery life in minutes and wrong byte order.\n");
380 	return 0;
381 }
382 
383 /*
384  * ASUS K7V-RM has broken ACPI table defining sleep modes
385  */
386 
broken_acpi_Sx(struct dmi_blacklist * d)387 static __init int broken_acpi_Sx(struct dmi_blacklist *d)
388 {
389 	printk(KERN_WARNING "Detected ASUS mainboard with broken ACPI sleep table\n");
390 	dmi_broken |= BROKEN_ACPI_Sx;
391 	return 0;
392 }
393 
394 /*
395  * Toshiba fails to preserve interrupts over S1
396  */
397 
init_ints_after_s1(struct dmi_blacklist * d)398 static __init int init_ints_after_s1(struct dmi_blacklist *d)
399 {
400 	printk(KERN_WARNING "Toshiba with broken S1 detected.\n");
401 	dmi_broken |= BROKEN_INIT_AFTER_S1;
402 	return 0;
403 }
404 
405 /*
406  * Some Bioses enable the PS/2 mouse (touchpad) at resume, even if it
407  * was disabled before the suspend. Linux gets terribly confused by that.
408  */
409 
410 typedef void (pm_kbd_func) (void);
411 
broken_ps2_resume(struct dmi_blacklist * d)412 static __init int broken_ps2_resume(struct dmi_blacklist *d)
413 {
414 #if defined(CONFIG_VT) && !defined(CONFIG_DUMMY_KEYB)
415 	if (pm_kbd_request_override == NULL)
416 	{
417 		pm_kbd_request_override = pckbd_pm_resume;
418 		printk(KERN_INFO "%s machine detected. Mousepad Resume Bug workaround enabled.\n", d->ident);
419 	}
420 #endif
421 	return 0;
422 }
423 
424 /*
425  * Work around broken HP Pavilion Notebooks which assign USB to
426  * IRQ 9 even though it is actually wired to IRQ 11
427  */
fix_broken_hp_bios_irq9(struct dmi_blacklist * d)428 static __init int fix_broken_hp_bios_irq9(struct dmi_blacklist *d)
429 {
430 #ifdef CONFIG_PCI
431 	extern int broken_hp_bios_irq9;
432 	if (broken_hp_bios_irq9 == 0)
433 	{
434 		broken_hp_bios_irq9 = 1;
435 		printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", d->ident);
436 	}
437 #endif
438 	return 0;
439 }
440 
441 /*
442  * Work around broken Acer TravelMate 360 Notebooks which assign Cardbus to
443  * IRQ 11 even though it is actually wired to IRQ 10
444  */
fix_acer_tm360_irqrouting(struct dmi_blacklist * d)445 static __init int fix_acer_tm360_irqrouting(struct dmi_blacklist *d)
446 {
447 #ifdef CONFIG_PCI
448 	extern int acer_tm360_irqrouting;
449 	if (acer_tm360_irqrouting == 0) {
450 		acer_tm360_irqrouting = 1;
451 		printk(KERN_INFO "%s detected - fixing broken IRQ routing\n", d->ident);
452 	}
453 #endif
454 	return 0;
455 }
456 
457 /*
458  *	Exploding PnPBIOS. Don't yet know if its the BIOS or us for
459  *	some entries
460  */
461 
exploding_pnp_bios(struct dmi_blacklist * d)462 static __init int exploding_pnp_bios(struct dmi_blacklist *d)
463 {
464 	printk(KERN_WARNING "%s detected. Disabling PnPBIOS\n", d->ident);
465 	dmi_broken |= BROKEN_PNP_BIOS;
466 	return 0;
467 }
468 
469 /*
470  *	Simple "print if true" callback
471  */
472 
print_if_true(struct dmi_blacklist * d)473 static __init int print_if_true(struct dmi_blacklist *d)
474 {
475 	printk("%s\n", d->ident);
476 	return 0;
477 }
478 
479 
480 #ifdef	CONFIG_ACPI_BOOT
481 extern int acpi_force;
482 
dmi_disable_acpi(struct dmi_blacklist * d)483 static __init __attribute__((unused)) int dmi_disable_acpi(struct dmi_blacklist *d)
484 {
485 	if (!acpi_force) {
486 		printk(KERN_NOTICE "%s detected: acpi off\n",d->ident);
487 		disable_acpi();
488 	} else {
489 		printk(KERN_NOTICE
490 		       "Warning: DMI blacklist says broken, but acpi forced\n");
491 	}
492 	return 0;
493 }
494 
495 
496 /*
497  * Limit ACPI to CPU enumeration for HT
498  */
force_acpi_ht(struct dmi_blacklist * d)499 static __init __attribute__((unused)) int force_acpi_ht(struct dmi_blacklist *d)
500 {
501 	if (!acpi_force) {
502 		printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident);
503 		disable_acpi();
504 		acpi_ht = 1;
505 	} else {
506 		printk(KERN_NOTICE
507 		       "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
508 	}
509 	return 0;
510 }
511 #endif	/* CONFIG_ACPI_BOOT */
512 
513 #ifdef	CONFIG_ACPI_PCI
disable_acpi_pci(struct dmi_blacklist * d)514 static __init int disable_acpi_pci(struct dmi_blacklist *d)
515 {
516 	printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", d->ident);
517 	acpi_noirq_set();
518 	return 0;
519 }
520 #endif	/* CONFIG_ACPI_PCI */
521 
522 /*
523  *	Process the DMI blacklists
524  */
525 
526 
527 #ifdef CONFIG_VT
528 /*      IBM bladeservers have a USB console switch. The keyboard type is USB
529  *      and the hardware does not have a console keyboard. We disable the
530  *      console keyboard so the kernel does not try to initialize one and
531  *      spew errors. This can be used for all systems without a console
532  *      keyboard like systems with just a USB or IrDA keyboard.
533  */
disable_console_keyboard(struct dmi_blacklist * d)534 static __init int disable_console_keyboard(struct dmi_blacklist *d)
535 {
536         extern int keyboard_controller_present;
537         printk(KERN_INFO "*** Hardware has no console keyboard controller.\n");
538         printk(KERN_INFO "*** Disabling console keyboard.\n");
539         keyboard_controller_present = 0;
540         return 0;
541 }
542 #endif
543 
544 /*
545  *	This will be expanded over time to force things like the APM
546  *	interrupt mask settings according to the laptop
547  */
548 
549 static __initdata struct dmi_blacklist dmi_blacklist[]={
550 #if 0
551 	{ disable_ide_dma, "KT7", {	/* Overbroad right now - kill DMA on problem KT7 boards */
552 			MATCH(DMI_PRODUCT_NAME, "KT7-RAID"),
553 			NO_MATCH, NO_MATCH, NO_MATCH
554 			} },
555 	{ disable_ide_dma, "Dell Inspiron 8100", {	/* Kill DMA on Dell Inspiron 8100 laptops */
556 			MATCH(DMI_PRODUCT_NAME, "Inspiron 8100"),
557 			MATCH(DMI_SYS_VENDOR,"Dell Computer Corporation"), NO_MATCH, NO_MATCH
558 			} },
559 
560 #endif
561 	/* Dell Laptop hall of shame */
562 	{ broken_ps2_resume, "Dell Latitude C600", {	/* Handle problems with APM on the C600 */
563 		        MATCH(DMI_SYS_VENDOR, "Dell"),
564 			MATCH(DMI_PRODUCT_NAME, "Latitude C600"),
565 			NO_MATCH, NO_MATCH
566 	                } },
567 	{ apm_is_horked, "Dell Inspiron 2500", { /* APM crashes */
568 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
569 			MATCH(DMI_PRODUCT_NAME, "Inspiron 2500"),
570 			MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
571 			MATCH(DMI_BIOS_VERSION,"A11")
572 			} },
573 	{ apm_is_horked, "Dell Dimension 4100", { /* APM crashes */
574 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
575 			MATCH(DMI_PRODUCT_NAME, "XPS-Z"),
576 			MATCH(DMI_BIOS_VENDOR,"Intel Corp."),
577 			MATCH(DMI_BIOS_VERSION,"A11")
578 			} },
579 	{ set_apm_ints, "Dell Inspiron", {	/* Allow interrupts during suspend on Dell Inspiron laptops*/
580 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
581 			MATCH(DMI_PRODUCT_NAME, "Inspiron 4000"),
582 			NO_MATCH, NO_MATCH
583 			} },
584 	{ set_apm_ints, "Dell Latitude", {	/* Allow interrupts during suspend on Dell Latitude laptops*/
585 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
586 			MATCH(DMI_PRODUCT_NAME, "Latitude C510"),
587 			NO_MATCH, NO_MATCH
588 			} },
589 	{ broken_apm_power, "Dell Inspiron 5000e", {	/* Handle problems with APM on Inspiron 5000e */
590 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
591 			MATCH(DMI_BIOS_VERSION, "A04"),
592 			MATCH(DMI_BIOS_DATE, "08/24/2000"), NO_MATCH
593 			} },
594 
595 	/* other items */
596 	{ broken_apm_power, "Dell Inspiron 2500", {	/* Handle problems with APM on Inspiron 2500 */
597 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
598 			MATCH(DMI_BIOS_VERSION, "A12"),
599 			MATCH(DMI_BIOS_DATE, "02/04/2002"), NO_MATCH
600 			} },
601 	{ set_realmode_power_off, "Award Software v4.60 PGMA", {	/* broken PM poweroff bios */
602 			MATCH(DMI_BIOS_VENDOR, "Award Software International, Inc."),
603 			MATCH(DMI_BIOS_VERSION, "4.60 PGMA"),
604 			MATCH(DMI_BIOS_DATE, "134526184"), NO_MATCH
605 			} },
606 	{ set_smp_bios_reboot, "Dell PowerEdge 1300", {	/* Handle problems with rebooting on Dell 1300's */
607 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
608 			MATCH(DMI_PRODUCT_NAME, "PowerEdge 1300/"),
609 			NO_MATCH, NO_MATCH
610 			} },
611 	{ set_bios_reboot, "Dell PowerEdge 300", {	/* Handle problems with rebooting on Dell 1300's */
612 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
613 			MATCH(DMI_PRODUCT_NAME, "PowerEdge 300/"),
614 			NO_MATCH, NO_MATCH
615 			} },
616 	{ set_bios_reboot, "Dell PowerEdge 2400", {  /* Handle problems with rebooting on Dell 2400's */
617 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
618 			MATCH(DMI_PRODUCT_NAME, "PowerEdge 2400"),
619 			NO_MATCH, NO_MATCH
620 			} },
621 	{ set_apm_ints, "Compaq 12XL125", {	/* Allow interrupts during suspend on Compaq Laptops*/
622 			MATCH(DMI_SYS_VENDOR, "Compaq"),
623 			MATCH(DMI_PRODUCT_NAME, "Compaq PC"),
624 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
625 			MATCH(DMI_BIOS_VERSION,"4.06")
626 			} },
627 	{ set_apm_ints, "ASUSTeK", {   /* Allow interrupts during APM or the clock goes slow */
628 			MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
629 			MATCH(DMI_PRODUCT_NAME, "L8400K series Notebook PC"),
630 			NO_MATCH, NO_MATCH
631 			} },
632 	{ apm_is_horked, "ABIT KX7-333[R]", { /* APM blows on shutdown */
633 			MATCH(DMI_BOARD_VENDOR, "ABIT"),
634 			MATCH(DMI_BOARD_NAME, "VT8367-8233A (KX7-333[R])"),
635 			NO_MATCH, NO_MATCH,
636 			} },
637 	{ apm_is_horked, "Trigem Delhi3", { /* APM crashes */
638 			MATCH(DMI_SYS_VENDOR, "TriGem Computer, Inc"),
639 			MATCH(DMI_PRODUCT_NAME, "Delhi3"),
640 			NO_MATCH, NO_MATCH,
641 			} },
642 	{ apm_is_horked, "Fujitsu-Siemens", { /* APM crashes */
643 			MATCH(DMI_BIOS_VENDOR, "hoenix/FUJITSU SIEMENS"),
644 			MATCH(DMI_BIOS_VERSION, "Version1.01"),
645 			NO_MATCH, NO_MATCH,
646 			} },
647 	{ apm_is_horked_d850md, "Intel D850MD", { /* APM crashes */
648 			MATCH(DMI_BIOS_VENDOR, "Intel Corp."),
649 			MATCH(DMI_BIOS_VERSION, "MV85010A.86A.0016.P07.0201251536"),
650 			NO_MATCH, NO_MATCH,
651 			} },
652 	{ apm_is_horked, "Intel D810EMO", { /* APM crashes */
653 			MATCH(DMI_BIOS_VENDOR, "Intel Corp."),
654 			MATCH(DMI_BIOS_VERSION, "MO81010A.86A.0008.P04.0004170800"),
655 			NO_MATCH, NO_MATCH,
656 			} },
657 	{ apm_is_horked, "Dell XPS-Z", { /* APM crashes */
658 			MATCH(DMI_BIOS_VENDOR, "Intel Corp."),
659 			MATCH(DMI_BIOS_VERSION, "A11"),
660 			MATCH(DMI_PRODUCT_NAME, "XPS-Z"),
661 			NO_MATCH,
662 			} },
663 	{ apm_is_horked, "Sharp PC-PJ/AX", { /* APM crashes */
664 			MATCH(DMI_SYS_VENDOR, "SHARP"),
665 			MATCH(DMI_PRODUCT_NAME, "PC-PJ/AX"),
666 			MATCH(DMI_BIOS_VENDOR,"SystemSoft"),
667 			MATCH(DMI_BIOS_VERSION,"Version R2.08")
668 			} },
669 	{ apm_is_horked, "Dell Inspiron 2500", { /* APM crashes */
670 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
671 			MATCH(DMI_PRODUCT_NAME, "Inspiron 2500"),
672 			MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
673 			MATCH(DMI_BIOS_VERSION,"A11")
674 			} },
675 	{ apm_likes_to_melt, "Jabil AMD", { /* APM idle hangs */
676 			MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
677 			MATCH(DMI_BIOS_VERSION, "0AASNP06"),
678 			NO_MATCH, NO_MATCH,
679 			} },
680 	{ apm_likes_to_melt, "AMI Bios", { /* APM idle hangs */
681 			MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
682 			MATCH(DMI_BIOS_VERSION, "0AASNP05"),
683 			NO_MATCH, NO_MATCH,
684 			} },
685 	{ apm_likes_to_melt, "Dell Inspiron 7500", { /* APM idle hangs */
686 			MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
687 			MATCH(DMI_PRODUCT_NAME,  "Inspiron 7500"),
688 			NO_MATCH, NO_MATCH,
689 			} },
690 
691 	{ sony_vaio_laptop, "Sony Vaio", { /* This is a Sony Vaio laptop */
692 			MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
693 			MATCH(DMI_PRODUCT_NAME, "PCG-"),
694 			NO_MATCH, NO_MATCH,
695 			} },
696 	{ swab_apm_power_in_minutes, "Sony VAIO", { /* Handle problems with APM on Sony Vaio PCG-N505X(DE) */
697 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
698 			MATCH(DMI_BIOS_VERSION, "R0206H"),
699 			MATCH(DMI_BIOS_DATE, "08/23/99"), NO_MATCH
700 	} },
701 
702 	{ swab_apm_power_in_minutes, "Sony VAIO", { /* Handle problems with APM on Sony Vaio PCG-N505VX */
703 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
704 			MATCH(DMI_BIOS_VERSION, "W2K06H0"),
705 			MATCH(DMI_BIOS_DATE, "02/03/00"), NO_MATCH
706 			} },
707 
708 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-XG29 */
709 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
710 			MATCH(DMI_BIOS_VERSION, "R0117A0"),
711 			MATCH(DMI_BIOS_DATE, "04/25/00"), NO_MATCH
712 			} },
713 
714 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z600NE */
715 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
716 			MATCH(DMI_BIOS_VERSION, "R0121Z1"),
717 			MATCH(DMI_BIOS_DATE, "05/11/00"), NO_MATCH
718 			} },
719 
720 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z600NE */
721 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
722 			MATCH(DMI_BIOS_VERSION, "WME01Z1"),
723 			MATCH(DMI_BIOS_DATE, "08/11/00"), NO_MATCH
724 			} },
725 
726 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z600LEK(DE) */
727 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
728 			MATCH(DMI_BIOS_VERSION, "R0206Z3"),
729 			MATCH(DMI_BIOS_DATE, "12/25/00"), NO_MATCH
730 			} },
731 
732 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z505LS */
733 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
734 			MATCH(DMI_BIOS_VERSION, "R0203D0"),
735 			MATCH(DMI_BIOS_DATE, "05/12/00"), NO_MATCH
736 			} },
737 
738 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z505LS */
739 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
740 			MATCH(DMI_BIOS_VERSION, "R0203Z3"),
741 			MATCH(DMI_BIOS_DATE, "08/25/00"), NO_MATCH
742 			} },
743 
744 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z505LS (with updated BIOS) */
745 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
746 			MATCH(DMI_BIOS_VERSION, "R0209Z3"),
747 			MATCH(DMI_BIOS_DATE, "05/12/01"), NO_MATCH
748 			} },
749 
750 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z505LS (with updated BIOS) */
751 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
752 			MATCH(DMI_BIOS_VERSION, "WXP01Z3"),
753 			MATCH(DMI_BIOS_DATE, "10/26/01"), NO_MATCH
754 			} },
755 
756 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-F104K */
757 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
758 			MATCH(DMI_BIOS_VERSION, "R0204K2"),
759 			MATCH(DMI_BIOS_DATE, "08/28/00"), NO_MATCH
760 			} },
761 
762 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-C1VN/C1VE */
763 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
764 			MATCH(DMI_BIOS_VERSION, "R0208P1"),
765 			MATCH(DMI_BIOS_DATE, "11/09/00"), NO_MATCH
766 			} },
767 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-C1VE */
768 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
769 			MATCH(DMI_BIOS_VERSION, "R0204P1"),
770 			MATCH(DMI_BIOS_DATE, "09/12/00"), NO_MATCH
771 			} },
772 
773 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z600RE */
774 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
775 			MATCH(DMI_BIOS_VERSION, "R0116Z1"),
776 			NO_MATCH, NO_MATCH
777 			} },
778 
779 	{ swab_apm_power_in_minutes, "Sony VAIO", {	/* Handle problems with APM on Sony Vaio PCG-Z600RE */
780 			MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
781 			MATCH(DMI_BIOS_VERSION, "RK116Z1"),
782 			NO_MATCH, NO_MATCH
783 			} },
784 
785 	{ exploding_pnp_bios, "Higraded P14H", {	/* BIOSPnP problem */
786 			MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
787 			MATCH(DMI_BIOS_VERSION, "07.00T"),
788 			MATCH(DMI_SYS_VENDOR, "Higraded"),
789 			MATCH(DMI_PRODUCT_NAME, "P14H")
790 			} },
791 
792 	{ init_ints_after_s1, "Toshiba Satellite 4030cdt", { /* Reinitialization of 8259 is needed after S1 resume */
793 			MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
794 			NO_MATCH, NO_MATCH, NO_MATCH
795 			} },
796 
797 	{ broken_acpi_Sx, "ASUS K7V-RM", {		/* Bad ACPI Sx table */
798 			MATCH(DMI_BIOS_VERSION,"ASUS K7V-RM ACPI BIOS Revision 1003A"),
799 			MATCH(DMI_BOARD_NAME, "<K7V-RM>"),
800 			NO_MATCH, NO_MATCH
801 			} },
802 
803 	{ print_if_true, KERN_WARNING "IBM T23 - BIOS 1.03b+ and controller firmware 1.02+ may be needed for Linux APM.", {
804 			MATCH(DMI_SYS_VENDOR, "IBM"),
805 			MATCH(DMI_BIOS_VERSION, "1AET38WW (1.01b)"),
806 			NO_MATCH, NO_MATCH
807 			} },
808 
809 	{ fix_broken_hp_bios_irq9, "HP Pavilion N5400 Series Laptop", {
810 			MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
811 			MATCH(DMI_BIOS_VERSION, "GE.M1.03"),
812 			MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook Model GE"),
813 			MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736")
814 			} },
815 
816 	{ fix_acer_tm360_irqrouting, "Acer TravelMate 36x Laptop", {
817 			MATCH(DMI_SYS_VENDOR, "Acer"),
818 			MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
819 			NO_MATCH, NO_MATCH
820 			} },
821 
822 	/*
823 	 *	Generic per vendor APM settings
824 	 */
825 
826 	{ set_apm_ints, "IBM", {	/* Allow interrupts during suspend on IBM laptops */
827 			MATCH(DMI_SYS_VENDOR, "IBM"),
828 			NO_MATCH, NO_MATCH, NO_MATCH
829 			} },
830 #ifdef CONFIG_VT
831         /*
832          *      IBM Bladeservers
833          */
834 
835         { disable_console_keyboard, "IBM Server Blade", {
836                         MATCH(DMI_SYS_VENDOR,"IBM"),
837                         MATCH(DMI_BOARD_NAME, "Server Blade"),
838                         NO_MATCH, NO_MATCH
839                         } },
840 #endif
841 
842 #ifdef	CONFIG_ACPI_BOOT
843 	/*
844 	 * If your system is blacklisted here, but you find that acpi=force
845 	 * works for you, please contact acpi-devel@sourceforge.net
846 	 */
847 
848 	/*
849 	 *	Boxes that need ACPI disabled
850 	 */
851 
852 	{ dmi_disable_acpi, "IBM Thinkpad", {
853 			MATCH(DMI_BOARD_VENDOR, "IBM"),
854 			MATCH(DMI_BOARD_NAME, "2629H1G"),
855 			NO_MATCH, NO_MATCH }},
856 
857 	/*
858 	 *	Boxes that need acpi=ht
859 	 */
860 
861 	{ force_acpi_ht, "FSC Primergy T850", {
862 			MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
863 			MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
864 			NO_MATCH, NO_MATCH }},
865 
866 	{ force_acpi_ht, "DELL GX240", {
867 			MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
868 			MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
869 			NO_MATCH, NO_MATCH }},
870 
871 	{ force_acpi_ht, "HP VISUALIZE NT Workstation", {
872 			MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
873 			MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
874 			NO_MATCH, NO_MATCH }},
875 
876 	{ force_acpi_ht, "Compaq ProLiant DL380 G2", {
877 			MATCH(DMI_SYS_VENDOR, "Compaq"),
878 			MATCH(DMI_PRODUCT_NAME, "ProLiant DL380 G2"),
879 			NO_MATCH, NO_MATCH }},
880 
881 	{ force_acpi_ht, "Compaq ProLiant ML530 G2", {
882 			MATCH(DMI_SYS_VENDOR, "Compaq"),
883 			MATCH(DMI_PRODUCT_NAME, "ProLiant ML530 G2"),
884 			NO_MATCH, NO_MATCH }},
885 
886 	{ force_acpi_ht, "Compaq ProLiant ML350 G3", {
887 			MATCH(DMI_SYS_VENDOR, "Compaq"),
888 			MATCH(DMI_PRODUCT_NAME, "ProLiant ML350 G3"),
889 			NO_MATCH, NO_MATCH }},
890 
891 	{ force_acpi_ht, "Compaq Workstation W8000", {
892 			MATCH(DMI_SYS_VENDOR, "Compaq"),
893 			MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
894 			NO_MATCH, NO_MATCH }},
895 
896 	{ force_acpi_ht, "ASUS P4B266", {
897 			MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
898 			MATCH(DMI_BOARD_NAME, "P4B266"),
899 			NO_MATCH, NO_MATCH }},
900 
901 	{ force_acpi_ht, "ASUS P2B-DS", {
902 			MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
903 			MATCH(DMI_BOARD_NAME, "P2B-DS"),
904 			NO_MATCH, NO_MATCH }},
905 
906 	{ force_acpi_ht, "ASUS CUR-DLS", {
907 			MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
908 			MATCH(DMI_BOARD_NAME, "CUR-DLS"),
909 			NO_MATCH, NO_MATCH }},
910 
911 	{ force_acpi_ht, "ABIT i440BX-W83977", {
912 			MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
913 			MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
914 			NO_MATCH, NO_MATCH }},
915 
916 	{ force_acpi_ht, "IBM Bladecenter", {
917 			MATCH(DMI_BOARD_VENDOR, "IBM"),
918 			MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
919 			NO_MATCH, NO_MATCH }},
920 
921 	{ force_acpi_ht, "IBM eServer xSeries 360", {
922 			MATCH(DMI_BOARD_VENDOR, "IBM"),
923 			MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
924 			NO_MATCH, NO_MATCH }},
925 
926 	{ force_acpi_ht, "IBM eserver xSeries 330", {
927 			MATCH(DMI_BOARD_VENDOR, "IBM"),
928 			MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
929 			NO_MATCH, NO_MATCH }},
930 
931 	{ force_acpi_ht, "IBM eserver xSeries 440", {
932 			MATCH(DMI_BOARD_VENDOR, "IBM"),
933 			MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
934 			NO_MATCH, NO_MATCH }},
935 
936 #endif	/* CONFIG_ACPI_BOOT */
937 #ifdef	CONFIG_ACPI_PCI
938 	/*
939 	 *	Boxes that need ACPI PCI IRQ routing disabled
940 	 */
941 
942 	{ disable_acpi_pci, "ASUS A7V", {
943 			MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
944 			MATCH(DMI_BOARD_NAME, "<A7V>"),
945 			/* newer BIOS, Revision 1011, does work */
946 			MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"),
947 			NO_MATCH }},
948 
949 	{ disable_acpi_pci, "Acer TravelMate 36x Laptop", {
950 			MATCH(DMI_SYS_VENDOR, "Acer"),
951 			MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
952 			NO_MATCH, NO_MATCH
953 			} },
954 
955 #endif	/* CONFIG_ACPI_PCI */
956 
957 	{ NULL, }
958 };
959 
960 
961 /*
962  *	Walk the blacklist table running matching functions until someone
963  *	returns 1 or we hit the end.
964  */
965 
966 
dmi_check_blacklist(void)967 static __init void dmi_check_blacklist(void)
968 {
969 	struct dmi_blacklist *d;
970 	int i;
971 
972 #ifdef  CONFIG_ACPI_BOOT
973 #define	ACPI_BLACKLIST_CUTOFF_YEAR	2001
974 
975 	if (dmi_ident[DMI_BIOS_DATE]) {
976 		char *s = strrchr(dmi_ident[DMI_BIOS_DATE], '/');
977 		if (s) {
978 			int year, disable = 0;
979 			s++;
980 			year = simple_strtoul(s,NULL,10);
981 			if (year >= 1000)
982 				disable = year < ACPI_BLACKLIST_CUTOFF_YEAR;
983 			else if (year < 1 || (year > 90 && year <= 99))
984 				disable = 1;
985 			if (disable && !acpi_force) {
986 				printk(KERN_NOTICE "ACPI disabled because your bios is from %s and too old\n", s);
987 				printk(KERN_NOTICE "You can enable it with acpi=force\n");
988 				disable_acpi();
989 			}
990 		}
991 	}
992 #endif
993 
994 	d=&dmi_blacklist[0];
995 	while(d->callback)
996 	{
997 		for(i=0;i<4;i++)
998 		{
999 			int s = d->matches[i].slot;
1000 			if(s==NONE)
1001 				continue;
1002 			if(dmi_ident[s] && strstr(dmi_ident[s], d->matches[i].substr))
1003 				continue;
1004 			/* No match */
1005 			goto fail;
1006 		}
1007 		if(d->callback(d))
1008 			return;
1009 fail:
1010 		d++;
1011 	}
1012 }
1013 
1014 
1015 
1016 /*
1017  *	Process a DMI table entry. Right now all we care about are the BIOS
1018  *	and machine entries. For 2.5 we should pull the smbus controller info
1019  *	out of here.
1020  */
1021 
dmi_decode(struct dmi_header * dm)1022 static void __init dmi_decode(struct dmi_header *dm)
1023 {
1024 #ifdef	DMI_DEBUG
1025 	u8 *data = (u8 *)dm;
1026 #endif
1027 	switch(dm->type)
1028 	{
1029 		case  0:
1030 			dmi_printk(("BIOS Vendor: %s\n",
1031 				dmi_string(dm, data[4])));
1032 			dmi_save_ident(dm, DMI_BIOS_VENDOR, 4);
1033 			dmi_printk(("BIOS Version: %s\n",
1034 				dmi_string(dm, data[5])));
1035 			dmi_save_ident(dm, DMI_BIOS_VERSION, 5);
1036 			dmi_printk(("BIOS Release: %s\n",
1037 				dmi_string(dm, data[8])));
1038 			dmi_save_ident(dm, DMI_BIOS_DATE, 8);
1039 			break;
1040 		case 1:
1041 			dmi_printk(("System Vendor: %s\n",
1042 				dmi_string(dm, data[4])));
1043 			dmi_save_ident(dm, DMI_SYS_VENDOR, 4);
1044 			dmi_printk(("Product Name: %s\n",
1045 				dmi_string(dm, data[5])));
1046 			dmi_save_ident(dm, DMI_PRODUCT_NAME, 5);
1047 			dmi_printk(("Version: %s\n",
1048 				dmi_string(dm, data[6])));
1049 			dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6);
1050 			dmi_printk(("Serial Number: %s\n",
1051 				dmi_string(dm, data[7])));
1052 			break;
1053 		case 2:
1054 			dmi_printk(("Board Vendor: %s\n",
1055 				dmi_string(dm, data[4])));
1056 			dmi_save_ident(dm, DMI_BOARD_VENDOR, 4);
1057 			dmi_printk(("Board Name: %s\n",
1058 				dmi_string(dm, data[5])));
1059 			dmi_save_ident(dm, DMI_BOARD_NAME, 5);
1060 			dmi_printk(("Board Version: %s\n",
1061 				dmi_string(dm, data[6])));
1062 			dmi_save_ident(dm, DMI_BOARD_VERSION, 6);
1063 			break;
1064 	}
1065 }
1066 
dmi_scan_machine(void)1067 void __init dmi_scan_machine(void)
1068 {
1069 	int err = dmi_iterate(dmi_decode);
1070 	if(err == 0)
1071 		dmi_check_blacklist();
1072 	else
1073 		printk(KERN_INFO "DMI not present.\n");
1074 }
1075 
1076