Skip to content

Commit

Permalink
wifi: mt6620&mt5931 support mac addr from flash idb
Browse files Browse the repository at this point in the history
  • Loading branch information
Rockchip committed Jul 9, 2014
1 parent e5aaa4d commit bb3dfd1
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 93 deletions.
89 changes: 43 additions & 46 deletions arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,52 +1613,6 @@ int rk29sdk_wifi_set_carddetect(int val)
}
EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);


#include <linux/etherdevice.h>
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,
Expand Down Expand Up @@ -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 <linux/etherdevice.h>
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 = {
Expand Down
88 changes: 43 additions & 45 deletions arch/arm/plat-rk/rk-sdmmc-wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,51 +580,6 @@ int rk29sdk_wifi_set_carddetect(int val)
#endif
EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);

#include <linux/etherdevice.h>
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[] = {
Expand Down Expand Up @@ -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 <linux/etherdevice.h>
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 = {
Expand Down
20 changes: 19 additions & 1 deletion drivers/net/wireless/combo_mt66xx/mt6620/wlan/common/wlan_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
********************************************************************************
Expand Down Expand Up @@ -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();

Expand All @@ -3806,6 +3812,9 @@ wlanUpdateNetworkAddress (
rMacAddr[2] = 0x22;

kalMemCopy(&rMacAddr[3], &u4SysTime, 3);
#else
rk29sdk_wifi_mac_addr(rMacAddr);
#endif
}
}
else {
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 19 additions & 1 deletion drivers/net/wireless/mt5931_kk/drv_wlan/common/wlan_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
********************************************************************************
Expand Down Expand Up @@ -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();

Expand All @@ -3846,6 +3852,9 @@ wlanUpdateNetworkAddress (
rMacAddr[2] = 0x22;

kalMemCopy(&rMacAddr[3], &u4SysTime, 3);
#else
rk29sdk_wifi_mac_addr(rMacAddr);
#endif
}
}
else {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit bb3dfd1

Please sign in to comment.