Skip to content

Commit c1b4d66

Browse files
MaochenWang1mmahadevan108
authored andcommitted
conn_fwloader: write CAU temperature to FW before DPD training
write CAU temperature to FW before DPD training Signed-off-by: Maochen Wang <[email protected]>
1 parent 19c05e1 commit c1b4d66

File tree

4 files changed

+138
-1
lines changed

4 files changed

+138
-1
lines changed

mcux/mcux-sdk-ng/components/conn_fwloader/fsl_loader.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ void power_off_device(LOAD_Target_Type loadTarget)
5656
{
5757
power_off_device_impl(loadTarget);
5858
}
59+
60+
////////////////////////////////////////////////////////////////////////////
61+
//! @brief write temperature to FW
62+
////////////////////////////////////////////////////////////////////////////
63+
int32_t cau_temperature_write_to_firmware(void)
64+
{
65+
return cau_temperature_write_to_firmware_impl();
66+
}
67+
68+
////////////////////////////////////////////////////////////////////////////
69+
//! @brief get cau temperature
70+
////////////////////////////////////////////////////////////////////////////
71+
int32_t cau_get_temperature(void)
72+
{
73+
return cau_get_temperature_impl();
74+
}
75+
76+
////////////////////////////////////////////////////////////////////////////
77+
//! @brief enable cau temperature
78+
////////////////////////////////////////////////////////////////////////////
79+
void cau_temperature_enable(void)
80+
{
81+
cau_temperature_enable_impl();
82+
}
5983
//! @}
6084
////////////////////////////////////////////////////////////////////////////
6185
// EOF

mcux/mcux-sdk-ng/components/conn_fwloader/fsl_loader_utils.c

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,90 @@ static int __OtpDeInit(void)
13301330
return ret;
13311331
}
13321332

1333+
void cau_temperature_enable_impl(void)
1334+
{
1335+
uint32_t val;
1336+
1337+
val = CAU_REG32(CAU_ENABLE_ADDR);
1338+
val &= ~(0xC);
1339+
val |= (2 << 2);
1340+
CAU_WRITE_REG32(CAU_ENABLE_ADDR, val);
1341+
OSA_TimeDelay(1);
1342+
}
1343+
1344+
int32_t cau_get_temperature_impl(void)
1345+
{
1346+
int32_t val = 0;
1347+
uint32_t reg_val = 0;
1348+
uint32_t temp_Cau_Raw_Reading = 0;
1349+
status_t status = 0;
1350+
uint32_t board_type = 0;
1351+
1352+
reg_val = CAU_REG32(CAU_TEMPERATURE_ADDR);
1353+
temp_Cau_Raw_Reading = ((reg_val & 0XFFC00) >> 10);
1354+
1355+
OCOTP_OtpInit();
1356+
status = OCOTP_ReadPackage(&board_type);
1357+
if (status != kStatus_Success)
1358+
{
1359+
/*If status error, use BGA as default type*/
1360+
board_type = RW610_PACKAGE_TYPE_BGA;
1361+
}
1362+
OCOTP_OtpDeinit();
1363+
1364+
switch (board_type)
1365+
{
1366+
case RW610_PACKAGE_TYPE_QFN:
1367+
val = (((((int32_t)(temp_Cau_Raw_Reading)) * 484260) - 220040600) / 1000000);
1368+
break;
1369+
1370+
case RW610_PACKAGE_TYPE_CSP:
1371+
val = (((((int32_t)(temp_Cau_Raw_Reading)) * 480560) - 220707000) / 1000000);
1372+
break;
1373+
1374+
case RW610_PACKAGE_TYPE_BGA:
1375+
val = (((((int32_t)(temp_Cau_Raw_Reading)) * 480561) - 220707400) / 1000000);
1376+
break;
1377+
1378+
default:
1379+
val = (((((int32_t)(temp_Cau_Raw_Reading)) * 480561) - 220707400) / 1000000);
1380+
break;
1381+
}
1382+
1383+
return val;
1384+
}
1385+
1386+
int32_t cau_temperature_write_to_firmware_impl()
1387+
{
1388+
int32_t val = 0;
1389+
1390+
val = cau_get_temperature_impl();
1391+
CAU_WRITE_REG32(CAU_TEMPERATURE_FW_ADDR, val);
1392+
return val;
1393+
}
1394+
1395+
static void cau_pmip_v33_enable()
1396+
{
1397+
uint32_t val;
1398+
1399+
val = CAU_REG32(CAU_PMIP_TSEN_ADDR);
1400+
val &= ~(0xE);
1401+
val |= (5 << 1);
1402+
CAU_WRITE_REG32(CAU_PMIP_TSEN_ADDR, val);
1403+
1404+
val = CAU_REG32(CAU_V33_VSEN_ADDR);
1405+
val &= ~(0xE);
1406+
val |= (5 << 1);
1407+
CAU_WRITE_REG32(CAU_V33_VSEN_ADDR, val);
1408+
1409+
val = CAU_REG32(CAU_ADC_CTRL_ADDR);
1410+
val |= 1 << 0;
1411+
CAU_WRITE_REG32(CAU_ADC_CTRL_ADDR, val);
1412+
1413+
val = CAU_REG32(CAU_ADC_CTRL_ADDR);
1414+
val &= ~(1 << 0);
1415+
CAU_WRITE_REG32(CAU_ADC_CTRL_ADDR, val);
1416+
}
13331417

