Commit Graph

909 Commits (fbd4214bb0727268aa535af5b600d38939ec8dbc)

Author SHA1 Message Date
David Bauer c0a80b7125 ath79: rename qca9557.dtsi to qca955x.dtsi
There are at least 3 different chips in the Scorpion series of SoCs.
Rename the common DTSI to better reflect it's purpose for the whole
series.

Also rename the compatible bindings from qca,ar9557 and qca,qca9557
to qca,qca9550.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Adrian Schmutzler d3c9630811 ath79: move tplinkpart.c parser to patches
Between 4.19 and 5.4, mtd parsers have been moved to "parsers"
subdirectory. Like for myloader.c in the previous patch,
this patch moves tplinkpart.c to the kernel patches, so the
code and the kernel includes are at the same location and
the path can be adjusted per kernel.

While at it, remove some outdated kernel version switches from
the C code.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 5f92349841 kernel: fix include of myloader.o since kernel 5.4
Between 4.19 and 5.4, mtd parsers have been moved to "parsers"
subdirectory. Based on this, the selection of myloader.o in OpenWrt
was also moved to that subdirectory, while the Kconfig and our local
myloader.c file remained in /drivers/mtd.

This resulted in linking errors like the following (on ath25@5.4):

make[8]: *** No rule to make target 'drivers/mtd/parsers/myloader.o', ...
   needed by 'drivers/mtd/parsers/built-in.a'.  Stop.
make[7]: *** [scripts/Makefile.build:500: drivers/mtd/parsers] Error 2
make[6]: *** [scripts/Makefile.build:500: drivers/mtd] Error 2

Since myloader.c is not too big, this patch moves it to the kernel patches,
allowing to adjust the path for kernel 5.4 and keeping Makefiles and
file paths better in sync.

Other patches have been refreshed accordingly.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer 8d9c1087e4 ath79: add support for AVM FRITZ!WLAN Repeater 450E
SOC:    Qualcomm QCA9556 (Scorpion) 560MHz MIPS74Kc
RAM:    64MB Zentel A3R12E40CBF DDR2
FLASH:  16MiB Winbond W25Q128 SPI NOR
WLAN1:  QCA9556 2.4 GHz 802.11b/g/n 3x3
INPUT:  WPS button
LED:    Power, WiFi, LAN, RSSI indicator
Serial: Header Next to Black metal shield
        Pinout is 3.3V - RX - TX - GND (Square Pad is 3.3V)
        The Serial setting is 115200-8-N-1.

Installation via EVA:
In the first seconds after Power is connected, the bootloader will
listen for FTP connections on 192.168.178.1. Firmware can be uploaded
like following:

  ftp> quote USER adam2
  ftp> quote PASS adam2
  ftp> binary
  ftp> debug
  ftp> passive
  ftp> quote MEDIA FLSH
  ftp> put openwrt-sysupgrade.bin mtd1

Note that this procedure might take up to two minutes.
You need to powercycle the device afterwards to boot OpenWRT.

Tested-by: Andreas Ziegler <dev@andreas-ziegler.de>
Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer edf812e25c ath79: remove stray pipe
Fixes: 8918c038f3 ("ath79: add support for AVM FRITZ!WLAN Repeater 1750E")

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer 8918c038f3 ath79: add support for AVM FRITZ!WLAN Repeater 1750E
This commit adds support for the AVM Fritz!WLAN Repeater 1750E

SOC:	Qualcomm QCA9556 (Scorpion) 720MHz MIPS74Kc
RAM:    64MB Zentel A3R12E40CBF DDR2
FLASH:  16MiB Winbond W25Q128 SPI NOR
WLAN1:  QCA9556 2.4 GHz 802.11b/g/n 3x3
WLAN2:  QCA9880 5 GHz 802.11 n/ac 3x3
INPUT:  WPS button
LED:    Power, WiFi, LAN, RSSI indicator
Serial: Header Next to Black metal shield
        Pinout is 3.3V - RX - TX - GND (Square Pad is 3.3V)
        The Serial setting is 115200-8-N-1.

Tested and working:
 - Ethernet
 - 2.4 GHz WiFi (correct MAC)
 - 5 GHz WiFi (correct MAC)
 - Installation via EVA bootloader
 - OpenWRT sysupgrade
 - Buttons
 - LEDs

Installation via EVA:
In the first seconds after Power is connected, the bootloader will
listen for FTP connections on 192.168.178.1. Firmware can be uploaded
like following:

  ftp> quote USER adam2
  ftp> quote PASS adam2
  ftp> binary
  ftp> debug
  ftp> passive
  ftp> quote MEDIA FLSH
  ftp> put openwrt-sysupgrade.bin mtd1

Note that this procedure might take up to two minutes.
You need to powercycle the Device afterwards to boot OpenWRT.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer d883eaacd4 ath79: add QCA9550 reset sequence
The QCA9550 family of SoCs have a slightly different reset
sequence compared to older chips.

Normally the bootloader performs this sequence, however
some bootloader implementation expect the operating system
to clear the reset. Also get the PCIe resets from OF to
support the second RC of the QCA9558.

This is required for the AVM FRITZ!WLAN Repeater 1750E to work,
as EVA leaves the PCIe bus in reset.

Tested: AVM FRITZ!WLAN Repeater 1750E - OCEDO Koala

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Roger Pueyo Centelles c0430b8da4 ath79: reduce spi-max-frequency for Mikrotik wAP G-5HacT2HnD
The previous spi-max-frequency value did not work with all the CPU speed
settings (configurable with rbcfg or from the stock firmware); the new
one does for the three of them.

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
4 years ago
Koen Vandeputte 20efd5614a ath79: MikroTik: fix missing nand on kernel 5.4
Following symbol got renamed upstream:
CONFIG_MTD_NAND --> CONFIG_MTD_RAW_NAND

Also add this renamed symbol so NAND also works on kernel 5.4.

After:
[    0.628372] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xf1
[    0.634862] nand: Samsung NAND 128MiB 3,3V 8-bit
[    0.639554] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    0.647263] Scanning device for bad blocks
[    0.656228] random: fast init done
[    0.789652] 3 fixed-partitions partitions found on MTD device ar934x-nand
[    0.796550] Creating 3 MTD partitions on "ar934x-nand":
[    0.801874] 0x000000000000-0x000000040000 : "booter"
[    0.807715] 0x000000040000-0x000000400000 : "kernel"
[    0.813551] 0x000000400000-0x000008000000 : "ubi"

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Koen Vandeputte 3c3825436e kernel: bump 4.19 to 4.19.115
Refreshed all patches.

Remove upstreamed:
- 600-ipv6-addrconf-call-ipv6_mc_up-for-non-Ethernet-inter.patch
- 184-USB-serial-option-add-Wistron-Neweb-D19Q1.patch

Fixes:
- CVE-2020-8647
- CVE-2020-8648 (potentially)
- CVE-2020-8649

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Hannu Nyman a7423fef32 ath79: improve status LED definitions for GL-AR750
Improve the status LED functionality in GL-AR750
by adding the definitions for different statuses
(boot, failsafe, running, flashing).

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
4 years ago
Adrian Schmutzler 508462a399 ath79: add SUPPORTED_DEVICES for TP-Link TL-WA901ND v2
This adds the board name from ar71xx to support upgrade without
-F for the TP-Link TL-WA901ND v2.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Petr Štetiar 0bea89a1d0 kernel: bump 5.4 to 5.4.32
Refreshed patches, removed upstreamed patches:

 generic: 746-stable-net-dsa-mt7530-fix-null-pointer-dereferencing-in-por.patch

Run tested: qemu-x86-64, apalis
Build tested: x86/64, imx6, sunxi/a53

Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years ago
Adrian Schmutzler d0cb6e995b ath79: further fixes for ZyXEL NBG6716
This applies further fixes to the DTS of ZyXEL NBG6716 based on
what is found in ar71xx (mach-nbg6716.c):

- use WiFi label names as in ar71xx
- fix WPS gpio number
- fix GPIO_ACTIVE_HIGH and mode for WiFi switch
- add codes for USB eject buttons
- fix node name for "internet" LED

This device has separate LEDs for WAN and "Internet". As the WAN-LED
(and the four LAN-LEDs) are driven independent of the setup in
DT/01_leds, the "internet" LED is left unassigned (in contrast to
ar71xx, where it was set up effectively as a second WAN LED)

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Luiz Angelo Daros de Luca 1b2c4af039 ath79: enable m25p,fast-read for tplink,tl-wr1043-v1
Enables spi-mem interface for 3x faster flash read.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
4 years ago
Luiz Angelo Daros de Luca e430dfdd69 ath79: enable m25p,fast-read for tplink,tl-wr2543-v1
Enables spi-mem interface usage. It speeds up flash read
in about 3x while it also workaround a possible hardware
bug when normal spi read is used.

Fixes: FS#2742

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
4 years ago
Luiz Angelo Daros de Luca b3f9842330 ath79: add read support using spi-mem
Reimplements read optimization on top of spi-mem. Similar to
what 461-spi-ath79-add-fast-flash-read.patch used to do with
the dropped flash read interface.

It accelerate only fast-read op reading flash directly from
memory mapped region. 'm25p,fast-read' must be set in order
to use the new spi-mem.

It improved read speed up to 3x on old devices (tplink,tl-wr2543-v1)
while no speed improvement was noticed on newer devices like
(tplink,archer-c7-v2).

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
4 years ago
Adrian Schmutzler 97af28d23e ath79: fix USB port LED assignment for ZyXEL NBG6716
The USB LED assignment to internal ports was swapped.

Fix it.

We also explicitly checked that the LED label numbers match those
on the device.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Guillaume Lefebvre f5a9181d6e ath79: fix wmac initialization for Zyxel NBG6716
2.4 GHz Wifi on ath79 is set up in 10-ath9k-eeprom, but in ar71xx
it was done with ath79_register_wmac.

Thus, the following errors are observed on the device:
ath: phy1: Unable to initialize hardware; initialization status: -5
ath9k 18100000.wmac: failed to initialize device
ath9k: probe of 18100000.wmac failed with error -5

This patch changes the ath79 support to properly use wmac as well.
This will also require fixing the MAC address in a different way.

Signed-off-by: Guillaume Lefebvre <guillaume@zelig.ch>
[several adjustments to 10-fix-wifi-mac, use correct MAC address,
rewrite commit message]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Roman Hampel cd510e775b ath79: add support for Comfast CF-WR752AC v1
Specifications:

- Qualcomm QCA9531 + QCA9886
- dual band, antenna 2*3dBi
- Output power 50mW (17dBm)
- 1x 10/100 Mbps LAN RJ45
- 128 MB RAM / 16 MB FLASH (w25q128)
- 3 LEDs (red/green/blue)
  incorporated in
  "color wheel reset switch"
- UART 115200 8N1

Flashing instructions:

 The U-boot bootloader contains a recovery HTTP server
 to upload the  firmware. Push the reset button while powering the
 device on and keep it pressed for ~10 seconds. The device's LEDs will
 blink several times and the recovery page will be at
 http://192.168.1.1; use it to upload the sysupgrade image.

 Alternatively, the original firmware is based on OpenWrt so a
 sysupgrade image can be installed via the stock web GUI. Settings from
 the original firmware will be saved and restored on the new one, so a
 factory reset will be needed. To do so, once the new firmware is flashed,
 enter into failsafe mode by pressing the reset button several times during
 the boot process, until it starts flashing. Once in failsafe mode, perform
 a factory reset as usual.

LED-Info:

 The LEDs on the Comfast stock fw have a very proprietary behaviour,
 corresponding to the user selected working mode (AP, ROUTER or REPEATER).
 In the first two cases, only blue is used for status and LAN signaling. When
 using the latter, blue is always off (except for sysupgrade), either red
 signals bad rssi on master-link, or green good. Since the default working
 mode of OpenWrt resembles that of a router/AP, the default behavior is
 implemented accordingly.

MAC addresses (art partition):

location  address (example)    use in vendor firmware
0x0       xx:xx:xx:xx:xc:f8 -> eth0
0x6       xx:xx:xx:xx:xc:fa -> wlan5g (+2)
0x1002    xx:xx:xx:xx:xc:f9 -> not used
0x5006    xx:xx:xx:xx:xc:fb -> not used
---       xx:xx:xx:xx:xd:02 -> wlan2g (+10)

The same strange situation has already been observed and documented
for COMFAST CF-E560AC.

Signed-off-by: Roman Hampel <rhamp@arcor.de>
Co-developed-by: Joao Albuquerque <joaohccalbu@gmail.com>
Signed-off-by: Joao Albuquerque <joaohccalbu@gmail.com>
[adjust and extend commit message, rebase, minor DTS adjustments,
add correct MAC address for wmac, change RSSI LED names and behavior]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 85aef6f627 ath79: fix MAC addresses for ethernet on ZyXEL NBG6716
MAC addresses of the ethernet devices (eth0 & eth1) are randomly set at
boot time by the ag71xx driver, because it is currently not possible to
retrieve MAC addresses in ASCII format within the DTS file.
This commit works around this behaviour by setting the MAC addresses
during the preinit phase.

The same has been implemented recently for the Siemens WS-AP3610 in
d2b8ccb1c0 ("ath79: add support for Siemens WS-AP3610").

MAC assignment in vendor firmware is as follows:

