ath79: add support for NEC Aterm WR8750N

NEC Aterm WR8750N is a 2.4/5 GHz band 11n (Wi-Fi 4) router, based on
AR9344.

Specification:

- SoC             : Atheros AR9344
- RAM             : DDR2 128 MiB (2x Hynix H5PS5162GFR-S6C)
- Flash           : SPI-NOR 8 MiB (Macronix MX25L6406EMI-12G)
- WLAN            : 2.4/5 GHz 2T2R
  - 2.4 GHz       : Atheros AR9344 (SoC)
  - 5 GHz         : Atheros AR9382
- Ethernet        : 5x 10/100/1000 Mbps
  - switch        : Atheros AR8327
- LEDs/Keys (GPIO): 10x/4x
  - note          : all LEDs are controlled by ath9k chip (AR9382)
- UART            : through-hole on PCB
  - assignment    : 3.3V, GND, NC, TX, RX from tri-angle marking
  - settings      : 9600n8
- USB             : 1x USB 2.0 Type-A
  - hub (internal): NEC uPD720114
- Power           : 12 VDC, 1.5 A (Max. 16 W)
- Stock OS        : NetBSD based

Flash instruction using initramfs-factory.bin image (StockFW WebUI):

1. Boot WR8750N with router mode normally
2. Access to the WebUI ("http://aterm.me/" or "http://192.168.0.1/") on
   the device and open firmware update page ("ファームウェア更新")
3. Select the OpenWrt initramfs-factory.bin image and click update
   ("更新") button
4. After updating, the device will be rebooted and booted with OpenWrt
   initramfs image
5. On the initramfs image, upload (or download) uboot.bin and
   sysupgrade.bin image to the device
6. Replace the bootloader with a uboot.bin image

   mtd write <uboot.bin image> bootloader

7. Perform sysupgrade with a sysupgrade.bin image

   sysupgrade <sysupgrade image>

8. Wait ~120 seconds to complete flashing

Flash instruction using initramfs-factory.bin image (bootloader CLI):

 1. Connect and open serial console
 2. Power on WR8750N and interrupt bootloader by ESC key
 3. Login to the bootloader CLI with a password "chiron"
 4. Start TFTP server by "tftpd" command
 5. Upload initramfs-factory.bin via tftp from your computer

   example (Windows): tftp -i 192.168.0.1 PUT initramfs-factory.bin

 6. Boot initramfs image by "boot" command
 7. On the initramfs image, back up the stock bootloader and firmware if
   needed
 8. Upload (or download) uboot.bin and sysupgrade.bin image to the device
 9. Replace the bootloader with a uboot.bin image
10. Perform sysupgrade with a sysupgrade.bin image
11. Wait ~120 seconds to complete flashing

Notes:

- All LEDs are connected to the GPIO controller on the ath9k chip
  (AR9382) and controlled by it. Those LEDs are probed after probing of
  ath9k chip, so they cannot be handled as status LEDs of OpenWrt while
  booting.

- A reset pin of the internal USB hub is connected to the GPIO
  controller of the ath9k chip, like LEDs above. That hub will be
  detected after probing of the ath9k chip.

- The stock bootloader requires an unknown filesystem on firmware area
  in the flash. Booting of OpenWrt from that filesystem cannot be
  handled, so the bootloader needs to be replaced to mainline U-Boot
  before OpenWrt installation.

MAC Addresses:

LAN    : 1C:B1:7F:xx:xx:00 (config,  0x6 (hex))
WAN    : 1C:B1:7F:xx:xx:01 (config,  0xc (hex))
2.4 GHz: 1C:B1:7F:xx:xx:02 (config,  0x0 (hex) / art, 0x1002 (hex))
5 GHz  : 1C:B1:7F:xx:xx:03 (config, 0x12 (hex) / art, 0x5002 (hex))

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/15432
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
INAGAKI Hiroshi 2024-04-25 01:08:41 +09:00 committed by Hauke Mehrtens
parent 09eee2538e
commit 7e37a457d4
7 changed files with 441 additions and 5 deletions

