415 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			415 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "phy_status.h"
							 | 
						||
| 
								 | 
							
								#include "phy_bb.h"
							 | 
						||
| 
								 | 
							
								#include "hw_tonemask.h"
							 | 
						||
| 
								 | 
							
								#include "hw_reg_api.h"
							 | 
						||
| 
								 | 
							
								#include "phy_dfe_reg.h"
							 | 
						||
| 
								 | 
							
								#include "phy_tx_reg.h"
							 | 
						||
| 
								 | 
							
								#include "phy_reg.h"
							 | 
						||
| 
								 | 
							
								#include "phy_ana.h"
							 | 
						||
| 
								 | 
							
								#include "phy_txrx_pwr.h"
							 | 
						||
| 
								 | 
							
								#include "hw_phy_api.h"
							 | 
						||
| 
								 | 
							
								#include "mac_sys_reg.h"
							 | 
						||
| 
								 | 
							
								#include "granite_reg.h"
							 | 
						||
| 
								 | 
							
								#include "iot_io_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_dbglog_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_dbglog.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* 30 minutes period, uint 10 mimutes */
							 | 
						||
| 
								 | 
							
								#define PHY_PERIOD_30_MIN      3
							 | 
						||
| 
								 | 
							
								/* 60 minutes period, uint 10 mimutes */
							 | 
						||
| 
								 | 
							
								#define PHY_PERIOD_60_MIN      6
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static uint8_t g_phy_period_30_min_cnt = 0, g_phy_period_60_min_cnt = 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_rx_dc()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    volatile uint16_t dc_pgf = 0;
							 | 
						||
| 
								 | 
							
								    volatile uint16_t dc_pga = 0;
							 | 
						||
| 
								 | 
							
								    /* scan each gain */
							 | 
						||
| 
								 | 
							
								    uint8_t i;
							 | 
						||
| 
								 | 
							
								    for(i = 0; i < 8; i++)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        phy_pgf_pga_dc_cal_get(i+77, &dc_pgf, &dc_pga);
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[i] = dc_pga;
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[i] = dc_pga;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* dc comp */
							 | 
						||
| 
								 | 
							
								void phy_dc_comp_gain_get(volatile uint16_t *gain0, volatile uint16_t *gain1,
							 | 
						||
| 
								 | 
							
								                          volatile uint16_t *gain2, volatile uint16_t *gain3)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    uint32_t tmp = 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    tmp = PHY_DFE_READ_REG(CFG_BB_DC_COMP0_ADDR);
							 | 
						||
| 
								 | 
							
								    *gain0 = (uint16_t)REG_FIELD_GET(SW_DC_COMP_GAIN0, tmp);
							 | 
						||
| 
								 | 
							
								    *gain1 = (uint16_t)REG_FIELD_GET(SW_DC_COMP_GAIN1, tmp);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    tmp = PHY_DFE_READ_REG(CFG_BB_DC_COMP1_ADDR);
							 | 
						||
| 
								 | 
							
								    *gain2 = (uint16_t)REG_FIELD_GET(SW_DC_COMP_GAIN2, tmp);
							 | 
						||
| 
								 | 
							
								    *gain3 = (uint16_t)REG_FIELD_GET(SW_DC_COMP_GAIN3, tmp);
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								    (void)gain0;
							 | 
						||
| 
								 | 
							
								    (void)gain1;
							 | 
						||
| 
								 | 
							
								    (void)gain2;
							 | 
						||
| 
								 | 
							
								    (void)gain3;
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_tx_dc()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    volatile uint16_t tx_dc_gain0 = 0;
							 | 
						||
| 
								 | 
							
								    volatile uint16_t tx_dc_gain1 = 0;
							 | 
						||
| 
								 | 
							
								    volatile uint16_t tx_dc_gain2 = 0;
							 | 
						||
| 
								 | 
							
								    volatile uint16_t tx_dc_gain3 = 0;
							 | 
						||
