我们在内核启动时候已经配置系统了UART,但是tqimx6q这块开发板上引出了imx6q的5路TTL接口,其中,uart1和uart2转成232接口,本文将配置这5路Uart接口。
DTS配置
由于内核中已经有imx6q的uart控制器驱动,因此,我们只需要配置各端口的pinctrl即可。根据tqimx6q的原理图,我们对我们的DTS作如下修改:
- ...
- &uart1 {
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_uart1_2>;
- status = "okay";
- };
- &uart2 {
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_uart2_3>;
- status = "okay";
- };
- &uart3 {
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_uart3_2>;
- status = "okay";
- };
- &uart4 {
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_uart4_1>;
- status = "okay";
- };
- &uart5 {
- pintctrl-names = "default";
- pinctrl-0 = <&pinctrl_uart5_1>;
- status = "okay";
- };
- ...
- &iomuxc {
- pinctrl-names = "default";
- uart1 {
- pinctrl_uart1_2: uart1grp-2 {
- fsl,pins = <
- MX6QDL_PAD_SD3_DAT7__UART1_TX_DATA 0x1b0b1
- MX6QDL_PAD_SD3_DAT6__UART1_RX_DATA 0x1b0b1
- MX6QDL_PAD_EIM_D20__UART1_RTS_B 0x1b0b1
- MX6QDL_PAD_EIM_D19__UART1_CTS_B 0x1b0b1
- >;
- };
- };
- uart2 {
- pinctrl_uart2_3: uart2grp-3 {
- fsl,pins = <
- MX6QDL_PAD_EIM_D26__UART2_TX_DATA 0x1b0b1
- MX6QDL_PAD_EIM_D27__UART2_RX_DATA 0x1b0b1
- MX6QDL_PAD_EIM_D28__UART2_CTS_B 0x1b0b1
- MX6QDL_PAD_EIM_D29__UART2_RTS_B 0x1b0b1
- >;
- };
- };
- uart3 {
- pinctrl_uart3_2: uart3grp-2 {
- fsl,pins = <
- MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1
- MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1
- >;
- };
- };
- uart5 {
- pinctrl_uart5_1: uart5grp-1 {
- fsl,pins = <
- MX6QDL_PAD_KEY_COL1__UART5_TX_DATA 0x1b0b1
- MX6QDL_PAD_KEY_ROW1__UART5_RX_DATA 0x1b0b1
- >;
- };
- };
- };
测试方法
测试串口的方式有很多,可以编写专门的测试程序来测试,这方面的资料网上可以找到很多,我这里就不举例了。本文使用了偷懒的方式,在uboot中将bootargs临时修改为如下内容:
- setenv bootargs 'noinitrd console=ttymxc1,115200 root=/dev/mmcblk0p1 rw rootfstype=ext4 init=/linuxrc'
至此,tqimx6q的全部串口都移植好了。有任何疑问可以留言讨论。