Path: blob/master/arch/mips/loongson/common/early_printk.c
10818 views
/* early printk support1*2* Copyright (c) 2009 Philippe Vachon <[email protected]>3* Copyright (c) 2009 Lemote Inc.4* Author: Wu Zhangjin, [email protected]5*6* This program is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License as published by the8* Free Software Foundation; either version 2 of the License, or (at your9* option) any later version.10*/11#include <linux/serial_reg.h>1213#include <loongson.h>1415#define PORT(base, offset) (u8 *)(base + offset)1617static inline unsigned int serial_in(unsigned char *base, int offset)18{19return readb(PORT(base, offset));20}2122static inline void serial_out(unsigned char *base, int offset, int value)23{24writeb(value, PORT(base, offset));25}2627void prom_putchar(char c)28{29int timeout;30unsigned char *uart_base;3132uart_base = (unsigned char *)_loongson_uart_base;33timeout = 1024;3435while (((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) &&36(timeout-- > 0))37;3839serial_out(uart_base, UART_TX, c);40}414243