/*********************************************************************
 *
 *        Filename:  hw_cpri.h
 *
 *         Created:  2022-05-5 05:20:34 PM
 *   Last Modified:  2022-05-5 05:20:34 PM
 *          Author:  xinxin.li
 *    Organization:  Beijing Smart Logic Technology Co., Ltd.
 *
 *     Description:
 *
 *
 ********************************************************************/


#ifndef __HW_CPRI_H__
#define __HW_CPRI_H__

#include "typedef.h"

typedef struct _tagCpriPara
{
	uint32_t option_num;
	uint32_t core_clk;
	uint32_t pcs_core_clk;
	uint32_t cpu_clk;
	uint32_t gmii_tx_rx_clk;
	uint32_t pcs_fine_delay_clk;
	uint32_t pcs_serdes_clk;
	uint32_t serdes_data_width;
	uint32_t cpri_rate_coff;
	uint32_t line_rate;
	uint32_t valid_line_rate;
	uint32_t encode_flag;				// 0:8B/10B; 1:64B/66B
	uint32_t rs_fec_flag;             // RS-FEC
	uint32_t len_word;
	uint32_t len_ctrl_word;
	uint32_t aux_cnt_pos_max;
}stCpriPara;

typedef struct _tagCpriIntStat
{
	int32_t cpriIntCnt;
	
	int32_t rxRfpIntCnt;
	int32_t txRfpIntCnt;
	
	int32_t alarmIntCnt;
	
	int32_t ddrFifoIntCnt;
	int32_t rxFifoIntCnt;
	int32_t l1ResetIntCnt;
	int32_t lofIntCnt;
	int32_t syncIntCnt;
	
	int32_t gmacIntCnt;

	uint32_t cpriSyncFlag;
	
	//uint32_t gScrRxRfpValL;
	//uint32_t gScrRxRfpValH;
}stCpriIntStat;

typedef struct
{
	uint32_t cmd32l;
	uint32_t cmd14h;
}stCpriCsuCmd;

typedef struct
{
	uint32_t cmd_num;
	stCpriCsuCmd cmd[10];
}stCpriCsuCmdFifo;

typedef struct
{
	uint32_t cmdFifo_num;
	stCpriCsuCmdFifo cmdFifo[8];
}stCpriCsuCmdFifoInfo;


void cpri_init(uint32_t option,uint32_t MappingMode);

void cpri_ecprimode_init();

// cpri参数初始化
void cpri_para_init(uint32_t option);

void cpri_int_init(void);

void isr_cpri_int(void);

void isr_gmac_int(void);

void HeaderTxRam_init();

#endif

