blob: bd49321034db775a486279fbdf8948a1b9392401 [file] [log] [blame]
Rene Hermanb02aae92008-01-30 13:30:05 +01001/*
2 * I/O delay strategies for inb_p/outb_p
Ingo Molnar6e7c4022008-01-30 13:30:05 +01003 *
4 * Allow for a DMI based override of port 0x80, needed for certain HP laptops
5 * and possibly other systems. Also allow for the gradual elimination of
6 * outb_p/inb_p API uses.
Rene Hermanb02aae92008-01-30 13:30:05 +01007 */
8#include <linux/kernel.h>
9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/delay.h>
12#include <linux/dmi.h>
13#include <asm/io.h>
14
Ingo Molnar6e7c4022008-01-30 13:30:05 +010015int io_delay_type __read_mostly = CONFIG_DEFAULT_IO_DELAY_TYPE;
16EXPORT_SYMBOL_GPL(io_delay_type);
Rene Hermanb02aae92008-01-30 13:30:05 +010017
Ingo Molnar6e7c4022008-01-30 13:30:05 +010018static int __initdata io_delay_override;
Rene Hermanb02aae92008-01-30 13:30:05 +010019
20/*
21 * Paravirt wants native_io_delay to be a constant.
22 */
23void native_io_delay(void)
24{
Ingo Molnar6e7c4022008-01-30 13:30:05 +010025 switch (io_delay_type) {
26 default:
27 case CONFIG_IO_DELAY_TYPE_0X80:
28 asm volatile ("outb %al, $0x80");
29 break;
30 case CONFIG_IO_DELAY_TYPE_0XED:
31 asm volatile ("outb %al, $0xed");
32 break;
33 case CONFIG_IO_DELAY_TYPE_UDELAY:
34 /*
35 * 2 usecs is an upper-bound for the outb delay but
36 * note that udelay doesn't have the bus-level
37 * side-effects that outb does, nor does udelay() have
38 * precise timings during very early bootup (the delays
39 * are shorter until calibrated):
40 */
41 udelay(2);
42 case CONFIG_IO_DELAY_TYPE_NONE:
43 break;
44 }
Rene Hermanb02aae92008-01-30 13:30:05 +010045}
46EXPORT_SYMBOL(native_io_delay);
47
Ingo Molnar6e7c4022008-01-30 13:30:05 +010048static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
Rene Hermanb02aae92008-01-30 13:30:05 +010049{
Ingo Molnar6e7c4022008-01-30 13:30:05 +010050 if (io_delay_type == CONFIG_IO_DELAY_TYPE_0X80) {
51 printk(KERN_NOTICE "%s: using 0xed I/O delay port\n",
52 id->ident);
53 io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
54 }
55
Rene Hermanb02aae92008-01-30 13:30:05 +010056 return 0;
57}
58
Ingo Molnar6e7c4022008-01-30 13:30:05 +010059/*
60 * Quirk table for systems that misbehave (lock up, etc.) if port
61 * 0x80 is used:
62 */
63static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
Rene Hermanb02aae92008-01-30 13:30:05 +010064 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +010065 .callback = dmi_io_delay_0xed_port,
Ingo Molnarf9fc5892008-01-30 13:30:05 +010066 .ident = "Compaq Presario V6000",
67 .matches = {
68 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
69 DMI_MATCH(DMI_BOARD_NAME, "30B7")
70 }
71 },
72 {
73 .callback = dmi_io_delay_0xed_port,
Rene Hermanb02aae92008-01-30 13:30:05 +010074 .ident = "HP Pavilion dv9000z",
75 .matches = {
76 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
77 DMI_MATCH(DMI_BOARD_NAME, "30B9")
78 }
79 },
Ingo Molnarf9fc5892008-01-30 13:30:05 +010080 {
81 .callback = dmi_io_delay_0xed_port,
82 .ident = "HP Pavilion tx1000",
83 .matches = {
84 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
85 DMI_MATCH(DMI_BOARD_NAME, "30BF")
86 }
87 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +010088 { }
Rene Hermanb02aae92008-01-30 13:30:05 +010089};
90
Rene Hermanb02aae92008-01-30 13:30:05 +010091void __init io_delay_init(void)
92{
93 if (!io_delay_override)
Ingo Molnar6e7c4022008-01-30 13:30:05 +010094 dmi_check_system(io_delay_0xed_port_dmi_table);
Rene Hermanb02aae92008-01-30 13:30:05 +010095}
Rene Hermanb02aae92008-01-30 13:30:05 +010096
97static int __init io_delay_param(char *s)
98{
Ingo Molnar6e7c4022008-01-30 13:30:05 +010099 if (!strcmp(s, "0x80"))
100 io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
101 else if (!strcmp(s, "0xed"))
102 io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
Rene Hermanb02aae92008-01-30 13:30:05 +0100103 else if (!strcmp(s, "udelay"))
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100104 io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
105 else if (!strcmp(s, "none"))
106 io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
Rene Hermanb02aae92008-01-30 13:30:05 +0100107 else
108 return -EINVAL;
109
Rene Hermanb02aae92008-01-30 13:30:05 +0100110 io_delay_override = 1;
Rene Hermanb02aae92008-01-30 13:30:05 +0100111 return 0;
112}
113
114early_param("io_delay", io_delay_param);