Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * 16550 compatible uart based serial debug support for zboot
 4 */
 5
 6#include <linux/types.h>
 7#include <linux/serial_reg.h>
 8
 9#include <asm/addrspace.h>
10
 
 
11#if defined(CONFIG_MACH_LOONGSON64) || 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#ifdef CONFIG_MACH_INGENIC
22#define INGENIC_UART_BASE_ADDR	(0x10030000 + 0x1000 * CONFIG_ZBOOT_INGENIC_UART)
23#define PORT(offset) (CKSEG1ADDR(INGENIC_UART_BASE_ADDR) + (4 * offset))
24#endif
25
26#ifndef IOTYPE
27#define IOTYPE char
28#endif
29
30#ifndef PORT
31#error please define the serial port address for your own machine
32#endif
33
34static inline unsigned int serial_in(int offset)
35{
36	return *((volatile IOTYPE *)PORT(offset)) & 0xFF;
37}
38
39static inline void serial_out(int offset, int value)
40{
41	*((volatile IOTYPE *)PORT(offset)) = value & 0xFF;
42}
43
44void putc(char c)
45{
46	int timeout = 1000000;
47
48	while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
49		;
50
51	serial_out(UART_TX, c);
52}
v6.9.4
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * 16550 compatible uart based serial debug support for zboot
 4 */
 5
 6#include <linux/types.h>
 7#include <linux/serial_reg.h>
 8
 9#include <asm/addrspace.h>
10
11#include "decompress.h"
12
13#if defined(CONFIG_MACH_LOONGSON64) || defined(CONFIG_MIPS_MALTA)
14#define UART_BASE 0x1fd003f8
15#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
 
 
 
 
 
16#endif
17
18#ifdef CONFIG_MACH_INGENIC
19#define INGENIC_UART_BASE_ADDR	(0x10030000 + 0x1000 * CONFIG_ZBOOT_INGENIC_UART)
20#define PORT(offset) (CKSEG1ADDR(INGENIC_UART_BASE_ADDR) + (4 * offset))
21#endif
22
23#ifndef IOTYPE
24#define IOTYPE char
25#endif
26
27#ifndef PORT
28#error please define the serial port address for your own machine
29#endif
30
31static inline unsigned int serial_in(int offset)
32{
33	return *((volatile IOTYPE *)PORT(offset)) & 0xFF;
34}
35
36static inline void serial_out(int offset, int value)
37{
38	*((volatile IOTYPE *)PORT(offset)) = value & 0xFF;
39}
40
41void putc(char c)
42{
43	int timeout = 1000000;
44
45	while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
46		;
47
48	serial_out(UART_TX, c);
49}