ide_32.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(void __iomem *port, void *dst, u32 count)
  25. {
  26. /* unsigned long end = (unsigned long)dst + (count << 1); */ /* P3 */
  27. u16 *ps = dst;
  28. u32 *pi;
  29. if(((unsigned long)ps) & 0x2) {
  30. *ps++ = __raw_readw(port);
  31. count--;
  32. }
  33. pi = (u32 *)ps;
  34. while(count >= 2) {
  35. u32 w;
  36. w = __raw_readw(port) << 16;
  37. w |= __raw_readw(port);
  38. *pi++ = w;
  39. count -= 2;
  40. }
  41. ps = (u16 *)pi;
  42. if(count)
  43. *ps++ = __raw_readw(port);
  44. /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */
  45. }
  46. static inline void __ide_outsw(void __iomem *port, const void *src, u32 count)
  47. {
  48. /* unsigned long end = (unsigned long)src + (count << 1); */
  49. const u16 *ps = src;
  50. const u32 *pi;
  51. if(((unsigned long)src) & 0x2) {
  52. __raw_writew(*ps++, port);
  53. count--;
  54. }
  55. pi = (const u32 *)ps;
  56. while(count >= 2) {
  57. u32 w;
  58. w = *pi++;
  59. __raw_writew((w >> 16), port);
  60. __raw_writew(w, port);
  61. count -= 2;
  62. }
  63. ps = (const u16 *)pi;
  64. if(count)
  65. __raw_writew(*ps, port);
  66. /* __flush_dcache_range((unsigned long)src, end); */ /* P3 see hme */
  67. }
  68. #endif /* __KERNEL__ */
  69. #endif /* _SPARC_IDE_H */