summaryrefslogtreecommitdiff
path: root/arch/arm/mach-msm/htc_wifi_nvs.c
blob: 95b8c3bbae9d84c6fc2db53226181b3ae271564e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* arch/arm/mach-msm/htc_wifi_nvs.c
 *
 * Code to extract WiFi calibration information from ATAG set up 
 * by the bootloader.
 *
 * Copyright (C) 2008 Google, Inc.
 * Author: Dmitry Shmidt <dimitrysh@google.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>

#include <asm/setup.h>

/* configuration tags specific to msm */
#define ATAG_MSM_WIFI	0x57494649 /* MSM WiFi */

#define MAX_NVS_SIZE	0x800U
static unsigned char wifi_nvs_ram[MAX_NVS_SIZE];

unsigned char *get_wifi_nvs_ram( void )
{
	return( wifi_nvs_ram );
}
EXPORT_SYMBOL(get_wifi_nvs_ram);

static int __init parse_tag_msm_wifi(const struct tag *tag)
{
	unsigned char *dptr = (unsigned char *)(&tag->u);
	unsigned size;
	
	size = min((tag->hdr.size - 2) * sizeof(__u32), MAX_NVS_SIZE);
#ifdef ATAG_MSM_WIFI_DEBUG	
	unsigned i;
	
	printk("WiFi Data size = %d , 0x%x\n", tag->hdr.size, tag->hdr.tag);
	for(i=0;( i < size );i++) {
		printk("%02x ", *dptr++);
	}
#endif	
	memcpy( (void *)wifi_nvs_ram, (void *)dptr, size );
	return 0;
}

__tagtable(ATAG_MSM_WIFI, parse_tag_msm_wifi);