Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Joe Hershberger | 65b905b | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 National Instruments |
| 4 | * |
| 5 | * (C) Copyright 2015 |
| 6 | * Joe Hershberger <joe.hershberger@ni.com> |
Joe Hershberger | 65b905b | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __MAPMEM_H |
| 10 | #define __MAPMEM_H |
| 11 | |
| 12 | /* Define a null map_sysmem() if the architecture doesn't use it */ |
| 13 | # ifdef CONFIG_ARCH_MAP_SYSMEM |
| 14 | #include <asm/io.h> |
| 15 | # else |
Tom Rini | a4a8ea9 | 2023-12-14 13:16:57 -0500 | [diff] [blame] | 16 | #include <linux/types.h> |
| 17 | |
Joe Hershberger | 65b905b | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 18 | static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) |
| 19 | { |
| 20 | return (void *)(uintptr_t)paddr; |
| 21 | } |
| 22 | |
| 23 | static inline void unmap_sysmem(const void *vaddr) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | static inline phys_addr_t map_to_sysmem(const void *ptr) |
| 28 | { |
| 29 | return (phys_addr_t)(uintptr_t)ptr; |
| 30 | } |
Simon Glass | 919f835 | 2023-12-31 08:25:54 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * nomap_sysmem() - pass through an address unchanged |
| 34 | * |
| 35 | * This is used to indicate an address which should NOT be mapped, e.g. in |
| 36 | * SMBIOS tables. Using this function instead of a case shows that the sandbox |
| 37 | * conversion has been done |
| 38 | */ |
| 39 | static inline void *nomap_sysmem(phys_addr_t paddr, unsigned long len) |
| 40 | { |
| 41 | return (void *)(uintptr_t)paddr; |
| 42 | } |
| 43 | |
| 44 | static inline phys_addr_t nomap_to_sysmem(const void *ptr) |
| 45 | { |
| 46 | return (phys_addr_t)(uintptr_t)ptr; |
| 47 | } |
| 48 | |
Joe Hershberger | 65b905b | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 49 | # endif |
| 50 | |
| 51 | #endif /* __MAPMEM_H */ |