ide.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* ide.h: SPARC PCI specific IDE glue.
  2. *
  3. * Copyright (C) 1997 David S. Miller (davem@davemloft.net)
  4. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  5. * Adaptation from sparc64 version to sparc by Pete Zaitcev.
  6. */
  7. #ifndef _SPARC_IDE_H
  8. #define _SPARC_IDE_H
  9. #ifdef __KERNEL__
  10. #include <asm/io.h>
  11. #ifdef CONFIG_SPARC64
  12. #include <asm/pgalloc.h>
  13. #include <asm/spitfire.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/page.h>
  16. #else
  17. #include <asm/pgtable.h>
  18. #include <asm/psr.h>
  19. #endif
  20. #undef MAX_HWIFS
  21. #define MAX_HWIFS 2
  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 sparc, 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 void __ide_insw(void __iomem *port, void *dst, u32 count)
  32. {
  33. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  34. unsigned long end = (unsigned long)dst + (count << 1);
  35. #endif
  36. u16 *ps = dst;
  37. u32 *pi;
  38. if(((unsigned long)ps) & 0x2) {
  39. *ps++ = __raw_readw(port);
  40. count--;
  41. }
  42. pi = (u32 *)ps;
  43. while(count >= 2) {
  44. u32 w;
  45. w = __raw_readw(port) << 16;
  46. w |= __raw_readw(port);
  47. *pi++ = w;
  48. count -= 2;
  49. }
  50. ps = (u16 *)pi;
  51. if(count)
  52. *ps++ = __raw_readw(port);
  53. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  54. __flush_dcache_range((unsigned long)dst, end);
  55. #endif
  56. }
  57. static inline void __ide_outsw(void __iomem *port, const void *src, u32 count)
  58. {
  59. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  60. unsigned long end = (unsigned long)src + (count << 1);
  61. #endif
  62. const u16 *ps = src;
  63. const u32 *pi;
  64. if(((unsigned long)src) & 0x2) {
  65. __raw_writew(*ps++, port);
  66. count--;
  67. }
  68. pi = (const u32 *)ps;
  69. while(count >= 2) {
  70. u32 w;
  71. w = *pi++;
  72. __raw_writew((w >> 16), port);
  73. __raw_writew(w, port);
  74. count -= 2;
  75. }
  76. ps = (const u16 *)pi;
  77. if(count)
  78. __raw_writew(*ps, port);
  79. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  80. __flush_dcache_range((unsigned long)src, end);
  81. #endif
  82. }
  83. #endif /* __KERNEL__ */
  84. #endif /* _SPARC_IDE_H */