203 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			203 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/****************************************************************************
 | 
						|
 | 
						|
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.
 | 
						|
 | 
						|
****************************************************************************/
 | 
						|
#ifndef PHY_MULTI_PPM_H
 | 
						|
#define PHY_MULTI_PPM_H
 | 
						|
 | 
						|
#include "os_types.h"
 | 
						|
#include "phy_ppm.h"
 | 
						|
#include "hw_war.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* max cco cnt enable sync */
 | 
						|
#define MAX_SYNC_CCO_CNT                   (PHY_SW_NN_PPM_PARA_MAX)
 | 
						|
 | 
						|
#define RECORD_PPM_INVALID_NID              0
 | 
						|
#define RECORD_PPM_INVALID_PPM              1
 | 
						|
#define RECORD_PPM_VALID                    2
 | 
						|
 | 
						|
#pragma pack(push)
 | 
						|
#pragma pack(1)
 | 
						|
 | 
						|
/* status struct:
 | 
						|
 * used for cpu1's WAR to apply the ppm, it
 | 
						|
 * stores the result of ppm calculation
 | 
						|
 */
 | 
						|
typedef struct _phy_ppm_status {
 | 
						|
    /* ntb ppm err, unit: 1/64 ppm */
 | 
						|
    int16_t ppm_err;
 | 
						|
    uint32_t nid  :  24,
 | 
						|
             valid : 2,
 | 
						|
             rsv   : 6;
 | 
						|
} phy_ppm_status;
 | 
						|
 | 
						|
typedef struct _phy_ppm_status_ctxt{
 | 
						|
    uint8_t enable;
 | 
						|
    phy_ppm_status ppm_status[MAX_SYNC_CCO_CNT];
 | 
						|
} phy_ppm_status_ctxt_t;
 | 
						|
 | 
						|
#pragma pack(pop)
 | 
						|
 | 
						|
#if ENA_SYNC_DIFF_CCO_PPM
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_set_valid_flag          set flag
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@param idx                                    array idx
 | 
						|
 *@param flag                                   flag to set
 | 
						|
 *@exception                                    none
 | 
						|
 *@return                                       none
 | 
						|
*/
 | 
						|
void phy_multi_sync_set_valid_flag(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint8_t idx, uint8_t valid);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_get_record_nid          get nid by idx
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@param idx                                    array idx
 | 
						|
 *@exception                                    none
 | 
						|
 *@return uint32_t                              nid;
 | 
						|
*/
 | 
						|
uint32_t phy_multi_sync_get_record_nid(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint8_t idx);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_set_record_nid          set nid
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@param idx                                    array idx
 | 
						|
 *@param nid                                    nid to set
 | 
						|
 *@exception                                    none
 | 
						|
 *@return                                       none
 | 
						|
*/
 | 
						|
void phy_multi_sync_set_record_nid(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint8_t idx, uint32_t nid);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_set_record_ppm          set ppm
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@param idx                                    array idx
 | 
						|
 *@param ppm                                    ppm to set
 | 
						|
 *@exception                                    none
 | 
						|
 *@return                                       none
 | 
						|
*/
 | 
						|
void phy_multi_sync_set_record_ppm(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint8_t idx, int16_t ppm);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_get_record_ppm          get ppm
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@exception                                    none
 | 
						|
 *@return                                       ppm
 | 
						|
*/
 | 
						|
int16_t phy_multi_sync_get_record_ppm(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint8_t idx);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_apply_bb_ppm            find nid and sync ppm
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@param update_flag                            see BB_PPM_UPDATE_METHORD
 | 
						|
 *@param cur_nid                                cur rx fc nid
 | 
						|
 *@exception                                    none
 | 
						|
 *@return                                       none
 | 
						|
 */
 | 
						|
void phy_multi_sync_apply_bb_ppm(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint32_t cur_nid, uint8_t update_flag);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_get_ppm_status
 | 
						|
 *@return status_ptr
 | 
						|
 */
 | 
						|
