xref: /openbmc/linux/arch/arm/include/asm/fixmap.h (revision a05e54c103b0b8e1dab5d04b411f1d48387c4903)
15f0fbf9eSNicolas Pitre #ifndef _ASM_FIXMAP_H
25f0fbf9eSNicolas Pitre #define _ASM_FIXMAP_H
35f0fbf9eSNicolas Pitre 
4*a05e54c1SLiu Hua #define FIXADDR_START		0xffc00000UL
5*a05e54c1SLiu Hua #define FIXADDR_TOP		0xffe00000UL
65f0fbf9eSNicolas Pitre #define FIXADDR_SIZE		(FIXADDR_TOP - FIXADDR_START)
75f0fbf9eSNicolas Pitre 
84221e2e6SLiu Hua #define FIX_KMAP_NR_PTES	(FIXADDR_SIZE >> PAGE_SHIFT)
95f0fbf9eSNicolas Pitre 
105f0fbf9eSNicolas Pitre #define __fix_to_virt(x)	(FIXADDR_START + ((x) << PAGE_SHIFT))
115f0fbf9eSNicolas Pitre #define __virt_to_fix(x)	(((x) - FIXADDR_START) >> PAGE_SHIFT)
125f0fbf9eSNicolas Pitre 
135f0fbf9eSNicolas Pitre extern void __this_fixmap_does_not_exist(void);
145f0fbf9eSNicolas Pitre 
155f0fbf9eSNicolas Pitre static inline unsigned long fix_to_virt(const unsigned int idx)
165f0fbf9eSNicolas Pitre {
174221e2e6SLiu Hua 	if (idx >= FIX_KMAP_NR_PTES)
185f0fbf9eSNicolas Pitre 		__this_fixmap_does_not_exist();
195f0fbf9eSNicolas Pitre 	return __fix_to_virt(idx);
205f0fbf9eSNicolas Pitre }
215f0fbf9eSNicolas Pitre 
225f0fbf9eSNicolas Pitre static inline unsigned int virt_to_fix(const unsigned long vaddr)
235f0fbf9eSNicolas Pitre {
245f0fbf9eSNicolas Pitre 	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
255f0fbf9eSNicolas Pitre 	return __virt_to_fix(vaddr);
265f0fbf9eSNicolas Pitre }
275f0fbf9eSNicolas Pitre 
285f0fbf9eSNicolas Pitre #endif
29