Support for Dlink DAP-1620

strange why it doesn't detect for me. what dts you used ?

root@OpenWrt:/# hexdump -C /dev/mtd2

will reveal label mac address in ascii format at 0xffe8 and wifi mac address (incremented by 2) at 0xffd4.

Not sure how to deal with 5G in rampis though, besides hadn't really tested the mac assignment in the vendor firmware :innocent:

mtd1 is not uboot-env but the vendors settings, so it should probably remain nvram.

By the way, I'm using a different TLL dongle, now I can actually enter uboot... So we really don't have different devices, just my faulty dongle... sorry for that :innocent:

I'll push changes soon, just trying to figure out why the factory image generation is not yet working as intended...

So... current state: I have no interfaces besides loopback... no boot led blinking pattern (probably messed up my pinmux settings if the led binding works for you?)

Maybe I find a little more time for testing at the weekend...

But at least the factory image generation is working :sweat_smile: It can be flashed via the D-Link Web UI and will detect the kernel and rootfs partitions automatically.

Tried your changes but rootfs still doesn't mount:

[    6.768354] spi-nor spi0.0: mx25l6405d (8192 Kbytes)
[    6.778378] 7 fixed-partitions partitions found on MTD device spi0.0
[    6.791042] Creating 7 MTD partitions on "spi0.0":
[    6.800599] 0x000000000000-0x000000030000 : "u-boot"
[    6.811574] 0x000000030000-0x000000040000 : "u-boot-env"
[    6.823234] 0x000000040000-0x000000050000 : "factory"
[    6.834475] 0x000000050000-0x0000004e0000 : "firmware"
[    6.848966] 0x0000004e0000-0x0000004f0000 : "lang"
[    6.859670] 0x0000004f0000-0x0000005c0000 : "linux4b"
[    6.870854] 0x0000005c0000-0x000000800000 : "rootfsb"
[    6.882958] libphy: Fixed MDIO Bus: probed
[    6.902067] gsw: setting port4 to ephy mode
[    6.910893] libphy: mdio: probed

Picture of device with GPIOs:


still looking for GPIO to enable ethernet
also in [mt7620.mk] maybe to add
DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek

1 Like

Did you build and flash a factory/sysupgrade image, or is this from initramfs? (You should also see a kernel panic later if the rootfs could not be mounted).

Looks like a good idea if there's a driver package for this phy :wink:

I used initramfs, regarding the driver this is exactly the driver for RTL8211E but it need to be restarted through GPIO after boot I still didn't find the what gpio ca be used and also for the buttons using the test for GPIO it doesn't detect them.
Regarding ethernet similar device: Support for Edimax EW-7476RPC

Could you measure the voltage at the bottom pins (i.e. facing towards RTL8211E) of R150 / R152?

It's the pin of the unpopulated resistor in the bottom right corner of the silk-screened frame;
this is the level of PHYRSTB, which is high for my device (i.e. RTL8211E not in reset state), so this should not be the issue :thinking:

However it is also connected to a via which has no connection on the bottom layer of the pcb, thus the trace vanishes somewhere into the intermediate layers, most probably connected to the SoC.

Since you defined several GPIOs for testing, maybe this is pulled to GND, so the phy would not leave reset state?

I'm trying to build with the kmod-phy-realtek package included now.

// Edit: weird, I simply don't have any interface configured after a fresh install, I can set ifconfig eth0 up, wlan0 up and wlan1 up without seeing errors, but uci show network just shows entries for the loopback adapter!?

Just pushed changes, LEDs not working, probably belong to &gpio0 or &gpio1.

The ramips target is weird, I'll better just stick with ath79 for now :innocent:

I have also ath79 but this one it's small and I use it as portable if I could find USB pins that I can use it would be even better.
voltage for the resistors is 3.2v
why initramfs doesn't mount rootfs, it should be like this ? regarding the GPIO I can turn them manually but don't understand why dts isn't working
my uci show network:

network.loopback=interface
network.loopback.ifname='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.globals=globals
network.globals.ula_prefix='fd00:3851:431b::/48'
network.lan=interface
network.lan.type='bridge'
network.lan.ifname='eth0'
network.lan.proto='static'
network.lan.ipaddr='192.168.1.1'
network.lan.netmask='255.255.255.0'
network.lan.ip6assign='60'
network.wwan=interface
network.wwan.proto='dhcp'

und uci show wireless gives 2 wireless interfaces.

I'm using now as a repeated and it works fine. now need to find the way to enable leds and ethernet
strange that ethernet shoes connected but no traffic through it , I think it needs to be reseted.

Yes they belong to &gpio0 but have no idea what this means

some logs that I have for ethernet:
[ 57.233150] mtk_soc_eth 10100000.ethernet eth0: port 5 link up (1000Mbps/Full duplex)
[ 57.263863] 8021q: adding VLAN 0 to HW filter on device eth0
[ 57.408142] br-lan: port 1(eth0) entered blocking state
[ 57.418582] br-lan: port 1(eth0) entered disabled state
[ 57.429417] device eth0 entered promiscuous mode
[ 57.494727] br-lan: port 1(eth0) entered blocking state
[ 57.505212] br-lan: port 1(eth0) entered forwarding state
[ 58.252144] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[ 91.429083] done.
but still not working.
and for GPIO correct config:

	leds {
		compatible = "gpio-leds";

		led_power: power {
			label = "dap-1620:red:power";
			gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
		};

		lan {
			label = "dap-1620:green:lan";
			gpios = <&gpio0 40 GPIO_ACTIVE_LOW>;
		};

		wlan2g {
			label = "dap-1620:green:wlan2g";
			gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1radio";
		};

		wlan5g {
			label = "dap-1620:green:wlan5g";
			gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0radio";
		};

		status_red {
			label = "dap-1620:green:status";
			gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
		};
		
		status_green {
			label = "dap-1620:green:status";
			gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
		};
	};

