ide.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/pgtable.h>
  11. #include <asm/io.h>
  12. #include <asm/psr.h>
  13. #undef MAX_HWIFS
  14. #define MAX_HWIFS 2
  15. #define __ide_insl(data_reg, buffer, wcount) \
  16. __ide_insw(data_reg, buffer, (wcount)<<1)
  17. #define __ide_outsl(data_reg, buffer, wcount) \
  18. __ide_outsw(data_reg, buffer, (wcount)<<1)
  19. /* On sparc, I/O ports and MMIO registers are accessed identically. */
  20. #define __ide_mm_insw __ide_insw
  21. #define __ide_mm_insl __ide_insl
  22. #define __ide_mm_outsw __ide_outsw
  23. #define __ide_mm_outsl __ide_outsl
  24. static inline void __ide_insw(unsigned long port,
  25. void *dst,
  26. unsigned long count)
  27. {
  28. volatile unsigned short *data_port;
  29. /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
  30. u16 *ps = dst;
  31. u32 *pi;
  32. data_port = (volatile unsigned short *)port;
  33. if(((unsigned long)ps) & 0x2) {
  34. *ps++ = *data_port;
  35. count--;
  36. }
  37. pi = (u32 *)ps;
  38. while(count >= 2) {
  39. u32 w;
  40. w = (*data_port) << 16;
  41. w |= (*data_port);
  42. *pi++ = w;
  43. count -= 2;
  44. }
  45. ps = (u16 *)pi;
  46. if(count)
  47. *ps++ = *data_port;
  48. /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
  49. }
  50. static inline void __ide_outsw(unsigned long port,
  51. const void *src,
  52. unsigned long count)
  53. {
  54. volatile unsigned short *data_port;
  55. /* unsigned long end = (unsigned long)src + (count << 1); */
  56. const u16 *ps = src;
  57. const u32 *pi;
  58. data_port = (volatile unsigned short *)port;
  59. if(((unsigned long)src) & 0x2) {
  60. *data_port = *ps++;
  61. count--;
  62. }
  63. pi = (const u32 *)ps;
  64. while(count >= 2) {
  65. u32 w;
  66. w = *pi++;
  67. *data_port = (w >> 16);
  68. *data_port = w;
  69. count -= 2;
  70. }
  71. ps = (const u16 *)pi;
  72. if(count)
  73. *data_port = *ps;
  74. /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
  75. }
  76. #endif /* __KERNEL__ */
  77. #endif /* _SPARC_IDE_H */