summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mediatek/mt76/eeprom.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* wifi: mt76: add support for providing eeprom in nvmem cellsChristian Marangi2023-07-261-1/+37
| | | | | | | | | | | | | Add support for providing eeprom in nvmem cells by adding nvmem cell as an alternative source for mt76_get_of_eeprom(). Nvmem cells will follow standard nvmem cell definition and needs to be called 'eeprom' to be correctly identified. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Daniel Golle <daniel@makrotopia.org> Tested-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* wifi: mt76: split get_of_eeprom in subfunctionChristian Marangi2023-07-261-16/+35
| | | | | | | | | | | | | | In preparation for NVMEM support, split get_of_eeprom() in subfunction to tidy the code and facilitate the addition of alternative method to get eeprom data. No behaviour change intended. While at it also drop OF ifdef checks as OF have stubs and calling of_get_property would result in the same error returned. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Daniel Golle <daniel@makrotopia.org> Tested-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* wifi: mt76: support ww power config in dts nodeDeren Wu2023-02-031-0/+1
| | | | | | | | support new node for WW regulatory domain Tested-by: Michael Lo <michael.lo@mediatek.com> Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mediatek: mt76: eeprom: fix missing of_node_put() in ↵Liang He2022-07-111-1/+4
| | | | | | | | | | | mt76_find_power_limits_node() We should use of_node_put() for the reference 'np' returned by of_get_child_by_name() which will increase the refcount. Fixes: 22b980badc0f ("mt76: add functions for parsing rate power limits from DT") Signed-off-by: Liang He <windhl@126.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: eeprom: tolerate corrected bit-flipsDaniel Golle2021-12-191-0/+2
| | | | | | | | | mtd_read() returns -EUCLEAN in case of corrected bit-flips. As data was read, don't error out in this case. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Acked-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: Print error message when reading EEPROM from mtd failedHauke Mehrtens2021-10-231-1/+4
| | | | | | | | | | | | | | | | | | When the EEPROM data is stored on a MTD partition print an error message when reading this MTD partition failed. This is currently happening often in OpenWrt because the initial data was written with using a flash driver which ignores the error detection data and now OpenWrt uses a driver which checks it. With this patch a better error message is shown: [ 8.986988] mt7915e 0000:01:00.0: WA Firmware Version: DEV_000000, Build Time: 20201105222323 [ 9.100508] mt7915e 0000:01:00.0: reading EEPROM from mtd factory failed: -117 [ 9.144289] mt7915e: probe of 0000:01:00.0 failed with error -22 mt7915 does not work without an EEPROM, MT7922 still works. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: support reading EEPROM data embedded in fdtDaniel Golle2021-10-201-0/+11
| | | | | | | | | | Some platforms boot from SD card and don't come with calibration data stored anywhere on the board. As EEPROM data is rather small it can be embedded into the device tree to be loaded from there by the mt76. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: connac: set 6G phymode in single-sku supportLorenzo Bianconi2021-10-201-0/+3
| | | | | | | | | Configure tx rate power for 6GHz channels. This is a preliminary patch to enable 6GHz band for mt7921 devices. Tested-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt7915: add support for applying pre-calibration dataRyder Lee2021-04-211-6/+5
| | | | | | | | | | | | When the EEPROM data is read from flash, it can contain pre-calibration data, which can save calibration time. Note that group_cal can save 30% bootup calibration time, and dpd_cal can save 75% channel switching time. Tested-by: Bo Jiao <bo.jiao@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: extend DT rate power limits to support 11ax devicesShayne Chen2021-04-211-23/+39
| | | | | | | | | | | Enable parsing per-rate txpower limits from DT for 11ax chipsets. Co-developed-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Felix Fietkau <nbd@nbd.name> Tested-by: Evelyn Tsai <evelyn.tsai@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add functions for parsing rate power limits from DTFelix Fietkau2021-04-211-0/+204
| | | | | | | | | | | This subnode can be used to set per-rate tx power limits either per country code / regdomain or globally. These limits are typically provided by the device manufacturers and are used to limit sideband emissions and stay within regulatory limits Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* of: net: pass the dst buffer to of_get_mac_address()Michael Walle2021-04-131-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_get_mac_address() returns a "const void*" pointer to a MAC address. Lately, support to fetch the MAC address by an NVMEM provider was added. But this will only work with platform devices. It will not work with PCI devices (e.g. of an integrated root complex) and esp. not with DSA ports. There is an of_* variant of the nvmem binding which works without devices. The returned data of a nvmem_cell_read() has to be freed after use. On the other hand the return of_get_mac_address() points to some static data without a lifetime. The trick for now, was to allocate a device resource managed buffer which is then returned. This will only work if we have an actual device. Change it, so that the caller of of_get_mac_address() has to supply a buffer where the MAC address is written to. Unfortunately, this will touch all drivers which use the of_get_mac_address(). Usually the code looks like: const char *addr; addr = of_get_mac_address(np); if (!IS_ERR(addr)) ether_addr_copy(ndev->dev_addr, addr); This can then be simply rewritten as: of_get_mac_address(np, ndev->dev_addr); Sometimes is_valid_ether_addr() is used to test the MAC address. of_get_mac_address() already makes sure, it just returns a valid MAC address. Thus we can just test its return code. But we have to be careful if there are still other sources for the MAC address before the of_get_mac_address(). In this case we have to keep the is_valid_ether_addr() call. The following coccinelle patch was used to convert common cases to the new style. Afterwards, I've manually gone over the drivers and fixed the return code variable: either used a new one or if one was already available use that. Mansour Moufid, thanks for that coccinelle patch! <spml> @a@ identifier x; expression y, z; @@ - x = of_get_mac_address(y); + x = of_get_mac_address(y, z); <... - ether_addr_copy(z, x); ...> @@ identifier a.x; @@ - if (<+... x ...+>) {} @@ identifier a.x; @@ if (<+... x ...+>) { ... } - else {} @@ identifier a.x; expression e; @@ - if (<+... x ...+>@e) - {} - else + if (!(e)) {...} @@ expression x, y, z; @@ - x = of_get_mac_address(y, z); + of_get_mac_address(y, z); ... when != x </spml> All drivers, except drivers/net/ethernet/aeroflex/greth.c, were compile-time tested. Suggested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
* mt76: testmode: move mtd part to mt76_devShayne Chen2021-01-261-2/+2
| | | | | | | | | Move testmode mtd variables to mt76_dev, since they are the same on each phy. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Acked-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: testmode: introduce dbdc supportShayne Chen2021-01-261-2/+2
| | | | | | | | | | Add testmode support for DBDC NICs (both MT7615D and MT7915D work). Testmode data and parameters are moved from per-dev to per-phy for maintaining the value of each band. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Acked-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move hw mac_addr in mt76_phyLorenzo Bianconi2020-12-041-5/+7
| | | | | | | This is a preliminary patch to properly support mt7915 dbdc Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add API for testmode supportFelix Fietkau2020-07-211-0/+5
| | | | | | | | | | | This can be used for calibration in the manufacturing process. It supports sending a configurable number of packets with a specific rate and configurable tx power levels / antenna settings. It also supports receiving packets and showing some statistics, including packet counters and detailed RSSI information. It will only be compiled in if CONFIG_NL80211_TESTMODE is enabled Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: fix compilation warning in mt76_eeprom_override()Lorenzo Bianconi2020-02-141-7/+4
| | | | | | | | | | | Fix the following compilation warning in mt76_eeprom_override routine when CONFIG_OF is not set and label 'out' is not actually used drivers/net/wireless/mediatek/mt76/eeprom.c: In function ‘mt76_eeprom_override’: drivers/net/wireless/mediatek/mt76/eeprom.c:100:1: warning: label ‘out’ defined but not used [-Wunused-label] Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: eeprom: add support for big endian eeprom partitionLorenzo Bianconi2020-02-141-0/+10
| | | | | | | | | | | mt76x0e users reported some devices (e.g TP-Link Archer VR200v) have been flashed with big endian radio partition. Add the possibility to specify eeprom endianness using big-endian dts property and in case covert eeprom data in little endian Tested-by: Kevin Schmidt <kevin.patrick.schmidt@googlemail.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: fix possible undetected invalid MAC addressShayne Chen2020-02-141-1/+2
| | | | | | | | | | Make sure the MAC address is checked before function returns. If CONFIG_OF is set and the device node is null, the function will return directly, and an invalid MAC address will not be checked. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: switch to SPDX tag instead of verbose boilerplate textRyder Lee2019-09-051-12/+1
| | | | | | | | | No functional change intended. Add SPDX identifiers to all remaining files in /mt76. Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* net: wireless: mt76: fix similar warning reported by kbuild test robotPetr Štetiar2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes following (similar) warning reported by kbuild test robot: In function ‘memcpy’, inlined from ‘smsc75xx_init_mac_address’ at drivers/net/usb/smsc75xx.c:778:3, inlined from ‘smsc75xx_bind’ at drivers/net/usb/smsc75xx.c:1501:2: ./include/linux/string.h:355:9: warning: argument 2 null where non-null expected [-Wnonnull] return __builtin_memcpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/usb/smsc75xx.c: In function ‘smsc75xx_bind’: ./include/linux/string.h:355:9: note: in a call to built-in function ‘__builtin_memcpy’ I've replaced the offending memcpy with ether_addr_copy, because I'm 100% sure, that of_get_mac_address can't return NULL as it returns valid pointer or ERR_PTR encoded value, nothing else. I'm hesitant to just change IS_ERR into IS_ERR_OR_NULL check, as this would make the warning disappear also, but it would be confusing to check for impossible return value just to make a compiler happy. I'm now changing all occurencies of memcpy to ether_addr_copy after the of_get_mac_address call, as it's very likely, that we're going to get similar reports from kbuild test robot in the future. Fixes: d31a36b5f407 ("net: wireless: support of_get_mac_address new ERR_PTR error") Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Petr Štetiar <ynezz@true.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: wireless: support of_get_mac_address new ERR_PTR errorPetr Štetiar2019-05-061-1/+1
| | | | | | | | | There was NVMEM support added to of_get_mac_address, so it could now return ERR_PTR encoded error values, so we need to adjust all current users of of_get_mac_address to this new fact. Signed-off-by: Petr Štetiar <ynezz@true.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
* mt76: fix a leaked reference by adding a missing of_node_putWen Yang2019-02-281-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | The call to of_find_node_by_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./drivers/net/wireless/mediatek/mt76/eeprom.c:58:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:61:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:67:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:70:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:72:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Cc: Felix Fietkau <nbd@nbd.name> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> Cc: Kalle Valo <kvalo@codeaurora.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: add common code shared between multiple chipsetsFelix Fietkau2017-12-071-0/+112
This will be used by drivers for MT76x2e, MT7603e and MT7628 Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>