mirror of
https://github.com/torvalds/linux.git
synced 2024-11-19 10:31:48 +00:00
5c93316c8c
prom_putchar() is used centrally in early printk infrastructure therefore at least MIPS should agree on the function return type. [paul.burton@mips.com: - Include linux/types.h in asm/setup.h to gain the bool typedef before we start include asm/setup.h elsewhere. - Include asm/setup.h in all files that use or define prom_putchar(). - Also standardise on signed rather than unsigned char argument.] Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Signed-off-by: Paul Burton <paul.burton@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/19842/ Cc: linux-mips@linux-mips.org Cc: Ralf Baechle <ralf@linux-mips.org> Cc: James Hogan <jhogan@kernel.org> Cc: Jonas Gorski <jonas.gorski@gmail.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com>
68 lines
1.8 KiB
C
68 lines
1.8 KiB
C
/*
|
|
* 8250/16550-type serial ports prom_putchar()
|
|
*
|
|
* Copyright (C) 2010 Yoichi Yuasa <yuasa@linux-mips.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
#include <linux/io.h>
|
|
#include <linux/serial_core.h>
|
|
#include <linux/serial_reg.h>
|
|
#include <asm/setup.h>
|
|
|
|
static void __iomem *serial8250_base;
|
|
static unsigned int serial8250_reg_shift;
|
|
static unsigned int serial8250_tx_timeout;
|
|
|
|
void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift,
|
|
unsigned int timeout)
|
|
{
|
|
serial8250_base = (void __iomem *)base;
|
|
serial8250_reg_shift = reg_shift;
|
|
serial8250_tx_timeout = timeout;
|
|
}
|
|
|
|
static inline u8 serial_in(int offset)
|
|
{
|
|
return readb(serial8250_base + (offset << serial8250_reg_shift));
|
|
}
|
|
|
|
static inline void serial_out(int offset, char value)
|
|
{
|
|
writeb(value, serial8250_base + (offset << serial8250_reg_shift));
|
|
}
|
|
|
|
void prom_putchar(char c)
|
|
{
|
|
unsigned int timeout;
|
|
int status, bits;
|
|
|
|
if (!serial8250_base)
|
|
return;
|
|
|
|
timeout = serial8250_tx_timeout;
|
|
bits = UART_LSR_TEMT | UART_LSR_THRE;
|
|
|
|
do {
|
|
status = serial_in(UART_LSR);
|
|
|
|
if (--timeout == 0)
|
|
break;
|
|
} while ((status & bits) != bits);
|
|
|
|
if (timeout)
|
|
serial_out(UART_TX, c);
|
|
}
|