18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_VGA_H_
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_VGA_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifdef __KERNEL__
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/*
88c2ecf20Sopenharmony_ci *	Access to VGA videoram
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *	(c) 1998 Martin Mares <mj@ucw.cz>
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <asm/io.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define VT_BUF_HAVE_RW
208c2ecf20Sopenharmony_ci/*
218c2ecf20Sopenharmony_ci *  These are only needed for supporting VGA or MDA text mode, which use little
228c2ecf20Sopenharmony_ci *  endian byte ordering.
238c2ecf20Sopenharmony_ci *  In other cases, we can optimize by using native byte ordering and
248c2ecf20Sopenharmony_ci *  <linux/vt_buffer.h> has already done the right job for us.
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistatic inline void scr_writew(u16 val, volatile u16 *addr)
288c2ecf20Sopenharmony_ci{
298c2ecf20Sopenharmony_ci	*addr = cpu_to_le16(val);
308c2ecf20Sopenharmony_ci}
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic inline u16 scr_readw(volatile const u16 *addr)
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci	return le16_to_cpu(*addr);
358c2ecf20Sopenharmony_ci}
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define VT_BUF_HAVE_MEMSETW
388c2ecf20Sopenharmony_cistatic inline void scr_memsetw(u16 *s, u16 v, unsigned int n)
398c2ecf20Sopenharmony_ci{
408c2ecf20Sopenharmony_ci	memset16(s, cpu_to_le16(v), n / 2);
418c2ecf20Sopenharmony_ci}
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define VT_BUF_HAVE_MEMCPYW
448c2ecf20Sopenharmony_ci#define VT_BUF_HAVE_MEMMOVEW
458c2ecf20Sopenharmony_ci#define scr_memcpyw	memcpy
468c2ecf20Sopenharmony_ci#define scr_memmovew	memmove
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#endif /* !CONFIG_VGA_CONSOLE && !CONFIG_MDA_CONSOLE */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#ifdef __powerpc64__
518c2ecf20Sopenharmony_ci#define VGA_MAP_MEM(x,s) ((unsigned long) ioremap((x), s))
528c2ecf20Sopenharmony_ci#else
538c2ecf20Sopenharmony_ci#define VGA_MAP_MEM(x,s) (x)
548c2ecf20Sopenharmony_ci#endif
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define vga_readb(x) (*(x))
578c2ecf20Sopenharmony_ci#define vga_writeb(x,y) (*(y) = (x))
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#endif	/* __KERNEL__ */
608c2ecf20Sopenharmony_ci#endif	/* _ASM_POWERPC_VGA_H_ */
61