File Index
Files and directories
Sign in
FILE

dma-types.h

File preview with syntax highlighting.

linux-6.19.14/arch/s390/include/asm/dma-types.h C
  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 */
 20typedef 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 */
 31typedef 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 */
 38static inline dma32_t virt_to_dma32(void *ptr)
 39{
 40	return (__force dma32_t)__pa32(ptr);
 41}
 42
 43static inline void *dma32_to_virt(dma32_t addr)
 44{
 45	return __va((__force unsigned long)addr);
 46}
 47
 48static inline dma32_t u32_to_dma32(u32 addr)
 49{
 50	return (__force dma32_t)addr;
 51}
 52
 53static inline u32 dma32_to_u32(dma32_t addr)
 54{
 55	return (__force u32)addr;
 56}
 57
 58static inline dma32_t dma32_add(dma32_t a, u32 b)
 59{
 60	return (__force dma32_t)((__force u32)a + b);
 61}
 62
 63static 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 */
 73static inline dma64_t virt_to_dma64(void *ptr)
 74{
 75	return (__force dma64_t)__pa(ptr);
 76}
 77
 78static inline void *dma64_to_virt(dma64_t addr)
 79{
 80	return __va((__force unsigned long)addr);
 81}
 82
 83static inline dma64_t u64_to_dma64(u64 addr)
 84{
 85	return (__force dma64_t)addr;
 86}
 87
 88static inline u64 dma64_to_u64(dma64_t addr)
 89{
 90	return (__force u64)addr;
 91}
 92
 93static inline dma64_t dma64_add(dma64_t a, u64 b)
 94{
 95	return (__force dma64_t)((__force u64)a + b);
 96}
 97
 98static 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_ */
~/ Read-only file preview.