ipq40xx: Add support for D-Link DAP-2610
authorFredrik Olofsson <fredrik.olofsson@anyfinetworks.com>
Tue, 10 Sep 2019 09:25:53 +0000 (11:25 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 26 Jan 2020 00:20:45 +0000 (01:20 +0100)
Specifications
==============
- SOC: IPQ4018
- RAM: DDR3 256MB
- Flash: SPI NOR 16MB
- WiFi:
    - 2.4GHz: IPQ4018, 2x2, front end SKY85303-11
    - 5GHz: IPQ4018, 2x2, front end SKY85717-21
- Ethernet: 1x 10/100/1000Mbps, POE 802.3af
- PHY: QCA8072
- UART: GND, blocked, 3.3V, RX, TX / 115200 8N1
- LED: 1x red / green
- Button: 1x reset / factory default
- U-Boot bootloader with tftp and "emergency web server" accessible
  using serial port.

Installation
============
Flash factory image from D-Link web UI. Constraints in the D-Link web UI
makes the factory image unnecessarily large. Flash again using
sysupgrade from inside OpenWrt to reclaim some flash space.

Return to stock D-Link firmware
===============================
Partition layout is preserved, and it is possible to return to the stock
firmware simply by downloading it from D-Link and writing it to the
firmware partition.

    # mtd -r write dap2610-firmware.bin firmware

Quirks
======
To be flashable from the D-Link http server, the firmware must be larger
then 6MB, and the size in the firmware header must match the actual file
size. Also, the boot loader verifies the checksum of the firmware before
each boot, thus the jffs2 must be after the checksum covered part. This
is solved in the factory image by having the rootfs at the very end of
the image (without pad-rootfs).

The sysupgrade image which does not have to be flashable from the D-Link
web UI may be smaller, and the checksum in the firmware header only
covers the kernel part of the image.

Signed-off-by: Fredrik Olofsson <fredrik.olofsson@anyfinetworks.com>
[added WRGG Variables to DEVICE_VARS, squashed spi pinconf/mux,
added emd1's gmac0 config,fix dtc warnings]
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
package/firmware/ipq-wifi/Makefile
package/firmware/ipq-wifi/board-dlink_dap2610.qca4019 [new file with mode: 0644]
target/linux/ipq40xx/base-files/etc/board.d/02_network
target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
target/linux/ipq40xx/config-4.19
target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4018-dap-2610.dts [new file with mode: 0644]
target/linux/ipq40xx/image/Makefile
target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch

index 161954f..065cda1 100644 (file)
@@ -14,6 +14,8 @@ endef
 define Build/Compile
 endef
 
+# Use ath10k-bdencoder from https://github.com/qca/qca-swiss-army-knife.git
+# to generate the board-* files here.
 #
 # This is intended to be used on an interim basis until device-specific
 # board data for new devices is available through the upstream compilation
@@ -21,11 +23,11 @@ endef
 # Please send a mail with your device-specific board files upstream.
 # You can find instructions and examples on the linux-wireless wiki:
 # <https://wireless.wiki.kernel.org/en/users/drivers/ath10k/boardfiles>
-#
 
 ALLWIFIBOARDS:= \
        aruba_ap-303 \
        avm_fritzrepeater-1200 \
+       dlink_dap2610 \
        ezviz_cs-w3-wd1200g-eup \
        linksys_ea8300 \
        qxwlan_e2600ac
@@ -93,6 +95,7 @@ endef
 
 $(eval $(call generate-ipq-wifi-package,aruba_ap-303,Aruba AP-303))
 $(eval $(call generate-ipq-wifi-package,avm_fritzrepeater-1200,AVM FRITZRepeater 1200))
+$(eval $(call generate-ipq-wifi-package,dlink_dap2610,D-Link DAP-2610))
 $(eval $(call generate-ipq-wifi-package,ezviz_cs-w3-wd1200g-eup,EZVIZ CS-W3-WD1200G EUP))
 $(eval $(call generate-ipq-wifi-package,linksys_ea8300,Linksys EA8300))
 $(eval $(call generate-ipq-wifi-package,qxwlan_e2600ac,Qxwlan E2600AC))
diff --git a/package/firmware/ipq-wifi/board-dlink_dap2610.qca4019 b/package/firmware/ipq-wifi/board-dlink_dap2610.qca4019
new file mode 100644 (file)
index 0000000..08ed731
Binary files /dev/null and b/package/firmware/ipq-wifi/board-dlink_dap2610.qca4019 differ
index 59a2be0..9cfc43f 100755 (executable)
@@ -47,6 +47,7 @@ ipq40xx_setup_interfaces()
                ;;
        aruba,ap-303|\
        avm,fritzrepeater-1200|\
+       dlink,dap-2610 |\
        engenius,eap1300|\
        meraki,mr33|\
        netgear,ex6100v2|\
@@ -103,6 +104,10 @@ ipq40xx_setup_macs()
        cilab,meshpoint-one)
                label_mac=$(mtd_get_mac_binary "ART" 0x1006)
                ;;
+       dlink,dap-2610)
+               lan_mac=$(mtd_get_mac_ascii bdcfg lanmac)
+               label_mac=$lan_mac
+               ;;
        engenius,ens620ext)
                wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
                lan_mac=$(macaddr_add "$wan_mac" 1)
