aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/files
Commit message (Collapse)AuthorAgeFilesLines
* ath79: add support for reset key on MikroTik RB912UAG-2HPnDDenis Kalashnikov2022-01-193-6/+240
| | | | | | | | | | | | | | | | | | | | | | On MikroTik RB91x board series a reset key shares SoC gpio line #15 with NAND ALE and NAND IO7. So we need a custom gpio driver to manage this non-trivial connection schema. Also rb91x-nand needs to have an ability to disable a polling of the key while it works with NAND. While we've been integrating rb91x-key into a firmware, we've figured out that: * In the gpio-latch driver we need to add a "cansleep" suffix to several gpiolib calls, * When gpio-latch and rb91x-nand fail to get a gpio and an error is -EPROBE_DEFER, they shouldn't report about this, since this actually is not an error and occurs when the gpio-latch probe function is called before the rb91x-key probe. We fix these related things here too. Signed-off-by: Denis Kalashnikov <denis281089@gmail.com> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
* ath79: remove pre-5.10 specific kernel codeDavid Bauer2021-12-295-65/+2
| | | | | | With Kernel 5.4 support removed, we can get rid of this legacy code. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ag71xx: Disable napi related interrupts during probeSven Eckelmann2021-10-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ag71xx_probe is registering ag71xx_interrupt as handler for the gmac0/gmac1 interrupts. The handler is trying to use napi_schedule to handle the processing of packets. But the netif_napi_add for this device is called a lot later in ag71xx_probe. It can therefore happen that a still running gmac0/gmac1 is triggering the interrupt handler with a bit from AG71XX_INT_POLL set in AG71XX_REG_INT_STATUS. The handler will then call napi_schedule and the napi code will crash the system because the ag->napi is not yet initialized: libphy: Fixed MDIO Bus: probed CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 00000000, ra == 81373408 Oops[#1]: CPU: 0 PID: 1 Comm: swapper Not tainted 5.4.152 #0 $ 0 : 00000000 00000001 00000000 8280bf28 $ 4 : 82a98cb0 00000000 81620000 00200140 $ 8 : 00000000 00000000 74657272 7570743a $12 : 0000005b 8280bdb9 ffffffff ffffffff $16 : 00000001 82a98cb0 00000000 8280bf27 $20 : 8280bf28 81620000 ffff8b00 8280bf30 $24 : 00000000 8125af9c $28 : 82828000 8280bed8 81610000 81373408 Hi : 00005fff Lo : 2e48f657 epc : 00000000 0x0 ra : 81373408 __napi_poll+0x3c/0x11c Status: 1100dc03 KERNEL EXL IE Cause : 00800008 (ExcCode 02) BadVA : 00000000 PrId : 00019750 (MIPS 74Kc) Modules linked in: Process swapper (pid: 1, threadinfo=(ptrval), task=(ptrval), tls=00000000) Stack : ffff8afb ffff8afa 81620000 00200140 00000000 82a98cb0 00000008 0000012c 81625620 81373684 ffffffff ffffffff ffffffef 00000008 816153d8 81620000 815b0d60 815bbd54 00000000 81753700 8280bf28 8280bf28 8280bf30 8280bf30 81753748 00000008 00000003 00000004 0000000c 00000100 3fffffff 8175373c 816059f0 814ddb48 00000001 8160ab30 81615488 810618bc 00000006 00000000 ... Call Trace: [<81373684>] net_rx_action+0xfc/0x26c [<814ddb48>] __do_softirq+0x118/0x2ec [<810618bc>] handle_percpu_irq+0x50/0x80 [<8125ab8c>] plat_irq_dispatch+0x94/0xc8 [<81004e98>] handle_int+0x138/0x144 Code: (Bad address in epc) ---[ end trace a60d797432b656b2 ]--- The gmcc0/gmac1 must be brought in a state in which it doesn't signal a AG71XX_INT_POLL related status bits as interrupt before registering the interrupt handler. ag71xx_hw_start will take care of re-initializing the AG71XX_REG_INT_ENABLE. Fixes: f529a3742043 ("surprise :p") Signed-off-by: Sven Eckelmann <sven@narfation.org>
* ath79: remove obsolete pci-ath9k-fixup.[c,h] filesChristian Lamparter2021-08-262-132/+0
| | | | | | | | | | | | This was old code from the AR71XXs target days that doesn't get compiled and used anymore. Bringing up AR92xx and earlier chips from their OWL-Emulator state is currently done by the upstream ath9k-pci-owl-loader module. (see the kmod-owl-loader package). Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* treewide: backport support for nvmem on non platform devicesAnsuel Smith2021-08-051-5/+2
| | | | | | | | | | | | In the current state, nvmem cells are only detected on platform device. To quickly fix the problem, we register the affected problematic driver with the of_platform but that is more an hack than a real solution. Backport from net-next the required patch so that nvmem can work also with non-platform devices and rework our current patch. Drop the mediatek and dsa workaround and rework the ath10k patches. Rework every driver that use the of_get_mac_address api. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
* ath79: ar934x: fix mounting issues if subpage is not supportedKoen Vandeputte2021-06-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the option to disable subpage writing is only set when a HW ECC engine is used. Some boards lack a HW ECC engine and use software for that. In this case, this NAND option does not get set when the NAND chip does not support it, resulting in mounting errors. Move the setting of this option to a generic init location so it gets set for all types where required. While at it, also OR the option instead of just setting it so we don't overwrite potential flags being set somewhere else. Before: [ 1.681273] UBI: auto-attach mtd2 [ 1.684669] ubi0: attaching mtd2 [ 1.688877] ubi0 error: validate_ec_hdr: bad VID header offset 2048, expected 512 [ 1.696469] ubi0 error: validate_ec_hdr: bad EC header [ 1.701712] Erase counter header dump: [ 1.705512] magic 0x55424923 [ 1.709322] version 1 [ 1.712330] ec 1 [ 1.715331] vid_hdr_offset 2048 [ 1.718610] data_offset 4096 [ 1.721880] image_seq 1462320675 [ 1.725680] hdr_crc 0x12255a15 After: 1.680917] UBI: auto-attach mtd2 [ 1.684308] ubi0: attaching mtd2 [ 2.954504] random: crng init done [ 3.142813] ubi0: scanning is finished [ 3.163455] ubi0: attached mtd2 (name "ubi", size 124 MiB) [ 3.169069] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes [ 3.176037] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048 [ 3.182942] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096 [ 3.190013] ubi0: good PEBs: 992, bad PEBs: 0, corrupted PEBs: 0 [ 3.196102] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128 [ 3.203434] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1462320675 [ 3.212700] ubi0: available PEBs: 0, total reserved PEBs: 992, PEBs reserved for bad PEB handling: 20 [ 3.222124] ubi0: background thread "ubi_bgt0d" started, PID 317 [ 3.230246] block ubiblock0_1: created from ubi0:1(rootfs) [ 3.235819] ubiblock: device ubiblock0_1 (rootfs) set to be root filesystem [ 3.256830] VFS: Mounted root (squashfs filesystem) readonly on device 254:0. Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
* ath79: add NAND driver for MikroTik RB91xG seriesDenis Kalashnikov2021-06-211-0/+375
| | | | | | | | | | | | | Main part is copied from ar71xx original driver rb91x_nand written by Gabor Juhos <juhosg@openwrt.org>. What is done: * Support of kernel 5.4 and 5.10, * DTS support, * New gpio API (gpiod_*) support. Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> Signed-off-by: Denis Kalashnikov <denis281089@gmail.com>
* ath79: add gpio-latch driver for MikroTik RouterBOARDsDenis Kalashnikov2021-06-211-0/+203
| | | | | | | | | | | | This is a slighty modified version of ar71xx gpio-latch driver written by Gabor Juhos <juhosg@openwrt.org>. Changes: * DTS support, * New gpio API (gpiod_*). Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> Signed-off-by: Denis Kalashnikov <denis281089@gmail.com>
* ath79: ag71xx: fix error handling for of_get_phy_modeDavid Bauer2021-05-101-3/+3
| | | | | | | Errors are not indicated by the phy_mode value but returned separately from the function. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: mikrotik: update nand-rb4xx driverRoger Pueyo Centelles2021-04-171-5/+20
| | | | | | | | | | | | | | | This updates the NAND driver for MikroTik RB4XX series to work with kernel 5.10, similarly to the ar934x-nand driver (fb64e2c3). Support for kernel 5.10 was added to all ath79 subtargets except for the mikrotik one by commit d6b785d, since patch 920-mikrotik-rb4xx.patch needed to be reworked. Later, commit f8512661 enabled kernel 5.10 for the mikrotik subtarget with the nand-rb4xx driver still pending, which is updated and added back by this patch. Compile-tested only. Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
* ath79: force SGMII SerDes mode to MAC operationDavid Bauer2021-04-131-0/+5
| | | | | | | | | | | | | | | | | The mode on the SGMII SerDes on the QCA9563 is 1000 Base-X by default. This only allows for 1000 Mbit/s links, however when used with an SGMII PHY in 100 Mbit/s link mode, the link remains dead. This strictly has nothing to do with the SerDes calibration, however it is done at the same point in the QCA reference U-Boot which is the blueprint for everything happening here. As the current state is more or less a hack, this should be fine. This fixes the issues outlined above on a TP-Link EAP-225 Outdoor. Reported-by: Tom Herbers <freifunk@tomherbers.de> Tested-by: Tom Herbers <freifunk@tomherbers.de> Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ar934x-nand: fix broken nand on kernel 5.10Koen Vandeputte2021-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Booting current 5.10.x testing kernel shows this: [ 0.335781] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xf1 [ 0.342280] nand: Samsung NAND 128MiB 3,3V 8-bit [ 0.346982] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.354703] ar934x-nand 1b800200.nand: unknown ECC mode 2 [ 0.360193] ar934x-nand 1b800200.nand: nand_scan failed, err:-22 [ 0.366341] ar934x-nand: probe of 1b800200.nand failed with error -22 ... [ 1.089264] /dev/root: Can't open blockdev [ 1.093482] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6 [ 1.101077] Please append a correct "root=" boot option; here are the available partitions: [ 1.109555] 1f00 64 mtdblock0 [ 1.109559] (driver?) [ 1.116199] 1f01 48 mtdblock1 [ 1.116202] (driver?) [ 1.122841] 1f02 4 mtdblock2 [ 1.122844] (driver?) [ 1.129493] 1f03 4 mtdblock3 [ 1.129497] (driver?) [ 1.136138] 1f04 4 mtdblock4 [ 1.136142] (driver?) [ 1.142787] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) [ 1.151168] Rebooting in 1 seconds.. The issue is caused by a wrong check for ECC engine type on newer kernels. Fix this. Bootlog after: [ 0.335689] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xf1 [ 0.342192] nand: Samsung NAND 128MiB 3,3V 8-bit [ 0.346884] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 0.354611] Scanning device for bad blocks [ 0.364924] random: fast init done [ 0.496641] 3 fixed-partitions partitions found on MTD device ar934x-nand [ 0.503545] Creating 3 MTD partitions on "ar934x-nand": [ 0.508865] 0x000000000000-0x000000040000 : "booter" [ 0.515133] 0x000000040000-0x000000400000 : "kernel" [ 0.523265] 0x000000400000-0x000008000000 : "ubi" Fixes: fb64e2c30f ("ath79: ar934x-nand: add kernel 5.10 compatibility") Signed-off-by: Koen Vandeputte <koen.vandeputte@citymesh.com>
* ath79: use ioremap kernel version independentDavid Bauer2021-02-221-14/+0
| | | | | | | | | | As mangix pointed out on IRC, ioremap and ioremap_nocache are functionally equivalent on kenrel 5.4 and 5.10. Therefore we can use ioremap regardless of the kernel the driver gets compiled for. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ar934x-nand: add kernel 5.10 compatibilityDavid Bauer2021-02-201-0/+30
| | | | | | | | | Adapt the driver to make it work with the NAND subsystem changes between kernel 5.4 and 5.10. Tested-on: Aerohive HiveAP121 Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ag71xx: make kernel 5.10 compatibleDavid Bauer2021-02-202-1/+28
| | | | | | | Add the necessary kernel version ifdef switches in order to support the kernel version 5.10. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ag71xx: add ethtool statistics supportLeon Leijssen2021-02-011-0/+86
| | | | | | | | | Add statistics to ethtool. The statistics can be useful to debug network issues. The code is backported from mainline ag71xx.c driver. Signed-off-by: Leon Leijssen <leon.git@leijssen.info>
* ath79: add QCA956x SERDES init workaroundJulien Dusser2020-11-231-0/+76
| | | | | | | | | | | | | | | | | | | | | | | This commit add a workaround for non working SGMII link observed on some QCA956x SoCs. The workaround originates part from the U-Boot source code from QCA, part from the implementation from TP-Link found in the GPL tarball for the EAP245v1. Extends commit 0d416a8d3b990e3b78628f0e7546527709c877f7 for QCA956x. Note that reset is the same on QCA955x and QCA956x, same register offset and values. Auto calibration is done on u-boot, but always fall back to default value 0x7. Add a DTS entry serdes-cal in case a device require another value. Signed-off-by: Julien Dusser <julien.dusser@free.fr> [Sander Vanheule: Minor code style fixes, Remove hunk adding qca956x-serdes-fixup to a missing DTS, Remove variable err that was only assigned, Rename function to sgmii_serdes_init, Lower priority of serdes call message to pr_debug] Signed-off-by: Sander Vanheule <sander@svanheule.net>
* ath79: ensure QCA956x gmac0 mux selects sgmiiSander Vanheule2020-11-231-0/+35
| | | | | | | | | Some bootloaders do not set up gmac0 properly, leaving it disconnected from the sgmii interface. If the user specificies phy-mode sgmii, then use the gmac-config/device node to ensure the mux is configured correctly. Signed-off-by: Sander Vanheule <sander@svanheule.net>
* target: remove obsolete kernel version switches for 4.19Adrian Schmutzler2020-10-302-156/+0
| | | | | | | This removes unneeded kernel version switches from the targets after kernel 4.19 has been dropped. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* kernel: Update kernel 4.19 to version 4.19.131Hauke Mehrtens2020-07-042-14/+8
| | | | | | | | | | | | | Fixes: - CVE-2020-10757 The "mtd: rawnand: Pass a nand_chip object to nand_release()" commit was backported which needed some adaptations to other code. Run tested: ath79 Build tested: ath79 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* ath79: add Mikrotik rb4xx series driversChristopher Hill2020-06-154-0/+676
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds 3 Mikrotik rb4xx series drivers as follows: rb4xx-cpld: This is in the mfd subsystem, and is the parent CPLD device that interfaces between the SoC SPI bus and its two children below. rb4xx-gpio: This is the GPIO expander. rb4xx-nand: This is the NAND driver. The history of this code comes in three phases. 1. The first is a May 2015 attempt to push the equivalient ar71xx rb4xx drivers upstream. See https://lore.kernel.org/patchwork/patch/940880/. Module-author: Gabor Juhos <juhosg@openwrt.org> Module-author: Imre Kaloz <kaloz@openwrt.org> Module-author: Bert Vermeulen <bert@biot.com> 2. Next several ar71xx patches were applied bringing the code current. commit 7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> commit af79fdbe4af32a287798b579141204bda056b8aa commit 889272d92db689fd9c910243635e44c9d8323095 commit e21cb649a235180563363b8af5ba8296b9ac0baa commit 7c09fa4a7492ca436f2c94bd9a465b7c5bbeed6f Signed-off-by: Felix Fietkau <nbd@nbd.name> 3. Finally a heavy refactor to split the driver into the three new subsystems, and updated to work with the device tree configuration, plus updates and review feedback incorporated Reviewed-by: Thibaut VARÈNE <hacks@slashdirt.org> Signed-off-by: Christopher Hill <ch6574@gmail.com>
* ath79: ag71xx: don't warn on RGMII_RXID and RGMII_TXIDDavid Bauer2020-06-151-0/+4
| | | | | | | | | | Currently, ag71xx will trigger a warning when TX xor RX-Delay modes are enabled. Handle them identical to the already implemented RGMII modes, as they are only different for the attached PHY. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ag71xx: unify version dependent codeDavid Bauer2020-04-271-5/+1
| | | | | | | Use IS_ERR_OR_NULL macro to use the same code on kernel 4.19 as well as 5.4. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: ag71xx: remove code for legacy kernelsDavid Bauer2020-04-271-32/+0
| | | | | | | ath79 does not support kernels prior to 4.19 anymore. Remove legacy code for those kernels from the ag71xx driver. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: move tplinkpart.c parser to patchesAdrian Schmutzler2020-04-241-235/+0
| | | | | | | | | | | | | Between 4.19 and 5.4, mtd parsers have been moved to "parsers" subdirectory. Like for myloader.c in the previous patch, this patch moves tplinkpart.c to the kernel patches, so the code and the kernel includes are at the same location and the path can be adjusted per kernel. While at it, remove some outdated kernel version switches from the C code. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* ath79: fix missing return statement in ar934x_nandDavid Bauer2020-03-221-4/+12
| | | | | | | | | | | The reset assert and deassert methods currently miss a return value, leading to a compilation warning. Return the return-value of reset_control_assert and reset_control_deassert to fix these warnings. Suggested-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: fix NAND driver compilation for kernel 5.4David Bauer2020-03-221-5/+122
| | | | | | | | | | | | | | | This fixes the compilation of the AR934x NAND controller driver for kernel 5.4 while leaving it untouched for kernel 4.19. This change is currently not run-tested, as i do not have such a device at hand. CC: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> CC: André Valentin <avalentin@marcant.net> CC: WeiDong Jia <jwdsccd@gmail.com> Signed-off-by: David Bauer <mail@david-bauer.net> Tested-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
* ath79: use downstream ag71xx for Kernel 5.4David Bauer2020-03-139-0/+3106
| | | | | | | | | | | | | | | | | | | The ag71xx driver from Linux 5.4 currently has various shortcomings when used with OpenWrt compared to our downstream version. For example, the upstream driver does not support modifying the ethernet clock and configuring RGMII delays on the MAC side. While we should certainly switch to the upstream driver, the amount of necessary patches would make it cumbersome to work with. It's also highly likely we won't be able to finish patching the upstream driver in time for a Linux 5.4 release. Tested on Siemens WS-AP3610. CC: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: David Bauer <mail@david-bauer.net> Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
* ath79: add support for kernel 5.4David Bauer2020-02-289-3102/+0
| | | | | | | | | | | | | | | Signed-off-by: David Bauer <mail@david-bauer.net> [refreshed] Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com> * Sync the patches with the changes done for kernel 4.19 * Use KERNEL_TESTING_PATCHVER * Refresh the configuration * Fix multiple compile bugs in the patches * Only add own ag71xx files for kernel 4.19 and use upstream version for 5.4. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* ath79: ag71xx: use netif_receive_skb_list on 4.19Chuanhong Guo2020-02-071-1/+19
| | | | | | | | This new function make batch processing of network packets possible, which slightly improves performance. Signed-off-by: Chuanhong Guo <gch981213@gmail.com> Tested-by: Rosen Penev <rosenp@gmail.com>
* ath79: add QCA955x SGMII link loss workaroundDavid Bauer2020-01-231-0/+108
| | | | | | | | | | | | | | | | This commit adds a workaround for the loss of the SGMII link observed on the QCA955x generation of SoCs. The workaround originates part from the U-Boot source code, part from the implementation from AVM found in the GPL tarball for the AVM FRITZ!WLAN Repeater 450E. The bug results in a stuck SGMII link between the PHY device and the SoC side. This has only been observed with the Atheros AR8033 PHY and most likely all devices using such combination are affected. It is worked around by reading a hidden SGMII status register and issuing a SGMII PHY reset until the link becomes useable again. Signed-off-by: David Bauer <mail@david-bauer.net>
* ath79: add AR934x NAND Flash Controller driverMichal Cieslakiewicz2019-10-201-0/+1481
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch contains updated driver for Atheros NAND Flash Controller written originally by Gabor Juhos for ar71xx (aka 'ar934x-nfc'). ath79 version has adapted to work with kernel 4.19 and Device Tree. It has also been renamed to 'ar934x-nand' to avoid confusion with Near-Field Communication technology. Controller is present on Atheros AR934x SoCs and required for accessing internal flash storage on routers like Netgear WNDR4300. This port preserves all NAND programming code while moving platform configuration to Device Tree and replacing some kernel functions marked for retirement by 4.19. Suitable definition is included in 'ar934x.dtsi' ('nand@1b000200' section). Most important changes to ar71xx version are: * old kernel sections of code removed * 'bool swap_dma' provided by platform data is now set by boolean DT property 'qca,nand-swap-dma' * board-supplied (mach-*.c code) platform data removed - its elements become either unused, redundant or replaced by DT methods (like reset) * IRQ is reserved by devm_request_irq() so free_irq() is not needed anymore * calls to deprecated nand_scan_ident() + nand_scan_tail() function pair replaced by using recommended nand_scan() with attach_chip() callback * ECC is set to hardware by default, can be overriden by standard DT 'nand-ecc-*' properties (software Hamming or BCH are other options) This driver has been successfully tested on Netgear WNDR4300 running experimental ath79 OpenWrt master branch. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> [add reset control] Signed-off-by: David Bauer <mail@david-bauer.net>
* ar71xx/ath79: ag71xx: dont fetch the same var againKoen Vandeputte2019-08-271-1/+1
| | | | | | | tx_size was just declared above and set to BIT(tx->order) Use the declaration instead, which could avoid a pointer deref Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
* ar71xx/ath79: ag71xx: get ring_mask consistentKoen Vandeputte2019-08-271-1/+1
| | | | | | | | | All other instances of this identical declaration fetch the value directly from the ring_order. Also do it here. Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
* ar71xx/ath79: ag71xx: init rings with GFP_KERNELKoen Vandeputte2019-08-091-1/+1
| | | | | | | | | | | | | | | Upstream commit 246902bdf562d45ea3475fac64c93048a7a39f01 Which contains following explanation: -- There is no need to use GFP_ATOMIC here, GFP_KERNEL should be enough. The 'kcalloc()' just a few lines above, already uses GFP_KERNEL. -- Looking at the code, all other descriptors also use plain GFP_KERNEL Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
* ar71xx/ath79: ag71xx: fix sleep in atomicKoen Vandeputte2019-08-091-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When enabling atomic-sleep-debugging options in the kernel, following splat is seen when disabling the interface (which happens on boot): [ 10.892878] eth0: link down [ 10.896788] BUG: sleeping function called from invalid context at net/core/dev.c:5563 [ 10.904730] in_atomic(): 1, irqs_disabled(): 1, pid: 425, name: ip [ 10.911004] 2 locks held by ip/425: [ 10.914539] #0: (rtnl_mutex){....}, at: [<80377474>] rtnetlink_rcv_msg+0x2d8/0x380 [ 10.922441] #1: (&(&ag->lock)->rlock){....}, at: [<80330158>] ag71xx_hw_disable+0x24/0x94 [ 10.930976] CPU: 0 PID: 425 Comm: ip Not tainted 4.14.136 #0 [ 10.936716] Stack : 805e0000 80589228 80557404 876998ec 80610000 80610000 87cdcafc 805b5327 [ 10.945233] 80551534 000001a9 8061386c 87699ccc 87cfb180 00000001 876998a0 84f70903 [ 10.953751] 00000000 00000000 80b00000 8769979c 6a7407fa 00000000 00000007 00000000 [ 10.962270] 000000b7 16d0954a 000000b6 00000000 80000000 87cb658c 87cb65b0 00000001 [ 10.970787] 8046f97c 87699ccc 87cfb180 87ff2810 00000003 802ce724 0806e098 80610000 [ 10.979306] ... [ 10.981797] Call Trace: [ 10.984287] [<8006cb0c>] show_stack+0x58/0x100 [ 10.988814] [<800aab34>] ___might_sleep+0x100/0x120 [ 10.993774] [<8035c434>] napi_disable+0x30/0xd8 [ 10.998377] [<80330198>] ag71xx_hw_disable+0x64/0x94 [ 11.003418] [<8033069c>] ag71xx_stop+0x24/0x38 [ 11.007959] [<80359e30>] __dev_close_many+0xcc/0x104 [ 11.013009] [<80362eac>] __dev_change_flags+0xc8/0x1ac [ 11.018227] [<80362fb8>] dev_change_flags+0x28/0x70 [ 11.023182] [<80376890>] do_setlink+0x31c/0x91c [ 11.027786] [<80379360>] rtnl_newlink+0x3ec/0x7f8 [ 11.032563] [<80377498>] rtnetlink_rcv_msg+0x2fc/0x380 [ 11.037799] [<8039a734>] netlink_rcv_skb+0xd4/0x178 [ 11.042754] [<80399d10>] netlink_unicast+0x168/0x250 [ 11.047796] [<8039a2d4>] netlink_sendmsg+0x3d8/0x434 [ 11.052841] [<8033f0e4>] ___sys_sendmsg+0x1dc/0x290 [ 11.057794] [<80340140>] __sys_sendmsg+0x54/0x84 [ 11.062495] [<8007212c>] syscall_common+0x34/0x58 This is caused by calling napi_disable() while holding the spinlock. Fix it by omitting the spinlock, which is not required here Extensively tested on GL-MiFi, RB-912 and RB-922 hardware Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
* ath79: support "rgmii-id" PHY mode in ag71xxDaniel Gimpelevich2019-07-171-0/+2
| | | | | | | The ag71xx code did not include a case for the "rgmii-id" PHY mode in the code. There are devices that need this mode, so I'm adding it. Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
* ath79: ag71xx: defer probe if of_phy_connect failedChuanhong Guo2019-06-051-2/+2
| | | | | | | | | gmac0 may need a phy on builtin switch, which can be unavailable if gmac0 is probed before builtin switch. Return -EPROBE_DEFER in this case so that gmac0 can be probed later. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx: update ethtool supportPetr Štetiar2019-06-051-26/+14
| | | | | | | | | | | | ethtool doesn't work currently as phy_ethtool_ioctl expects user space pointer, but it's being passed kernel one. Fixing it doesn't make sense as {s,g}et_settings were deprecated anyway. So let's rather remove phy_ethtool_ioctl and use new {s,g}et_link_ksettings instead. While at it, update nway_reset as well. Cc: John Crispin <john@phrozen.org> Ref: https://bugs.openwrt.org/index.php?do=details&task_id=1982 Signed-off-by: Petr Štetiar <ynezz@true.cz>
* ath79: ag71xx: remove unused SIOCETHTOOL ioctl handlingPetr Štetiar2019-06-051-10/+1
| | | | | | | | | | | | | This ioctl is currently routed through generic interface code: dev_ioctl dev_ethtool __ethtool_get_link_ksettings phy_ethtool_ioctl Cc: John Crispin <john@phrozen.org> Cc: Chuanhong Guo <gch981213@gmail.com> Signed-off-by: Petr Štetiar <ynezz@true.cz>
* ath79: ag71xx: Enable tx hang workaround for the rest of ar724x SoCsPetr Štetiar2019-04-081-1/+8
| | | | | | | | | | | In ar71xx we check for stuck DMA on devices which fall in the is_ar724x SoC group (ar724x, ar933x, ar934x, qca9533, tp9343, qca955x, qca956x). In ath79 we're currently performing this check only for devices with ar7240 SoC, so this patch tries to sync the dma stuck checking behavior with what is being done in ar71xx. Signed-off-by: Petr Štetiar <ynezz@true.cz>
* ath79: ag71xx: remove switch driver in ag71xxChuanhong Guo2019-03-242-1345/+0
| | | | Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx: pass correct device pointer to dma functionsChuanhong Guo2019-03-241-7/+7
| | | | | | | | | linux 4.19 doesn't accept a NULL device for these functions. It also complains that the device struct in net_device doesn't have a dma_mask set. Pass the device struct from platform_device for these functions. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx: add support for timer functions in linux 4.15+Chuanhong Guo2019-03-241-0/+10
| | | | | | | Kernel newer than 4.15 dropped "data" field and used from_timer to cast out the parent struct pointer for current timer. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx: Remove ndo_poll_controllerRosen Penev2019-03-131-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | It is unused by default and upstream is trying to remove it as it has negative effects when the driver is under load. Upstream explanation: netpoll: avoid capture effects for NAPI drivers As diagnosed by Song Liu, ndo_poll_controller() can be very dangerous on loaded hosts, since the cpu calling ndo_poll_controller() might steal all NAPI contexts (for all RX/TX queues of the NIC). This capture, showing one ksoftirqd eating all cycles can last for unlimited amount of time, since one cpu is generally not able to drain all the queues under load. It seems that all networking drivers that do use NAPI for their TX completions, should not provide a ndo_poll_controller() : Most NAPI drivers have netpoll support already handled in core networking stack, since netpoll_poll_dev( uses poll_napi(dev) to iterate through registered NAPI contexts for a device. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* ath79: gmac: ar934x: Add parser for mii-gmac0-slavePetr Štetiar2019-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | While converting Nanostation M XW from current ar71xx code to ath79 I've hit one issue, where the ethernet networking wasn't working, so I was checking every bit in the networking setup path between ar71xx and ath79. I've came to the following code in ar71xx/mach-ubnt-xm.c: static void __init ubnt_xw_init(void) { ... ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE); ... } Where this code is setting AR934X_ETH_CFG_MII_GMAC0_SLAVE bit in AR934X_GMAC_REG_ETH_CFG register, but I couldn't find a way of setting this bit from DTS, so this patch adds `mii-gmac0-slave` DTS property which allows setting of this bit in `gmac-config`, which is then used in Nanostation M XW DTS. Tested-by: Joe Ayers <ae6xe@arrl.net> Signed-off-by: Petr Štetiar <ynezz@true.cz>
* ath79: ag71xx: add support for optional mdio resetChuanhong Guo2019-03-052-1/+8
| | | | | | | | | | | | | | | | | | | | | | On ar933x and later chips, there are separated mac/mdio resets, but resetting the entire gmac block with register values requires both mac_reset and mdio_reset to be asserted together. Add support for optional mdio reset so that we can do a full reset if needed. This patch also replaced deprecated devm_reset_control_get for mac reset. To use this feature, the following is needed: 1. drop "simple-mfd" compatible to register mdio0 after gmac init so that mdio registers aren't reset after initialization. 2. move mdio reset from mdio-bus to its parent eth node. NOTE: This can't be applied on gmac1 with builtin switch since we haven't add a feature to defer probe if phy connection failed. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx: register mdio using of_platform_populateChuanhong Guo2019-03-051-5/+12
| | | | | | | remove the hacky checking of "simple-mfd" compatible also add some comments explaining that piece of code. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx-mdio: get reset control using devm apiChuanhong Guo2019-03-051-1/+1
| | | | Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* ath79: ag71xx: replace alloc_etherdev with devm_alloc_etherdevChuanhong Guo2019-03-051-22/+11
| | | | | | | | using the devm api makes the code simpler. also drop unneeded memory free from ag71xx_remove since they are allocated using devm apis. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>