Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Atmel Corporation |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __ASM_AVR32_IO_H |
| 7 | #define __ASM_AVR32_IO_H |
| 8 | |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 9 | #include <asm/types.h> |
| 10 | |
Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 11 | #ifdef __KERNEL__ |
| 12 | |
| 13 | /* |
| 14 | * Generic IO read/write. These perform native-endian accesses. Note |
| 15 | * that some architectures will want to re-define __raw_{read,write}w. |
| 16 | */ |
| 17 | extern void __raw_writesb(unsigned int addr, const void *data, int bytelen); |
| 18 | extern void __raw_writesw(unsigned int addr, const void *data, int wordlen); |
| 19 | extern void __raw_writesl(unsigned int addr, const void *data, int longlen); |
| 20 | |
| 21 | extern void __raw_readsb(unsigned int addr, void *data, int bytelen); |
| 22 | extern void __raw_readsw(unsigned int addr, void *data, int wordlen); |
| 23 | extern void __raw_readsl(unsigned int addr, void *data, int longlen); |
| 24 | |
| 25 | #define __raw_writeb(v,a) (*(volatile unsigned char *)(a) = (v)) |
| 26 | #define __raw_writew(v,a) (*(volatile unsigned short *)(a) = (v)) |
| 27 | #define __raw_writel(v,a) (*(volatile unsigned int *)(a) = (v)) |
| 28 | |
| 29 | #define __raw_readb(a) (*(volatile unsigned char *)(a)) |
| 30 | #define __raw_readw(a) (*(volatile unsigned short *)(a)) |
| 31 | #define __raw_readl(a) (*(volatile unsigned int *)(a)) |
| 32 | |
| 33 | /* As long as I/O is only performed in P4 (or possibly P3), we're safe */ |
| 34 | #define writeb(v,a) __raw_writeb(v,a) |
| 35 | #define writew(v,a) __raw_writew(v,a) |
| 36 | #define writel(v,a) __raw_writel(v,a) |
| 37 | |
| 38 | #define readb(a) __raw_readb(a) |
| 39 | #define readw(a) __raw_readw(a) |
| 40 | #define readl(a) __raw_readl(a) |
| 41 | |
| 42 | /* |
| 43 | * Bad read/write accesses... |
| 44 | */ |
| 45 | extern void __readwrite_bug(const char *fn); |
| 46 | |
| 47 | #define IO_SPACE_LIMIT 0xffffffff |
| 48 | |
| 49 | /* |
| 50 | * All I/O is memory mapped, so these macros doesn't make very much sense |
| 51 | */ |
| 52 | #define outb(v,p) __raw_writeb(v, p) |
| 53 | #define outw(v,p) __raw_writew(cpu_to_le16(v),p) |
| 54 | #define outl(v,p) __raw_writel(cpu_to_le32(v),p) |
| 55 | |
| 56 | #define inb(p) ({ unsigned int __v = __raw_readb(p); __v; }) |
| 57 | #define inw(p) ({ unsigned int __v = __le16_to_cpu(__raw_readw(p)); __v; }) |
| 58 | #define inl(p) ({ unsigned int __v = __le32_to_cpu(__raw_readl(p)); __v; }) |
| 59 | |
Olav Morken | 51b2ec9 | 2009-01-23 12:56:28 +0100 | [diff] [blame] | 60 | #include <asm/arch/addrspace.h> |
| 61 | /* Provides virt_to_phys, phys_to_virt, cached, uncached, map_physmem */ |
Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 62 | |
| 63 | #endif /* __KERNEL__ */ |
| 64 | |
Haiying Wang | c123a38 | 2007-02-21 16:52:31 +0100 | [diff] [blame] | 65 | static inline void sync(void) |
| 66 | { |
Haavard Skinnemoen | f985551 | 2007-12-13 12:56:33 +0100 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /* |
| 70 | * Take down a mapping set up by map_physmem(). |
| 71 | */ |
| 72 | static inline void unmap_physmem(void *vaddr, unsigned long len) |
| 73 | { |
| 74 | |
| 75 | } |
| 76 | |
Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 77 | #endif /* __ASM_AVR32_IO_H */ |