View File

@ -0,0 +1,300 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
#include "ar9344.dtsi"
/ {
aliases {
led-running = &led_power_green;
led-upgrade = &led_power_green;
};
chosen {
/*
* don't specify bootargs property in DeviceTree to
* enable a console with a default baudrate (9600)
* or passed console= parameter from the bootloader
*/
/delete-property/ bootargs;
stdout-path = &uart;
};
keys: keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&jtag_disable_pins>;
button-eco {
label = "eco";
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
debounce-interval = <60>;
};
switch-ap {
label = "ap";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_1>;
debounce-interval = <60>;
};
button-reset {
label = "reset";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
debounce-interval = <60>;
};
button-wps {
label = "wps";
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
debounce-interval = <60>;
};
};
ath9k_leds: ath9k-leds {
/* all LEDs are connected to ath9k chip (AR938x) */
compatible = "gpio-leds";
led_power_green: led-0 {
gpios = <&ath9k 0 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_POWER;
default-state = "on";
};
led-1 {
gpios = <&ath9k 1 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_POWER;
};
led-2 {
gpios = <&ath9k 2 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WAN_ONLINE;
};
led-3 {
gpios = <&ath9k 3 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_WAN_ONLINE;
};
led-4 {
gpios = <&ath9k 4 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WLAN_2GHZ;
linux,default-trigger = "phy0tpt";
};
led-5 {
gpios = <&ath9k 5 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_WLAN_2GHZ;
};
led-6 {
gpios = <&ath9k 6 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WLAN_5GHZ;
linux,default-trigger = "phy1tpt";
};
led-7 {
gpios = <&ath9k 7 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_WLAN_5GHZ;
};
led-8 {
gpios = <&ath9k 12 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = "tv";
};
led-9 {
gpios = <&ath9k 13 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = "tv";
};
};
regulator {
compatible = "regulator-fixed";
regulator-name = "usb-vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio 20 GPIO_ACTIVE_HIGH>;
enable-active-high;
regulator-always-on;
};
};
&ref {
clock-frequency = <40000000>;
};
&spi {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
partitions: partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/*
* since the OEM bootloader requires unknown
* filesystem on firmware area, needs to be
* replaced to u-boot before OpenWrt installation
*/
partition@0 {
label = "bootloader";
reg = <0x000000 0x020000>;
};
/* not compatible with u-boot */
partition@20000 {
label = "config";
reg = <0x020000 0x010000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
macaddr_config_6: macaddr@6 {
reg = <0x6 0x6>;
};
};
};
partition@30000 {
label = "art";
reg = <0x030000 0x010000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
cal_art_1000: calibration@1000 {
reg = <0x1000 0x440>;
};
cal_art_5000: calibration@5000 {
reg = <0x5000 0x440>;
};
};
};
};
};
};
&mdio0 {
status = "okay";
phy0: ethernet-phy@0 {
reg = <0>;
qca,ar8327-initvals = <
0x04 0x07a00000 /* PORT0_PAD_MODE_CTRL */
0x08 0x00000000 /* PORT5_PAD_MODE_CTRL */
0x0c 0x00000000 /* PORT6_PAD_MODE_CTRL */
0x10 0x81000080 /* POWER_ON_STRAP */
0x50 0xcf37cf37 /* LED_CTRL0 */
0x54 0x00000000 /* LED_CTRL1 */
0x58 0x00000000 /* LED_CTRL2 */
0x5c 0x03ffff00 /* LED_CTRL3 */
0x7c 0x0000007e /* PORT0_STATUS */
>;
};
};
&eth0 {
status = "okay";
pll-data = <0x06000000 0x00000101 0x00001616>;
phy-mode = "rgmii";
phy-handle = <&phy0>;
nvmem-cells = <&macaddr_config_6>;
nvmem-cell-names = "mac-address";
gmac-config {
device = <&gmac>;
rgmii-gmac0 = <1>;
rxdv-delay = <0>;
rxd-delay = <0>;
txd-delay = <0>;
txen-delay = <0>;
};
};
&gpio {
switch-reset {
gpio-hog;
gpios = <13 GPIO_ACTIVE_HIGH>;
output-high;
};
};
&pcie {
status = "okay";
ath9k: wifi@0,0 {
compatible = "pci168c,0030";
reg = <0x0000 0 0 0 0>;
#gpio-cells = <2>;
gpio-controller;
nvmem-cells = <&cal_art_5000>;
nvmem-cell-names = "calibration";
usb-hub-reset {
gpio-hog;
gpios = <10 GPIO_ACTIVE_HIGH>;
output-high;
};
};
};
&usb_phy {
status = "okay";
};
&usb {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
dr_mode = "host";
/delete-node/ port@1;
/* NEC uPD720114 */
hub@1 {
compatible = "usb0409,005a";
reg = <1>;
};
};
&wmac {
status = "okay";
nvmem-cells = <&cal_art_1000>;
nvmem-cell-names = "calibration";
};

