ide.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994-1996 Linus Torvalds & authors
  7. *
  8. * Copied from i386; many of the especially older MIPS or ISA-based platforms
  9. * are basically identical. Using this file probably implies i8259 PIC
  10. * support in a system but the very least interrupt numbers 0 - 15 need to
  11. * be put aside for legacy devices.
  12. */
  13. #ifndef __ASM_MACH_GENERIC_IDE_H
  14. #define __ASM_MACH_GENERIC_IDE_H
  15. #ifdef __KERNEL__
  16. #include <linux/pci.h>
  17. #include <linux/stddef.h>
  18. #include <asm/processor.h>
  19. /* MIPS port and memory-mapped I/O string operations. */
  20. static inline void __ide_flush_prologue(void)
  21. {
  22. #ifdef CONFIG_SMP
  23. if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc)
  24. preempt_disable();
  25. #endif
  26. }
  27. static inline void __ide_flush_epilogue(void)
  28. {
  29. #ifdef CONFIG_SMP
  30. if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc)
  31. preempt_enable();
  32. #endif
  33. }
  34. static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size)
  35. {
  36. if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc) {
  37. unsigned long end = addr + size;
  38. while (addr < end) {
  39. local_flush_data_cache_page((void *)addr);
  40. addr += PAGE_SIZE;
  41. }
  42. }
  43. }
  44. /*
  45. * insw() and gang might be called with interrupts disabled, so we can't
  46. * send IPIs for flushing due to the potencial of deadlocks, see the comment
  47. * above smp_call_function() in arch/mips/kernel/smp.c. We work around the
  48. * problem by disabling preemption so we know we actually perform the flush
  49. * on the processor that actually has the lines to be flushed which hopefully
  50. * is even better for performance anyway.
  51. */
  52. static inline void __ide_insw(unsigned long port, void *addr,
  53. unsigned int count)
  54. {
  55. __ide_flush_prologue();
  56. insw(port, addr, count);
  57. __ide_flush_dcache_range((unsigned long)addr, count * 2);
  58. __ide_flush_epilogue();
  59. }
  60. static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
  61. {
  62. __ide_flush_prologue();
  63. insl(port, addr, count);
  64. __ide_flush_dcache_range((unsigned long)addr, count * 4);
  65. __ide_flush_epilogue();
  66. }
  67. static inline void __ide_outsw(unsigned long port, const void *addr,
  68. unsigned long count)
  69. {
  70. __ide_flush_prologue();
  71. outsw(port, addr, count);
  72. __ide_flush_dcache_range((unsigned long)addr, count * 2);
  73. __ide_flush_epilogue();
  74. }
  75. static inline void __ide_outsl(unsigned long port, const void *addr,
  76. unsigned long count)
  77. {
  78. __ide_flush_prologue();
  79. outsl(port, addr, count);
  80. __ide_flush_dcache_range((unsigned long)addr, count * 4);
  81. __ide_flush_epilogue();
  82. }
  83. static inline void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
  84. {
  85. __ide_flush_prologue();
  86. readsw(port, addr, count);
  87. __ide_flush_dcache_range((unsigned long)addr, count * 2);
  88. __ide_flush_epilogue();
  89. }
  90. static inline void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
  91. {
  92. __ide_flush_prologue();
  93. readsl(port, addr, count);
  94. __ide_flush_dcache_range((unsigned long)addr, count * 4);
  95. __ide_flush_epilogue();
  96. }
  97. static inline void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
  98. {
  99. __ide_flush_prologue();
  100. writesw(port, addr, count);
  101. __ide_flush_dcache_range((unsigned long)addr, count * 2);
  102. __ide_flush_epilogue();
  103. }
  104. static inline void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
  105. {
  106. __ide_flush_prologue();
  107. writesl(port, addr, count);
  108. __ide_flush_dcache_range((unsigned long)addr, count * 4);
  109. __ide_flush_epilogue();
  110. }
  111. /* ide_insw calls insw, not __ide_insw. Why? */
  112. #undef insw
  113. #undef insl
  114. #undef outsw
  115. #undef outsl
  116. #define insw(port, addr, count) __ide_insw(port, addr, count)
  117. #define insl(port, addr, count) __ide_insl(port, addr, count)
  118. #define outsw(port, addr, count) __ide_outsw(port, addr, count)
  119. #define outsl(port, addr, count) __ide_outsl(port, addr, count)
  120. #endif /* __KERNEL__ */
  121. #endif /* __ASM_MACH_GENERIC_IDE_H */