162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci#ifndef __ASM_GENERIC_FB_H_
462306a36Sopenharmony_ci#define __ASM_GENERIC_FB_H_
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci/*
762306a36Sopenharmony_ci * Only include this header file from your architecture's <asm/fb.h>.
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/io.h>
1162306a36Sopenharmony_ci#include <linux/mm_types.h>
1262306a36Sopenharmony_ci#include <linux/pgtable.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_cistruct fb_info;
1562306a36Sopenharmony_cistruct file;
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#ifndef fb_pgprotect
1862306a36Sopenharmony_ci#define fb_pgprotect fb_pgprotect
1962306a36Sopenharmony_cistatic inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
2062306a36Sopenharmony_ci				unsigned long off)
2162306a36Sopenharmony_ci{
2262306a36Sopenharmony_ci	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
2362306a36Sopenharmony_ci}
2462306a36Sopenharmony_ci#endif
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#ifndef fb_is_primary_device
2762306a36Sopenharmony_ci#define fb_is_primary_device fb_is_primary_device
2862306a36Sopenharmony_cistatic inline int fb_is_primary_device(struct fb_info *info)
2962306a36Sopenharmony_ci{
3062306a36Sopenharmony_ci	return 0;
3162306a36Sopenharmony_ci}
3262306a36Sopenharmony_ci#endif
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/*
3562306a36Sopenharmony_ci * I/O helpers for the framebuffer. Prefer these functions over their
3662306a36Sopenharmony_ci * regular counterparts. The regular I/O functions provide in-order
3762306a36Sopenharmony_ci * access and swap bytes to/from little-endian ordering. Neither is
3862306a36Sopenharmony_ci * required for framebuffers. Instead, the helpers read and write
3962306a36Sopenharmony_ci * raw framebuffer data. Independent operations can be reordered for
4062306a36Sopenharmony_ci * improved performance.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#ifndef fb_readb
4462306a36Sopenharmony_cistatic inline u8 fb_readb(const volatile void __iomem *addr)
4562306a36Sopenharmony_ci{
4662306a36Sopenharmony_ci	return __raw_readb(addr);
4762306a36Sopenharmony_ci}
4862306a36Sopenharmony_ci#define fb_readb fb_readb
4962306a36Sopenharmony_ci#endif
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#ifndef fb_readw
5262306a36Sopenharmony_cistatic inline u16 fb_readw(const volatile void __iomem *addr)
5362306a36Sopenharmony_ci{
5462306a36Sopenharmony_ci	return __raw_readw(addr);
5562306a36Sopenharmony_ci}
5662306a36Sopenharmony_ci#define fb_readw fb_readw
5762306a36Sopenharmony_ci#endif
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#ifndef fb_readl
6062306a36Sopenharmony_cistatic inline u32 fb_readl(const volatile void __iomem *addr)
6162306a36Sopenharmony_ci{
6262306a36Sopenharmony_ci	return __raw_readl(addr);
6362306a36Sopenharmony_ci}
6462306a36Sopenharmony_ci#define fb_readl fb_readl
6562306a36Sopenharmony_ci#endif
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#ifndef fb_readq
6862306a36Sopenharmony_ci#if defined(__raw_readq)
6962306a36Sopenharmony_cistatic inline u64 fb_readq(const volatile void __iomem *addr)
7062306a36Sopenharmony_ci{
7162306a36Sopenharmony_ci	return __raw_readq(addr);
7262306a36Sopenharmony_ci}
7362306a36Sopenharmony_ci#define fb_readq fb_readq
7462306a36Sopenharmony_ci#endif
7562306a36Sopenharmony_ci#endif
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#ifndef fb_writeb
7862306a36Sopenharmony_cistatic inline void fb_writeb(u8 b, volatile void __iomem *addr)
7962306a36Sopenharmony_ci{
8062306a36Sopenharmony_ci	__raw_writeb(b, addr);
8162306a36Sopenharmony_ci}
8262306a36Sopenharmony_ci#define fb_writeb fb_writeb
8362306a36Sopenharmony_ci#endif
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#ifndef fb_writew
8662306a36Sopenharmony_cistatic inline void fb_writew(u16 b, volatile void __iomem *addr)
8762306a36Sopenharmony_ci{
8862306a36Sopenharmony_ci	__raw_writew(b, addr);
8962306a36Sopenharmony_ci}
9062306a36Sopenharmony_ci#define fb_writew fb_writew
9162306a36Sopenharmony_ci#endif
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#ifndef fb_writel
9462306a36Sopenharmony_cistatic inline void fb_writel(u32 b, volatile void __iomem *addr)
9562306a36Sopenharmony_ci{
9662306a36Sopenharmony_ci	__raw_writel(b, addr);
9762306a36Sopenharmony_ci}
9862306a36Sopenharmony_ci#define fb_writel fb_writel
9962306a36Sopenharmony_ci#endif
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#ifndef fb_writeq
10262306a36Sopenharmony_ci#if defined(__raw_writeq)
10362306a36Sopenharmony_cistatic inline void fb_writeq(u64 b, volatile void __iomem *addr)
10462306a36Sopenharmony_ci{
10562306a36Sopenharmony_ci	__raw_writeq(b, addr);
10662306a36Sopenharmony_ci}
10762306a36Sopenharmony_ci#define fb_writeq fb_writeq
10862306a36Sopenharmony_ci#endif
10962306a36Sopenharmony_ci#endif
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#ifndef fb_memcpy_fromio
11262306a36Sopenharmony_cistatic inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
11362306a36Sopenharmony_ci{
11462306a36Sopenharmony_ci	memcpy_fromio(to, from, n);
11562306a36Sopenharmony_ci}
11662306a36Sopenharmony_ci#define fb_memcpy_fromio fb_memcpy_fromio
11762306a36Sopenharmony_ci#endif
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#ifndef fb_memcpy_toio
12062306a36Sopenharmony_cistatic inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
12162306a36Sopenharmony_ci{
12262306a36Sopenharmony_ci	memcpy_toio(to, from, n);
12362306a36Sopenharmony_ci}
12462306a36Sopenharmony_ci#define fb_memcpy_toio fb_memcpy_toio
12562306a36Sopenharmony_ci#endif
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#ifndef fb_memset
12862306a36Sopenharmony_cistatic inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
12962306a36Sopenharmony_ci{
13062306a36Sopenharmony_ci	memset_io(addr, c, n);
13162306a36Sopenharmony_ci}
13262306a36Sopenharmony_ci#define fb_memset fb_memset_io
13362306a36Sopenharmony_ci#endif
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci#endif /* __ASM_GENERIC_FB_H_ */
136