2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 * Putting things on the screen/serial line using YAMONs facilities.
20 #include <linux/config.h>
21 #include <linux/init.h>
22 #include <linux/kernel.h>
23 #include <linux/serial_reg.h>
24 #include <linux/spinlock.h>
27 #ifdef CONFIG_MIPS_ATLAS
29 #include <asm/mips-boards/atlas.h>
32 * Atlas registers are memory mapped on 64-bit aligned boundaries and
33 * only word access are allowed.
34 * When reading the UART 8 bit registers only the LSB are valid.
36 static inline unsigned int serial_in(int offset)
38 return (*(volatile unsigned int *)(mips_io_port_base + ATLAS_UART_REGS_BASE + offset*8) & 0xff);
41 static inline void serial_out(int offset, int value)
43 *(volatile unsigned int *)(mips_io_port_base + ATLAS_UART_REGS_BASE + offset*8) = value;
46 #elif defined(CONFIG_MIPS_SEAD)
48 #include <asm/mips-boards/sead.h>
51 * SEAD registers are just like Atlas registers.
53 static inline unsigned int serial_in(int offset)
55 return (*(volatile unsigned int *)(mips_io_port_base + SEAD_UART0_REGS_BASE + offset*8) & 0xff);
58 static inline void serial_out(int offset, int value)
60 *(volatile unsigned int *)(mips_io_port_base + SEAD_UART0_REGS_BASE + offset*8) = value;
65 static inline unsigned int serial_in(int offset)
67 return inb(0x3f8 + offset);
70 static inline void serial_out(int offset, int value)
72 outb(value, 0x3f8 + offset);
76 int putPromChar(char c)
78 while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0)
81 serial_out(UART_TX, c);
86 char getPromChar(void)
88 while (!(serial_in(UART_LSR) & 1))
91 return serial_in(UART_RX);
94 static spinlock_t con_lock = SPIN_LOCK_UNLOCKED;
96 static char buf[1024];
98 void __init prom_printf(char *fmt, ...)
105 int putPromChar(char);
107 spin_lock_irqsave(con_lock, flags);
109 l = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf) */
114 for (p = buf; p < buf_end; p++) {
115 /* Crude cr/nl handling is better than none */
120 spin_unlock_irqrestore(con_lock, flags);