xref: /openbmc/linux/arch/mips/sgi-ip27/ip27-console.c (revision 8dd06ef34b6e2f41b29fbf5fc1663780f2524285)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * This file is subject to the terms and conditions of the GNU General Public
31da177e4SLinus Torvalds  * License.  See the file "COPYING" in the main directory of this archive
41da177e4SLinus Torvalds  * for more details.
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * Copyright (C) 2001, 2002 Ralf Baechle
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds #include <asm/page.h>
105c93316cSAlexander Sverdlin #include <asm/setup.h>
111da177e4SLinus Torvalds #include <asm/sn/addrs.h>
12b78e9d63SThomas Bogendoerfer #include <asm/sn/agent.h>
131da177e4SLinus Torvalds #include <asm/sn/klconfig.h>
141da177e4SLinus Torvalds #include <asm/sn/ioc3.h>
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #include <linux/serial.h>
171da177e4SLinus Torvalds #include <linux/serial_core.h>
181da177e4SLinus Torvalds 
19*9d0aaf98SThomas Bogendoerfer #include "ip27-common.h"
20*9d0aaf98SThomas Bogendoerfer 
211da177e4SLinus Torvalds #define IOC3_CLK	(22000000 / 3)
221da177e4SLinus Torvalds #define IOC3_FLAGS	(0)
231da177e4SLinus Torvalds 
console_uart(void)241da177e4SLinus Torvalds static inline struct ioc3_uartregs *console_uart(void)
251da177e4SLinus Torvalds {
261da177e4SLinus Torvalds 	struct ioc3 *ioc3;
2701d42abdSRalf Baechle 	nasid_t nasid;
281da177e4SLinus Torvalds 
2901d42abdSRalf Baechle 	nasid = (master_nasid == INVALID_NASID) ? get_nasid() : master_nasid;
3001d42abdSRalf Baechle 	ioc3 = (struct ioc3 *)KL_CONFIG_CH_CONS_INFO(nasid)->memory_base;
311da177e4SLinus Torvalds 
321da177e4SLinus Torvalds 	return &ioc3->sregs.uarta;
331da177e4SLinus Torvalds }
341da177e4SLinus Torvalds 
prom_putchar(char c)35f7be4e75SAaro Koskinen void prom_putchar(char c)
361da177e4SLinus Torvalds {
371da177e4SLinus Torvalds 	struct ioc3_uartregs *uart = console_uart();
381da177e4SLinus Torvalds 
39cbe7d517SThomas Bogendoerfer 	while ((readb(&uart->iu_lsr) & 0x20) == 0)
40cbe7d517SThomas Bogendoerfer 		;
41cbe7d517SThomas Bogendoerfer 	writeb(c, &uart->iu_thr);
421da177e4SLinus Torvalds }
43