Commit Graph

2327 Commits (6ba58b7b020c4b793e6fb7a43c8adef070579d8d)

Author SHA1 Message Date
John Crispin 7197744cd6 Revert "ramips: Move PCI driver to files directory"
This reverts commit a098a78a33.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 69929dac89 Revert "ramips: Remove redundant owner assignment"
This reverts commit 2ad4daf579.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 64878a5616 Revert "ramips: improve interrupt mapping"
This reverts commit 5f7396ebef.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 7577f32c8a Revert "ramips: remove conditional compilation."
This reverts commit 1f78625714.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin b8569427eb Revert "ramips: remove unnecessary resource details."
This reverts commit edea934799.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 784943e3f2 Revert "ramips: pci: sync with staging driver"
This reverts commit e07baec9fa.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 8a570921b5 Revert "ramips: Add back some non-mt7621 code that staging removed"
This reverts commit 048e41f649.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 1d3c286381 Revert "ramips: Fix WiFi after 5f7396ebef09b224edf08b0bda113613a42f0928"
This reverts commit 02f815d190.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Rosen Penev 9685f39787 ramips: Use generic board detect for GnuBee devices
This is a port of an old commit from mkresin's tree:

09260cdf3e9332978c2a474a58e93a6f2b55f4a8

This has the potential to break sysupgrade but it should be fine as
there is no stable release of LEDE or OpenWrt that support these devices.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Rosen Penev 976c27f2dd ramips: Fix a few other GnuBee DTS differences
I was carrying a local commit that added the sdhci stuff and missed it
as a result.

Also fix the rgmii3 thing in the PC2 DTS file as that's bogus and causes
a dmesg warning that it's bogus.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Rosen Penev 02f815d190 ramips: Fix WiFi after 5f7396ebef
That commit exposed a bug in the DTS files used by mt7621 where the wrong
reg value for pcie1 (and potentially pcie2) was being used. This was
causing WiFi failures for interfaces in pcie1.

eg. 2.4GHz working but not 5GHz.

As all of these dts entries are already specified in mt7621.dtsi, remove
them.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Stijn Tintel 64b53247c4 kernel: bump 4.14 to 4.14.44
Refresh patches.

Remove upstreamed patch:
generic/pending/181-net-usb-add-lte-modem-wistron-neweb-d18q1.patch
Update patches that no longer applies:
generic/hack/901-debloat_sock_diag.patch

Compile-tested on: x86/64.
Runtime-tested on: x86/64.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
6 years ago
Rosen Penev 8c818fa1f0 ramips: Fix up GnuBee PC1 DTS file a little
There's nothing connected to i2c on this board, so remove it.

Also edited the gpio group to match the PC2 as they're the same.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Rosen Penev 048e41f649 ramips: Add back some non-mt7621 code that staging removed
Staging is meant only for mt7621 but for OpenWrt more is needed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Matthias Badaire 52809db544 ramips: fix to mt7620a and add support for i2c on WD03
There was an error on initial commit, the proper soc is mt7620n (which is
more limited than mt7620a). Moreover, there is a battery management
controller connected to the i2c port of the mt7620n. I have a small piece
of i2c code to get battery level coming.

Signed-off-by: Matthias Badaire <mbadaire@gmail.com>
6 years ago
Koen Vandeputte faf0a460c4 kernel: bump 4.14 to 4.14.42
Refreshed all patches

Compile-tested on: cns3xxx, imx6, x86_64
Runtime-tested on: cns3xxx, imx6, x86_64

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
6 years ago
David Bauer ce91c85e01 ramips: change wifi led trigger for Archer C50v3
This commit alters the TP-Link Archer C50v3 LED settings to use the phy
trigger instead of the netdev one. This way the WiFi status is displayed
even if the wifi interface name is altered.

Signed-off-by: David Bauer <mail@david-bauer.net>
6 years ago
David Bauer 35d00d9a41 ramips: fix Archer C50v3 LED mapping
This commit fixes the wrong LED mapping of the Archer C50 v3.
Commit was tested with an EU device.

Signed-off-by: David Bauer <mail@david-bauer.net>
6 years ago
Sergey Ryazanov 67a3cdcbb0 kernel: enable THIN_ARCHIVES by default
THIN_ARCHIVES option is enabled by default in the kernel configuration
and no one target config disables it. So enable it by default and remove
this symbol from target specific configs to keep them light.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
6 years ago
Sergey Ryazanov bdc2b58c4b kernel: enable FUTEX_PI by default
New FUTEX_PI configuration symbol enabled if FUTEX and RT_MUTEX symbols
are enabled. Both of these symbols are enabled by default in the
generic config, so enable FUTEX_PI by default too to keep platform
specific configs minimal.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
6 years ago
Sergey Ryazanov a08b0d0c31 kernel: enable EXPORTFS by default
OVERLAY_FS config symbol selects EXPORTFS since 4.12 kernel, we have
OVERLAY_FS enabled by default, so enable EXPORTFS in the generic config
of 4.14 and remove this option from platform specific configs.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
6 years ago
Sergey Ryazanov 978543a246 kernel: disable DRM_LIB_RANDOM by default
DRM_LIB_RANDOM config symbol selected only by DRM_DEBUG_MM_SELFTEST
which is disable by default, so disable DRM_LIB_RANDOM by default too.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
6 years ago
Sergey Ryazanov ead26e9db6 kernel: disable DMA_{NOOP|VIRT}_OPS by default
These options do not used by any supported arch, so disable them by
default to make arch configs a bit more clean.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
6 years ago
Sergey Ryazanov f928c338ad kernel: disable ARCH_WANTS_THP_SWAP by default
Only one arch (x86_64) enables this option. So disable
ARCH_WANTS_THP_SWAP by default and remove referencies to it from all
configs (except x86_64) to make them clean.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
6 years ago
YuheiOKAWA d91953cb53 ramips: add support for YUKAI Engineering Inc. BOCCO
BOCCO is a communication robot provided by YUKAI Engineering Inc.

SoC: MT7620A
MEM: 256MB
Flash: 8MB
NAND: 512MB (non support)
Include Sound DAC and AMP.
No Wired Ethernet.

Signed-off-by: YuheiOKAWA <tochiro.srchack@gmail.com>
6 years ago
Koen Vandeputte e2aa0c3f8b kernel: bump 4.14 to 4.14.41
Refreshed all patches

Dropped upstreamed patches:
522-PCI-aardvark-fix-logic-in-PCI-configuration-read-write-functions.patch
523-PCI-aardvark-set-PIO_ADDR_LS-correctly-in-advk_pcie_rd_conf.patch
525-PCI-aardvark-use-isr1-instead-of-isr0-interrupt-in-legacy-irq-mode.patch
527-PCI-aardvark-fix-PCIe-max-read-request-size-setting.patch

updated patches:
524-PCI-aardvark-set-host-and-device-to-the-same-MAX-payload-size.patch
030-USB-serial-option-fix-dwm-158-3g-modem-interface.patch

Added new ARM64 symbol: CONFIG_ARM64_ERRATUM_1024718

Compile-tested on: cns3xxx, imx6, mvebu (arm64), x86_64
Runtime-tested on: cns3xxx, imx6, x86_64

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
6 years ago
Rosen Penev fec205f654 ramips: mmc: Sync with staging driver
Mostly whitespace cleanups. Some unneeded code was removed.

MMC init was also moved to the probe function as in
6069bdd

The cleanup commits are over 100, making it hard to do them individually.

Tested on GnuBee PC1 with an SD card being used as swap.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
v2: Fixed compile issue with mt7620
6 years ago
Mathias Kresin 0e9e8d8323 kernel: dwc2: add support for host mode external vbus supply
Backport patch adding support for the vbus-supply devicetree property,
which allows to specific GPIOs (via fixed regulators) to enable
vbus/usb power.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
John Crispin 7e15e21766 Revert "ramips: mmc: Sync with staging drivers"
This reverts commit 2d401925b9.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Wei Yongjun 87c254c87e staging: mt7621-eth: fix return value check in mt7621_gsw_probe()
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: f079b6406348 ("staging: mt7621-eth: add gigabit switch driver (GSW)")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Wei Yongjun edec251870 staging: mt7621-eth: fix return value check in mtk_connect_phy_node()
In case of error, the function of_phy_connect() returns NULL pointer not
ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: e3cbf478f846 ("staging: mt7621-eth: add the drivers core files")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Wei Yongjun c4ae54dfab staging: mt7621-eth: fix return value check in mtk_probe()
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: e3cbf478f846 ("staging: mt7621-eth: add the drivers core files")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Rosen Penev e07baec9fa ramips: pci: sync with staging driver
This is an amagalmation of two upstream commits dealing with whitespace
and dead code removal. I'm synching instead of having two separate commits
as they go out of order compared to previous commits here.

Tested on GnuBee PC1.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Rosen Penev 2d401925b9 ramips: mmc: Sync with staging drivers
Mostly whitespace cleanups. Some unneeded code was removed.

MMC init was also moved to the probe function as in
6069bdd087

The cleanup commits are over 100, making it hard to do them individually.

Tested on GnuBee PC1 with an SD card being used as swap.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Matthias Badaire a0685deec4 ramips: Add i2c support for mt7620n
I2c is supported on mt7620n like on mt7620a when checking the datasheet

Signed-off-by: Matthias Badaire <mbadaire@gmail.com>
6 years ago
NeilBrown edea934799 ramips: remove unnecessary resource details.
These resources are extracted from devicetree, so they aren't
needed here.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
NeilBrown 1f78625714 ramips: remove conditional compilation.
Code currently defines:

and then compiles code only if they are defined.
We might want to disable some of these via devicetree one
day, but for now just remove the #defines and the
conditions - all the code for different ports is
easy to identify.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
NeilBrown 5f7396ebef ramips: improve interrupt mapping
As the Interrupts for the PCI adapters are listed in
devicetree we shouldn't need to have them explicit in the code.

The simplest way to do this is to use of_irq_parse_and_map_pci()
and specify an interrupt-map which identifies the different
PCI hosts by bus/slot numbers.
This has the advantage that the hwirq number are mapped to virq
numbers for us, so the ugly hack can go.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Christian Lütke-Stetzkamp 2ad4daf579 ramips: Remove redundant owner assignment
Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Rosen Penev a098a78a33 ramips: Move PCI driver to files directory
This will make it easier to port upstream code.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Felix Fietkau 6069bdd087 ramips: move mtk-mmc init to probe function to avoid breaking NAND flash
The driver messes with the pin control settings - MMC and NAND are
mutually exclusive

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau f95a4aa565 ramips: clean up the mt7621 nand flash driver hacks, add support for the xiaomi mir3g flash chip
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Davide Ammirata 004cc22e4e ramips: add support for mqmaker witi 512mb version
Splitted out the dts file and create the new dts for the 256 MByte RAM and
the 512 MB RAM version.

Migrate both versions to the common board detection.

The install the 512 MByte Version on a board running the 256 MByte image,
a forceful sysupgrade with the -F flag is required.

Signed-off-by: Davide Ammirata <list@davidea.it>
6 years ago
Matthias Badaire 5ef79af4f8 ramips: add support for Ravpower WD03
The RavPower WD03 is a battery powered SD card reader and a USB port.

Specifications:
SOC:     MediaTek MT7620N
BATTERY: 6000mah
WLAN:    802.11bgn
LAN:     1x 10/100 Mbps Ethernet
USB:     1x USB 2.0 (Type-A)
RAM:     PM Tech PMD708416CTR-5CN 32 MB
FLASH:   Holtek HT66F40 - 8 MB Flash
LED:     Power button and 4 leds to indicate power level of the
         battery (could not get control of that)
INPUT:   Power, reset button
OTHER:   USB SD-Card reader with card detect on GPIO#42

Tested and working:
 - Ethernet
 - 2.4 GHz WiFi (Correct MAC-address)
 - installation from tftp
 - OpenWRT sysupgrade (Preserving and non-preserving)
 - LEDs
 - Buttons

Installation:
 - Download the sysupgrade image
 - Place it in the root of a clean TFTP server running on your computer.
 - Rename the image to "kernel" — be sure there is no file extension.
 - Plug the WD03 into your computer via ethernet.
 - Set your computer to use 10.10.10.254 as its IP address.
 - With your WD03 shut down, hold down the power button until the first
   white LED lights up.
 - Push and hold the reset button and release the power button. Continue
   holding the reset button for 30 seconds or until it begins searching
   for files on your TFTP server, whichever comes first.
 - The WD03 (10.10.10.128) will look for your computer at 10.10.10.254
   and install the kernel file. Once it has finished installation of the
   kernel file, it will search for a (nonexistent) rootfs file — when it
   begins searching for this file, shut down the WD03 by holding the
   power button normally.
 - Start up your WD03 normally.

Signed-off-by: Matthias Badaire <mbadaire@gmail.com>
6 years ago
John Crispin 6e0ae87a98 ramips: disable spi full duplex on mt7621
Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Mathias Kresin 91e11bec74 ramips: fix mt7628 eval board pinmux
There is no pinmux group "jtag" for mt7628 and the pinmux driver fails
to load due to the use of the not existing group.

Fixes: FS#1515

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Mathias Kresin d089a5d773 ramips: create image for mt7628 evb board
The image for the EVB board got lost with the merge of the mt7628 and
mt7688 subtargets.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Tobias Wolf 3d800f14a9 ramips: use patch-dtb for F5D8235 V1
The old DTB method (OWRTDTB) is not recognized by the boot process
anymore with 4.9/4.14.

This patch reuses KERNEL_DTB to get a valid DTB applied to the kernel
image.

Signed-off-by: Tobias Wolf <github-NTEO@vplace.de>
6 years ago
Mathias Kresin 74a0d8cd92 build: consolidate fake uImage header build commands
Merge the two existing functions and use a parameter for the type
header field.

It updates the syntax of the former mpc85xx fake ramdisk header
command to be compatible with mkimage from u-boot 2018.03 and fixes the
build error spotted by the build bot.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Felix Fietkau 173d93ea23 ramips: fix locking issues in the ethernet driver
The stats update needs to protect against being interrupted by a tasklet
The u64 stats seqlock needs to be initialized

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Mathias Kresin e988b0fe0d ramips: mt7620: fix double use of pins
The pins are used as (LED) GPIOs and can't be used at the same time as
hardware controlled ephy (LED) pins.

Fixes: FS#1500

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Stijn Tintel ec1d7b9461 kernel: bump 4.14 to 4.14.34
Refresh patches.
Update patches that no longer apply:
- backport/313-netfilter-remove-defensive-check-on-malformed-packet.patch
- pending/642-net-8021q-support-hardware-flow-table-offload.patch

