Commit Graph

539 Commits (dc76900021b880820adf981bb7b1cf5ff3ffe1fd)

Author SHA1 Message Date
Fredrik Olofsson dc76900021 kernel: Correctly search for the FIT image in mtd partition.
Previously all iterations of the loop checked offset=0 in the partition.

Signed-off-by: Fredrik Olofsson <fredrik.olofsson@anyfinetworks.com>
5 years ago
Chuanhong Guo 1d6368ee73 kernel: mtdsplit_uimage: add support for okli image
This adds support for uImage used by OpenWrt kernel loader.
The parser searches for uImage header at flash eraseblock boundary
and it might attempt to split any firmware with loader, therefore
this entry doesn't have MTD_PARSER_TYPE_FIRMWARE so that this parser
is only used when explicitly defined in dts.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Rafał Miłecki c4492dd70e kernel: drop Fon(Foxconn) parser matching for the "firmware" partition
This parser's matching function appears to be too generic as it matches
e.g. Buffalo WZR-HP-G300NH. That results in incorrect parts parsing.

Luckily this parser is needed by Fon FON2601 only which uses DT-based
ramips target. It means we can depend on mtd subsystem matching of
"fonfxc,uimage" string.

That said triggering this parser based on the "firmware" (or whatever
MTD_SPLIT_FIRMWARE_NAME is) partiiton name is not needed. It can be
dropped which will automatically fix the Buffalo WZR-HP-G300NH case.

Fixes: a1c6a316d2 ("ramips: add support for Fon FON2601")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Rafał Miłecki 4b755ce06a Revert "kernel: generic: fix fonfxc uimage parser"
This reverts commit e92a14709d.

mtdsplit_uimage_parse_fonfxc() gets called in two situations:
1) It was /requested/ from DT using "fonfxc,uimage" compatible string
2) It was called by parsing code after finding "firmware"
   (MTD_SPLIT_FIRMWARE_NAME) due to the parser's type

Code added in the /fix/ commit basically just disabled the second case.
If that's the real goal it could be achieved by simply dropping type
MTD_PARSER_TYPE_FIRMWARE. It may however require another solution as
it's possible that some non-DT target actually needs fonfxc uImage
parsing.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
NOGUCHI Hiroshi e92a14709d kernel: generic: fix fonfxc uimage parser
We cannot distinguish between fonfxc uImage and generic uImage because
fonfxc uImage header is almost same as generic uImage, except padding
length after image name.

The fonfxc uImage parser is available when specifying directly with DT
compatible property.  So this patch adds check if the partition DT node
is compatible with the parser.

Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2413
Fixes: a1c6a316d2 ("ramips: add support for Fon FON2601")
Signed-off-by: NOGUCHI Hiroshi <drvlabo@gmail.com>
[commit light touches and removed C code comment]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
NOGUCHI Hiroshi a1c6a316d2 ramips: add support for Fon FON2601
FON2601 is a wireless router.

Specification:
- SoC: Mediatek MT7620A (580MHz)
- RAM: 128 MiB
- ROM: 16 MiB SPI Flash
- Wireless:
   for 11b/g/n (upto 300 Mbps):  MT7620A built-in WMAC
   for 11a/n/ac (upto 867 Mbps): MT7662E
