blob: a979b5bd2fc06ee5d07e2eb6a292caa773113f1a [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>
Rene Hermanb02aae92008-01-30 13:30:05 +010010#include <linux/delay.h>
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053011#include <linux/init.h>
Rene Hermanb02aae92008-01-30 13:30:05 +010012#include <linux/dmi.h>
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053013#include <linux/io.h>
Rene Hermanb02aae92008-01-30 13:30:05 +010014
Ingo Molnar6e7c4022008-01-30 13:30:05 +010015int io_delay_type __read_mostly = CONFIG_DEFAULT_IO_DELAY_TYPE;
Rene Hermanb02aae92008-01-30 13:30:05 +010016
Ingo Molnar6e7c4022008-01-30 13:30:05 +010017static int __initdata io_delay_override;
Rene Hermanb02aae92008-01-30 13:30:05 +010018
19/*
20 * Paravirt wants native_io_delay to be a constant.
21 */
22void native_io_delay(void)
23{
Ingo Molnar6e7c4022008-01-30 13:30:05 +010024 switch (io_delay_type) {
25 default:
26 case CONFIG_IO_DELAY_TYPE_0X80:
27 asm volatile ("outb %al, $0x80");
28 break;
29 case CONFIG_IO_DELAY_TYPE_0XED:
30 asm volatile ("outb %al, $0xed");
31 break;
32 case CONFIG_IO_DELAY_TYPE_UDELAY:
33 /*
34 * 2 usecs is an upper-bound for the outb delay but
35 * note that udelay doesn't have the bus-level
36 * side-effects that outb does, nor does udelay() have
37 * precise timings during very early bootup (the delays
38 * are shorter until calibrated):
39 */
40 udelay(2);
41 case CONFIG_IO_DELAY_TYPE_NONE:
42 break;
43 }
Rene Hermanb02aae92008-01-30 13:30:05 +010044}
45EXPORT_SYMBOL(native_io_delay);
46
Ingo Molnar6e7c4022008-01-30 13:30:05 +010047static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
Rene Hermanb02aae92008-01-30 13:30:05 +010048{
Ingo Molnar6e7c4022008-01-30 13:30:05 +010049 if (io_delay_type == CONFIG_IO_DELAY_TYPE_0X80) {
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053050 pr_notice("%s: using 0xed I/O delay port\n", id->ident);
Ingo Molnar6e7c4022008-01-30 13:30:05 +010051 io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
52 }
53
Rene Hermanb02aae92008-01-30 13:30:05 +010054 return 0;
55}
56
Ingo Molnar6e7c4022008-01-30 13:30:05 +010057/*
58 * Quirk table for systems that misbehave (lock up, etc.) if port
59 * 0x80 is used:
60 */
61static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
Rene Hermanb02aae92008-01-30 13:30:05 +010062 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +010063 .callback = dmi_io_delay_0xed_port,
Ingo Molnarf9fc5892008-01-30 13:30:05 +010064 .ident = "Compaq Presario V6000",
65 .matches = {
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053066 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
67 DMI_MATCH(DMI_BOARD_NAME, "30B7")
Ingo Molnarf9fc5892008-01-30 13:30:05 +010068 }
69 },
70 {
71 .callback = dmi_io_delay_0xed_port,
Rene Hermanb02aae92008-01-30 13:30:05 +010072 .ident = "HP Pavilion dv9000z",
73 .matches = {
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053074 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
75 DMI_MATCH(DMI_BOARD_NAME, "30B9")
Rene Hermanb02aae92008-01-30 13:30:05 +010076 }
77 },
Ingo Molnarf9fc5892008-01-30 13:30:05 +010078 {
79 .callback = dmi_io_delay_0xed_port,
Ingo Molnar3c274c22008-03-21 10:06:32 +010080 .ident = "HP Pavilion dv6000",
81 .matches = {
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053082 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
83 DMI_MATCH(DMI_BOARD_NAME, "30B8")
Ingo Molnar3c274c22008-03-21 10:06:32 +010084 }
85 },
86 {
87 .callback = dmi_io_delay_0xed_port,
Ingo Molnarf9fc5892008-01-30 13:30:05 +010088 .ident = "HP Pavilion tx1000",
89 .matches = {
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053090 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
91 DMI_MATCH(DMI_BOARD_NAME, "30BF")
Ingo Molnarf9fc5892008-01-30 13:30:05 +010092 }
93 },
Chuck Ebberte6a56522008-09-03 19:33:14 -040094 {
95 .callback = dmi_io_delay_0xed_port,
96 .ident = "Presario F700",
97 .matches = {
Jaswinder Singh Rajputd53a4442009-03-21 16:57:04 +053098 DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
99 DMI_MATCH(DMI_BOARD_NAME, "30D3")
Chuck Ebberte6a56522008-09-03 19:33:14 -0400100 }
101 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100102 { }
Rene Hermanb02aae92008-01-30 13:30:05 +0100103};
104
Rene Hermanb02aae92008-01-30 13:30:05 +0100105void __init io_delay_init(void)
106{
107 if (!io_delay_override)
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100108 dmi_check_system(io_delay_0xed_port_dmi_table);
Rene Hermanb02aae92008-01-30 13:30:05 +0100109}
Rene Hermanb02aae92008-01-30 13:30:05 +0100110
111static int __init io_delay_param(char *s)
112{
Cyrill Gorcunovd6cd7ef2008-07-05 15:53:37 +0400113 if (!s)
114 return -EINVAL;
115
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100116 if (!strcmp(s, "0x80"))
117 io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
118 else if (!strcmp(s, "0xed"))
119 io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
Rene Hermanb02aae92008-01-30 13:30:05 +0100120 else if (!strcmp(s, "udelay"))
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100121 io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
122 else if (!strcmp(s, "none"))
123 io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
Rene Hermanb02aae92008-01-30 13:30:05 +0100124 else
125 return -EINVAL;
126
Rene Hermanb02aae92008-01-30 13:30:05 +0100127 io_delay_override = 1;
Rene Hermanb02aae92008-01-30 13:30:05 +0100128 return 0;
129}
130
131early_param("io_delay", io_delay_param);