io_delay.c 3.0 KB
Newer Older
1 2
/*
 * I/O delay strategies for inb_p/outb_p
3 4 5 6
 *
 * Allow for a DMI based override of port 0x80, needed for certain HP laptops
 * and possibly other systems. Also allow for the gradual elimination of
 * outb_p/inb_p API uses.
7 8
 */
#include <linux/kernel.h>
9
#include <linux/export.h>
10
#include <linux/delay.h>
J
Jaswinder Singh Rajput 已提交
11
#include <linux/init.h>
12
#include <linux/dmi.h>
J
Jaswinder Singh Rajput 已提交
13
#include <linux/io.h>
14

15
int io_delay_type __read_mostly = CONFIG_DEFAULT_IO_DELAY_TYPE;
16

17
static int __initdata io_delay_override;
18 19 20 21 22 23

/*
 * Paravirt wants native_io_delay to be a constant.
 */
void native_io_delay(void)
{
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
	switch (io_delay_type) {
	default:
	case CONFIG_IO_DELAY_TYPE_0X80:
		asm volatile ("outb %al, $0x80");
		break;
	case CONFIG_IO_DELAY_TYPE_0XED:
		asm volatile ("outb %al, $0xed");
		break;
	case CONFIG_IO_DELAY_TYPE_UDELAY:
		/*
		 * 2 usecs is an upper-bound for the outb delay but
		 * note that udelay doesn't have the bus-level
		 * side-effects that outb does, nor does udelay() have
		 * precise timings during very early bootup (the delays
		 * are shorter until calibrated):
		 */
		udelay(2);
	case CONFIG_IO_DELAY_TYPE_NONE:
		break;
	}
44 45 46
}
EXPORT_SYMBOL(native_io_delay);

47
static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
48
{
49
	if (io_delay_type == CONFIG_IO_DELAY_TYPE_0X80) {
J
Jaswinder Singh Rajput 已提交
50
		pr_notice("%s: using 0xed I/O delay port\n", id->ident);
51 52 53
		io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
	}

54 55 56
	return 0;
}

57 58 59 60 61
/*
 * Quirk table for systems that misbehave (lock up, etc.) if port
 * 0x80 is used:
 */
static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
62 63 64 65
	{
		.callback	= dmi_io_delay_0xed_port,
		.ident		= "Compaq Presario V6000",
		.matches	= {
J
Jaswinder Singh Rajput 已提交
66 67
			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
			DMI_MATCH(DMI_BOARD_NAME,	"30B7")
68 69
		}
	},
70
	{
71
		.callback	= dmi_io_delay_0xed_port,
72 73
		.ident		= "HP Pavilion dv9000z",
		.matches	= {
J
Jaswinder Singh Rajput 已提交
74 75
			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
			DMI_MATCH(DMI_BOARD_NAME,	"30B9")
76 77
		}
	},
I
Ingo Molnar 已提交
78 79 80 81
	{
		.callback	= dmi_io_delay_0xed_port,
		.ident		= "HP Pavilion dv6000",
		.matches	= {
J
Jaswinder Singh Rajput 已提交
82 83
			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
			DMI_MATCH(DMI_BOARD_NAME,	"30B8")
I
Ingo Molnar 已提交
84 85
		}
	},
86 87 88 89
	{
		.callback	= dmi_io_delay_0xed_port,
		.ident		= "HP Pavilion tx1000",
		.matches	= {
J
Jaswinder Singh Rajput 已提交
90 91
			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
			DMI_MATCH(DMI_BOARD_NAME,	"30BF")
92 93
		}
	},
94 95 96 97
	{
		.callback	= dmi_io_delay_0xed_port,
		.ident		= "Presario F700",
		.matches	= {
J
Jaswinder Singh Rajput 已提交
98 99
			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
			DMI_MATCH(DMI_BOARD_NAME,	"30D3")
100 101
		}
	},
102
	{ }
103 104 105 106 107
};

void __init io_delay_init(void)
{
	if (!io_delay_override)
108
		dmi_check_system(io_delay_0xed_port_dmi_table);
109 110 111 112
}

static int __init io_delay_param(char *s)
{
113 114 115
	if (!s)
		return -EINVAL;

116 117 118 119
	if (!strcmp(s, "0x80"))
		io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
	else if (!strcmp(s, "0xed"))
		io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
120
	else if (!strcmp(s, "udelay"))
121 122 123
		io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
	else if (!strcmp(s, "none"))
		io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
124 125 126 127 128 129 130 131
	else
		return -EINVAL;

	io_delay_override = 1;
	return 0;
}

early_param("io_delay", io_delay_param);