ide.h 2.2 KB

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