PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/mips/boot/compressed/uart-16550.c

https://bitbucket.org/cresqo/cm7-p500-kernel
C | 43 lines | 30 code | 10 blank | 3 comment | 5 complexity | d696470f17d582296abd511339a38a82 MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
 1/*
 2 * 16550 compatible uart based serial debug support for zboot
 3 */
 4
 5#include <linux/types.h>
 6#include <linux/serial_reg.h>
 7#include <linux/init.h>
 8
 9#include <asm/addrspace.h>
10
11#if defined(CONFIG_MACH_LOONGSON) || defined(CONFIG_MIPS_MALTA)
12#define UART_BASE 0x1fd003f8
13#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
14#endif
15
16#ifdef CONFIG_AR7
17#include <ar7.h>
18#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
19#endif
20
21#ifndef PORT
22#error please define the serial port address for your own machine
23#endif
24
25static inline unsigned int serial_in(int offset)
26{
27	return *((char *)PORT(offset));
28}
29
30static inline void serial_out(int offset, int value)
31{
32	*((char *)PORT(offset)) = value;
33}
34
35void putc(char c)
36{
37	int timeout = 1024;
38
39	while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
40		;
41
42	serial_out(UART_TX, c);
43}