Skip to content

Commit 7e80c74

Browse files
soburicarlescufi
authored andcommitted
drivers: serial: Add USART support for GD32V
Modifying configuration to enable with gd32vf103 - Add usart definition to devicetree. - Define USART_STAT as alias of USART_STAT0 if not defined it. - Enable USART if SOC_SERIES_RISCV_GIGADEVICE_GD32VF103. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 5c7a0ef commit 7e80c74

File tree

7 files changed

+81
-1
lines changed

7 files changed

+81
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2021, TOKITA Hiroshi
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <dt-bindings/pinctrl/gd32vf103c(b-8)xx-pinctrl.h>
7+
8+
&pinctrl {
9+
usart0_default: usart0_default {
10+
group1 {
11+
pinmux = <USART0_TX_PA9_NORMP>, <USART0_RX_PA10_NORMP>;
12+
};
13+
};
14+
};

boards/riscv/longan_nano/longan_nano.dts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66

77
/dts-v1/;
88
#include <gigadevice/gd32vf103Xb.dtsi>
9+
#include "longan_nano-pinctrl.dtsi"
910

1011
/ {
1112
model = "Sipeed Longan Nano";
1213
compatible = "sipeed,longan_nano";
1314

1415
chosen {
16+
zephyr,console = &usart0;
17+
zephyr,shell-uart = &usart0;
1518
zephyr,sram = &sram0;
1619
zephyr,flash = &flash0;
1720
};
1821
};
22+
23+
&usart0 {
24+
status = "okay";
25+
current-speed = <115200>;
26+
pinctrl-0 = <&usart0_default>;
27+
pinctrl-names = "default";
28+
};

boards/riscv/longan_nano/longan_nano_defconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ CONFIG_GD32_HXTAL_8MHZ=y
1111

1212
# enable machine timer
1313
CONFIG_RISCV_MACHINE_TIMER=y
14+
15+
# enable uart driver
16+
CONFIG_SERIAL=y
17+
CONFIG_UART_INTERRUPT_DRIVEN=y
18+
19+
# enable console
20+
CONFIG_CONSOLE=y
21+
CONFIG_UART_CONSOLE=y

boards/riscv/longan_nano/longan_nano_lite.dts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66

77
/dts-v1/;
88
#include <gigadevice/gd32vf103X8.dtsi>
9+
#include "longan_nano-pinctrl.dtsi"
910

1011
/ {
1112
model = "Sipeed Longan Nano Lite";
1213
compatible = "sipeed,longan_nano_lite";
1314

1415
chosen {
16+
zephyr,console = &usart0;
17+
zephyr,shell-uart = &usart0;
1518
zephyr,sram = &sram0;
1619
zephyr,flash = &flash0;
1720
};
1821
};
22+
23+
&usart0 {
24+
status = "okay";
25+
current-speed = <115200>;
26+
pinctrl-0 = <&usart0_default>;
27+
pinctrl-names = "default";
28+
};

boards/riscv/longan_nano/longan_nano_lite_defconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ CONFIG_GD32_HXTAL_8MHZ=y
1111

1212
# enable machine timer
1313
CONFIG_RISCV_MACHINE_TIMER=y
14+
15+
# enable uart driver
16+
CONFIG_SERIAL=y
17+
CONFIG_UART_INTERRUPT_DRIVEN=y
18+
19+
# enable console
20+
CONFIG_CONSOLE=y
21+
CONFIG_UART_CONSOLE=y

drivers/serial/Kconfig.gd32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ DT_COMPAT_GIGADEVICE_GD32_USART := gd,gd32-usart
77
config USART_GD32
88
bool "GD32 serial driver"
99
default $(dt_compat_enabled,$(DT_COMPAT_GIGADEVICE_GD32_USART))
10-
depends on SOC_FAMILY_GD32
10+
depends on (SOC_FAMILY_GD32 || SOC_SERIES_GD32VF103)
1111
select SERIAL_HAS_DRIVER
1212
select SERIAL_SUPPORT_INTERRUPT
1313
select USE_GD32_USART

dts/riscv/gigadevice/gd32vf103.dtsi

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,36 @@
6565
};
6666
};
6767

68+
usart0: serial@40013800 {
69+
compatible = "gd,gd32-usart";
70+
reg = <0x40013800 0x400>;
71+
interrupts = <56 0>;
72+
interrupt-parent = <&eclic>;
73+
rcu-periph-clock = <0x60e>;
74+
status = "disabled";
75+
label = "UART_0";
76+
};
77+
78+
usart1: serial@40004400 {
79+
compatible = "gd,gd32-usart";
80+
reg = <0x40004400 0x400>;
81+
interrupts = <57 0>;
82+
interrupt-parent = <&eclic>;
83+
rcu-periph-clock = <0x711>;
84+
status = "disabled";
85+
label = "UART_1";
86+
};
87+
88+
usart2: serial@40004800 {
89+
compatible = "gd,gd32-usart";
90+
reg = <0x40004800 0x400>;
91+
interrupts = <58 0>;
92+
interrupt-parent = <&eclic>;
93+
rcu-periph-clock = <0x712>;
94+
status = "disabled";
95+
label = "UART_2";
96+
};
97+
6898
afio: afio@40010000 {
6999
compatible = "gd,gd32-afio";
70100
reg = <0x40010000 0x400>;

0 commit comments

Comments
 (0)