ath9k: integrate AR92XX pci fixup code
RFC PATCH 1/1 ath9k: integrate AR92XX pci fixup code
Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this is done during the early stages of booting linux, because the necessary init code is read from the memory mapped SPI and passed to pci_enable_ath9k_fixup. However, this isn't possible for devices which have the init code for the Atheros chip stored on NAND in an UBI volume. Hence, this module can be used to initialize the chip when the user-space is ready to extract the init code.
Martin Blumenstingl prodived the following fixes:
owl-loader: add support for OWL emulation PCI devices
owl-loader: don't re-scan the bus when ath9k_pci_fixup failed
owl-loader: use dev_* instead of pr_* logging functions
owl-loader: auto-generate the eeprom filename as fallback
owl-loader: add a debug message when swapping the eeprom data
owl-loader: add missing newlines in log messages
--- drivers/net/wireless/ath/ath9k/Kconfig | 15 ++ drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/pci.c | 252 ++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/Kconfig +15 -0
@@ -157,6 +157,21 @@ config ATH9K_PCOEM depends on ATH9K default y +config ATH9K_PCI_NO_EEPROM + bool "Atheros ath9k support for EEPROM-less chips" + depends on ATH9K_PCI + default n + help + Say Y to support AR92XX-generation of ath9k PCI(e) WiFi chips, which + have their initialization data (which contains the PCI Device ID!) + stored together with the calibration data out of reach for the ath9k + chip. + + These devices are usually various network appliances, routers or + access Points and such. + + If unsure say N. + config ATH9K_HTC tristate "Atheros HTC based wireless cards support" depends on USB && MAC80211
drivers/net/wireless/ath/ath9k/ath9k.h +1 -0
@@ -959,6 +959,7 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);#define ATH9K_PCI_NO_PLL_PWRSAVE 0x0200#define ATH9K_PCI_KILLER 0x0400#define ATH9K_PCI_LED_ACT_HI 0x0800 +#define ATH9K_PCI_NO_EEPROM 0x1000/* * Default cache line size, in bytes.
drivers/net/wireless/ath/ath9k/pci.c +250 -2
284 lines not on this page · raw message
Signature · 1 line
2.20.1
Hi Christian,
Quoted 18 lines · Christian Lamparter
Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this is done during the early stages of booting linux, because the necessary init code is read from the memory mapped SPI and passed to
pci_enable_ath9k_fixup. However, this isn't possible for devices which have the init code for the Atheros chip stored on NAND in an UBI volume. Hence, this module can be used to initialize the chip when the user-space is ready to extract the init code.Martin Blumenstingl prodived the following fixes:
owl-loader: add support for OWL emulation PCI devices
owl-loader: don't re-scan the bus whenath9k_pci_fixupfailed
owl-loader: use dev_* instead of pr_* logging functions
owl-loader: auto-generate the eeprom filename as fallback
owl-loader: add a debug message when swapping the eeprom data
owl-loader: add missing newlines in log messages
Quoted 2 lines
Signed-off-by Christian Lamparter <[email protected]>Signed-off-by Martin Blumenstingl <[email protected]>
Two questions:
1. This seems complicated enough that the functions introduced should probably go into a separate .c file, maybe "noeeprom.c", with a header file with all the ifdef / config magic in it.
2. This smells almost like a completely separate PCI(e) driver for cards in a "weird" state. Is there anything you're using from ath9k other than the eeprom file naming? and is that really useful? Won't the eeprom files be device specific and therefore could always use the device name fallback?
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Hello Julian,
Quoted 19 lines · CEST Julian Calaby
Quoted 18 lines · Christian Lamparter
Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this is done during the early stages of booting linux, because the necessary init code is read from the memory mapped SPI and passed to
pci_enable_ath9k_fixup. However, this isn't possible for devices which have the init code for the Atheros chip stored on NAND in an UBI volume. Hence, this module can be used to initialize the chip when the user-space is ready to extract the init code.Martin Blumenstingl prodived the following fixes:
owl-loader: add support for OWL emulation PCI devices
owl-loader: don't re-scan the bus whenath9k_pci_fixupfailed
owl-loader: use dev_* instead of pr_* logging functions
owl-loader: auto-generate the eeprom filename as fallback
owl-loader: add a debug message when swapping the eeprom data
owl-loader: add missing newlines in log messages
Quoted 8 lines
Quoted 2 lines
Signed-off-by Christian Lamparter <[email protected]>Signed-off-by Martin Blumenstingl <[email protected]>Two questions:
1. This seems complicated enough that the functions introduced should probably go into a separate .c file, maybe "
noeeprom.c", with a header file with all the ifdef / config magic in it.
In openwrt we called it owl-loader.c and it's a separate module there. But I don't think that noeeprom.c is that great since ath9k also supports AHB and htc_usb, so from this perspective it would mean:pci_init_noeeprom.c ? (As AR5008, AR9160 and AR92XX seem to be affected).
Quoted 2 lines
2. This smells almost like a completely separate PCI(e) driver for cards in a "weird" state.
It's in the Datasheet that the device initializes into this state. See AR9280 6.1.2 DEVICE_ID. "... if the EEPROM content is not valid, a value of 0XFF1C returns when read from the register". This would also mean that this routine can be used to resurrect aging AR9280 cards that have a failed eeprom or are from APPLE, see this thread:
<https://www.mail-archive.com/[email protected]/msg03918.html>
"does anyone know whether 168c:ff1c can be supported by the current ath9k driver? It isn't listed with the PCI IDs in the source. I bought it off eBay as "Apple" AR5008. It is a PCI Express card with 3 Antenna connectors and lots of Apple stampings on it. lspci says:"
Quoted 4 lines
Is there anything you're using from ath9k
other than the eeprom file naming? and is that really useful? Won't the eeprom files be device specific and therefore could always use the device name fallback?
Please take a look at the commit message. Unfortunately the Z1 stores its calibration data in a ubi volume, these can't be easily read without interfacing with either ubi or the vfs. In the future, simpler devices that have it on SPI-NOR in a mtd partition can setup a nvmem provider and the code can have a nvmem-consumer. (see attached patch).
Note: There are also devices with mutliple ath9k pci(e) chips (usually one 2.4Ghz and one 5GHz), so a generic "ath9k" name is too short and the pciids of both are the same. That's why the pci-bus location is currently used for the eeprom name identifier.
Regards,
Christian
---
Note: nvmem dts is not finalized. See
commit 517f14d9cf3533d5ab4fded195ab6f80a92e378f
Author: Bartosz Golaszewski <[email protected]> Date: Fri Nov 30 11:53:25 2018 +0000
nvmem: add new config option
for details why adding something like this unfinished patch just does not makes sense (yet).
drivers/net/wireless/ath/ath9k/pci.c +17 -0
@@ -21,6 +21,7 @@#include <linux/module.h> #include <linux/firmware.h> #include <linux/completion.h> +#include <linux/nvmem-consumer.h> #include <linux/ath9k_platform.h> #include "ath9k.h" #include "eeprom.h"
@@ -1053,6 +1054,7 @@ static int ath_pci_fixup_probe(struct pci_dev *pdev, const struct pci_device_id *id) {struct ath_pci_fixup_ctx *ctx; +struct nvmem_cell *cell;const char *eeprom_name;int err =0 ;
@@ -1062,6 +1064,21 @@ static int ath_pci_fixup_probe(struct pci_dev *pdev,pcim_pin_device (pdev); + cell =nvmem_cell_get (&pdev->dev,"caldata" ); +if (!IS_ERR (cell)) { +void *value; +size_t len; + + value =nvmem_cell_read (cell, &len); +if (!IS_ERR (value)) { + err =ath_pci_fixup (pdev, value, len); +kfree (value); + }else + err = -EINVAL ; +nvmem_cell_put (cell); +return err; + } + eeprom_name =ath_pci_fixup_get_eeprom_name (pdev);if (!eeprom_name) {dev_err (&pdev->dev,"no eeprom filename found.\n" );
Hi Christian,
Quoted 28 lines · Christian Lamparter
Hello Julian,
Quoted 24 lines · CEST Julian Calaby
Quoted 18 lines · Christian Lamparter
Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this is done during the early stages of booting linux, because the necessary init code is read from the memory mapped SPI and passed to
pci_enable_ath9k_fixup. However, this isn't possible for devices which have the init code for the Atheros chip stored on NAND in an UBI volume. Hence, this module can be used to initialize the chip when the user-space is ready to extract the init code.Martin Blumenstingl prodived the following fixes:
owl-loader: add support for OWL emulation PCI devices
owl-loader: don't re-scan the bus whenath9k_pci_fixupfailed
owl-loader: use dev_* instead of pr_* logging functions
owl-loader: auto-generate the eeprom filename as fallback
owl-loader: add a debug message when swapping the eeprom data
owl-loader: add missing newlines in log messagesQuoted 2 lines
Signed-off-by Christian Lamparter <[email protected]>Signed-off-by Martin Blumenstingl <[email protected]>Two questions:
Quoted 8 lines
Quoted 3 lines
1. This seems complicated enough that the functions introduced should probably go into a separate .c file, maybe "
noeeprom.c", with a header file with all the ifdef / config magic in it.In openwrt we called it
owl-loader.cand it's a separate module there. But I don't think thatnoeeprom.cis that great since ath9k also supports AHB andhtc_usb, so from this perspective it would mean:pci_init_noeeprom.c? (As AR5008, AR9160 and AR92XX seem to be affected).
Fair enough, I hadn't thought of the other buses.
Quoted 8 lines
Quoted 2 lines
2. This smells almost like a completely separate PCI(e) driver for cards in a "weird" state.
It's in the Datasheet that the device initializes into this state. See AR9280 6.1.2
DEVICE_ID. "... if the EEPROM content is not valid, a value of0XFF1Creturns when read from the register". This would also mean that this routine can be used to resurrect aging AR9280 cards that have a failed eeprom or are from APPLE, see this thread:
Quoted 6 lines
<https://www.mail-archive.com/[email protected]/msg03918.html>
"does anyone know whether 168c:ff1c can be supported by the current ath9k driver? It isn't listed with the PCI IDs in the source. I bought it off eBay as "Apple" AR5008. It is a PCI Express card with 3 Antenna connectors and lots of Apple stampings on it. lspci says:"
I'm asking because (I think) Ath3k Bluetooth devices initialise with one device ID when they don't have firmware, then initialise with a different one once they do. These two states are handled using different drivers. This seems like almost identical behaviour and looks like it could be handled the same way. The code here looks like it's just using the common boilerplate pci device initialisation code from ath9k before doing it's own completely separate thing including having PCI driver data in a different format to the rest of the ath9k driver.
Quoted 9 lines
Quoted 4 lines
Is there anything you're using from ath9k
other than the eeprom file naming? and is that really useful? Won't the eeprom files be device specific and therefore could always use the device name fallback?Please take a look at the commit message. Unfortunately the Z1 stores its calibration data in a ubi volume, these can't be easily read without interfacing with either ubi or the vfs. In the future, simpler devices that have it on SPI-NOR in a mtd partition can setup a nvmem provider and the code can have a nvmem-consumer. (see attached patch).
Fair enough, I was reading the code as-is, not looking forward to other possibilities.
Quoted 4 lines
Note: There are also devices with mutliple ath9k pci(e) chips (usually one 2.4Ghz and one 5GHz), so a generic "ath9k" name is too short and the pciids of both are the same. That's why the pci-bus location is currently used for the eeprom name identifier.
I've finally worked out what was bothering me about the code: you look at the platform data expecting it to be in the ath9k_platform_data structure, however as far as I can tell, the platform data is only ever set by reading the eeprom, which doesn't happen when there isn't one, therefore the eeprom name retrieval will always fall back to dev_name(). I'm assuming that dev_name() returns something sufficiently unique to identify multiple different cards in a system.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/