xref: /openbmc/linux/include/asm-generic/fb.h (revision ec7743c9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __ASM_GENERIC_FB_H_
4 #define __ASM_GENERIC_FB_H_
5 
6 /*
7  * Only include this header file from your architecture's <asm/fb.h>.
8  */
9 
10 #include <linux/io.h>
11 #include <linux/mm_types.h>
12 #include <linux/pgtable.h>
13 
14 struct fb_info;
15 struct file;
16 
17 #ifndef fb_pgprotect
18 #define fb_pgprotect fb_pgprotect
19 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
20 				unsigned long off)
21 {
22 	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
23 }
24 #endif
25 
26 #ifndef fb_is_primary_device
27 #define fb_is_primary_device fb_is_primary_device
28 static inline int fb_is_primary_device(struct fb_info *info)
29 {
30 	return 0;
31 }
32 #endif
33 
34 /*
35  * I/O helpers for the framebuffer. Prefer these functions over their
36  * regular counterparts. The regular I/O functions provide in-order
37  * access and swap bytes to/from little-endian ordering. Neither is
38  * required for framebuffers. Instead, the helpers read and write
39  * raw framebuffer data. Independent operations can be reordered for
40  * improved performance.
41  */
42 
43 #ifndef fb_readb
44 static inline u8 fb_readb(const volatile void __iomem *addr)
45 {
46 	return __raw_readb(addr);
47 }
48 #define fb_readb fb_readb
49 #endif
50 
51 #ifndef fb_readw
52 static inline u16 fb_readw(const volatile void __iomem *addr)
53 {
54 	return __raw_readw(addr);
55 }
56 #define fb_readw fb_readw
57 #endif
58 
59 #ifndef fb_readl
60 static inline u32 fb_readl(const volatile void __iomem *addr)
61 {
62 	return __raw_readl(addr);
63 }
64 #define fb_readl fb_readl
65 #endif
66 
67 #ifndef fb_readq
68 #if defined(__raw_readq)
69 static inline u64 fb_readq(const volatile void __iomem *addr)
70 {
71 	return __raw_readq(addr);
72 }
73 #define fb_readq fb_readq
74 #endif
75 #endif
76 
77 #ifndef fb_writeb
78 static inline void fb_writeb(u8 b, volatile void __iomem *addr)
79 {
80 	__raw_writeb(b, addr);
81 }
82 #define fb_writeb fb_writeb
83 #endif
84 
85 #ifndef fb_writew
86 static inline void fb_writew(u16 b, volatile void __iomem *addr)
87 {
88 	__raw_writew(b, addr);
89 }
90 #define fb_writew fb_writew
91 #endif
92 
93 #ifndef fb_writel
94 static inline void fb_writel(u32 b, volatile void __iomem *addr)
95 {
96 	__raw_writel(b, addr);
97 }
98 #define fb_writel fb_writel
99 #endif
100 
101 #ifndef fb_writeq
102 #if defined(__raw_writeq)
103 static inline void fb_writeq(u64 b, volatile void __iomem *addr)
104 {
105 	__raw_writeq(b, addr);
106 }
107 #define fb_writeq fb_writeq
108 #endif
109 #endif
110 
111 #ifndef fb_memcpy_fromio
112 static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
113 {
114 	memcpy_fromio(to, from, n);
115 }
116 #define fb_memcpy_fromio fb_memcpy_fromio
117 #endif
118 
119 #ifndef fb_memcpy_toio
120 static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
121 {
122 	memcpy_toio(to, from, n);
123 }
124 #define fb_memcpy_toio fb_memcpy_toio
125 #endif
126 
127 #ifndef fb_memset
128 static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
129 {
130 	memset_io(addr, c, n);
131 }
132 #define fb_memset fb_memset_io
133 #endif
134 
135 #endif /* __ASM_GENERIC_FB_H_ */
136