Linux Audio

Check our new training course

Loading...
v3.1
 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}
v4.10.11
 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
 8#include <asm/addrspace.h>
 9
10#if defined(CONFIG_MACH_LOONGSON64) || defined(CONFIG_MIPS_MALTA)
11#define UART_BASE 0x1fd003f8
12#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
13#endif
14
15#ifdef CONFIG_AR7
16#include <ar7.h>
17#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
18#endif
19
20#if defined(CONFIG_MACH_JZ4740) || defined(CONFIG_MACH_JZ4780)
21#include <asm/mach-jz4740/base.h>
22#define PORT(offset) (CKSEG1ADDR(JZ4740_UART0_BASE_ADDR) + (4 * offset))
23#endif
24
25#ifdef CONFIG_CPU_XLR
26#define UART0_BASE  0x1EF14000
27#define PORT(offset) (CKSEG1ADDR(UART0_BASE) + (4 * offset))
28#define IOTYPE unsigned int
29#endif
30
31#ifdef CONFIG_CPU_XLP
32#define UART0_BASE  0x18030100
33#define PORT(offset) (CKSEG1ADDR(UART0_BASE) + (4 * offset))
34#define IOTYPE unsigned int
35#endif
36
37#ifndef IOTYPE
38#define IOTYPE char
39#endif
40
41#ifndef PORT
42#error please define the serial port address for your own machine
43#endif
44
45static inline unsigned int serial_in(int offset)
46{
47	return *((volatile IOTYPE *)PORT(offset)) & 0xFF;
48}
49
50static inline void serial_out(int offset, int value)
51{
52	*((volatile IOTYPE *)PORT(offset)) = value & 0xFF;
53}
54
55void putc(char c)
56{
57	int timeout = 1000000;
58
59	while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
60		;
61
62	serial_out(UART_TX, c);
63}