xref: /kernel/linux/linux-5.10/arch/mips/fw/arc/promlib.c (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
38c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
48c2ecf20Sopenharmony_ci * for more details.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 1996 David S. Miller (dm@sgi.com)
78c2ecf20Sopenharmony_ci * Compatibility with board caches, Ulf Carlsson
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#include <linux/kernel.h>
108c2ecf20Sopenharmony_ci#include <asm/sgialib.h>
118c2ecf20Sopenharmony_ci#include <asm/bcache.h>
128c2ecf20Sopenharmony_ci#include <asm/setup.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#if defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32)
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * For 64bit kernels working with a 32bit ARC PROM pointer arguments
178c2ecf20Sopenharmony_ci * for ARC calls need to reside in CKEG0/1. But as soon as the kernel
188c2ecf20Sopenharmony_ci * switches to it's first kernel thread stack is set to an address in
198c2ecf20Sopenharmony_ci * XKPHYS, so anything on stack can't be used anymore. This is solved
208c2ecf20Sopenharmony_ci * by using a * static declartion variables are put into BSS, which is
218c2ecf20Sopenharmony_ci * linked to a CKSEG0 address. Since this is only used on UP platforms
228c2ecf20Sopenharmony_ci * there is not spinlock needed
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci#define O32_STATIC	static
258c2ecf20Sopenharmony_ci#else
268c2ecf20Sopenharmony_ci#define O32_STATIC
278c2ecf20Sopenharmony_ci#endif
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/*
308c2ecf20Sopenharmony_ci * IP22 boardcache is not compatible with board caches.	 Thus we disable it
318c2ecf20Sopenharmony_ci * during romvec action.  Since r4xx0.c is always compiled and linked with your
328c2ecf20Sopenharmony_ci * kernel, this shouldn't cause any harm regardless what MIPS processor you
338c2ecf20Sopenharmony_ci * have.
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * The ARC write and read functions seem to interfere with the serial lines
368c2ecf20Sopenharmony_ci * in some way. You should be careful with them.
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_civoid prom_putchar(char c)
408c2ecf20Sopenharmony_ci{
418c2ecf20Sopenharmony_ci	O32_STATIC ULONG cnt;
428c2ecf20Sopenharmony_ci	O32_STATIC CHAR it;
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	it = c;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	bc_disable();
478c2ecf20Sopenharmony_ci	ArcWrite(1, &it, 1, &cnt);
488c2ecf20Sopenharmony_ci	bc_enable();
498c2ecf20Sopenharmony_ci}
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cichar prom_getchar(void)
528c2ecf20Sopenharmony_ci{
538c2ecf20Sopenharmony_ci	O32_STATIC ULONG cnt;
548c2ecf20Sopenharmony_ci	O32_STATIC CHAR c;
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	bc_disable();
578c2ecf20Sopenharmony_ci	ArcRead(0, &c, 1, &cnt);
588c2ecf20Sopenharmony_ci	bc_enable();
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	return c;
618c2ecf20Sopenharmony_ci}
62