void* phy_multi_sync_get_ppm_status();
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief  phy_multi_sync_get_record_idx          get record idx
 | 
						|
 *@param  ctxt                                   ctxt ptr
 | 
						|
 *@param  cur_nid                                cur multi sync record nid
 | 
						|
 *@return idx
 | 
						|
 */
 | 
						|
uint8_t phy_multi_sync_get_record_idx(phy_ppm_status_ctxt_t *ctxt, \
 | 
						|
    uint32_t cur_nid);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief  phy_multi_sync_set_enable              set function enabale or not
 | 
						|
 *@param  ctxt                                   ctxt ptr
 | 
						|
 *@param  enable                                 0 - disable, 1 - enable
 | 
						|
 *@return none
 | 
						|
 */
 | 
						|
void phy_multi_sync_set_enable(phy_ppm_status_ctxt_t *ctxt, uint8_t enable);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief phy_multi_sync_ppm_rst                 rst rx ppm
 | 
						|
 *@param ctxt                                   ctxt ptr
 | 
						|
 *@exception                                    none
 | 
						|
 *@return                                       none
 | 
						|
*/
 | 
						|
void phy_multi_sync_ppm_rst(phy_ppm_status_ctxt_t *ctxt);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief  phy_multi_sync_get_valid_flag          get record flag
 | 
						|
 *@param  ctxt                                   ctxt ptr
 | 
						|
 *@param  idx                                    array idx
 | 
						|
 *@exception                                     none
 | 
						|
 *@return                                        none
 | 
						|
 */
 | 
						|
uint32_t phy_multi_sync_get_valid_flag(phy_ppm_status_ctxt_t *ctxt,
 | 
						|
    uint8_t idx);
 | 
						|
 | 
						|
/**
 | 
						|
 *@brief  phy_multi_sync_set_ppm                 set multi ppm
 | 
						|
 *@param  status_ctxt                            ctxt ptr
 | 
						|
 *@param  nid                                    nid
 | 
						|
 *@exception                                     none
 | 
						|
 *@return                                        0/1
 | 
						|
 */
 | 
						|
uint32_t phy_multi_sync_set_ppm(phy_ppm_status_ctxt_t *status_ctxt, uint32_t nid);
 | 
						|
 | 
						|
#else /* ENA_SYNC_DIFF_CCO_PPM */
 | 
						|
 | 
						|
#define phy_multi_sync_set_valid_flag(ctxt, idx, valid)
 | 
						|
 | 
						|
#define phy_multi_sync_get_record_nid(ctxt, idx)        (PLC_NID_INVALID)
 | 
						|
 | 
						|
#define phy_multi_sync_set_record_nid(ctxt, idx, nid)
 | 
						|
 | 
						|
#define phy_multi_sync_set_record_ppm(ctxt, idx, ppm)
 | 
						|
 | 
						|
#define phy_multi_sync_get_record_ppm(ctxt, idx)        (PLC_MAX_MAC_NTB_PPM)
 | 
						|
 | 
						|
#define phy_multi_sync_apply_bb_ppm(ctxt, cur_nid, update_flag)
 | 
						|
 | 
						|
#define phy_multi_sync_get_ppm_status()                 (NULL)
 | 
						|
 | 
						|
#define phy_multi_sync_get_record_idx(ctxt, cur_nid)    (MAX_SYNC_CCO_CNT)
 | 
						|
 | 
						|
#define phy_multi_sync_set_enable(ctxt, enable)
 | 
						|
 | 
						|
#define phy_multi_sync_ppm_rst(ctxt)
 | 
						|
 | 
						|
#define phy_multi_sync_get_valid_flag(ctxt, idx)        (RECORD_PPM_INVALID_NID)
 | 
						|
 | 
						|
#define phy_multi_sync_set_ppm(status_ctxt, nid)        (ERR_INVAL)
 | 
						|
 | 
						|
#endif /* ENA_SYNC_DIFF_CCO_PPM */
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif
 |