- Ethernet LAN: 1 port, upto 100 Mbps
- Ethernet WAN: 1 port, upto 1000 Mbps
- USB: 1 port (USB 2.0 host)
- LEDs: 4 (all can be controlled by SoC's GPIO)
- buttons: 1 (Displayed as "WPS" on enclosure)
- serial port: 57600n8
 pins: Vcc(3.3V), Rx, Tx, GND
(left to right, viewed from outside of board)

Installation (only available via UART):
  1. download sysupgrade binary image by wget command
  2. write sysupgrade binary image to Flash
     command is:
       mtd write sysupgrade.bin firmware
  3. reboot

Important Notice:
  Only one button is displayed as "WPS" on enclosure.
  However, it is configured as "reset" (factory resetting feature).

Signed-off-by: NOGUCHI Hiroshi <drvlabo@gmail.com>
[removed unrelated openwrt-keyring revert, missing -Wall for uimage_padhdr]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Hauke Mehrtens 8ef6240fa6 kernel: Add missing includes mtdsplit_*.c
This fixes the following compile problem with kernel 4.9 on lantiq:
drivers/mtd/mtdsplit/mtdsplit_uimage.c:244:34: error: array type has incomplete element type 'struct of_device_id'
 static const struct of_device_id mtdsplit_uimage_of_match_table[] = {
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/mtdsplit/mtdsplit_uimage.c:245:4: error: field name not in record or union initializer
  { .compatible = "denx,uimage" },

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
5 years ago
Chuanhong Guo 01c0d7f86f generic: ar8216: group MIB counters and use two basic ones only by default
There are too many MIB counters that almost nobody needs since commit
d6366ce366 ("generic: ar8216: mib_work_func: read all port mibs
everytime").

In the worker function to poll MIB data, it deals with all ports instead
of only one port every time, which introduces too many mdio operations
that it becomes a heavy CPU load even on not-emulated MDIO bus.

This commit groups MIB counters and enable only TxBytes and RxGoodBytes
by default (both of which are necessary to get swconfig led working.)
and adds an swconfig attribute to allow enabling all counters if users
need them.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo 107dc4326c generic: ar8216: add mib_poll_interval switch attribute
This allows specifying interval of polling MIB counters from userspace
and allow completely turning off MIB counter support by setting
mib_poll_interval to 0.

Since MIB counter polling is a heavy CPU load for GPIO emulated MDIO
bus, disable this behavior by default. Those who wants to use swconfig
LEDs can enable them with qca,mib-poll-interval dts property or with
swconfig command.

Fixes: FS#2230 ("kworker spikes 100% cpu every 2 second.")
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Rafał Miłecki 8dacd75ea8 kernel: b53: add support for kernels 5.0+
It adjusts b53 code to upstream changes from the commit 3c1bcc8614db
("net: ethernet: Convert phydev advertize and supported from u32 to link
mode").

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Chuanhong Guo 47eef3a5ce generic: ar8216: introduce qca,mib-poll-interval property
This allows users to specify a shorter mib poll interval so that the
swconfig leds could behave normal with current get_port_stats()
implementation.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo c8c2ef1d49 generic: ar8216: do a software reset for switch during hw_init
This applies to ar8216 and ar8236. QCA's newer U-boot will enable
the switch mdio master for FE switches which makes phy inaccessible
from CPU mdio. (e.g. on TP-Link TL-WR941N v7 Chinese version which
uses QCA9558+AR8236.) For these devices PHY probing is broken and
mdio device probing is a must. We also need to disable switch mdio
master in driver for later PHY initialization.

Do a soft reset during hw_init so that mdio master can be disabled
and expose PHYs to CPU mdio for later PHY accessing.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo d6366ce366 generic: ar8216: mib_work_func: read all port mibs everytime
ar8xxx_mib_capture will update mib counters for all ports. Current
code only update one port at a time and the data for other ports
are lost.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo 9fc506e9b2 generic: ar8216: add support for get_port_stats()
Partially reverts commit eff3549c58.

AR7240 and AR9341 have buggy hardware switch LED trigger. The AR7240
one doesn't blink and the blinking of port0/port5 is reversed on
AR9341 if we swap PHY0 and PHY4. (Only blinking is reversed, which
means LED for PHY0 will lit when PHY0 is link up and will blink when
PHY4 has active link and vice versa.) On these two chips a software
swconfig LED trigger is required.

This commit adds swconfig port stats back but:
 1. move checking of mib_t/rxb_id into ar8xxx_chip since we can't
    distinguish ar7240sw and ar8216 using only chip id.
 2. don't update mib counter in get_port_stat. This function is called
    every 0.01s and this capturing procedure will take up a lot of CPU.
    We already have a mib_work_func updating mib counters every 2s so
    return the saved counter instead of fetching new data. The blinking
    rate will be weird but it should solve the previously mentioned CPU
    time problem.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo 0598ec0abc generic: ar8216: add support for ar724x/ar933x builtin switch
This builtin switch is a bugless ar8216 with different mib counters
and gigabit cpu port.
Atheros uses the same device ID and it's impossible to distinguish
the standalone one and the builtin one. So we add support to mdio
device probe only.

This switch doesn't have buggy vlan tag so it's not needed to enable
atheros header. This commit changed ar8216_setup_port so that it can
be reused for this switch.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo ad8db1fa2e generic: ar8216: mdiodev: add qca,phy4-mii-enable option
This option allows setting phy4 as a phy connected directly to CPU.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo cf9900978a generic: ar8216: ar8229: add phy_read/phy_write
the added function also works for ar8216 and will be used in the
following ar7240 support.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo cc817392f4 generic: ar8216: add support for separated mdio bus for phy access
Atheros FE switches have a builtin mdio master available for PHY
accessing and on ar724x/ar933x builtin switches this mdio master
is the only way of accessing PHYs.

After this patch if there is phy_read/phy_write method available
in ar8xxx_chip we register a separated mdio bus for accessing PHYs.

Still adds support for mdio device probing only since this isn't
needed for those switches registered using PHY probing.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo cb7d96499c generic: ar8216: add support for ar8229
ar8229 is the builtin switch in ar934x and later chips. There is
also a standalone version available and their registers/functions
are the same.

This commit added support for the builtin ar8229. The only thing
missing for standalone ar8229 should be phy modes. Since I don't
have a router using that, this commit doesn't add support for
other phy modes.

Only add its support for mdio-device probing method because the
current PHY probing can't return 1G speed when it's a FE switch.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo 7d504f68a6 generic: ar8216: add mdio-device probing support
currently only ar8327 and ar8236 are added since they are the only
two I could verify.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo da64a8c656 generic: ar8216: move ar8xxx_id_chip into ar8xxx_phy_probe
ar8xxx_id_chip is used to determine current ar8xxx_chip using switch
id and this isn't needed during mdiodev probing.
Move it out of ar8xxx_probe_switch so that we can skip it.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo ebec6c9f85 generic: ar8216: add device struct into struct ar8xxx_priv
dev has been taken up by switch_dev so it's named pdev instead.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo 2e6c96a649 generic: ar8216: drop duplicated include
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Chuanhong Guo 15323c4ef8 generic: ar8216: move chip id reading into a separate function
for mdio-device probing we still need to read chip id but ar8xxx_chip
can be determined using drvdata. We can't distinguish the buggy
standalone ar8216 and the builtin ar8216 in ar724x/ar933x using chip
id.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Linus Walleij b907097291 kernel: mtdsplit: wrgg: Support big and little endian
The WRGG images exist in both big and little endian variants,
as can be seen from the image generator in
tools/firmware-utils/src/mkwrggimg.c, you either pass
the "-b" flag or not. The D-Link DIR-685 is using little
endian images so we need to support splitting these.

Detect endianness like this: if the kernel entity size
gets silly big (bigger than the flash memory) we are
probably using the wrong endianness.

Example: my kernel of 0x0067ff64 was switched around by
wrong endianness and detected as 0x64ff67a0 (the actual
size in swapped endianness + header 0xa0).

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years ago
Christian Lamparter 457de5a154 owl-loader: fix crash caused by endian patch
This patch fixes a crash that occured on the
BT Home Hub v5a (lantiq/xrx200) which resulted
in the device bootlooping.

Reported-by: Ryan Mounce <ryan@mounce.com.au>
Tested-by: Vitalij Alshevsky <v_alshevsky@tut.by>
Fixes: ddece08bf4 ("kernel: owl-loader: fix sparse endian warnings")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years ago
Christian Lamparter ddece08bf4 kernel: owl-loader: fix sparse endian warnings
owl-loader.c:83:21: sparse: warning: incorrect type in assignment (different base types)
owl-loader.c:83:21: sparse:    expected unsigned short [usertype] reg
owl-loader.c:83:21: sparse:    got restricted __be16 const [usertype] reg
owl-loader.c:84:21: sparse: warning: incorrect type in assignment (different base types)
owl-loader.c:84:21: sparse:    expected unsigned int [usertype] val
owl-loader.c:84:21: sparse:    got restricted __be16 const [usertype] low_val
owl-loader.c:85:28: sparse: warning: restricted __be16 degrades to integer

Reported-by: kbuild test robot
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
5 years ago
Mathias Kresin 116d0f276d kernel: add DT binding support to the Edimax uImage parser
It allows specifying those parsers directly in the DT.

Signed-off-by: Mathias Kresin <dev@kresin.me>
5 years ago
Chuanhong Guo bd03255ec4 generic: ar8216: ar8327: kill warnings
This fixed warnings caused by returning value in a void function

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Christian Lamparter 40180b6305 kernel: add DT binding support to the fit parser
It allows specifying default and Netgear parsers directly in the DT.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
6 years ago
Deng Qingfang 18501889f6 kernel: add mv88e61xx switch port-mirroring support
Compile & run tested on mvebu

Signed-off-by: Deng Qingfang <dengqf6@mail2.sysu.edu.cn>
6 years ago
Hauke Mehrtens 9261e7447e kernel: Make the patches apply on top of 4.19
This makes the patches which were just copied in the previous commit
apply on top of kernel 4.19.

The patches in the backports-4.19 folder were checked if they are really
in kernel 4.19 based on the title and only removed if they were found in
the upstream kernel.

The following additional patches form the pending folder went into
upstream Linux 4.19:
pending-4.19/171-usb-dwc2-Fix-inefficient-copy-of-unaligned-buffers.patch
pending-4.19/190-2-5-e1000e-Fix-wrong-comment-related-to-link-detection.patch
pending-4.19/478-mtd-spi-nor-Add-support-for-XM25QH64A-and-XM25QH128A.patch
pending-4.19/479-mtd-spi-nor-add-eon-en25qh32.patch
pending-4.19/950-tty-serial-exar-generalize-rs485-setup.patch
pending-4.19/340-MIPS-mm-remove-mips_dma_mapping_error.patch

Bigger changes were introduced to the m25p80 spi nor driver, as far as I
saw it in the new code, it now has the functionality provided in this
patch:
pending-4.19/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch

Part of this patch went upstream independent of OpenWrt:
hack-4.19/220-gc_sections.patch
This patch was reworked to match the changes done upstream.

The MIPS DMA API changed a lot, this patch was rewritten to match the
new DMA handling:
pending-4.19/341-MIPS-mm-remove-no-op-dma_map_ops-where-possible.patch

I did bigger manual changes to the following patches and I am not 100% sure if they are all correct:
pending-4.19/0931-w1-gpio-fix-problem-with-platfom-data-in-w1-gpio.patch
pending-4.19/411-mtd-partial_eraseblock_write.patch
pending-4.19/600-netfilter_conntrack_flush.patch
pending-4.19/611-netfilter_match_bypass_default_table.patch
pending-4.19/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch
hack-4.19/211-host_tools_portability.patch
hack-4.19/221-module_exports.patch
hack-4.19/321-powerpc_crtsavres_prereq.patch
hack-4.19/902-debloat_proc.patch

This is based on patchset from Marko Ratkaj <marko.ratkaj@sartura.hr>

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
6 years ago
Hauke Mehrtens aa3b6a08c5 kernel: Replace ledtrig-netdev with upstream backport
The ledtrig-netdev was added to upstream Linux kernel 4.16, replace our
own version with the patch based on the upstream version.
This will remove the ledtrig-netdev support from kernel 3.18, because I
not want to spend time on backporting it to 3.18. This will make it
easier to use the upstream version with kernel 4.19, by just not
applying this patch.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
6 years ago
Rafał Miłecki 816ae87709 kernel: drop unneeded LINUX_VERSION_CODE checks
All those parsers are used by 4.14 targets. They don't need that
backward compatibility code.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
Rafał Miłecki 2abb128f2e kernel: add DT binding support to the LZMA and WRG parsers
It allows specifying those parsers directly in the DT.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
Rafał Miłecki 4d3a53b9ef kernel: add DT binding support to the TRX and minor parsers
It allows specifying those parsers directly in the DT.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
David Bauer 68e59b61c6 kernel: add DT binding support to AVM EVA parser
It allows selecting split-firmware parser directly by
specifying image-format in the device-tree.

Signed-off-by: David Bauer <mail@david-bauer.net>
6 years ago
Ram Chandra Jangir bf7719f22c kernel: ar83xx: Add support for three GMAC's connection
We have IPQ8064 AP161 board which has three GMAC's
 * RGMII x2
 * SGMII x1.
The existing ar8327 driver does not have support for
three GMAC's connection, hence this change adds support
for the same. This has been verified on AP148 and AP161
board.

Signed-off-by: xiaofeis <xiaofeis@codeaurora.org>
Signed-off-by: Ram Chandra Jangir <rjangir@codeaurora.org>
6 years ago
Pawel Dembicki b5597d5cc9 kernel: add DT binding support to the jimage parser
It allows specifying jimage parser directly in the DT.

Tested on LAVA LR-25G001

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
6 years ago
Günther Kelleter 33878b0a40 kernel: ar8xxx: get_arl_table now shows all ports of an entry
Multicast ARL entries can have multiple destination ports. Get and dump
all destination ports of each entry, not just the lowest.

Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
6 years ago
Pawel Dembicki e61812fd34 ar8216: add adjust_link checking
Driver crash when 'phydev->adjust_link' isn't provided.

This patch check if 'phydev->adjust_link' exist before
call the method.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
6 years ago
Christian Lamparter a9839fe638 generic: rtl8367b: make it possible to specify cpu_port via DT
This patch adds the feature to parse the existing cpu_port DT
property, which is used to specify which port is the cpu port
of the switch.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
6 years ago
Christian Lamparter 910c2f9e68 generic: rtl836x: support defered probe on mdio-bus
On the WNDAP620, the mdio and mdc lines are controlled by
the EMAC ethernet device. This results in a hen-vs-egg problem.
The rtl8367b driver is probed before the ethernet driver and
the mdio-bus is not available yet, which caused the rtl8367b
driver to fail.

This patch changes the rtl8366_smi_probe_of() function to
return -EPROBE_DEFER if the mdio-bus lookup failed and changes
rtl8366_smi_probe()'s signature to return the error code back to
the callee, so it can propagate back to the kernel. Which, will
retry the switch probe at a later time.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
6 years ago
Rafał Miłecki f995e143ba kernel: add missing version.h include to the TP-LINK parser
Fixes: a29c8d685b ("kernel: add DT binding support to the TP-LINK parser")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
Rafał Miłecki a29c8d685b kernel: add DT binding support to the TP-LINK parser
It allows triggering it directly by specifying format in the DT.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
Rafał Miłecki a22311e6a6 kernel: add DT binding support to the uimage parsers
It allows specifying default and Netgear parsers directly in the DT.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
David Bauer 6680fab947 kernel: b53: register switch on probe
Currently, the b53 MDIO switch driver registers the switch on
config-init and not on device probe. Because of this, the switch
gets added every time the associated interface comes up.

This commit fixes this behavior by registering the switch on device
probe.

Compile- and run-tested on OCEDO Koala.

Signed-off-by: David Bauer <mail@david-bauer.net>
6 years ago
Rafał Miłecki dab5a93086 kernel: add DT binding support to the Seama parser
It allows specifying that parser directly in the DT.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
6 years ago
Mathias Kresin 6b13238a13 generic: revert workarounds for AR8337 switch
The intention of 967b6be118 ("ar8327: Add workarounds for AR8337
switch") was to remove the register fixups for AR8337. But instead they
were removed for AR8327.

The RGMII RX delay is forced even if the port is used as phy instead of
mac, which results in no package flow at least for one board.

Fixes: FS#1664

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Franz Flasch d4ac26ec49 kernel: rtl8366-smi: add Realtek switch management via mii-bus
Current version of rtl8366-smi module only supports Realtek switch
managment via two gpio lines. This adds Realtek switch
management via mii_bus. Tested on a Tp-link Archer C2 v1 (Mediatek
SoC mt7620a based)

dts-file configuration should look like this:

rtl8367rb {
	compatible = "realtek,rtl8367b";
	realtek,extif1 = <1 0 1 1 1 1 1 1 2>;
	mii-bus = <&mdio0>;
};

&ethernet {
	status = "okay";
	mtd-mac-address = <&rom 0xf100>;
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;

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

	mdio0: mdio-bus {
		status = "okay";
	};
};

Signed-off-by: Serge Vasilugin <vasilugin@yandex.ru>
Signed-off-by: Franz Flasch <franz.flasch@gmx.at>
6 years ago