Stefan Kristiansson | 6e560bb | 2011-11-26 19:04:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2011, Julius Baxter <julius@opencores.org> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 17 | * MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef __ASM_OPENRISC_IO_H |
| 21 | #define __ASM_OPENRISC_IO_H |
| 22 | |
| 23 | /* |
| 24 | * Given a physical address and a length, return a virtual address |
| 25 | * that can be used to access the memory range with the caching |
| 26 | * properties specified by "flags". |
| 27 | */ |
| 28 | #define MAP_NOCACHE (0) |
| 29 | #define MAP_WRCOMBINE (0) |
| 30 | #define MAP_WRBACK (0) |
| 31 | #define MAP_WRTHROUGH (0) |
| 32 | |
| 33 | static inline void * |
| 34 | map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) |
| 35 | { |
| 36 | return (void *)paddr; |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | * Take down a mapping set up by map_physmem(). |
| 41 | */ |
| 42 | static inline void unmap_physmem(void *vaddr, unsigned long flags) |
| 43 | { |
| 44 | |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Change virtual addresses to physical addresses |
| 49 | */ |
| 50 | static inline phys_addr_t virt_to_phys(void *vaddr) |
| 51 | { |
| 52 | return (phys_addr_t)(vaddr); |
| 53 | } |
| 54 | |
| 55 | |
| 56 | /* |
| 57 | * readX/writeX() are used to access memory mapped devices. On some |
| 58 | * architectures the memory mapped IO stuff needs to be accessed |
| 59 | * differently. On the openrisc architecture, we just read/write the |
| 60 | * memory location directly. |
| 61 | */ |
| 62 | #define readb(addr) (*(volatile unsigned char *) (addr)) |
| 63 | #define readw(addr) (*(volatile unsigned short *) (addr)) |
| 64 | #define readl(addr) (*(volatile unsigned int *) (addr)) |
| 65 | #define __raw_readb readb |
| 66 | #define __raw_readw readw |
| 67 | #define __raw_readl readl |
| 68 | |
| 69 | #define writeb(b, addr) ((*(volatile unsigned char *) (addr)) = (b)) |
| 70 | #define writew(b, addr) ((*(volatile unsigned short *) (addr)) = (b)) |
| 71 | #define writel(b, addr) ((*(volatile unsigned int *) (addr)) = (b)) |
| 72 | #define __raw_writeb writeb |
| 73 | #define __raw_writew writew |
| 74 | #define __raw_writel writel |
| 75 | |
| 76 | #define memset_io(a, b, c) memset((void *)(a), (b), (c)) |
| 77 | #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) |
| 78 | #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) |
| 79 | |
| 80 | /* |
| 81 | * Again, OpenRISC does not require mem IO specific function. |
| 82 | */ |
| 83 | |
| 84 | |
| 85 | #define IO_BASE 0x0 |
| 86 | #define IO_SPACE_LIMIT 0xffffffff |
| 87 | |
| 88 | #define inb(port) readb((port + IO_BASE)) |
| 89 | #define outb(value, port) writeb((value), (port + IO_BASE)) |
| 90 | #define inb_p(port) inb((port)) |
| 91 | #define outb_p(value, port) outb((value), (port)) |
| 92 | |
| 93 | /* |
| 94 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem |
| 95 | * access |
| 96 | */ |
| 97 | #define xlate_dev_mem_ptr(p) __va(p) |
| 98 | |
| 99 | /* |
| 100 | * Convert a virtual cached pointer to an uncached pointer |
| 101 | */ |
| 102 | #define xlate_dev_kmem_ptr(p) p |
| 103 | |
| 104 | #define ioread8(addr) readb(addr) |
| 105 | #define ioread16(addr) readw(addr) |
| 106 | #define ioread32(addr) readl(addr) |
| 107 | |
| 108 | #define iowrite8(v, addr) writeb((v), (addr)) |
| 109 | #define iowrite16(v, addr) writew((v), (addr)) |
| 110 | #define iowrite32(v, addr) writel((v), (addr)) |
| 111 | |
| 112 | #endif |