io-64-nonatomic-hi-lo.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_IO_64_NONATOMIC_HI_LO_H_
  3. #define _LINUX_IO_64_NONATOMIC_HI_LO_H_
  4. #include <linux/io.h>
  5. #include <asm-generic/int-ll64.h>
  6. static inline __u64 hi_lo_readq(const volatile void __iomem *addr)
  7. {
  8. const volatile u32 __iomem *p = addr;
  9. u32 low, high;
  10. high = readl(p + 1);
  11. low = readl(p);
  12. return low + ((u64)high << 32);
  13. }
  14. static inline void hi_lo_writeq(__u64 val, volatile void __iomem *addr)
  15. {
  16. writel(val >> 32, addr + 4);
  17. writel(val, addr);
  18. }
  19. static inline __u64 hi_lo_readq_relaxed(const volatile void __iomem *addr)
  20. {
  21. const volatile u32 __iomem *p = addr;
  22. u32 low, high;
  23. high = readl_relaxed(p + 1);
  24. low = readl_relaxed(p);
  25. return low + ((u64)high << 32);
  26. }
  27. static inline void hi_lo_writeq_relaxed(__u64 val, volatile void __iomem *addr)
  28. {
  29. writel_relaxed(val >> 32, addr + 4);
  30. writel_relaxed(val, addr);
  31. }
  32. #ifndef readq
  33. #define readq hi_lo_readq
  34. #endif
  35. #ifndef writeq
  36. #define writeq hi_lo_writeq
  37. #endif
  38. #ifndef readq_relaxed
  39. #define readq_relaxed hi_lo_readq_relaxed
  40. #endif
  41. #ifndef writeq_relaxed
  42. #define writeq_relaxed hi_lo_writeq_relaxed
  43. #endif
  44. #ifndef ioread64_hi_lo
  45. #define ioread64_hi_lo ioread64_hi_lo
  46. static inline u64 ioread64_hi_lo(const void __iomem *addr)
  47. {
  48. u32 low, high;
  49. high = ioread32(addr + sizeof(u32));
  50. low = ioread32(addr);
  51. return low + ((u64)high << 32);
  52. }
  53. #endif
  54. #ifndef iowrite64_hi_lo
  55. #define iowrite64_hi_lo iowrite64_hi_lo
  56. static inline void iowrite64_hi_lo(u64 val, void __iomem *addr)
  57. {
  58. iowrite32(val >> 32, addr + sizeof(u32));
  59. iowrite32(val, addr);
  60. }
  61. #endif
  62. #ifndef ioread64be_hi_lo
  63. #define ioread64be_hi_lo ioread64be_hi_lo
  64. static inline u64 ioread64be_hi_lo(const void __iomem *addr)
  65. {
  66. u32 low, high;
  67. high = ioread32be(addr);
  68. low = ioread32be(addr + sizeof(u32));
  69. return low + ((u64)high << 32);
  70. }
  71. #endif
  72. #ifndef iowrite64be_hi_lo
  73. #define iowrite64be_hi_lo iowrite64be_hi_lo
  74. static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr)
  75. {
  76. iowrite32be(val >> 32, addr);
  77. iowrite32be(val, addr + sizeof(u32));
  78. }
  79. #endif
  80. #ifndef ioread64
  81. #define ioread64_is_nonatomic
  82. #define ioread64 ioread64_hi_lo
  83. #endif
  84. #ifndef iowrite64
  85. #define iowrite64_is_nonatomic
  86. #define iowrite64 iowrite64_hi_lo
  87. #endif
  88. #ifndef ioread64be
  89. #define ioread64be_is_nonatomic
  90. #define ioread64be ioread64be_hi_lo
  91. #endif
  92. #ifndef iowrite64be
  93. #define iowrite64be_is_nonatomic
  94. #define iowrite64be iowrite64be_hi_lo
  95. #endif
  96. #endif /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */