Objective:
In Linux, when a GPIO is configured as a serial port or other function, it is no longer possible to export the Gpio (echo xx >/sys/class/gpio/export) in the file system, which is not allowed because your PIN is already in use as a function of other functions.
when configuring the Linux kernel, make menuconfig configures the serial port Uart2 as a case with RTS pins. Then make compile the kernel, the results run to the board, in the file system can really export the corresponding GPIO pin of the serial port, this is certainly not correct, after testing, did find that at this time the serial port does not work, such as the loss of the serial port function.
Reason: After the serial drive source analysis, the serial port driver is divided into three layers of key code, respectively: TTY_IO.C, serial_core.c, NUC970_SERIAL.C (This is the board manufacturers to implement the serial port file).
After knowing the three key files, we just need to focus on the NUC970_SERIAL.C, because the other two files can be said to be no problem. Make menuconfig in the kernel-driven configuration, when the UART2 is configured with the RTS pin function, in the. CONFIG file under the source root, a macro is displayed about Uart2 as the matching macro, at which point it is named defined (config_ NUC970_UART2_FC_PF). The result is in the static int Nuc970serial_pinctrl (struct platform_device *pdev) function in/drivers/tty/serial/nuc970_serial.c, The macro is named defined (CONFIG_NUC970_UART2_PF_FC), it is clear that the name of the macro is wrong, FC and PF position is reversed, the macro changes in the file and make Menuconfig After generating the name of the macro in the. config file, the uart2 is normal.
Summary: In the case of a Linux migration, if you find a problem during the porting process, consider a workaround, which is to first determine which driver is the problem, and then consider the build after make menuconfig, the config file, about the drive macro, is consistent with the source of the macro, when the problem is difficult to solve, this is a trial process.
This article is from the "Whylinux" blog, make sure to keep this source http://whylinux.blog.51cto.com/10900429/1903195
Linux kernel issues with the serial port not available when the UART2 is configured as an RTS Pin