How can I configure port 1 as WAN on ipq40xx?

Hi, I'm currently working on an ipq40xx device which has WAN port at port 1. (It seems most ipq40xx devices on OpenWrt use port 5 for WAN)
But I can't figure out how to set WAN on the port 1.

I've tried these things on RT-AC58U:

Finally, I found an almost-close solution:

ess-switch@c000000 {
	status = "okay";

	switch_lan_bmp = <0x3c>;
	switch_wan_bmp = <0x02>;
};

&gmac0 {
	vlan_tag = <1 0x3c>;
};

&gmac1 {
	qcom,phy_mdio_addr = <0>;
	vlan_tag = <2 0x02>;
};

changing qcom,phy_mdio_addr worked, except that it did not accept 0.
If I used value other than 0, it changed WAN port accordingly, and it worked well. Only value 0 seems to be a problem.
git grep "qcom,phy_mdio_addr" shows that qcom,phy_mdio_addr = <0>; is used for non-existing port. So the driver might be the cause.

How can we solve this? Is there another workaround for this?

Depends what you mean by WAN. Two elements

  1. Its the default route for packets, when routing isn't explicit
  2. There is a firewall in that direction

Now me I mainly work from the command line, so you do

ip route add default via ip.dress.here

I'll need to check the syntax when I get home.

Firewall is similar, take the ip of the wan address, and set up fillter and NAT on that as needed.

When I set port 2 (or port 3~5) to WAN using methods above, it successfully fetches IP address from external DHCP server. But if I use port 1, it fails. I don't think it's a matter of routing or firewall, something in the switch driver must be blocking the change (maybe the VLAN is hardcoded?).