ide.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* $Id: ide.h,v 1.21 2001/09/25 20:21:48 kanoj Exp $
  2. * ide.h: Ultra/PCI specific IDE glue.
  3. *
  4. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  6. */
  7. #ifndef _SPARC64_IDE_H
  8. #define _SPARC64_IDE_H
  9. #ifdef __KERNEL__
  10. #include <asm/pgalloc.h>
  11. #include <asm/io.h>
  12. #include <asm/spitfire.h>
  13. #include <asm/cacheflush.h>
  14. #include <asm/page.h>
  15. #ifndef MAX_HWIFS
  16. # ifdef CONFIG_BLK_DEV_IDEPCI
  17. #define MAX_HWIFS 10
  18. # else
  19. #define MAX_HWIFS 2
  20. # endif
  21. #endif
  22. #define __ide_insl(data_reg, buffer, wcount) \
  23. __ide_insw(data_reg, buffer, (wcount)<<1)
  24. #define __ide_outsl(data_reg, buffer, wcount) \
  25. __ide_outsw(data_reg, buffer, (wcount)<<1)
  26. /* On sparc64, I/O ports and MMIO registers are accessed identically. */
  27. #define __ide_mm_insw __ide_insw
  28. #define __ide_mm_insl __ide_insl
  29. #define __ide_mm_outsw __ide_outsw
  30. #define __ide_mm_outsl __ide_outsl
  31. static inline unsigned int inw_be(void __iomem *addr)
  32. {
  33. unsigned int ret;
  34. __asm__ __volatile__("lduha [%1] %2, %0"
  35. : "=r" (ret)
  36. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  37. return ret;
  38. }
  39. static inline void __ide_insw(void __iomem *port, void *dst, u32 count)
  40. {
  41. #ifdef DCACHE_ALIASING_POSSIBLE
  42. unsigned long end = (unsigned long)dst + (count << 1);
  43. #endif
  44. u16 *ps = dst;
  45. u32 *pi;
  46. if(((u64)ps) & 0x2) {
  47. *ps++ = inw_be(port);
  48. count--;
  49. }
  50. pi = (u32 *)ps;
  51. while(count >= 2) {
  52. u32 w;
  53. w = inw_be(port) << 16;
  54. w |= inw_be(port);
  55. *pi++ = w;
  56. count -= 2;
  57. }
  58. ps = (u16 *)pi;
  59. if(count)
  60. *ps++ = inw_be(port);
  61. #ifdef DCACHE_ALIASING_POSSIBLE
  62. __flush_dcache_range((unsigned long)dst, end);
  63. #endif
  64. }
  65. static inline void outw_be(unsigned short w, void __iomem *addr)
  66. {
  67. __asm__ __volatile__("stha %0, [%1] %2"
  68. : /* no outputs */
  69. : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  70. }
  71. static inline void __ide_outsw(void __iomem *port, void *src, u32 count)
  72. {
  73. #ifdef DCACHE_ALIASING_POSSIBLE
  74. unsigned long end = (unsigned long)src + (count << 1);
  75. #endif
  76. const u16 *ps = src;
  77. const u32 *pi;
  78. if(((u64)src) & 0x2) {
  79. outw_be(*ps++, port);
  80. count--;
  81. }
  82. pi = (const u32 *)ps;
  83. while(count >= 2) {
  84. u32 w;
  85. w = *pi++;
  86. outw_be((w >> 16), port);
  87. outw_be(w, port);
  88. count -= 2;
  89. }
  90. ps = (const u16 *)pi;
  91. if(count)
  92. outw_be(*ps, port);
  93. #ifdef DCACHE_ALIASING_POSSIBLE
  94. __flush_dcache_range((unsigned long)src, end);
  95. #endif
  96. }
  97. #endif /* __KERNEL__ */
  98. #endif /* _SPARC64_IDE_H */