aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>2016-10-16 16:59:07 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2016-11-15 09:55:42 -0500
commit138b41253d9c9f9a06c8b086880cd3e839a23d69 (patch)
treed8f431bf18b52b7fbbc71e99b063170b1c7b8477 /drivers/net/wireless/ath
parentb40ded2ad75cc251e7ce4ae0db7098e5a0157200 (diff)
ath9k: parse the device configuration from an OF node
This allows setting the MAC address and specifying that the firmware will be requested from userspace (because there might not be a hardware EEPROM connected to the chip) for ath9k based PCI devices using the device tree. There is some out-of-tree code to "convert devicetree to ath9k_platform_data" (for example in OpenWrt and LEDE) which becomes obsolete with this patch. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index cfa3fe82ade3..b7c8ff9b4192 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -20,6 +20,8 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/ath9k_platform.h> 21#include <linux/ath9k_platform.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of.h>
24#include <linux/of_net.h>
23#include <linux/relay.h> 25#include <linux/relay.h>
24#include <net/ieee80211_radiotap.h> 26#include <net/ieee80211_radiotap.h>
25 27
@@ -555,6 +557,42 @@ static int ath9k_init_platform(struct ath_softc *sc)
555 return 0; 557 return 0;
556} 558}
557 559
560static int ath9k_of_init(struct ath_softc *sc)
561{
562 struct device_node *np = sc->dev->of_node;
563 struct ath_hw *ah = sc->sc_ah;
564 struct ath_common *common = ath9k_hw_common(ah);
565 enum ath_bus_type bus_type = common->bus_ops->ath_bus_type;
566 const char *mac;
567 char eeprom_name[100];
568 int ret;
569
570 if (!of_device_is_available(np))
571 return 0;
572
573 ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
574
575 if (of_property_read_bool(np, "qca,no-eeprom")) {
576 /* ath9k-eeprom-<bus>-<id>.bin */
577 scnprintf(eeprom_name, sizeof(eeprom_name),
578 "ath9k-eeprom-%s-%s.bin",
579 ath_bus_type_to_string(bus_type), dev_name(ah->dev));
580
581 ret = ath9k_eeprom_request(sc, eeprom_name);
582 if (ret)
583 return ret;
584 }
585
586 mac = of_get_mac_address(np);
587 if (mac)
588 ether_addr_copy(common->macaddr, mac);
589
590 ah->ah_flags &= ~AH_USE_EEPROM;
591 ah->ah_flags |= AH_NO_EEP_SWAP;
592
593 return 0;
594}
595
558static int ath9k_init_softc(u16 devid, struct ath_softc *sc, 596static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
559 const struct ath_bus_ops *bus_ops) 597 const struct ath_bus_ops *bus_ops)
560{ 598{
@@ -611,6 +649,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
611 if (ret) 649 if (ret)
612 return ret; 650 return ret;
613 651
652 ret = ath9k_of_init(sc);
653 if (ret)
654 return ret;
655
614 if (ath9k_led_active_high != -1) 656 if (ath9k_led_active_high != -1)
615 ah->config.led_active_high = ath9k_led_active_high == 1; 657 ah->config.led_active_high = ath9k_led_active_high == 1;
616 658