index 34ea5a5..22ac6ee 100644 (file)
@@ -87,6 +87,10 @@ case "$FIRMWARE" in
        unielec,u4019-32m)
                caldata_extract "0:ART" 0x1000 0x2f20
                ;;
+       dlink,dap-2610)
+               caldata_extract "ART" 0x1000 0x2f20
+               ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac)
+               ;;
        engenius,ens620ext)
                caldata_extract "ART" 0x1000 0x2f20
                ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +2)
@@ -158,6 +162,10 @@ case "$FIRMWARE" in
        unielec,u4019-32m)
                caldata_extract "0:ART" 0x5000 0x2f20
                ;;
+       dlink,dap-2610)
+               caldata_extract "ART" 0x5000 0x2f20
+               ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
+               ;;
        engenius,ens620ext)
                caldata_extract "ART" 0x5000 0x2f20
                ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +3)
index e9c1bcd..a28497a 100644 (file)
@@ -305,6 +305,7 @@ CONFIG_MTD_SPI_NAND=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_SPLIT_FIT_FW=y
+CONFIG_MTD_SPLIT_WRGG_FW=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_BEB_LIMIT=20
 CONFIG_MTD_UBI_BLOCK=y
diff --git a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4018-dap-2610.dts b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4018-dap-2610.dts
new file mode 100644 (file)
index 0000000..0fd4318
--- /dev/null
@@ -0,0 +1,241 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "qcom-ipq4019.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/soc/qcom,tcsr.h>
+
+/ {
+       model = "D-Link DAP 2610";
+       compatible = "dlink,dap-2610";
+
+       aliases {
+               led-boot = &led_red;
+               led-failsafe = &led_red;
+               led-running = &led_green;
+               led-upgrade = &led_red;
+       };
+
+       soc {
+               edma@c080000 {
+                       qcom,num_gmac = <1>;
+                       status = "ok";
+               };
+
+               tcsr@1949000 {
+                       compatible = "qcom,tcsr";
+                       reg = <0x1949000 0x100>;
+                       qcom,wifi_glb_cfg = <TCSR_WIFI_GLB_CFG>;
+               };
+
+               ess_tcsr@1953000 {
+                       compatible = "qcom,tcsr";
+                       reg = <0x1953000 0x1000>;
+                       qcom,ess-interface-select = <TCSR_ESS_PSGMII>;
+               };
+
+               tcsr@1957000 {
+                       compatible = "qcom,tcsr";
+                       reg = <0x1957000 0x100>;
+                       qcom,wifi_noc_memtype_m0_m2 = <TCSR_WIFI_NOC_MEMTYPE_M0_M2>;
+               };
+
+               rng@22000 {
+                       status = "ok";
+               };
+
+               crypto@8e3a000 {
+                       status = "ok";
+               };
+
+               watchdog@b017000 {
+                       status = "ok";
+               };
+
+               ess-switch@c000000 {
+                       status = "ok";
+                       switch_lan_bmp = <0x20>;
+                       switch_wan_bmp = <0x00>;
+               };
+
+               ess-psgmii@98000 {
+                       status = "ok";
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_red: red {
+                       label = "dap-2610:red:power";
+                       gpios = <&tlmm 4 GPIO_ACTIVE_LOW>;
+               };
+
+               led_green: green {
+                       label = "dap-2610:green:power";
+                       gpios = <&tlmm 5 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&tlmm 63 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+       };
+};
+
+&blsp1_spi1 {
+       pinctrl-0 = <&spi_0_pins>;
+       pinctrl-names = "default";
+       status = "ok";
+       cs-gpios = <&tlmm 54 GPIO_ACTIVE_HIGH>;
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <24000000>;
+
+               partitions {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "fixed-partitions";
+
+                       partition@0 {
+                               label = "SBL1";
+                               reg = <0x0 0x40000>;
+                               read-only;
+                       };
+                       partition@40000 {
+                               label = "MIBIB";
+                               reg = <0x40000 0x20000>;
+                               read-only;
+                       };
+                       partition@60000 {
+                               label = "QSEE";
+                               reg = <0x60000 0x60000>;
+                               read-only;
+                       };
+                       partition@c0000 {
+                               label = "CDT";
+                               reg = <0xc0000 0x10000>;
+                               read-only;
+                       };
+                       partition@d0000 {
+                               label = "DDRPARAMS";
+                               reg = <0xd0000 0x10000>;
+                               read-only;
+                       };
+                       partition@e0000 {
+                               label = "APPSBLENV";
+                               reg = <0xe0000 0x10000>;
+                               read-only;
+                       };
+                       partition@f0000 {
+                               label = "APPSBL";
+                               reg = <0xf0000 0x80000>;
+                               read-only;
+                       };
+                       partition@170000 {
+                               label = "ART";
+                               reg = <0x170000 0x10000>;
+                               read-only;
+                       };
+                       partition@180000 {
+                               compatible = "wrg";
+                               label = "firmware";
+                               reg = <0x180000 0xdc0000>;
+                       };
+                       partition@fb0000 {
+                               label = "rgbd";
+                               reg = <0xfb0000 0x10000>;
+                               read-only;
+                       };
+                       partition@fc0000 {
+                               label = "bdcfg";
+                               reg = <0xfc0000 0x10000>;
+                               read-only;
+                       };
+                       partition@fd0000 {
+                               label = "langpack";
+                               reg = <0xfd0000 0x20000>;
+                               read-only;
+                       };
+                       partition@ff0000 {
+                               label = "certificate";
+                               reg = <0xff0000 0x10000>;
+                               read-only;
+                       };
+                       partition@f40000 {
+                               label = "captival";
+                               reg = <0xf40000 0x70000>;
+                               read-only;
+                       };
+               };
+       };
+};
+
+&blsp_dma {
+       status = "ok";
+};
+
+&blsp1_uart1 {
+       pinctrl-0 = <&serial_pins>;
+       pinctrl-names = "default";
+       status = "ok";
+};
+
+&cryptobam {
+       status = "ok";
+};
+
+&gmac0 {
+       qcom,phy_mdio_addr = <4>;
+       qcom,poll_required = <1>;
+       qcom,forced_speed = <1000>;
+       qcom,forced_duplex = <1>;
+       vlan_tag = <1 0x20>;
+};
+
+&mdio {
+       status = "ok";
+};
+
+&tlmm {
+       serial_pins: serial_pinmux {
+               mux {
+                       pins = "gpio60", "gpio61";
+                       function = "blsp_uart0";
+                       bias-disable;
+               };
+       };
+
+       spi_0_pins: spi_0_pinmux {
+               mux {
+                       function = "blsp_spi0";
+                       pins = "gpio55", "gpio56", "gpio57";
+                       drive-strength = <12>;
+                       bias-disable;
+               };
+               mux_cs {
+                       function = "gpio";
+                       pins = "gpio54";
+                       drive-strength = <2>;
+                       bias-disable;
+                       output-high;
+               };
+       };
+};
+
+&wifi0 {
+       status = "ok";
+       qcom,ath10k-calibration-variant = "dlink,dap-2610";
+};
+
+&wifi1 {
+       status = "ok";
+       qcom,ath10k-calibration-variant = "dlink,dap-2610";
+};
index 588a24c..41a6528 100644 (file)
@@ -1,7 +1,8 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
 
-DEVICE_VARS += RAS_BOARD RAS_ROOTFS_SIZE RAS_VERSION
+DEVICE_VARS += RAS_BOARD RAS_ROOTFS_SIZE RAS_VERSION \
+              WRGG_DEVNAME WRGG_SIGNATURE
 
 define Device/Default
        PROFILES := Default
@@ -61,6 +62,15 @@ define Build/SenaoFW
        @cp $@.new $@
 endef
 
+define Build/wrgg-image
+       mkwrggimg -i $@ \
+       -o $@.new \
+       -d "$(WRGG_DEVNAME)" \
+       -s "$(WRGG_SIGNATURE)" \
+       -v "" -m "" -B ""
+       mv $@.new $@
+endef
+
 define Device/8dev_jalapeno-common
        $(call Device/FitImage)
        $(call Device/UbiFit)
@@ -227,6 +237,33 @@ define Device/compex_wpj428
 endef
 TARGET_DEVICES += compex_wpj428
 
+define Device/dlink_dap-2610
+       $(call Device/FitImageLzma)
+       DEVICE_VENDOR := D-Link
+       DEVICE_MODEL := DAP-2610
+       SOC := qcom-ipq4018
+       DEVICE_DTS_CONFIG := config@ap.dk01.1-c1
+       BLOCKSIZE := 64k
+       WRGG_DEVNAME := /dev/mtdblock/8
+       WRGG_SIGNATURE := wapac30_dkbs_dap2610
+       IMAGE_SIZE := 14080k
+       IMAGES := sysupgrade.bin factory.bin
+       # Bootloader expects a special 160 byte header which is added by
+       # wrgg-image.
+       # Factory image size must be larger than 6MB, and size in wrgg header must
+       # match actual factory image size to be flashable from D-Link http server.
+       # Bootloader verifies checksum of wrgg image before booting, thus jffs2
+       # cannot be part of the wrgg image. This is solved in the factory image by
+       # having the rootfs at the end of the image (without pad-rootfs). And in
+       # the sysupgrade image only the kernel is included in the wrgg checksum,
+       # but this is not flashable from the D-link http server.
+       # append-rootfs must start on an erase block boundary.
+       IMAGE/factory.bin    := append-kernel | pad-offset 6144k 160 | append-rootfs | wrgg-image | check-size $$$$(IMAGE_SIZE)
+       IMAGE/sysupgrade.bin := append-kernel | wrgg-image | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) | append-metadata
+       DEVICE_PACKAGES := ipq-wifi-dlink_dap2610
+endef
+TARGET_DEVICES += dlink_dap-2610
+
 define Device/engenius_eap1300
        $(call Device/FitImage)
        DEVICE_VENDOR := EnGenius
index 099a2c7..9c9a31e 100644 (file)
@@ -10,12 +10,13 @@ Signed-off-by: John Crispin <john@phrozen.org>
 
 --- a/arch/arm/boot/dts/Makefile
 +++ b/arch/arm/boot/dts/Makefile
-@@ -785,11 +785,40 @@ dtb-$(CONFIG_ARCH_QCOM) += \
+@@ -785,11 +785,41 @@ dtb-$(CONFIG_ARCH_QCOM) += \
        qcom-apq8074-dragonboard.dtb \
        qcom-apq8084-ifc6540.dtb \
        qcom-apq8084-mtp.dtb \
 +      qcom-ipq4018-a42.dtb \
 +      qcom-ipq4018-ap120c-ac.dtb \
++      qcom-ipq4018-dap-2610.dtb \
 +      qcom-ipq4018-cs-w3-wd1200g-eup.dtb \
 +      qcom-ipq4018-ea6350v3.dtb \
 +      qcom-ipq4018-eap1300.dtb \