RZ/G2L串口簡介
瑞薩RZ/G2L的串口簡稱SCI,全稱Serial Communication Interface。
RZ/G2L有兩種串口,一種帶FIFO叫SCIFA,另一種不帶FIFO叫SCIg。
所以,RZ/G2L有5路SCIFA和2路SCIg總共7路的串口。
RZ/G2L串口驅動
包含驅動代碼和設備樹兩部分:
內核中的驅動文件sh-sci.c
該源碼文件路徑:drivers/tty/serial/sh-sci.c,該驅動代碼包含SCIFA和SCIg兩種型號的完整驅動代碼。
編譯內核的時候需進行以下配置
左右滑動查看完整內容
egrep -rin "CONFIG_SERIAL_SH_SCI" .out/.config 2180:CONFIG_SERIAL_SH_SCI=y 2181:CONFIG_SERIAL_SH_SCI_NR_UARTS=18 2182:CONFIG_SERIAL_SH_SCI_CONSOLE=y 2183:CONFIG_SERIAL_SH_SCI_EARLYCON=y 2184:CONFIG_SERIAL_SH_SCI_DMA=y
該配置能夠確保sh-sci.c的驅動代碼能夠被編譯包含到Image中。
github上提供的內核源碼的defconfig中默認已包含SCI驅動代碼的編譯。
SCI串口的設備樹節點在r9a07g044.dtsi中定義,分別定義了scif0~4, sci0~1共7路。
左右滑動查看完整內容
scif0: serial@1004b800 { compatible = "renesas,scif-r9a07g044"; reg = <0 0x1004b800 0 0x400>; interrupts =, , , , , ; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCIF0_CLK_PCK>; clock-names = "fck"; dmas = <&dmac 0x4e79>, <&dmac 0x4e7a>; dma-names = "tx", "rx"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCIF0_RST_SYSTEM_N>; status = "disabled"; }; scif1: serial@1004bc00 { compatible = "renesas,scif-r9a07g044"; reg = <0 0x1004bc00 0 0x400>; interrupts = , , , , , ; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCIF1_CLK_PCK>; clock-names = "fck"; dmas = <&dmac 0x4e7d>, <&dmac 0x4e7e>; dma-names = "tx", "rx"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCIF1_RST_SYSTEM_N>; status = "disabled"; }; scif2: serial@1004c000 { compatible = "renesas,scif-r9a07g044"; reg = <0 0x1004c000 0 0x400>; interrupts = , , , , , ; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCIF2_CLK_PCK>; clock-names = "fck"; dmas = <&dmac 0x4e81>, <&dmac 0x4e82>; dma-names = "tx", "rx"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCIF2_RST_SYSTEM_N>; status = "disabled"; }; scif3: serial@1004c400 { compatible = "renesas,scif-r9a07g044"; reg = <0 0x1004c400 0 0x400>; interrupts = , , , , , ; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCIF3_CLK_PCK>; clock-names = "fck"; dmas = <&dmac 0x4e85>, <&dmac 0x4e86>; dma-names = "tx", "rx"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCIF3_RST_SYSTEM_N>; status = "disabled"; }; scif4: serial@1004c800 { compatible = "renesas,scif-r9a07g044"; reg = <0 0x1004c800 0 0x400>; interrupts = , , , , , ; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCIF4_CLK_PCK>; clock-names = "fck"; dmas = <&dmac 0x4e89>, <&dmac 0x4e8a>; dma-names = "tx", "rx"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCIF4_RST_SYSTEM_N>; status = "disabled"; }; sci0: serial@1004d000 { compatible = "renesas,r9a07g044-sci", "renesas,rz-sci"; reg = <0 0x1004d000 0 0x400>; interrupts = , , , ; interrupt-names = "eri", "rxi", "txi", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCI0_CLKP>; clock-names = "fck"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCI0_RST>; status = "disabled"; }; sci1: serial@1004d400 { compatible = "renesas,r9a07g044-sci", "renesas,rz-sci"; reg = <0 0x1004d400 0 0x400>; interrupts = , , , ; interrupt-names = "eri", "rxi", "txi", "tei"; clocks = <&cpg CPG_MOD R9A07G044_SCI1_CLKP>; clock-names = "fck"; power-domains = <&cpg>; resets = <&cpg R9A07G044_SCI1_RST>; status = "disabled"; };
設備樹文件路徑
arch/arm64/boot/dts/renesas/r9a07g044.dtsi
根據項目需要,使能需要使用的設備節點,如欲使用SCIFA2:
左右滑動查看完整內容
&scif2 { pinctrl-0 = <&scif2_pins>; pinctrl-names = "default"; uart-has-rtscts; status = "okay"; };
注意需通過scif2_pins正確處理IO口復用問題。如果不使用DMA需要將設備節點中的dmas和dma-names刪除。
編譯內核:
左右滑動查看完整內容
export ARCH=arm64 export CROSS_COMPILE=aarch64-none-elf- export PATH=$PATH:/opt/arm/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin make defconfig O=.out && make -j8 O=.out
使用當前編譯生成的內核Image和dtb
左右滑動查看完整內容
.out/arch/arm64/boot/Image .out/arch/arm64/boot/dts/renesas/r9a07g044l2-smarc.dtb
啟動板子后就能在系統路徑下生成/dev/ttySC2節點。
Linux應用層使用RZ/G2L的串口SCI
RZ/G2L的串口設備節點在Linux應用層遵循POSIX標準,使用方法和PC端的Ubuntu系統并無差別。
RZ/G2L除了支持市面上常用的串口波特率如9600/115200/921600等,實際上除POSIX系統定義的波特率都支持外,RZ/G2L能夠支持的最大串口波特率是12.5Mbps,下一篇我們將介紹如何在內核驅動代碼中實現RZ/G2L的最大波特率12.5Mbps。
審核編輯:湯梓紅
-
內核
+關注
關注
3文章
1372瀏覽量
40277 -
瑞薩
+關注
關注
35文章
22308瀏覽量
86240 -
串口
+關注
關注
14文章
1551瀏覽量
76425 -
SCI
+關注
關注
1文章
56瀏覽量
20116
原文標題:RZ/G2L串口SCI的使用(上)
文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論