Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | |
| 24 | #include <asm/setup.h> |
| 25 | |
| 26 | /* configuration tags specific to msm */ |
| 27 | #define ATAG_MSM_WIFI 0x57494649 /* MSM WiFi */ |
| 28 | |
| 29 | #define MAX_NVS_SIZE 0x800U |
| 30 | static unsigned char wifi_nvs_ram[MAX_NVS_SIZE]; |
| 31 | |
| 32 | unsigned char *get_wifi_nvs_ram( void ) |
| 33 | { |
| 34 | return( wifi_nvs_ram ); |
| 35 | } |
| 36 | EXPORT_SYMBOL(get_wifi_nvs_ram); |
| 37 | |
| 38 | static int __init parse_tag_msm_wifi(const struct tag *tag) |
| 39 | { |
| 40 | unsigned char *dptr = (unsigned char *)(&tag->u); |
| 41 | unsigned size; |
| 42 | |
| 43 | size = min((tag->hdr.size - 2) * sizeof(__u32), MAX_NVS_SIZE); |
| 44 | #ifdef ATAG_MSM_WIFI_DEBUG |
| 45 | unsigned i; |
| 46 | |
| 47 | printk("WiFi Data size = %d , 0x%x\n", tag->hdr.size, tag->hdr.tag); |
| 48 | for (i = 0; i < size; i++) |
| 49 | printk("%02x ", *dptr++); |
| 50 | #endif |
| 51 | memcpy( (void *)wifi_nvs_ram, (void *)dptr, size ); |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | __tagtable(ATAG_MSM_WIFI, parse_tag_msm_wifi); |