initramfs will extract, as the name suggests, ist own rootfs to a ramdisk and mount that (similar to booting a ubuntu live image from a USB drive), without touching the flash.
This is particularly useful when adding support for a new device, when the flash layout is not yet known.

If you don't see the sysupgrade or factory image being created, it might be dropped due to its size exceeding the firmware partition from the dts (run make V=s for debug output to see if that happened).

So the interfaces are looking good, it's just a problem with my build then.

MT7620 has several gpio nodes, OpenWRT will map them all together into a logical numeric space. Could you post the output of ls /sys/class/gpio? There should be several gpiochip directories in there, where you could cat base to see the offset where gpio 0 of that bank is mapped to in OpenWRT.
So in the dts, I think the numbers could not be as high as 40, you most probably have to subtract the base first and specifiy which node they belong to (40 should imho result in gpio 0 of &gpio2, but again, I'm also not quite familiar with ramips).

Ethernet link but no traffic could also be due to a GMAC PLL mismatch (clock Speed on rgmii interface), but no idea how set this in ramips :thinking: Does it work when putting a 10/100M Switch in between (or setting the link speed manually on the computer)?

I used:

&ethernet {
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii1_pins &mdio_pins &phy_reset_pins>;

	mtd-mac-address = <&factory 0x4>;

	mediatek,mdio-mode = <1>;

	phy-reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <30>;

	port@5 {
		status = "okay";
		mediatek,fixed-link = <1000 1 1 1>;
		phy-mode = "rgmii";
	};

	mdio-bus {
		status = "okay";

		phy0: ethernet-phy@0 {
			status = "disabled";
			reg = <0>;
			phy-mode = "rgmii";
		};

		phy1: ethernet-phy@1 {
			status = "disabled";
			reg = <1>;
			phy-mode = "rgmii";
		};

		phy2: ethernet-phy@2 {
			status = "disabled";
			reg = <2>;
			phy-mode = "rgmii";
		};

		phy3: ethernet-phy@3 {
			status = "disabled";
			reg = <3>;
			phy-mode = "rgmii";
		};

		phy4: ethernet-phy@4 {
			status = "disabled";
			reg = <4>;
			phy-mode = "rgmii";
		};
	};
};

&gsw {
	mediatek,port5 = "gmac";
};

&wmac {
	ralink,mtd-eeprom = <&factory 0x0>;
};

&pcie {
	status = "okay";
};

used in dts from edimax-ew-7476rpc only then I could see ethernet link.

This led setup working good:
leds {
compatible = "gpio-leds";

	led_power: power {
		label = "dap-1620-a1:red:power";
		gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
	};

	lan {
		label = "dap-1620-a1:green:lan";
		gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
	};

	wlan2g {
		label = "dap-1620-a1:green:wlan2g";
		gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "phy1radio";
	};

	wlan5g {
		label = "dap-1620-a1:green:wlan5g";
		gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "phy0radio";
	};

	wps {
		label = "dap-1620-a1:green:wps";
		gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
	};
};

I couldn't use GPIO40 don't know why and also gpio12 for lan when I declare gpio13 in reality it turns on gpio12.

and for SPI I Used;


partition@50000 {
				label = "firmware";
				reg = <0x50000 0x7b0000>;
				compatible = "denx,uimage";
			};

Have you checked this is the correct gpio for DAP-1620?

When toggling the pin, the voltage change should be visible at resistors R150/R152, but you have to remove the phy-reset-gpios declaration from the dts first (can't export the gpio when it's occupied by some other kernel driver).

From mt7620a.dtsi we learn (simplified):

		gpio0: gpio@600 {
			ralink,gpio-base = <0>;
			ralink,num-gpios = <24>;
		};

		gpio1: gpio@638 {
			ralink,gpio-base = <24>;
			ralink,num-gpios = <16>;
			status = "disabled";
		};

		gpio2: gpio@660 {
			ralink,gpio-base = <40>;
			ralink,num-gpios = <32>;
			status = "disabled";
		};

		gpio3: gpio@688 {
			ralink,gpio-base = <72>;
			ralink,num-gpios = <1>;
			status = "disabled";
		};

so GPIO 40 in OpenWRT would be actually <&gpio2 0 ...>, and
<&gpio1 15 GPIO_ACTIVE_LOW> means we have logical GPIO 39 in OpenWRT.

Not sure about additional requirements for pinmux though.

Run the script for GPIOS 0 100 but voltage from R150 didn't disappeare also can't find GPIO for two buttons.

Still no luck with ethernet, tried all the gpios don't see anyting or R150, maybe you have any other ideas ?

It seems something in the kernel is still blocking access to that GPIO (as well as many others; I was only able to test maybe around 10-20 pins out of 72), maybe the pinmux settings for rgmii, if the reset line itself could be considered part of the rgmii interface :thinking:

What happens when you plug in a network cable, e.g. when connecting to a switch, will the switch LED light up, indicating any link status? Could you test with a 10/100M switch, sometimes there's a PLL clock issue with the GMAC... also still looking for ways to solve this in ath79 :pensive:

Not sure if it's worth trying to mess with GPIO registers manually; pinmux is called GPIOMODE in the programming manual (p. 37)

To change register values you need to select the utility io in menuconfig as well as enable the /dev/mem device in global build options -> kernel options or something like that...

For me no connection at all like cable is not even pluged.

Interesting, I see a link indication on the other end (switch LED lights up), there is just no connectivity (not even when using a 100Base-T switch) :thinking: