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 _HAL_INIT_C_
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/rtw_efuse.h"
|
|
|
|
#include "../include/rtl8188e_hal.h"
|
|
|
|
#include "../include/rtw_iol.h"
|
|
|
|
#include "../include/usb_ops.h"
|
|
|
|
#include "../include/rtw_fw.h"
|
2013-07-11 18:35:36 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
static void iol_mode_enable(struct adapter *padapter, u8 enable)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 reg_0xf0 = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (enable) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Enable initial offload */
|
2013-05-08 21:45:39 +00:00
|
|
|
reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG);
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 | SW_OFFLOAD_EN);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!padapter->bFWReady)
|
|
|
|
rtw_reset_8051(padapter);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:24:47 +00:00
|
|
|
} else {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* disable initial offload */
|
2013-05-08 21:45:39 +00:00
|
|
|
reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG);
|
|
|
|
rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
static s32 iol_execute(struct adapter *padapter, u8 control)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
s32 status = _FAIL;
|
2013-09-27 19:41:36 +00:00
|
|
|
u8 reg_0x88 = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 start = 0, passing_time = 0;
|
2013-05-26 03:24:47 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
control = control & 0x0f;
|
2013-05-08 21:45:39 +00:00
|
|
|
reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0);
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88 | control);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:18:54 +00:00
|
|
|
start = jiffies;
|
2013-08-08 05:41:21 +00:00
|
|
|
while ((reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0)) & control &&
|
|
|
|
(passing_time = rtw_get_passing_time_ms(start)) < 1000) {
|
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0);
|
2013-08-08 05:41:21 +00:00
|
|
|
status = (reg_0x88 & control) ? _FAIL : _SUCCESS;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (reg_0x88 & control << 4)
|
2013-05-08 21:45:39 +00:00
|
|
|
status = _FAIL;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
s32 rst = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
iol_mode_enable(padapter, 1);
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy);
|
2013-05-08 21:45:39 +00:00
|
|
|
rst = iol_execute(padapter, CMD_INIT_LLT);
|
|
|
|
iol_mode_enable(padapter, 0);
|
|
|
|
return rst;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
static void
|
2013-08-08 05:41:21 +00:00
|
|
|
efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 *efuseTbl = NULL;
|
|
|
|
u8 rtemp8;
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 eFuse_Addr = 0;
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 offset, wren;
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 i, j;
|
|
|
|
u16 **eFuseWord = NULL;
|
|
|
|
u16 efuse_utilized = 0;
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 u1temp = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
|
|
|
|
if (!efuseTbl)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
|
|
|
|
if (!eFuseWord)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 0. Refresh efuse init map as all oxFF. */
|
2013-05-08 21:45:39 +00:00
|
|
|
for (i = 0; i < EFUSE_MAX_SECTION_88E; i++)
|
|
|
|
for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++)
|
|
|
|
eFuseWord[i][j] = 0xFFFF;
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 1. Read the first byte to check if efuse is empty!!! */
|
|
|
|
/* */
|
|
|
|
/* */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtemp8 = *(phymap + eFuse_Addr);
|
2013-05-26 03:24:47 +00:00
|
|
|
if (rtemp8 != 0xFF) {
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_utilized++;
|
|
|
|
eFuse_Addr++;
|
2013-05-26 03:24:47 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 2. Read real efuse content. Filter PG header and every section data. */
|
|
|
|
/* */
|
2013-05-26 03:24:47 +00:00
|
|
|
while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Check PG header for section num. */
|
2013-08-08 05:41:21 +00:00
|
|
|
if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */
|
|
|
|
u1temp = ((rtemp8 & 0xE0) >> 5);
|
2022-06-08 23:46:35 +00:00
|
|
|
rtemp8 = *(phymap + eFuse_Addr);
|
2013-05-26 03:24:47 +00:00
|
|
|
if ((rtemp8 & 0x0F) == 0x0F) {
|
2013-05-19 04:28:07 +00:00
|
|
|
eFuse_Addr++;
|
2022-06-08 23:46:35 +00:00
|
|
|
rtemp8 = *(phymap + eFuse_Addr);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E))
|
2013-05-19 04:28:07 +00:00
|
|
|
eFuse_Addr++;
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
2013-05-26 03:24:47 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
offset = ((rtemp8 & 0xF0) >> 1) | u1temp;
|
|
|
|
wren = (rtemp8 & 0x0F);
|
2013-05-19 04:28:07 +00:00
|
|
|
eFuse_Addr++;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-26 03:24:47 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
offset = ((rtemp8 >> 4) & 0x0f);
|
2013-05-19 04:28:07 +00:00
|
|
|
wren = (rtemp8 & 0x0f);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:24:47 +00:00
|
|
|
if (offset < EFUSE_MAX_SECTION_88E) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Get word enable value from PG header */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Check word enable condition in the section */
|
2013-05-26 03:24:47 +00:00
|
|
|
if (!(wren & 0x01)) {
|
2022-06-08 23:46:35 +00:00
|
|
|
rtemp8 = *(phymap + eFuse_Addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
eFuse_Addr++;
|
|
|
|
efuse_utilized++;
|
|
|
|
eFuseWord[offset][i] = (rtemp8 & 0xff);
|
2013-05-19 04:28:07 +00:00
|
|
|
if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2022-06-08 23:46:35 +00:00
|
|
|
rtemp8 = *(phymap + eFuse_Addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
eFuse_Addr++;
|
|
|
|
efuse_utilized++;
|
2013-08-14 17:03:28 +00:00
|
|
|
eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
wren >>= 1;
|
|
|
|
}
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Read next PG header */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtemp8 = *(phymap + eFuse_Addr);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:24:47 +00:00
|
|
|
if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_utilized++;
|
|
|
|
eFuse_Addr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 3. Collect 16 sections and 4 word unit into Efuse map. */
|
|
|
|
/* */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) {
|
|
|
|
for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff);
|
|
|
|
efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 4. Copy from Efuse map to output pointer memory!!! */
|
|
|
|
/* */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < _size_byte; i++)
|
2022-06-08 23:46:35 +00:00
|
|
|
pbuf[i] = efuseTbl[_offset + i];
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 5. Calculate Efuse utilization. */
|
|
|
|
/* */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(efuseTbl);
|
2022-06-08 23:46:35 +00:00
|
|
|
kfree(eFuseWord);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 19:52:18 +00:00
|
|
|
static void efuse_read_phymap_from_txpktbuf(
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *adapter,
|
2013-07-10 18:25:07 +00:00
|
|
|
int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */
|
|
|
|
u8 *content, /* buffer to store efuse physical map */
|
|
|
|
u16 *size /* for efuse content: the max byte to read. will update to byte read */
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u16 dbg_addr = 0;
|
|
|
|
u32 start = 0, passing_time = 0;
|
2014-12-12 18:15:07 +00:00
|
|
|
__le32 lo32 = 0, hi32 = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 len = 0, count = 0;
|
|
|
|
int i = 0;
|
|
|
|
u16 limit = *size;
|
|
|
|
|
|
|
|
u8 *pos = content;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (bcnhead < 0) /* if not valid */
|
2022-06-08 23:46:35 +00:00
|
|
|
bcnhead = rtw_read8(adapter, REG_TDECTRL + 1);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
dbg_addr = bcnhead * 128 / 8; /* 8-bytes addressing */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:24:47 +00:00
|
|
|
while (1) {
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr + i);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_write8(adapter, REG_TXPKTBUF_DBG, 0);
|
2014-12-13 21:18:54 +00:00
|
|
|
start = jiffies;
|
2022-06-08 23:46:35 +00:00
|
|
|
while (!rtw_read8(adapter, REG_TXPKTBUF_DBG) &&
|
|
|
|
(passing_time = rtw_get_passing_time_ms(start)) < 1000)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_usleep_os(100);
|
|
|
|
|
2014-12-13 02:43:14 +00:00
|
|
|
/* data from EEPROM needs to be in LE */
|
2014-12-12 18:15:07 +00:00
|
|
|
lo32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L));
|
|
|
|
hi32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (i == 0) {
|
2014-12-13 02:43:14 +00:00
|
|
|
/* Although lenc is only used in a debug statement,
|
|
|
|
* do not remove it as the rtw_read16() call consumes
|
|
|
|
* 2 bytes from the EEPROM source.
|
|
|
|
*/
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_read16(adapter, REG_PKTBUF_DBG_DATA_L);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 02:43:14 +00:00
|
|
|
len = le32_to_cpu(lo32) & 0x0000ffff;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
limit = (len - 2 < limit) ? len - 2 : limit;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(pos, ((u8 *)&lo32) + 2, (limit >= count + 2) ? 2 : limit - count);
|
|
|
|
count += (limit >= count + 2) ? 2 : limit - count;
|
|
|
|
pos = content + count;
|
2013-05-18 21:16:10 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(pos, ((u8 *)&lo32), (limit >= count + 4) ? 4 : limit - count);
|
|
|
|
count += (limit >= count + 4) ? 4 : limit - count;
|
|
|
|
pos = content + count;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (limit > count && len - 2 > count) {
|
|
|
|
memcpy(pos, (u8 *)&hi32, (limit >= count + 4) ? 4 : limit - count);
|
|
|
|
count += (limit >= count + 4) ? 4 : limit - count;
|
|
|
|
pos = content + count;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (limit <= count || len - 2 <= count)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS);
|
|
|
|
*size = count;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
s32 status = _FAIL;
|
|
|
|
u8 physical_map[512];
|
|
|
|
u16 size = 512;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy);
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(physical_map, 0xFF, 512);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT);
|
|
|
|
status = iol_execute(padapter, CMD_READ_EFUSE_MAP);
|
2013-05-09 04:04:25 +00:00
|
|
|
if (status == _SUCCESS)
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_read_phymap_from_txpktbuf(padapter, txpktbuf_bndy, physical_map, &size);
|
|
|
|
efuse_phymap_to_logical(physical_map, offset, size_byte, logical_map);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
s32 rtl8188e_iol_efuse_patch(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
s32 result = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (rtw_IOL_applied(padapter)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
iol_mode_enable(padapter, 1);
|
|
|
|
result = iol_execute(padapter, CMD_READ_EFUSE_MAP);
|
2013-05-19 04:28:07 +00:00
|
|
|
if (result == _SUCCESS)
|
2013-05-08 21:45:39 +00:00
|
|
|
result = iol_execute(padapter, CMD_EFUSE_PATCH);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
iol_mode_enable(padapter, 0);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
s32 rst = _SUCCESS;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(padapter, REG_TDECTRL + 1, iocfg_bndy);
|
2013-05-08 21:45:39 +00:00
|
|
|
rst = iol_execute(padapter, CMD_IOCONFIG);
|
|
|
|
return rst;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-10-19 17:45:47 +00:00
|
|
|
struct pkt_attrib *pattrib = &xmit_frame->attrib;
|
2013-09-27 19:41:36 +00:00
|
|
|
u8 i;
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = _FAIL;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS)
|
|
|
|
goto exit;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE + pattrib->last_txcmdsz)) {
|
2013-08-08 05:41:21 +00:00
|
|
|
if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS)
|
|
|
|
goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
dump_mgntframe_and_wait(adapter, xmit_frame, max_wating_ms);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
iol_mode_enable(adapter, 1);
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < bndy_cnt; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 page_no = 0;
|
2022-06-08 23:46:35 +00:00
|
|
|
page_no = i * 2;
|
2013-08-08 05:41:21 +00:00
|
|
|
ret = iol_ioconfig(adapter, page_no);
|
|
|
|
if (ret != _SUCCESS)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
iol_mode_enable(adapter, 0);
|
|
|
|
exit:
|
2013-07-10 18:25:07 +00:00
|
|
|
/* restore BCN_HEAD */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(adapter, REG_TDECTRL + 1, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
void rtl8188e_EfusePowerSwitch(struct adapter *pAdapter, u8 PwrState)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u16 tmpV16;
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (PwrState) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON);
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */
|
2013-08-08 05:41:21 +00:00
|
|
|
tmpV16 = rtw_read16(pAdapter, REG_SYS_ISO_CTRL);
|
|
|
|
if (!(tmpV16 & PWC_EV12V)) {
|
|
|
|
tmpV16 |= PWC_EV12V;
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Reset: 0x0000h[28], default valid */
|
2013-08-08 05:41:21 +00:00
|
|
|
tmpV16 = rtw_read16(pAdapter, REG_SYS_FUNC_EN);
|
|
|
|
if (!(tmpV16 & FEN_ELDR)) {
|
|
|
|
tmpV16 |= FEN_ELDR;
|
|
|
|
rtw_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */
|
2013-08-08 05:41:21 +00:00
|
|
|
tmpV16 = rtw_read16(pAdapter, REG_SYS_CLKR);
|
|
|
|
if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) {
|
|
|
|
tmpV16 |= (LOADER_CLK_EN | ANA8M);
|
|
|
|
rtw_write16(pAdapter, REG_SYS_CLKR, tmpV16);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
static void Hal_EfuseReadEFuse88E(struct adapter *Adapter,
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 _offset,
|
2013-05-19 04:28:07 +00:00
|
|
|
u16 _size_byte,
|
2022-06-08 23:46:35 +00:00
|
|
|
u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 *efuseTbl = NULL;
|
|
|
|
u8 rtemp8[1];
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 eFuse_Addr = 0;
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 offset, wren;
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 i, j;
|
|
|
|
u16 **eFuseWord = NULL;
|
|
|
|
u16 efuse_utilized = 0;
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 u1temp = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */
|
|
|
|
/* */
|
2022-06-08 23:46:35 +00:00
|
|
|
if ((_offset + _size_byte) > EFUSE_MAP_LEN_88E) /* total E-Fuse table is 512bytes */
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
|
|
|
|
if (!efuseTbl)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
|
|
|
|
if (!eFuseWord)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 0. Refresh efuse init map as all oxFF. */
|
2013-05-08 21:45:39 +00:00
|
|
|
for (i = 0; i < EFUSE_MAX_SECTION_88E; i++)
|
|
|
|
for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++)
|
|
|
|
eFuseWord[i][j] = 0xFFFF;
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 1. Read the first byte to check if efuse is empty!!! */
|
|
|
|
/* */
|
|
|
|
/* */
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
|
2013-08-08 05:41:21 +00:00
|
|
|
if (*rtemp8 != 0xFF) {
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_utilized++;
|
|
|
|
eFuse_Addr++;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* 2. Read real efuse content. Filter PG header and every section data. */
|
|
|
|
/* */
|
2013-08-08 05:41:21 +00:00
|
|
|
while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Check PG header for section num. */
|
2013-08-08 05:41:21 +00:00
|
|
|
if ((*rtemp8 & 0x1F) == 0x0F) { /* extended header */
|
|
|
|
u1temp = ((*rtemp8 & 0xE0) >> 5);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if ((*rtemp8 & 0x0F) == 0x0F) {
|
2013-05-19 04:28:07 +00:00
|
|
|
eFuse_Addr++;
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E))
|
2013-05-19 04:28:07 +00:00
|
|
|
eFuse_Addr++;
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
offset = ((*rtemp8 & 0xF0) >> 1) | u1temp;
|
|
|
|
wren = (*rtemp8 & 0x0F);
|
2013-05-19 04:28:07 +00:00
|
|
|
eFuse_Addr++;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
offset = ((*rtemp8 >> 4) & 0x0f);
|
2013-05-19 04:28:07 +00:00
|
|
|
wren = (*rtemp8 & 0x0f);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (offset < EFUSE_MAX_SECTION_88E) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Get word enable value from PG header */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Check word enable condition in the section */
|
2013-08-08 05:41:21 +00:00
|
|
|
if (!(wren & 0x01)) {
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
|
2013-05-08 21:45:39 +00:00
|
|
|
eFuse_Addr++;
|
|
|
|
efuse_utilized++;
|
|
|
|
eFuseWord[offset][i] = (*rtemp8 & 0xff);
|
2013-05-19 04:28:07 +00:00
|
|
|
if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
|
2013-05-08 21:45:39 +00:00
|
|
|
eFuse_Addr++;
|
|
|
|
efuse_utilized++;
|
2013-08-14 17:03:28 +00:00
|
|
|
eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00);
|
2013-05-19 04:28:07 +00:00
|
|
|
if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
wren >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Read next PG header */
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByte(Adapter, eFuse_Addr, rtemp8);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
efuse_utilized++;
|
|
|
|
eFuse_Addr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 3. Collect 16 sections and 4 word unit into Efuse map. */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) {
|
|
|
|
for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff);
|
|
|
|
efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 4. Copy from Efuse map to output pointer memory!!! */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (i = 0; i < _size_byte; i++)
|
2022-06-08 23:46:35 +00:00
|
|
|
pbuf[i] = efuseTbl[_offset + i];
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(efuseTbl);
|
2022-06-08 23:46:35 +00:00
|
|
|
kfree(eFuseWord);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static void ReadEFuseByIC(struct adapter *Adapter, u16 _offset, u16 _size_byte, u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
int ret = _FAIL;
|
|
|
|
if (rtw_IOL_applied(Adapter)) {
|
|
|
|
rtl8188eu_InitPowerOn(Adapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
iol_mode_enable(Adapter, 1);
|
|
|
|
ret = iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf);
|
|
|
|
iol_mode_enable(Adapter, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (_SUCCESS == ret)
|
|
|
|
return;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _offset, u16 _size_byte, u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
ReadEFuseByIC(Adapter, _offset, _size_byte, pbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
void rtl8188e_read_chip_version(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u32 value32;
|
2013-07-22 22:43:38 +00:00
|
|
|
struct HAL_VERSION ChipVersion;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &padapter->haldata;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
value32 = rtw_read32(padapter, REG_SYS_CFG);
|
|
|
|
ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP);
|
|
|
|
|
|
|
|
ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC);
|
2022-06-08 23:46:35 +00:00
|
|
|
ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /* IC version (CUT) */
|
2013-07-10 18:25:07 +00:00
|
|
|
ChipVersion.ROMVer = 0; /* ROM code version. */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
dump_chip_info(ChipVersion);
|
|
|
|
|
|
|
|
pHalData->VersionID = ChipVersion;
|
|
|
|
}
|
2013-05-26 17:17:22 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
void rtl8188e_SetHalODMVar(struct adapter *Adapter, void *pValue1, bool bSet)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *podmpriv = &pHalData->odmpriv;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct sta_info *psta = (struct sta_info *)pValue1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (bSet) {
|
|
|
|
podmpriv->pODM_StaInfo[psta->mac_id] = psta;
|
|
|
|
ODM_RAInfo_Init(podmpriv, psta->mac_id);
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
podmpriv->pODM_StaInfo[psta->mac_id] = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
void hal_notch_filter_8188e(struct adapter *adapter, bool enable)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
if (enable)
|
|
|
|
rtw_write8(adapter, rOFDM0_RxDSP + 1, rtw_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1));
|
|
|
|
else
|
|
|
|
rtw_write8(adapter, rOFDM0_RxDSP + 1, rtw_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* LLT R/W/Init function */
|
|
|
|
/* */
|
|
|
|
/* */
|
2013-08-08 05:41:21 +00:00
|
|
|
static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
s32 status = _SUCCESS;
|
|
|
|
s32 count = 0;
|
|
|
|
u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
|
|
|
|
u16 LLTReg = REG_LLT_INIT;
|
|
|
|
|
|
|
|
rtw_write32(padapter, LLTReg, value);
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* polling */
|
2013-05-08 21:45:39 +00:00
|
|
|
do {
|
|
|
|
value = rtw_read32(padapter, LLTReg);
|
2013-08-08 05:41:21 +00:00
|
|
|
if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (count > POLLING_LLT_THRESHOLD) {
|
|
|
|
status = _FAIL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (count++);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
s32 status = _FAIL;
|
|
|
|
u32 i;
|
2013-07-10 18:25:07 +00:00
|
|
|
u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/* 176, 22k */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-14 16:21:05 +00:00
|
|
|
if (rtw_IOL_applied(padapter)) {
|
2013-05-19 04:28:07 +00:00
|
|
|
status = iol_InitLLTTable(padapter, txpktbuf_bndy);
|
2013-07-14 16:21:05 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
for (i = 0; i < (txpktbuf_bndy - 1); i++) {
|
|
|
|
status = _LLTWrite(padapter, i, i + 1);
|
2013-08-08 05:41:21 +00:00
|
|
|
if (_SUCCESS != status)
|
2013-05-08 21:45:39 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* end of list */
|
2013-05-08 21:45:39 +00:00
|
|
|
status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF);
|
2013-08-08 05:41:21 +00:00
|
|
|
if (_SUCCESS != status)
|
2013-05-08 21:45:39 +00:00
|
|
|
return status;
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Make the other pages as ring buffer */
|
|
|
|
/* This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */
|
|
|
|
/* Otherwise used as local loopback buffer. */
|
2013-05-08 21:45:39 +00:00
|
|
|
for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) {
|
|
|
|
status = _LLTWrite(padapter, i, (i + 1));
|
2013-08-08 05:41:21 +00:00
|
|
|
if (_SUCCESS != status)
|
2013-05-08 21:45:39 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Let last entry point to the start entry of ring buffer */
|
2013-05-08 21:45:39 +00:00
|
|
|
status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy);
|
|
|
|
if (_SUCCESS != status) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Hal_EfuseParseIDCode88E(
|
2013-08-08 05:41:21 +00:00
|
|
|
struct adapter *padapter,
|
|
|
|
u8 *hwinfo
|
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
|
|
|
u16 EEPROMId;
|
|
|
|
|
2014-11-13 00:42:52 +00:00
|
|
|
/* Check 0x8129 again for making sure autoload status!! */
|
2013-07-09 22:40:50 +00:00
|
|
|
EEPROMId = le16_to_cpu(*((__le16 *)hwinfo));
|
2013-08-08 05:41:21 +00:00
|
|
|
if (EEPROMId != RTL_EEPROM_ID) {
|
2014-11-13 00:42:52 +00:00
|
|
|
pr_err("EEPROM ID(%#x) is invalid!!\n", EEPROMId);
|
2013-05-26 03:02:10 +00:00
|
|
|
pEEPROM->bautoload_fail_flag = true;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-26 03:02:10 +00:00
|
|
|
pEEPROM->bautoload_fail_flag = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 00:42:52 +00:00
|
|
|
pr_info("EEPROM ID = 0x%04x\n", EEPROMId);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-08-08 05:41:21 +00:00
|
|
|
u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (AutoLoadFail) {
|
2016-02-13 21:40:00 +00:00
|
|
|
for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 2.4G default value */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
|
|
|
|
pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
|
|
|
|
}
|
2013-08-08 05:41:21 +00:00
|
|
|
for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
|
|
|
|
if (TxCount == 0) {
|
|
|
|
pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF;
|
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF;
|
|
|
|
} else {
|
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
|
|
|
pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
2013-08-08 05:41:21 +00:00
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
return;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2016-02-13 21:40:00 +00:00
|
|
|
for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 2.4G default value */
|
2013-08-08 05:41:21 +00:00
|
|
|
for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++];
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF)
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
|
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
for (group = 0; group < MAX_CHNL_GROUP_24G - 1; group++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++];
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF)
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-08-08 05:41:21 +00:00
|
|
|
for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
|
|
|
|
if (TxCount == 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->BW40_Diff[rfPath][TxCount] = 0;
|
2013-08-08 05:41:21 +00:00
|
|
|
if (PROMContent[eeAddr] == 0xFF) {
|
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF;
|
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4;
|
|
|
|
if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0;
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (PROMContent[eeAddr] == 0xFF) {
|
2013-05-19 04:28:07 +00:00
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f);
|
|
|
|
if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0;
|
|
|
|
eeAddr++;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
|
|
|
if (PROMContent[eeAddr] == 0xFF) {
|
2013-05-19 04:28:07 +00:00
|
|
|
pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4;
|
|
|
|
if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (PROMContent[eeAddr] == 0xFF) {
|
2013-05-19 04:28:07 +00:00
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f);
|
|
|
|
if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0;
|
|
|
|
}
|
|
|
|
eeAddr++;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (PROMContent[eeAddr] == 0xFF) {
|
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4;
|
|
|
|
if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (PROMContent[eeAddr] == 0xFF) {
|
2013-05-19 04:28:07 +00:00
|
|
|
pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f);
|
|
|
|
if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0;
|
|
|
|
}
|
|
|
|
eeAddr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static void hal_get_chnl_group_88e(u8 chnl, u8 *group)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
if (chnl < 3) /* Channel 1-2 */
|
|
|
|
*group = 0;
|
|
|
|
else if (chnl < 6) /* Channel 3-5 */
|
|
|
|
*group = 1;
|
|
|
|
else if (chnl < 9) /* Channel 6-8 */
|
|
|
|
*group = 2;
|
|
|
|
else if (chnl < 12) /* Channel 9-11 */
|
|
|
|
*group = 3;
|
|
|
|
else if (chnl < 14) /* Channel 12-13 */
|
|
|
|
*group = 4;
|
|
|
|
else if (chnl == 14) /* Channel 14 */
|
|
|
|
*group = 5;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
if (AutoLoadFail)
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->pwrctrlpriv.bSupportRemoteWakeup = false;
|
2022-06-08 23:46:35 +00:00
|
|
|
else
|
2013-07-10 18:25:07 +00:00
|
|
|
/* hw power down mode selection , 0:rf-off / 1:power down */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* decide hw if support remote wakeup function */
|
2013-08-08 05:41:21 +00:00
|
|
|
/* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */
|
2022-06-08 23:46:35 +00:00
|
|
|
padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT(1)) ? true : false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &padapter->haldata;
|
2013-07-26 20:54:27 +00:00
|
|
|
struct txpowerinfo24g pwrInfo24G;
|
2022-06-08 23:46:35 +00:00
|
|
|
u8 ch, group;
|
|
|
|
u8 TxCount;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
|
|
|
|
hal_get_chnl_group_88e(ch, &group);
|
|
|
|
|
|
|
|
pHalData->Index24G_CCK_Base[ch] = pwrInfo24G.IndexCCK_Base[0][group];
|
|
|
|
if (ch == 14)
|
|
|
|
pHalData->Index24G_BW40_Base[ch] = pwrInfo24G.IndexBW40_Base[0][4];
|
|
|
|
else
|
|
|
|
pHalData->Index24G_BW40_Base[ch] = pwrInfo24G.IndexBW40_Base[0][group];
|
|
|
|
}
|
|
|
|
for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
|
|
|
|
pHalData->OFDM_24G_Diff[TxCount] = pwrInfo24G.OFDM_Diff[0][TxCount];
|
|
|
|
pHalData->BW20_24G_Diff[TxCount] = pwrInfo24G.BW20_Diff[0][TxCount];
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 2010/10/19 MH Add Regulator recognize for CU. */
|
2013-08-08 05:41:21 +00:00
|
|
|
if (!AutoLoadFail) {
|
2022-06-08 23:46:35 +00:00
|
|
|
pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x7); /* bit0~2 */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF)
|
2022-06-08 23:46:35 +00:00
|
|
|
pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION & 0x7); /* bit0~2 */
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pHalData->EEPROMRegulatory = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &pAdapter->haldata;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (!AutoLoadFail) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E];
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pHalData->CrystalCap == 0xFF)
|
2013-05-19 04:28:07 +00:00
|
|
|
pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-08 05:41:21 +00:00
|
|
|
padapter->mlmepriv.ChannelPlan =
|
|
|
|
hal_com_get_channel_plan(padapter,
|
|
|
|
hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF,
|
|
|
|
padapter->registrypriv.channel_plan,
|
|
|
|
RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &pAdapter->haldata;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct registry_priv *registry_par = &pAdapter->registrypriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (!AutoLoadFail) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Antenna Diversity setting. */
|
2013-08-08 05:41:21 +00:00
|
|
|
if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */
|
2022-06-08 23:46:35 +00:00
|
|
|
pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x18) >> 3;
|
2013-05-19 04:28:07 +00:00
|
|
|
if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF)
|
2022-06-08 23:46:35 +00:00
|
|
|
pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION & 0x18) >> 3;
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
|
|
|
pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (registry_par->antdiv_type == 0) {
|
|
|
|
/* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */
|
2013-05-19 04:28:07 +00:00
|
|
|
pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E];
|
|
|
|
if (pHalData->TRxAntDivType == 0xFF)
|
2013-07-10 18:25:07 +00:00
|
|
|
pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /* For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
|
|
|
pHalData->TRxAntDivType = registry_par->antdiv_type;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV)
|
2013-07-10 18:25:07 +00:00
|
|
|
pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */
|
2013-08-08 05:41:21 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pHalData->AntDivCfg = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &Adapter->haldata;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* ThermalMeter from EEPROM */
|
2013-05-19 04:28:07 +00:00
|
|
|
if (!AutoloadFail)
|
2013-05-08 21:45:39 +00:00
|
|
|
pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E];
|
|
|
|
else
|
|
|
|
pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail)
|
2013-05-19 04:28:07 +00:00
|
|
|
pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|