iwl-nvm-parse.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /*
  3. * Copyright (C) 2005-2015, 2018-2021 Intel Corporation
  4. * Copyright (C) 2016-2017 Intel Deutschland GmbH
  5. */
  6. #ifndef __iwl_nvm_parse_h__
  7. #define __iwl_nvm_parse_h__
  8. #include <net/cfg80211.h>
  9. #include "iwl-eeprom-parse.h"
  10. #include "mei/iwl-mei.h"
  11. /**
  12. * enum iwl_nvm_sbands_flags - modification flags for the channel profiles
  13. *
  14. * @IWL_NVM_SBANDS_FLAGS_LAR: LAR is enabled
  15. * @IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ: disallow 40, 80 and 160MHz on 5GHz
  16. */
  17. enum iwl_nvm_sbands_flags {
  18. IWL_NVM_SBANDS_FLAGS_LAR = BIT(0),
  19. IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ = BIT(1),
  20. };
  21. /**
  22. * iwl_parse_nvm_data - parse NVM data and return values
  23. *
  24. * This function parses all NVM values we need and then
  25. * returns a (newly allocated) struct containing all the
  26. * relevant values for driver use. The struct must be freed
  27. * later with iwl_free_nvm_data().
  28. */
  29. struct iwl_nvm_data *
  30. iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
  31. const struct iwl_fw *fw,
  32. const __be16 *nvm_hw, const __le16 *nvm_sw,
  33. const __le16 *nvm_calib, const __le16 *regulatory,
  34. const __le16 *mac_override, const __le16 *phy_sku,
  35. u8 tx_chains, u8 rx_chains);
  36. /**
  37. * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW
  38. *
  39. * This function parses the regulatory channel data received as a
  40. * MCC_UPDATE_CMD command. It returns a newly allocation regulatory domain,
  41. * to be fed into the regulatory core. In case the geo_info is set handle
  42. * accordingly. An ERR_PTR is returned on error.
  43. * If not given to the regulatory core, the user is responsible for freeing
  44. * the regdomain returned here with kfree.
  45. */
  46. struct ieee80211_regdomain *
  47. iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
  48. int num_of_ch, __le32 *channels, u16 fw_mcc,
  49. u16 geo_info, u16 cap, u8 resp_ver);
  50. /**
  51. * struct iwl_nvm_section - describes an NVM section in memory.
  52. *
  53. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  54. * and saved for later use by the driver. Not all NVM sections are saved
  55. * this way, only the needed ones.
  56. */
  57. struct iwl_nvm_section {
  58. u16 length;
  59. const u8 *data;
  60. };
  61. /**
  62. * iwl_read_external_nvm - Reads external NVM from a file into nvm_sections
  63. */
  64. int iwl_read_external_nvm(struct iwl_trans *trans,
  65. const char *nvm_file_name,
  66. struct iwl_nvm_section *nvm_sections);
  67. void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data,
  68. unsigned int len);
  69. /**
  70. * iwl_get_nvm - retrieve NVM data from firmware
  71. *
  72. * Allocates a new iwl_nvm_data structure, fills it with
  73. * NVM data, and returns it to caller.
  74. */
  75. struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans,
  76. const struct iwl_fw *fw);
  77. /**
  78. * iwl_parse_mei_nvm_data - parse the mei_nvm_data and get an iwl_nvm_data
  79. */
  80. struct iwl_nvm_data *
  81. iwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
  82. const struct iwl_mei_nvm *mei_nvm,
  83. const struct iwl_fw *fw);
  84. #endif /* __iwl_nvm_parse_h__ */