]> Git Repo - linux.git/blob - arch/s390/include/asm/dma-types.h
Linux 6.14-rc3
[linux.git] / arch / s390 / include / asm / dma-types.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2
3 #ifndef _ASM_S390_DMA_TYPES_H_
4 #define _ASM_S390_DMA_TYPES_H_
5
6 #include <linux/types.h>
7 #include <linux/io.h>
8
9 /*
10  * typedef dma32_t
11  * Contains a 31 bit absolute address to a DMA capable piece of storage.
12  *
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.
17  *
18  * This type is to be used when such fields can be modelled as 32 bit wide.
19  */
20 typedef u32 __bitwise dma32_t;
21
22 /*
23  * typedef dma64_t
24  * Contains a 64 bit absolute address to a DMA capable piece of storage.
25  *
26  * For CIO, DMA addresses are always absolute addresses. These addresses tend
27  * to be used in architectured memory blocks (like ORB, IDAW, MIDAW).
28  *
29  * This type is to be used to model such 64 bit wide fields.
30  */
31 typedef u64 __bitwise dma64_t;
32
33 /*
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.
37  */
38 static inline dma32_t virt_to_dma32(void *ptr)
39 {
40         return (__force dma32_t)__pa32(ptr);
41 }
42
43 static inline void *dma32_to_virt(dma32_t addr)
44 {
45         return __va((__force unsigned long)addr);
46 }
47
48 static inline dma32_t u32_to_dma32(u32 addr)
49 {
50         return (__force dma32_t)addr;
51 }
52
53 static inline u32 dma32_to_u32(dma32_t addr)
54 {
55         return (__force u32)addr;
56 }
57
58 static inline dma32_t dma32_add(dma32_t a, u32 b)
59 {
60         return (__force dma32_t)((__force u32)a + b);
61 }
62
63 static inline dma32_t dma32_and(dma32_t a, u32 b)
64 {
65         return (__force dma32_t)((__force u32)a & b);
66 }
67
68 /*
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.
72  */
73 static inline dma64_t virt_to_dma64(void *ptr)
74 {
75         return (__force dma64_t)__pa(ptr);
76 }
77
78 static inline void *dma64_to_virt(dma64_t addr)
79 {
80         return __va((__force unsigned long)addr);
81 }
82
83 static inline dma64_t u64_to_dma64(u64 addr)
84 {
85         return (__force dma64_t)addr;
86 }
87
88 static inline u64 dma64_to_u64(dma64_t addr)
89 {
90         return (__force u64)addr;
91 }
92
93 static inline dma64_t dma64_add(dma64_t a, u64 b)
94 {
95         return (__force dma64_t)((__force u64)a + b);
96 }
97
98 static inline dma64_t dma64_and(dma64_t a, u64 b)
99 {
100         return (__force dma64_t)((__force u64)a & b);
101 }
102
103 #endif /* _ASM_S390_DMA_TYPES_H_ */
This page took 0.034999 seconds and 4 git commands to generate.