ide.h 2.1 KB

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