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