ide.h 2.2 KB

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