Skip to contentSkip to conversation

ath9k: add loader for AR92XX (and older) pci(e)

PATCH Superseded Christian Lamparter 3 participants 4 messages Jun 9, 2019 – Jul 1, 2019

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ath9k: add loader for AR92XX (and older) pci(e)

Atheros cards with a AR92XX generation (and older) chip usually store their pci(e) initialization vectors on an external eeprom chip. However these chips technically don't need the eeprom chip attached, the AR9280 Datasheet in section "6.1.2 DEVICE_ID" describes that "... if the EEPROM content is not valid, a value of 0xFF1C returns when read from the register". So, they will show up on the system's pci bus. However in that state, ath9k can't load, since it relies on having the correct pci-id, otherwise it doesn't know what chip it actually is. This happens on many embedded devices like routers and accesspoint since they want to keep the BOM low and store the pci(e) initialization vectors together with the calibration data on the system's FLASH, which is out of reach of the ath9k chip.

Furthermore, Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this should be done as a pci quirk during the early stages of booting linux. 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

---
v3: changed module description

v2: address Julian Calaby's comments:
- make it a separate driver again (much like OpenWrt)
- remove ar71xx leftovers (pdata)

---
 drivers/net/wireless/ath/ath9k/Kconfig        |  16 ++
 drivers/net/wireless/ath/ath9k/Makefile       |   2 +
 .../wireless/ath/ath9k/ath9k_pci_owl_loader.c | 215 ++++++++++++++++++
 3 files changed, 233 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c
drivers/net/wireless/ath/ath9k/Kconfig +16 -0
index a1ef8769983a..d6a87698a44a 100644
@@ -157,6 +157,22 @@ config ATH9K_PCOEM
 	depends on ATH9K
 	default y
 
+config ATH9K_PCI_NO_EEPROM
+	tristate "Atheros ath9k pci loader for EEPROM-less chips"
+	depends on ATH9K_PCI
+	default n
+	help
+	 This separate driver provides a loader in order to support the
+	 AR500X to AR92XX-generation of ath9k PCI(e) WiFi chips, which have
+	 their initialization data (which contains the real PCI Device ID
+	 that ath9k will need) 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/Makefile +2 -0
index f71b2ad8275c..abd0f61370d9 100644
@@ -77,3 +77,5 @@ ath9k_htc-y +=	htc_hst.o \
 ath9k_htc-$(CONFIG_ATH9K_HTC_DEBUGFS) += htc_drv_debug.o
 
 obj-$(CONFIG_ATH9K_HTC) += ath9k_htc.o
+
+obj-$(CONFIG_ATH9K_PCI_NO_EEPROM) += ath9k_pci_owl_loader.o
drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c new file +215 -0

215 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw
Quoted 32 lines · Christian Lamparter

Atheros cards with a AR92XX generation (and older) chip usually store their pci(e) initialization vectors on an external eeprom chip. However these chips technically don't need the eeprom chip attached, the AR9280 Datasheet in section "6.1.2 DEVICE_ID" describes that "... if the EEPROM content is not valid, a value of 0xFF1C returns when read from the register". So, they will show up on the system's pci bus. However in that state, ath9k can't load, since it relies on having the correct pci-id, otherwise it doesn't know what chip it actually is. This happens on many embedded devices like routers and accesspoint since they want to keep the BOM low and store the pci(e) initialization vectors together with the calibration data on the system's FLASH, which is out of reach of the ath9k chip.

Furthermore, Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this should be done as a pci quirk during the early stages of booting linux. 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

[...]

Quoted 4 lines
drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c new file +1 -0
@@ -0,0 +1,215 @@
+// SPDX-License-Identifier: GPL-2.0

[...]

Quoted 1 line

+MODULE_LICENSE("GPL v2");

ath9k has ISC license, is there a specific reason why you chose GPLv2 here instead of ISC? I don't like mixing licenses within a driver, that's why I'm asking.

Signature · 1 line
Kalle Valo
#2 lore raw

Hello,

(Sorry for the delay. I only have time for dealing with this on the weekends. Thanks!)

Quoted 43 lines · CEST Kalle Valo
Quoted 32 lines · Christian Lamparter

Atheros cards with a AR92XX generation (and older) chip usually store their pci(e) initialization vectors on an external eeprom chip. However these chips technically don't need the eeprom chip attached, the AR9280 Datasheet in section "6.1.2 DEVICE_ID" describes that "... if the EEPROM content is not valid, a value of 0xFF1C returns when read from the register". So, they will show up on the system's pci bus. However in that state, ath9k can't load, since it relies on having the correct pci-id, otherwise it doesn't know what chip it actually is. This happens on many embedded devices like routers and accesspoint since they want to keep the BOM low and store the pci(e) initialization vectors together with the calibration data on the system's FLASH, which is out of reach of the ath9k chip.

Furthermore, Some devices (like the Cisco Meraki Z1 Cloud Managed Teleworker Gateway) need to be able to initialize the PCIe wifi device. Normally, this should be done as a pci quirk during the early stages of booting linux. 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

[...]

Quoted 4 lines
drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c new file +1 -0
@@ -0,0 +1,215 @@
+// SPDX-License-Identifier: GPL-2.0

[...]

Quoted 5 lines
Quoted 1 line

+MODULE_LICENSE("GPL v2");

ath9k has ISC license, is there a specific reason why you chose GPLv2 here instead of ISC? I don't like mixing licenses within a driver, that's why I'm asking.

About that: The commit message hints The owl-loader was written because Chris Blake needed it for the Cisco Meraki Z1 (Atheros based SoC) because the existing methods in the OpenWrt project were designed to work with straight-from-SPI-NOR. OpenWrt already had multiple different versions for each platform (ar71xx = Atheros SoCs, lantiq, brcm63xx) of the pci-ath9k-fixup.c which are all licensed under GPLv2 and they predated owl-loader initiative by about 8 years.

https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c
(lantiq's version has been since replaced by the owl-loader)
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/brcm63xx/patches-4.14/416-BCM63XX-add-a-fixup-for-ath9k-devices.patch

(ar71xx has been deprecated and will be dropped in favor of the upstream DeviceTree ath79 which relies on the owl-loader exclusivly)

So this is were the license comes from: Existing code looks similar. And while the owl-loader was written from scratch as it needed:
- to get the via firmware_request to make it as universal as possible
- be able to support all platforms (no fixed pci(e) addresses)
- separate driver as a module (and not a pci fixup)
I went for the safer "GPLv2" as it is the standard OpenWrt License:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=LICENSE

That said: I have no problem relicensing my code under the ISC, if it helps with the upstreaming process. I've added Chris, Martin and Mathias as they both were consultants, as well as the previous authors of three targets to "let them know".

Best Regards,
Christian

(Yeah, I think this might take a while longer. So please don't delete it just yet.)

#3 lore raw

On Sat, Jun 29, 2019 at 10:44 AM Christian Lamparter <[email protected]> wrote:
[...]

Quoted 4 lines

That said: I have no problem relicensing my code under the ISC, if it helps with the upstreaming process. I've added Chris, Martin and Mathias as they both were consultants, as well as the previous authors of three targets to "let them know".

I am also fine with re-licensing my part of the code (to make it
explicit: of the ath9k PCI OWL loader) under the ISC (which is expressed as MODULE_LICENSE("Dual BSD/GPL") in the ath9k driver code)

Martin