View File

@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9344_nec_aterm.dtsi"
/ {
compatible = "nec,wr8750n", "qca,ar9344";
model = "NEC Aterm WR8750N";
};
&partitions {
partition@40000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x040000 0x7c0000>;
};
};

View File

@ -0,0 +1,25 @@
DEVICE_VARS += NEC_FW_TYPE
define Build/nec-usbaterm-fw
$(STAGING_DIR_HOST)/bin/nec-usbatermfw $@.new -t $(NEC_FW_TYPE) $(1)
mv $@.new $@
endef
define Device/nec-netbsd-aterm
DEVICE_VENDOR := NEC
LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
ARTIFACTS := uboot.bin
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
COMPILE := loader-$(1).bin
COMPILE/loader-$(1).bin := loader-okli-compile
ARTIFACTS += initramfs-factory.bin
ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \
pad-to 4 skip=16 | \
nec-usbaterm-fw -f 0x0003 -d $$(KDIR)/loader-$(1).bin -d $$$$@ | check-size
endif
UBOOT_PATH := $$(STAGING_DIR_IMAGE)/$$(SOC)_nec_aterm-u-boot.bin
ARTIFACT/uboot.bin := append-uboot | check-size 128k
DEVICE_PACKAGES := kmod-usb2 -uboot-envtools
endef

View File

