spi-topcliff-pch: Fix issue for transmitting over 4KByte
[zen-stable.git] / arch / openrisc / include / asm / fixmap.h
blob52733416c1f313d3027fa06c66d3d9e6f8ed8b42
1 /*
2 * OpenRISC Linux
4 * Linux architectural port borrowing liberally from similar works of
5 * others. All original copyrights apply as per the original source
6 * declaration.
8 * OpenRISC implementation:
9 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
10 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
11 * et al.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
19 #ifndef __ASM_OPENRISC_FIXMAP_H
20 #define __ASM_OPENRISC_FIXMAP_H
22 /* Why exactly do we need 2 empty pages between the top of the fixed
23 * addresses and the top of virtual memory? Something is using that
24 * memory space but not sure what right now... If you find it, leave
25 * a comment here.
27 #define FIXADDR_TOP ((unsigned long) (-2*PAGE_SIZE))
29 #include <linux/kernel.h>
30 #include <asm/page.h>
33 * On OpenRISC we use these special fixed_addresses for doing ioremap
34 * early in the boot process before memory initialization is complete.
35 * This is used, in particular, by the early serial console code.
37 * It's not really 'fixmap', per se, but fits loosely into the same
38 * paradigm.
40 enum fixed_addresses {
42 * FIX_IOREMAP entries are useful for mapping physical address
43 * space before ioremap() is useable, e.g. really early in boot
44 * before kmalloc() is working.
46 #define FIX_N_IOREMAPS 32
47 FIX_IOREMAP_BEGIN,
48 FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1,
49 __end_of_fixed_addresses
52 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
53 /* FIXADDR_BOTTOM might be a better name here... */
54 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
56 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
57 #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
60 * 'index to address' translation. If anyone tries to use the idx
61 * directly without tranlation, we catch the bug with a NULL-deference
62 * kernel oops. Illegal ranges of incoming indices are caught too.
64 static __always_inline unsigned long fix_to_virt(const unsigned int idx)
67 * this branch gets completely eliminated after inlining,
68 * except when someone tries to use fixaddr indices in an
69 * illegal way. (such as mixing up address types or using
70 * out-of-range indices).
72 * If it doesn't get removed, the linker will complain
73 * loudly with a reasonably clear error message..
75 if (idx >= __end_of_fixed_addresses)
76 BUG();
78 return __fix_to_virt(idx);
81 static inline unsigned long virt_to_fix(const unsigned long vaddr)
83 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
84 return __virt_to_fix(vaddr);
87 #endif