1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _ASM_S390_DMA_TYPES_H_
4 #define _ASM_S390_DMA_TYPES_H_
6 #include <linux/types.h>
11 * Contains a 31 bit absolute address to a DMA capable piece of storage.
13 * For CIO, DMA addresses are always absolute addresses. These addresses tend
14 * to be used in architectured memory blocks (like ORB, IDAW, MIDAW). Under
15 * certain circumstances 31 bit wide addresses must be used because the
16 * address must fit in 31 bits.
18 * This type is to be used when such fields can be modelled as 32 bit wide.
20 typedef u32 __bitwise dma32_t;
24 * Contains a 64 bit absolute address to a DMA capable piece of storage.
26 * For CIO, DMA addresses are always absolute addresses. These addresses tend
27 * to be used in architectured memory blocks (like ORB, IDAW, MIDAW).
29 * This type is to be used to model such 64 bit wide fields.
31 typedef u64 __bitwise dma64_t;
34 * Although DMA addresses should be obtained using the DMA API, in cases when
35 * it is known that the first argument holds a virtual address that points to
36 * DMA-able 31 bit addressable storage, then this function can be safely used.
38 static inline dma32_t virt_to_dma32(void *ptr)
40 return (__force dma32_t)__pa32(ptr);
43 static inline void *dma32_to_virt(dma32_t addr)
45 return __va((__force unsigned long)addr);
48 static inline dma32_t u32_to_dma32(u32 addr)
50 return (__force dma32_t)addr;
53 static inline u32 dma32_to_u32(dma32_t addr)
55 return (__force u32)addr;
58 static inline dma32_t dma32_add(dma32_t a, u32 b)
60 return (__force dma32_t)((__force u32)a + b);
63 static inline dma32_t dma32_and(dma32_t a, u32 b)
65 return (__force dma32_t)((__force u32)a & b);
69 * Although DMA addresses should be obtained using the DMA API, in cases when
70 * it is known that the first argument holds a virtual address that points to
71 * DMA-able storage, then this function can be safely used.
73 static inline dma64_t virt_to_dma64(void *ptr)
75 return (__force dma64_t)__pa(ptr);
78 static inline void *dma64_to_virt(dma64_t addr)
80 return __va((__force unsigned long)addr);
83 static inline dma64_t u64_to_dma64(u64 addr)
85 return (__force dma64_t)addr;
88 static inline u64 dma64_to_u64(dma64_t addr)
90 return (__force u64)addr;
93 static inline dma64_t dma64_add(dma64_t a, u64 b)
95 return (__force dma64_t)((__force u64)a + b);
98 static inline dma64_t dma64_and(dma64_t a, u64 b)
100 return (__force dma64_t)((__force u64)a & b);
103 #endif /* _ASM_S390_DMA_TYPES_H_ */