use   vendor   address     OpenWrt
2g    wifi0    ethaddr     -> wlan1
5g    wifi1    ethaddr +1  -> wlan0
lan   eth1     ethaddr +2  -> eth0
wan   eth0     ethaddr +3  -> eth1

ethaddr is retrieved by $(mtd_get_mac_ascii u-boot-env ethaddr)

Note that both Wifi and ethernet indexing is swapped in OpenWrt
compared to vendor firmware.

Suggested-by: Guillaume Lefebvre <guillaume@zelig.ch>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Kevin Gagnon <kevin_gagnon@videotron.ca>
4 years ago
Chris Morgan 7daab62861 ath79: add support for Comfast CF-EW72
Specifications:
Qualcomm/Atheros QCA9531 + QCA9886
2x 10/100 Mbps Ethernet, with 48v PoE
2T2R 2.4 GHz, 802.11b/g/n
2T2R 5 GHz, 802.11a/n/ac
128MB RAM
16MB SPI Flash
4x LED (Always On Power, LAN, WAN, WLAN)

Flashing Instructions:
Original firmware is based on OpenWRT, so flashing the sysupgrade image on
the factory firmware is sufficient.

Tested: Reset button, WAN LED, LAN LED, Power LED (always on, not much
to test), WLAN LED (one LED only for 2 interfaces, by default it gets
assigned to the first interface), MAC addresses (match factory firmware).
My LAN factory MAC address ends in F2.

use	stock_mac	art_loc
lan	:f2		0x0
wan	:f3		0x1002
5g	:f4		0x6
2g	:f5		0x5006

Since MAC address flash locations do not really match their use in vendor
firmware (e.g. address from 5 GHz calibration data is assigned to 2.4 GHz
WiFi), just calculate the MAC addresses with an offset based on 0x0 address.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
[add MAC address comment]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Lim Guo Wei bf9b742cd4 ath79: add support for TP-Link TL-MR3420 v3
This adds support for the TP-Link TL-MR3420 v3, a later revision of the
v2 with an external gpiochip similar to TP-Link Archer C7 v4.

Specifications:

SOC: Qualcomm Atheros QCA9531
CPU: 650MHz
Flash: 4 MiB
RAM: 32 MiB
WLAN: Qualcomm Atheros QCA9531 bgn 2T2R 2.4 GHz
Ethernet: 5 ports (100M)

Flashing instructions:

- Flash factory image from OEM WebUI:
  openwrt-ath79-tiny-tplink_tl-mr3420-v3-squashfs-factory.bin
- Sysupgrade from ath79 image:
  openwrt-ath79-tiny-tplink_tl-mr3420-v3-squashfs-sysupgrade.bin

Signed-off-by: Lim Guo Wei <limguowei@gmail.com>
[remove SUPPORTED devices, some typo adjustments, fix WAN MAC
address, fix sorting in 01_leds]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Thibaut VARÈNE fdac4c085d ath79: improve mikrotik-caldata.sh
Reduce unnecessary flash wear and be tidy:
- Run the extraction only if necessary
- Extract temporary file to /tmp
- cleanup after execution

Tested-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
4 years ago
Petr Štetiar 5ecc0cfd6f kernel: bump 5.4 to 5.4.28
Changelog since 5.4.24 mentions CVE-2019-19769, CVE-2020-8648,
CVE-2020-8649 and CVE-2020-8647.

Removed upstreamed:

 generic: 507-v5.6-iio-chemical-sps30-fix-missing-triggered-buffer-depe.patch
 generic: 600-ipv6-addrconf-call-ipv6_mc_up-for-non-Ethernet-inter.patch
 bcm27xx: 950-0435-ASoC-pcm512x-Fix-unbalanced-regulator-enable-call-in.patch
 ipq806x: 701-stmmac-fix-notifier-registration.patch
 lantiq: 002-pinctrl-falcon-fix-syntax-error.patch
 octeontx: 0002-net-thunderx-workaround-BGX-TX-Underflow-issue.patch

Run tested: apu2, qemu-x86-64, apalis, a64-olinuxino, nbg6617
Build tested: sunxi/a53, imx6, x86/64, ipq40xx

Tested-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> [apu2]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years ago
Thibaut VARÈNE 92616c4227 ath79: rename Mikrotik RB 922UAGS-5HPacD mtd partition
In RouterBOARD parlance there never was an "art" partition.
This partition has always been named 'hard_config' on ar71xx.

This partition contains more than just ART (Atheros Radio Test) data. It
includes the hardware description (product code, serial, board
identifier, name, hardware options, MAC address), as well as other bits
affecting the operation of RouterBoot.
To avoid confusion with regular ART data, this partition is renamed in
line with historical ar71xx and ramips nomenclature as 'hard_config'.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
[minor commit title/message adjustments]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Thibaut VARÈNE 9a122df07e ath79: fix Mikrotik wAP G-5HacT2HnD mtd partitions
In RouterBOARD parlance there never was an "art" partition.
This partition has always been named 'hard_config' on ar71xx.

This partition contains more than just ART (Atheros Radio Test) data. It
includes the hardware description (product code, serial, board
identifier, name, hardware options, MAC address), as well as other bits
affecting the operation of RouterBoot.
To avoid confusion with regular ART data, this partition is renamed in
line with historical ar71xx and ramips nomenclature as 'hard_config'.

This commit fixes the previous support files and implements the nested
RouterBoot partition scheme as already used by ramips-based SPI-NOR
RouterBOARD DTSes, as previously reviewed and implemented in
bbe2cf657c ("ramips: fix RBM11G partitioning").

Tested-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
[minor commit title/message adjustments]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 385f4868bc ath79: add support for TP-Link TL-WA860RE v1
This ports support for the TL-WA860RE v1 range extender from ar71xx
to ath79.

Specifications:
  Board: AP123 / AR9341 rev. 3
  Flash/RAM: 4/32 MiB
  CPU: 535 MHz
  WiFi: 2.4 GHz b/g/n
  Ethernet: 1 port (100M)
  Two external antennas

Flashing instructions:
  Upload the factory image via the vendor firmware upgrade option.

Recovery:
  Note that this device does not provide TFTP via ethernet like many
  other TP-Link devices do. You will have to open the case if you
  require recovery beyond failsafe.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Sebastian Knapp <sebastian4842@outlook.com>
4 years ago
Adrian Schmutzler 676ca94c3c ath79: add support for TP-Link TL-WDR4310 v1
This device seems to be identical to the TL-WDR4300, just with
different release date/region and TPLINK_HWID.

Support is added based on the ar71xx implementation.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer f1f8700d54 ath79: fix missing return statement in ar934x_nand
The reset assert and deassert methods currently miss
a return value, leading to a compilation warning.

Return the return-value of reset_control_assert and
reset_control_deassert to fix these warnings.

Suggested-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer 94c0926106 ath79: fix NAND driver compilation for kernel 5.4
This fixes the compilation of the AR934x NAND controller
driver for kernel 5.4 while leaving it untouched for
kernel 4.19.

This change is currently not run-tested, as i do not have such
a device at hand.

CC: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
CC: André Valentin <avalentin@marcant.net>
CC: WeiDong Jia <jwdsccd@gmail.com>
Signed-off-by: David Bauer <mail@david-bauer.net>
Tested-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
David Bauer 280868e54d ath79: align Ubiquiti AC Pro ethernet map to factory
The Uniquiti AC Pro and Ubiquiti AC Mesh Pro currently have the
"Primary" and "Secondary" ethernet ports configured to offer LAN as well
as WAN. However, Uiquiti describes the following behavior for the
devices Ethernet ports:

 > Secondary UniFi Access Point (UAP) Ethernet ports don't
 > provide PoE passthrough (to run current to a second powered
 > device), but they do support data passthrough.
 > It serves as a bridged interface between main / secondary
 > Ethernet port.

To reduce confusion for users (as LAN and WAN functionality is not
visible on the device itself), configure both ports to offer LAN
functionality. Users can still configure a WAN interface on a port they
are able to choose.

CC: Lucian Cristian <lucian.cristian@gmail.com>
Reported-by: Florian Klink <flokli@flokli.de>
Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Roger Pueyo Centelles 1775d50bde ath79: add support for Ubiquiti NanoBridge M (XM)
This patch adds support for the Ubiquiti NanoBridge M (XM), a
802.11n wireless with a feed+dish form factor, with the same board
definition as the Bullet M (XM).

Specifications:
 - Atheros AR7241 SoC
 - 32 MB RAM
 - 8 MB SPI flash
 - 1x 10/100 Mbps Ethernet port, 24 Vdc PoE-in
 - Power and LAN green LEDs
 - 4x RSSI LEDs (red, orange, green, green)
 - UART (115200 8N1)

Flashing via stock GUI:
 - WARNING: flashing OpenWrt from AirOS v5.6 or newer will brick your
   device! Read the wiki for more info.
 - Downgrade to AirOS v5.5.x (latest available is 5.5.11) first.
 - Upload the factory image via AirOS web GUI.

Flashing via TFTP:
 - WARNING: flashing OpenWrt from AirOS v5.6 or newer will brick your
   device! Read the wiki for more info.
 - Downgrade to AirOS v5.5.x (latest available is 5.5.11) first.
 - Use a pointy tool (e.g., pen cap, slotted screwdriver) to keep the
   reset button pressed.
 - Power on the device (keep reset button pressed).
 - Keep pressing until LEDs flash alternatively LED1+LED3 =>
   LED2+LED4 => LED1+LED3, etc.
 - Release reset button.
 - The device starts a TFTP server at 192.168.1.20.
 - Set a static IP on the computer (e.g., 192.168.1.21/24).
 - Upload via tftp the factory image:
    $ tftp 192.168.1.20
    tftp> bin
    tftp> trace
    tftp> put openwrt-ath79-generic-xxxxx-ubnt_nanobridge-m-squashfs-factory.bin

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
[rebase, fix includes in DTS, add label MAC address, add SOC and
fix sorting in generic-ubnt.mk]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Sungbo Eo 3f14f034fb treewide: omit IMAGE_SIZE argument from check-size
Now that check-size uses IMAGE_SIZE by default, we can skip the argument from
image recipes to reduce redundancy.

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
[do not touch ar71xx]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Sungbo Eo 5b392c7119 treewide: gather DEVICE_VARS into one place
Place DEVICE_VARS assignments at the top of the file or above Device/Default
to make them easier to find.

For ramips, remove redundant values already present in parent file.

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
[do not touch ar71xx, extend commit message]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Russell Senior d5812478ad ath79: add support for ubnt_bullet-m-ar7240 variant
This adds support for the Ubiquiti Bullet M (AR7240).

Specifications:
- AR7240 SoC @ 400 MHz
- 32 MB RAM
- 8 MB SPI flash
- 1x 10/100 Mbps Ethernet, 24 Vdc PoE-in
- External antenna
- POWER/LAN green LEDs
- 4x RSSI LEDs (red, orange, green, green)
- UART (115200 8N1) on PCB

Flashing via WebUI:
  Upload the factory image via the stock firmware web UI.

  Attention: airOS firmware versions >= 5.6 have a new bootloader with
  an incompatible partition table!

  Please downgrade to <= 5.5 _before_ flashing OpenWrt!
  Refer to the device's Wiki page for further information.

Flashing via TFTP:
  Same procedure as other Ubiquiti M boards.

- Use a pointy tool (e.g., pen cap, paper clip) and keep the reset
  button on the device or on the PoE supply pressed
- Power on the device via PoE (keep reset button pressed)
- Keep pressing until LEDs flash alternatively LED1+LED3 =>
  LED2+LED4 => LED1+LED3, etc.
- Release reset button
- The device starts a TFTP server at 192.168.1.20
- Set a static IP on the computer (e.g., 192.168.1.21/24)
- Upload via tftp the factory image:
  $ tftp 192.168.1.20
  tftp> bin
  tftp> trace
  tftp> put openwrt-ath79-generic-xxxxx-ubnt_bullet-m-ar7240-squashfs-factory.bin

The "fixed-link" section of the device tree is needed to avoid errors like this:

  Generic PHY mdio.0:1f:04: Master/Slave resolution failed, maybe conflicting manual settings?

With "fixed-link", the errors go away and eth0 comes up reliably.

Signed-off-by: Russell Senior <russell@personaltelco.net>
[fix SUPPORTED_DEVICES]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Davide Fioravanti 213250b56b ath79: add support for TP-Link Archer D7/D7b v1
TP-Link Archer D7 v1 is a dual-band AC1750 router + modem.
The router section is based on Qualcomm/Atheros QCA9558 + QCA9880.
The "DSL" section is based on BCM6318 but it's currently not supported.

The Archer D7b seems to differ from the Archer D7 only in the
partition table.

Router section - Specification:

775/650/258 MHz (CPU/DDR/AHB)
128 MB of RAM (DDR2)
16 MB of FLASH (SPI NOR)
3T3R 2.4 GHz
3T3R 5 GHz
4x 10/100/1000 Mbps Ethernet
7x LED, 2x button
UART header on PCB

Known issues:

- Broadband LED (missing GPIO - probably driven by the BCM6318)
- Internet LED (missing GPIO - probably driven by the BCM6318)
- WIFI LED (working only for one interface at a time, while in the
  OEM firmware works for both wifi interfaces; thus, this patch does
  not set a trigger by default)
- DSL not working (eth0)

