iwl-agn-ucode.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. *****************************************************************************/
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/init.h>
  32. #include "iwl-dev.h"
  33. #include "iwl-core.h"
  34. #define IWL_UCODE_GET(item) \
  35. static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\
  36. u32 api_ver) \
  37. { \
  38. if (api_ver <= 2) \
  39. return le32_to_cpu(ucode->u.v1.item); \
  40. return le32_to_cpu(ucode->u.v2.item); \
  41. }
  42. static u32 iwlagn_ucode_get_header_size(u32 api_ver)
  43. {
  44. if (api_ver <= 2)
  45. return UCODE_HEADER_SIZE(1);
  46. return UCODE_HEADER_SIZE(2);
  47. }
  48. static u32 iwlagn_ucode_get_build(const struct iwl_ucode_header *ucode,
  49. u32 api_ver)
  50. {
  51. if (api_ver <= 2)
  52. return 0;
  53. return le32_to_cpu(ucode->u.v2.build);
  54. }
  55. static u8 *iwlagn_ucode_get_data(const struct iwl_ucode_header *ucode,
  56. u32 api_ver)
  57. {
  58. if (api_ver <= 2)
  59. return (u8 *) ucode->u.v1.data;
  60. return (u8 *) ucode->u.v2.data;
  61. }
  62. IWL_UCODE_GET(inst_size);
  63. IWL_UCODE_GET(data_size);
  64. IWL_UCODE_GET(init_size);
  65. IWL_UCODE_GET(init_data_size);
  66. IWL_UCODE_GET(boot_size);
  67. struct iwl_ucode_ops iwlagn_ucode = {
  68. .get_header_size = iwlagn_ucode_get_header_size,
  69. .get_build = iwlagn_ucode_get_build,
  70. .get_inst_size = iwlagn_ucode_get_inst_size,
  71. .get_data_size = iwlagn_ucode_get_data_size,
  72. .get_init_size = iwlagn_ucode_get_init_size,
  73. .get_init_data_size = iwlagn_ucode_get_init_data_size,
  74. .get_boot_size = iwlagn_ucode_get_boot_size,
  75. .get_data = iwlagn_ucode_get_data,
  76. };