// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ #include <drv_types.h> #include <rtw_debug.h> #include <hal_data.h> #include <linux/jiffies.h> /* Define global variables */ u8 fakeEfuseBank; u32 fakeEfuseUsedBytes; u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = …; u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN] = …; u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN] = …; u32 BTEfuseUsedBytes; u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = …; u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = …; u32 fakeBTEfuseUsedBytes; u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = …; u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = …; #define REG_EFUSE_CTRL … #define EFUSE_CTRL … static bool Efuse_Read1ByteFromFakeContent(u16 Offset, u8 *Value) { … } static bool Efuse_Write1ByteToFakeContent(u16 Offset, u8 Value) { … } /*----------------------------------------------------------------------------- * Function: Efuse_PowerSwitch * * Overview: When we want to enable write operation, we should change to * 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 * 11/17/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ void Efuse_PowerSwitch( struct adapter *padapter, u8 bWrite, u8 PwrState) { … } /*----------------------------------------------------------------------------- * Function: Efuse_GetCurrentSize * * Overview: Get current efuse size!!! * * Input: NONE * * Output: NONE * * Return: NONE * * Revised History: * When Who Remark * 11/16/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ u16 Efuse_GetCurrentSize( struct adapter *padapter, u8 efuseType, bool bPseudoTest) { … } /* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */ u8 Efuse_CalculateWordCnts(u8 word_en) { … } /* */ /* Description: */ /* 1. Execute E-Fuse read byte operation according as map offset and */ /* save to E-Fuse table. */ /* 2. Referred from SD1 Richard. */ /* */ /* Assumption: */ /* 1. Boot from E-Fuse and successfully auto-load. */ /* 2. PASSIVE_LEVEL (USB interface) */ /* */ /* Created by Roger, 2008.10.21. */ /* */ /* 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description. */ /* 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. */ /* */ void efuse_ReadEFuse( struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest ); void efuse_ReadEFuse( struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest ) { … } void EFUSE_GetEfuseDefinition( struct adapter *padapter, u8 efuseType, u8 type, void *pOut, bool bPseudoTest ) { … } /*----------------------------------------------------------------------------- * Function: EFUSE_Read1Byte * * Overview: Copy from WMAC fot EFUSE read 1 byte. * * Input: NONE * * Output: NONE * * Return: NONE * * Revised History: * When Who Remark * 09/23/2008 MHC Copy from WMAC. * *---------------------------------------------------------------------------*/ u8 EFUSE_Read1Byte( struct adapter *Adapter, u16 Address) { … } /* EFUSE_Read1Byte */ /* 11/16/2008 MH Read one byte from real Efuse. */ u8 efuse_OneByteRead( struct adapter *padapter, u16 addr, u8 *data, bool bPseudoTest) { … } /* 11/16/2008 MH Write one byte to reald Efuse. */ u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool bPseudoTest) { … } int Efuse_PgPacketRead(struct adapter *padapter, u8 offset, u8 *data, bool bPseudoTest) { … } int Efuse_PgPacketWrite(struct adapter *padapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) { … } /*----------------------------------------------------------------------------- * Function: efuse_WordEnableDataRead * * Overview: Read allowed word in current efuse section data. * * Input: NONE * * Output: NONE * * Return: NONE * * Revised History: * When Who Remark * 11/16/2008 MHC Create Version 0. * 11/21/2008 MHC Fix Write bug when we only enable late word. * *---------------------------------------------------------------------------*/ void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) { … } u8 Efuse_WordEnableDataWrite(struct adapter *padapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) { … } /*----------------------------------------------------------------------------- * Function: Efuse_ReadAllMap * * Overview: Read All Efuse content * * Input: NONE * * Output: NONE * * Return: NONE * * Revised History: * When Who Remark * 11/11/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ void Efuse_ReadAllMap( struct adapter *padapter, u8 efuseType, u8 *Efuse, bool bPseudoTest); void Efuse_ReadAllMap(struct adapter *padapter, u8 efuseType, u8 *Efuse, bool bPseudoTest) { … } /*----------------------------------------------------------------------------- * 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 * 11/12/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ static void efuse_ShadowRead1Byte(struct adapter *padapter, u16 Offset, u8 *Value) { … } /* EFUSE_ShadowRead1Byte */ /* Read Two Bytes */ static void efuse_ShadowRead2Byte(struct adapter *padapter, u16 Offset, u16 *Value) { … } /* EFUSE_ShadowRead2Byte */ /* Read Four Bytes */ static void efuse_ShadowRead4Byte(struct adapter *padapter, u16 Offset, u32 *Value) { … } /* efuse_ShadowRead4Byte */ /*----------------------------------------------------------------------------- * 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 * 11/13/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ void EFUSE_ShadowMapUpdate(struct adapter *padapter, u8 efuseType, bool bPseudoTest) { … } /* EFUSE_ShadowMapUpdate */ /*----------------------------------------------------------------------------- * Function: EFUSE_ShadowRead * * Overview: Read from efuse init map !!!!! * * Input: NONE * * Output: NONE * * Return: NONE * * Revised History: * When Who Remark * 11/12/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ void EFUSE_ShadowRead(struct adapter *padapter, u8 Type, u16 Offset, u32 *Value) { … } /* EFUSE_ShadowRead*/