UART connection
---------------
J1 HEADER (Qualcomm CPU)
. VCC
. GND
. RX
O TX

J41 HEADER (Broadcom CPU)
. VCC
. GND
. RX
O TX

The following instructions require a connection to the J1 UART header
and are tested for the Archer D7 v1.
For the Archer D7b v1, names should be changed accordingly.

Flash instructions under U-Boot, using UART
------------------------------------------
 1. Press "tpl" to stop autobooting and obtain U-Boot CLI access.
 2. Setup ip addresses for U-Boot and your tftp server.
 3. Issue below commands:
	tftpboot 0x81000000 openwrt-ath79-generic-tplink_archer-d7-v1-squashfs-sysupgrade.bin
	erase 0x9f020000 +f90000
	cp.b 0x81000000 0x9f020000 0xf90000
	reset

Initramfs instructions under U-Boot for testing, using UART
----------------------------------------------------------
 1. Press "tpl" to stop autobooting and obtain U-Boot CLI access.
 2. Setup ip addresses for U-Boot and your tftp server.
 3. Issue below commands:
	tftpboot 0x81000000 openwrt-ath79-generic-tplink_archer-d7-v1-initramfs-kernel.bin
	bootm 0x81000000
 4. Here you can backup the original firmware and/or flash the sysupgrade openwrt if you want

Restore the original firmware
-----------------------------
 0. Backup every partition using the OpenWrt web interface
 1. Download the OEM firmware from the TP-Link website
 2. Extract the bin file in a folder (eg. Archer_D7v1_1.6.0_0.9.1_up_boot(160216)_2016-02-16_15.55.48.bin)
 3. Remove the U-Boot and the Broadcom image part from the file.
    Issue the following command:
	dd if="Archer_D7v1_1.6.0_0.9.1_up_boot(160216)_2016-02-16_15.55.48.bin" of="Archer_D7v1_1.6.0_0.9.1_up_boot(160216)_2016-02-16_15.55.48.bin.mod" skip=257 bs=512 count=31872
 4. Double check the .mod file size. It must be 16318464 bytes.
 5. Flash it using the OpenWrt web interface. Force the update if needed.
    WARNING: Remember to NOT keep settings.

 5b. (Alternative to 5.) Flash it using the U-Boot and UART connection.
     Issue below commands in the U-Boot:
	tftpboot 0x81000000 Archer_D7v1_1.6.0_0.9.1_up_boot(160216)_2016-02-16_15.55.48.bin.mod
	erase 0x9f020000 +f90000
	cp.b 0x81000000 0x9f020000 0xf90000
	reset

Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com>
[cosmetic DTS changes, remove TPLINK_HWREVADD := 0, do not use two
phyXtpt at once, add missing buttons, minor commit message adjustments]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 646d95c374 ath79: add support for TP-Link Archer C60 v3
TP-Link Archer C60 v3 is a dual-band AC1350 router,
based on Qualcomm/Atheros QCA9561 + QCA9886.

It seems to be identical to the v2 revision, except that
it lacks a WPS LED and has different GPIO for amber WAN LED.

Specification:

- 775/650/258 MHz (CPU/DDR/AHB)
- 64 MB of RAM (DDR2)
- 8 MB of FLASH (SPI NOR)
- 3T3R 2.4 GHz
- 2T2R 5 GHz
- 5x 10/100 Mbps Ethernet
- 6x LED, 2x button
- UART header on PCB

Flash instruction (WebUI):
Download *-factory.bin image and upload it via the firmwary upgrade
function of the stock firmware WebUI.

Flash instruction (TFTP):
1. Set PC to fixed IP address 192.168.0.66
2. Download *-factory.bin image and rename it to tp_recovery.bin
3. Start a tftp server with the file tp_recovery.bin in its root
   directory
4. Turn off the router
5. Press and hold reset button
6. Turn on router with the reset button pressed and wait ~15 seconds
7. Release the reset button and after a short time the firmware should
   be transferred from the tftp server
8. Wait ~30 second to complete recovery

While TFTP works for OpenWrt images, my device didn't accept the
only available official firmware "Archer C60(EU)_V3.0_190115.bin".

In contrast to earlier revisions (v2), the v3 contains the (same)
MAC address twice, once in 0x1fa08 and again in 0x1fb08.
While the partition-table on the device refers to the latter, the
firmware image contains a different partition-table for that region:

name           device            firmware
factory-boot   0x00000-0x1fb00   0x00000-0x1fa00
default-mac    0x1fb00-0x1fd00   0x1fa00-0x1fc00
pin            0x1fd00-0x1fe00   0x1fc00-0x1fd00
product-info   0x1fe00-0x1ff00   0x1fd00-0x1ff00
device-id      0x1ff00-0x20000   0x1ff00-0x20000

While the MAC address is present twice, other data like the PIN isn't,
so with the partitioning from the firmware image the PIN on the device
would actually be outside of its partition.
Consequently, the patch uses the MAC location from the device (which
is the same as for the v2).

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Russell Senior 8cacb84041 ath79: rename ubnt_bullet-m to ubnt_bullet-m-ar7241
Since there exists another variant of the Bullet M with AR7240 SoC
under the same name, this patch introduces the SoC into the device
name to be able to distinguish these variants.

Signed-off-by: Russell Senior <russell@personaltelco.net>
[add commit message, adjust model in DTS, fix 02_network and
SUPPORTED_DEVICES]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Russell Senior 572278d3a0 ath79: generalize ubnt_xm dtsi for ar7240 and ar7241
* Prepare to support the AR7240 variant of ubiquiti bullet m, by
  reorganizing the related dtsi files.

* Distribute SOC variable across ubnt-xm devices.

Signed-off-by: Russell Senior <russell@personaltelco.net>
4 years ago
Adrian Schmutzler a57fcd880e ath79: fix execute bit for 02_network on mikrotik subtarget
When creating the mikrotik subtarget, the execute bit on 02_network
was not set. Fix it.

Fixes: a66eee6336 ("ath79: add mikrotik subtarget")

Reported-by: Christopher Hill <ch6574@gmail.com>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 3d8be08939 ath79: get rid of BOARD_NAME for Mikrotik RouterBOARD
So far, specifying "BOARD_NAME := routerboard" is required by the
upgrade code of Mikrotik NAND devices, as "sysupgrade-routerboard"
is hardcoded in platform_do_upgrade_mikrotik_nand().

This patch replaces the latter with a grep for the name like it
is already done in nand_upgrade_tar() in /lib/upgrade/nand.sh.

By that, BOARD_NAME is obsolete now for this device.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Roger Pueyo Centelles a66eee6336 ath79: add mikrotik subtarget
This commit creates the ath79/mikrotik subtarget in order to support
MikroTik devices based on Qualcomm Atheros MIPS SoCs.

MikroTik devices need a couple of specific features: the split MiNOR
firmware MTD format, which is not used by other devices, and the 4k
sector erase size on SPI NOR storage, which can not be added to the
ath79/generic and ath79/nand subtargets now.

Additionally, the commit moves the two MikroTik devices already in
the generic and nand subtargets to this new one.

Tested on the RB922 board and the wAP AC router.

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
4 years ago
David Bauer f68c48f7dd ath79: fix missing watchdog core dependency for hwmon-sch5627
Fixes following error uncovered while building ath79/tiny on 5.4:

 Package kmod-hwmon-sch5627 is missing dependencies for the following
 libraries:
 watchdog.ko

