ide.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #define __ide_insl(data_reg, buffer, wcount) \
  21. __ide_insw(data_reg, buffer, (wcount)<<1)
  22. #define __ide_outsl(data_reg, buffer, wcount) \
  23. __ide_outsw(data_reg, buffer, (wcount)<<1)
  24. /* On sparc, I/O ports and MMIO registers are accessed identically. */
  25. #define __ide_mm_insw __ide_insw
  26. #define __ide_mm_insl __ide_insl
  27. #define __ide_mm_outsw __ide_outsw
  28. #define __ide_mm_outsl __ide_outsl
  29. static inline void __ide_insw(void __iomem *port, void *dst, u32 count)
  30. {
  31. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  32. unsigned long end = (unsigned long)dst + (count << 1);
  33. #endif
  34. u16 *ps = dst;
  35. u32 *pi;
  36. if(((unsigned long)ps) & 0x2) {
  37. *ps++ = __raw_readw(port);
  38. count--;
  39. }
  40. pi = (u32 *)ps;
  41. while(count >= 2) {
  42. u32 w;
  43. w = __raw_readw(port) << 16;
  44. w |= __raw_readw(port);
  45. *pi++ = w;
  46. count -= 2;
  47. }
  48. ps = (u16 *)pi;
  49. if(count)
  50. *ps++ = __raw_readw(port);
  51. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  52. __flush_dcache_range((unsigned long)dst, end);
  53. #endif
  54. }
  55. static inline void __ide_outsw(void __iomem *port, const void *src, u32 count)
  56. {
  57. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  58. unsigned long end = (unsigned long)src + (count << 1);
  59. #endif
  60. const u16 *ps = src;
  61. const u32 *pi;
  62. if(((unsigned long)src) & 0x2) {
  63. __raw_writew(*ps++, port);
  64. count--;
  65. }
  66. pi = (const u32 *)ps;
  67. while(count >= 2) {
  68. u32 w;
  69. w = *pi++;
  70. __raw_writew((w >> 16), port);
  71. __raw_writew(w, port);
  72. count -= 2;
  73. }
  74. ps = (const u16 *)pi;
  75. if(count)
  76. __raw_writew(*ps, port);
  77. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  78. __flush_dcache_range((unsigned long)src, end);
  79. #endif
  80. }
  81. #endif /* __KERNEL__ */
  82. #endif /* _SPARC_IDE_H */