io_delay.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/init.h>
  11. #include <linux/delay.h>
  12. #include <linux/dmi.h>
  13. #include <asm/io.h>
  14. int io_delay_type __read_mostly = CONFIG_DEFAULT_IO_DELAY_TYPE;
  15. EXPORT_SYMBOL_GPL(io_delay_type);
  16. static int __initdata io_delay_override;
  17. /*
  18. * Paravirt wants native_io_delay to be a constant.
  19. */
  20. void native_io_delay(void)
  21. {
  22. switch (io_delay_type) {
  23. default:
  24. case CONFIG_IO_DELAY_TYPE_0X80:
  25. asm volatile ("outb %al, $0x80");
  26. break;
  27. case CONFIG_IO_DELAY_TYPE_0XED:
  28. asm volatile ("outb %al, $0xed");
  29. break;
  30. case CONFIG_IO_DELAY_TYPE_UDELAY:
  31. /*
  32. * 2 usecs is an upper-bound for the outb delay but
  33. * note that udelay doesn't have the bus-level
  34. * side-effects that outb does, nor does udelay() have
  35. * precise timings during very early bootup (the delays
  36. * are shorter until calibrated):
  37. */
  38. udelay(2);
  39. case CONFIG_IO_DELAY_TYPE_NONE:
  40. break;
  41. }
  42. }
  43. EXPORT_SYMBOL(native_io_delay);
  44. static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
  45. {
  46. if (io_delay_type == CONFIG_IO_DELAY_TYPE_0X80) {
  47. printk(KERN_NOTICE "%s: using 0xed I/O delay port\n",
  48. id->ident);
  49. io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
  50. }
  51. return 0;
  52. }
  53. /*
  54. * Quirk table for systems that misbehave (lock up, etc.) if port
  55. * 0x80 is used:
  56. */
  57. static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
  58. {
  59. .callback = dmi_io_delay_0xed_port,
  60. .ident = "Compaq Presario V6000",
  61. .matches = {
  62. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  63. DMI_MATCH(DMI_BOARD_NAME, "30B7")
  64. }
  65. },
  66. {
  67. .callback = dmi_io_delay_0xed_port,
  68. .ident = "HP Pavilion dv9000z",
  69. .matches = {
  70. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  71. DMI_MATCH(DMI_BOARD_NAME, "30B9")
  72. }
  73. },
  74. {
  75. .callback = dmi_io_delay_0xed_port,
  76. .ident = "HP Pavilion tx1000",
  77. .matches = {
  78. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  79. DMI_MATCH(DMI_BOARD_NAME, "30BF")
  80. }
  81. },
  82. { }
  83. };
  84. void __init io_delay_init(void)
  85. {
  86. if (!io_delay_override)
  87. dmi_check_system(io_delay_0xed_port_dmi_table);
  88. }
  89. static int __init io_delay_param(char *s)
  90. {
  91. if (!strcmp(s, "0x80"))
  92. io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
  93. else if (!strcmp(s, "0xed"))
  94. io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
  95. else if (!strcmp(s, "udelay"))
  96. io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
  97. else if (!strcmp(s, "none"))
  98. io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
  99. else
  100. return -EINVAL;
  101. io_delay_override = 1;
  102. return 0;
  103. }
  104. early_param("io_delay", io_delay_param);