2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2014-12-19 06:59:46 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _RTW_EFUSE_C_
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
#include <drv_conf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
2014-12-17 04:26:13 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <rtw_efuse.h>
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/*------------------------Define local variable------------------------------*/
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 fakeEfuseBank=0;
|
|
|
|
u32 fakeEfuseUsedBytes=0;
|
|
|
|
u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]={0};
|
|
|
|
u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]={0};
|
|
|
|
u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]={0};
|
|
|
|
|
|
|
|
u32 BTEfuseUsedBytes=0;
|
|
|
|
u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
|
|
|
|
u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
|
|
|
|
u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
|
|
|
|
|
|
|
|
u32 fakeBTEfuseUsedBytes=0;
|
|
|
|
u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
|
|
|
|
u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
|
|
|
|
u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
|
2013-05-08 21:45:39 +00:00
|
|
|
/*------------------------Define local variable------------------------------*/
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2013-05-08 21:45:39 +00:00
|
|
|
#define REG_EFUSE_CTRL 0x0030
|
2014-12-17 04:26:13 +00:00
|
|
|
#define EFUSE_CTRL REG_EFUSE_CTRL // E-Fuse Control.
|
|
|
|
//------------------------------------------------------------------------------
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
BOOLEAN
|
2013-05-08 21:45:39 +00:00
|
|
|
Efuse_Read1ByteFromFakeContent(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u8 *Value );
|
|
|
|
BOOLEAN
|
2013-05-08 21:45:39 +00:00
|
|
|
Efuse_Read1ByteFromFakeContent(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u8 *Value )
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
if(Offset >= EFUSE_MAX_HW_SIZE)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
//DbgPrint("Read fake content, offset = %d\n", Offset);
|
|
|
|
if(fakeEfuseBank == 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
*Value = fakeEfuseContent[Offset];
|
|
|
|
else
|
|
|
|
*Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset];
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
BOOLEAN
|
|
|
|
Efuse_Write1ByteToFakeContent(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
IN u8 Value );
|
2014-12-17 04:26:13 +00:00
|
|
|
BOOLEAN
|
2013-05-08 21:45:39 +00:00
|
|
|
Efuse_Write1ByteToFakeContent(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
IN u8 Value )
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
if(Offset >= EFUSE_MAX_HW_SIZE)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
if(fakeEfuseBank == 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
fakeEfuseContent[Offset] = Value;
|
2014-12-17 04:26:13 +00:00
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value;
|
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: Efuse_PowerSwitch
|
|
|
|
*
|
2014-12-19 06:59:46 +00:00
|
|
|
* Overview: When we want to enable write operation, we should change to
|
2013-05-08 21:45:39 +00:00
|
|
|
* pwr on state. When we stop write, we should switch to 500k mode
|
|
|
|
* and disable LDO 2.5V.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/17/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
Efuse_PowerSwitch(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 bWrite,
|
|
|
|
IN u8 PwrState)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
pAdapter->HalFunc.EfusePowerSwitch(pAdapter, bWrite, PwrState);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: efuse_GetCurrentSize
|
|
|
|
*
|
|
|
|
* Overview: Get current efuse size!!!
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/16/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
u16
|
|
|
|
Efuse_GetCurrentSize(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter * pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 efuseType,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u16 ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */
|
|
|
|
u8
|
2014-12-17 04:26:13 +00:00
|
|
|
Efuse_CalculateWordCnts(IN u8 word_en)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 word_cnts = 0;
|
2014-12-17 04:26:13 +00:00
|
|
|
if(!(word_en & BIT(0))) word_cnts++; // 0 : write enable
|
|
|
|
if(!(word_en & BIT(1))) word_cnts++;
|
|
|
|
if(!(word_en & BIT(2))) word_cnts++;
|
|
|
|
if(!(word_en & BIT(3))) word_cnts++;
|
2013-05-08 21:45:39 +00:00
|
|
|
return word_cnts;
|
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Execute E-Fuse read byte operation.
|
|
|
|
// Refered from SD1 Richard.
|
|
|
|
//
|
|
|
|
// Assumption:
|
|
|
|
// 1. Boot from E-Fuse and successfully auto-load.
|
|
|
|
// 2. PASSIVE_LEVEL (USB interface)
|
|
|
|
//
|
|
|
|
// Created by Roger, 2008.10.21.
|
|
|
|
//
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
ReadEFuseByte(
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *Adapter,
|
2014-12-19 06:59:46 +00:00
|
|
|
u16 _offset,
|
|
|
|
u8 *pbuf,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u32 value32;
|
|
|
|
u8 readbyte;
|
|
|
|
u16 retry;
|
|
|
|
//u32 start=rtw_get_current_time();
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if(bPseudoTest)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//Write Address
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff));
|
2013-05-08 21:45:39 +00:00
|
|
|
readbyte = rtw_read8(Adapter, EFUSE_CTRL+2);
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//Write bit 32 0
|
2014-12-19 06:59:46 +00:00
|
|
|
readbyte = rtw_read8(Adapter, EFUSE_CTRL+3);
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f));
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//Check bit 32 read-ready
|
2013-05-08 21:45:39 +00:00
|
|
|
retry = 0;
|
|
|
|
value32 = rtw_read32(Adapter, EFUSE_CTRL);
|
2014-12-17 04:26:13 +00:00
|
|
|
//while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10))
|
|
|
|
while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
value32 = rtw_read32(Adapter, EFUSE_CTRL);
|
|
|
|
retry++;
|
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
// 20100205 Joseph: Add delay suggested by SD1 Victor.
|
|
|
|
// This fix the problem that Efuse read error in high temperature condition.
|
|
|
|
// Designer says that there shall be some delay after ready bit is set, or the
|
|
|
|
// result will always stay on last data we read.
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_udelay_os(50);
|
|
|
|
value32 = rtw_read32(Adapter, EFUSE_CTRL);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
*pbuf = (u8)(value32 & 0xff);
|
2014-12-17 04:26:13 +00:00
|
|
|
//DBG_871X("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Description:
|
2014-12-19 06:59:46 +00:00
|
|
|
// 1. Execute E-Fuse read byte operation according as map offset and
|
2014-12-17 04:26:13 +00:00
|
|
|
// save to E-Fuse table.
|
|
|
|
// 2. Refered from SD1 Richard.
|
|
|
|
//
|
|
|
|
// Assumption:
|
|
|
|
// 1. Boot from E-Fuse and successfully auto-load.
|
|
|
|
// 2. PASSIVE_LEVEL (USB interface)
|
|
|
|
//
|
|
|
|
// Created by Roger, 2008.10.21.
|
|
|
|
//
|
2014-12-19 06:59:46 +00:00
|
|
|
// 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description.
|
2014-12-17 04:26:13 +00:00
|
|
|
// 2. Add efuse utilization collect.
|
|
|
|
// 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1
|
|
|
|
// write addr must be after sec5.
|
|
|
|
//
|
|
|
|
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
efuse_ReadEFuse(
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *Adapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 efuseType,
|
|
|
|
u16 _offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
u16 _size_byte,
|
|
|
|
u8 *pbuf,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN BOOLEAN bPseudoTest
|
|
|
|
);
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
efuse_ReadEFuse(
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *Adapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 efuseType,
|
|
|
|
u16 _offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
u16 _size_byte,
|
|
|
|
u8 *pbuf,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN BOOLEAN bPseudoTest
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
EFUSE_GetEfuseDefinition(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 efuseType,
|
|
|
|
IN u8 type,
|
|
|
|
OUT void *pOut,
|
|
|
|
IN BOOLEAN bPseudoTest
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: EFUSE_Read1Byte
|
|
|
|
*
|
|
|
|
* Overview: Copy from WMAC fot EFUSE read 1 byte.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 09/23/2008 MHC Copy from WMAC.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-17 04:26:13 +00:00
|
|
|
u8
|
2014-12-19 06:59:46 +00:00
|
|
|
EFUSE_Read1Byte(
|
|
|
|
IN struct adapter *Adapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Address)
|
|
|
|
{
|
|
|
|
u8 data;
|
|
|
|
u8 Bytetemp = {0x00};
|
|
|
|
u8 temp = {0x00};
|
|
|
|
u32 k=0;
|
|
|
|
u16 contentLen=0;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
if (Address < contentLen) //E-fuse 512Byte
|
|
|
|
{
|
|
|
|
//Write E-fuse Register address bit0~7
|
2014-12-19 06:59:46 +00:00
|
|
|
temp = Address & 0xFF;
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+1, temp);
|
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
|
2014-12-17 04:26:13 +00:00
|
|
|
//Write E-fuse Register address bit8~9
|
2014-12-19 06:59:46 +00:00
|
|
|
temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+2, temp);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
//Write 0x30[31]=0
|
2013-05-08 21:45:39 +00:00
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
|
|
|
|
temp = Bytetemp & 0x7F;
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+3, temp);
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//Wait Write-ready (0x30[31]=1)
|
2013-05-08 21:45:39 +00:00
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
|
2014-12-17 04:26:13 +00:00
|
|
|
while(!(Bytetemp & 0x80))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
|
|
|
|
k++;
|
2014-12-17 04:26:13 +00:00
|
|
|
if(k==1000)
|
|
|
|
{
|
|
|
|
k=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
data=rtw_read8(Adapter, EFUSE_CTRL);
|
2013-05-08 21:45:39 +00:00
|
|
|
return data;
|
2013-07-28 17:00:21 +00:00
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
else
|
|
|
|
return 0xFF;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
}/* EFUSE_Read1Byte */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: EFUSE_Write1Byte
|
|
|
|
*
|
|
|
|
* Overview: Copy from WMAC fot EFUSE write 1 byte.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 09/23/2008 MHC Copy from WMAC.
|
2014-12-17 04:26:13 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
void
|
|
|
|
EFUSE_Write1Byte(
|
|
|
|
IN struct adapter *Adapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Address,
|
|
|
|
IN u8 Value);
|
2014-12-19 06:59:46 +00:00
|
|
|
void
|
|
|
|
EFUSE_Write1Byte(
|
|
|
|
IN struct adapter *Adapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Address,
|
|
|
|
IN u8 Value)
|
|
|
|
{
|
|
|
|
u8 Bytetemp = {0x00};
|
|
|
|
u8 temp = {0x00};
|
|
|
|
u32 k=0;
|
|
|
|
u16 contentLen=0;
|
|
|
|
|
|
|
|
//RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr=%x Data =%x\n", Address, Value));
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
if( Address < contentLen) //E-fuse 512Byte
|
|
|
|
{
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL, Value);
|
|
|
|
|
|
|
|
//Write E-fuse Register address bit0~7
|
2014-12-19 06:59:46 +00:00
|
|
|
temp = Address & 0xFF;
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+1, temp);
|
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//Write E-fuse Register address bit8~9
|
2014-12-19 06:59:46 +00:00
|
|
|
temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+2, temp);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
//Write 0x30[31]=1
|
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
|
|
|
|
temp = Bytetemp | 0x80;
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL+3, temp);
|
|
|
|
|
|
|
|
//Wait Write-ready (0x30[31]=0)
|
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
|
|
|
|
while(Bytetemp & 0x80)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
|
2014-12-17 04:26:13 +00:00
|
|
|
k++;
|
|
|
|
if(k==100)
|
|
|
|
{
|
|
|
|
k=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}/* EFUSE_Write1Byte */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* 11/16/2008 MH Read one byte from real Efuse. */
|
2014-12-17 04:26:13 +00:00
|
|
|
u8
|
|
|
|
efuse_OneByteRead(
|
2014-12-19 06:59:46 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 addr,
|
|
|
|
IN u8 *data,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 tmpidx = 0;
|
|
|
|
u8 bResult;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if(bPseudoTest)
|
|
|
|
{
|
|
|
|
bResult = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data);
|
|
|
|
return bResult;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
// -----------------e-fuse reg ctrl ---------------------------------
|
2014-12-19 06:59:46 +00:00
|
|
|
//address
|
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff));
|
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03) ) |
|
|
|
|
(rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC ));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);//read cmd
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
while(!(0x80 &rtw_read8(pAdapter, EFUSE_CTRL+3))&&(tmpidx<100))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
tmpidx++;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
if(tmpidx<100)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
*data=rtw_read8(pAdapter, EFUSE_CTRL);
|
2014-12-29 02:13:24 +00:00
|
|
|
bResult = true;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
*data = 0xff;
|
2014-12-29 02:13:24 +00:00
|
|
|
bResult = false;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
return bResult;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/* 11/16/2008 MH Write one byte to reald Efuse. */
|
2014-12-17 04:26:13 +00:00
|
|
|
u8
|
|
|
|
efuse_OneByteWrite(
|
2014-12-19 06:59:46 +00:00
|
|
|
IN struct adapter *pAdapter,
|
|
|
|
IN u16 addr,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 data,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 tmpidx = 0;
|
|
|
|
u8 bResult;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if(bPseudoTest)
|
|
|
|
{
|
|
|
|
bResult = Efuse_Write1ByteToFakeContent(pAdapter, addr, data);
|
|
|
|
return bResult;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
//RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr = %x Data=%x\n", addr, data));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
// -----------------e-fuse reg ctrl ---------------------------------
|
|
|
|
//address
|
2014-12-17 04:26:13 +00:00
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff));
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL+2,
|
|
|
|
(rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC )|(u8)((addr>>8)&0x03) );
|
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL, data);//data
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);//write cmd
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
while((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100) ){
|
2013-05-08 21:45:39 +00:00
|
|
|
tmpidx++;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if(tmpidx<100)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
bResult = true;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
bResult = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
int
|
2014-12-17 23:13:53 +00:00
|
|
|
Efuse_PgPacketRead( IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 offset,
|
|
|
|
IN u8 *data,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
int
|
|
|
|
Efuse_PgPacketWrite(IN struct adapter *pAdapter,
|
|
|
|
IN u8 offset,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 word_en,
|
|
|
|
IN u8 *data,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
|
2015-01-30 03:41:53 +00:00
|
|
|
static int
|
2014-12-19 06:59:46 +00:00
|
|
|
Efuse_PgPacketWrite_BT(IN struct adapter *pAdapter,
|
|
|
|
IN u8 offset,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 word_en,
|
|
|
|
IN u8 *data,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: efuse_WordEnableDataRead
|
|
|
|
*
|
|
|
|
* Overview: Read allowed word in current efuse section data.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/16/2008 MHC Create Version 0.
|
|
|
|
* 11/21/2008 MHC Fix Write bug when we only enable late word.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-17 04:26:13 +00:00
|
|
|
void
|
|
|
|
efuse_WordEnableDataRead(IN u8 word_en,
|
|
|
|
IN u8 *sourdata,
|
|
|
|
IN u8 *targetdata)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
if (!(word_en&BIT(0)))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
targetdata[0] = sourdata[0];
|
|
|
|
targetdata[1] = sourdata[1];
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
if (!(word_en&BIT(1)))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
targetdata[2] = sourdata[2];
|
|
|
|
targetdata[3] = sourdata[3];
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
if (!(word_en&BIT(2)))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
targetdata[4] = sourdata[4];
|
|
|
|
targetdata[5] = sourdata[5];
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
if (!(word_en&BIT(3)))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
targetdata[6] = sourdata[6];
|
|
|
|
targetdata[7] = sourdata[7];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
u8
|
2014-12-17 23:13:53 +00:00
|
|
|
Efuse_WordEnableDataWrite( IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 efuse_addr,
|
2014-12-19 06:59:46 +00:00
|
|
|
IN u8 word_en,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 *data,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
|
|
|
{
|
|
|
|
u8 ret=0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static u8 efuse_read8(struct adapter *padapter, u16 address, u8 *value)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return efuse_OneByteRead(padapter,address, value, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static u8 efuse_write8(struct adapter *padapter, u16 address, u8 *value)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return efuse_OneByteWrite(padapter,address, *value, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* read/wirte raw efuse data
|
|
|
|
*/
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 rtw_efuse_access(struct adapter *padapter, u8 bWrite, u16 start_addr, u16 cnts, u8 *data)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
2014-12-17 04:26:13 +00:00
|
|
|
u16 real_content_len = 0, max_available_size = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 res = _FAIL ;
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 (*rw8)(struct adapter *, u16, u8*);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&real_content_len, false);
|
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (start_addr > real_content_len)
|
|
|
|
return _FAIL;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (true == bWrite) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((start_addr + cnts) > max_available_size)
|
|
|
|
return _FAIL;
|
|
|
|
rw8 = &efuse_write8;
|
2014-12-17 04:26:13 +00:00
|
|
|
} else
|
2013-05-08 21:45:39 +00:00
|
|
|
rw8 = &efuse_read8;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, bWrite, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
// e-fuse one byte read / write
|
2013-05-08 21:45:39 +00:00
|
|
|
for (i = 0; i < cnts; i++) {
|
|
|
|
if (start_addr >= real_content_len) {
|
|
|
|
res = _FAIL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = rw8(padapter, start_addr++, data++);
|
2014-12-17 04:26:13 +00:00
|
|
|
if (_FAIL == res) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, bWrite, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2014-12-17 23:13:53 +00:00
|
|
|
u16 efuse_GetMaxSize(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u16 max_size;
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
return max_size;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 efuse_GetCurrentSize(struct adapter *padapter, u16 *size)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, false, true);
|
|
|
|
*size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, false);
|
|
|
|
Efuse_PowerSwitch(padapter, false, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 rtw_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u16 mapLen=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if ((addr + cnts) > mapLen)
|
|
|
|
return _FAIL;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, false, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, false, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 rtw_BT_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u16 mapLen=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if ((addr + cnts) > mapLen)
|
|
|
|
return _FAIL;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, false, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, false, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 offset, word_en;
|
|
|
|
u8 *map;
|
|
|
|
u8 newdata[PGPKT_DATA_SIZE];
|
|
|
|
s32 i, j, idx;
|
|
|
|
u8 ret = _SUCCESS;
|
|
|
|
u16 mapLen=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if ((addr + cnts) > mapLen)
|
|
|
|
return _FAIL;
|
|
|
|
|
|
|
|
map = rtw_zmalloc(mapLen);
|
2014-12-17 04:26:13 +00:00
|
|
|
if(map == NULL){
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
ret = rtw_efuse_map_read(padapter, 0, mapLen, map);
|
2014-12-17 04:26:13 +00:00
|
|
|
if (ret == _FAIL) goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, true, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
offset = (addr >> 3);
|
|
|
|
word_en = 0xF;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(newdata, 0xFF, PGPKT_DATA_SIZE);
|
2014-12-17 04:26:13 +00:00
|
|
|
i = addr & 0x7; // index of one package
|
|
|
|
j = 0; // index of new package
|
|
|
|
idx = 0; // data index
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (i & 0x1) {
|
2014-12-17 04:26:13 +00:00
|
|
|
// odd start
|
2013-05-08 21:45:39 +00:00
|
|
|
if (data[idx] != map[addr+idx]) {
|
|
|
|
word_en &= ~BIT(i >> 1);
|
|
|
|
newdata[i-1] = map[addr+idx-1];
|
|
|
|
newdata[i] = data[idx];
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
do {
|
2014-12-17 04:26:13 +00:00
|
|
|
for (; i < PGPKT_DATA_SIZE; i += 2)
|
|
|
|
{
|
|
|
|
if (cnts == idx) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((cnts - idx) == 1) {
|
|
|
|
if (data[idx] != map[addr+idx]) {
|
|
|
|
word_en &= ~BIT(i >> 1);
|
|
|
|
newdata[i] = data[idx];
|
|
|
|
newdata[i+1] = map[addr+idx+1];
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if ((data[idx] != map[addr+idx]) ||
|
2014-12-17 04:26:13 +00:00
|
|
|
(data[idx+1] != map[addr+idx+1]))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
word_en &= ~BIT(i >> 1);
|
|
|
|
newdata[i] = data[idx];
|
|
|
|
newdata[i+1] = data[idx + 1];
|
|
|
|
}
|
|
|
|
idx += 2;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
if (idx == cnts) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (word_en != 0xF) {
|
2014-12-29 02:13:24 +00:00
|
|
|
ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, false);
|
2014-12-17 04:26:13 +00:00
|
|
|
DBG_871X("offset=%x \n",offset);
|
|
|
|
DBG_871X("word_en=%x \n",word_en);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
for(i=0;i<PGPKT_DATA_SIZE;i++)
|
|
|
|
{
|
|
|
|
DBG_871X("data=%x \t",newdata[i]);
|
|
|
|
}
|
|
|
|
if (ret == _FAIL) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if (idx == cnts) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
offset++;
|
|
|
|
i = 0;
|
2014-12-17 04:26:13 +00:00
|
|
|
j = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
word_en = 0xF;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(newdata, 0xFF, PGPKT_DATA_SIZE);
|
2013-05-08 21:45:39 +00:00
|
|
|
} while (1);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, true, false);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
rtw_mfree(map, mapLen);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2014-12-17 23:13:53 +00:00
|
|
|
u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
u8 offset, word_en;
|
|
|
|
u8 *map;
|
|
|
|
u8 newdata[PGPKT_DATA_SIZE];
|
|
|
|
s32 i, j, idx;
|
|
|
|
u8 ret = _SUCCESS;
|
|
|
|
u16 mapLen=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if ((addr + cnts) > mapLen)
|
|
|
|
return _FAIL;
|
|
|
|
|
|
|
|
map = rtw_zmalloc(mapLen);
|
2014-12-17 04:26:13 +00:00
|
|
|
if(map == NULL){
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map);
|
2014-12-17 04:26:13 +00:00
|
|
|
if (ret == _FAIL) goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, true, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
offset = (addr >> 3);
|
|
|
|
word_en = 0xF;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(newdata, 0xFF, PGPKT_DATA_SIZE);
|
2014-12-17 04:26:13 +00:00
|
|
|
i = addr & 0x7; // index of one package
|
|
|
|
j = 0; // index of new package
|
|
|
|
idx = 0; // data index
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (i & 0x1) {
|
2014-12-17 04:26:13 +00:00
|
|
|
// odd start
|
2013-05-08 21:45:39 +00:00
|
|
|
if (data[idx] != map[addr+idx]) {
|
|
|
|
word_en &= ~BIT(i >> 1);
|
|
|
|
newdata[i-1] = map[addr+idx-1];
|
|
|
|
newdata[i] = data[idx];
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
do {
|
2014-12-17 04:26:13 +00:00
|
|
|
for (; i < PGPKT_DATA_SIZE; i += 2)
|
|
|
|
{
|
|
|
|
if (cnts == idx) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((cnts - idx) == 1) {
|
|
|
|
if (data[idx] != map[addr+idx]) {
|
|
|
|
word_en &= ~BIT(i >> 1);
|
|
|
|
newdata[i] = data[idx];
|
|
|
|
newdata[i+1] = map[addr+idx+1];
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if ((data[idx] != map[addr+idx]) ||
|
2014-12-17 04:26:13 +00:00
|
|
|
(data[idx+1] != map[addr+idx+1]))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
word_en &= ~BIT(i >> 1);
|
|
|
|
newdata[i] = data[idx];
|
|
|
|
newdata[i+1] = data[idx + 1];
|
|
|
|
}
|
|
|
|
idx += 2;
|
|
|
|
}
|
2014-12-17 04:26:13 +00:00
|
|
|
if (idx == cnts) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if (word_en != 0xF)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: offset=%#X\n", __FUNCTION__, offset);
|
|
|
|
DBG_871X("%s: word_en=%#X\n", __FUNCTION__, word_en);
|
|
|
|
DBG_871X("%s: data=", __FUNCTION__);
|
|
|
|
for (i=0; i<PGPKT_DATA_SIZE; i++)
|
|
|
|
{
|
|
|
|
DBG_871X("0x%02X ", newdata[i]);
|
|
|
|
}
|
|
|
|
DBG_871X("\n");
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, false);
|
2014-12-17 04:26:13 +00:00
|
|
|
if (ret == _FAIL) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if (idx == cnts) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
offset++;
|
|
|
|
i = 0;
|
2014-12-17 04:26:13 +00:00
|
|
|
j = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
word_en = 0xF;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(newdata, 0xFF, PGPKT_DATA_SIZE);
|
2013-05-08 21:45:39 +00:00
|
|
|
} while (1);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(padapter, true, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
rtw_mfree(map, mapLen);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: Efuse_ReadAllMap
|
|
|
|
*
|
|
|
|
* Overview: Read All Efuse content
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/11/2008 MHC Create Version 0.
|
2014-12-17 04:26:13 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
Efuse_ReadAllMap(
|
2014-12-19 06:59:46 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 efuseType,
|
|
|
|
IN OUT u8 *Efuse,
|
|
|
|
IN BOOLEAN bPseudoTest);
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
Efuse_ReadAllMap(
|
2014-12-19 06:59:46 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 efuseType,
|
|
|
|
IN OUT u8 *Efuse,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
|
|
|
{
|
|
|
|
u16 mapLen=0;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(pAdapter,false, true);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
2014-12-29 02:06:17 +00:00
|
|
|
EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, bPseudoTest);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, bPseudoTest);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
Efuse_PowerSwitch(pAdapter,false, false);
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: efuse_ShadowRead1Byte
|
|
|
|
* efuse_ShadowRead2Byte
|
|
|
|
* efuse_ShadowRead4Byte
|
|
|
|
*
|
|
|
|
* Overview: Read from efuse init map by one/two/four bytes !!!!!
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/12/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_ShadowRead1Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u8 *Value)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
*Value = pEEPROM->efuse_eeprom_data[Offset];
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
} // EFUSE_ShadowRead1Byte
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//---------------Read Two Bytes
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_ShadowRead2Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u16 *Value)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
*Value = pEEPROM->efuse_eeprom_data[Offset];
|
|
|
|
*Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8;
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
} // EFUSE_ShadowRead2Byte
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//---------------Read Four Bytes
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_ShadowRead4Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u32 *Value)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
*Value = pEEPROM->efuse_eeprom_data[Offset];
|
|
|
|
*Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8;
|
|
|
|
*Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16;
|
|
|
|
*Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24;
|
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
} // efuse_ShadowRead4Byte
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
2014-12-17 04:26:13 +00:00
|
|
|
* Function: efuse_ShadowWrite1Byte
|
|
|
|
* efuse_ShadowWrite2Byte
|
|
|
|
* efuse_ShadowWrite4Byte
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
2014-12-17 04:26:13 +00:00
|
|
|
* Overview: Write efuse modify map by one/two/four byte.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/12/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-17 04:26:13 +00:00
|
|
|
#ifdef PLATFORM
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2014-12-17 04:26:13 +00:00
|
|
|
efuse_ShadowWrite1Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
IN u8 Value);
|
2014-12-17 04:26:13 +00:00
|
|
|
#endif //PLATFORM
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2014-12-17 04:26:13 +00:00
|
|
|
efuse_ShadowWrite1Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
IN u8 Value)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
pEEPROM->efuse_eeprom_data[Offset] = Value;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
} // efuse_ShadowWrite1Byte
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
//---------------Write Two Bytes
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2014-12-17 04:26:13 +00:00
|
|
|
efuse_ShadowWrite2Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
2014-12-19 06:59:46 +00:00
|
|
|
IN u16 Value)
|
2014-12-17 04:26:13 +00:00
|
|
|
{
|
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
pEEPROM->efuse_eeprom_data[Offset] = Value&0x00FF;
|
|
|
|
pEEPROM->efuse_eeprom_data[Offset+1] = Value>>8;
|
|
|
|
|
|
|
|
} // efuse_ShadowWrite1Byte
|
|
|
|
|
|
|
|
//---------------Write Four Bytes
|
2014-12-29 02:06:17 +00:00
|
|
|
static void
|
2014-12-17 04:26:13 +00:00
|
|
|
efuse_ShadowWrite4Byte(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u16 Offset,
|
|
|
|
IN u32 Value)
|
|
|
|
{
|
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
|
|
|
|
|
|
|
pEEPROM->efuse_eeprom_data[Offset] = (u8)(Value&0x000000FF);
|
|
|
|
pEEPROM->efuse_eeprom_data[Offset+1] = (u8)((Value>>8)&0x0000FF);
|
|
|
|
pEEPROM->efuse_eeprom_data[Offset+2] = (u8)((Value>>16)&0x00FF);
|
|
|
|
pEEPROM->efuse_eeprom_data[Offset+3] = (u8)((Value>>24)&0xFF);
|
|
|
|
|
|
|
|
} // efuse_ShadowWrite1Byte
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: EFUSE_ShadowMapUpdate
|
|
|
|
*
|
|
|
|
* Overview: Transfer current EFUSE content to shadow init and modify map.
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/13/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
void EFUSE_ShadowMapUpdate(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 efuseType,
|
|
|
|
IN BOOLEAN bPseudoTest)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:26:13 +00:00
|
|
|
EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
|
|
|
|
u16 mapLen=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:06:17 +00:00
|
|
|
EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, bPseudoTest);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (pEEPROM->bautoload_fail_flag == true)
|
2014-12-17 04:26:13 +00:00
|
|
|
{
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen);
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-17 04:26:13 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
#ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
|
2014-12-17 04:26:13 +00:00
|
|
|
if(_SUCCESS != retriveAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pEEPROM)) {
|
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data, bPseudoTest);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
#ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
|
|
|
|
storeAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pEEPROM);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-12-29 02:06:17 +00:00
|
|
|
//PlatformMoveMemory((void *)&pHalData->EfuseMap[EFUSE_MODIFY_MAP][0],
|
|
|
|
//(void *)&pHalData->EfuseMap[EFUSE_INIT_MAP][0], mapLen);
|
2014-12-17 04:26:13 +00:00
|
|
|
}// EFUSE_ShadowMapUpdate
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: EFUSE_ShadowRead
|
|
|
|
*
|
|
|
|
* Overview: Read from efuse init map !!!!!
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/12/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-17 04:26:13 +00:00
|
|
|
void
|
|
|
|
EFUSE_ShadowRead(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 Type,
|
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u32 *Value )
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
if (Type == 1)
|
|
|
|
efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value);
|
|
|
|
else if (Type == 2)
|
|
|
|
efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value);
|
|
|
|
else if (Type == 4)
|
|
|
|
efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
} // EFUSE_ShadowRead
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* Function: EFUSE_ShadowWrite
|
|
|
|
*
|
|
|
|
* Overview: Write efuse modify map for later update operation to use!!!!!
|
|
|
|
*
|
|
|
|
* Input: NONE
|
|
|
|
*
|
|
|
|
* Output: NONE
|
|
|
|
*
|
|
|
|
* Return: NONE
|
|
|
|
*
|
|
|
|
* Revised History:
|
|
|
|
* When Who Remark
|
2014-12-19 06:59:46 +00:00
|
|
|
* 11/12/2008 MHC Create Version 0.
|
2014-12-17 04:26:13 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
EFUSE_ShadowWrite(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 Type,
|
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u32 Value);
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
EFUSE_ShadowWrite(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter,
|
2014-12-17 04:26:13 +00:00
|
|
|
IN u8 Type,
|
|
|
|
IN u16 Offset,
|
|
|
|
IN OUT u32 Value)
|
|
|
|
{
|
|
|
|
#if (MP_DRIVER == 0)
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
if ( pAdapter->registrypriv.mp_mode == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (Type == 1)
|
|
|
|
efuse_ShadowWrite1Byte(pAdapter, Offset, (u8)Value);
|
|
|
|
else if (Type == 2)
|
|
|
|
efuse_ShadowWrite2Byte(pAdapter, Offset, (u16)Value);
|
|
|
|
else if (Type == 4)
|
|
|
|
efuse_ShadowWrite4Byte(pAdapter, Offset, (u32)Value);
|
|
|
|
|
|
|
|
} // EFUSE_ShadowWrite
|
|
|
|
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
Efuse_InitSomeVar(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter
|
2014-12-17 04:26:13 +00:00
|
|
|
);
|
2014-12-29 02:06:17 +00:00
|
|
|
void
|
2014-12-17 04:26:13 +00:00
|
|
|
Efuse_InitSomeVar(
|
2014-12-17 23:13:53 +00:00
|
|
|
IN struct adapter *pAdapter
|
2014-12-17 04:26:13 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u8 i;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset((void *)&fakeEfuseContent[0], 0xff, EFUSE_MAX_HW_SIZE);
|
|
|
|
memset((void *)&fakeEfuseInitMap[0], 0xff, EFUSE_MAX_MAP_LEN);
|
|
|
|
memset((void *)&fakeEfuseModifiedMap[0], 0xff, EFUSE_MAX_MAP_LEN);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
for(i=0; i<EFUSE_MAX_BT_BANK; i++)
|
|
|
|
{
|
2015-02-19 20:58:09 +00:00
|
|
|
memset((void *)&BTEfuseContent[i][0], EFUSE_MAX_HW_SIZE, 0xff);
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2015-02-19 20:58:09 +00:00
|
|
|
memset((void *)&BTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
memset((void *)&BTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
|
2014-12-17 04:26:13 +00:00
|
|
|
|
|
|
|
for(i=0; i<EFUSE_MAX_BT_BANK; i++)
|
|
|
|
{
|
2015-02-19 20:58:09 +00:00
|
|
|
memset((void *)&fakeBTEfuseContent[i][0], 0xff, EFUSE_MAX_HW_SIZE);
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
2015-02-19 20:58:09 +00:00
|
|
|
memset((void *)&fakeBTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
memset((void *)&fakeBTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
|
|
|
|
//#include <rtw_eeprom.h>
|
|
|
|
|
|
|
|
int isAdaptorInfoFileValid(void)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2014-12-17 04:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int storeAdaptorInfoFile(char *path, struct eeprom_priv * eeprom_priv)
|
|
|
|
{
|
|
|
|
int ret =_SUCCESS;
|
|
|
|
|
|
|
|
if(path && eeprom_priv) {
|
|
|
|
ret = rtw_store_to_file(path, eeprom_priv->efuse_eeprom_data, EEPROM_MAX_SIZE_512);
|
|
|
|
if(ret == EEPROM_MAX_SIZE)
|
|
|
|
ret = _SUCCESS;
|
|
|
|
else
|
|
|
|
ret = _FAIL;
|
|
|
|
} else {
|
|
|
|
DBG_871X("%s NULL pointer\n",__FUNCTION__);
|
|
|
|
ret = _FAIL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int retriveAdaptorInfoFile(char *path, struct eeprom_priv * eeprom_priv)
|
|
|
|
{
|
|
|
|
int ret = _SUCCESS;
|
|
|
|
mm_segment_t oldfs;
|
|
|
|
struct file *fp;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if(path && eeprom_priv) {
|
|
|
|
|
|
|
|
ret = rtw_retrive_from_file(path, eeprom_priv->efuse_eeprom_data, EEPROM_MAX_SIZE);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 04:26:13 +00:00
|
|
|
if(ret == EEPROM_MAX_SIZE)
|
|
|
|
ret = _SUCCESS;
|
|
|
|
else
|
|
|
|
ret = _FAIL;
|
|
|
|
} else {
|
|
|
|
DBG_871X("%s NULL pointer\n",__FUNCTION__);
|
|
|
|
ret = _FAIL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif //CONFIG_ADAPTOR_INFO_CACHING_FILE
|