See the similar commit e546e6252b ("malta: fix missing watchdog core
dependency for hwmon-sch5627") for a detailed explanation.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer fcd247d02b ath79: add correct phy-mode for QCA9563 boards
The TP-Link RE450 as well as the UniFi AC series missed the phy-mode
property. Because of this, the incorrect MII phy-mode from the root dtsi
was used.

With Kernel 5.4, this leads to problems when used with a AR8033 PHY. The
bootloader seems to leave the fiber pages selected.

As there's not switch to copper pages happening in at803x_config_init
due to the incorrect phy-mode, the new at803x_read_status will interpret
the status of the SGMII side as the status of the copper side.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer 32726846c8 ath79: use downstream ag71xx for Kernel 5.4
The ag71xx driver from Linux 5.4 currently has various shortcomings
when used with OpenWrt compared to our downstream version.

For example, the upstream driver does not support modifying the ethernet
clock and configuring RGMII delays on the MAC side.

While we should certainly switch to the upstream driver, the amount of
necessary patches would make it cumbersome to work with. It's also
highly likely we won't be able to finish patching the upstream driver in
time for a Linux 5.4 release.

Tested on Siemens WS-AP3610.

CC: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: David Bauer <mail@david-bauer.net>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
Sungbo Eo 4caaa778f7 kernel: make kmod-i2c-core selected by dependent modules
Currently kmod-i2c-* will not get into images unless kmod-i2c-core is added to
DEVICE_PACKAGES as well. By changing the dependencies from "depends on" to
"select", we do not have the issue anymore.

Furthermore, we can remove most occurrences of the package from DEVICE_PACKAGES
and similar variables, as it is now pulled by dependent modules such as:
- kmod-hwmon-lm75
- kmod-i2c-gpio
- kmod-i2c-gpio-custom
- kmod-i2c-mux
- kmod-i2c-ralink

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
[do not touch ar71xx]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Jun Su b9f4f1f97a ath79: add support for TP-Link TL-WR740N v5
This adds support for the TP-Link TL-WR740N v5, a clone of the
v4 only with a different TPLINK_HWID. It was already supported
in ar71xx as well.

Specifications:

SOC: Atheros AR9331
CPU: 400MHz
Flash: 4 MiB
RAM: 32 MiB
WLAN: Atheros AR9330 bgn
Ethernet: 5 ports (100M)

Flashing instructions:

- Flash factory image from OEM WebUI:
  openwrt-ath79-tiny-tplink_tl-wr740n-v5-squashfs-factory.bin
- Sysupgrade from ar71xx image:
  openwrt-ath79-tiny-tplink_tl-wr740n-v5-squashfs-sysupgrade.bin

Signed-off-by: Jun Su <howard0su@gmail.com>
[commit title/message facelift]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer 86fe348949 ath79: add back NAND symbols to NAND target
The NAND config symbols were removed unintentionally while adding
support for Linux 5.4.

Add the respective symbols for v4.19 as well as v5.4.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Hauke Mehrtens 7a6a85ce10 ath79: Remove kernel 4.14 support
This target was switched to kernel 4.19 more than 6 months ago in commit
f342ffd300 ("treewide: kernel: bump some targets to 4.19") and now
with kernel 5.4 support being added it gets harder to support kernel
4.14 in addition to kernel 4.19 and 5.4.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
Sungbo Eo 90daff4cf8 build: image: move IMAGE_SIZE to image.mk
IMAGE_SIZE is widely used in many targets. Declare it in the default template to
clean up redundant code. This also prevents deriving IMAGE_SIZE unintentionally
from the previously defined device.

While at it, remove duplicate KERNEL_SIZE declaration.

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
4 years ago
Adrian Schmutzler b054729899 ath79: fix port order on TP-Link Archer C60 v1/v2
The labels on the LAN ports of the TP-Link Archer C60 v1/v2 are
actually inverted compared to the ports of the internal switch.

Add this information to 02_network.

This is the same for to-be-supported v3 of this device.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 88aead0a66 ath79: fix swapped LAN/WAN MAC address for Archer C60 v1/v2
The MAC addresses for lan/wan are swapped compared to the vendor
firmware. This adjusts to vendor configuration, which is:

lan   *:7b   label
wan   *:7c   label+1
2.4g  *:7b   label
5g    *:7a   label-1

Only one address is stored in <&mac 0x8>, corresponding to the label.

This has been checked on revisions v1, v2 and v3.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Catrinel Catrinescu 3e03b7ac4a ar71xx/ath79: ew-dorin, fix the trigger level for WPS button
Because the WPS button had the wrong trigger level,
the failsafe mode was triggered quite often,
after this commit:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=27f3f493de

Signed-off-by: Catrinel Catrinescu <cc@80211.de>
4 years ago
Yousong Zhou 860652f4b9 kernel: 5.4: move some kconfig options to generic
CONFIG_64BIT_TIME=y
	CONFIG_KASAN_STACK=1
	CONFIG_UBSAN_ALIGNMENT=y
	CONFIG_UNIX_SCM=y
	CONFIG_DMA_DECLARE_COHERENT=y
	CONFIG_OF_RESERVED_MEM=y

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
4 years ago
Adrian Schmutzler ab9fd528ae ath79: fix indent for wrapped lines in image/nand.mk
This applies the common indent (one tab) for the wrapped lines of
domywifi_dw33d and glinet_gl-ar750s-nor-nand.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Davide Fioravanti dfb7a4ce5d ath79: add support for Sitecom WLR-8100
Sitecom WLR-8100 v1 002 (marketed as X8 AC1750) is a dual band wireless
router.

Specification:

- Qualcomm Atheros SoC QCA9558
- 128 MB of RAM (DDR2)
- 16 MB of FLASH (Macronix MX25L12845EMI-10G - SPI NOR)
- 5x 10/100/1000 Mbps Ethernet
- 3T3R 2.4 GHz (QCA9558 WMAC)
- 3T3R 5.8 Ghz (QCA9880-BR4A)
- 1x USB 3.0 (Etron EJ168A)
- 1x USB 2.0
- 9x LEDs
- 2x GPIO buttons

Everything working.
Installation and restore procedure tested

Installation
1. Connect to one of LAN (yellow) ethernet ports,
2. Open router configuration interface,
3. Go to Toolbox > Firmware,
4. Browse for OpenWrt factory image with dlf extension and hit Apply,
5. Wait few minutes, after the Power LED will stop blinking, the router
	is ready for configuration.

Restore OEM FW (Linux only)
1. Download OEM FW from website (tested with WLR-8100v1002-firmware-v27.dlf)
2. Compile the FW for this router and locate the "mksenaofw" tool
	in build_dir/host/firmware-utils/bin/ inside the OpenWrt buildroot
3. Execute "mksenaofw -d WLR-8100v1002-firmware-v27.dlf -o WLR-8100v1002-firmware-v27.dlf.out" where:
	WLR-8100v1002-firmware-v27.dlf is the path to the input file
		(use the downloaded file)
	WLR-8100v1002-firmware-v27.dlf.out is the path to the output file
		(you can use the filename you want)
4. Flash the new WLR-8100v1002-firmware-v27.dlf.out file. WARNING: Do not keep settings.

Additional notes.
The original firmware has the following button configuration:
- Press for 2s the 2.4GHz button: WPS for 2.4GHz
- Press for 2s the 5GHz button: WPS for 5GHz
- Press for 15s both 2.4GHz and 5GHz buttons: Reset
I am not able to replicate this behaviour, so I used the following configuration:
- Press the 2.4GHz button: RFKILL (disable/enable every wireless interfaces)
- Press the 5GHz button: Reset

Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com>
4 years ago
Manuel Giganto b2130b9ce8 ath79: add support for Devolo Magic 2 WIFI
This patch support Devolo Magic 2 WIFI, board devolo_dlan2-2400-ac.
This device is a plc wifi AC2400 router/extender with 2 Ethernet
ports, has a G.hn PLC and uses LCMP protocol from Home Grid Forum.

Hardware:
   SoC:         AR9344
   CPU:         560 MHz
   Flash:       16 MiB (W25Q128JVSIQ)
   RAM:         128 MiB DDR2
   Ethernet:    2xLAN 10/100/1000
   PLC:         88LX5152 (MaxLinear G.hn)
   PLC Flash:   W25Q32JVSSIQ
   PLC Uplink:  1Gbps MIMO
   PLC Link:    RGMII 1Gbps (WAN)
   WiFi:        Atheros AR9340 2.4GHz 802.11bgn
                Atheros AR9882-BR4A 5GHz 802.11ac
   Switch:      QCA8337, Port0:CPU, Port2:PLC, Port3:LAN1, Port4:LAN2
   Button:      3x Buttons (Reset, wifi and plc)
   LED:         3x Leds (wifi, plc white, plc red)
   GPIO Switch: 11-PLC Pairing (Active Low)
                13-PLC Enable
                21-WLAN power

MACs Details verified with the stock firmware:
   Radio1: 2.4 GHz &wmac     *:4c Art location: 0x1002
   Radio0: 5.0 GHz &pcie     *:4d Art location: 0x5006
   Ethernet        &ethernet *:4e = 2.4 GHz + 2
   PLC uplink      ---       *:4f = 2.4 GHz + 3
Label MAC address is from PLC uplink

OEM SSID: echo devolo-$(grep SerialNumber /dev/mtd1 | grep -o ...$)
OEM WiFi password: grep DlanSecurityID /dev/mtd1|tr -d -|cut -d'=' -f 2

Recommendations: Configure and link your PLC with OEM firmware
BEFORE you flash the device. PLC configuration/link should
remain in different memory and should work straight forward
after flashing.

Restrictions: PLC link detection to trigger plc red led is not
available. PLC G.hn chip is not compatible with open-plc-tools,
it uses LCMP protocol with AES-128 and requires different
software.

Notes: Pairing should be possible with gpio switch. Default
configuration will trigger wifi led with 2.4Ghz wifi traffic
and plc white led with wan traffic.

Flash instruction (TFTP):
 1. Set PC to fixed ip address 192.168.0.100
 2. Download the sysupgrade image and rename it to uploadfile
 3. Start a tftp server with the image file in its root directory
 4. Turn off the router
 5. Press and hold Reset button
 6. Turn on router with the reset button pressed and wait ~15 seconds
 7. Release the reset button and after a short time
    the firmware should be transferred from the tftp server
 8. Allow 1-2 minutes for the first boot.

Signed-off-by: Manuel Giganto <mgigantoregistros@gmail.com>
4 years ago
WeiDong Jia 643cab4f31 ath79: add support for DomyWifi DW33D
This commit ports the device from ar71xx to the ath79 target and
modifies the partition layout.
1. Firmware is installed to nand flash.
2. Modify the uboot-env parameter to boot from the nand flash.
3. The kernel size is extended to 5M.
4.nor flash retains the oem firmware.

oem partition layout
dev:    size   erasesize  name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00e30000 00010000 "rootfs"
mtd3: 00170000 00010000 "kernel"
mtd4: 00010000 00010000 "art"
mtd5: 00f90000 00010000 "firmware"
mtd6: 06000000 00020000 "rootfs_data"
mtd7: 02000000 00020000 "backup"

new partition layout
dev:    size   erasesize  name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00fa0000 00010000 "oem-firmware"
mtd3: 00010000 00010000 "art"
mtd4: 00500000 00020000 "kernel"
mtd5: 05b00000 00020000 "ubi"
mtd6: 02000000 00020000 "oem-backup"

MAC address overview:
All mac addresses are stored in the art partition.
eth0: 0x0
eth1: 0x6
ath9k: 0xc
ath10k: 0x12
No valid addresses in 0x1002 and 0x5006. All addresses match the OEM
firmware.

Install from oem firmware.
Enable ssh service:
Connect to the router web, click professional, click system-startup,
and add dropbear in the local startup input box. Click
system-administration, delete ssh-key, and replace your ssh pub key.
Restart the router.
1.Upload openwrt firmware to the device
scp openwrt-snapshot-r11365-df60a0852c-ath79-nand-domywifi_dw33d-\
squashfs-factory.bin root@192.168.10.1:/tmp
2.modify uboot-env.
ssh login to the device:
fw_setenv bootcmd 'nboot 0x8050000 0;bootm || bootm 0x9fe80000'
Run the fw_printenv command to check if the settings are correct.
3.Write openwrt firmware.
ssh login to the device:
mtd -r write /tmp/openwrt-snapshot-r11365-df60a0852c-ath79-nand-\
domywifi_dw33d-squashfs-factory.bin /dev/mtd6
The device will restart automatically and the openwrt firmware
installation is complete.

Restore oem firmware.just erase the kernel partition and the ubi
partition.
ssh login to the device:
mtd erase /dev/mtd4
mtd -r erase /dev/mtd5
Reboot the device

Signed-off-by: WeiDong Jia <jwdsccd@gmail.com>
[alter flash instruction in commit message]
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
4 years ago
Daniel Golle ca6885456f ath79: re-add accidentally dropped patch to kernel 5.4
Patch 0061-tty-serial-ar933x-uart-rs485-gpio.patch wasn't included
when adding support for kernel 5.4. Re-add it and refresh patches.

Fixes: 53ab9865c2 ("ath79: add support for kernel 5.4")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
David Bauer 71f3179fc8 spi: ath79: remove spi-master setup and cleanup assignment
This removes the assignment of setup and cleanup functions for the ath79
target. Assigning the setup-method will lead to 'setup_transfer' not
being assigned in spi_bitbang_init.

Also drop the redundant cleanup assignment, as this also happens in
spi_bitbang_init.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Hauke Mehrtens 1e95f9b3ea ath79: Make upstream ag71xx driver work
* Fix some bugs in the driver
* Add missing clock and reset references in dts
* Rename mdio-bus to mdio so the driver find it

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
David Bauer 53ab9865c2 ath79: add support for kernel 5.4
Signed-off-by: David Bauer <mail@david-bauer.net>
[refreshed]
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>

* Sync the patches with the changes done for kernel 4.19
* Use KERNEL_TESTING_PATCHVER
* Refresh the configuration
* Fix multiple compile bugs in the patches
* Only add own ag71xx files for kernel 4.19 and use upstream version for
  5.4.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
Adrian Schmutzler 0b9b0c5d15 ath79: also reduce spi-max-frequency for buffalo_wzr-hp-ag300h
In accordance to ebc090e420 ("ath79: reduce spi-max-frequency to 50 MHz")
this also reduces the spi-max-frequency to 50 MHz for the last remaining
device with higher frequency in ath79. This will save us from having a
single special case that will require adjustment when the spi driver for
this device is changed in the future.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Acked-by: Chuanhong Guo <gch981213@gmail.com>
4 years ago
Adrian Schmutzler ebc090e420 ath79: reduce spi-max-frequency to 50 MHz
The introduction of ebf0d8dade ("ath79: add new ar934x spi driver")
made the SPI memory unusable on devices with very high spi-max-frequency
(104 MHz).

Here's how the actual clock is calculated: (AHB_CLK/((CLOCK_DIVIDER+1)*2))
where AHB_CLK is a fixed clock (e.g. 200MHz on AR9331) and CLOCK_DIVIDER
is the parameter we can set. Highest clock according to this formula is
AHB_CLK/2 (100MHz, but that didn't work in device tests).
The next possible value is AHB_CLK/4 (50MHz). Speeds between 50 MHz and
100 MHz will be rounded down, so using values higher than 50 MHz does
not provide any benefit.

Consequently, this patch reduces spi-max-frequency for all devices with
values higher than 50 MHz to 50 MHz (effectively, this only affects
devices with 104 MHz before this patch).

Tested on GL.inet GL-AR150:
Boot fails with 104 MHz but is successful with both 50 MHz and 80 MHz
(fast-read), where the latter two yield identical read speeds.

Fixes: ebf0d8dade ("ath79: add new ar934x spi driver")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Roger Pueyo Centelles 9de6bc872a ath79: fix spi-max-frequency for wAP G-5HacT2HnD
The introduction of ebf0d8dade (ath79: add new ar934x spi driver)
made the SPI memory unusable. Reducing the spi-max-frequency to
a smaller value makes it work again.

Tested on two MikroTik RouterBOARD wAP G-5HacT2HnD devices.

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
4 years ago
Roger Pueyo Centelles 8f93c05a59 ath79: add support for MikroTik RouterBOARD 922UAGS-5HPacD
This patch ports support for the MikroTik RouterBOARD 922UAGS-5HPacD
with a built-in 802.11ac High-Power radio (31dBm), which was already
available in the ar71xx target.

See https://mikrotik.com/product/RB922UAGS-5HPacD for more info.

Specifications:
- SoC: Qualcomm Atheros QCA9558 (720 MHz)
- RAM: 128 MB
- Storage: 128 MB NAND
- Wireless: external QCA9882 802.11a/ac 2x2:2
- Ethernet: 1x 1000/100/10 Mbps, integrated, via AR8031 PHY, passive PoE-in 24V
- SFP: 1x host
- USB: 1x 2.0 type A
- PCIe: 1x Mini slot (also contains USB 2.0 for 3G/LTE modems)
- SIM slot: 1x mini-SIM

Working:
- Board/system detection
- SPI and NAND storage
- PCIe
- USB type A host
- Wireless
- Ethernet
- LEDs (user, phy0)
- Reset button
- Sysupgrade to/from ar71xx

Not supported:
- RSSI LEDs
- SFP cage

Installation methods:
- Sysupgrade from ar71xx (it is advisable to use the -n option to
wipe any previous settings), or
- Boot the initramfs image via TFTP and then flash the sysupgrade
image using "sysupgrade -n"

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
4 years ago
Roger Pueyo Centelles 6613a7f5cc ath79: add missing reset-gpios for NanoStation Loco M (XW)
When porting support from ar71xx to ath79, the reset-gpios option was
missed. Due to a hardware bug, this would eventually leave the devices
with RX-deaf Ethernet PHY.

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
4 years ago
Koen Vandeputte 7ae2523323 kernel: bump 4.19 to 4.19.106
Refreshed all patches.

Remove upstreamed:
- 950-0786-leds-pca963x-Fix-open-drain-initialization.patch

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Koen Vandeputte b6c9d2bab0 kernel: bump 4.19 to 4.19.105
Refreshed all patches.

Fixes:
- CVE-2013-1798
- CVE-2019-3016

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Koen Vandeputte f4bea1b6a3 kernel: bump 4.14 to 4.14.171
Refreshed all patches.

Fixes:
- CVE-2013-1798

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
David Bauer 55c153538d ath79: fix TP-Link TL-WA901ND v2 PHY stuck in reset
Some newer bootloaders for the TP-Link TL-WA901ND put the ethernet PHY
in reset before loading the kernel, thus the LAN interface is not
working in OpenWrt.

Clear the reset to restore ethernet functionality.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Adrian Schmutzler a967ae9d14 ath79: remove redundant includes in DTS files
Many DTS files contain the same includes again that are already
present in the DTSI files they are derived from.

Remove those redundant includes in the DTS files.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Daniel Golle d1130ad265 ath79: add support for Teltonika RUT955
Specification:

- 550/400/200 MHz (CPU/DDR/AHB)
- 128 MB of RAM (DDR2)
- 16 MB of FLASH (SPI NOR)
- 4x 10/100 Mbps Ethernet, with passive PoE support on LAN1
- 2T2R 2,4 GHz (AR9344)
- built-in 4G/3G module (example: Quectel EC-25EU)
- internal microSD slot (spi-mmc, buggy and disabled for now)
- RS232 on D-Sub9 port (Cypress ACM via USB, /dev/ttyACM0)
- RS422/RS485 (AR934x high speed UART, /dev/ttyATH1)
- analog 0-24V input (MCP3221)
- various digital inputs and outputs incl. a relay
- 11x LED (4 are driven by AR9344, 7 by 74HC595)
- 2x miniSIM slot (can be swapped via GPIO)
- 2x RP-SMA/F (Wi-Fi), 3x SMA/F (2x WWAN, GPS)
- 1x button (reset)
- DC jack for main power input (9-30 V)
- debugging UART available on PCB edge connector

Serial console (/dev/ttyS0) pinout:

- RX: pin1 (square) on top side of the main PCB (AR9344 is on top)
- TX: pin1 (square) on bottom side

Flash instruction:

Vendor firmware is based on OpenWrt CC release. Use the "factory" image
directly in GUI (make sure to uncheck "keep settings") or in U-Boot web
based recovery. To avoid any problems, make sure to first update vendor
firmware to latest version - "factory" image was successfully tested on
device running "RUT9XX_R_00.06.051" firmware and U-Boot "3.0.2".

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Daniel Golle e5e461b621 serial: ar933x_uart: add rs485 support
Add support for RS485 tranceiver with transmit/receive switch hooked
to a RTS GPIO pin.
Use the 'rts-gpios' and 'rs485-rts-active-low' properties as described
in devicetree/bindings/serial/rs485.yaml.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Adrian Schmutzler 2f1cc5c3d5 ath79: add support for TP-Link TL-WA701ND/730RE/801ND/901ND v1
This adds support for the various clones of the TL-WA830RE recently
supported in fb99ac6807 ("ath79: add support for TP-Link TL-WA830RE v1"):

- tplink,tl-wa701nd-v1
- tplink,tl-wa730re-v1
- tplink,tl-wa801nd-v1
- tplink,tl-wa830re-v1 (already supported)
- tplink,tl-wa901nd-v1

Since these devices are 100%-clones in ar71xx, this patch adds all
of them without run-testing (as this has been done for TL-WA830RE v1).

Specifications:
- SOC: Atheros AR7240
- CPU: 400MHz
- Flash: 4 MiB (Spansion S25FL032P)
- RAM: 32 MiB (Zentel A3S56D40FTP-G5)
- WLAN: Atheros AR9280 bgn 2x2
- Ethernet: 1 port (100M)

Flash instructions:
- install from u-boot with tftp (requires serial access)
  > setenv ipaddr a.b.c.d
  > setenv serverip e.f.g.h
  > tftpboot 0x80000000 \
      openwrt-ath79-tiny-tplink_tl-waxxxxx-v1-squashfs-factory.bin
  > erase 0x9f020000 +0x3c0000
  > cp.b 0x80000000 0x9f020000 0x3c0000
  > bootm 0x9f020000
- flash factory image from OEM WebUI
- sysupgrade from ar71xx image

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer 0709943182 ath79: correct Siemens WS-AP3610 blocksize
With the wrong blocksize, the rootfs was not positioned on the boundary
of a block, thus breaking the mtdsplit driver.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Adrian Schmutzler 060b58fd6e ath79: add label MAC address for Ubiquiti Picostation M (XM)
This adds the label MAC address for the Ubiquiti Picostation M (XM).
This was overlooked when adding support in the previous patch.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 6fdaf16dd0 ath79: add support for Ubiquiti Picostation M (XM)
This adds support for the Ubiquiti Picostation M (XM), which has the
same board/LEDs as the Bullet M XM, but different case and antennas.

Specifications:
- AR7241 SoC @ 400 MHz
- 32 MB RAM
- 8 MB SPI flash
- 1x 10/100 Mbps Ethernet, 24 Vdc PoE-in
- External antenna: 5 dBi (USA), 2 dBi (EU)
- POWER/LAN green LEDs
- 4x RSSI LEDs (red, orange, green, green)
- UART (115200 8N1) on PCB

Flashing via WebUI:
  Upload the factory image via the stock firmware web UI.

  Attention: airOS firmware versions >= 5.6 have a new bootloader with
  an incompatible partition table!

  Please downgrade to <= 5.5 _before_ flashing OpenWrt!
  Refer to the device's Wiki page for further information.

Flashing via TFTP:
  Same procedure as other NanoStation M boards.

- Use a pointy tool (e.g., pen cap, paper clip) and keep the reset
  button on the device or on the PoE supply pressed
- Power on the device via PoE (keep reset button pressed)
- Keep pressing until LEDs flash alternatively LED1+LED3 =>
  LED2+LED4 => LED1+LED3, etc.
- Release reset button
- The device starts a TFTP server at 192.168.1.20
- Set a static IP on the computer (e.g., 192.168.1.21/24)
- Upload via tftp the factory image:
  $ tftp 192.168.1.20
  tftp> bin
  tftp> trace
  tftp> put openwrt-ath79-generic-xxxxx-ubnt_picostation-m-squashfs-factory.bin

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Sven Roederer b56bcfe3be ath79: add support for Ubiquiti Nanostation Loco M (XM)
This adds support for the Ubiquiti Nanostation Loco M (XM), which
has the same board/LEDs as the Bullet M XM, but different case and
antennas.

Specifications:
- AR7241 SoC @ 400 MHz
- 32 MB RAM
- 8 MB SPI flash
- 1x 10/100 Mbps Ethernet, 24 Vdc PoE-in
- NS Loco M2: built-in antenna: 8 dBi; AR9287
- NS Loco M5: built-in antenna: 13 dBi; 2T2R 5 GHz radio
- POWER/LAN green LEDs
- 4x RSSI LEDs (red, orange, green, green)
- UART (115200 8N1) on PCB

Flashing via WebUI:
  Upload the factory image via the stock firmware web UI.
  Note that only certain firmware versions accept unsigned
  images. Refer to the device's Wiki page for further information.

Flashing via TFTP:
  Same procedure as other NanoStation M boards.

- Use a pointy tool (e.g., pen cap, paper clip) and keep the reset
  button on the device or on the PoE supply pressed
- Power on the device via PoE (keep reset button pressed)
- Keep pressing until LEDs flash alternatively LED1+LED3 =>
  LED2+LED4 => LED1+LED3, etc.
- Release reset button
- The device starts a TFTP server at 192.168.1.20
- Set a static IP on the computer (e.g., 192.168.1.21/24)
- Upload via tftp the factory image:
  $ tftp 192.168.1.20
  tftp> bin
  tftp> trace
  tftp> put openwrt-ath79-generic-xxxxx-ubnt_nanostation-loco-m-squashfs-factory.bin

Tested on NanoStation Loco M2.

Signed-off-by: Sven Roederer <freifunk@it-solutions.geroedel.de>
Co-developed-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 98fbf2edc0 ath79: move TPLINK_HWID/_HWREV to parent for tplink-safeloader
Several devices with tplink-safeloader contain default values (0x0)
for TPLINK_HWID and TPLINK_HWREV in their device definitions.
Move those to common tplink-safeloader definition so they do not
have to be repeated each time.

While at it, set default value for tplink-v1 and tplink-v2 as well.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 18c95c9d6e ath79: add gpio4 pinmux on TL-WR841N/ND v8, WR842N v2, MR3420 v2
This adds a pinmux to the shared DTSI for TP-Link TL-WR841N/ND v8,
TL-WR842N v2 and TL-MR3420 v2. It is supposed to be the equivalent
of:

/* config gpio4 as normal gpio function */
ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER,AR934X_GPIO_OUT_GPIO);

This allows to enable USB power on these devices.

While at it, move the jtag_disable_pins to &gpio node and remove the
redundant status=okay there.

Tested on TP-Link TL-WR842N v2.

Fixes: FS#2753

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Armin Fuerst <armin@fuerst.priv.at>
4 years ago
Adrian Schmutzler dc145de4be ath79: move mikrotik-caldata.sh to target base-files
Mikrotik devices will be found in both generic and nand subtargets.

The file mikrotik-caldata.sh, currently used in generic, contains
a few lines of code that would need to be duplicated for nand
support. Instead of duplicating it, move it to target base-files,
as size impact is small and the maintenance gain should outweigh it.

This is changed separately to make life easier for the people
currently working on Mikrotik NAND support.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer d2b8ccb1c0 ath79: add support for Siemens WS-AP3610
Hardware
--------
SoC:  Atheros AR7161
RAM:  Samsung K4H511638D-UCCC
      2x 64M DDR1
SPI:  Micron M25P128 (16M)
WiFi: Atheros AR9160 bgn
      Atheros AR9160 an
ETH:  Broadcom BCM5481
LED:  Power (Green/Red)
      ETH (Green / Blue / Yellow)
          (PHY-controlled)
      WiFi 5 (Green / Blue)
      WiFi 2 (Green / Blue)
BTN:  Reset

Serial: Cisco-Style RJ45 - 115200 8N1

Installation
------------

1. Download the OpenWrt initramfs-image. Place it into a TFTP server
   root directory and rename it to 1401A8C0.img. Configure the TFTP
   server to listen at 192.168.1.66/24.

2. Connect the TFTP server to the access point.

3. Connect to the serial console of the access point. Attach power and
   interrupt the boot procedure when prompted (bootdelay is 1 second).

4. Configure the U-Boot environment for booting OpenWrt from Ram and
   flash:

   $ setenv boot_openwrt 'setenv bootargs; bootm 0xbf080000'
   $ setenv ramboot_openwrt 'setenv serverip 192.168.1.66;
     tftpboot; bootm'
   $ saveenv

5. Load OpenWrt into memory:

   $ run ramboot_openwrt

   Wait for the image to boot.

6. Transfer the OpenWrt sysupgrade image to the device. Write the image
   to flash using sysupgrade:

   $ sysupgrade -n /path/to/openwrt-sysuograde.bin

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
David Bauer ae35ff5767 ath79: backport phy reset-controller patches
The Siemens WS-AP3610 asserts reset to the ethernet PHY with the
reset-register. Backport the necessary patches to de-assert reset
when probing the PHY.

These patches can be dropped when using kernel 5.4.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Adrian Schmutzler fbd00bb8d4 ath79: add support for TP-Link TL-WR940N v6
The TL-WR940N v6 is similar to v3/v4, it just has different
LEDs and MAC address assignment.

Specification:
- 750 MHz CPU
- 32 MB of RAM
- 4 MB of FLASH
- 2.4 GHz WiFi
- 4x 10/100 Mbps Ethernet

The use of LEDs is based on ar71xx, so blue LED is used for WAN
and orange LED for diag (boot/failsafe/etc.).

Flash instruction (WebUI):
Download *-factory.bin image and upload it via the firmwary upgrade
function of the stock firmware WebUI.

Flash instruction (TFTP):
1. Set PC to fixed ip address 192.168.0.66
2. Download *-factory.bin image and rename it to
   wr940nv6_tp_recovery.bin
3. Start a tftp server with the image file in its root directory
4. Turn off the router
5. Press and hold Reset button
6. Turn on router with the reset button pressed and wait ~15 seconds
7. Release the reset button and after a short time
the firmware should be transferred from the tftp server
8. Wait ~30 second to complete recovery.

Thanks to Manuel Kock for reviewing and testing this patch.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Manuel Kock <github.web@manu.li>
4 years ago
Adrian Schmutzler 49ff00db34 ath79: enable forceless sysupgrade from ar71xx on fritz300e
This adds the ar71xx board name to the SUPPORTED_DEVICES on ath79,
so forceless sysupgrade on this device becomes possible.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Christian Buschau fb99ac6807 ath79: add support for TP-Link TL-WA830RE v1
This ports support for the TL-WA830RE v1 range extender from ar71xx to
ath79.

Specifications:
- SOC: Atheros AR7240
- CPU: 400MHz
- Flash: 4 MiB (Spansion S25FL032P)
- RAM: 32 MiB (Zentel A3S56D40FTP-G5)
- WLAN: Atheros AR9280 bgn 2x2
- Ethernet: 1 port (100M)

Flash instructions:
- install from u-boot with tftp (requires serial access)
  > setenv ipaddr a.b.c.d
  > setenv serverip e.f.g.h
  > tftpboot 0x80000000 \
      openwrt-ath79-tiny-tplink_tl-wa830re-v1-squashfs-factory.bin
  > erase 0x9f020000 +0x3c0000
  > cp.b 0x80000000 0x9f020000 0x3c0000
  > bootm 0x9f020000
- flash factory image from OEM WebUI
- sysupgrade from ar71xx image

The device seems to be a clone of the following devices not yet
added to ath79:
- tl-wa701nd-v1
- tl-wa730re-v1
- tl-wa801nd-v1
- tl-wa901nd-v1

Signed-off-by: Christian Buschau <christian.buschau@mailbox.org>
[make use of ar7240_tplink.dtsi, add note about clones]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 273e00c4a5 ath79: reorganize DTSI for ar7240 TP-Link devices
The current set of TP-Link devices with ar7240 SoC all share
the same DTSI file. As the latter is very similar to the
definition required for the to-be-supported TP-Link TL-WA devices
with ar7240, this patch splits the definitions into a shared part
for all TP-Link devices (ar7240_tplink.dtsi) and a file containing
the specific setup for the present TL-WR devices
(ar7240_tplink_tl-wr.dtsi), equivalent to the former
ar7240_tplink_tl-wr74xn-v1.dtsi.

While at it, remove unused firmware partition label and rename
pinmux_switch_led_pins.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Chuanhong Guo 9c19c35d1e ath79: restore pin state on probe for ar934x-spi
If bootloader doesn't terminate its last spi operation properly
before starting kernel, our first transfer in kernel becomes a
continuous transfer to that request instead of a new one.
Fix this flaw by restoring IOC register, which restored all pin
state to default.

Fixes: ebf0d8dade ("ath79: add new ar934x spi driver")
Reported-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
4 years ago
Lech Perczak 52a0bd3334 ath79: add LED trigger for TL-WR902AC v1 WAN LED
Inspired by commit c48b571ad7, add an LED trigger for the WAN LED on top of
the TP-Link TL-WR902AC v1. Currently, only the LED on the port itself shows the
link state, while the LED on top of the device stays dark.

The WAN port of the device is a hybrid LAN/WAN one, hence why the LED at the
port was labeled LAN.

Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
4 years ago
Daniel Golle 16031ebaf8 ath79: add support for Atheros AR934x HS UART
AR934x chips also got the 'old' qca,ar9330-uart in addition to the
'new' ns16550a compatible one. Add support for UART1 clock selector as
well as device-tree bindings in ar934x.dtsi to make use of that uart.

Reported-by: Piotr Dymacz <pepe2k@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Daniel Golle b439d3bfb5 ath79: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE
On AR934x this UART is usually not initialized by the bootloader
as it is only used as a secondary serial port while the primary
UART is a newly introduced NS16550-compatible.
In order to make use of the ar933x-uart on AR934x without RTS/CTS
hardware flow control, one needs to set the
UART_CS_{RX,TX}_READY_ORIDE bits as other than on AR933x where this
UART is used as primary/console, the bootloader on AR934x typically
doesn't set those bits.
Setting them explicitely on AR933x does not do any harm, so just set
them unconditionally.

Tested-by: Chuanhong Guo <gch981213@gmail.com
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Chuanhong Guo dd280444b3 ath79: ag71xx: use netif_receive_skb_list on 4.19
This new function make batch processing of network packets possible,
which slightly improves performance.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Tested-by: Rosen Penev <rosenp@gmail.com>
4 years ago
Chuanhong Guo 0046aef672 ath79: use ar934x-spi for ar933x as well
ar933x appears to have the same spi controller as ar934x but it's
not mentioned in datasheet at all. Use new spi driver instead to
gain more flash operating performance.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
4 years ago
Chuanhong Guo ebf0d8dade ath79: add new ar934x spi driver
A new shift mode was introduced since ar934x which has a way better
performance than current bitbang driver and can handle higher spi
clock properly. This commit adds a new driver to make use of this
new feature.
This new driver has chipselect properly configured and we don't need
cs-gpios hack in dts anymore. Remove them.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
4 years ago
Koen Vandeputte 20b5a4ca01 kernel: bump 4.19 to 4.19.101
Refreshed all patches.

Fixes:
- CVE-2019-14896
- CVE-2019-14897

Remove upstreamed:
- 023-0007-crypto-crypto4xx-Fix-wrong-ppc4xx_trng_probe-ppc4xx_.patch
- 950-0202-staging-bcm2835-camera-fix-module-autoloading.patch
- 001-4.22-01-MIPS-BCM63XX-drop-unused-and-broken-DSP-platform-dev.patch

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Michal Cieslakiewicz 6227c8d1bf ath79: WNDR3700 v1/v2: make u-boot env partition writable
Remove read-only flag from U-boot environment partition for Netgear
WNDR3700 v1 and v2 so u-boot-envtools can modify data there.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
August Huber ae61d21ca3 ath79: add support for COMFAST CF-E560AC
This commit adds support for the COMFAST CF-E560AC, an ap143 based
in-wall access point.

Specifications:
 - SoC: Qualcomm Atheros QCA9531
 - RAM: 128 MB DDR2 (Winbond W971GG6SB-25)
 - Storage: 16 MB NOR (Winbond 25Q128JVSO)
 - WAN: 1x 10/100 PoE ethernet (48v)
 - LAN: 4x 10/100 ethernet
 - WLAN1: QCA9531 - 802.11b/g/n - 2x SKY85303-21 FEM
 - WLAN2: QCA9886 - 802.11ac/n/a - 2x SKY85735-11 FEM
 - USB: one external USB2.0 port
 - UART: 3.3v, 2.54mm headers already populated on board
 - LED: 7x external
 - Button: 1x external
 - Boot: U-Boot 1.1.4 (pepe2k/u-boot_mod)

MAC addressing:

- stock
  LAN    *:40 (label)
  WAN    *:41
  5G     *:42
  2.4G   *:4a

- flash (art partition)
  0x0    *:40 (label)
  0x6    *:42
  0x1002 *:41
  0x5006 *:43

This device contains valid MAC addresses in art 0x0, 0x6, 0x1002 and
0x5006, however the vendor firmware only reads from art:0x0 for the LAN
interface and then increments in 02_network. They also jump 8 addresses
for the second wifi interface (2.4 GHz). This behavior has been duplicated
in the DTS and ath10k hotplug to align addresses with the vendor firmware
v2.6.0.

Recovery instructions:

This device contains built-in u-boot tftp recovery.

1. Configure PC with static IP 192.168.1.10/24 and tftp server.
2. Place desired image at /firmware_auto.bin at tftp root.
3. Connect device to PC, and power on.
4. Device will fetch flash from tftp, flash and reboot into new image.

Signed-off-by: August Huber <auh@google.com>
[move jtag_disable_pins, remove unnecessary statuses in DTS, remove
duplicate entry in 11-ath10k-caldata, remove hub_port0 label in DTS]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Michal Cieslakiewicz 3b99d67639 ath79: WNDR3700 v2: add dash before version in device name
Adapt Netgear WNDR3700v2 device identification string to ath79 naming
scheme by changing from 'wndr3700v2' to 'wndr3700-v2' (affects config,
makefile, init scripts and device tree definition).

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
Adrian Schmutzler 4897bf0ca5 ath79: add common definition for Device/tplink-v2
This adds a shared definition Device/tplink-v2 to common-tp-link.mk.
Though currently only one device in ath79 uses it, putting it in
the common file seems more organized. The definitions are based
on the implementation in ramips target, where a lot of devices
is using tplink-v2-* commands already.

The '-V "ver. 2.0"' suffix for Archer D50 v1 can be removed because
it's default in Build/tplink-v2-image anyway.

While at it, add TPLINK_HWREVADD and TPLINK_HVERSION to DEVICE_VARS,
which seems to have been overlooked when adding Archer D50 v1.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 8a6994eb03 ath79: rename tplink-loader-okli to tplink-safeloader-okli
This renames Device/tplink-loader-okli to Device/tplink-safeloader-okli
since the latter more accurately describes the combination of
tplink-safeloader and loader-okli use there. The old version might
be confused with other uses of the okli loader.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 9c37c5ef2f ath79: rename Device/tplink to Device/tplink-v1
As we have tplink-v2-header and tplink-v2-image recipes as well,
this patch renames the Device/tplink definition to Device/tplink-v1,
as it's using the tplink-v1-* commands. This should provide easier
distinction in the future.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Roger Pueyo Centelles 633c4304ad ath79: add support for Ubiquiti NanoStation Loco M (XW)
This commit adds support for the NanoStation Loco M2/M5 XW devices
on the ath79 target (support was long ago available on ar71xx).

Specifications:

 - AR9342 SoC @ 535 MHz
 - 64 MB RAM
 - 8 MB SPI flash
 - 1x 10/100 Mbps Ethernet, 24 Vdc PoE-in
 - AR8032 switch
 - 2T2R 5 GHz radio, 22 dBm
 - 13 dBi built-in antenna
 - POWER/LAN green LEDs
 - 4x RSSI LEDs (red, orange, green, green)
 - UART (115200 8N1) on PCB

Flashing via TFTP:

 - Use a pointy tool (e.g., pen cap, paper clip) and keep the reset
   button on the device or on the PoE supply pressed
 - Power on the device via PoE (keep reset button pressed)
 - Keep pressing until LEDs flash alternatively LED1+LED3 =>
   LED2+LED4 => LED1+LED3, etc.
 - Release reset button
 - The device starts a TFTP server at 192.168.1.20
 - Set a static IP on the computer (e.g., 192.168.1.21/24)
 - Upload via tftp the factory image:
   $ tftp 192.168.1.20
   tftp> bin
   tftp> trace
   tftp> put openwrt-ath79-generic-xxxxx-ubnt_nanostation-loco-m-xw-squashfs-factory.bin

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
4 years ago
Adrian Schmutzler 6c407fb5db ath79: do not set inherited phy-mode/status properties again
There are several cases where phy-mode and status properties are
set again in DTS(I) files although those were set to the same values
in parent DTSI files already. Remove those cases (and thus also stop
their proliferation by copy/paste).

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler c8190713cb ath79: harmonize ethernet-phy naming scheme
A minority of ethernet-phy definitions seems to use numbers in label,
name and reg property relatively random. This patch aligns their
use to have the same numeric value for all of them.

While at it, improve order of properties/add newlines for the ethX
nodes where necessary.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler b4d3110ac1 ath79: add support for GL.iNet 6408/6416 (GL.iNet V1)
This ports the GL.iNet 6408/6416 from ar71xx.

The GL-Connect GL.iNet v1 routers are basically a TP-Link TL-WR710N with
more DRAM/Flash and console/GPIO header in the same small form-factor.

Specifications:
 - SoC: Atheros AR9331
 - CPU: 400 MHz
 - Flash: 8/16 MiB
 - RAM: 64 MiB
 - WiFi: 2.4 GHz b/g/n (SoC)
 - Ethernet: 2x 100M ports (LAN/WAN)
 - USB: 1x 2.0

The difference between 6408 and 6416 is just the flash size. It looks like
only the 16 MiB version has been advertised, while the 6408 is a modified
version. There are also 1-port versions sold by third parties.

Installation:
Install the sysupgrade image via stock firmware GUI or upload it via uboot
(web-based). The device will be available at 192.168.1.1.

Attention: In ar71xx, the same board name is used for both flash versions.
So, please make sure you flash the correct ath79 image when upgrading.

This has been device-tested on a GL.iNet 6416.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Koen Vandeputte 40842167d2 kernel: bump 4.19 to 4.19.98
Refreshed all patches.

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Koen Vandeputte 76254cb75e kernel: bump 4.14 to 4.14.167
Refreshed all patches.

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Adrian Schmutzler 07ce940b77 ath79: fix SUPPORTED_DEVICES not matching ar71xx board names
Based on a script for comparison, this fixes (hopefully) all errors
in SUPPORTED_DEVICES for ar71xx->ath79 upgrade.

Devices where old string is removed as the device does not exist
in ar71xx:
- dlink_dir-859-a1
- tplink_archer-a7-v5
- tplink_cpe510-v3

Devices where string is changed because it did not match the board
name in ar71xx:
- tplink_tl-mr3220-v1
- tplink_tl-mr3420-v1
- tplink_tl-wr2543-v1
- tplink_tl-wr741nd-v4
- tplink_tl-wr841-v7
- ubnt_unifiac-mesh
- ubnt_unifiac-mesh-pro
- ubnt_unifiac-pro

For this device, the correct string could not be found, but we could
not determine the correct one. Thus, the string is removed for now:
- tplink_tl-wr740n-v4

The script for checking this is quite simple (note that newer
entries, i.e. ath79->ath79 upgrade, are displayed as missing):

  newpath=target/linux/ath79/image/
  oldpath=target/linux/ar71xx/base-files/lib/ar71xx.sh

  for s in $(grep -roh "SUPPORTED_DEVICES.*" $newpath | sed 's/SUPPORTED_DEVICES *.= *//'); do
    found="Missing"
    grep -q -r "\"$s\"" $oldpath && found="Found"
    echo "$s: $found."
  done

The errors might be filtered by appending 'grep "Missing"' to the script.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 071a637276 ath79: move lzma-loader to the end of available RAM
In certain cases, the uncompressed initramfs image will overwrite
the lzma-loader, which is currently only 10 MB away from kernel image
start. To prevent this, change LZMA_TEXT_START to 24 MB, so loader
and compressed image have 8 MB at the end of RAM and uncompressed
image has 24 MB available.

This is only enabled for ath79 at the moment, as there we can be sure
that all devices have 32+ MB RAM and TARGET_INITRAMFS_COMPRESSION_LZMA
is not enabled there.

Despite, since lzma-loader is currently build specifically for ath79
anyway, there is no need to re-specify LOADADDR and LZMA_TEXT_START
in image/Makefile, so the values are set directly in
image/lzma-loader/Makefile and the overwrite in image/Makefile is
removed.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Roger Pueyo Centelles 6aaa5ce2c5 ath79: add support for MikroTik RouterBOARD wAP G-5HacT2HnD
This commit adds support for the MikroTik RouterBOARD wAP G-5HacT2HnD
(wAP AC), a small weatherproof dual band, dual-radio 802.11ac
wireless AP with integrated omnidirectional anntennae and one
10/100/1000 Mbps Ethernet port.

See https://mikrotik.com/product/RBwAPG-5HacT2HnD for more info.

Specifications:
 - SoC: Qualcomm Atheros QCA9556
 - RAM: 64 MB
 - Storage: 16 MB NOR
 - Wireless:
   · Atheros AR9550 (SoC) 802.11b/g/n 2x2:2, 2 dBi antennae
   · Qualcomm QCA9880 802.11a/n/ac 3x3:3, 2 dBi antennae
 - Ethernet: Atheros AG71xx (SoC, AR8033), 1x 1000/100/10 port,
   passive PoE in

Working:
 - Board/system detection
 - Sysupgrade
 - Serial console
 - Ethernet
 - 2.4 GHz radio
 - 5 GHz radio and LED
 - Reset button

Not working/Unsupported:
 - 2.4 GHz LED
 - AP/CAP LED
 - ZT2046Q SPI temperature and voltage sensor

This adds the basic features for supporting MikroTik devices:
 - a common recipe for mikrotik images in common-mikrotik.mk
 - support for minor (MikroTik NOR) split firmware (only for
   generic subtarget so far)

Acknowledgments: Robert Marko <robimarko@gmail.com>
                 Andrew Cameron <apcameron@softhome.net>
                 Koen Vandeputte <koen.vandeputte@ncentric.com>
                 Chuanhong Guo <gch981213@gmail.com>

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
Co-developed-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
David Bauer 26c2556775 ath79: allow to override AR8033 SGMII aneg status
In order to make the QCA955x SGMII workaround work, the unsuccessful
SGMII autonegotiation on the AR8033 should not block the PHY
state-machine.

Otherwise, the ag71xx driver never becomes aware of the copper-side
link-establishment and the workaround is never executed.

Signed-off-by: David Bauer <mail@david-bauer.net>
[remove one trailing whitespace per file]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer 0d416a8d3b ath79: add QCA955x SGMII link loss workaround
This commit adds a workaround for the loss of the SGMII link observed on
the QCA955x generation of SoCs. The workaround originates part from the
U-Boot source code, part from the implementation from AVM found in the
GPL tarball for the AVM FRITZ!WLAN Repeater 450E.

The bug results in a stuck SGMII link between the PHY device and the SoC
side. This has only been observed with the Atheros AR8033 PHY and most
likely all devices using such combination are affected.

It is worked around by reading a hidden SGMII status register and
issuing a SGMII PHY reset until the link becomes useable again.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Adrian Schmutzler a66a1eb9c5 ath79: add support for TP-Link TL-WA850RE v2
TP-Link TL-WA850RE v2 is a wall-plug N300 Wi-Fi range extender,
based on Qualcomm/Atheros QCA9533 v2.

Short specification:

- 550/391/195 MHz (CPU/DDR/AHB)
- 1x 10/100 Mbps Ethernet
- 32 MB of RAM (DDR1)
- 4 MB of FLASH
- 2T2R 2.4 GHz
- 2x internal antennas (embedded on PCB)
- 9x LED (all can be turned off with GPIO15), 2x button
- UART (J3) header on PCB

Flash instruction: use "factory" image directly in vendor GUI.

Warning: this device does not include any kind of recovery mechanism
in the bootloader and disassembling process is not trivial.

You can access vendor firmware over serial line using:
- login: root
- password: sohoadmin

Stock firmware uses label MAC address for WiFi and same with local
bit set for ethernet. Since this is difficult to reproduce with
the toolset of OpenWrt, we just keep both ethernet and WiFi to
the same address here.

This is the first tiny device with tplink-safeloader in ath79.
Firmware partition is only 3648k and thus even smaller than for
the tplink-4m(lzma) devices.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
David Bauer a8898f1a11 ath79: use upstream properties to disable EEE
The hack-patch which introduced the "at803x-disable-smarteee" for
disabling SmartEEE did in fact not disable SmartEEE but rather disabled
802.3az "standard" EEE.

This can be done by using the upstream properties "eee-broken-100tx" and
"eee-broken-1000t". EEE is then disabled by the PHY subsystem.

Tested on devolo WiFi pro 1200e.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Adrian Schmutzler 6eaea3a8ba ath79: add support for TP-Link TL-WA850RE v1
This ports support for the TL-WA850RE v1 range extender from ar71xx
to ath79.

Specifications:
  Board: AP123 / AR9341 rev. 3
  Flash/RAM: 4/32 MiB
  CPU: 535 MHz
  WiFi: 2.4 GHz b/g/n
  Ethernet: 1 port (100M)

Flashing instructions:
Upload the factory image via the vendor firmware upgrade option.

Recovery:
Note that this device does not provide TFTP via ethernet like many
other TP-Link devices do. You will have to open the case if you
require recovery beyond failsafe.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 111a7a3d01 ath79: remove usused TPLINK_BOARD_NAME variable for DEVICE_VARS
TPLINK_BOARD_NAME has been renamed to TPLINK_BOARD_ID a long time
ago (7d6c63d87542: "build: rename TPLINK_BOARD_NAME to
TPLINK_BOARD_ID" for ar71xx), and before introducing ath79 target
at all.

TPLINK_BOARD_NAME seems to have been introduced into ath79 target
only by mistake. It has never been used. Remove it.

Fixes: 53c474abbd ("ath79: add new OF only target for QCA MIPS silicon")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Enrico Mioso b99b60b2f1 ath79: add support for TP-Link TL-MR6400
This device is an LTE router supported in ar71xx so far.
As per original commit, hardware specifications (v1.0 EU):
- SoC: QCA9531
- Flash: Winbond W25Q64FV (8MiB)
- RAM: EtronTech EM6AB160TSE-5G (64MiB)
- Wireless: SoC platform only (2.4GHz b/g/n, 2x internal antenna)
- Ethernet: 2NIC (3x100M + 1x100M)
- WWAN: TP-LINK LTE MODULE (2x external detachable antenna)
- Power: DC 12V 1A

Flashing instructions:
You can flash via tftp recovery (serve factory image as /mr6400_tp_recovery.bin
on 192.168.0.66/24, connect to any ethernet port and power on device while
holding the reset button). Flashing via OEM web interface does not work.

Known issues:
- LTE module does not always come up during boot (showing USB enumeration errors). Similar behavior has been reported at least from one user for ar71xx, too. Turning USB off and on again will serve as a workaround.
- eth0 (LAN) always shows carrier as 1 even if no cable is plugged in (this works "correctly" on ar71xx)

Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
[several adjustments]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Filip Moc <lede@moc6.cz>
4 years ago
Michal Cieslakiewicz 0d28e5d644 ath79: fix SUPPORTED_DEVICES for WNDR4300 and WNDR3700v4
Kernel partition increase to 4 MiBs for Netgear WNDR3700v4 and WNDR4300
routers breaks sysupgrade image compatibility with ar71xx builds.
Therefore, SUPPORTED_DEVICES variable has to be removed for both devices
from target makefile.

Reported-by: DENG Qingfang <dengqf6@mail2.sysu.edu.cn>
Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
Koen Vandeputte 692b91f56b kernel: bump 4.19 to 4.19.95
Refreshed all patches.

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Koen Vandeputte b5480de4d1 kernel: bump 4.14 to 4.14.164
Refreshed all patches.

Compile-tested on: cns3xxx
Runtime-tested on: cns3xxx

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Adrian Schmutzler 8d78354d24 ath79: add led_ prefix for Phicomm K2T LED label
Using the led_ prefix for the node label is now common in ath79,
so also apply it here.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 9573176300 ath79: use rssihigh LED instead of WAN LED for status indication
Using the LED of network interfaces for status (boot/failsafe/...)
indication is somewhat misleading, as the blinking might be
mistaken for network activity. This uses rssi LEDs instead, which
do not blink normally and thus are less ambiguous.

The rssihigh LED has also been used consistently for the TP-Link CPE
devices.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Johann Neuhauser bda6b6144d ath79: ar934x: use reset for usb-phy-analog
This was already available on ar71xx, but is missing on ath79.
This solves the slow usb speed on TP-Link WDR3600/WDR4300 and similar,
as reported in Flyspray [0], OpenWRT Forum [1] and GitHub PR [2].

[0] https://bugs.openwrt.org/index.php?do=details&task_id=2567
[1] https://forum.openwrt.org/t/usb-wdr4300-low-speed-on-external-storage/46794
[2] https://github.com/openwrt/openwrt/pull/964

Signed-off-by: Johann Neuhauser <johann@it-neuhauser.de>
4 years ago
Johann Neuhauser 6cca6fffa0 ath79: phy-ar7200-usb: adapt old behavior of arch/mips/ath79/dev-usb.c
Do not put usb-phy into reset if clearing the usb-phy reset or
setting the suspend_override has failed.

Reorder (de)asserts like in arch/mips/ath79/dev-usb.c.

Add an optional reset_control "usb-phy-analog", which is needed for
ar934x SoCs like in the old mach-driver arch/mips/ath79/dev-usb.c.

Signed-off-by: Johann Neuhauser <johann@it-neuhauser.de>
4 years ago
Adrian Schmutzler bbab32b2e3 ath79: use caldata partition label consistently
Change the caldata partition DTS node label to be consistent with
the label property for some Netgear WNDR devices.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Michal Cieslakiewicz a736f39432 ath79: add support for Netgear WNDR4500 v3
This patch introduces support for Netgear WNDR4500v3. Router
is very similar to WNDR4300v2 and is based on the same PCB.

Information gathered from various Internet sources (including
https://patchwork.ozlabs.org/patch/809227/) shows following
differences to WNDR4300v2:

 * two USB 2.0 ports with separate LEDs
 * USB LEDs soldered to secondary pads
 * WPS and RFKILL buttons soldered to secondary pads
 * described as N900 device with 3x3:3 MIMO for 2.4GHz radio
 * power supply requirement is DC 12V 2.5A
 * vendor HW ID suffix differs in one digit
 * bigger chassis

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
Michal Cieslakiewicz 37a36a588a ath79: add support for Netgear WNDR4300 v2
This patch introduces support for Netgear WNDR4300v2.

Specification
=============
  * Description: Netgear WNDR4300 v2
  * Loader: U-boot
  * SOC: Qualcomm Atheros QCA9563 (775 MHz)
  * RAM: 128 MiB
  * Flash: 2 MiB SPI-NOR + 128 MiB SPI-NAND
	- NOR: U-boot binary: 256 KiB
	- NOR: U-boot environment: 64 KiB
	- NOR: ART Backup: 64 KiB
 	- NOR: Config: 64 KiB
	- NOR: Traffic Meter: 64 KiB
	- NOR: POT: 64 KiB
	- NOR: Reserved: 1408 KiB
	- NOR: ART: 64 KiB
	- NAND: Firmware: 25600 KiB (see notes for OpenWrt)
	- NAND: Language: 2048 KiB
	- NAND: mtdoops Crash Dump: 128 KiB
	- NAND: Reserved: 103296 KiB
  * Ethernet: 5 x 10/100/1000 (4 x LAN, 1 x WAN) (AR8337)
  * Wireless:
	- 2.4 GHz b/g/n (internal)
	- 5 GHz a/n (AR9580)
  * USB: yes, 1 x USB 2.0
  * Buttons:
	- Reset
	- WiFi (rfkill)
	- WPS
  * LEDs:
	- Power (amber/green)
	- WAN (amber/green)
	- WLAN 2G (green)
	- WLAN 5G (blue)
	- 4 x LAN (amber/green)
	- USB (green)
	- WPS (green)
  * UART: 4-pin connector JP1, 3.3V (Vcc, TX, RX, GND), 115200 8N1
  * Power supply: DC 12V 1.5A
  * MAC addresses: LAN=WLAN2G on case label, WAN +1, WLAN5G +2

Important Notes
===============
0. NOR Flash (2 MiB) is not touched by OpenWrt installation.
1. NAND Flash (128 MiB) layout under OpenWrt is changed as follows:
   all space is split between 4 MiB kernel and 124 MiB UBI areas;
   vendor partitions (language and mtdoops) are removed; kernel space
   size can be further expanded if needed; maximum image size is set
   to 25600k for compatibility reasons and can also be increased.
2. CPU clock is 775 MHz, not 750 MHz.
3. 5 GHz wireless radio chip is Atheros AR9580-AR1A with bogus PCI
   device ID 0xabcd. For ath9k driver to load successfully, this is
   overriden in DTS with correct value for this chip, 0x0033.
4. RFKILL button is wired to AR9580 pin 9 which is normally disabled
   by chip definition in ath9k code (0x0000F4FF gpio mask). Therefore
   'qca,gpio-mask=<0xf6ff>' hack must be used for button to work
   properly.
5. USB port is always on, no GPIO for 5V power control has been
   identified.

Installation
============
  * TFTP recovery
  * TFTP via U-boot prompt
  * sysupgrade
  * Web interface

Test build configuration
========================
CONFIG_TARGET_ath79=y
CONFIG_TARGET_ath79_nand=y
CONFIG_TARGET_ath79_nand_DEVICE_netgear_wndr4300-v2=y
CONFIG_ALL_KMODS=y
CONFIG_DEVEL=y
CONFIG_CCACHE=y
CONFIG_COLLECT_KERNEL_DEBUG=y
CONFIG_IMAGEOPT=y

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
Michal Cieslakiewicz 4e6af8b9ef ath79: WNDR4300: increase kernel partition to 4M
Increase kernel partition from 2 MiB to 4 MiB for Netgear WNDR routers
with NAND flash. Change affects following devices:
 * Netgear WNDR3700 v4
 * Netgear WNDR4300

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
4 years ago
David Bauer c9ac7b1729 ath79: add support for D-Link DIR-505
This commit adds support for the D-Link DIR-505, previously supported in
ar71xx.

Hardware
--------
SoC:   Atheros AR9330
FLASH: 8M SPI-NOR
RAM:   64M
WIFI:  1T1R 1SS Atheros AR9330
LED:   Power green, Status red
BTN:   WPS, Reset

Installation
------------
Currently, installation is only possible by sysupgrading from an earlier
OpenWrt version, U-Boot TFTP or a modded U-Boot. I do not have the
original bootloader from D-Link on my device anymore, so i cannot test
the factory image.

Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Jeff Kletsky e96bfaedf3 ath79: GL-AR750S (NOR/NAND): limit factory.img kernel size to 2 MB
The present U-Boot for GL-AR750S has a limit of 2 MB for kernel size.
While sysupgrade can manage kernels up to the present limit of 4 MB,
directly flashing a factory.img with a kernel size greater than 2 MB
through U-Boot will result in an unbootable device.

This commit uses the newly-introduced check-kernel-size build
operation to prevent the output of factory.img when the kernel
exceeds 2 MB in size, yet permits output of sysupgrade.img
as long as the kernel is within KERNEL_SIZE := 4096k

Cc: Chuanhong Guo <gch981213@gmail.com>

Signed-off-by: Jeff Kletsky <git-commits@allycomm.com>
4 years ago
Tomasz Maciej Nowak 2248df303d ath79: wlr-7100: use ath10k-ct smallbuffers package variant
The memory hacks got removed from ath10k with 1e27bef ("mac80211: remove
ath10k_pci memory hacks"). As this device has low amount of RAM, switch
to ath-10k-ct small buffers variant, to avoid the OOM Reaper.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
4 years ago
Tobias Schramm 66eb88edb6 ath79: add support for Ubiquiti EdgeSwitch/ToughSwitch 5XP
The Ubiquiti ToughSwitch 5XP is a 5-port PoE Gigabit switch with a single
Fast-Ethernet management port. It supports both 24V passive PoE out on all
five ports.

Flash:    8 MB
RAM:      64 MB
SoC:      AR7242
Switch:   ar8327
USB:      1x USB 2.0
Ethernet: 5x GbE, 1x FE

Installation of the firmware is possible either via serial + tftpboot or
the factory firmware update function via webinterface.

By default the single Fast-Ethernet port labeled "MGMT" is configured
as the WAN port. Thus access to the device is only possible via the
five switch ports.

Serial: 3v3 115200 8n1

The serial header is located in the lower left corner of the switches PCB:

```
|
|
|
| o
| o RX
| o TX
| o GND
|
|
++  +-++-+  ++  ++  +
+--+ ++ +--++--++--+
```

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
[remove ubnt,sw compatible - fix spelling - wrap commit message -
remove superfluous phy-mode property]
Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Tobias Schramm 2e05d6185a ath79: add generic dtsi for Ubiquiti SW boards
Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
[remove ubnt,sw compatible]
Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Tobias Schramm b6946542f8 ath79: add support for Ubiquiti ToughSwitch/EdgeSwitch 8XP
Flash:    8 MB
RAM:      64 MB
SoC:      AR7242
Switch:   bcm53128
USB:      1x USB 2.0
Ethernet: 8x GbE, 1x FE

The Ubiquiti ToughSwitch 8XP is a 8-port PoE Gigabit switch with a single
Fast-Ethernet management port. It supports both 24V passive PoE and 48V
802.11af/at PoE out on all eight ports.

By default the single Fast-Ethernet port labeled "MGMT" is configured as the
WAN port. Thus access to the device is only possible via the eight switch
ports.

Installation of the firware is possible either via serial + tftpboot or
the factory firmware update function via webinterface.

Serial: 3v3 115200 8n1

The serial header is located in the lower left corner of the switches PCB:

|
|
|
| o
| o RX
| o TX
| o GND
|
|
++  +-++-+  ++  ++  +
 +--+ ++ +--++--++--+

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
[fix whitespace issue]
Signed-off-by: David Bauer <mail@david-bauer.net>
4 years ago
Tobias Schramm 7d97fdf5ef ath79: add support for Ubiquiti SW devices
SW devices are Ubiquit ToughSwitch and EdgeSwitch series devices.
Hardware-wise they are very similar to the XM device series.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
4 years ago
Chuanhong Guo b97247c2e9 ath79: gl-ar750s: reduce kernel size to 2M in image Makefile
u-boot splits nand factory firmware at 2M offset, flash the first
part as kernel into spi nor and the other part as ubi into nand
flash. With previous commit increasing kernel size to 4M, generated
factory firmware is broken because ubi is at 4M offset.

This commit reduces kernel size definition to 2M in image Makefile,
producing proper factory image. Partition size in dts is kept
unchanged so that sysupgrade to a firmware with 2M+ kernel still
works.

Fixes: b496a2294c ("ath79: GL-AR750S: provide NAND support; increase kernel to 4 MB")
Reported-by: Jeff Kletsky <git-commits@allycomm.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
4 years ago
Adrian Schmutzler df41cc7445 ath79: remove unused Build/mktplinkfw-combined
Build/mktplinkfw-combined is not used anywhere, so remove it.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Adrian Schmutzler 9b0e8d0aa4 treewide: move mktplinkfw to tplink-v1-image in image-commands.mk
This move the slightly different target-specific implementations of
mktplinkfw from the targets to include/image-commands.mk and renames
it to tplink-v1-image. Having a common version will increase
consistency between implementation and will complete the
tplink build command already present in the new location.

Due to the slight differences of the original implementations, this
also does some adjustments to the device build commands/variables.

This also moves rootfs_align as this is required as dependency.

Tested on:
- TL-WDR4300 v1 (ath79, factory)
- TL-WDR4900 v1 (mpc85xx, sysupgrade)
- RE210 v1 (ramips, see Tested-by)

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Christoph Krapp <achterin@googlemail.com>
4 years ago
Christoph Krapp 7bef62de79 ath79: use ath10k-ct-smallbuffers for TP-Link RE355/RE450 v1
Both devices are available in 64M and 128M RAM configurations but there
is no visial indication which configuration one might get.
So just to be sure we properly support both configurations switch to
kmod-atk10k-ct-smallbuffers.

Signed-off-by: Christoph Krapp <achterin@googlemail.com>
4 years ago
Bjørn Mork 0bd322861c ath79: drop obsolete ehci hacks
There's nothing enabling these hacks in ath79, so drop the redundant
patches.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
4 years ago
Tokunori Ikegami 946eba9a92 ath79: Remove mtd cfi_cmdset_0002 status check patches
Currently the patch only changes break to use goto statement instead.
But not necessary acutually since the ret value checked after the for loop.
So it is okay for the break case before changed by the patch also.

This patch only reverts the following commit partially.
  https://github.com/openwrt/openwrt/commit/ddc11c3932c7b7b7df7d5fbd48f207e7
    Note: The changes are mainly applied into the linux kernel upstream.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Cc: Koen Vandeputte <koen.vandeputte@ncentric.com>
4 years ago
Hauke Mehrtens b6cdc042af kernel: bump 4.19 to 4.19.93
Refreshed all patches.

The patch hack-4.19/550-loop-better-discard-for-block-devices.patch was
replaced with an new version of the patch from:
https://lore.kernel.org/patchwork/patch/1153625/
https://lore.kernel.org/patchwork/patch/1153626/

Compile-tested on: ipq40xx, lantiq
Runtime-tested on: ipq40xx, lantiq

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
Hauke Mehrtens 1bb90a28e4 kernel: bump 4.14 to 4.14.162
Refreshed all patches.

Compile-tested on: ramips
Runtime-tested on: ramips

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
Christian Mauderer 5e5e92b7c3 ath79: generate firmware image for aircube-isp
This adds a "factory" image for the aircube-isp devices. Note that the
firmware can't be uploaded without prior special preparation. For the
most recent instructions on how to do that, visit the OpenWRT wiki page
of the Ubiquiti airCube ISP for details:

https://openwrt.org/toh/ubiquiti/ubiquiti_aircube_isp

Current procedure:

With the original firmware 2.5.0 it is possible to upload and execute a
script via the configuration. To do that download and unpack the
original configuration, adapt uhttpd config to execute another lua
handler (placed in the config directory) and pack and upload it again.

The lua handler can call a script that mounts an overlayfs and modifies
the "fwupdate.real" binary so that an unsigned image is accepted. The
overlayfs is necessary because a security system (called tomoyo) doesn't
allow binaries in other locations than /sbin/fwupdate.real (and maybe
some more) to access the flash when executed via network.

A big thanks to Torvald Menningen (Snap) from the OpenWRT forum for
finding out how to patch the binary so that it accepts an unsigned
image.

The current step-by-step procedure is:

- Use a version 2.5.0 of the original firmware. This is important
  because a binary file will be modified.
- Download a configuration.
- Unpack it (it's just a tar gz file without an ending).
- Add the following to uhttpd:

``````
config 'uhttpd' 'other'
	list listen_http    0.0.0.0:8080
	list listen_http    [::]:8080
	option 'home'       '/tmp/persistent/config/patch/www'
	option lua_prefix   '/lua'
	option lua_handler  '/tmp/persistent/config/patch/handler.lua'
``````

- Create a `patch` subfolder.
- Create a `patch/www` subfolder.
- Create a `patch/handler.lua` with the following content:

``````
function handle_request(env)
    uhttpd.send("Status: 200 OK\r\n")
    uhttpd.send("Content-Type: text/plain\r\n\r\n")

    local command = "/bin/sh /tmp/persistent/config/patch/patch.sh 2>&1"

    local proc = assert(io.popen(command))
    for line in proc:lines() do
        uhttpd.send(line.."\r\n")
    end
    proc:close()
end
``````

- Create a `patch/patch.sh` with the following content:

``````
#!/bin/sh -x

set -e
set -u
set -x

UBNTBOX_PATCHED="/tmp/fwupdate.real"
MD5FILE="/tmp/patchmd5"

cat <<EOF > ${MD5FILE}
c33235322da5baca5a7b237c09bc8df1  /sbin/fwupdate.real
EOF

# check md5 of files that will be patched
if ! md5sum -c ${MD5FILE}
then
        echo "******** Error when checking files. Refuse to do anything. ********"
        exit 0
fi

# prepare some overlay functionality
LOWERDIR="/tmp/lower_root"
mkdir -p ${LOWERDIR}
mount -t squashfs -oro /dev/mtdblock3 ${LOWERDIR}
overlay_some_path()
{
        PATH_TO_OVERLAY=$1
        ALIAS=$2
        UPPERDIR="/tmp/over_${ALIAS}"
        WORKDIR="/tmp/over_${ALIAS}_work"

        mkdir -p ${UPPERDIR}
        mkdir -p ${WORKDIR}

        mount -t overlay -o lowerdir=${LOWERDIR}${PATH_TO_OVERLAY},upperdir=${UPPERDIR},workdir=${WORKDIR} overlay ${PATH_TO_OVERLAY}
}

# patch the ubntbox binary.
overlay_some_path "/sbin" "sbin"
echo -en '\x10' | dd of=/sbin/fwupdate.real conv=notrunc bs=1 count=1 seek=24598

echo "******** Done ********"
``````

- Repack the configuration.
- Upload it via the normal web interface.
- Wait about a minute. The webserver should restart.
- Now there is a second web server at port 8080 which can call the lua
  script. Visit the page with a web browser. Link is for example
  http://192.168.1.1:8080/lua
- You should see the output of the script with a "*** Done ***" at the
  end. Note that the patches are not permanent. If you restart the
  router you have to re-visit the link (but not re-upload the config).
- Now you can upload an unsigned binary via the normal web interface.

Signed-off-by: Christian Mauderer <oss@c-mauderer.de>
4 years ago
Paul Fertser 3e51cb7820 ath79: tp-link: use ath10k-ct-smallbuffers for 64 MiB devices
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
4 years ago
Paul Fertser db992e7b53 ath79: use ath10k-ct-smallbuffers for 64 MiB devices
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
4 years ago
Hauke Mehrtens b0b1d4aaf0 ath79: Do not build dlink_dir-615-e4 by default
The factory image for the dlink_dir-615-e4 is getting too big which makes
the full ath79 tiny build fail, deactivate it by default.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
4 years ago
Sungbo Eo a4260eaab7 ath79: fix MAC address setup for TP-Link TL-WDR3600/TL-WDR4300
The current ethernet MAC address setup of TL-WDR4300 board is different
from the setup of stock firmware:

OpenWrt: lan = label_mac -2, wan = label_mac -2
  stock: lan = label_mac,    wan = label_mac +1

The full address assignment is as follows:
LAN  label
WAN  label + 1
5G   label
2G   label - 1

This patch changes all devices using TL-WDR4300 board:
TL-WDR3600 v1 (checked on device)
TL-WDR4300 v1 (checked on device)
TL-WDR4300 v1 (IL)

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
[rephrase/extend commit title/message]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago