TL-WR842ND V2 no USB power after switching to ATH79

After building on ATH79 target there is no power on USB port. On AR7xxx/AR9xxx target it is working. I know it is something wrong with GPIO`s config. I am on the latest snapshot.
Ask me if any additional info is needed.

Thanks

Are you comfortable with command-line use of your device?

Someone would need to confirm that

#define TL_MR3420V2_GPIO_USB_POWER 4

is correct, based on

commit 3f7908d697
Author: Matthias Schiffer <redacted>
Date:   Wed Jan 31 21:18:16 2018 +0100

    ar71xx-generic: enable ATH79_MACH_TL_WR841N_V8 machine
    
    This machfile also contains the code for the TL-WR842N/ND v2, which is in
    ar71xx-generic and not in ar71xx-tiny.
[...]

Of course I am. How would I check that commit?

Ah, not that commit -- that is what led me to it being the WR841N_V8 to look at for the "old" GPIO definition.

The following should let you manually toggle a GPIO:

cd /sys/class/gpio/
echo 4 > export
cd gpio4
cat direction           # probably "in"
echo out > direction    # assuming set for "in"
cat value               # probably 0
echo 1 > value          # assuming was 0 before

If that resolves the problem, the changes to the DTS for ath79 should be straightforward (as would be a "quick hack" for your running device).

Please ask if you have any questions as to what the above is doing

root@OpenWrt:/sys/class/gpio# echo 4 > export
ash: write error: Resource busy

root@OpenWrt:/sys/class/gpio# ls
export             gpiochip0          tp-link:power:usb  unexport

Hmm...

Looks like something is already using that GPIO -- hmmm...

target/linux/ath79/dts/ar9341_tplink_tl-wr842n-v2.dts

        gpio-export {
                compatible = "gpio-export";

                gpio_usb_power {
                        gpio-export,name = "tp-link:power:usb";
                        gpio-export,output = <1>;
                        gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
                };
        };

Looks like it's already exported by the above. That's a functional, but now-deprecated way of handling it.

Do you already have /sys/class/gpio/tp-link:power:usb/ on your running device?

If so, you should be able to continue with checking its behavior with

cd /sys/class/gpio/tp-link:power:usb/
cat direction           # should already be "out" based on the DTS
cat value               # probably 0
echo 1 > value          # toggle it, assuming was 0 before

cd /sys/class/gpio/tp-link:power:usb/

Seems to be a symlink to:

/sys/devices/platform/ahb/ahb:apb/18040000.gpio/gpiochip0/gpio/tp-link:power:usb

root@OpenWrt:/sys/devices/platform/ahb/ahb:apb/18040000.gpio/gpiochip0/gpio/tp-link:power:usb# ls
active_low device subsystem uevent value

You should be able to look at the current value and toggle it to see if you get USB power and, if so, what value is needed.