diff --git a/arch/arm/configs/htcleo_defconfig b/arch/arm/configs/htcleo_defconfig index c9e0eff5..aba9cc88 100644 --- a/arch/arm/configs/htcleo_defconfig +++ b/arch/arm/configs/htcleo_defconfig @@ -221,6 +221,7 @@ CONFIG_HTC_35MM_JACK=y # CONFIG_HTC_PWRSPLY is not set # CONFIG_HTC_PWRSINK is not set CONFIG_MSM_DALRPC=y +# CONFIG_MSM_DALRPC_TEST is not set CONFIG_CACHE_FLUSH_RANGE_LIMIT=0x40000 CONFIG_MSM7X00A_USE_GP_TIMER=y # CONFIG_MSM7X00A_USE_DG_TIMER is not set @@ -255,7 +256,8 @@ CONFIG_QSD_HTC_FM=y # CONFIG_MSM_CLOCK_CTRL_DEBUG is not set CONFIG_ARCH_MSM_FLASHLIGHT=y CONFIG_WIFI_CONTROL_FUNC=y -# CONFIG_WIFI_MEM_PREALLOC is not set +CONFIG_WIFI_MEM_PREALLOC=y +CONFIG_WIFI_NVS_PROC_CREATE=y # CONFIG_VIRTUAL_KPANIC_PARTITION is not set # CONFIG_HTC_FB_CONSOLE is not set CONFIG_VERY_EARLY_CONSOLE=y @@ -883,7 +885,7 @@ CONFIG_TUN=m CONFIG_WLAN=y # CONFIG_WLAN_PRE80211 is not set # CONFIG_WLAN_80211 is not set -# CONFIG_BCM4329 is not set +CONFIG_BCM4329=m CONFIG_BCM4329_FW_PATH="/system/etc/firmware/fw_bcm4329.bin" CONFIG_BCM4329_NVRAM_PATH="/proc/calibration" CONFIG_BCM4329_204=m diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index 695e68c8..172dcccb 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile @@ -18,7 +18,12 @@ obj-$(CONFIG_ARCH_MSM_SCORPION) += idle-v7.o obj-y += gpio.o generic_gpio.o obj-y += nand_partitions.o obj-y += drv_callback.o -obj-$(CONFIG_ARCH_QSD8X50) += pmic.o htc_wifi_nvs.o htc_bluetooth.o +obj-$(CONFIG_ARCH_QSD8X50) += pmic.o htc_bluetooth.o +ifndef CONFIG_MACH_HTCLEO +obj-$(CONFIG_ARCH_QSD8X50) += htc_wifi_nvs.o +else +obj-$(CONFIG_ARCH_QSD8X50) += board-htcleo-wifi-nvs.o +endif obj-$(CONFIG_MSM_FIQ_SUPPORT) += fiq_glue.o obj-$(CONFIG_MACH_TROUT) += board-trout-rfkill.o @@ -108,7 +113,7 @@ obj-$(CONFIG_MACH_BRAVOC) += board-bravoc-microp.o clock.o obj-$(CONFIG_MACH_HTCLEO) += board-htcleo.o board-htcleo-spi.o board-htcleo-panel.o board-htcleo-keypad.o obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-ts.o board-htcleo-mmc.o ieee754-df.o board-htcleo-power.o obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-battery.o board-htcleo-log.o board-htcleo-acoustic.o board-htcleo-audio.o -obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-bt.o board-htcleo-microp.o +obj-$(CONFIG_MACH_HTCLEO) += board-htcleo-bt.o board-htcleo-microp.o board-htcleo-wifi.o obj-$(CONFIG_MACH_HTCLEO) += clock-wince.o # MSM7x30 boards diff --git a/arch/arm/mach-msm/board-htcleo-wifi-nvs.c b/arch/arm/mach-msm/board-htcleo-wifi-nvs.c new file mode 100644 index 00000000..6c6cdcef --- /dev/null +++ b/arch/arm/mach-msm/board-htcleo-wifi-nvs.c @@ -0,0 +1,91 @@ +/* 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 + * + * 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 +#include +#include +#include + +#include + + +static unsigned char *hardcoded_nvs = + "macaddr=00:11:22:33:44:55\n"\ + "sromrev=3\n"\ + "vendid=0x14e4\n"\ + "devid=0x432f\n"\ + "boardtype=0x4b9\n"\ + "boardrev=0x32\n"\ + "boardflags=0x200\n"\ + "xtalfreq=37400\n"\ + "aa2g=1\n"\ + "aa5g=0\n"\ + "ag0=255\n"\ + "pa0b0=6003\n"\ + "pa0b1=64086\n"\ + "pa0b2=65195\n"\ + "pa0itssit=62\n"\ + "pa0maxpwr=68\n"\ + "opo=0\n"\ + "mcs2gpo0=0x6666\n"\ + "mcs2gpo1=0x6666\n"\ + "rssismf2g=0xa\n"\ + "rssismc2g=0xb\n"\ + "rssisav2g=0x3\n"\ + "bxa2g=0\n"\ + "ccode=ALL\n"\ + "cctl=0x0\n"\ + "cckdigfilttype=0\n"\ + "ofdmdigfilttype=1\n"\ + "rxpo2g=2\n"\ + "boardnum=1\n"\ + "nocrc=1\n"\ + "otpimagesize=182\n"\ + "hwhdr=0x05ffff031030031003100000\n"\ + "RAW1=80 32 fe 21 02 0c 00 22 2a 01 01 00 00 c5 0 e6 00 00 00 00 00 40 00 00 ff ff 80 00 00 00 00 00 00 00 00 00 00 c8 00 00 00 00 00 00 00 00 00 00 00 00 00 ff 20 04 D0 2 29 43 21 02 0c 00 22 04 00 20 00 5A\n"\ + "sd_gpout=0\n"\ + "sd_oobonly=1\n"; + + + +static struct proc_dir_entry *wifi_calibration; + + +static int wifi_calibration_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + unsigned len; + + len = min(strlen(hardcoded_nvs), (unsigned)count); + memcpy(page, hardcoded_nvs, len); + return len; +} + +static int __init wifi_nvs_init(void) +{ + wifi_calibration = create_proc_entry("calibration", 0444, NULL); + if (wifi_calibration != NULL) { + wifi_calibration->size = strlen(hardcoded_nvs); + wifi_calibration->read_proc = wifi_calibration_read_proc; + wifi_calibration->write_proc = NULL; + } + return 0; +} + +device_initcall(wifi_nvs_init); diff --git a/arch/arm/mach-msm/board-htcleo-wifi.c b/arch/arm/mach-msm/board-htcleo-wifi.c new file mode 100644 index 00000000..1322811a --- /dev/null +++ b/arch/arm/mach-msm/board-htcleo-wifi.c @@ -0,0 +1,117 @@ +/* linux/arch/arm/mach-msm/board-bravo-wifi.c +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "board-htcleo.h" + +int htcleo_wifi_power(int on); +int htcleo_wifi_reset(int on); +int htcleo_wifi_set_carddetect(int on); + +#define PREALLOC_WLAN_NUMBER_OF_SECTIONS 4 + +#define PREALLOC_WLAN_NUMBER_OF_BUFFERS 160 +#define PREALLOC_WLAN_SECTION_HEADER 24 + +#define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_NUMBER_OF_BUFFERS * 128) +#define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_NUMBER_OF_BUFFERS * 128) +#define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_NUMBER_OF_BUFFERS * 512) +#define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_NUMBER_OF_BUFFERS * 1024) + +#define WLAN_SKB_BUF_NUM 16 + +static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM]; + +typedef struct wifi_mem_prealloc_struct { + void *mem_ptr; + unsigned long size; +} wifi_mem_prealloc_t; + +static wifi_mem_prealloc_t wifi_mem_array[PREALLOC_WLAN_NUMBER_OF_SECTIONS] = { + { NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER) }, + { NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER) }, + { NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER) }, + { NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER) } +}; + +static void *htcleo_wifi_mem_prealloc(int section, unsigned long size) +{ + if (section == PREALLOC_WLAN_NUMBER_OF_SECTIONS) + return wlan_static_skb; + if ((section < 0) || (section > PREALLOC_WLAN_NUMBER_OF_SECTIONS)) + return NULL; + if (wifi_mem_array[section].size < size) + return NULL; + return wifi_mem_array[section].mem_ptr; +} + +int __init htcleo_init_wifi_mem(void) +{ + int i; + + for(i=0;( i < WLAN_SKB_BUF_NUM );i++) { + if (i < (WLAN_SKB_BUF_NUM/2)) + wlan_static_skb[i] = dev_alloc_skb(4096); + else + wlan_static_skb[i] = dev_alloc_skb(8192); + } + for(i=0;( i < PREALLOC_WLAN_NUMBER_OF_SECTIONS );i++) { + wifi_mem_array[i].mem_ptr = kmalloc(wifi_mem_array[i].size, + GFP_KERNEL); + if (wifi_mem_array[i].mem_ptr == NULL) + return -ENOMEM; + } + return 0; +} + +static struct resource htcleo_wifi_resources[] = { + [0] = { + .name = "bcm4329_wlan_irq", + .start = MSM_GPIO_TO_INT(HTCLEO_GPIO_WIFI_IRQ), + .end = MSM_GPIO_TO_INT(HTCLEO_GPIO_WIFI_IRQ), + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, + }, +}; + +static struct wifi_platform_data htcleo_wifi_control = { + .set_power = htcleo_wifi_power, + .set_reset = htcleo_wifi_reset, + .set_carddetect = htcleo_wifi_set_carddetect, + .mem_prealloc = htcleo_wifi_mem_prealloc, +}; + +static struct platform_device htcleo_wifi_device = { + .name = "bcm4329_wlan", + .id = 1, + .num_resources = ARRAY_SIZE(htcleo_wifi_resources), + .resource = htcleo_wifi_resources, + .dev = { + .platform_data = &htcleo_wifi_control, + }, +}; + + +static int __init htcleo_wifi_init(void) +{ + int ret; + + if (!machine_is_htcleo()) + return 0; + + printk("%s: start\n", __func__); + // htcleo_wifi_update_nvs("sd_oobonly=1\n"); + htcleo_init_wifi_mem(); + ret = platform_device_register(&htcleo_wifi_device); + return ret; +} + +device_initcall(htcleo_wifi_init);