4/29/2020
Godson 3A1000 Processor User Manual
111
LEAF (initserial)
li a0, GS3_UART_BASE
li
t1,128
sb
t1,3 (a0)
// Access the divider register
li
t1,0x12 # divider, highest possible baud rate
sb
t1,0 (a0)
// Frequency divider register 1, stores the lower 8 bits of the frequency divider register, the calculation formula is
// Working clock / (baud rate * 16), in this case 33M / (115200 * 16)
li
t1,0x0
# divider, highest possible baud rate
sb
t1,1 (a0)
// Frequency divider register 2, stores the upper 8 bits of the frequency divider register
li
t1,3
sb
t1,3 (a0)
// The data bits are 8 bits
li
t1,0
sb
t1,1 (a0)
// Do not use interrupt
125
Page 138
Godson 3A1000 Processor User Manual Part 2
li
t1,71
sb
t1,2 (a0)
// Set FIFO control register
jr
ra
nop
END (initserial)
GS3_UART_BASE is also defined in the start.S file, which is 0xbfe001e0.
In tgt_machdep.c, the structure ConfigEntry also gives the UART settings, the function ns16550 also
It is the processing function of UART sending and receiving.
12.3 Serial configuration of Linux kernel
There are three main files for configuring the serial port in the Linux kernel: include / asm / serial.h,
arch / mips / kernel / 8250-platform.c, arch / mips / lemote / ev3a / dbg_io.c. These three configuration files involve
The setting of the serial port base address depends on the specific serial port used. In the kernel, in arch / mips / Kconfig
There is also a macro definition CONFIG_CPU_UART, used to select whether to use LPC serial port or CPU serial port. vertical
Although I chose the CPU UART, but whether it is UART0 or UART1, I still need to check the above three files.
Whether the definition of the serial port base address is correct.
In arch / mips / lemote / ev3a / dbg_io.c is mainly used in the kernel startup process, there is no initial
A simple serial port printing method that is used for the convenience of kernel debugging at the stage of conversion
It is often used in the kernel debugging stage, it will call putDebugChar () to print the characters one by one
Print to the console. include / asm / serial.h provides a macro definition for the serial driver / serial / 8250.c,
If you use the UART0 of the CPU, the definition is as follows:
#define STD_SERIAL_PORT_DEFNS \
/ * UART_CLK PORT_IRQ FLAGS * /
{
.baud_base
=
BASE_BAUD,
.irq
=
58,
\