[OpenWrt-Devel] [enhancement] ar71xx: Moving UART related GPIO initialization into the serial drivers.

Piotr Madalinski piotr.madalinski at yahoo.pl
Wed Dec 9 19:37:51 EST 2015

Here are my patches for ar71xx enabling UART to be turned on and off at 
runtime to free up the GPIO pins,
if someone is interested. I think doing this at runtime is better than 
compiling out UART support altogether.
For example, it allows the failsafe mode to function without problems, 
and, as the RX pin should not be written
to neither by the kernel, nor by the bootloader, it makes perfect sense 
to use it as 1-wire bus, or i2c SCL line.

I tested this on an ar933x based platform (tp-link 740n v4) and it works 

But, as I don't have access to older devices (ar71xx-ar91xx based), and 
the serial driver they use is different,
the patch for them (the second one) is NOT TESTED and I'd appreciate if 
someone else would test it.

Usage example:

#Unbind the serial driver
echo ar933x-uart > /sys/bus/platform/drivers/ar933x-uart/unbind

[dmesg: console [ttyATH0] disabled]

#export RX pin as GPIO
echo 9 > /sys/class/gpio/export

#From now on RX pin works as normal GPIO
echo out > /sys//sys/class/gpio/gpio9/direction
echo 1 > /sys//sys/class/gpio/gpio9/value

#Rebind the serial driver back
echo ar933x-uart > /sys/bus/platform/drivers/ar933x-uart/bind
[dmesg: console [ttyATH0] enabled]

#WARNING: Remember to remove the askconsole line from /etc/inittab - 
otherwise procd will reboot the system
#if console goes away. I plan to make procd/askfirst better behaved in 
future. But - as of yet - I'm not sure how.

Piotr Madalinski
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list