htc_wifi_nvs.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* arch/arm/mach-msm/htc_wifi_nvs.c
  2. *
  3. * Code to extract WiFi calibration information from ATAG set up
  4. * by the bootloader.
  5. *
  6. * Copyright (C) 2008 Google, Inc.
  7. * Author: Dmitry Shmidt <dimitrysh@google.com>
  8. *
  9. * This software is licensed under the terms of the GNU General Public
  10. * License version 2, as published by the Free Software Foundation, and
  11. * may be copied, distributed, and modified under those terms.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <asm/setup.h>
  23. /* configuration tags specific to msm */
  24. #define ATAG_MSM_WIFI 0x57494649 /* MSM WiFi */
  25. #define MAX_NVS_SIZE 0x800U
  26. static unsigned char wifi_nvs_ram[MAX_NVS_SIZE];
  27. unsigned char *get_wifi_nvs_ram( void )
  28. {
  29. return( wifi_nvs_ram );
  30. }
  31. EXPORT_SYMBOL(get_wifi_nvs_ram);
  32. static int __init parse_tag_msm_wifi(const struct tag *tag)
  33. {
  34. unsigned char *dptr = (unsigned char *)(&tag->u);
  35. unsigned size;
  36. size = min((tag->hdr.size - 2) * sizeof(__u32), MAX_NVS_SIZE);
  37. #ifdef ATAG_MSM_WIFI_DEBUG
  38. unsigned i;
  39. printk("WiFi Data size = %d , 0x%x\n", tag->hdr.size, tag->hdr.tag);
  40. for (i = 0; i < size; i++)
  41. printk("%02x ", *dptr++);
  42. #endif
  43. memcpy( (void *)wifi_nvs_ram, (void *)dptr, size );
  44. return 0;
  45. }
  46. __tagtable(ATAG_MSM_WIFI, parse_tag_msm_wifi);