@ -213,9 +213,74 @@ static inline void huawei_ap_init(void)
static inline void huawei_ap_init(void) {}
#endif
#if defined(CONFIG_BOARD_NEC_WR8750N)
#define AR934X_PLL_SWITCH_CLK_CTRL_REG 0x24
#define AR934X_PLL_SWITCH_CLK_CTRL_SWITCHCLK_SEL BIT(0)
static inline void nec_aterm_init(void)
{
unsigned int reg, val;
printf("NEC Aterm series (AR9344)\n");
/* set REFCLK=40MHz to switch PLL */
reg = KSEG1ADDR(AR71XX_PLL_BASE);
val = READREG(reg + AR934X_PLL_SWITCH_CLK_CTRL_REG);
val &= ~AR934X_PLL_SWITCH_CLK_CTRL_SWITCHCLK_SEL;
WRITEREG(reg + AR934X_PLL_SWITCH_CLK_CTRL_REG, val);
reg = KSEG1ADDR(AR71XX_RESET_BASE);
#ifndef LOADADDR
/*
* This is for initramfs-factory image.
* When the system was reset by power source or FULL_CHIP_RESET
* and started from the OEM bootloader with a dummy tp data
* (this loader), reset again by timeout of the watchdog timer
* to load an actual OpenWrt initramfs image in firmware block
* in a factory image.
* Note: On the stock firmware, TP block contains a POST function
* and sub commands of "tp" command.
*
* Behaviors of OEM bootloader:
*
* - reset by watchdog (ex.: rebooting on the stock firmware):
* called as "SOFT-RESET", boot a firmware without POST
*
* - reset by FULL_CHIP_RESET (or powering on):
* called as "HARD-RESET", run POST and boot a firmware
*/
printf("\n## booted with dummy tp (lzma-loader),"
" waiting reset... (count: 0x%08x) ##\n",
READREG(reg + AR71XX_RESET_REG_WDOG));
while (1);
#endif
/*
* set maximum watchdog count to avoid reset while
* booting from stock bootloader
*/
WRITEREG(reg + AR71XX_RESET_REG_WDOG, 0xffffffff);
/*
* deassert some RESET bits not handled by drivers
* and mainline U-Boot
*
* - ETH_SWITCH(_ANALOG): eth0
* - RTC : wmac
*/
val = READREG(reg + AR934X_RESET_REG_RESET_MODULE);
val &= ~(AR934X_RESET_ETH_SWITCH | AR934X_RESET_ETH_SWITCH_ANALOG |
AR934X_RESET_RTC);
WRITEREG(reg + AR934X_RESET_REG_RESET_MODULE, val);
}
#else
static inline void nec_aterm_init(void) {}
#endif
void board_init(void)
{
tlwr1043nd_init();
mr18_init();
huawei_ap_init();
nec_aterm_init();
}

View File

@ -1,4 +1,5 @@
include ./common-buffalo.mk
include ./common-nec.mk
include ./common-senao.mk
define Device/buffalo_whr-g301n
@ -120,6 +121,16 @@ define Device/engenius_enh202-v1
endef
TARGET_DEVICES += engenius_enh202-v1
define Device/nec_wr8750n
SOC := ar9344
DEVICE_MODEL := Aterm WR8750N
BLOCKSIZE := 4k
IMAGE_SIZE := 7936k
NEC_FW_TYPE := H033a
$(Device/nec-netbsd-aterm)
endef
TARGET_DEVICES += nec_wr8750n
define Device/pqi_air-pen
SOC := ar9330
DEVICE_VENDOR := PQI

View File

@ -69,6 +69,11 @@ ath79_setup_interfaces()
ucidef_add_switch "switch0" \
"0@eth1" "4:lan:1"
;;
nec,wr8750n|\
tplink,tl-wr941n-v7-cn)
ucidef_add_switch "switch0" \
"0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
;;
tplink,tl-mr3220-v1|\
tplink,tl-mr3420-v1|\
tplink,tl-mr3420-v3|\
@ -105,10 +110,6 @@ ath79_setup_interfaces()
tplink,tl-wr941-v2)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
tplink,tl-wr941n-v7-cn)
ucidef_add_switch "switch0" \
"0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
;;
ubnt,airrouter)
ucidef_set_interface_wan "eth1"
ucidef_add_switch "switch0" \
@ -152,6 +153,10 @@ ath79_setup_macs()
ubnt,picostation-m)
label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
;;
nec,wr8750n)
wan_mac=$(mtd_get_mac_binary config 0xc)
label_mac=$wan_mac
;;
tplink,tl-wr941-v2|\
tplink,tl-wr941n-v7-cn)
base_mac=$(mtd_get_mac_binary u-boot 0x1fc00)

View File

@ -9,7 +9,21 @@ RAMFS_COPY_BIN='fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config'
platform_check_image() {
return 0
local board=$(board_name)
case "$board" in
nec,wr8750n)
local uboot_mtd=$(find_mtd_part "bootloader")
# check "U-Boot <year>.<month>" string in the "bootloader" partition
if ! grep -q "U-Boot [0-9]\{4\}\.[0-9]\{2\}" $uboot_mtd; then
v "The bootloader doesn't seem to be replaced to U-Boot!"
return 1
fi
;;
*)
return 0
esac
}
platform_do_upgrade() {