| 
								 | 
							
								    phy_dc_comp_gain_get(&tx_dc_gain0, &tx_dc_gain1,\
							 | 
						||
| 
								 | 
							
								                         &tx_dc_gain2, &tx_dc_gain3);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[0] = tx_dc_gain0;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[1] = tx_dc_gain1;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[2] = tx_dc_gain2;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[3] = tx_dc_gain3;
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_add_dc_cal_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.dc_cal_cnt++;
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_dc_cal_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    return g_phy_ctxt.dep.phy_status.dc_cal_cnt;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t IRAM_ATTR phy_add_overstress_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.indep.ovs_ctxt.os_cnt++;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.indep.ovs_ctxt.no_ovs_cnt = 0;
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_overstress_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    return g_phy_ctxt.indep.ovs_ctxt.os_cnt;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_periodic_fc_err_num()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    return g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_fc_fail_cnt_clr;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_rxtd_reg_tx_pkt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    iot_phy_sts_info_t pkt_sts;
							 | 
						||
| 
								 | 
							
								    phy_sts_get(&pkt_sts);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_fc_ok_cnt = \
							 | 
						||
| 
								 | 
							
								        pkt_sts.fc_crc_ok_cnt;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_fc_fail_cnt = \
							 | 
						||
| 
								 | 
							
								        pkt_sts.fc_crc_fail_cnt;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_pld_ok_cnt = \
							 | 
						||
| 
								 | 
							
								        pkt_sts.pld_crc_ok_cnt;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_pld_fail_cnt = \
							 | 
						||
| 
								 | 
							
								        pkt_sts.pld_crc_fail_cnt;
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_pkt_cnt = \
							 | 
						||
| 
								 | 
							
								        pkt_sts.sync_ok_cnt;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pkt_cnt = pkt_sts.mac_tx_ok_cnt;
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_granite_reg()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    uint32_t i;
							 | 
						||
| 
								 | 
							
								    uint8_t rodata = 0;
							 | 
						||
| 
								 | 
							
								    uint32_t rdata = 0;
							 | 
						||
| 
								 | 
							
								    for(i = 0; i < 11; i++)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        phy_ana_i2c_read(i, &rdata, &rodata);
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[i] = rdata;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_txfd_reg()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt0_bd0 = \
							 | 
						||