Compile-tested: x86/64.
Runtime-tested: x86/64.

Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
6 years ago
Felix Fietkau 31a6ee0219 ramips: remove broken and bogus spinlock in the SPI driver
Based on patch by Neil Brown

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau ceff5d8c82 ramips: add missing unlock in fe_phy_link_adjust
Based on patch by Neil Brown

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 07b4e49abb ramips: fix usb phy compatible string (should fix FS#1489)
In the new USB phy driver, it checks the compatible string before
attempting to iomap its mem resource and do the extra PHY init

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Mathias Kresin dda5d9b786 ramips: rename pwm kernel module
With kernel 4.14 the OpenWrt specific module name collides with the
upstream added module for Mediatek ARM Socs.

During addition of preliminary support for kernel 4.14, the config
symbol used by the out of tree driver was already renamed but the ramips
kernel package wasn't updated.

Fix the build error by updating the config and kernel module name for
the kernel package.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Vianney le Clément de Saint-Marcq bcf2125142 ramips: add support for Zorlik ZL5900V2
The Zorlik ZL5900V2 is an unbranded clone of HAME MPR-A1/2.  It is
marketed as "3G Wi-Fi Router".  Only the PCB has the model name
"ZL5900V2" printed on it.

Specifications:
- Ralink RT5350F (360 MHz)
- 32 MB RAM
- 8 MB Flash
- 802.11bgn 1T1R
- 1x 10/100 Mbps Ethernet
- 1x USB 2.0 (Type-A)
- 5200 mAh battery

The ramdisk image (not the squashfs sysupgrade image) can be flashed
through the web interface (named "GoAhead") of the factory firmware.
However, as the factory firmware does not cleanly unmount the rootfs
before flashing, the device may hang instead of rebooting after
successful write.  Power cycling the device gets you in OpenWrt where
the squashfs image may be flashed through normal sysupgrade procedure.

Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
6 years ago
Zheng Qian 80a94aacaf ramips: add support for the YouHua WR1200JS
YouHua tech WR1200JS is an AC1200 router with 5 1Gb ports (4 Lan, 1 Wan)
and 1 USB 2.0 port.

Devices is base on MediaTek MT7621AT + MT7603E + MT7612E.

Specification:

- MT7612AT (880 MHz)
- 128 MB of RAM
- 16 MB of FLASH (SPI NOR)
- 5x 10/100/1000 Mbps Ethernet
- 2T2R 2.4 GHz (MT7603E)
- 2T2R 5 GHz (MT7612E)
- 1x USB 2.0
- 10x LED (Power 2G 5G WPS Internet LAN4-1 USB)
- 3x button (reset wifi wps)
- DC jack for main power input (12V)

Installation:

1.) Press reset key 5 sec and restore the factory default
2.) Login webUI and change username to root and set a
    new password
3.) Visit http://192.168.2.254/adm/telnetd.shtml and
    turn on the telnet service
4.) Copy openwrt-ramips-mt7621-youhua_wr1200js-initramfs-kernel.bin
    to a usb pan
5.) Plug the usb pan to the router, telnet to the router
    and login by root
6.) cd /media/sda1 and check the initramfs file is there
7.) exec command:
    mtd_write write openwrt-ramips-mt7621-youhua_wr1200js-initramfs-kernel.bin Kernel
8.) reboot and visit 192.168.1.1

Signed-off-by: Zheng Qian <sotux82@gmail.com>
6 years ago
Giuseppe Lippolis 1680ae7eae ramips: add dwr-512 jboot firmware configuration
The previous fw version require the replacement of the stock bootloader
with u-boot. This prevent an easy stock restore of the original fw.

Now a proper fw util has been developed to manage the stock jboot
bootloader. Therefore make sense have a fw image for the stock
bootloader.

The old fw configuration (u-boot) is not compatible with the new one
and will not be supported anymore.

So at the end 2 image can be generated:

1) factory image with jboot bootloader
     openwrt-ramips-rt305x-dwr-512-b-squashfs-factory.bin
2) sysupgrade image with jboot bootloader
     openwrt-ramips-rt305x-dwr-512-b-squashfs-sysupgrade.bin

Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
6 years ago
Vianney le Clément de Saint-Marcq eda27d7557 ramips: fix usbphy DT nodes on linux 4.14
The Ralink USB PHY driver merged into mainline has a slightly different
device tree binding than the patch that was used with linux 4.9.
The new driver requires a `ralink,sysctl` node pointing to the `syscon`
node.

This patch also sets `#phy-cells` to 0, as recommended by the mainline
documentation [1].

[1] Documentation/devicetree/bindings/phy/ralink-usb-phy.txt

Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
6 years ago
Piotr Dymacz 10ea53f900 ramips: add U-Boot env support for ALFA Network AC1200RM
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
6 years ago
Piotr Dymacz 68dcec7e16 ramips: image: drop redundant SUPPORTED_DEVICES
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
6 years ago
John Crispin bfed382540 ramips: fix build error caused by missing ifdef guard in hwnat code
Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 424a9ae128 ramips: implement hardware NAT offload for MT7621
Supports IPv4 flow offloading on MT7621 for Routing, SNAT and DNAT

Supported are regular ethernet->ethernet connections, including one
802.1q VLAN and/or PPPoE encapsulation

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau dea9922acd ramips: drop linux 4.9 support
4.14 has been tested a lot by a number of users, and we want to use it
for the release.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 804952e7ef ramips: switch to linux 4.14
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
NeilBrown f27336e115 ramips: mtk-mmc: don't advertise highmem support.
of_dma_configure() sets a default ->dma_mask of
DMA_BIT_MASK(32), claiming devices can DMA from
the full 32bit address space.
The mtk-mmc driver does not support access to
highmem pages, so it is really limited to the
bottom 512M (actually 448M due to 64M of IO space).
Setting ->dma_mask to NULL causes mmc_setup_queue()
to fall-back to using BLK_BOUNCE_HIGH to tell the
block layer to use a bounce-buffer for any highmem
pages requiring IO.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 6a621f4bd9 ramips: fix BUG_ON on mtk-mmc driver probe
Our .dts files only have one device defined and this is unlikely to
change, so statically initialize host->id to 0.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau f9b2d369a6 ramips: move mtk-mmc driver code out of patches-*/ and into files-*/
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Pawel Dembicki 8db84cc0ee ramips: add support for DLINK DWR-921-C3
The DWR-921-C3 Wireless Routers with LTE embedded modem is based on the
MT7620N SoC.

Specification:

  * MediaTek MT7620N (580 Mhz)
  * 64 MB of RAM
  * 16 MB of FLASH
  * 802.11bgn radio
  * 5x 10/100 Mbps Ethernet (1 WAN and 4 LAN)
  * 2x external, detachable (LTE) antennas
  * UART header on PCB (57600 8n1)
  * 6x LED (GPIO-controlled)
  * 1x bi-color Signal Strength LED (GPIO-controlled)
  * 2x button
  * JBOOT bootloader

Installation:
Apply factory image via d-link http web-gui.

How to revert to OEM firmware:
1.) Push the reset button and turn on the power. Wait until LED start
    blinking (~10sec.)
2.) Upload original factory image via JBOOT http (IP: 192.168.123.254)
3.) If http doesn't work, it can be done with curl command:
    curl -F FN=@XXXXX.bin http://192.168.123.254/upg
    where XXXXX.bin is name of firmware file.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
6 years ago
Giuseppe Lippolis 6525bffc0a ramips: add support for DLINK DWR-921-C1
The DWR-921-C1 Wireless Routers with LTE embedded modem is based on the
MT7620N SoC.

Specification:

  * MediaTek MT7620N (580 Mhz)
  * 64 MB of RAM
  * 16 MB of FLASH
  * 802.11bgn radio
  * 5x 10/100 Mbps Ethernet (1 WAN and 4 LAN)
  * 2x external, detachable (LTE) antennas
  * UART header on PCB (57600 8n1)
  * 6x LED (GPIO-controlled)
  * 1x bi-color Signal Strength LED (GPIO-controlled)
  * 2x button
  * JBOOT bootloader

The status led has been assigned to the dwr-921-c1:green:sigstrength (lte
signal strength) led. At the end of the boot it is switched off and is
available for lte operation. Work correctly also during sysupgrade
operation.

Installation:
Apply factory image via d-link http web-gui.

How to revert to OEM firmware:
1.) Push the reset button and turn on the power. Wait until LED start
    blinking (~10sec.)
2.) Upload original factory image via JBOOT http (IP: 192.168.123.254)
3.) If http doesn't work, it can be done with curl command:
    curl -F FN=@XXXXX.bin http://192.168.123.254/upg
    where XXXXX.bin is name of firmware file.

Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
6 years ago
André Draszik cd75d6f7b3 ramips: mt7620: eMMC: fix compiler warnings in non-debug mode
drivers/mmc/host/mtk-mmc/dbg.c:51:13: warning: 'cmd_buf' defined but not used [-Wunused-variable]
 static char cmd_buf[256];
             ^~~~~~~

In addition, msdc_reg[] is completely unused, even in debug
mode.

Signed-off-by: André Draszik <git@andred.net>
6 years ago
André Draszik 584b2a26f5 ramips: mt7620: eMMC: remove unused variable
msdc_6575_host[] is unused, just remove it. Also, it
was the source of memory corruption up until the
previous fix to this driver.

Signed-off-by: André Draszik <git@andred.net>
6 years ago
André Draszik ace1686200 ramips: mt7620: eMMC: stop invalid memory access if only one device is defined
pdev->id is -1 when only one device exists, and is used:
* as an index into drv_mode[] to determine whether to use
  PIO or DMA mode (via host->id)
* as an index into msdc_6575_host[], to store the
  mmc_priv() data.

Obviously, -1 is not a valid index in either case, causing
us to read invalid memory, and memory corruption,
respectively.

The invalid memory read is causing non-deterministic
behaviour, in particular in the v4.4 kernel it still
picked DMA mode, but in the v4.9 it now always picks
PIO mode.
Also, PIO mode doesn't work, causing the following:

/ # echo 3 > /proc/sys/vm/drop_caches
[ 3845.249237] sh (128): drop_caches: 3

/ # /root/usr/lib/libc.so
[ 3846.096070] do_page_fault(): sending SIGSEGV to libc.so for invalid read access from 7f9cb5a0
[ 3846.104758] epc = 779b0ea4 in libc.so[7792f000+c3000]
[ 3846.109907] ra  = 779a8004 in libc.so[7792f000+c3000]
Segmentation fault

/ # /root/usr/lib/libc.so
musl libc (mipsel-sf)
Version 1.1.16-git-40-g54807d47
Dynamic Program Loader
Usage: /root/usr/lib/libc.so [options] [--] pathname [args]

(i.e. initial page-in of any binary causes a segfault,
subsequent access works.)

While this change doesn't fix PIO mode, it at least makes
us deterministically use DMA (which works), and it also
stops us from corrupting memory.

Signed-off-by: André Draszik <git@andred.net>
6 years ago
André Draszik dcbf6284e5 ramips: mt7620: eMMC: fix MODULE_DEVICE_TABLE
This was referencing an undefined symbol, probably
due to copy/paste error.

Signed-off-by: André Draszik <git@andred.net>
6 years ago
André Draszik 7d44b36c98 ramips: mt7620: eMMC: fix compiler warning (misleading indentation)
drivers/mmc/host/mtk-mmc/sd.c:2782:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if ((hw->flags & MSDC_SDIO_IRQ) || (hw->flags & MSDC_EXT_SDIO_IRQ))
     ^~
drivers/mmc/host/mtk-mmc/sd.c:2785:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
  cd_active_low = !of_property_read_bool(pdev->dev.of_node, "mediatek,cd-high");
  ^~~~~~~~~~~~~

Signed-off-by: André Draszik <git@andred.net>
6 years ago
André Draszik bbbd71e3ea ramips: mt7620: eMMC: clear owner field
a) This is not needed in recent kernels anymore (> 3.x ??)
b) this allows driver unloading now

Signed-off-by: André Draszik <git@andred.net>
6 years ago
Hauke Mehrtens a74fd570a2 kernel: update kernel 4.14 to 4.14.32
The following patches are now included upstream:
* 0052-MIPS-lantiq-fix-usb-clocks.patch
* 0053-MIPS-lantiq-enable-AHB-Bus-for-USB.patch
* 0060-lantiq-ase-enable-MFD-SYSCON.patch

Closes: FS#1466

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Tested-by: Stijn Segers <foss@volatilesystems.org>
Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
6 years ago
Hauke Mehrtens aed03d5d0f kernel: update kernel 4.9 to version 4.9.91
* Refreshed patches.
 * Deleted 210-Revert-led-core-Fix-brightness-setting-when-setting-.patch (was accepted upstream)
 * Deleted 812-pci-dwc-fix-enumeration.patch (was accepted upstream)

Compile and run tested on lantiq

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
6 years ago
Stijn Segers 41a881a8d9 Kernel: bump 4.14 to 4.14.29
Right patch version this time, sorry!

* Patch 180-usb-xhci-add-support-for-performing-fake-doorbell.patch had to be adjusted slightly because of upstream adapted code.
* Refreshed patches.

Compile-tested: ramips/mt7621, x86/64
Run-tested: ramips/mt7621, x86/64
Signed-off-by: Stijn Segers <foss@volatilesystems.org>
Tested-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Felix Fietkau a276002079 ramips: remove dead (and potentially crashy) code in mt7621 gsw init
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 147b679891 ramips: rename ethernet priv->device field to dev to match upstream
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
INAGAKI Hiroshi e3bf92edf5 ramips: fix switch and MAC address for WHR-G300N
WHR-G300N has 5 ethernet ports (lan: 4, wan: 1), but there was no
correct configuration in 02_network script and 6 ports was configured
on the switch.
Also, since the MAC address was not acquired from factory partition,
incorrect values was set to LAN and WAN interfaces.

This commit fixes these issues.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
6 years ago
Peter Lundkvist d13b05741a ramips: add support for TP-Link TL-WR902AC v3
TP-Link TL-WR902AC v3 is a pocket-size dual-band (AC750) router
based on MediaTek MT7628N + MT7650E.

Specification:
- MediaTek MT7628N/N (580 Mhz)
- 64 MB of RAM
- 8 MB of FLASH
- 2T2R 2.4 GHz and 1T1R 5 GHz
- 1x 10/100 Mbps Ethernet

* MT7650 ac chip isn't not supported by LEDE/OpenWrt at the moment.
  Therefore 5Ghz won' work.

Flash instruction:

The only way to flash LEDE image in TL-WR902AC v3 is to use
tftp recovery mode in U-Boot:

1. Configure PC with static IP 192.168.0.66/24 and tftp server.
2. Rename "openwrt-ramips-mt76x8-tplink_tl-wr902ac-v3-squashfs-tftp-recovery.bin"
   to "tp_recovery.bin" and place it in tftp server directory.
3. Connect PC with the LAN port, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
4. Router will download file from server, write it to flash and reboot.

