io_delay.c 3.0 KB

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