i8237.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * 8237A DMA controller suspend functions.
  3. *
  4. * Written by Pierre Ossman, 2005.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. */
  11. #include <linux/dmi.h>
  12. #include <linux/init.h>
  13. #include <linux/syscore_ops.h>
  14. #include <asm/dma.h>
  15. #include <asm/x86_init.h>
  16. /*
  17. * This module just handles suspend/resume issues with the
  18. * 8237A DMA controller (used for ISA and LPC).
  19. * Allocation is handled in kernel/dma.c and normal usage is
  20. * in asm/dma.h.
  21. */
  22. static void i8237A_resume(void)
  23. {
  24. unsigned long flags;
  25. int i;
  26. flags = claim_dma_lock();
  27. dma_outb(0, DMA1_RESET_REG);
  28. dma_outb(0, DMA2_RESET_REG);
  29. for (i = 0; i < 8; i++) {
  30. set_dma_addr(i, 0x000000);
  31. /* DMA count is a bit weird so this is not 0 */
  32. set_dma_count(i, 1);
  33. }
  34. /* Enable cascade DMA or channel 0-3 won't work */
  35. enable_dma(4);
  36. release_dma_lock(flags);
  37. }
  38. static struct syscore_ops i8237_syscore_ops = {
  39. .resume = i8237A_resume,
  40. };
  41. static int __init i8237A_init_ops(void)
  42. {
  43. /*
  44. * From SKL PCH onwards, the legacy DMA device is removed in which the
  45. * I/O ports (81h-83h, 87h, 89h-8Bh, 8Fh) related to it are removed
  46. * as well. All removed ports must return 0xff for a inb() request.
  47. *
  48. * Note: DMA_PAGE_2 (port 0x81) should not be checked for detecting
  49. * the presence of DMA device since it may be used by BIOS to decode
  50. * LPC traffic for POST codes. Original LPC only decodes one byte of
  51. * port 0x80 but some BIOS may choose to enhance PCH LPC port 0x8x
  52. * decoding.
  53. */
  54. if (dma_inb(DMA_PAGE_0) == 0xFF)
  55. return -ENODEV;
  56. /*
  57. * It is not required to load this driver as newer SoC may not
  58. * support 8237 DMA or bus mastering from LPC. Platform firmware
  59. * must announce the support for such legacy devices via
  60. * ACPI_FADT_LEGACY_DEVICES field in FADT table.
  61. */
  62. if (x86_pnpbios_disabled() && dmi_get_bios_year() >= 2017)
  63. return -ENODEV;
  64. register_syscore_ops(&i8237_syscore_ops);
  65. return 0;
  66. }
  67. device_initcall(i8237A_init_ops);