Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The Chromium OS Authors. |
| 3 | * |
Wolfgang Denk | bd8ec7e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Simon Glass | 62cf912 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 7 | #ifndef __SANDBOX_ASM_IO_H |
| 8 | #define __SANDBOX_ASM_IO_H |
| 9 | |
Simon Glass | b4a905e | 2011-10-10 08:22:14 +0000 | [diff] [blame] | 10 | /* |
| 11 | * Given a physical address and a length, return a virtual address |
| 12 | * that can be used to access the memory range with the caching |
| 13 | * properties specified by "flags". |
| 14 | */ |
| 15 | #define MAP_NOCACHE (0) |
| 16 | #define MAP_WRCOMBINE (0) |
| 17 | #define MAP_WRBACK (0) |
| 18 | #define MAP_WRTHROUGH (0) |
| 19 | |
| 20 | void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags); |
| 21 | |
| 22 | /* |
| 23 | * Take down a mapping set up by map_physmem(). |
| 24 | */ |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 25 | void unmap_physmem(const void *vaddr, unsigned long flags); |
Simon Glass | 17dabf0 | 2013-02-24 17:33:14 +0000 | [diff] [blame] | 26 | |
| 27 | /* For sandbox, we want addresses to point into our RAM buffer */ |
| 28 | static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) |
| 29 | { |
| 30 | return map_physmem(paddr, len, MAP_WRBACK); |
| 31 | } |
| 32 | |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 33 | /* Remove a previous mapping */ |
Simon Glass | 17dabf0 | 2013-02-24 17:33:14 +0000 | [diff] [blame] | 34 | static inline void unmap_sysmem(const void *vaddr) |
| 35 | { |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 36 | unmap_physmem(vaddr, MAP_WRBACK); |
Simon Glass | 17dabf0 | 2013-02-24 17:33:14 +0000 | [diff] [blame] | 37 | } |
Simon Glass | e23d293 | 2013-04-20 08:42:37 +0000 | [diff] [blame] | 38 | |
| 39 | /* Map from a pointer to our RAM buffer */ |
Simon Glass | 656bfc4 | 2013-11-07 09:31:58 -0700 | [diff] [blame] | 40 | phys_addr_t map_to_sysmem(const void *ptr); |
Simon Glass | 62cf912 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 41 | |
Simon Glass | 125a27b | 2014-06-11 23:29:43 -0600 | [diff] [blame] | 42 | /* Define nops for sandbox I/O access */ |
| 43 | #define readb(addr) 0 |
| 44 | #define readw(addr) 0 |
| 45 | #define readl(addr) 0 |
| 46 | #define writeb(v, addr) |
| 47 | #define writew(v, addr) |
| 48 | #define writel(v, addr) |
| 49 | |
Simon Glass | 70778bc | 2015-03-05 12:25:26 -0700 | [diff] [blame] | 50 | /* I/O access functions */ |
| 51 | int inl(unsigned int addr); |
| 52 | int inw(unsigned int addr); |
| 53 | int inb(unsigned int addr); |
| 54 | |
| 55 | void outl(unsigned int value, unsigned int addr); |
| 56 | void outw(unsigned int value, unsigned int addr); |
| 57 | void outb(unsigned int value, unsigned int addr); |
| 58 | |
Simon Glass | 125a27b | 2014-06-11 23:29:43 -0600 | [diff] [blame] | 59 | #include <iotrace.h> |
| 60 | |
Simon Glass | 62cf912 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 61 | #endif |