1
0

328-ath9k-parse-the-device-configuration-from-an-OF-node.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. From cea03be5a848823cb8052e2e7b93cb2249d5f60c Mon Sep 17 00:00:00 2001
  2. From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  3. Date: Sun, 16 Oct 2016 22:59:07 +0200
  4. Subject: [PATCH 3/3] ath9k: parse the device configuration from an OF node
  5. This allows setting the MAC address and specifying that the firmware
  6. will be requested from userspace (because there might not be a hardware
  7. EEPROM connected to the chip) for ath9k based PCI devices using
  8. the device tree.
  9. There is some out-of-tree code to "convert devicetree to
  10. ath9k_platform_data" (for example in OpenWrt and LEDE) which becomes
  11. obsolete with this patch.
  12. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  13. Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  14. ---
  15. drivers/net/wireless/ath/ath9k/init.c | 42 +++++++++++++++++++++++++++++++++++
  16. 1 file changed, 42 insertions(+)
  17. --- a/drivers/net/wireless/ath/ath9k/init.c
  18. +++ b/drivers/net/wireless/ath/ath9k/init.c
  19. @@ -20,6 +20,8 @@
  20. #include <linux/slab.h>
  21. #include <linux/ath9k_platform.h>
  22. #include <linux/module.h>
  23. +#include <linux/of.h>
  24. +#include <linux/of_net.h>
  25. #include <linux/relay.h>
  26. #include <net/ieee80211_radiotap.h>
  27. @@ -554,6 +556,42 @@ static int ath9k_init_platform(struct at
  28. return 0;
  29. }
  30. +static int ath9k_of_init(struct ath_softc *sc)
  31. +{
  32. + struct device_node *np = sc->dev->of_node;
  33. + struct ath_hw *ah = sc->sc_ah;
  34. + struct ath_common *common = ath9k_hw_common(ah);
  35. + enum ath_bus_type bus_type = common->bus_ops->ath_bus_type;
  36. + const char *mac;
  37. + char eeprom_name[100];
  38. + int ret;
  39. +
  40. + if (!of_device_is_available(np))
  41. + return 0;
  42. +
  43. + ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
  44. +
  45. + if (of_property_read_bool(np, "qca,no-eeprom")) {
  46. + /* ath9k-eeprom-<bus>-<id>.bin */
  47. + scnprintf(eeprom_name, sizeof(eeprom_name),
  48. + "ath9k-eeprom-%s-%s.bin",
  49. + ath_bus_type_to_string(bus_type), dev_name(ah->dev));
  50. +
  51. + ret = ath9k_eeprom_request(sc, eeprom_name);
  52. + if (ret)
  53. + return ret;
  54. + }
  55. +
  56. + mac = of_get_mac_address(np);
  57. + if (mac)
  58. + ether_addr_copy(common->macaddr, mac);
  59. +
  60. + ah->ah_flags &= ~AH_USE_EEPROM;
  61. + ah->ah_flags |= AH_NO_EEP_SWAP;
  62. +
  63. + return 0;
  64. +}
  65. +
  66. static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
  67. const struct ath_bus_ops *bus_ops)
  68. {
  69. @@ -610,6 +648,10 @@ static int ath9k_init_softc(u16 devid, s
  70. if (ret)
  71. return ret;
  72. + ret = ath9k_of_init(sc);
  73. + if (ret)
  74. + return ret;
  75. +
  76. if (ath9k_led_active_high != -1)
  77. ah->config.led_active_high = ath9k_led_active_high == 1;