162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_FB_H_
362306a36Sopenharmony_ci#define _ASM_FB_H_
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/compiler.h>
662306a36Sopenharmony_ci#include <linux/efi.h>
762306a36Sopenharmony_ci#include <linux/string.h>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <asm/page.h>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cistruct file;
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistatic inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
1462306a36Sopenharmony_ci				unsigned long off)
1562306a36Sopenharmony_ci{
1662306a36Sopenharmony_ci	if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
1762306a36Sopenharmony_ci		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
1862306a36Sopenharmony_ci	else
1962306a36Sopenharmony_ci		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
2062306a36Sopenharmony_ci}
2162306a36Sopenharmony_ci#define fb_pgprotect fb_pgprotect
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cistatic inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
2462306a36Sopenharmony_ci{
2562306a36Sopenharmony_ci	memcpy(to, (void __force *)from, n);
2662306a36Sopenharmony_ci}
2762306a36Sopenharmony_ci#define fb_memcpy_fromio fb_memcpy_fromio
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_cistatic inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
3062306a36Sopenharmony_ci{
3162306a36Sopenharmony_ci	memcpy((void __force *)to, from, n);
3262306a36Sopenharmony_ci}
3362306a36Sopenharmony_ci#define fb_memcpy_toio fb_memcpy_toio
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_cistatic inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
3662306a36Sopenharmony_ci{
3762306a36Sopenharmony_ci	memset((void __force *)addr, c, n);
3862306a36Sopenharmony_ci}
3962306a36Sopenharmony_ci#define fb_memset fb_memset_io
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#include <asm-generic/fb.h>
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#endif /* _ASM_FB_H_ */
44