| 
								 | 
							
								        PHY_TX_READ_REG(CFG_BB_DB_AMP_CTRL_RATE0_BAND0_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt0_bd1 = \
							 | 
						||
| 
								 | 
							
								        PHY_TX_READ_REG(CFG_BB_DB_AMP_CTRL_RATE0_BAND1_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt0_bd2 = \
							 | 
						||
| 
								 | 
							
								        PHY_TX_READ_REG(CFG_BB_DB_AMP_CTRL_RATE0_BAND2_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt1_bd0 = \
							 | 
						||
| 
								 | 
							
								        PHY_TX_READ_REG(CFG_BB_DB_AMP_CTRL_RATE1_BAND0_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt1_bd1 = \
							 | 
						||
| 
								 | 
							
								        PHY_TX_READ_REG(CFG_BB_DB_AMP_CTRL_RATE1_BAND1_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt1_bd2 = \
							 | 
						||
| 
								 | 
							
								        PHY_TX_READ_REG(CFG_BB_DB_AMP_CTRL_RATE1_BAND2_ADDR);
							 | 
						||
| 
								 | 
							
								 #endif
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_dfe_reg()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_gain_adjust_info = \
							 | 
						||
| 
								 | 
							
								        PHY_DFE_READ_REG(CFG_BB_SW_ADJUST_GAIN_ADDR);
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_version()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_mode = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_VERSION_ADDR);
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_band_cfg()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM >= HW_PLATFORM_FPGA
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_band.bb_r0_b0 = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_R0_B0_TONE_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_band.bb_r0_b1 = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_R0_B1_TONE_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_band.bb_r0_b2 = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_R0_B2_TONE_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_band.bb_r1_b0 = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_R1_B0_TONE_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_band.bb_r1_b1 = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_R1_B1_TONE_ADDR);
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_band.bb_r1_b2 = \
							 | 
						||
| 
								 | 
							
								        PHY_READ_REG(CFG_BB_R1_B2_TONE_ADDR);
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint16_t phy_set_init_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_init_cnt++;
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint16_t phy_get_init_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    return g_phy_ctxt.dep.phy_status.phy_init_cnt;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint16_t phy_set_reinit_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.phy_status.phy_reinit_cnt++;
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint16_t phy_get_reinit_cnt()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    return g_phy_ctxt.dep.phy_status.phy_reinit_cnt;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t phy_get_status()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    phy_get_rx_dc();
							 | 
						||
| 
								 | 
							
								    phy_get_tx_dc();
							 | 
						||
| 
								 | 
							
								    phy_get_dc_cal_cnt();
							 | 
						||
| 
								 | 
							
								    phy_get_overstress_cnt();
							 | 
						||
| 
								 | 
							
								    /* update by log print, share with flash log */
							 | 
						||
| 
								 | 
							
								    //phy_get_rxtd_reg_tx_pkt();
							 | 
						||
| 
								 | 
							
								    /* the same as above */
							 | 
						||
| 
								 | 
							
								    //phy_get_granite_reg();
							 | 
						||
| 
								 | 
							
								    phy_get_txfd_reg();
							 | 
						||
| 
								 | 
							
								    phy_get_dfe_reg();
							 | 
						||
| 
								 | 
							
								    phy_get_version();
							 | 
						||
| 
								 | 
							
								    phy_get_band_cfg();
							 | 
						||
| 
								 | 
							
								    return 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void phy_print_ana_dbg_info()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    uint8_t rodata = 0;
							 | 
						||
| 
								 | 
							
								    uint32_t phy_status = 0;
							 | 
						||
| 
								 | 
							
								    ana_dbg_info_t ana_data;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    phy_ana_i2c_read(CFG_ANA_TOP_REG_ADDR, &phy_status, &rodata);
							 | 
						||
| 
								 | 
							
								    ana_data.phy_status = phy_status;
							 | 
						||
| 
								 | 
							
								    ana_data.force_0 = RGF_MAC_READ_REG(CFG_PHY_FORCE_0_ADDR);
							 | 
						||
| 
								 | 
							
								    ana_data.force_1 = RGF_MAC_READ_REG(CFG_PHY_FORCE_1_ADDR);
							 | 
						||
| 
								 | 
							
								    ana_data.force_2 = RGF_MAC_READ_REG(CFG_PHY_FORCE_2_ADDR);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								        IOT_PHY_STATUS9_ID, 4,\
							 | 
						||
| 
								 | 
							
								        ana_data.force_0, \
							 | 
						||
| 
								 | 
							
								        ana_data.force_1, \
							 | 
						||
| 
								 | 
							
								        ana_data.force_2, \
							 | 
						||
| 
								 | 
							
								        ana_data.phy_status);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_printf("wait rssi timeout FORCE_0:%x,FORCE_1:%x,FORCE_2:%x,ANA_TOP:%x \n", \
							 | 
						||
| 
								 | 
							
								        ana_data.force_0, \
							 | 
						||
| 
								 | 
							
								        ana_data.force_1, \
							 | 
						||
| 
								 | 
							
								        ana_data.force_2, \
							 | 
						||
| 
								 | 
							
								        ana_data.phy_status);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void phy_get_status_printf()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    phy_get_status();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (++g_phy_period_60_min_cnt >= PHY_PERIOD_60_MIN) {
							 | 
						||
| 
								 | 
							
								        iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								            IOT_PHY_STATUS0_ID, 9,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.ppm_value,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[0],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[0],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[1],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[1],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[2],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[2],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[3],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[3]);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								            IOT_PHY_STATUS1_ID, 9,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[4],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[4],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[5],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[5],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[6],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[6],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pga[7],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.rx_dc_pgf[7],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[0]);
							 | 
						||
| 
								 | 
							
								        g_phy_period_60_min_cnt = 0;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								        IOT_PHY_STATUS2_ID, 9,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[1],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[2],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.gain_dc.tx_dc[3],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.dc_cal_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.indep.ovs_ctxt.os_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_pkt_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_fc_ok_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_fc_fail_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_pld_ok_cnt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								        IOT_PHY_STATUS3_ID, 9,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_rx_cnt.phy_rx_pld_fail_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_tx_pkt_cnt,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[0],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[1],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[2],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[3],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[4],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[5],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.granite_reg[6]);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (++g_phy_period_30_min_cnt >= PHY_PERIOD_30_MIN) {
							 | 
						||
| 
								 | 
							
								        iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								            IOT_PHY_STATUS4_ID, 9,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.granite_reg[7],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.granite_reg[8],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.granite_reg[9],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.granite_reg[10],\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.temp_res,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt0_bd0,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt0_bd1,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt0_bd2,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt1_bd0);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								            IOT_PHY_STATUS5_ID, 8,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt1_bd1,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_tx_pwr_reg.bb_rt1_bd2,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_band.bb_r0_b0,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_band.bb_r0_b1,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_band.bb_r0_b2,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_band.bb_r1_b0,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_band.bb_r1_b1,\
							 | 
						||
