io_delay.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. 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. printk(KERN_NOTICE "%s: using 0xed I/O delay port\n",
  47. id->ident);
  48. io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
  49. }
  50. return 0;
  51. }
  52. /*
  53. * Quirk table for systems that misbehave (lock up, etc.) if port
  54. * 0x80 is used:
  55. */
  56. static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
  57. {
  58. .callback = dmi_io_delay_0xed_port,
  59. .ident = "Compaq Presario V6000",
  60. .matches = {
  61. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  62. DMI_MATCH(DMI_BOARD_NAME, "30B7")
  63. }
  64. },
  65. {
  66. .callback = dmi_io_delay_0xed_port,
  67. .ident = "HP Pavilion dv9000z",
  68. .matches = {
  69. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  70. DMI_MATCH(DMI_BOARD_NAME, "30B9")
  71. }
  72. },
  73. {
  74. .callback = dmi_io_delay_0xed_port,
  75. .ident = "HP Pavilion dv6000",
  76. .matches = {
  77. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  78. DMI_MATCH(DMI_BOARD_NAME, "30B8")
  79. }
  80. },
  81. {
  82. .callback = dmi_io_delay_0xed_port,
  83. .ident = "HP Pavilion tx1000",
  84. .matches = {
  85. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  86. DMI_MATCH(DMI_BOARD_NAME, "30BF")
  87. }
  88. },
  89. {
  90. .callback = dmi_io_delay_0xed_port,
  91. .ident = "Presario F700",
  92. .matches = {
  93. DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"),
  94. DMI_MATCH(DMI_BOARD_NAME, "30D3")
  95. }
  96. },
  97. { }
  98. };
  99. void __init io_delay_init(void)
  100. {
  101. if (!io_delay_override)
  102. dmi_check_system(io_delay_0xed_port_dmi_table);
  103. }
  104. static int __init io_delay_param(char *s)
  105. {
  106. if (!s)
  107. return -EINVAL;
  108. if (!strcmp(s, "0x80"))
  109. io_delay_type = CONFIG_IO_DELAY_TYPE_0X80;
  110. else if (!strcmp(s, "0xed"))
  111. io_delay_type = CONFIG_IO_DELAY_TYPE_0XED;
  112. else if (!strcmp(s, "udelay"))
  113. io_delay_type = CONFIG_IO_DELAY_TYPE_UDELAY;
  114. else if (!strcmp(s, "none"))
  115. io_delay_type = CONFIG_IO_DELAY_TYPE_NONE;
  116. else
  117. return -EINVAL;
  118. io_delay_override = 1;
  119. return 0;
  120. }
  121. early_param("io_delay", io_delay_param);