[OpenWrt-Devel] ath79: seting GPIO registers to specific values via DTS?

Roger Pueyo Centelles | Guifi.net roger.pueyo at guifi.net
Sun Dec 16 12:23:53 EST 2018


Some weeks ago I sent a PR adding ar71xx support for the Comfast
CF-E110N [1], an outdoor 2,4 GHz router. Everything was working fine. A
few days later I started working on adding ath79 support for the same
device [2]. Almost everything worked, except for three GPIOs which I was
not able to properly configure.

Thanks to the help from @ynezz we traced the issue until we could narrow
the problem: the bootloader (U-Boot) configures the GPIOs with some
specific values (e.g., so that LEDs blink to the Ethernet ports
activity, firmware recovery, etc.). With the ar71xx code I was able to
reset the GPIOs configuration; with the ath79 code I am not. You can
read the full discussion at the GitHub pull request page [2], but here
is the summary.

    The GPIOs I need to properly configure are GPIO11, GPIO14 and
GPIO16, which drive three RSSI LEDs. According to the SoC's datasheet
[3], they are configured through registers 0x18040034, 0x18040038 and

    Using U-Boot's memory dump and memory write functions I could read
their values and set them to zero. This way, instead of (e.g.) blinking
to the Ethernet port activity, they did work as they were told by OpenWrt:

    ath> md 0x18040034 1; md 0x18040038 1; md 0x1804003c 1
    18040034: 2c160000    ,...
    18040038: 2a2b0000    *+..
    1804003c: 00000129    ...)

    ath> mw 0x18040034 00160000; mw 0x18040038 2a000000; mw 0x1804003c

    ath> md 0x18040034 1; md 0x18040038 1; md 0x1804003c 1
    18040034: 00160000    ....
    18040038: 2a000000    *...
    1804003c: 00000100    ....

This way I made sure I needed to write zeros to the specific bits in the
three different addresses.

So, following @ynezz suggestions I added the following code to the
device dts file:


        leds {
                compatible = "gpio-leds";
                pinctrl-1 = <&led_rssilow_pin &led_rssimediumhigh_pin


&pinmux {
        led_rssilow_pin: pinmux_rssilow_pin {
                pinctrl-single,bits = <0x8 0x0 0xff000000>;

        led_rssimediumhigh_pin: pinmux_rssimediumhigh_pin {
                pinctrl-single,bits = <0xc 0x0 0x00ff0000>;

        led_rssihigh_pin: pinmux_rssihigh_pin {
                pinctrl-single,bits = <0x10 0x0 0x000000ff>;


Where 0x8, 0xc and 0x10 are the distances from the starting address of
pinmux to the registers, 0x0 is the value I want to write, and
0xff000000, 0x00ff0000 and 0x000000ff are the submasks to apply (it's a
32 bits register, right?), so that I change only the wanted bits and not
the rest of the register. However, nothing happened.

I also got more suggestions from @ynezz, which I tried, as well as tons
of other combinations, values, masks, using pinctrl-single,pins, etc.,
with no success at all.

So, the question is, what do I have to add to the device's DTS file so
can I write these 0s to the registers?

Thank you very much for your help, and my gratitude to @ynezz for his
contributions so far. :)


[1] https://github.com/openwrt/openwrt/pull/1531

[2] https://github.com/openwrt/openwrt/pull/1623


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

More information about the openwrt-devel mailing list