return retU2;
}
-static u8
-Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter,
- u16 efuse_addr, u8 word_en, u8 *data)
-{
- u16 tmpaddr = 0;
- u16 start_addr = efuse_addr;
- u8 badworden = 0x0F;
- u8 tmpdata[PGPKT_DATA_SIZE];
-
- memset(tmpdata, 0xFF, PGPKT_DATA_SIZE);
-
- if (!(word_en & BIT(0))) {
- tmpaddr = start_addr;
- efuse_OneByteWrite23a(padapter, start_addr++, data[0]);
- efuse_OneByteWrite23a(padapter, start_addr++, data[1]);
-
- efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[0]);
- efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[1]);
- if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) {
- badworden &= ~BIT(0);
- }
- }
- if (!(word_en & BIT(1))) {
- tmpaddr = start_addr;
- efuse_OneByteWrite23a(padapter, start_addr++, data[2]);
- efuse_OneByteWrite23a(padapter, start_addr++, data[3]);
-
- efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[2]);
- efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[3]);
- if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) {
- badworden &= ~BIT(1);
- }
- }
- if (!(word_en & BIT(2))) {
- tmpaddr = start_addr;
- efuse_OneByteWrite23a(padapter, start_addr++, data[4]);
- efuse_OneByteWrite23a(padapter, start_addr++, data[5]);
-
- efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[4]);
- efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[5]);
- if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) {
- badworden &= ~BIT(2);
- }
- }
- if (!(word_en & BIT(3))) {
- tmpaddr = start_addr;
- efuse_OneByteWrite23a(padapter, start_addr++, data[6]);
- efuse_OneByteWrite23a(padapter, start_addr++, data[7]);
-
- efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[6]);
- efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[7]);
- if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) {
- badworden &= ~BIT(3);
- }
- }
-
- return badworden;
-}
-
-static s32
-Hal_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data)
+bool
+rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data)
{
u8 efuse_data, word_cnts = 0;
u16 efuse_addr = 0;
return ret;
}
-static u8
-hal_EfusePgCheckAvailableAddr(struct rtw_adapter *pAdapter, u8 efuseType)
-{
- u16 max_available = 0;
- u16 current_size;
-
- EFUSE_GetEfuseDefinition23a(pAdapter, efuseType,
- TYPE_AVAILABLE_EFUSE_BYTES_TOTAL,
- &max_available);
-
- current_size = Efuse_GetCurrentSize23a(pAdapter, efuseType);
- if (current_size >= max_available) {
- DBG_8723A("%s: Error!! current_size(%d)>max_available(%d)\n",
- __func__, current_size, max_available);
- return false;
- }
- return true;
-}
-
-static void
-hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData,
- struct pg_pkt_struct *pTargetPkt)
-{
- memset(pTargetPkt->data, 0xFF, PGPKT_DATA_SIZE);
- pTargetPkt->offset = offset;
- pTargetPkt->word_en = word_en;
- efuse_WordEnableDataRead23a(word_en, pData, pTargetPkt->data);
- pTargetPkt->word_cnts = Efuse_CalculateWordCnts23a(pTargetPkt->word_en);
-}
-
-static u8
-hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType,
- u16 *pAddr, struct pg_pkt_struct *pTargetPkt)
-{
- struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
- u8 bRet = false;
- u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0;
- u8 efuse_data = 0;
-
- EFUSE_GetEfuseDefinition23a(padapter, efuseType,
- TYPE_AVAILABLE_EFUSE_BYTES_TOTAL,
- &efuse_max_available_len);
- EFUSE_GetEfuseDefinition23a(padapter, efuseType,
- TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max);
-
- if (efuseType == EFUSE_WIFI)
- startAddr = pHalData->EfuseUsedBytes;
- else
- startAddr = pHalData->BTEfuseUsedBytes;
-
- startAddr %= efuse_max;
-
- while (1) {
- if (startAddr >= efuse_max_available_len) {
- bRet = false;
- DBG_8723A("%s: startAddr(%d) >= efuse_max_available_"
- "len(%d)\n", __func__, startAddr,
- efuse_max_available_len);
- break;
- }
-
- if (efuse_OneByteRead23a(padapter, startAddr, &efuse_data) &&
- (efuse_data != 0xFF)) {
- bRet = false;
- DBG_8723A("%s: Something Wrong! last bytes(%#X = 0x%02X) "
- "is not 0xFF\n", __func__,
- startAddr, efuse_data);
- break;
- } else {
- /* not used header, 0xff */
- *pAddr = startAddr;
- bRet = true;
- break;
- }
- }
-
- return bRet;
-}
-
-static u8
-hal_EfusePgPacketWrite1ByteHeader(struct rtw_adapter *pAdapter, u8 efuseType,
- u16 *pAddr, struct pg_pkt_struct *pTargetPkt)
-{
- u8 pg_header = 0, tmp_header = 0;
- u16 efuse_addr = *pAddr;
- u8 repeatcnt = 0;
-
- pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en;
-
- do {
- efuse_OneByteWrite23a(pAdapter, efuse_addr, pg_header);
- efuse_OneByteRead23a(pAdapter, efuse_addr, &tmp_header);
- if (tmp_header != 0xFF)
- break;
- if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) {
- DBG_8723A("%s: Repeat over limit for pg_header!!\n",
- __func__);
- return false;
- }
- } while (1);
-
- if (tmp_header != pg_header) {
- DBG_8723A(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X "
- "read = 0x%02X)\n", __func__,
- pg_header, tmp_header);
- return false;
- }
-
- *pAddr = efuse_addr;
-
- return true;
-}
-
-static u8
-hal_EfusePgPacketWrite2ByteHeader(struct rtw_adapter *padapter, u8 efuseType,
- u16 *pAddr, struct pg_pkt_struct *pTargetPkt)
-{
- u16 efuse_addr, efuse_max_available_len = 0;
- u8 pg_header = 0, tmp_header = 0;
- u8 repeatcnt = 0;
-
- EFUSE_GetEfuseDefinition23a(padapter, efuseType,
- TYPE_AVAILABLE_EFUSE_BYTES_BANK,
- &efuse_max_available_len);
-
- efuse_addr = *pAddr;
- if (efuse_addr >= efuse_max_available_len) {
- DBG_8723A("%s: addr(%d) over avaliable(%d)!!\n", __func__,
- efuse_addr, efuse_max_available_len);
- return false;
- }
-
- pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F;
-
- do {
- efuse_OneByteWrite23a(padapter, efuse_addr, pg_header);
- efuse_OneByteRead23a(padapter, efuse_addr, &tmp_header);
- if (tmp_header != 0xFF)
- break;
- if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) {
- DBG_8723A("%s: Repeat over limit for pg_header!!\n",
- __func__);
- return false;
- }
- } while (1);
-
- if (tmp_header != pg_header) {
- DBG_8723A(KERN_ERR
- "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n",
- __func__, pg_header, tmp_header);
- return false;
- }
-
- /* to write ext_header */
- efuse_addr++;
- pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en;
-
- do {
- efuse_OneByteWrite23a(padapter, efuse_addr, pg_header);
- efuse_OneByteRead23a(padapter, efuse_addr, &tmp_header);
- if (tmp_header != 0xFF)
- break;
- if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) {
- DBG_8723A("%s: Repeat over limit for ext_header!!\n",
- __func__);
- return false;
- }
- } while (1);
-
- if (tmp_header != pg_header) { /* offset PG fail */
- DBG_8723A(KERN_ERR
- "%s: PG EXT Header Fail!!(pg = 0x%02X read = 0x%02X)\n",
- __func__, pg_header, tmp_header);
- return false;
- }
-
- *pAddr = efuse_addr;
-
- return true;
-}
-
-static u8
-hal_EfusePgPacketWriteHeader(struct rtw_adapter *padapter, u8 efuseType,
- u16 *pAddr, struct pg_pkt_struct *pTargetPkt)
-{
- u8 bRet = false;
-
- if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) {
- bRet = hal_EfusePgPacketWrite2ByteHeader(padapter, efuseType,
- pAddr, pTargetPkt);
- } else {
- bRet = hal_EfusePgPacketWrite1ByteHeader(padapter, efuseType,
- pAddr, pTargetPkt);
- }
-
- return bRet;
-}
-
-static u8
-hal_EfusePgPacketWriteData(struct rtw_adapter *pAdapter, u8 efuseType,
- u16 *pAddr, struct pg_pkt_struct *pTargetPkt)
-{
- u16 efuse_addr;
- u8 badworden;
-
- efuse_addr = *pAddr;
- badworden =
- Efuse_WordEnableDataWrite23a(pAdapter, efuse_addr + 1,
- pTargetPkt->word_en, pTargetPkt->data);
- if (badworden != 0x0F) {
- DBG_8723A("%s: Fail!!\n", __func__);
- return false;
- }
-
- return true;
-}
-
-static s32
-Hal_EfusePgPacketWrite(struct rtw_adapter *padapter,
- u8 offset, u8 word_en, u8 *pData)
-{
- struct pg_pkt_struct targetPkt;
- u16 startAddr = 0;
- u8 efuseType = EFUSE_WIFI;
-
- if (!hal_EfusePgCheckAvailableAddr(padapter, efuseType))
- return false;
-
- hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt);
-
- if (!hal_EfusePartialWriteCheck(padapter, efuseType,
- &startAddr, &targetPkt))
- return false;
-
- if (!hal_EfusePgPacketWriteHeader(padapter, efuseType,
- &startAddr, &targetPkt))
- return false;
-
- if (!hal_EfusePgPacketWriteData(padapter, efuseType,
- &startAddr, &targetPkt))
- return false;
-
- return true;
-}
-
-static bool
-Hal_EfusePgPacketWrite_BT(struct rtw_adapter *pAdapter,
- u8 offset, u8 word_en, u8 *pData)
-{
- struct pg_pkt_struct targetPkt;
- u16 startAddr = 0;
- u8 efuseType = EFUSE_BT;
-
- if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType))
- return false;
-
- hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt);
-
- if (!hal_EfusePartialWriteCheck(pAdapter, efuseType,
- &startAddr, &targetPkt))
- return false;
-
- if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType,
- &startAddr, &targetPkt))
- return false;
-
- if (!hal_EfusePgPacketWriteData(pAdapter, efuseType,
- &startAddr, &targetPkt))
- return false;
-
- return true;
-}
-
void rtl8723a_read_chip_version(struct rtw_adapter *padapter)
{
u32 value32;
return ret;
}
-void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc)
-{
- /* Efuse related function */
- pHalFunc->Efuse_PgPacketRead23a = &Hal_EfusePgPacketRead;
- pHalFunc->Efuse_PgPacketWrite23a = &Hal_EfusePgPacketWrite;
- pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite;
- pHalFunc->Efuse_PgPacketWrite23a_BT = &Hal_EfusePgPacketWrite_BT;
-}
-
void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter)
{
u8 val;