Signed-off-by: Peter Lundkvist <peter.lundkvist@gmail.com>
[drop p2led_an pinmux, this pin isn't used as gpio, fix whitespace issues]
Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Pawel Dembicki a5bd8de0bd ramips: add support for D-Link DWR-116-A1/2
The DWR-116-A1/2 Wireless Router is based on the MT7620N SoC.

Specification:

  MediaTek MT7620N (580 Mhz)
  32 MB of RAM
  8 MB of FLASH
  802.11bgn radio
  5x 10/100 Mbps Ethernet (1 WAN and 4 LAN)
  2x external, non-detachable antennas
  UART (J1 in A1, JP1 in A2) header on PCB (57600 8n1)
  6x LED (GPIO-controlled), 2x button
  JBOOT bootloader

Known issues:
WAN LED is drived by uartl tx pin. I decide to use this pin as
uartlite tx pin.

Installation:
Apply factory image via http web-gui.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
6 years ago
INAGAKI Hiroshi dbdc26ba33 ramips: fix switch for Nexx devices
There are 2 ethernet ports on Nexx WT1520 and WT3020. These ethernet
ports are assigned as follows, and other ports cannot be used.

- WT1520:
  - port0 -> lan
  - port4 -> wan

- WT3020:
  - port0 -> wan
  - port4 -> lan

I dropped ports that cannot be used.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
6 years ago
Mathias Kresin d482356322 ramips: mt7620n: add mdio node and disable port4 by default
Revert the changes I applied to aa5014dd1a ("ramips: mt7620n: enable
port 4 as EPHY by default").

The driver expects a node mdio-bus to be present, regardless of the
actual node status. If the node is missing the driver fails to load  with

  mtk_soc_eth 10100000.ethernet: no mdio-bus child node found

Disable port4 by default again. If the port is enabled but not present, a
"invalid port id 4" warning is shown during boot.

Fixes: FS#1428

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
John Crispin d57ca53ff9 Revert "ramips: gpio: fix compilation if CONFIG_GPIO_SYSFS=n"
This reverts commit cff2dedebc.

This patch causes build issues

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
André Draszik cff2dedebc ramips: gpio: fix compilation if CONFIG_GPIO_SYSFS=n
If CONFIG_GPIO_SYSFS=n, compilation fails with
  drivers/built-in.o: In function `gpio_export_with_name':
  include/asm-generic/gpio.h:128: undefined reference to `__gpiod_export'

This is because the stub in that case has the wrong name,
_gpiod_export() - note the missing underscore (_) at the
start.

Fix the stub, and add the correct prototype for the real
implementation.

Signed-off-by: André Draszik <git@andred.net>
6 years ago
Giuseppe Lippolis aa5014dd1a ramips: mt7620n: enable port 4 as EPHY by default
According to the datasheet the mt7620n have a fixed switch configuration
with 5 ephy (10/100) port. No RGMII configuration is possible.

Drop the mdio node as well. Without RGMII, the mdio node doesn't make any
sense

Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
[drop mdio node, enable port4 by default]
Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Pawel Dembicki 39b5218434 ramips: mt7620: power up ephy port 4
In some boards port 4 of mt7620 switch is powered down in bootloader
configuration as lan/wan package leak mitigation.

Reset ephy port 4 to default settings to power up the port.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
[clarify issue in commit message]
Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Magnus Kroken 5af85dab22 kernel: bump 4.9 to 4.9.85
Signed-off-by: Magnus Kroken <mkroken@gmail.com>
6 years ago
Stijn Segers b5469b38cd kernel: bump 4.14 to 4.14.23
This patch bumps the 4.14 kernel to .23.
- Refreshed patches.
- Deleted bcm53xx/patches-4.14/089-PCI-iproc-Fix-NULL-pointer-dereference-for-BCMA.patch. Has been accepted upstream.
- Deleted generic/pending-4.14/821-usb-Remove-annoying-warning-about-bogus-URB.patch. The upstream URB code was changed,
  the patch no longer applies. I discussed this with the patch author and removed it for now, we'll see how it goes.

Compile-tested on: ramips/mt7621, x86/64
Run-tested on: ramips/mt7621, x86/64

Signed-off-by: Stijn Segers <foss@volatilesystems.org>
6 years ago
Felix Fietkau d8655868ca ramips: fix spurious IRQ7 events when using perf on 4.14
Upstream handling of MIPS CPU IRQs is rather hackish and the interrupts
are being enabled unconditionally in various places because of legacy
code.
Performance counter events are routed both through the GIC and through
legacy CPU IRQ7 events, causing spurious interrupts.

Fix this by disabling IRQ7 when trying to access the performance counter
IRQ.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau e9b58b22c1 Revert "ramips: improve NAPI polling to increase GRO batch size" (fixes FS#1333)
This reverts commit 968b861612.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Roman Yeryomin f5984e0a0c ramips: mt7621: add Mediatek AP-MT7621A-V60 EVB support
This board has:
- mt7621 SoC
- 8MB SPI flash
- 128MB RAM
- 5x ethernet ports from internal (SoC) switch
- 1x ethernet port sitting on gmac2 and IC+ phy (not yet supported)
- 3x PCIe slots
- 1x USB 2.0 and 1x USB 3.0
- sound based on wm8960
- SDXC card slot (full size)

First fw write from interactive u-boot menu, interrupt with 2.
After that sysupgrade.

Tested both with 4.9 and 4.14

Signed-off-by: Roman Yeryomin <roman@advem.lv>
6 years ago
Felix Fietkau bcf4a5f474 ramips: remove chunked-io patch and set spi->max_transfer_size instead
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 46c49d8381 kernel: optimize for performance by default starting with 4.14
Keep size optimizations for smaller targets that already switched

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Benjamin Valentin 2d8eeca842 ramips: enable power LED and second uart on GL-MT300N-V2
The device has a second uart accessible via pin headers, so enable it.

There is also a green power led which was not enabled previously.
Enable it too and use it as status LED.

Signed-off-by: Benjamin Valentin <benjamin.valentin@volatiles.de>
6 years ago
Piotr Dymacz f1c193c27e ramips: add support for ALFA Network AWUSFREE1
ALFA Network AWUSFREE1 is an USB Wi-Fi N300 adapter based on MT7628.

Specification:

- MT7628AN (580 MHz)
- 64 MB of RAM (DDR2)
- 8 MB of FLASH (SPI NOR)
- 2T2R 2.4 GHz (MT7628) with external FEM (RFFM4203)
- 2x detachable antennas (RP-SMA)
- ASIX AX88772 USB to Ethernet bridge (connected with MT7628 PHY0)
- 4x LED (2 driven by GPIO)
- 1x button (reset)
- 1x mini USB for host and main power input
- UART header on PCB

Flash instruction:

You can use sysupgrade image directly in vendor firmware which is based
on LEDE/OpenWrt. Alternatively, you can use web recovery mode in U-Boot:

1. Power device with reset button pressed and release it after ~5 sec.
2. Setup static IP 192.168.1.2/4 on your PC.
3. Go to 192.168.1.1 in browser and upload "sysupgrade" image.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
6 years ago
Roman Yeryomin 6b6dc2b3e3 ramips: mt7621: fix usb init
In 4.14 reg-names is required to identify resources.
Otherwise init fails with:

[    5.900501] xhci-mtk 1e1c0000.xhci: invalid resource
[    5.910499] xhci-mtk: probe of 1e1c0000.xhci failed with error -22

Signed-off-by: Roman Yeryomin <roman@advem.lv>
6 years ago
Felix Fietkau 8a59f9590e ramips: fix MT7621 switch driver IRQ storm on init with linux 4.14
The hardware emits some interrupts while initializing and handling them
can mess up the state or cause infinite loops.
Fix this by disabling IRQs during init and re-enabling them afterwards

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 79f9cadd00 ramips: fix MT7621 PCI driver on 4.14
The .map_irq hook can now be called after init.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
INAGAKI Hiroshi e1d4aa36b0 ramips: add support for Tama W06
Tama Electric Axing W06 is a 2.4 GHz band 11n router, based on Mediatek
MT7688AN.

Specification:

- MT7688AN (575 MHz)
- 64 MB of RAM (DDR2 SDRAM)
- 16 MB of Flash (SPI)
- 1T1R 2.4 GHz
- 1x 10/100/1000 Mbps Ethernet
- 4x LEDs (GPIO connected: 3), 1x button
- 1x USB 2.0 Type-A (host)
- UART header on PCB (GND, RX, TX, Vcc from RJ45 side)

Flash instruction using sysupgrade image:
1. Connect micro-USB cable for power supply into W06 and turn on the
router
2. Connect to wifi with SSID "tama-*" with password. Complete SSID and
password are listed on the back of the router
3. Access to 192.168.1.1 and login with user name "admin" and password
empty
4. In firmware update(ファームウェア更新) page, click "参照" button
and click "ブラウザー" button to open file browser, select the
sysupgrade image and press OK button
5. Wait ~150 seconds to complete flashing

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
6 years ago
Mathias Kresin cb741654e5 ramips: improve GnuBee Personal Cloud Two support
Use the generic board detection for the GnuBee Personal Cloud Two
instead of the target specific one as all recent additions are doing.

Fixup the pinmux to set all pins used as GPIO to the function GPIO.
Request pins where used.

Drop the i2c from the dts. There is nothing connected. While at it fix an
indentation issue and use references instead of duplicating the whole
node path.

Use the same switch config as for the GB-PC1 and drop the led trigger for
the not supported IP1001 phy connected to second rgmii.

Fixes: c60a21532b ("ramips: Add support for the GnuBee Personal Cloud Two")
Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Mathias Kresin c330408ea9 ramips: use generic board detection for D-Link DAP-1522 A1
Use the generic board detection for the D-Link DAP-1522 A1 instead of the
target specific one as all recent additions are doing.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Stijn Tintel f621b53951 kernel: bump 4.9 to 4.9.82
Refresh patches.
Remove upstreamed patches:
- ar7/002-MIPS-AR7-ensure-the-port-type-s-FCR-value-is-used.patch
- backport/040-crypto-fix-typo-in-KPP-dependency-of-CRYPTO_ECDH.patch
Remove layerscape/819-Revert-dmaengine-dmatest-move-callback-wait-queue-to.patch,
it is superseded by upstream commit 297c7cc4b5651b174a62925b6c961085f04979fd.
Remove pending/650-pppoe_header_pad.patch, it is superseded by
upstream commit 1bd21b158e07e0b8c5a2ce832305a0ebfe42c480.
Update patches that no longer apply:
- ar71xx/004-register_gpio_driver_earlier.patch
- hack/204-module_strip.patch
- pending/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch

Fixes CVE-2017-8824.

Compile-tested: ar71xx.
Runtime-tested: ar71xx.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
6 years ago
Stijn Tintel 88ba41453d kernel: bump 4.14 to 4.14.20
Refresh patches.
Remove upstreamed patches:
- backport/080-v4.15-0001-arch-define-weak-abort.patch
- backport/081-v4.15-0002-kernel-exit.c-export-abort-to-modules.patch
Update patch that no longer applies:
pending/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch

Fixes CVE-2017-8824.

Compile-tested: octeon, x86/64.
Runtime-tested: octeon, x86/64.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
6 years ago
Mathias Kresin c4ac02ffca treewide: remove obsolete sysupgrade watchdog kill
The watchdog kill command was meant for busybox watchdog. Busybox watchdog
was replaced by the procd watchdog mid 2013 with commit df7ce9301a
("busybox: disable the watchdog utility by default"), which makes the kill
command obsolete since quite some time.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Roman Yeryomin f4e5880d0f ramips: preliminary support for 4.14
- removed upstreamed patches
- 0901-spansion_nand_id_fix.patch is disabled, not clear if it's needed

Signed-off-by: Roman Yeryomin <roman@advem.lv>
Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Jo-Philipp Wich dc7a1e8555 ramips: fix reporting effective VLAN ID on MT7621 switches
On MT7621, the REG_ESW_VLAN_VTIM reads are undefined, causing swconfig
to always report `vid: 0` in swconfig show output.

Since a 4K VLAN table is used on this platform, the VLAN ID always
correponds to the actual VLAN table index so provide a specific MT7621
implementation of the get_vid callback which returns the table index
as VLAN ID.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
6 years ago
Jo-Philipp Wich 341b1427fc ramips: properly map pvid for vlans with remapped vid on mt7530/762x switches
Currently, untagged port primary vlan IDs are set to the VLAN table index,
and not the actual VLAN ID, breaking configurations with IDs deviating from
the VLAN index.

Fix the issue by resolving the per-port pvid property to the target VLAN ID
value before committing to the hardware.

Fixes FS#991, FS#1147, FS#1341

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
6 years ago
Jo-Philipp Wich bb4002c79d ramips: don't clobber vlans with remapped vid on mt7530/762x switches
Avoid overwriting vlan entries with remapped vid in later iterations of
the vlan enumeration loop of mt7530_apply_config().

Fix the problem by refactoring the code to first reset the entire table,
then reprogram only vlans with members to prevent overwriting configured
vlans with unconfigured ones.

Fixes FS#1147, FS#1341

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
6 years ago
George Hopkins 13f9e40602 ramips: add support for D-Link DAP-1522 A1
D-Link DAP-1522 is a wireless bridge/access point with 4 LAN
ports and a dual-band wireless chipset.

Specifications:
- Ralink RT2880
- 32 MB of RAM
- 4 MB of Flash
- 4x 10/100/1000 Mbps Ethernet (RTL8366SR)
- 802.11abgn (RT2850)

Flash Instructions:
1. Download lede-ramips-rt288x-dap-1522-a1-squashfs-factory.bin
2. Open the web interface and upload the image

Signed-off-by: George Hopkins <george-hopkins@null.net>
6 years ago
INAGAKI Hiroshi 192b5a7710 ramips: use new image build code for WHR-G300N
The tftp.bin image for Buffalo WHR-G300N was not built, so I was fixed
it after rewriting to new image build code. And the code for
factory-EU.bin was broken, so I deleted it.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
6 years ago
Rosen Penev c60a21532b ramips: Add support for the GnuBee Personal Cloud Two
The GnuBee Personal Cloud Two crowdfunded on https://www.crowdsupply.com
It is a low-cost, low-power, network-attached storage device.

Specifications:

- SoC: MediaTek MT7621AT
- RAM: DDR3 512 MB
- Flash: 32 MB
- Six SATA ports for 3.5" Drives
- One SDcard
- One USB 3.0
- Two USB 2.0
- Gigabit Ethernet: Three Ports
- UART 3.5mm Audio Jack or 3 pin header - 57600 8N1
- Three GPIOs available on a pin header

Flash instructions:

The GnuBee Personal Cloud Two ships with libreCMC installed.
libreCMC is a Free Software Foundation approved fork of LEDE/OpenWrt.
As such one can upgrade using the webinterface or sysupgrade.

Das U-Boot has multiple options for recovery or updates including :

- USB
- http
- tftp

Errata:
- While there are three ethernet ports, the third requires support for
  the second GMAC. This will come in kernel 4.14.
- The first hard drive slot has a clearance issue with the two fan
  headers. Workaround is to pull the headers out and connect the pins to
  jumper wires.
- Using this device as a NAS is problematic with the 4.9 kernel as many
  /dev/sdX reads throw silent errors. The current theory behind this is
  some kind of unhandled DMA mapping error in the kernel. This is not an
  issue with kernel 4.4.

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Henryk Heisig 14951e8f8e ramips: add support for TP-Link Archer C50 v3
TP-Link Archer C50 v3 is a router with 5-port FE switch and
non-detachable antennas. It's based on MediaTek MT7628N+MT7612E.

Specification:
- MediaTek MT7628N/N (580 Mhz)
- 64 MB of RAM
- 8 MB of FLASH
- 2T2R 2.4 GHz and 2T2R 5 GHz
- 5x 10/100 Mbps Ethernet
- 4x external, non-detachable antennas
- UART (J1) header on PCB (115200 8n1)
- 7x LED (GPIO-controlled*), 2x button, power switch

* WAN LED in this devices is a dual-color, dual-leads type which isn't
  (fully) supported by gpio-leds driver. This type of LED requires both
  GPIOs state change at the same time to select color or turn it off.
  For now, we support/use only the green part of the LED.

Flash instruction:

The only way to flash LEDE image in ArcherC50v3 is to use
tftp recovery mode in U-Boot:

1. Configure PC with static IP 192.168.0.66/24 and tftp server.
2. Rename "openwrt-ramips-mt7628-ArcherC50v3-squashfs-tftp-recovery.bin"
   to "tp_recovery.bin" and place it in tftp server directory.
3. Connect PC with one of LAN ports, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
4. Router will download file from server, write it to flash and reboot.

Signed-off-by: Henryk Heisig <hyniu@o2.pl>
6 years ago
Henryk Heisig e39a240ba2 ramips: ArcherC20v4: use common TP-Link dtsi file
and remove common part from dts file.

Signed-off-by: Henryk Heisig <hyniu@o2.pl>
6 years ago
Henryk Heisig 368a7f4cec ramips: change the TP-Link dtsi filename
Signed-off-by: Henryk Heisig <hyniu@o2.pl>
6 years ago
Daniel Golle 32f120b783 ramips: various fixes for zbt-we1226
Convert userspace code to use generic device-tree compatible board
detection method.  Users of the existing code will have to use
sysupgrade -F once to switch to the new generic board naming.
Properly setup pinctrl fixing the switch port LEDs.

Fixes commit 9c4fe103cb (ramips: add support for ZBT-WE1226)
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
6 years ago
Felix Fietkau d3ea5fc9f3 ramips: use napi_alloc_frag and skb_free_frag
Slightly improves rx performance

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 968b861612 ramips: improve NAPI polling to increase GRO batch size
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau cde71a543c build: replace uses of OpenWrt with $(VERSION_DIST)
This makes the distribution name more configurable.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Jackson Ming Hu 21d3643828 ramips: add support for Widora Neo 32MB flash revision
Widora has updated their Widora Neo board recently.

The new model uses 32MB WSON-8 factor SPI flash
instead of the original 16MB SOP-8 factor SPI flash.

All the other hardware components are the same as
the first revision.

Detailed hardware specs listed below:

CPU: MTK MT7688AN
RAM: 128MB DDR2
ROM: 32MB WSON-8 factor SPI Flash (Winbond)
WiFi: Built-in 802.11n 150Mbps?
Ethernet: 10/100Mbps x1
Audio codec: WM8960
Other IO: USB OTG;
	  USB Power+Serial (CP2104);
	  3x LEDs (Power, LAN, WiFi);
	  2x Keys (WPS, CPU Reset)
	  1x Audio In/Out
	  1x IPEX antenna port
	  1x Micro SD slot

Signed-off-by: Jackson Ming Hu <huming2207@gmail.com>
Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Mathias Kresin a411881a40 ramips: add flash size postfix to Widora neo
Rename the Widora neo by adding a flash size prefix. Move the common parts
into a dtsi to be prepare everything for upcomming support of the 32MB
version.

Migrate the Widora neo to the generic board detection as well.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Rosen Penev c25d9cbde8 ramips: Fix GB-PC1 cpuclock again
The intended frequency is 900 MHz, not 90.

Fixes: 7059ab48a6 ("ramips: fix cpuclock for the GB-PC1")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Daniel Golle 9c4fe103cb ramips: add support for ZBT-WE1226
MT7628NN (580MHz), 8MB SPI NOR, 64MB DDR2 RAM

Everything except for the switch LEDs works great.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
6 years ago
Kevin Darbyshire-Bryant d8565a06dc kernel: bump 4.9 to 4.9.77
Refresh patches.
Remove upstreamed patches:

target/linux/generic/backport-4.9/023-2-smsc75xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch
target/linux/generic/backport-4.9/023-3-cx82310_eth-use-skb_cow_head-to-deal-with-cloned-skb.patch
target/linux/generic/backport-4.9/023-4-sr9700-use-skb_cow_head-to-deal-with-cloned-skbs.patch
target/linux/generic/backport-4.9/023-5-lan78xx-use-skb_cow_head-to-deal-with-cloned-skbs.patch

CVEs completely or partially addressed:

CVE-2017-5715
CVE-2017-5753
CVE-2017-17741
CVE-2017-1000410

Compile-tested: ar71xx Archer C7 v2
Run-tested: ar71xx Archer C7 v2

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
6 years ago
Serg Studzinskii eb58b14d27 ramips: tl-wr840n-v5: increase firmware partition for 4Mmtk layot
According to console log during TP-Link TL-WR840N v5 OEM firmware update
procedure 0x3e0000-0x3f0000 64kB "config" partition, which is used to store
router's configuration settings, is erased and recreated again during every
OEM firmware update procedure, thus does not contain any valuable factory data.
So it is conviniant to use this extra 64kB erase block for jffs overlay due
limited flash size on this device like it used on TP-Link's ar71xx boards.

Signed-off-by: Serg Studzinskii <serguzhg@gmail.com>
6 years ago
Daniel Gimpelevich e4442ca2d8 ramips: use blue status LED for Xiaomi Router 3G
The blue LED is what other firmwares use for this device, and it's a lot
easier on the eyes than its shade of yellow, which implies an error
condition.

Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
[merge into existing $boardname:blue:status block]
Signed-off-by: Mathias Kresin <dev@kresin.me>
Acked-by: Piotr Dymacz <pepe2k@gmail.com>
Acked-by: Cezary Jackiewicz <cezary@eko.one.pl>
6 years ago
Maxim Anisimov 5bdd238b63 ramips: add support for TP-Link Archer C20 v4
TP-Link Archer C20 v4 is a router with 5-port FE switch and
non-detachable antennas. It's based on MediaTek MT7628N+MT7610EN.

Specification:
- MediaTek MT7628N/N (580 Mhz)
- 64 MB of RAM
- 8 MB of FLASH
- 2T2R 2.4 GHz and 1T1R 5 GHz
- 5x 10/100 Mbps Ethernet
- 3x external, non-detachable antennas
- UART (J1) header on PCB (115200 8n1)
- 7x LED (GPIO-controlled*), 2x button, power input switch

* WAN LED in this devices is a dual-color, dual-leads type which isn't
  (fully) supported by gpio-leds driver. This type of LED requires both
  GPIOs state change at the same time to select color or turn it off.
  For now, we support/use only the green part of the LED.
* MT7610EN ac chip isn't not supported by LEDE. Therefore 5Ghz won't
  work.

Flash instruction:

The only way to flash LEDE image in ArcherC20v4 is to use
tftp recovery mode in U-Boot:

1. Configure PC with static IP 192.168.0.66/24 and tftp server.
2. Rename "openwrt-ramips-mt7628-ArcherC20v4-squashfs-tftp-recovery.bin"
   to "tp_recovery.bin" and place it in tftp server directory.
3. Connect PC with one of LAN ports, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
4. Router will download file from server, write it to flash and reboot.

Signed-off-by: Maxim Anisimov <maxim.anisimov.ua@gmail.com>
6 years ago
Maxim Anisimov ff1e895530 ramips: rename TP-Link Archer C20 to TP-Link Archer C20 v1
This changes device name from "TP-Link Archer C20" to "TP-Link Archer C20 v1"
because of TPLINK released new TP-Link Archer C20 v4. Additionally
migration to the generic board detection has been made.

Signed-off-by: Maxim Anisimov <maxim.anisimov.ua@gmail.com>
6 years ago
Chen Minqiang a8054d83dc ramips: add image checks
As long as we can't enforce image metadata, we need to use (platform)
image checks to have at least soem kind of validation.

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
6 years ago
Piotr Dymacz 5352669c2c ramips: add support for ALFA Network AC1200RM
ALFA Network AC1200RM is an AC1200 router, with 5-port FE switch and
USB 2.0 port. Device is based on MediaTek MT7620A + MT7612EN.

Specification:

- MT7620A (580 MHz)
- 64 MB of RAM (DDR2)
- 16 MB of FLASH (SPI NOR)
- 5x 10/100 Mbps Ethernet with passive PoE output in WAN and LAN4
- 2T2R 2.4 GHz (MT7620A)
- 2T2R 5 GHz (MT7612EN)
- 1x USB 2.0
- 9x LED (8 driven by GPIO)
- 1x button (reset)
- DC jack for main power input (12-24 V)
- 2x UART, I2C, I2S and LED headers

Flash instruction (do it under U-Boot, using UART and TFTP server):

Select option "2: Load system code then write to Flash via TFTP" and
use "sysupgrade" image.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
6 years ago
Rosen Penev 7059ab48a6 ramips: fix cpuclock for the GB-PC1
The GnuBee PC1 stock bootloader runs at 900Mhz. This fixes bad clock drift when running the platform.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Chuanhong Guo a657978fe7 ramips: fix lenovo newifi-y1 switch and LED config
There are 3 ethernet ports on Y1. LAN1 on port1, LAN2 on port0 and WAN on
port4.

Use a standalone switch configuration to match this and use the switch
trigger so that LAN LED could indicate the connetction status for both
lan ports correctly.

This patch also drop the internet led configuration, because there is a
WAN led for port4 and eth0.2 isn't always used as WAN.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
7 years ago
Mathias Kresin 6912e55e71 ramips: add missing soc compatibles to dts
Add SoC compatibles where missing.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 3326e36fa7 ramips: firewrt: indicate boot status via LED
Add the Firefly FireWRT gree power LED to diag.sh to indicate the boot
status via the power LED.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 4dd51788dd ramips: fix Omega2 compatible string
Change the compatibel from Omega to Omega2 and add the compatible string
where missing.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 76d735d189 ramips: fix widora neo diag led
The diag LED is named widora🍊wifi and can't be derived from the
boardname.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Kevin Darbyshire-Bryant 7b6e01d389 kernel: bump 4.9 to 4.9.72
Refresh patches.

Runtime tested: ar71xx - Archer C7 v2

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
7 years ago
Mathias Kresin c7776d4c55 ramips: fix Linkit smart 7688 support
Use a more appropriate compatible string. Fix the wireless led GPIO and
add the default wireless trigger. Use the wireless LED for boot state
indication as well.

Remove the GPIO pinmux for pins not exposed on the board.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Henryk Heisig 39e9bfb181 ramips: add support for TP-Link TL-MR3420 v5
TP-Link TL-MR3420 v5 are simple N300 router with
5-port FE switch and non-detachable antennas.
Its very similar to TP-Link TL-WR841N V13.

Specification:

- MT7628N/N (580 MHz)
- 64 MB of RAM (DDR2)
- 8 MB of FLASH
- 2T2R 2.4 GHz
- 5x 10/100 Mbps Ethernet
- 2x external, non-detachable antennas
- USB 2.0 Port
- UART (J1) header on PCB (115200 8n1)
- 8x LED, 2x button, power input switch

Flash instruction:

The only way to flash LEDE image in mr3420v5 is to use
tftp recovery mode in U-Boot:

1. Configure PC with static IP 192.168.0.225/24 and tftp server.
2. Rename "lede-ramips-mt7628-tplink_tl-mr3420-v5-squashfs-tftp-recovery.bin"
   to "tp_recovery.bin" and place it in tftp server directory.
3. Connect PC with one of LAN ports, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
4. Router will download file from server, write it to flash and reboot.

Signed-off-by: Henryk Heisig <hyniu@o2.pl>
7 years ago
Mathias Kresin 8ca650b8ce ramips: move common tplink image build code into own recipe
Move common tplink image build code into own recipe. Include the common
parts instead of including a full build recipe and overwriting former set
varaibles.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 198da20401 ramips: fix devicetree compat strings
"PandoraBox" is not the name of the manufacturer, it's a firmware made by
the manufacturer actually. Their official English name is "D-Team".

PBR-M1 is the only one they use "PandoraBox" as a brand name. Their other
products are using "Newifi" as their trademark (including Y1 and Y1S which
used to be OEM products for Lenovo).

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Jackson Ming Hu c0e131b436 ramips: add support for newifi d2
Previously Newifi D2 could only use PandoraBox M1's firmware.
It works fine, but LED GPIO is different.
As a result, a separated DTS file for this device should be implemented.

Hardware spec:

* CPU: MTK MT7621A
* RAM: 512MB
* ROM: 32MB SPI Flash
* WiFi: MTK MT7603+MT7612
* Button: 2 buttons (reset, wps)
* LED: 3 single-color LEDs (USB, WiFi 2.4GHz, WiFi 5GHz) &
       2 dual-color LEDs (Power, Internet)
* Ethernet: 5 ports, 4 LAN + 1 WAN

Installation method:

Same as Newifi D1, users may need to request unlock code from the device
manufacturer. Otherwise, a SPI flash programmer may be necessary to get
the firmware flashed. After the device is unlocked, press and hold reset
button before power cable plugs in. Then go to http://192.168.1.1 to
upload and flash the firmware package.

Signed-off-by: Jackson Ming Hu <huming2207@gmail.com>
7 years ago
Andrew Crawley fe6f298b07 ramips: add support for Vonets VAR11N-300
The VAR11N-300 is a tiny wireless-N device with a hardwired Ethernet
cable, one extra Ethernet port, and an internal antenna, based on the
MediaTek MT7620n chipset.

Specs:
- MT7620n WiSoC @ 600MHz
- 32 MB SDRAM
- 4 MB SPI flash
- 2T2R 2.4GHz WiFi-N
- 1 attached 10/100 Ethernet cable (LAN)
- 1 10/100 Ethernet port (WAN)
- 1 attached USB / barrel 5vdc power cable
- 5 LEDs (see notes below)
- 1 reset button
- 1 UART (3 pads on board)

Installation:

The stock firmware does not support uploading new firmware directly,
only checking the manufacturer's site for updates.  This process may be
possible to spoof, but the update check uses some kind of homebrew
encryption that I didn't investigate.  Instead, you can install via a
backdoor:

1. Set up a TFTP server to serve the firmware binary
(lede-ramips-mt7620-var11n-300-squashfs-sysupgrade.bin)
2. Factory reset the device by holding the reset button for a few
seconds.
3. Open the web interface (default IP: 192.168.253.254)
4. Log in with the "super admin" credentials: username `vonets`,
password `vonets26642519`.
5. On the "Operative Status" page, click the text "System Uptime", then
quickly click the uptime value.
6. If successful, an alert dialog will appear reading "Ated start", and
the device will now accept telnet connections.  If the alert does not
appear, repeat step 5 until it works (the timing is a bit tricky).
7. Telnet to the device using credentials "admin / admin"
8. Retrieve the firmware binary from the tftp server: `tftp -l lede.bin
-r lede-ramips-mt7620-var11n-300-squashfs-sysupgrade.bin -g
<tftp-server-ip>`
9. Write the firmware to flash: `mtd_write write lede.bin /dev/mtd4`
10. Reboot

Tested:
- LAN / WAN ethernet
- WiFi
- LAN / WAN / status LED GPIOs (see notes below)
- Reset button
- Sysupgrade

Notes:

LEDs:

The board has 5 LEDs - two green LEDs for LAN / WAN activity, one blue
LED for WiFi, and a pair of "status" LEDs connected to the same GPIO
(the blue LED lights when the GPIO is low, and the green when it's
high).  I was unable to determine how to operate the WiFi LED, as it
does not appear to be controlled by a GPIO directly.

Recovery:

The default U-boot installation will only boot from flash due to a
missing environment block.  I generated a valid 4KB env block using
U-boot's `fw_setenv` tool and wrote it to flash at 0x30000 using an
external programmer.  After this, it was possible to enter the U-boot
commandline interface and download a new image via TFTP (`tftpboot
81b00000 <image-filename>`), but while I could boot this image
sucessfully (`bootm`), writing it to flash (`cp.linux`) just corrupted
the flash chip.  The sysupgrade file can be written to flash at 0x50000
using an external programmer.

Signed-off-by: Andrew Crawley <acrawley@gmail.com>
7 years ago
Mathias Kresin ad002c397a ramips: add helper variable for boardname
Add a helper variable which contains the boardname separated from the
vendor name. It allows to switch to a device tree compatible string
based boardname, by keeping the $board:colour:function syntax in
scripts handling/adding config for LEDs.

Boards not using the device tree compatible string as based boardname
are unaffected by the change, since none of them uses a comma in the
boardname.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 6545c71d2c ramips: sync image filename with boardname
Use <manufacturer>_<modelname> as image name for board using the
devicetree compat string as boardname.

Replace the underline of the device define, to keep the SUPPORTED_DEVICES
in sync with a devicetree compat string based boardname.

Override the default SUPPORTED_DEVICES for board which are having an
userspace boardname with an underline.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 7d3ec5f833 ramips: fallback to generic board detect
Fallback to the generic board detection if no case for the current
board exists.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 224d4a96dd ramips: drop LinkIt Smart 7688 Duo userspace support
The  LinkIt Smart 7688/LinkIt Smart 7688 Duo are identical beside the
extra ATmega32U4 - accessible via UART - on the the Duo.

Since all relevant hardware is identical, drop the Duo special handling
in userspace.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Hauke Mehrtens f704b643b9 kernel: Update kernel 4.9 to 4.9.70
Runtime tested on lantiq.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
7 years ago
Mathias Kresin 95fe3c51e5 ramips: fix polarity in gpio-export node
If we need to set the initial output value to GPIOF_OUT_INIT_HIGH (1) to
enable something, the pin is ACTIVE_HIGH. The same applies to
GPIOF_OUT_INIT_LOW (0) and ACTIVE_LOW.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Luis Araneda 575178e462 treewide: add only one device when appending to TARGET_DEVICES
This will avoid some conflicts when doing a git rebase or merge,
specially when adding support to a new device.

Signed-off-by: Luis Araneda <luaraneda@gmail.com>
[drop brcm47xx changes which rename the images]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Pavel Kubelun 69d22a6bf6 ramips: fix a typo in 02_network
The typo in network defaults script in ramips target that prevents
defaults to initialize.

Signed-off-by: Pavel Kubelun <be.dissent@gmail.com>
7 years ago
Stijn Tintel f997478655 kernel: bump 4.9 to 4.9.67
Refresh patches.
Remove upstreamed patches:
- generic/190-1-5-e1000e-Fix-error-path-in-link-detection.patch
- generic/190-3-5-e1000e-Fix-return-value-test.patch
- generic/190-4-5-e1000e-Separate-signaling-for-link-check-link-up.patch
- generic/190-5-5-e1000e-Avoid-receiver-overrun-interrupt-bursts.patch
- ramips/0102-MIPS-ralink-Fix-MT7628-pinmux.patch
- ramips/0103-MIPS-ralink-Fix-typo-in-mt7628-pinmux-function
Update patches that no longer apply:
- layerscape/815-spi-support-layerscape.patch
- ramips/0099-pci-mt7620.patch

Compile-tested on ar71xx, brcm2708/bcm2708, octeon and x86/64.
Runtime-tested on ar71xx, brcm2708/bcm2708, octeon and x86/64.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years ago
Zoltan HERPAI 58e0673900 ramips: add support for Asus RT-N11P / RT-N12+ / RT-N12E b1
This is a variant of the MT7620N-based Asus routers.

Specifications:

- MT7620N (580 MHz)
- 32 MB RAM
- 8 MB Flash
- 5x 10/100Mbps Ethernet (built-in switch)
- 2.4 GHz WLAN
- 2x external, non-detachable antennas
- UART (J2) header on PCB (115200 8n1)

Flash instructions:

1. Configure PC with static IP 192.168.1.75/24
2. Connect PC with one of LAN ports, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds. All 4 LEDs will
   start to blink, which is when the router will accept firmware files via TFTP.
   No known limitations on firmware filenames, just send it with a TFTP client
   to 192.168.1.1.
3. Router will download file from server, write it to flash and reboot.

Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
7 years ago
INAGAKI Hiroshi 18cc8d520c ramips: add missing reset button for Nexx WT1520
This commit adds missing the GPIO key used as reset button.
Nexx WT1520 has a GPIO key for factory reset, but it's not defined in
WT1520.dtsi and cannot use it.

Drop the UART (full) from the device tree source file, it was never
used for this board. Adjust the kernel bootargs accordingly.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[add note about dropped UART (full) to the commit message]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Stijn Tintel 9fe59abef8 kernel: bump 4.9 to 4.9.65
Refresh patches.
Compile-tested: ar71xx, octeon, x86/64.
Runtime-tested: ar71xx, octeon, x86/64.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years ago
Koen Vandeputte 62ede4f783 kernel: bump 4.9 to 4.9.63
Refreshed all patches.

Removed upstreamed parts.

Compile-tested: cns3xxx, imx6, mvebu, layerscape
Run-tested: cns3xxx, imx6

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
7 years ago
Mathias Kresin aa82141d9b ramips: use pinmux nodes from dtsi
Use the pinmux nodes from the included dtsi file instead of adding
duplicate nodes.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin b69ceb0c3d ramips: add missing pinmuxes to SoC dtsi
Add pinmuxes defined by some board which are including the dtsi files
to the dtsi files itself. Allows to reduce duplication.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin e142173e8d ramips: backport MT7628 pinmux fixes
According to the datasheet the REFCLK pin is shared with GPIO#37 and
the PERST pin is shared with GPIO#36.

While at it fix a typo inside the pinmux setup code. The function is called
refclk and not reclk.

Update device tree source files accordingly.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 2f9fe78e75 ramips: fix Planex CS-QR10 device packages
Add kmod-sound-core, it is a dependency of kmod-sound-mt7620 and will
not be autoselected.

Remove kmod-i2c-core, it will be autoselected by kmod-i2c-ralink.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin a783185e28 ramips: fix DCH-M225 support
Setting the pins of the UARTF group to GPIO+I2S at the time the I2C
driver loads is to late for the wps GPIO button.

The gpio-keys driver fails to load since the pin used by the wps button
is not yet set to GPIO. The wps button with the rfkill keycode is
essential for this wireless only board.

Add the missing sound and I2C kernel modules corresponding to the
device nodes.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Felix Fietkau 9996480b0e ramips: add support for ZBT WE3526
This is a variant of the ZBT WG3526 with a few minor modifications.
The wifi chips are swapped, and there is no GPIO controllable status
LED. There is also no SATA port.

Specifications:

- MT7621AT (880 MHz)
- 512 MB RAM
- 16 MB Flash (SPI NOR)
- 5x 1Gbps Ethernet (built-in switch)
- MT7612E 802.11ac 5 GHz WLAN
- MT7603E 802.11n 2.4 GHz WLAN

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Felix Fietkau 3eb839b579 ramips: extract board name from device tree as a fallback
This makes it possible to avoid more duplication when adding support for
a new board

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Piotr Dymacz fa36bea470 ramips: add support for UniElec U7628-01
UniElec U7628-01 is a router platform board based on MediaTek MT7628AN.
The device has the following specifications:

- MT7628AN (580MHz)
- 64/128/256 MB of RAM (DDR2)
- 8/16 MB of flash (SPI NOR)
- 5x 10/100 Mbps Ethernet (MT7628 built-in switch)
- 1x 2T2R 2.4 GHz Wi-Fi (MT7628)
- 1x miniPCIe slot (with PCIe and USB 2.0 buses)
- 1x miniSIM slot
- 1x microSD slot
- 1x USB 2.0 port
- 7x single-color LEDs (GPIO-controlled)
- 1x bi-color LED (green GPIO-controlled, red -> LED_WLAN# in miniPCIe)
- 1x reset button
- 1x UART header (4-pins)
- 1x SDXC/GPIO header (10-pins, connected with microSD slot)
- 1x DC jack for main power (12 V)

The following has been tested and is working:

- Ethernet switch
- miniPCIe slot (tested with modem and Wi-Fi card)
- miniSIM slot
- sysupgrade
- reset button
- USB 2.0 port*

Due to a missing driver (MMC over GPIO) this is not supported:

- microSD card reader

* Warning:
USB buses in miniPCIe and regular A-type socket are connected together,
without any proper analog switch or USB HUB.

Installation:

This board might come with a different firmware versions (MediaTek SDK,
PandoraBox, Padavan, etc.). If your board comes with PandoraBox, you can
install LEDE using sysupgrade. Just SSH to the router and perform forced
sysupgrade (due to a board name mismatch). The default IP of this board
should be: 192.168.1.1 and username/password: root/admin. In case of a
different firmware, you can use web based recovery described below.

Use the following command to perform the sysupgrade (for the 128MB
RAM/16MB flash version):

sysupgrade -n -F lede-ramips-mt76x8-u7628-01-128M-16M-squashfs-sysupgrade.bin

Recovery:

This board contains a Chinese, closed-source bootloader called Breed
(Boot and Recovery Environment for Embedded Devices). Breed supports web
recovery and to enter it, you keep the reset button pressed for around
5 seconds during boot. Your machine will be assigned an IP through DHCP
and the router will use IP address 192.168.1.1. The recovery website is
in Chinese, but is easy to use. Click on the second item in the list to
access the recovery page, then the second item on the next page is where
you select the firmware. In order to start the recovery, you click the
button at the bottom.

SDXC/GPIO header (J3):

 1. SDXC_D3  / I2C_SCLK
 2. SDXC_D2  / I2C_SD
 3. SDXC_D1  / I2S_DI
 4. SDXC_D0  / I2S_WS
 5. SDXC_CMD / I2S_CLK
 6. SDXC_CLK / GPIO0
 7. SDXC_CD  / UART_RXD1
 8. UART_TXD1
 9. 3V3
10. GND

Other notes:

1. The board is available with different amounts of RAM and flash. We
have only added support for the 128/16 MB configuration, as that seems
to be the default. However, all the required infrastructure is in place
for making support for the other configurations easy.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
7 years ago
Piotr Dymacz 46ab81e405 ramips: add support for UniElec U7621-06
UniElec U7621-06 is a router platform board based on MediaTek MT7621AT.
The device has the following specifications:

- MT7621AT (880 MHz)
- 256/512 MB of RAM (DDR3)
- 8/16/32/64 MB of FLASH (SPI NOR)
- 5x 1 Gbps Ethernet (MT7621 built-in switch)
- 1x ASMedia ASM1061 (for mSATA and SATA)
- 2x miniPCIe slots (PCIe bus only)
- 1x mSATA slot (with USB 2.0 bus for modem)
- 1x SATA
- 1x miniSIM slot
- 1x microSD slot
- 1x USB 3.0
- 12x LEDs (3 GPIO-controlled)
- 1x reset button
- 1x UART header (4-pins)
- 1x GPIO header (30-pins)
- 1x FPC connector for LEDs (20-pin, 0.5 mm pitch)
- 1x DC jack for main power (12 V)

The following has been tested and is working:

- Ethernet switch
- miniPCIe slots (tested with Wi-Fi cards)
- mSATA slot (tested with modem and mSATA drive)
- miniSIM slot
- sysupgrade
- reset button
- microSD slot

Installation:

This board might come with a different firmware versions (MediaTek SDK,
PandoraBox, Padavan, etc.). If your board comes with PandoraBox, you can
install LEDE using sysupgrade. Just SSH to the router and perform forced
sysupgrade (due to a board name mismatch). The default IP of this board
should be: 192.168.1.1 and username/password: root/admin. In case of a
different firmware, you can use web based recovery described below.

Use the following command to perform the sysupgrade (for the 256MB
RAM/16MB flash version):

sysupgrade -n -F lede-ramips-mt7621-u7621-06-256M-16M-squashfs-sysupgrade.bin

Recovery:

This board contains a Chinese, closed-source bootloader called Breed
(Boot and Recovery Environment for Embedded Devices). Breed supports web
recovery and to enter it, you keep the reset button pressed for around
5 seconds during boot. Your machine will be assigned an IP through DHCP
and the router will use IP address 192.168.1.1. The recovery website is
in Chinese, but is easy to use. Click on the second item in the list to
access the recovery page, then the second item on the next page is where
you select the firmware. In order to start the recovery, you click the
button at the bottom.

LEDs list (top row, left to right):

- LED_WWAN# (connected with pin 42 in LTE/mSATA slot)
- Power (connected directly to 3V3)
- CTS2_N (GPIO10, configured as "status" LED)
- TXD2 (GPIO11, configured as "led4", without default trigger)
- RXD2 (GPIO12, configured as "led5", without default trigger)
- LED_WLAN# (connected with pin 44 in wifi0 slot)

LEDs list (bottom row, left to right):

- ESW_P0_LED_0
- ESW_P1_LED_0
- ESW_P2_LED_0
- ESW_P3_LED_0
- ESW_P4_LED_0
- LED_WLAN# (connected with pin 44 in wifi1 slot)

Other notes:

1. The board is available with different amounts of RAM and flash. We
have only added support for the 256/16 MB configuration, as that seems
to be the default. However, all the required infrastructure is in place
for making support for the other configurations easy.

2. The manufacturer offers five different wireless cards with MediaTek
chipsets, based on MT76x2, MT7603 and MT7615. Images of the board all
show that the miniPCIe slots are dedicated to specific Wi-Fi cards.
However, the slots are generic.

3. All boards we got access to had the same EEPROM content. The default
firmware reads the Ethernet MAC from offset 0xe000 in factory partition.
This offset only contains 0xffs, so a random MAC will be generated on
every boot of the router. There is a valid MAC stored at offset 0xe006
and this MAC is shown as the WAN MAC in the bootloader. However, it is
the same on all boards we have checked. Based on information provided
by the vendor, all boards sold in small quantities are considered more
as samples for development purposes.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
7 years ago
Robert Marko d0ef27594a ramips: add support for TP-Link TL-WR840N v5
TP-Link TL-WR840N v5 is simple N300 router with 5-port FE switch and
non-detachable antennas, based on MediaTek MT7628NN (aka MT7628N) WiSoC.

Specification:

- MT7628N/N (580 MHz)
- 64 MB of RAM (DDR2)
- 4 MB of FLASH
- 2T2R 2.4 GHz
- 5x 10/100 Mbps Ethernet
- 2x external, non-detachable antennas
- UART (J1) header on PCB (115200 8n1)
- 1x LED (GPIO-controlled), 1x button

* LED in TL-WR840N v5 is a dual-color, dual-leads type which isn't
  (fully) supported by gpio-leds driver. This type of LED requires both
  GPIOs state change at the same time to select color or turn it off.
  For now, we support/use only the green part of the LED.
  Orange LED is registered so you can later use it for your own purposes.

  Flash instruction:

  Unlike TL-WR840N v4 flashing through WEB UI works in v5.
  1. Download lede-ramips-mt76x8-tl-wr840n-v5-squashfs-sysupgrade.bin image.
  2. Go to 192.168.0.1
  3. Flash the sysupgrade image through Firmware upgrade section of WEB UI.
  4. Wait until green LED stops flashing and use the router.

Notes:
TFTP recovery is broken since TP-Link reused bootloader code for v4 and
that does not take into account only 4 MB of flash and bricks the device.
So do not use TFTP Recovery or you will have to rewrite SPI flash.
They fixed it in later GPL code,but it is unknown which version of
bootloader you have.

After manually compiling and flashing bootloader from GPL sources TFTP
recovery works properly.

Signed-off-by: Robert Marko <robimarko@gmail.com>
7 years ago
Felix Fietkau c08293893a kernel: add support for limiting 4K erase sector support based on flash chip size
Some targets need 4K sectors for small flash chips (e.g. some
routerboards, where the entire chip is just one "erase block"), whereas
on other devices 4K sectors lead to horrible flash erase/write
performance.

Set the default limit in the generic kernel configuration to 4 MiB to
ensure that all new platforms don't use 4K sectors for bigger flash
chips. On all existing targets use 16 MiB for now to avoid regressions.
They will be changed individually in follow-up commits.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Alexander Couzens 2e1f73a79f
mt7620: image.mk: make elecom-header reproducible
elecom-header adds a timestamp dependency. Replace
the timestamps with SOURCE_DATE_EPOCH [0] variable.

[0] https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
7 years ago
Felix Fietkau 22d982ea00 ramips: add support for switching between 3-byte and 4-byte addressing on w25q256 flash
On some devices the flash chip needs to be in 3-byte addressing mode during
reboot, otherwise the boot loader will fail to start.
This mode however does not allow regular reads/writes onto the upper 16M
half. W25Q256 has separate read commands for reading from >16M, however
it does not have any separate write commands.
This patch changes the code to leave the chip in 3-byte mode most of the
time and only switch during erase/write cycles that go to >16M
addresses.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Edmunt Pienkowsky 9786b53efb ramips: fix Youku-YK1 support
Remove the ephy-pins from the ethernet device tree node. The ephy-pins
are useed to controll the ePHY LEDs and this board doesn't have these.
Instead one of the ePHY pins is used in GPIO mode to control the WAN
LED.

Use the switch LED trigger to control the WAN LED. Move the power LED
handling to diag.sh to show the boot status via this LED.

Add the missing kernel packages for USB and microSD card reader to the
default package selection.

Fix the maximum image size value. The board has a 32MByte flash chip.

Fixes: FS#1055

Signed-off-by: Edmunt Pienkowsky <roed@onet.eu>
[make the commit message more verbose, remove GPIO pinmux for pins not
used as GPIOs]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Kevin Darbyshire-Bryant bca01fddb3 ramips: remove erroneous "wdt rst" DTS entries
Remove reference to pinmux group "wdt rst" on EW1200, ZBT-WG2626 and
ZBT-WG3526 devices. "wdt rst" is a pinmux function and not a pinmux
group.

Fixes the following error message during boot:

  rt2880-pinmux pinctrl: invalid group "wdt rst" for function "gpio"

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
7 years ago
Mathias Kresin dcf62cb24e ramips: don't enable usb for the WT3020-4M
That device does not have a USB port. It as the same board as the
WT3020-8M, but without soldered USB port port. Also the case lacks the
opening for the port.

Reported-by: Alberto Bursi <alberto.bursi@outlook.it>
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Alberto Bursi 1f7f24bfb9 ramips: fix default usb support for nexx wt3020-8M
the nexx wt3020-8M has a usb 2.0 port,
add usb 2.0 support packages to its default package list.

Signed-off-by: Alberto Bursi <alberto.bursi@outlook.it>
7 years ago
Kevin Darbyshire-Bryant 886d66abcd kernel: bump 4.9 to 4.9.57
Refresh patches.
Compile-tested for ar71xx - Archer C7 v2
Runtime-tested on  ar71xx - Archer C7 v2

Fixes the following CVEs:

- CVE-2017-7518
- CVE-2017-0786
- CVE-2017-1000255
- CVE-2017-12188
- CVE-2017-15265

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
7 years ago
Felix Fietkau fe3c3aed44 ramips: fix typo in MT7621 NAND driver
Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Daniel Kucera 6f008af3f0 ramips: add support for Kimax U25AWF-H1
Kimax U-25AWF-H1 is is a 2,5" HDD Enclosure with Wi-Fi/Eth conection
and battery, based on MediaTek MT7620A.

Patch rewritten from: https://forum.openwrt.org/viewtopic.php?pid=305643

Specification:

- MT7620A CPU
- 64 MB of RAM
- 16 MB of FLASH
- 802.11bgn WiFi
- 1x 10/100 Mbps Ethernet
- USB 2.0 Host
- UART for serial console

Flash instruction:
1. Download lede-ramips-mt7620-u25awf-h1-squashfs-sysupgrade.bin
2. Open webinterface a upgrade
3. After boot connect via ethernet to ip 192.168.1.1

Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
[fix reset button gpio, don't add a lan/wan vlan config for single
port board, add -H1 suffix do make sure that this revision of the
board is supported/tested]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Alexander Couzens b73986a826
ramips/mt76x8: add initramfs support for tplink 841n v13
The tplink 841n v13 requires an tplink v2 image header in
front of an initramfs image.

To boot an initramfs image:
- break the uboot by holding the '4' key
- setup your tftp server 192.168.0.255
- tftp 81000000 lede-ramips-mt76x8-tl-wr841n-v13-initramfs-kernel.bin
- bootm

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
7 years ago
Stijn Tintel f12c42940d kernel: bump 4.9 to 4.9.54
Refresh patches.
Remove upstreamed patches:
- ramips/0067-enable-mt7621-xhci.patch
- ramips/0085-pinmux-util.patch
- ramips/301-fix-rt3883.patch

Compile-tested on brcm2708/bcm2708, octeon, ramips/mt7621, x86/64.
Runtime-tested on brcm2708/bcm2708, octeon, ramips/mt7621, x86/64.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years ago
Stijn Tintel f625df7ab8 kernel: update 4.9 to 4.9.53
Refresh patches.
Compile-tested on brcm2708/bcm2708, octeon and x86/64.
Runtime-tested on brcm2708/bcm2708, octeon and x86/64.

Fixes the following CVEs:
- CVE-2017-1000252
- CVE-2017-12153
- CVE-2017-12154

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years ago
Thibaut VARÈNE 254061ee97 build: add mktplinkfw2 hardcoded values to makefile
This patch adds all the board-specific values currently hardcoded
in mktplinkfw2.c back to the respective device declarations in the
makefiles.

The rationale is to avoid modifying the source code every time a
new board or board variant is added.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
7 years ago
Sergey Ryazanov c9f66b1eb9 ramips: keep Archer C20 Power LED On during boot
Keep Archer C20 Power LED in the same state as it was configured by
bootloader (keep it hightlighed) to avoid unexpectable LED turning off
during kernel boot.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
7 years ago
Rosen Penev dcdc2880b6 ramips: reduce napi_weight in the ethernet driver.
Currently dmsg a weight of 128 which is above the kernel limit of 64. Silence the warning.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years ago
Roman Yeryomin bcb89fcca8 ramips: mt7621: add MT29F2G08ABAE NAND flash support
Signed-off-by: Roman Yeryomin <roman@advem.lv>
7 years ago
Kevin Darbyshire-Bryant f2107fc328 ramips: improve Xiaomi Mi Router 3G support
This commit improves support for the Xiaomi Mi Router 3G originally
added in commit 6e283cdc0d

Improvements:

- Remove software watchdog as hardware watchdog now working as per
  commit 3fbf3ab44f for all mt7621
  devices.

- Reset button polarity corrected - length of press determines reboot
  (short press) vs. reset to defaults (long press) behaviour.

- Enable GPIO amber switch port LEDs on board rear - lit indicates 1Gbit
  link and blink on activity.  Green LEDs driven directly by switch
  indicating any link speed and tx activity.

- USB port power on/off GPIO exposed as 'usbpower'

- Add access to uboot environment settings for checking/setting uboot
  boot order preference from user space.

Changes:

- Front LED indicator is physically made of independent Yellow/Amber,
  Red & Blue LEDs combined via a plastic 'lightpipe' to a front panel
  indicator, hence the colour behaviour is similar to an RGB LED. RGB
  LEDs are not supported at this time because they produce colour results
  that do not then match colour labels, e.g. enabling 'mir3g:red' and
  'mir3g:blue' would result in a purple indicator and we have no such
  label for purple.
  The yellow, red & blue LEDs have been split out as individual yellow,
  red & blue status LEDs, with yellow being the default status LED as
  before and with red's WAN and blue's USB default associations removed.

- Swapped order of vlan interfaces (eth0.1 & eth0.2) to match stock vlan
  layout. eth0.1 is LAN, eth0.2 is WAN

- Add 'lwlll' vlan layout to mt7530 switch driver to prevent packet
  leakage between kernel switch init and uci swconfig

uboot behaviour & system 'recovery'

uboot expects to find bootable kernels at nand addresses 0x200000 &
0x600000 known by uboot as "system 1" and "system 2" respectively.
uboot chooses which system to hand control to based on 3 environment
variables: flag_last_success, flag_try_sys1_failed & flag_try_sys2_failed

last_success represents a preference for a particular system and is set
to 0 for system 1, set to 1 for system 2.  last_success is considered *if*
and only if both try_sys'n'_failed flags are 0 (ie. unset) If *either*
failed flags are set then uboot will attempt to hand control to the
non failed system. If both failed flags are set then uboot will check
the uImage CRC of system 1 and hand control to it if ok.  If the uImage
CRC of system is not ok, uboot will hand control to system 2
irrespective of system 2's uImage CRC.

NOTE: uboot only ever sets failed flags, it *never* clears them. uboot
sets a system's failed flag if that system's was selected for boot but
the uImage CRC is incorrect.

Fortunately with serial console access, uboot provides the ability to
boot an initramfs image transferred via tftp, similarly an image may
be flashed to nand however it will flash to *both* kernels so a backup
of stock kernel image is suggested. Note that the suggested install
procedure below set's system 1's failed flag (stock) thus uboot ignores
the last_success preference and boots LEDE located in system 2.

Considerable thought has gone into whether LEDE should replace both
kernels, only one (and which one) etc. LEDE kernels do not include a
minimal rootfs and thus unlike the stock kernel cannot include a
method of controlling uboot environment variables in the event of
rootfs mount failure. Similarly uboot fails to provide an external
mechanism for indicating boot system failure.

Installation - from stock.

Installation through telnet/ssh:
- copy lede-ramips-mt7621-mir3g-squashfs-kernel1.bin and
  lede-ramips-mt7621-mir3g-squashfs-rootfs0.bin to usb disk or wget it
  from LEDE download site to /tmp
- switch to /extdisks/sda1/ (if copied to USB drive) or to /tmp if
  wgetted from LEDE download site
- run: mtd write lede-ramips-mt7621-mir3g-squashfs-kernel1.bin kernel1
- run: mtd write lede-ramips-mt7621-mir3g-squashfs-rootfs0.bin rootfs0
- run: nvram set flag_try_sys1_failed=1
- run: nvram commit
- run: reboot

Recovery - to stock.

Assuming you used the above installation instructions you will have a
stock kernel image in system 1. If it can be booted then it may be used
to perform a stock firmware recovery, thus erasing LEDE completely. From
a 'working' LEDE state (even failsafe)

Failsafe only:
- run: mount_root
- run: sh /etc/uci-defaults/30_uboot-envtools
Then do the steps for 'All'

All:
- run: fw_setenv flag_try_sys2_failed 1
- run: reboot

The board will reboot into system 1 (stock basic kernel) and wait with
system red light slowly blinking for a FAT formatted usb stick with a
recovery image to be inserted.  Press and hold the reset button for
around 1 second. Status LED will turn yellow during recovery and blue
when recovery complete.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
7 years ago
Zoltan Gyarmati 6a5b62f503 ramips: RT5350F-OLINUXINO: enable ttyS1
The RT5350F's second UART pins are available on the base module and on
the EVB as well, so enable it in the device tree.
 In order to keep the origian serial port numbering (ttyS0 is the serial
console), aliases added for the UART devices.

Signed-off-by: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>
7 years ago
Zoltan Gyarmati 9d8d3d4501 ramips: RT5350F-OLINUXINO: enable i2c
The RT5350F i2c pins is available on the base module and on
the EVB as well, so enable it in the dts.

Signed-off-by: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>
7 years ago
Zoltan Gyarmati c1d19b107b ramips: RT5350F-OLINUXINO: invert WiFi LED polarity
The polarity of WLAN_ACT LED on the base module needs to inverted
in order to be 'on' when the WiFi interface is active

Signed-off-by: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>
7 years ago
Zoltan Gyarmati 862b820f15 ramips: introduce RT5350F-OLINUXINO.dtsi
The RT5350F-OLINUXINO(-EVB).dts files' content are nearly the same, so to avoid
code duplication this patch creates RT5350F-OLINUXINO.dtsi file which
covers the base board's features. The corresponding RT5350F-OLINUXINO.dts
just includes the new .dtsi and the RT5350F-OLINUXINO-EVB.dts adds the EVB
specific GPIO config.

Signed-off-by: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>
7 years ago
Kevin Darbyshire-Bryant fd6bf05548 ramips: add 'lwlll' portmap to mt7530 switch
The Xiaomi Mi Router 3G uses this deranged vlan portmap. Add support so
that packets are not leaked across all switch ports when reset.

Fix a whitespace nit while we're here.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
[fix wrong pvids order]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Kevin Darbyshire-Bryant 972c126eb6 ramips: mt7621: fix failsafe mode networking
Disable VLANs on mt7621 boards with mt7530 switches on failsafe entry.

Allows failsafe networking to work correctly.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
[fixed default case syntax error]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Kevin Darbyshire-Bryant 3fbf3ab44f ramips: fix missing mediatek wdt
mediatek MT7621 soc watchdog DTS id was renamed from "mtk,mt7621-wdt" to
"mediatek,mt7621-wdt" when driver upstreamed to kernel 4.5

Update mt7621.dtsi & mt7628an.dtsi definitions to match upstreamed
kernel.

Restores hardward watchdog functionality on mt7621 devices under linux
4.9

Tested on: MIR3G

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
7 years ago
Stijn Tintel 6e48eb22b8 kernel: update 4.9 to 4.9.51
Refresh patches.
Compile-tested on octeon and x86/64.
Runtime-tested on octeon and x86/64.

Fixes the following CVEs:
- CVE-2017-14106
- CVE-2017-14497

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years ago
Jiawei Wang 9c500db896 ramips: fix used MAC addresses for Phicomm K2P
The factory partition of the Phicomm K2P contains two MAC addresses.
The lower MAC address is at offset 0xe006 and the higher one is at
offset 0xe000.

Use the lower MAC address as base mac-address which the switch driver
increments by one for the second (wan) vlan.

The MAC addresses are still inverted in contrast to the stock firmware
where the lower MAC address is used for wan. But at least the use of a
MAC address not intended/reserved for this particular board is fixed.

Signed-off-by: Jiawei Wang <me@jwang.link>
7 years ago
Kristian Evensen 133815ad8f ramips: fix D240 mini-PCIe power control GPIOs
In commit b11c51916c ("ramips: Improve Sanlinking D240 config") I made
a mistake with regards GPIO numbering. And in addition to specifying the
wrong GPIO for controling the power of one of the mini-PCIe, I recently
discovered that the power of both slots can be controlled.

This patch specifies the correct GPIO for the left-most mini-PCIe slot
of the D240 (labeled power_mpcie2 since the slot is attached to SIM2),
and adds a GPIO that can be used to control the power of the other
mini-PCIe slot (labeled power_mpcie1).

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
[do not use the gpio active macros for the gpio-export value]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Maxim Anisimov 161a3be5ad ramips: add support for TP-Link Archer C20 v1
TP-Link Archer C20 v1 is a router with 5-port FE switch and
non-detachable antennas. It's very similiar to TP-Link Archer C50.
Also it's based on MediaTek MT7620A+MT7610EN.

Specification:
- MediaTek MT7620A (580 Mhz)
- 64 MB of RAM
- 8 MB of FLASH
- 2T2R 2.4 GHz and 1T1R 5 GHz
- 5x 10/100 Mbps Ethernet
- 2x external, non-detachable antennas
- UART (J1) header on PCB (115200 8n1)
- 8x LED (GPIO-controlled*), 2x button, power input switch
- 1 x USB 2.0 port

* WAN LED in this devices is a dual-color, dual-leads type which isn't
  (fully) supported by gpio-leds driver. This type of LED requires both
  GPIOs state change at the same time to select color or turn it off.
  For now, we support/use only the blue part of the LED.
* MT7610EN ac chip isn't not supported by LEDE. Therefore 5Ghz won't
  work.

Factory image notes:

These devices use version 3 of TP-Link header, fortunately without RSA
signature (at least in case of devices sold in Europe). The difference
lays in the requirement for a non-zero value in "Additional Hardware
Version" field. Ideally, it should match the value stored in vendor
firmware header on device.

We are able to prepare factory firwmare file which is accepted and
(almost) correctly flashed from the vendor GUI. As it turned out, it
accepts files without U-Boot image with second header at the beginning
but due to some kind of bug in upgrade routine, flashed image gets
corrupted before it's written to flash. So, to flash this device we must
to prepare image using original firmware from tp-link site with uboot.

Flash instruction:

Until (if at all) TP-Link fixes described problem, the only way to flash
LEDE image in these devices is to use tftp recovery mode in U-Boot.
There are two ways to flash the device to LEDE:

1) Using tftp mode with UART connection and original LEDE image

 - Place lede-ramips-mt7620-ArcherC20-squashfs-factory.bin in tftp
   server directory
 - Configure PC with static IP 192.168.0.66/24 and tftp server.
 - Connect PC with one of LAN ports, power up the router and press
   key "4" to access U-Boot CLI.
 - Use the following commands to update the device to LEDE:

    setenv serverip 192.168.0.66
    tftp 0x80060000 lede-ramips-mt7620-ArcherC20-squashfs-factory.bin
    erase tplink 0x20000 0x7a0000
    cp.b 0x80060000 0x20000 0x7a0000
    reset

 - After that the device will reboot and boot to LEDE

2) Using tftp mode without UART connection but require some
   manipulations with target image

 - Download and unpack TP-Link Archer C20 v1 firmware from original web
   site
 - Split uboot.bin from original firmware by this command (example):

    dd if=Archer_C20v1_0.9.1_4.0_up_boot(160427)_2016-04-27_13.53.59.bin of=uboot.bin bs=512 count=256 skip=1

 - Create ArcherC20V1_tp_recovery.bin using this command:

    cat uboot.bin lede-ramips-mt7620-ArcherC20-squashfs-factory.bin > ArcherC20V1_tp_recovery.bin

 - Place ArcherC20V1_tp_recovery.bin in tftp server directory.
 - Configure PC with static IP 192.168.0.66/24 and tftp server.
 - Connect PC with one of LAN ports, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
 - Router will download file from server, write it to flash and reboot.

Signed-off-by: Maxim Anisimov <maxim.anisimov.ua@gmail.com>
7 years ago
David Yang fb128057da ramips: fix hg255d LED status support
Use the green power LED for boot status indication.

Source: https://my.oschina.net/osbin/blog/278782 Para 3

Signed-off-by: David Yang <mmyangfl@gmail.com>
7 years ago
Kristian Evensen 79440ea756 ramips: Add support for ZBT WE1026-5G
The ZBT WE1026-5G
(http://www.zbtlink.com/products/router/WE1026-5G.html) is the follow-up
to the ZBT WE1026 and is based on MT7620. For the previous WE1026, the
ZBT WE826 image could be used. However, as the name implies, the -5G
comes equipped with a 5GHz wifi radio. As the WE826 only has a 2.4GHz
radio, the addition of 5GHz means that a separate image is needed for
the WE1026-5G. I suspect that this image will also work on the previous
WE1026, but I don't have a device to test with.

The WE1026-5G has following specifications:
* CPU: MT7620A
* 1x 10/100Mbps Ethernet.
* 16 MB Flash.
* 64 MB RAM.
* 1x USB 2.0 port.
* 1x mini-PCIe slots.
* 1x SIM slots.
* 1x 2.4Ghz WIFI.
* 1x 5GHz wifi (MT7612)
* 1x button.
* 3x controllable LEDs.

Works:
* Wifi.
* Switch.
* mini-PCIe slot. Only tested with a USB device (a modem).
* SIM slot.
* Sysupgrade.
* Button (reset).

Not working:
* The 5GHz WIFI LED is completely dead. I suspect the issue is the same
as on other devices with Mediatek 5Ghz wifi-cards/chips. The LED is
controlled by the driver, and mt76 (currently) does not support this.

Not tested:
* SD card reader.

Notes:
* The modem (labeled 3G/4G) and power LEDs are controlled by the
hardware.
* There is a 32MB version of this device available, but I do not have
access to it. I have therefor only added support for the 16MB version,
but added all the required infrastructure to make adding support for the
32MB version easy.

Installation:
The router comes pre-installed with OpenWRT, including a variant of
Luci. The initial firmware install can be done through this UI,
following normal procedure. I.e., access the UI and update the firmware
using the sysupgrade-image. Remember to select that you do not want to
keep existing settings.

Recovery:
If you brick the device, the WE1026-5G supports recovery using HTTP. Keep the
reset button pressed for ~5sec when booting to start the web server. Set the
address of the network interface on your machine to 192.168.1.2/24, and
point your browser to 192.168.1.1 to access the recovery UI. From the
recovery UI you can upload a firmware image.

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
7 years ago
Rosen Penev 6aa46bf05e ramips: Change ethernet driver to use napi_complete_done.
Backport of mailine linux commit. Speeds up ethernet slightly and reduces latency.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years ago
Thibaut VARENE 991681cf49 ramips: Archer C50v1: support US and EU versions
For the Archer C50v1, the EU and US versions are differentiated by their
respective HW additional version (0x0 for US, 0x2 for EU).

The stock web interface checks this field before flashing, making it
impossible to flash the current (US) factory image on EU hardware.

However the bootloader does not check this field, making it possible to use
a single sysupgrade image for both hardware.

This patch adds the necessary build bits to generate both EU and US factory
images, and renames the target as "Archer C50v1" since there are as of now
3 different versions of Archer C50 (all with different CPUs).

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Kristian Evensen 80829022b0 ramips: add support for the HNET C108
The HNET C108
(http://www.szhwtech88.com/Product-product-cid-100-id-4374.html) is a
mifi based on MT7602A, which has the following specifications:

* CPU: MT7620A
* 1x 10/100Mbps Ethernet.
* 16 MB Flash.
* 64 MB RAM.
* 1x USB 2.0 port. Only power is connected, this port is meant for
charging other devices.
* 1x mini-PCIe slots.
* 1x SIM slots.
* 1x 2.4Ghz WIFI.
* 1x button.
* 6000 mAh battery.
* 5x controllable LEDs.

Works:
* Wifi.
* Switch.
* mini-PCIe slot. Only tested with a USB device (a modem).
* SIM slot.
* Sysupgrade.
* Button (reset).

Not working (also applies to the factory firmware):
* Wifi LED. It is always switched on, there is no relation to the
up/down state or activity of the wireless interface.

Not tested:
* SD card reader.

Notes:
* The C108 has no dedicated status LED. I therefore set the LAN LED as
status LED.

Installation:
The router comes pre-installed with OpenWRT, including a variant of
Luci. The initial firmware install can be done through this UI,
following normal procedure. I.e., access the UI and update the firmware
using the sysupgrade-image. Remember to select that you do not want to
keep existing settings.

Recovery:
If you brick the device, the C108 supports recovery using TFTP. Keep the
reset button pressed for ~5sec when booting to trigger TFTP. Set the
address of the network interface on your machine to 10.10.10.3/24, and
rename your image file to Kernal.bin.

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
7 years ago
Kristian Evensen f3b4e50cee ramips: fix default LED configuration
Commit 77645ffcd9 ("ramips: add support for the GnuBee Personal Cloud
One") dropped the execution permission from 01_leds with the result
that the file isn't started during first boot and no default LED
configuration is added.

Revert the introduced file permission change.

Fixes: FS#979

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
[cherry picked the fix from a board support patch]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
John Crispin 5117911d91 ramips: fix mt76x8 dependencies
The commit merging mt7628 and mt7688 failed to update some
dependencies.

Signed-off-by: John Crispin <john@phrozen.org>
7 years ago
Thibaut VARENE 2b3ab0208e ramips: provide get_port_stats() on mt7530/762x switches
This patch provides a generic switch_dev_ops 'get_port_stats()' callback by
taping into the relevant port MIB counters.

This callback is used by swconfig_leds led trigger to blink LEDs with port
network traffic.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
L. D. Pinney 3e36ca4b43 ramips: merge mt7628/mt7688 into mt76x8
The ramips subtargets of mt7628 and mt7688 dts files all #include "mt7628an.dtsi"

They are essentially a single subtarget.

This patch merges the ramips subtargets mt7628 and mt7688 into a single subtarget mt76x8.

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
7 years ago
Koen Vandeputte 40213cc154 kernel: update 4.9 to 4.9.45
Refreshed all patches

Compiled & run-tested on targets: cns3xxx, imx6

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
7 years ago
John Crispin a3f52f6165 ramips: refresh kernel patches
the reordering patch fixes random kernel hangs. bug/fix was reported by MTK/WCN.

Signed-off-by: John Crispin <john@phrozen.org>
7 years ago
John Crispin 5c971cd6fd ramips: make mt7621 select WEAK_REORDERING_BEYOND_LLSC
Signed-off-by: John Crispin <john@phrozen.org>
7 years ago
L. D. Pinney e9eb6e7bb3 ramips: set ethernet mac address for VoCore2
This patch sets the mac address for the VoCore2 devices.

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
7 years ago
Pavel Kubelun 6e283cdc0d ramips: add Xiaomi Mi Router 3G support
This commit adds support for Xiaomi Mi WiFi Router 3G.

Short specification:
 - MT7621AT + MT7603EN + 7612EN
 - 256MB DDR3 RAM
 - 128MB NAND flash
 - 1+2 x 1000M Ethernet
 - 1x USB 3.0 port
 - reset button
 - yellow, blue, red leds

Installation through telnet/ssh:
- copy lede-ramips-mt7621-mir3g-squashfs-kernel1.bin and
lede-ramips-mt7621-mir3g-squashfs-rootfs0.bin to usb disk or wget it
from LEDE download site to /tmp
- switch to /extdisks/sda1/ (if copied to USB drive) or to /tmp if
wgetted from LEDE download site
- run: mtd write lede-ramips-mt7621-mir3g-squashfs-kernel1.bin kernel1
- run: mtd write lede-ramips-mt7621-mir3g-squashfs-rootfs0.bin rootfs0
- run: mtd erase kernel0
- run: reboot

Originally stock firmware has following partitions:
 - ...
 - kernel0 (primary kernel image)
 - kernel1 (secondary kernel image, used by u-boot in failsafe routine)
 - rootfs0 (primary rootfs)
 - rootfs1 (secondary rootfs in case primary fails)
 - overlay (used as ubi overlay)

This commit squashes rootfs0, rootfs1 and overlay partitions into 1, so
it can be used by LEDE fully for package installation, resulting in 117,5MiB.

This device lacks hw watchdog, so adding softdog instead (stock does the same).

Signed-off-by: Pavel Kubelun <be.dissent@gmail.com>
7 years ago
Stijn Tintel 2d02a4f5bd kernel: update 4.9 to 4.9.44
Refresh patches.
Adapt 704-phy-no-genphy-soft-reset.patch.
Remove brcm2708/950-0005-mm-Remove-the-PFN-busy-warning.patch.
Compile-tested on brcm2708/bcm2708 and x86/64.
Runtime-tested on brcm2708/bcm2708 and x86/64.

Fixes the following vulnerabilities:
- CVE-2017-7533
- CVE-2017-1000111
- CVE-2017-1000112

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years ago
L. D. Pinney df3295f50e ramips: add support for the VoCore2 Lite
The VoCore2 Lite uses the same PCB as the Vocore2.
This patch moves the common VoCore2 parts into dtsi.

Removed memory node in the device tree source file.
Memory is detected automatically.

http://vocore.io/
http://vonger.net/
http://vonger.cn/

Specifications:
- SoC: MediaTek MT7688AN
- RAM: 64MB DDR2 EtronTech EM68B16CWQH-25H
- Flash: 8MB NOR SPI Flash GigaDevice GD25Q64CWIG
- Wireless: Built into MT7688AN with onboard IPEX connector

Firmware installation:
- VoCore2-Lite ships with firmware forked from OpenWrt.
- Installation from the bootloader is recommended.
- If using luci/sysupgrade use the -n option (do not keep settings)
  original firmware uses a modified proprietary MediaTek wireless driver.
- The wireless is disabled by default in LEDE.
- If reverting to factory firmware using the bootloader is recommended.

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
Tested by: Noble Pepper <noblepepper@gmail.com>
7 years ago
Mathias Kresin 8c9f847a80 ramips: fix WHR-1166D WAN port
By adding the ICPlus IP1001 phy driver an already set RGMII delay mode
is reset during driver load.

Set the rgmii rx delay to fix corrupt/no packages in case the WAN port
negotiates to 1000MBit.

Fixes: FS#670

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Thibaut VARENE 370aacf532 ramips: ArcherC50v1: fix wlan2g MAC address
By default the wlan eprom contains the generic ralink MAC which is not
the vendor (TP-Link) one. Based on OFW bootlog, it appears that addresses
are decremented from the ethernet MAC.

This patch fixes the MAC address for wlan2g in line with OFW.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Qin Wie de350550ef ramips: fix cd-poll sd card remove randomly
Fix when add 'mediatek,cd-poll' to dts cause the sd card be removed randomly.
Special for the device without card-detect pin.

Signed-off-by: Qin Wie <me@vonger.cn>
7 years ago
Mathias Kresin 313ce3afbb ramips: move common parts into dtsi
Move the common parts of boards with multiple flash size variants into
dtsi files.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
L. D. Pinney 70b192f573 ramips: update device tree source files
Use the GPIO dt-bindings macros and add compatible strings in the
ramips device tree source files.

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Thibaut VARENE 695f5ea85a ramips: Add support for Netgear EX3800
The Netgear EX3800 is essentially an EX3700 with a mains output socket.

Both devices use the exact same firmware image (original firmware is named
EX3700-EX3800-version.chk).

This patch adds suport by renaming the EX3700 device to EX3700/EX3800 and
updating the necessary glue.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Thibaut VARENE 8a13895a2e ramips: EX3700: rename factory.bin to factory.chk
The stock firmware upgrade interface requires the file to end with a .chk
extension.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Thibaut VARENE 1780d40f2b ramips: cleanup EX2700 and WN3000RPv3 LEDs
This patch cleans up the WN3000RPv3 and EX2700 setup, bringing it in line
with other similar devices:

The power led is a bicolor one. The bootloader brings the red side on at
powerup.

Instead of blinking the red side in diag.sh and need to forcefully turn it off
in 01_leds, this patch simplifies the setup by relying on the default off state
of the gpio-led driver for the red side and blinking the green side as with
other devices.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Mathias Kresin 419fa7a15f ramips: cleanup AsiaRF AWM002 eval board support
Cleanup the dtsi files and remove one layer of dtsi. Set the size of
the firmware partition to a value matching the flash size from the
board (variant) name.

Remove the usb led trigger. There is neither a default config for the
usb led trigger nor a LED for usb activity indication.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin b82ac84229 ramips: drop AsiaRF AWM003 eval board
Everything is identical to the AWM002 8m eval board. No need to
duplicate it once more.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 861b867d9c ramips: fix Omnima MiniEMBWiFi image
Reference the Omnima MiniEMBWiFi device tree source file in the image
build code. Otherwise the dts of the image processed before is used.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin afc1ccf955 ramips: build HuaWei HG255D image
The code to build an image was disabled some time ago for unknown
reasons albeit the image looks fine.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 60f6c2b2eb ramips: drop Edimax BR-6425 support
Code to build an image for the Edimax BR-6425 never existed.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 1eb1916c5f ramips: add missing partitions
The partitions were lost during migration to device tree.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Ilya Katsnelson bb4d5006c0 ramips: fix PCI init on MT7620 with Linux 4.9+
So, this is kind of complicated. This has been upstream for a while,
imported from OpenWRT/LEDE with some cleanups. LEDE ramips has stayed
on linux-4.4 this whole time, with the old(er) version of the patch
that had correct behavior[0], while upstream got changed[1].

When LEDE updated to kernel 4.9, the older version of the code from
the patch got replaced with the upstream version containing the bug.

The original behavior, however, seems to be correct here, as the
official programming guide[2] indicates that bit 31 (PDRV_SW_SET)
in register PPLL_CFG1 is reserved, but bit 23 (added as PPLL_LD)
is the PPLL lock state (which also happens to line up with the
error message).

The original confusion probably comes from the double definition
of PDRV_SW_SET[3, 4] in the upstream code, with one correct definition
(31) and one incorrect one (23).

I've also used the opportunity to clean up the error message a bit -
it's still not really helpful to anyone who doesn't already know what
the PPLL is, but at least it's slightly more readable now.

This will probably need to be upstreamed as well, since with the way
it's currently set up, it's unlikely PCI ever worked for anyone who's
running an upstream kernel on that SoC.

[0]: 05d6e92594/target/linux/ramips/patches-4.4/0009-PCI-MIPS-adds-mt7620a-pcie-driver.patch (L259)
[1]: 026d15f6b9/arch/mips/pci/pci-mt7620.c (L246)
[2]: http://www.anz.ru/files/mediatek/MT7620_ProgrammingGuide.pdf
[3]: 026d15f6b9/arch/mips/pci/pci-mt7620.c (L36)
[4]: 026d15f6b9/arch/mips/pci/pci-mt7620.c (L39)

Signed-off-by: Ilya Katsnelson <me@0upti.me>
7 years ago
Thibaut VARENE a6f6f8df23 ramips: Archer C50v1: fix power led
01_leds had a workaround for the power led to compensate for the
inverted GPIO state. This patch was missing from my previous commit.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
[add the power led default-state which was omitted in the last commit
by me]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Thibaut VARENE 5d7e23f5ad ramips: Archer C50v1: fix switch port numbering
Luci shows switch ports in wrong order on that device.
This patch fixes switch port numbering and matches them to the device
silkscreen.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Thibaut VARENE 0c81bc2969 ramips: Archer C50v1: fix LEDs active levels
All LEDs GPIOs are active low on this device.

WAN and POWER states were inverted. Add default state for power.

Tested on Archer C50v1.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Mathias Kresin 99f1097c0a ramips: fix Mercury MAC1200R v2.0 board name
With d2b6bf1416 ("ramips: fix image validation errors") the board
name was changed to fix an image validation error. But this change
wasn't applied to all other files using the board name, which broke
sysupgrade.

Revert this change and use the former board name in the metadata
instead.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
L. D. Pinney 45dbd65850 ramips: mt7621: add compatible strings
Add compatible strings to all mt7621 based device tree source files to
fix formal issues.

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
7 years ago
Mathias Kresin 0a17d2970a ramips: add NULL clock fix send upstream
Make the behaviour of clk_get_rate consistent with common clk's
clk_get_rate by accepting NULL clocks as parameter. Some device
drivers rely on this, and will cause an OOPS otherwise.

Fixes: FS#735

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin 7985bf23ef ramips: drop stray kernel 4.4 configs
The kernel 4.4 patches where already removed with the bump to 4.9. Drop
the the subtarget configs as well.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Oliver Fleischmann a92c64e8ae ramips: add support for Loewe WMDR-143N
The WMDR-143N is a small module originally used as a Wifi client
in some Loewe smart TV sets. It is sold cheaply at german surplus
shops. The module contains a RT3662 SOC.

Specifications:

- 500 MHz CPU Clock
- 1x 10/100Mbps Ethernet (pin header)
- 32 MB of RAM
- 8 MB of FLASH
- 2T3R 2.4/5 GHz (SOC internal)
- 3 Antennas on PCB
- UART pads on PCB (J3: 1 = +3.3V, 2 = RX, 3 = TX, 4 = GND), TX
  and RX are 3,3V only! The square hole is pin 1
- Power supply pads on PCB (J6: 1 and 2 = +5V, 3 and 4 = GND)
  The square hole is pin 1

The original firmware has two identical kernel/rootfs images and
two "Factory" calibration data blocks in flash. The LEDE image
leaves only the first "Factory" block in place and uses both
"Kernel" blocks and the redundant "Factory" block together to gain
enough space for the jffs2 partition.

Flash instructions:

You need UART and Ethernet connections to flash the board. Use
the LEDE "sysupgrade.bin" image with tftp.

Apply power to the board and in the first 5 seconds, hit 2 to
select TFTP upload. The bootloader asks for board- and server IP
addresses and filename.

Alternate method: With the vendor firmware running, assign an IP
address to the ethernet port, tftp the firmware image to
/tmp and write to mtd4 ("KernelA").

Signed-off-by: Oliver Fleischmann <ogf@bnv-bamberg.de>
[remove pinctrl node from dts, no pin is used as GPIO]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin a3995a6785 ramips: pinctrl: return proper error if pinctrl0 is empty
Children of the pinctrl0 node are optional. Return EINVAL (=missing)
instead of 0. Fixes a hang if the pinctrl0 has no children.

Signed-off-by: Mathias Kresin <dev@kresin.me>
Acked-by: John Crispin <john@phrozen.org>
7 years ago
John Crispin 9551d91b1d ramips: refresh the rcu_sched patch and remove debug info
Signed-off-by: John Crispin <john@phrozen.org>
7 years ago
John Crispin 6acb53c526 ralink: fix rcu_sched stalls on mt7621
there were 2 bugs
*) core1 came up with a bad bogo mips, looks like the clock needed time to stabilize
*) HPT frequency was not set making r4k timers not come up properly

Signed-off-by: John Crispin <john@phrozen.org>
7 years ago
L. D. Pinney 77645ffcd9 ramips: add support for the GnuBee Personal Cloud One
The GnuBee Personal Cloud One crowdfunded on https://www.crowdsupply.com
    It is a low-cost, low-power, network-attached storage device.

    Specifications:

    - SoC: MediaTek MT7621AT
    - RAM: DDR3 512 MB
    - Flash: 32 MB
    - Six SATA ports for 2.5" Drives
    - One micro SDcard
    - One USB 3.0
    - Two USB 2.0
    - Gigabit Ethernet: 1 x WAN and 1 x LAN
    - UART 3.5mm Audio Jack or 3 pin header - 57600 8N1
    - Four GPIOs available on a pin header

    Flash instructions:

    The GnuBee Personal Cloud One ships with libreCMC installed.
    libreCMC is a Free Software Foundation approved fork of LEDE/OpenWrt.
    As such one can upgrade using the webinterface or sysupgrade.

    Das U-Boot has multiple options for recovery or updates including :

    - USB
    - http
    - tftp

Signed-off-by: L. D. Pinney <ldpinney@gmail.com>
[use switchdev led trigger, all interfaces are in vlan1; rename leds
according to board.d setting; remove ge2 group from the pinmux, this
group doesn't exist in the driver]
Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Thibaut VARENE 4faf314933 ramips: DIR-860L-B1 fix switch port numbering
Luci shows switch ports in inverted order on that device.
This patch fixes switch port numbering and matches them to the device
silkscreen.

Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
7 years ago
Giuseppe Lippolis 786f7426c2 ramips: fix wps button gpio for DWR-512
The WPS button is at GPIO#7.

Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
7 years ago
Paul Wassi c51c976db8 ramips: DTS: VoCore2 improvements/fixes
The VoCore2 features 128MB of RAM, therefore set
memory in DTS to 128*1024*1024 = 0x8000000
The board's LED is connected to GND, set it to
ACTIVE_HIGH here.
Make serial console working again on kernel 4.9 by
change of pinmux configuration.

Signed-off-by: Paul Wassi <p.wassi@gmx.at>
7 years ago
Alex Maclean f683385e73 ramips: add support for TP-Link RE350
The TP-Link RE350 is a wall-wart AC1200 range extender/access point with
a single gigabit ethernet port and two non-detachable antennas, based on
the MT7621A SoC with MT7603E and MT7612E radios.

Firmware wise it is very similar to the QCA based RE450.

SoC: MediaTek MT7621A (880MHz)
Flash: 8MiB (Winbond W25Q64)
RAM:   64MiB (DDR2)
Ethernet: 1x 1Gbit
Wireless: 2T2R 2.4Ghz (MT7603E) and 5GHz (MT7612E)
LEDs: Power, 2.4G, 5G (blue), WPS (red and blue), ethernet link/act
(green)
Buttons: On/off, LED, reset, WPS

Serial header at J1, 57600 8n1:
Pin 1 TX
Pin 2 RX
Pin 3 GND
Pin 4 3.3V

Factory image can be uploaded directly through the stock UI.

Signed-off-by: Alex Maclean <monkeh@monkeh.net>
7 years ago
Chuanhong Guo a4c84b2d73 ramips: add support for Phicomm K2P
It uses one MT7615D radio chip with DBDC mode enabled. This mode allows
this single chip act as an 2x2 11n radio and an 2x2 11ac radio at the
same time. However mt76 doesn't  support it currently so there is no
wireless available.

Specification:
- SoC: MediaTek MT7621AT
- Flash: 16 MB
- RAM: 128 MB
- Ethernet: 1 x WAN (10/100/1000Mbps) and 4 x LAN (10/100/1000 Mbps)
- Wireless radio: MT7615D on PCIE0
- UART: 1 x UART on PCB - 57600 8N1

Issue:
- Wireless radio doesn't work due to the lack of driver.

Flash instruction:
Using UART:
1. Configure PC with a static IP address and setup an TFTP server.
2. Put the firmware into the tftp directory.
3. Connect the UART line as described on the PCB.
4. Power up the device and press 2,then follow the instruction to
   set device and tftp server IP address and input the firmware
   file name.U-boot will then load the firmware and write it into
   the flash.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
7 years ago
Mathias Kresin e0b9ec8e96 treewide: drop target board_name functions
They are not used any longer.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin f12a32630f treewide: use the generic board_name function
Use the generic function instead ot the target specific ones.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Mathias Kresin ac3e05c5d7 treewide: populate boardname and model earlier
For targets using the generic board detection and board specific
settings in diag.sh, the board name is still unset at the time the
set_state() provided by diag.sh is called by 10_indicate_preinit.

Change the execution order to ensure the boardname is populated before
required the first time. Do the target specific board detection as
early as possible, directly followed by the generic one to allow a
seamless switch to the generic function for populating /tmp/sysinfo/.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago