Linux Audio

Check our new training course

Linux BSP development engineering services

Need help to port Linux and bootloaders to your hardware?
Loading...
v3.5.6
 
  1/*
  2 * I/O delay strategies for inb_p/outb_p
  3 *
  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.
  7 */
  8#include <linux/kernel.h>
  9#include <linux/module.h>
 10#include <linux/delay.h>
 11#include <linux/init.h>
 12#include <linux/dmi.h>
 13#include <linux/io.h>
 14
 15int io_delay_type __read_mostly = CONFIG_DEFAULT_IO_DELAY_TYPE;
 16
 17static int __initdata io_delay_override;
 18
 19/*
 20 * Paravirt wants native_io_delay to be a constant.
 21 */
 22void native_io_delay(void)
 23{
 24	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	}
 44}
 45EXPORT_SYMBOL(native_io_delay);
 46
 47static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
 48{
 49	if (io_delay_type == CONFIG_IO_DELAY_TYPE_0X80) {
 50		pr_notice("%s: using 0xed I/O delay port\n", id->ident);
 51		io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
 52	}
 53
 54	return 0;
 55}
 56
 57/*
 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[] = {
 62	{
 63		.callback	= dmi_io_delay_0xed_port,
 64		.ident		= "Compaq Presario V6000",
 65		.matches	= {
 66			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 67			DMI_MATCH(DMI_BOARD_NAME,	"30B7")
 68		}
 69	},
 70	{
 71		.callback	= dmi_io_delay_0xed_port,
 72		.ident		= "HP Pavilion dv9000z",
 73		.matches	= {
 74			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 75			DMI_MATCH(DMI_BOARD_NAME,	"30B9")
 76		}
 77	},
 78	{
 79		.callback	= dmi_io_delay_0xed_port,
 80		.ident		= "HP Pavilion dv6000",
 81		.matches	= {
 82			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 83			DMI_MATCH(DMI_BOARD_NAME,	"30B8")
 84		}
 85	},
 86	{
 87		.callback	= dmi_io_delay_0xed_port,
 88		.ident		= "HP Pavilion tx1000",
 89		.matches	= {
 90			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 91			DMI_MATCH(DMI_BOARD_NAME,	"30BF")
 92		}
 93	},
 94	{
 95		.callback	= dmi_io_delay_0xed_port,
 96		.ident		= "Presario F700",
 97		.matches	= {
 98			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 99			DMI_MATCH(DMI_BOARD_NAME,	"30D3")
100		}
101	},
102	{ }
103};
104
105void __init io_delay_init(void)
106{
107	if (!io_delay_override)
108		dmi_check_system(io_delay_0xed_port_dmi_table);
109}
110
111static int __init io_delay_param(char *s)
112{
113	if (!s)
114		return -EINVAL;
115
116	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;
120	else if (!strcmp(s, "udelay"))
121		io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
122	else if (!strcmp(s, "none"))
123		io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
124	else
125		return -EINVAL;
126
127	io_delay_override = 1;
128	return 0;
129}
130
131early_param("io_delay", io_delay_param);
v4.17
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * I/O delay strategies for inb_p/outb_p
  4 *
  5 * Allow for a DMI based override of port 0x80, needed for certain HP laptops
  6 * and possibly other systems. Also allow for the gradual elimination of
  7 * outb_p/inb_p API uses.
  8 */
  9#include <linux/kernel.h>
 10#include <linux/export.h>
 11#include <linux/delay.h>
 12#include <linux/init.h>
 13#include <linux/dmi.h>
 14#include <linux/io.h>
 15
 16int io_delay_type __read_mostly = CONFIG_DEFAULT_IO_DELAY_TYPE;
 17
 18static int __initdata io_delay_override;
 19
 20/*
 21 * Paravirt wants native_io_delay to be a constant.
 22 */
 23void native_io_delay(void)
 24{
 25	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	}
 45}
 46EXPORT_SYMBOL(native_io_delay);
 47
 48static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
 49{
 50	if (io_delay_type == CONFIG_IO_DELAY_TYPE_0X80) {
 51		pr_notice("%s: using 0xed I/O delay port\n", id->ident);
 52		io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
 53	}
 54
 55	return 0;
 56}
 57
 58/*
 59 * Quirk table for systems that misbehave (lock up, etc.) if port
 60 * 0x80 is used:
 61 */
 62static const struct dmi_system_id io_delay_0xed_port_dmi_table[] __initconst = {
 63	{
 64		.callback	= dmi_io_delay_0xed_port,
 65		.ident		= "Compaq Presario V6000",
 66		.matches	= {
 67			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 68			DMI_MATCH(DMI_BOARD_NAME,	"30B7")
 69		}
 70	},
 71	{
 72		.callback	= dmi_io_delay_0xed_port,
 73		.ident		= "HP Pavilion dv9000z",
 74		.matches	= {
 75			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 76			DMI_MATCH(DMI_BOARD_NAME,	"30B9")
 77		}
 78	},
 79	{
 80		.callback	= dmi_io_delay_0xed_port,
 81		.ident		= "HP Pavilion dv6000",
 82		.matches	= {
 83			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 84			DMI_MATCH(DMI_BOARD_NAME,	"30B8")
 85		}
 86	},
 87	{
 88		.callback	= dmi_io_delay_0xed_port,
 89		.ident		= "HP Pavilion tx1000",
 90		.matches	= {
 91			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
 92			DMI_MATCH(DMI_BOARD_NAME,	"30BF")
 93		}
 94	},
 95	{
 96		.callback	= dmi_io_delay_0xed_port,
 97		.ident		= "Presario F700",
 98		.matches	= {
 99			DMI_MATCH(DMI_BOARD_VENDOR,	"Quanta"),
100			DMI_MATCH(DMI_BOARD_NAME,	"30D3")
101		}
102	},
103	{ }
104};
105
106void __init io_delay_init(void)
107{
108	if (!io_delay_override)
109		dmi_check_system(io_delay_0xed_port_dmi_table);
110}
111
112static int __init io_delay_param(char *s)
113{
114	if (!s)
115		return -EINVAL;
116
117	if (!strcmp(s, "0x80"))
118		io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
119	else if (!strcmp(s, "0xed"))
120		io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
121	else if (!strcmp(s, "udelay"))
122		io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
123	else if (!strcmp(s, "none"))
124		io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
125	else
126		return -EINVAL;
127
128	io_delay_override = 1;
129	return 0;
130}
131
132early_param("io_delay", io_delay_param);