13341418
////////////////////////////////////////////////////////////////////////////
13351419
//! @brief load service
@@ -1497,6 +1581,10 @@ status_t load_service(LOAD_Target_Type loadTarget, uint32_t sourceAddr)
14971581
(void)__OtpDeInit();
14981582
}
14991583

1584+
cau_temperature_enable_impl();
1585+
cau_pmip_v33_enable();
1586+
cau_temperature_write_to_firmware_impl();
1587+
15001588
if (status == kStatus_Success)
15011589
{
15021590
reset_device(loadTarget);
@@ -1586,6 +1674,10 @@ static status_t load_service_monolithic(LOAD_Target_Type loadTarget, uint32_t so
15861674
(void)__OtpDeInit();
15871675
}
15881676

1677+
cau_temperature_enable_impl();
1678+
cau_pmip_v33_enable();
1679+
cau_temperature_write_to_firmware_impl();
1680+
15891681
if (status == kStatus_Success)
15901682
{
15911683
reset_device(loadTarget);

mcux/mcux-sdk-ng/components/conn_fwloader/include/fsl_loader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ void power_off_device(LOAD_Target_Type loadTarget);
2929

3030
status_t sb3_fw_download(LOAD_Target_Type loadTarget, uint32_t flag, uint32_t sourceAddr);
3131
status_t sb3_fw_reset(LOAD_Target_Type loadTarget, uint32_t flag, uint32_t sourceAddr);
32+
int32_t cau_temperature_write_to_firmware(void);
33+
int32_t cau_get_temperature(void);
34+
void cau_temperature_enable(void);
3235

3336
//! @}
3437

mcux/mcux-sdk-ng/components/conn_fwloader/include/fsl_loader_utils.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,22 @@ typedef uint32_t fsl_nboot_status_t;
117117
#define kNBOOT_RootKeyUsage_DebugCA_ImageCA_FwCA_ImageKey_FwKey (0x0u)
118118
#define kNBOOT_RootKeyUsage_Unused (0x7u)
119119

120+
/*! @brief The cau registers. */
121+
#define CAU_ENABLE_ADDR (0x45004008U)
122+
#define CAU_TEMPERATURE_ADDR (0x4500400CU)
123+
#define CAU_TEMPERATURE_FW_ADDR (0x41382490U)
124+
#define CAU_FW_WAKE_STATUS_ADDR (0x40031068U)
125+
#define CAU_PMIP_TSEN_ADDR (0x45004010U)
126+
#define CAU_V33_VSEN_ADDR (0x45004028U)
127+
#define CAU_ADC_CTRL_ADDR (0x45004000U)
128+
129+
#define RW610_PACKAGE_TYPE_QFN 0
130+
#define RW610_PACKAGE_TYPE_CSP 1
131+
#define RW610_PACKAGE_TYPE_BGA 2
132+
133+
#define CAU_REG32(x) (*(volatile unsigned int *)(x))
134+
#define CAU_WRITE_REG32(reg, val) (CAU_REG32(reg) = (val))
135+
120136
//! @brief SB loader status codes.
121137
enum _sbloader_status
122138
{
@@ -663,7 +679,9 @@ status_t loader_process_sb_file(uint32_t readOffset);
663679
status_t fsl_sbloader_init(fsl_api_core_context_t *ctx);
664680
status_t fsl_sbloader_finalize(fsl_api_core_context_t *ctx);
665681
uint8_t get_chip_revision(void);
666-
682+
int32_t cau_temperature_write_to_firmware_impl(void);
683+
int32_t cau_get_temperature_impl(void);
684+
void cau_temperature_enable_impl(void);
667685
//! @}
668686

669687
#endif /* __FSL_LOADER_UTILS_H__ */

0 commit comments

Comments
 (0)