/arch/arm/mach-msm/board-trout-wifi.c

https://github.com/AICP/kernel_google_msm · C · 74 lines · 50 code · 9 blank · 15 comment · 6 complexity · 999c9dbf569fee2935b6c93e59a33e25 MD5 · raw file

  1. /* arch/arm/mach-msm/board-trout-wifi.c
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. * Author: Dmitry Shmidt <dimitrysh@google.com>
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifdef CONFIG_WIFI_CONTROL_FUNC
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/vmalloc.h>
  21. #include <linux/err.h>
  22. #include <linux/wifi_tiwlan.h>
  23. extern int trout_wifi_set_carddetect(int val);
  24. extern int trout_wifi_power(int on);
  25. extern int trout_wifi_reset(int on);
  26. #ifdef CONFIG_WIFI_MEM_PREALLOC
  27. typedef struct wifi_mem_prealloc_struct {
  28. void *mem_ptr;
  29. unsigned long size;
  30. } wifi_mem_prealloc_t;
  31. static wifi_mem_prealloc_t wifi_mem_array[WMPA_NUMBER_OF_SECTIONS] = {
  32. { NULL, (WMPA_SECTION_SIZE_0 + WMPA_SECTION_HEADER) },
  33. { NULL, (WMPA_SECTION_SIZE_1 + WMPA_SECTION_HEADER) },
  34. { NULL, (WMPA_SECTION_SIZE_2 + WMPA_SECTION_HEADER) }
  35. };
  36. static void *trout_wifi_mem_prealloc(int section, unsigned long size)
  37. {
  38. if( (section < 0) || (section >= WMPA_NUMBER_OF_SECTIONS) )
  39. return NULL;
  40. if( wifi_mem_array[section].size < size )
  41. return NULL;
  42. return wifi_mem_array[section].mem_ptr;
  43. }
  44. int __init trout_init_wifi_mem( void )
  45. {
  46. int i;
  47. for(i=0;( i < WMPA_NUMBER_OF_SECTIONS );i++) {
  48. wifi_mem_array[i].mem_ptr = vmalloc(wifi_mem_array[i].size);
  49. if( wifi_mem_array[i].mem_ptr == NULL )
  50. return -ENOMEM;
  51. }
  52. return 0;
  53. }
  54. #endif
  55. struct wifi_platform_data trout_wifi_control = {
  56. .set_power = trout_wifi_power,
  57. .set_reset = trout_wifi_reset,
  58. .set_carddetect = trout_wifi_set_carddetect,
  59. #ifdef CONFIG_WIFI_MEM_PREALLOC
  60. .mem_prealloc = trout_wifi_mem_prealloc,
  61. #else
  62. .mem_prealloc = NULL,
  63. #endif
  64. };
  65. #endif