2022-06-08 23:46:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright(c) 2007 - 2011 Realtek Corporation. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#define _RTW_EFUSE_C_
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/osdep_service.h"
|
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/rtw_efuse.h"
|
|
|
|
#include "../include/rtl8188e_hal.h"
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* */
|
|
|
|
/* Description: */
|
|
|
|
/* Execute E-Fuse read byte operation. */
|
2013-11-29 22:10:20 +00:00
|
|
|
/* Referred from SD1 Richard. */
|
2013-07-09 22:38:46 +00:00
|
|
|
/* */
|
|
|
|
/* Assumption: */
|
|
|
|
/* 1. Boot from E-Fuse and successfully auto-load. */
|
|
|
|
/* 2. PASSIVE_LEVEL (USB interface) */
|
|
|
|
/* */
|
|
|
|
/* Created by Roger, 2008.10.21. */
|
|
|
|
/* */
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
ReadEFuseByte(
|
2013-07-28 17:00:21 +00:00
|
|
|
struct adapter *Adapter,
|
|
|
|
u16 _offset,
|
2022-06-08 23:46:35 +00:00
|
|
|
u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-28 17:00:21 +00:00
|
|
|
u32 value32;
|
|
|
|
u8 readbyte;
|
|
|
|
u16 retry;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Write Address */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(Adapter, EFUSE_CTRL + 1, (_offset & 0xff));
|
|
|
|
readbyte = rtw_read8(Adapter, EFUSE_CTRL + 2);
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL + 2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Write bit 32 0 */
|
2022-06-08 23:46:35 +00:00
|
|
|
readbyte = rtw_read8(Adapter, EFUSE_CTRL + 3);
|
|
|
|
rtw_write8(Adapter, EFUSE_CTRL + 3, (readbyte & 0x7f));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Check bit 32 read-ready */
|
2013-05-08 21:45:39 +00:00
|
|
|
retry = 0;
|
|
|
|
value32 = rtw_read32(Adapter, EFUSE_CTRL);
|
2013-07-28 17:00:21 +00:00
|
|
|
while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < 10000)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
value32 = rtw_read32(Adapter, EFUSE_CTRL);
|
|
|
|
retry++;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +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. */
|
2022-06-08 23:46:35 +00:00
|
|
|
udelay(50);
|
2013-05-08 21:45:39 +00:00
|
|
|
value32 = rtw_read32(Adapter, EFUSE_CTRL);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
*pbuf = (u8)(value32 & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
* 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
|
2013-05-19 04:28:07 +00:00
|
|
|
* 11/13/2008 MHC Create Version 0.
|
2013-05-08 21:45:39 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
2022-06-08 23:46:35 +00:00
|
|
|
void EFUSE_ShadowMapUpdate(struct adapter *pAdapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct eeprom_priv *pEEPROM = &pAdapter->eeprompriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pEEPROM->bautoload_fail_flag) {
|
|
|
|
memset(pEEPROM->efuse_eeprom_data, 0xFF, EFUSE_MAP_LEN_88E);
|
|
|
|
return;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtl8188e_EfusePowerSwitch(pAdapter, true);
|
|
|
|
rtl8188e_ReadEFuse(pAdapter, 0, EFUSE_MAP_LEN_88E, pEEPROM->efuse_eeprom_data);
|
|
|
|
rtl8188e_EfusePowerSwitch(pAdapter, false);
|
|
|
|
}
|