| 
								 | 
							
								            g_phy_ctxt.dep.phy_status.phy_band.bb_r1_b2);
							 | 
						||
| 
								 | 
							
								        g_phy_period_30_min_cnt = 0;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								        IOT_PHY_STATUS6_ID, 5,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_gain_adjust_info,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.phy_mode, \
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[9],\
							 | 
						||
| 
								 | 
							
								        phy_get_init_cnt(),\
							 | 
						||
| 
								 | 
							
								        phy_get_reinit_cnt());
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								        IOT_PHY_STATUS7_ID, 9,\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[0],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[1],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[2],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[3],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[4],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[5],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[6],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[7],\
							 | 
						||
| 
								 | 
							
								        g_phy_ctxt.dep.phy_status.spur_array[8]);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    iot_dbglog_input(PLC_PHY_STATUS_MID, DBGLOG_ERR,
							 | 
						||
| 
								 | 
							
								        IOT_PHY_STATUS8_ID, 7,\
							 | 
						||
| 
								 | 
							
								        g_phy_cpu_share_ctxt.nf_192p,\
							 | 
						||
| 
								 | 
							
								        g_phy_cpu_share_ctxt.nf_384p,\
							 | 
						||
| 
								 | 
							
								        g_phy_cpu_share_ctxt.nf_768p,\
							 | 
						||
| 
								 | 
							
								        g_phy_cpu_share_ctxt.nf_1536p,\
							 | 
						||
| 
								 | 
							
								        g_phy_cpu_share_ctxt.nf_3072p,\
							 | 
						||
| 
								 | 
							
								        g_phy_cpu_share_ctxt.nf_6144p,\
							 | 
						||
| 
								 | 
							
								        phy_spike_shift_en_get());
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void phy_get_status_printf_force()
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    g_phy_period_30_min_cnt = PHY_PERIOD_30_MIN - 1;
							 | 
						||
| 
								 | 
							
								    g_phy_period_60_min_cnt = PHY_PERIOD_60_MIN - 1;
							 | 
						||
| 
								 | 
							
								    phy_get_status_printf();
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void phy_dump_busy_set(bool_t en)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    g_phy_ctxt.dep.dump_busy = en;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								bool_t phy_busy_get(void *phy_ctxt, PHY_BUSY_ID id)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    if (id == PHY_BUSY_TX) {
							 | 
						||
| 
								 | 
							
								        /* dump busy must not tx, and maybe incude other reason. */
							 | 
						||
| 
								 | 
							
								        return ((phy_ctxt_t *)phy_ctxt)->dep.dump_busy;
							 | 
						||
| 
								 | 
							
								    } else if(id == PHY_BUSY_DUMP) {
							 | 
						||
| 
								 | 
							
								        return ((phy_ctxt_t *)phy_ctxt)->dep.dump_busy;
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        return false;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 |