pmon下
diff --git a/Targets/LS2K/include/bonito.h b/Targets/LS2K/include/bonito.h
index 046273d..2db2b6d 100644
--- a/Targets/LS2K/include/bonito.h
+++ b/Targets/LS2K/include/bonito.h
@@ -56,6 +56,9 @@ struct pci_config_data {
#define COM1_BASE_ADDR 0xbfe00000
+#define COM4_BASE_ADDR 0xbfe00300
+#define COM5_BASE_ADDR 0xbfe00400
+#define COM6_BASE_ADDR 0xbfe00500
//#define COM1_BASE_ADDR 0xbfe00000
#if 0
#define COM2_BASE_ADDR 0xbfe81000
diff --git a/Targets/LS2K/ls2k/start.S b/Targets/LS2K/ls2k/start.S
index d04ba03..10c7762 100644
--- a/Targets/LS2K/ls2k/start.S
+++ b/Targets/LS2K/ls2k/start.S
@@ -649,6 +649,11 @@ cp0_main:
dli t1, 0xff204c
sw t1, 0x0(t0)
+ //enable uart3,4,5
+ li t0,0xbfe10420
+ lw t2,0x8(t0)
+ ori t2,0xe
+ sw t2,0x8(t0)
bal initserial
nop
@@ -1535,8 +1540,32 @@ LEAF(initserial)
.set noat
move AT,ra
-#if 1 //mtf add
- li a0, COM1_BASE_ADDR
+ li a0, COM1_BASE_ADDR //com0
+ nop
+ bal 2f
+ nop
+
+ li a0, COM4_BASE_ADDR //com3
+ nop
+ bal 2f
+ nop
+
+ li a0, COM5_BASE_ADDR //com4
+ nop
+ bal 2f
+ nop
+
+ li a0, COM6_BASE_ADDR //com5
+ nop
+ bal 2f
+ nop
+
+ jr AT
+ nop
+
+
+2:
+
li t1, CFCR_DLAB
sb t1, NSREG(NS16550_CFCR)(a0)
@@ -1555,7 +1584,6 @@ LEAF(initserial)
li t1, 71
sb t1, 2(a0)
-#endif
j ra
nop
@@ -1566,8 +1594,30 @@ LEAF(initserial_later)
.set noat
move AT,ra
-#if 1 //mtf add
li a0, COM1_BASE_ADDR
+ nop
+ bal 2f
+ nop
+
+ li a0, COM4_BASE_ADDR
+ nop
+ bal 2f
+ nop
+
+ li a0, COM5_BASE_ADDR
+ nop
+ bal 2f
+ nop
+
+ li a0, COM6_BASE_ADDR
+ nop
+ bal 2f
+ nop
+
+ jr AT
+ nop
+2:
+
li t1, CFCR_DLAB
sb t1, NSREG(NS16550_CFCR)(a0)
@@ -1586,7 +1636,6 @@ LEAF(initserial_later)
li t1, 71
sb t1, 2(a0)
-#endif
j ra
nop
在tgt_machdep.c中增加多路串口
ConfigEntry ConfigTable[] = {
{(char *)COM1_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ},
{(char *)COM4_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ},
{(char *)COM5_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ},
{(char *)COM5_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ},
内核配置如下
-
serial0x@0x1fe00000{ device_type = "serial"; compatible = "ns16550"; reg = <0x1fe00000 0x100>; clock-frequency = <125000000>; interrupt-parent = <&icu>; interrupts = <8>; }; 若要增加其他串口,仿写即可,0-3使用中断8,4-7使用中断9,注意龙芯2k使用pmon中的dtb作为设备树,修改pmon中的对应文件即可,下图为配置后的内容,并有配置文件的路径(最下一行):
2.配置共享中断和打开多路串口端口
图片如下linux系统下简单验证方法:
cat /dev/ttyS0 #打印串口数据
echo “what fuck” > /dev/ttyS0 #向串口发送数据