ide.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* ide.h: SPARC PCI specific IDE glue.
  3. *
  4. * Copyright (C) 1997 David S. Miller (davem@davemloft.net)
  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/io.h>
  12. #ifdef CONFIG_SPARC64
  13. #include <asm/pgalloc.h>
  14. #include <asm/spitfire.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/page.h>
  17. #else
  18. #include <asm/pgtable.h>
  19. #include <asm/psr.h>
  20. #endif
  21. #define __ide_insl(data_reg, buffer, wcount) \
  22. __ide_insw(data_reg, buffer, (wcount)<<1)
  23. #define __ide_outsl(data_reg, buffer, wcount) \
  24. __ide_outsw(data_reg, buffer, (wcount)<<1)
  25. /* On sparc, I/O ports and MMIO registers are accessed identically. */
  26. #define __ide_mm_insw __ide_insw
  27. #define __ide_mm_insl __ide_insl
  28. #define __ide_mm_outsw __ide_outsw
  29. #define __ide_mm_outsl __ide_outsl
  30. static inline void __ide_insw(void __iomem *port, void *dst, u32 count)
  31. {
  32. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  33. unsigned long end = (unsigned long)dst + (count << 1);
  34. #endif
  35. u16 *ps = dst;
  36. u32 *pi;
  37. if(((unsigned long)ps) & 0x2) {
  38. *ps++ = __raw_readw(port);
  39. count--;
  40. }
  41. pi = (u32 *)ps;
  42. while(count >= 2) {
  43. u32 w;
  44. w = __raw_readw(port) << 16;
  45. w |= __raw_readw(port);
  46. *pi++ = w;
  47. count -= 2;
  48. }
  49. ps = (u16 *)pi;
  50. if(count)
  51. *ps++ = __raw_readw(port);
  52. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  53. __flush_dcache_range((unsigned long)dst, end);
  54. #endif
  55. }
  56. static inline void __ide_outsw(void __iomem *port, const void *src, u32 count)
  57. {
  58. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  59. unsigned long end = (unsigned long)src + (count << 1);
  60. #endif
  61. const u16 *ps = src;
  62. const u32 *pi;
  63. if(((unsigned long)src) & 0x2) {
  64. __raw_writew(*ps++, port);
  65. count--;
  66. }
  67. pi = (const u32 *)ps;
  68. while(count >= 2) {
  69. u32 w;
  70. w = *pi++;
  71. __raw_writew((w >> 16), port);
  72. __raw_writew(w, port);
  73. count -= 2;
  74. }
  75. ps = (const u16 *)pi;
  76. if(count)
  77. __raw_writew(*ps, port);
  78. #if defined(CONFIG_SPARC64) && defined(DCACHE_ALIASING_POSSIBLE)
  79. __flush_dcache_range((unsigned long)src, end);
  80. #endif
  81. }
  82. #endif /* __KERNEL__ */
  83. #endif /* _SPARC_IDE_H */