From bb3dfd1dea98ebb44da720a580ba494c0f9cbbbd Mon Sep 17 00:00:00 2001 From: Rockchip Date: Wed, 9 Jul 2014 17:16:12 +0800 Subject: [PATCH] wifi: mt6620&mt5931 support mac addr from flash idb --- arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c | 89 +++++++++---------- arch/arm/plat-rk/rk-sdmmc-wifi.c | 88 +++++++++--------- .../mt6620/wlan/common/wlan_lib.c | 20 ++++- .../mt5931_kk/drv_wlan/common/wlan_lib.c | 20 ++++- 4 files changed, 124 insertions(+), 93 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c b/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c index 721da96b3f7..20547b24377 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c +++ b/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c @@ -1613,52 +1613,6 @@ int rk29sdk_wifi_set_carddetect(int val) } EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect); - -#include -u8 wifi_custom_mac_addr[6] = {0,0,0,0,0,0}; -extern char GetSNSectorInfo(char * pbuf); -int rk29sdk_wifi_mac_addr(unsigned char *buf) -{ - char mac_buf[20] = {0}; - printk("rk29sdk_wifi_mac_addr.\n"); - - // from vflash - if(is_zero_ether_addr(wifi_custom_mac_addr)) { - int i; - char *tempBuf = kmalloc(512, GFP_KERNEL); - if(tempBuf) { - GetSNSectorInfo(tempBuf); - for (i = 506; i <= 511; i++) - wifi_custom_mac_addr[i-506] = tempBuf[i]; - kfree(tempBuf); - } else { - return -1; - } - } - - sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1], - wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]); - printk("falsh wifi_custom_mac_addr=[%s]\n", mac_buf); - - if (is_valid_ether_addr(wifi_custom_mac_addr)) { - if (2 == (wifi_custom_mac_addr[0] & 0x0F)) { - printk("This mac address come into conflict with the address of direct, ignored...\n"); - return -1; - } - } else { - printk("This mac address is not valid, ignored...\n"); - return -1; - } - -#if defined(CONFIG_RKWIFI) - memcpy(buf, wifi_custom_mac_addr, 6); -#else - memcpy(buf, mac_buf, strlen(mac_buf));//realtek's wifi use this branch -#endif - return 0; -} -EXPORT_SYMBOL(rk29sdk_wifi_mac_addr); - static struct resource resources[] = { { .start = RK30SDK_WIFI_GPIO_WIFI_INT_B, @@ -1973,7 +1927,50 @@ EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect); /////////////////////////////////////////////////////////////////////////////////// #endif //#if defined(CONFIG_WIFI_CONTROL_FUNC)---#elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) --#endif +#include +u8 wifi_custom_mac_addr[6] = {0,0,0,0,0,0}; +extern char GetSNSectorInfo(char * pbuf); +int rk29sdk_wifi_mac_addr(unsigned char *buf) +{ + char mac_buf[20] = {0}; + printk("rk29sdk_wifi_mac_addr.\n"); + + // from vflash + if(is_zero_ether_addr(wifi_custom_mac_addr)) { + int i; + char *tempBuf = kmalloc(512, GFP_KERNEL); + if(tempBuf) { + GetSNSectorInfo(tempBuf); + for (i = 506; i <= 511; i++) + wifi_custom_mac_addr[i-506] = tempBuf[i]; + kfree(tempBuf); + } else { + return -1; + } + } + sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1], + wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]); + printk("falsh wifi_custom_mac_addr=[%s]\n", mac_buf); + + if (is_valid_ether_addr(wifi_custom_mac_addr)) { + if (2 == (wifi_custom_mac_addr[0] & 0x0F)) { + printk("This mac address come into conflict with the address of direct, ignored...\n"); + return -1; + } + } else { + printk("This mac address is not valid, ignored...\n"); + return -1; + } + +#if defined(CONFIG_RKWIFI) || defined(CONFIG_MTK_WIRELESS_SOLUTION) + memcpy(buf, wifi_custom_mac_addr, 6); +#else + memcpy(buf, mac_buf, strlen(mac_buf));//realtek's wifi use this branch +#endif + return 0; +} +EXPORT_SYMBOL(rk29sdk_wifi_mac_addr); #if defined(CONFIG_WIFI_CONTROL_FUNC) static struct wifi_platform_data rk29sdk_wifi_control = { diff --git a/arch/arm/plat-rk/rk-sdmmc-wifi.c b/arch/arm/plat-rk/rk-sdmmc-wifi.c index 0aaa39ca03a..1ab49bc2504 100755 --- a/arch/arm/plat-rk/rk-sdmmc-wifi.c +++ b/arch/arm/plat-rk/rk-sdmmc-wifi.c @@ -580,51 +580,6 @@ int rk29sdk_wifi_set_carddetect(int val) #endif EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect); -#include -u8 wifi_custom_mac_addr[6] = {0,0,0,0,0,0}; -extern char GetSNSectorInfo(char * pbuf); -int rk29sdk_wifi_mac_addr(unsigned char *buf) -{ - char mac_buf[20] = {0}; - printk("rk29sdk_wifi_mac_addr.\n"); - - // from vflash - if(is_zero_ether_addr(wifi_custom_mac_addr)) { - int i; - char *tempBuf = kmalloc(512, GFP_KERNEL); - if(tempBuf) { - GetSNSectorInfo(tempBuf); - for (i = 506; i <= 511; i++) - wifi_custom_mac_addr[i-506] = tempBuf[i]; - kfree(tempBuf); - } else { - return -1; - } - } - - sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1], - wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]); - printk("falsh wifi_custom_mac_addr=[%s]\n", mac_buf); - - if (is_valid_ether_addr(wifi_custom_mac_addr)) { - if (2 == (wifi_custom_mac_addr[0] & 0x0F)) { - printk("This mac address come into conflict with the address of direct, ignored...\n"); - return -1; - } - } else { - printk("This mac address is not valid, ignored...\n"); - return -1; - } - -#if defined(CONFIG_RKWIFI) - memcpy(buf, wifi_custom_mac_addr, 6); -#else - memcpy(buf, mac_buf, strlen(mac_buf));//realtek's wifi use this branch -#endif - return 0; -} -EXPORT_SYMBOL(rk29sdk_wifi_mac_addr); - //#define WIFI_HOST_WAKE RK30_PIN3_PD2 static struct resource resources[] = { @@ -970,7 +925,50 @@ EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect); /////////////////////////////////////////////////////////////////////////////////// #endif //#if defined(CONFIG_WIFI_CONTROL_FUNC)---#elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) --#endif +#include +u8 wifi_custom_mac_addr[6] = {0,0,0,0,0,0}; +extern char GetSNSectorInfo(char * pbuf); +int rk29sdk_wifi_mac_addr(unsigned char *buf) +{ + char mac_buf[20] = {0}; + printk("rk29sdk_wifi_mac_addr.\n"); + + // from vflash + if(is_zero_ether_addr(wifi_custom_mac_addr)) { + int i; + char *tempBuf = kmalloc(512, GFP_KERNEL); + if(tempBuf) { + GetSNSectorInfo(tempBuf); + for (i = 506; i <= 511; i++) + wifi_custom_mac_addr[i-506] = tempBuf[i]; + kfree(tempBuf); + } else { + return -1; + } + } + sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1], + wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]); + printk("falsh wifi_custom_mac_addr=[%s]\n", mac_buf); + + if (is_valid_ether_addr(wifi_custom_mac_addr)) { + if (2 == (wifi_custom_mac_addr[0] & 0x0F)) { + printk("This mac address come into conflict with the address of direct, ignored...\n"); + return -1; + } + } else { + printk("This mac address is not valid, ignored...\n"); + return -1; + } + +#if defined(CONFIG_RKWIFI) || defined(CONFIG_MTK_WIRELESS_SOLUTION) + memcpy(buf, wifi_custom_mac_addr, 6); +#else + memcpy(buf, mac_buf, strlen(mac_buf));//realtek's wifi use this branch +#endif + return 0; +} +EXPORT_SYMBOL(rk29sdk_wifi_mac_addr); #if defined(CONFIG_WIFI_CONTROL_FUNC) static struct wifi_platform_data rk29sdk_wifi_control = { diff --git a/drivers/net/wireless/combo_mt66xx/mt6620/wlan/common/wlan_lib.c b/drivers/net/wireless/combo_mt66xx/mt6620/wlan/common/wlan_lib.c index 6032977a10f..86674429edc 100755 --- a/drivers/net/wireless/combo_mt66xx/mt6620/wlan/common/wlan_lib.c +++ b/drivers/net/wireless/combo_mt66xx/mt6620/wlan/common/wlan_lib.c @@ -948,6 +948,11 @@ #include "precomp.h" #include "mgmt/ais_fsm.h" +#define USE_CUSTOM_MAC_ADDR +#ifdef USE_CUSTOM_MAC_ADDR +extern int rk29sdk_wifi_mac_addr(unsigned char *buf); +#endif + /******************************************************************************* * C O N S T A N T S ******************************************************************************** @@ -3798,6 +3803,7 @@ wlanUpdateNetworkAddress ( #if CFG_SHOW_MACADDR_SOURCE DBGLOG(INIT, STATE, ("WIFI_CONFIG:Using dynamically generated MAC address\n")); #endif +#ifndef USE_CUSTOM_MAC_ADDR // dynamic generate u4SysTime = (UINT_32) kalGetTimeTick(); @@ -3806,6 +3812,9 @@ wlanUpdateNetworkAddress ( rMacAddr[2] = 0x22; kalMemCopy(&rMacAddr[3], &u4SysTime, 3); +#else + rk29sdk_wifi_mac_addr(rMacAddr); +#endif } } else { @@ -4446,8 +4455,17 @@ wlanQueryNicCapability( prAdapter->fgIsHw5GBandDisabled = (BOOLEAN)prEventNicCapability->ucHw5GBandDisabled; prAdapter->fgIsEepromUsed = (BOOLEAN)prEventNicCapability->ucEepromUsed; prAdapter->fgIsEfuseValid = (BOOLEAN)prEventNicCapability->ucEfuseValid; +#ifndef USE_CUSTOM_MAC_ADDR prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)prEventNicCapability->ucMacAddrValid; - +#else +{ + PARAM_MAC_ADDRESS rMacAddr; + if(rk29sdk_wifi_mac_addr(rMacAddr) == 0) + prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)0;// + else + prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)prEventNicCapability->ucMacAddrValid; +} +#endif #if CFG_ENABLE_CAL_LOG DBGLOG(INIT, INFO, (" RF CAL FAIL = (%d),BB CAL FAIL = (%d)\n", diff --git a/drivers/net/wireless/mt5931_kk/drv_wlan/common/wlan_lib.c b/drivers/net/wireless/mt5931_kk/drv_wlan/common/wlan_lib.c index 07a60f1f2af..21dbd83b6e4 100755 --- a/drivers/net/wireless/mt5931_kk/drv_wlan/common/wlan_lib.c +++ b/drivers/net/wireless/mt5931_kk/drv_wlan/common/wlan_lib.c @@ -1004,6 +1004,11 @@ #include "precomp.h" #include "mgmt/ais_fsm.h" +//#define USE_CUSTOM_MAC_ADDR +#ifdef USE_CUSTOM_MAC_ADDR +extern int rk29sdk_wifi_mac_addr(unsigned char *buf); +#endif + /******************************************************************************* * C O N S T A N T S ******************************************************************************** @@ -3838,6 +3843,7 @@ wlanUpdateNetworkAddress ( #if CFG_SHOW_MACADDR_SOURCE DBGLOG(INIT, INFO, ("Using dynamically generated MAC address")); #endif +#ifndef USE_CUSTOM_MAC_ADDR // dynamic generate u4SysTime = (UINT_32) kalGetTimeTick(); @@ -3846,6 +3852,9 @@ wlanUpdateNetworkAddress ( rMacAddr[2] = 0x22; kalMemCopy(&rMacAddr[3], &u4SysTime, 3); +#else + rk29sdk_wifi_mac_addr(rMacAddr); +#endif } } else { @@ -4486,8 +4495,17 @@ wlanQueryNicCapability( prAdapter->fgIsHw5GBandDisabled = (BOOLEAN)prEventNicCapability->ucHw5GBandDisabled; prAdapter->fgIsEepromUsed = (BOOLEAN)prEventNicCapability->ucEepromUsed; prAdapter->fgIsEfuseValid = (BOOLEAN)prEventNicCapability->ucEfuseValid; +#ifndef USE_CUSTOM_MAC_ADDR prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)prEventNicCapability->ucMacAddrValid; - +#else +{ + PARAM_MAC_ADDRESS rMacAddr; + if(rk29sdk_wifi_mac_addr(rMacAddr) == 0) + prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)0;// + else + prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)prEventNicCapability->ucMacAddrValid; +} +#endif #if CFG_ENABLE_CAL_LOG DBGLOG(INIT, INFO, (" RF CAL FAIL = (%d),BB CAL FAIL = (%d)\n",