ide.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 <linux/config.h>
  11. #include <asm/pgalloc.h>
  12. #include <asm/io.h>
  13. #include <asm/spitfire.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/page.h>
  16. #ifndef MAX_HWIFS
  17. # ifdef CONFIG_BLK_DEV_IDEPCI
  18. #define MAX_HWIFS 10
  19. # else
  20. #define MAX_HWIFS 2
  21. # endif
  22. #endif
  23. #define IDE_ARCH_OBSOLETE_INIT
  24. #define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
  25. #define __ide_insl(data_reg, buffer, wcount) \
  26. __ide_insw(data_reg, buffer, (wcount)<<1)
  27. #define __ide_outsl(data_reg, buffer, wcount) \
  28. __ide_outsw(data_reg, buffer, (wcount)<<1)
  29. /* On sparc64, I/O ports and MMIO registers are accessed identically. */
  30. #define __ide_mm_insw __ide_insw
  31. #define __ide_mm_insl __ide_insl
  32. #define __ide_mm_outsw __ide_outsw
  33. #define __ide_mm_outsl __ide_outsl
  34. static inline unsigned int inw_be(void __iomem *addr)
  35. {
  36. unsigned int ret;
  37. __asm__ __volatile__("lduha [%1] %2, %0"
  38. : "=r" (ret)
  39. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  40. return ret;
  41. }
  42. static inline void __ide_insw(void __iomem *port, void *dst, u32 count)
  43. {
  44. #ifdef DCACHE_ALIASING_POSSIBLE
  45. unsigned long end = (unsigned long)dst + (count << 1);
  46. #endif
  47. u16 *ps = dst;
  48. u32 *pi;
  49. if(((u64)ps) & 0x2) {
  50. *ps++ = inw_be(port);
  51. count--;
  52. }
  53. pi = (u32 *)ps;
  54. while(count >= 2) {
  55. u32 w;
  56. w = inw_be(port) << 16;
  57. w |= inw_be(port);
  58. *pi++ = w;
  59. count -= 2;
  60. }
  61. ps = (u16 *)pi;
  62. if(count)
  63. *ps++ = inw_be(port);
  64. #ifdef DCACHE_ALIASING_POSSIBLE
  65. __flush_dcache_range((unsigned long)dst, end);
  66. #endif
  67. }
  68. static inline void outw_be(unsigned short w, void __iomem *addr)
  69. {
  70. __asm__ __volatile__("stha %0, [%1] %2"
  71. : /* no outputs */
  72. : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  73. }
  74. static inline void __ide_outsw(void __iomem *port, void *src, u32 count)
  75. {
  76. #ifdef DCACHE_ALIASING_POSSIBLE
  77. unsigned long end = (unsigned long)src + (count << 1);
  78. #endif
  79. const u16 *ps = src;
  80. const u32 *pi;
  81. if(((u64)src) & 0x2) {
  82. outw_be(*ps++, port);
  83. count--;
  84. }
  85. pi = (const u32 *)ps;
  86. while(count >= 2) {
  87. u32 w;
  88. w = *pi++;
  89. outw_be((w >> 16), port);
  90. outw_be(w, port);
  91. count -= 2;
  92. }
  93. ps = (const u16 *)pi;
  94. if(count)
  95. outw_be(*ps, port);
  96. #ifdef DCACHE_ALIASING_POSSIBLE
  97. __flush_dcache_range((unsigned long)src, end);
  98. #endif
  99. }
  100. #endif /* __KERNEL__ */
  101. #endif /* _SPARC64_IDE_H */