blob: 43f827c60f13eabd86c479731bbb555127259f1d [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* arch/arm/mach-msm/board-sapphire-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
17#ifdef CONFIG_WIFI_CONTROL_FUNC
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/vmalloc.h>
22#include <linux/err.h>
23#include <linux/wifi_tiwlan.h>
24
25extern int sapphire_wifi_set_carddetect(int val);
26extern int sapphire_wifi_power(int on);
27extern int sapphire_wifi_reset(int on);
28
29#ifdef CONFIG_WIFI_MEM_PREALLOC
30typedef struct wifi_mem_prealloc_struct {
31 void *mem_ptr;
32 unsigned long size;
33} wifi_mem_prealloc_t;
34
35static wifi_mem_prealloc_t wifi_mem_array[WMPA_NUMBER_OF_SECTIONS] = {
36 { NULL, (WMPA_SECTION_SIZE_0 + WMPA_SECTION_HEADER) },
37 { NULL, (WMPA_SECTION_SIZE_1 + WMPA_SECTION_HEADER) },
38 { NULL, (WMPA_SECTION_SIZE_2 + WMPA_SECTION_HEADER) }
39};
40
41static void *sapphire_wifi_mem_prealloc(int section, unsigned long size)
42{
43 if ((section < 0) || (section >= WMPA_NUMBER_OF_SECTIONS))
44 return NULL;
45 if (wifi_mem_array[section].size < size)
46 return NULL;
47 return wifi_mem_array[section].mem_ptr;
48}
49
50int __init sapphire_init_wifi_mem (void)
51{
52 int i;
53
54 for (i = 0; (i < WMPA_NUMBER_OF_SECTIONS); i++) {
55 wifi_mem_array[i].mem_ptr = vmalloc(wifi_mem_array[i].size);
56 if (wifi_mem_array[i].mem_ptr == NULL)
57 return -ENOMEM;
58 }
59 return 0;
60}
61#endif
62
63struct wifi_platform_data sapphire_wifi_control = {
64 .set_power = sapphire_wifi_power,
65 .set_reset = sapphire_wifi_reset,
66 .set_carddetect = sapphire_wifi_set_carddetect,
67#ifdef CONFIG_WIFI_MEM_PREALLOC
68 .mem_prealloc = sapphire_wifi_mem_prealloc,
69#else
70 .mem_prealloc = NULL,
71#endif
72};
73
74#endif