/*
 * cpri_dri_config.c
 *
 *  Created on: Apr 27, 2017
 *      Author: badal.nilawar
 */

#include <stdio.h>
#include "sample_hw_platform.h"


/*==============================================================================
 * CIPRI REGS
 */

#define HSLPBKEN 0

#define CPRI_BASE_ADDR	0x70000000

#define CPRI_CNTRL_REG 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x0)
#define TX_SEQ_NUM 		(volatile uint32_t *)(CPRI_BASE_ADDR + 0x4)
#define RX_SEQ_NUM 		(volatile uint32_t *)(CPRI_BASE_ADDR + 0x8)
#define TX_K28_5_CHR 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0xC)
#define RX_K28_5_CHR 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x10)
#define TX_D16_2_CHR 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x14)
#define RX_D16_2_CHR 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x18)
#define TX_Z_0_Y_CHR 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x1C)
#define RX_Z_0_Y_CHR 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x20)
#define TX_Z_2_0_VRN 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x24)
#define TX_Z_194_0 		(volatile uint32_t *)(CPRI_BASE_ADDR + 0x2C)
#define RX_Z_194_0_CFG 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x30)
#define CPRI_IQ_SWAP 	(volatile uint32_t *)(CPRI_BASE_ADDR + 0x40)
#define Startup_timer   (volatile uint32_t *)(CPRI_BASE_ADDR + 0x100)
#define HFN_COUNT       (volatile uint32_t *)(CPRI_BASE_ADDR + 0x104)
#define IFB_FRAME       (volatile uint32_t *)(CPRI_BASE_ADDR + 0x200)
#define IFB_FRAME_CNT   (volatile uint32_t *)(CPRI_BASE_ADDR + 0x204)
#define ETH_DEPTH       (volatile uint32_t *)(CPRI_BASE_ADDR + 0x208)
#define CPRI_STATUS_REG (volatile uint32_t *)(CPRI_BASE_ADDR + 0x31C)
#define CPRI_SEQ_STATUS_REG (volatile uint32_t *)(CPRI_BASE_ADDR + 0x320)
#define Z_194_0_RCVD_STATUS (volatile uint32_t *)(CPRI_BASE_ADDR + 0x324)
#define PATTERN_TYPE (volatile uint32_t *)(CPRI_BASE_ADDR + 0x38)
#define LOCK (volatile uint32_t *)(CPRI_BASE_ADDR + 0x328)


//CPRI Registers READ Parameters
uint32_t RD_TX_SEQ_NUM;
uint32_t RD_RX_SEQ_NUM;
uint32_t RD_TX_K28_5_CHR;
uint32_t RD_RX_K28_5_CHR;
uint32_t RD_TX_D16_2_CHR;
uint32_t RD_RX_D16_2_CHR;
uint32_t RD_TX_Z_0_Y_CHR;
uint32_t RD_RX_Z_0_Y_CHR;
uint32_t RD_TX_Z_2_0_VRN;
uint32_t RD_RX_Z_2_0_VRN;
uint32_t RD_TX_Z_194_0;
uint32_t RD_RX_Z_194_0;
uint32_t RD_Startup_timer;
uint32_t RD_HFN_COUNT;
uint32_t RD_IFB_FRAME;
uint32_t RD_IFB_FRAME_CNT;
uint32_t RD_ETH_DEPTH;
uint32_t RD_CPRI_CNTRL_REG;
uint32_t RD_CPRI_STATUS_REG;
uint32_t RD_CPRI_SEQ_STATUS_REG;
uint32_t RD_Z_194_0_RCVD_STATUS;
uint32_t RD_LOCK_STATUS;

void CPRI_Config()
{
	/* ---CPRI Register Description--- */
	*CPRI_IQ_SWAP = 0x03;
	/* ---TX Sequence Number Register--- */
	*TX_SEQ_NUM =  0x1f;
	RD_TX_SEQ_NUM = *TX_SEQ_NUM;

	/* ---RX Sequence Number Register--- */
	*RX_SEQ_NUM =  0x1f;
	RD_RX_SEQ_NUM = *RX_SEQ_NUM;

	/* ---TX K28_5 Character Register--- */
	*TX_K28_5_CHR =  0xBC;
	RD_TX_K28_5_CHR = *TX_K28_5_CHR;

	/* ---RX K28_5 Character Register--- */
	*RX_K28_5_CHR =  0xBC;
	RD_RX_K28_5_CHR = *RX_K28_5_CHR;

	/* ---TX_Z_0_1 Register--- */
	*TX_D16_2_CHR =  0x50;
	RD_TX_D16_2_CHR = *TX_D16_2_CHR;

	/* ---RX_Z_0_1 Register--- */
	*RX_D16_2_CHR =  0x50;
	RD_RX_D16_2_CHR = *RX_D16_2_CHR;

	/* ---TX_Z_0_Y Register--- */
	*TX_Z_0_Y_CHR =  0x50;
	RD_TX_Z_0_Y_CHR = *TX_Z_0_Y_CHR;

	/* ---RX_Z_0_Y Register--- */
	*RX_Z_0_Y_CHR =  0x50;
	RD_RX_Z_0_Y_CHR = *RX_Z_0_Y_CHR;

	/* ---TX_Z_2_0_VRN Register--- */
	*TX_Z_2_0_VRN =  0x1;
	RD_TX_Z_2_0_VRN = *TX_Z_2_0_VRN;

	/* ---RX_Z_2_0_VRN Register--- */
	//	*RX_Z_2_0_VRN =  0x50;
	//	RD_RX_Z_2_0_VRN = *RX_Z_2_0_VRN;

	/* ---TX_Z_194_0 Register--- */
	*TX_Z_194_0 =  0x14;
	RD_TX_Z_194_0 = *TX_Z_194_0;

	/* ---RX_Z_194_0 Register--- */
	*RX_Z_194_0_CFG =  0x14;
	RD_RX_Z_194_0 = *RX_Z_194_0_CFG;

	/* ---Startup_TIMER Register--- */
	*Startup_timer =  0x1000000;
	RD_Startup_timer = *Startup_timer;

	/* ---HFN_COUNT TIMER Register--- */
	*HFN_COUNT =   0x1fff;   // 0xfff; Rate3
	RD_HFN_COUNT = *HFN_COUNT;

	/* ---IFB_Frame TIMER Register--- */
	*IFB_FRAME =  0x1F;
	RD_IFB_FRAME = *IFB_FRAME;

	/* ---IFB_Frame COUNT Register--- */
	*IFB_FRAME_CNT =  0xC;
	RD_IFB_FRAME_CNT = *IFB_FRAME_CNT;

	/* ---Ethernet Depth Register--- */
	*ETH_DEPTH =  0x100;
	RD_ETH_DEPTH = *ETH_DEPTH;

	*PATTERN_TYPE = 0x3;

	/* ---CPRI Control Register--- */
//	*CPRI_CNTRL_REG =  0x1; //cpri_en_register
//	RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;
//	RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;
//	RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;

//	/* ---CPRI Control Register--- */
//	*CPRI_CNTRL_REG =  0x3; //IQ_demapper_en, L1_sync_en, cpri_en_register
//	RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;


	/* ---CPRI Control Register--- */
//	*CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
//	RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;
//
//	/* ---CPRI Control Register--- */
//	*CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
//	RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;

	/* ---CPRI Control Register--- */
	  *CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
//	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
//
//	/* ---CPRI Control Register--- */
//	  *CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
//	RD_CPRI_SEQ_STATUS_REG = *CPRI_SEQ_STATUS_REG;
}

/* This function is only for debugging purpose */
void CPRI_Read_Regs()
{
	/* ---CPRI Control Register--- */
	 // *CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
//	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
//	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
//	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
		/* ---CPRI Control Register--- */
//		*CPRI_CNTRL_REG =  0x3; //IQ_demapper_en, L1_sync_en, cpri_en_register
//		RD_CPRI_CNTRL_REG = *CPRI_CNTRL_REG;



	/* ---CPRI Control Register--- */
	  *CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;


	/* ---CPRI Control Register--- */
	//  *CPRI_CNTRL_REG =  0xf; //IQ_demapper_en, IQ_mapper_en, L1_sync_en, cpri_en_register
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_Z_194_0_RCVD_STATUS = *Z_194_0_RCVD_STATUS;
	RD_CPRI_SEQ_STATUS_REG = *CPRI_SEQ_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_Z_194_0_RCVD_STATUS = *Z_194_0_RCVD_STATUS;
	RD_CPRI_SEQ_STATUS_REG = *CPRI_SEQ_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
	RD_Z_194_0_RCVD_STATUS = *Z_194_0_RCVD_STATUS;
	RD_CPRI_SEQ_STATUS_REG = *CPRI_SEQ_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
	RD_Z_194_0_RCVD_STATUS = *Z_194_0_RCVD_STATUS;
	RD_CPRI_SEQ_STATUS_REG = *CPRI_SEQ_STATUS_REG;
	RD_CPRI_STATUS_REG = *CPRI_STATUS_REG;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
	RD_Z_194_0_RCVD_STATUS = *Z_194_0_RCVD_STATUS;
	RD_CPRI_SEQ_STATUS_REG = *CPRI_SEQ_STATUS_REG;
	RD_Z_194_0_RCVD_STATUS = *Z_194_0_RCVD_STATUS;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
	RD_LOCK_STATUS = *LOCK;
}

void DRI_Config()
{
	//------------------------------------------------------------------//
	//------Dynamic Configuration of XCVR Registers for QUAD2 LANE1-----//
	//-----------------------------------------------------------------//
			uint32_t read_data;
			uint32_t *fapb_cpri = (uint32_t *)0x80000000; // Base address for DRI
#if 0
			//TX PATH
			//TXPLL_CLKBUF
			printf ("\n");
			printf ("TXPLL_CLKBUF\r\n");
			fapb_cpri = (uint32_t *)0x81110004;
			//read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			//printf ("Writing 000000FF\r\n");
			*fapb_cpri = 0x000000FF; //Write Data
			//read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//TXPLL_CLOCK_SELECT
			printf ("\n");
			printf ("TXPLL_CLOCK_SELECT\r\n");
			fapb_cpri = (uint32_t *)0x8111000C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 01FFE380\r\n");
			*fapb_cpri = 0x01FFE380 ; //Write Data  // JA Enabled 0x1803A000
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//TXPLL_CTRL
			printf ("\n");
			printf ("TXPLL_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x81110008;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 007E0010\r\n");
			*fapb_cpri = 0x007E0010 ; //Write Data    // JA Enabled  0x007E000D
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//TXPLL_DIV_1
			printf ("\n");
			printf ("TXPLL_DIV_1\r\n");
			fapb_cpri = (uint32_t *)0x81110010;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 0280000\r\n");
			*fapb_cpri =0x0280000; //Write Data  // JA Enabled  0x028000A
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//TXPLL_DIV_2
			printf ("\n");
			printf ("TXPLL_DIV_2\r\n");
			fapb_cpri = (uint32_t *)0x81110014;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 2000000\r\n");
			*fapb_cpri = 0x2000000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//SER_CLK_CTRL
			printf ("\n");
			printf ("SER_CLK_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F074;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 0000071\r\n");
			*fapb_cpri = 0x0000071; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//DES_RXPLL_DIV
			printf ("\n");
			printf ("DES_RXPLL_DIV\r\n");
			fapb_cpri = (uint32_t *)0x8110F040;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 0002214\r\n");
			*fapb_cpri = 0x0002214; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//SERIALIZERA_RESETPD
			printf ("\n");
			printf ("SERIALIZERA_RESETPD\r\n");
			fapb_cpri = (uint32_t *)0x8110F078;
			//read_data = *fapb_cpri;
			//printf ("Read Value:%x\r\n",read_data);
			//printf ("Writing 00000003\r\n");
			*fapb_cpri = 0x00000003; //Write Data
			//read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//-------------------------//
			//TXPLL_CTRL
			printf ("\n");
			printf ("TXPLL_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x81110008;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00080010\r\n");
			*fapb_cpri =0x00080010 ; //Write Data    // JA Enabled  0x0000000D
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//TXPLL_CTRL
			//printf ("\n");
		//	printf ("TXPLL_CTRL\r\n");
		//	fapb_cpri = (uint32_t *)0x81090008;
		//	read_data = *fapb_cpri;
		//printf ("Read Value:%x\r\n",read_data);
			//Monitor TXPLL LOCK
		        /*while (1)
		        {
		          if ( ((read_data) & (0x01000000)) != 0)
		          {
		                  printf("TXPLL LOCKED \r\n");
		                  break;
		          }
		          else
		                  printf("TXPLL NOT LOCKED\n");
		          read_data = *fapb_cpri;
		          printf ("Read Value:%x\r\n",read_data);
		        }
*/
			//SERIALIZERA_RESETPD
			printf ("\n");
			printf ("SERIALIZERA_RESETPD\r\n");
			fapb_cpri = (uint32_t *)0x8110F078;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000001\r\n");
			*fapb_cpri = 0x00000001; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//SERIALIZER_RTL_CTRL
			printf ("\n");
			printf ("SERIALIZER_RTL_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F0C0;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000000\r\n");
			*fapb_cpri = 0x00000000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

		//End TX PATH

		//RX PATH

			//DESERIALIZERA_CLOCK_CONTROL
			printf ("\n");
			printf ("DESERIALIZERA_CLOCK_CONTROL\r\n");
			fapb_cpri = (uint32_t *)0x8110F048;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 0000003C\r\n");
			*fapb_cpri = 0x0000003C; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//DES_PKDET
			printf ("\n");
			printf ("DES_PKDET\r\n");
			fapb_cpri = (uint32_t *)0x8110F034;
			read_data = *fapb_cpri;
			printf ("Writing 0000005D\r\n");
			*fapb_cpri = 0x0000005D; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//DESERIALIZER_RESETPD
			printf ("\n");
			printf ("DESERIALIZER_RESETPD\r\n");
			fapb_cpri = (uint32_t *)0x8111F04C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000032\r\n");
			*fapb_cpri = 0x00000032; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);



		//End RX PATH

		//Additional registers

			//LOVR_R0
			printf ("\n");
			printf ("LOVR_R0\r\n");
			fapb_cpri = (uint32_t *)0x8010F008;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000044\r\n");
			*fapb_cpri = 0x00000044; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//MAJOR
			printf ("\n");
			printf ("MAJOR\r\n");
			fapb_cpri = (uint32_t *)0x82050008;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 0000000A\r\n");
			*fapb_cpri = 0x0000000A; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//LPIP_R0
			printf ("\n");
			printf ("LPIP_R0\r\n");
			fapb_cpri = (uint32_t *)0x8010F00C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000000\r\n");
			*fapb_cpri = 0x00000000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//L8_R0
			printf ("\n");
			printf ("L8_R0\r\n");
			fapb_cpri = (uint32_t *)0x8010F040;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000000\r\n");
			*fapb_cpri = 0x00000000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//LCLK_R0
			printf ("\n");
			printf ("LCLK_R0\r\n");
			fapb_cpri = (uint32_t *)0x8010F058;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00051F11\r\n");
			*fapb_cpri = 0x00051F11; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//LCLK_R1
			printf ("\n");
			printf ("LCLK_R1\r\n");
			fapb_cpri = (uint32_t *)0x8010F05C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000F00\r\n");
			*fapb_cpri = 0x00000F00; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//LCLK_RST
			printf ("\n");
			printf ("LCLK_RST\r\n");
			fapb_cpri = (uint32_t *)0x8010F068;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000001\r\n");
			*fapb_cpri = 0x00000D0D; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000004\r\n");
			*fapb_cpri = 0x00000404; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//LCLK_OPT
				printf ("\n");
				printf ("LCLK_OPT\r\n");
				fapb_cpri = (uint32_t *)0x8010F06C;
				read_data = *fapb_cpri;
				printf ("Read Value:%x\r\n",read_data);
				printf ("Writing 00000002\r\n");
				*fapb_cpri = 0x00000002; //Write Data
				read_data = *fapb_cpri;
				printf ("Read Value:%x\r\n",read_data);

			//GSSCLK_CTRL
			printf ("\n");
			printf ("GSSCLK_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x80110004;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
		//	printf ("Writing 00000909\r\n");
			*fapb_cpri = 0x00000909; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//QRST_R0
					printf ("\n");
					printf ("QRST_R0\r\n");
					fapb_cpri = (uint32_t *)0x82110008;
					read_data = *fapb_cpri;
					printf ("Read Value:%x\r\n",read_data);
				//	printf ("Writing 0000000A\r\n");
					*fapb_cpri = 0x0000000A; //Write Data
					read_data = *fapb_cpri;
					printf ("Read Value:%x\r\n",read_data);

		//Additional
			//Releasing soft resets
			printf ("\n");
			printf ("SR1 PCIESS Main\r\n");
			fapb_cpri = (uint32_t *)0x82110000;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
		//	printf ("Writing 00000000\r\n");
			*fapb_cpri = 0x00000000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			printf ("\n");
			printf ("SR2 PMA LANE\r\n");
			fapb_cpri = (uint32_t *)0x81110000;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
		//	printf ("Writing 01040000\r\n");
			*fapb_cpri = 0x01040000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			printf ("\n");
			printf ("SR3 PCS CMN\r\n");
			fapb_cpri = (uint32_t *)0x80110000;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
		//	printf ("Writing 00140000\r\n");
			*fapb_cpri = 0x00140000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


		//Drive settings
			//SER_DRV_CTRL
			printf ("\n");
			printf ("SER_DRV_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F09C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 07FFFFFF\r\n");
			*fapb_cpri = 0x07FFFFFF; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//SER_DRV_DATA_CTRL
			printf ("\n");
			printf ("SER_DRV_DATA_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F098;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000000\r\n");
			*fapb_cpri = 0x00000000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

		//Yoons and Barrys suggestion:

			//DES_IN_TERM
			printf ("\n");
			printf ("DES_IN_TERM\r\n");
			fapb_cpri = (uint32_t *)0x8110F030;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 000000F7\r\n");
			*fapb_cpri = 0x000000F7; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//DES_RTL_LOCK_CTRL
			printf ("\n");
			printf ("DES_RTL_LOCK_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F03C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000008\r\n");
			*fapb_cpri = 0x00000008; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//SER_TERM_CTRL
			printf ("\n");
			printf ("SER_TERM_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F090;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00007700\r\n");
			*fapb_cpri = 0x00007700; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//SER_CTRL
			printf ("\n");
			printf ("SER_CTRL\r\n");
			fapb_cpri = (uint32_t *)0x8110F070;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000001\r\n");
		        if (HSLPBKEN == 1)
		          *fapb_cpri = 0x00000801; //Write Data
		        else
		          *fapb_cpri = 0x00000001; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//SER_DRV_CTRL_SEL
			printf ("\n");
			printf ("SER_DRV_CTRL_SEL\r\n");
			fapb_cpri = (uint32_t *)0x8110F0A0;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000001\r\n");
			*fapb_cpri = 0x00000001; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


		//More additional settings
			//DES_CDR_CTRL_3
			printf ("\n");
			printf ("DES_CDR_CTRL_3\r\n");
			fapb_cpri = (uint32_t *)0x8110F00C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00040100\r\n");
			*fapb_cpri = 0x00040100; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


			//DES_DFE_CAL_BYPASS
			printf ("\n");
			printf ("DES_DFE_CAL_BYPASS\r\n");
			fapb_cpri = (uint32_t *)0x8110F0E0;
			read_data = *fapb_cpri;
		//	printf ("Read Value:%x\r\n",read_data);
		//	printf ("Writing 00200000\r\n");
			*fapb_cpri = 0x00200000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//DES_DFE_CAL_CTRL_0
			printf ("\n");
			printf ("DES_DFE_CAL_CTRL_0\r\n");
			fapb_cpri = (uint32_t *)0x8110F0D0;
		//	read_data = *fapb_cpri;
		//	printf ("Read Value:%x\r\n",read_data);
		//	printf ("Writing 64100716\r\n");
			*fapb_cpri = 0x64100716; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//OVRLY
			printf ("\n");
			printf ("OVRLY\r\n");
			fapb_cpri = (uint32_t *)0x8110F0E0;
			//read_data = *fapb_cpri;
			//printf ("Read Value:%x\r\n",read_data);
			//printf ("Writing 00000202\r\n");
			*fapb_cpri = 0x00200000; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);

			//DESERIALIZER_RESETPD
			printf ("\n");
			printf ("DESERIALIZER_RESETPD\r\n");
			fapb_cpri = (uint32_t *)0x8110F04C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
			printf ("Writing 00000010\r\n");
			*fapb_cpri = 0x00000010; //Write Data
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);


		        //DES_RTL_LOCK_CTRL
			printf ("\n");
			fapb_cpri = (uint32_t *)0x8110F03C;
			read_data = *fapb_cpri;
			printf ("Read Value:%x\r\n",read_data);
#endif

#if 0
			//TX PATH
						//TXPLL_CLKBUF
						printf ("\n");
						printf ("TXPLL_CLKBUF\r\n");
						fapb_cpri = (uint32_t *)0x81110004;
						printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 000000FF\r\n");
						*fapb_cpri = 0x000000FF; //Write Data
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_CLOCK_SELECT
						printf ("\n");
						printf ("TXPLL_CLOCK_SELECT\r\n");
						fapb_cpri = (uint32_t *)0x8111000C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 01FFE380\r\n");
						*fapb_cpri =0x3003A000; //Write Data  // JA Enabled     0x01FFE380 0x1803A000
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_CTRL
						printf ("\n");
						printf ("TXPLL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 007E0010\r\n");
						*fapb_cpri =  0x007E0010; //Write Data    // JA Enabled      0x007E0010
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_CTRL
						printf ("\n");
						printf ("TXPLL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 007E0010\r\n");
						*fapb_cpri =  0x00000010; //Write Data    // JA Enabled      0x007E0010
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_DIV_1
						printf ("\n");
						printf ("TXPLL_DIV_1\r\n");
						fapb_cpri = (uint32_t *)0x81110010;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0280000\r\n");
						*fapb_cpri = 0x0280014; //Write Data  // JA Enabled      0x0280000
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_DIV_2
						printf ("\n");
						printf ("TXPLL_DIV_2\r\n");
						fapb_cpri = (uint32_t *)0x81110014;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 2000000\r\n");
						*fapb_cpri = 0x2000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_CLK_CTRL
						printf ("\n");
						printf ("SER_CLK_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F074;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0000071\r\n");
						*fapb_cpri = 0x0000071 ; //Write Data  // JA Enabled     0x0000071
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_RXPLL_DIV
						printf ("\n");
						printf ("DES_RXPLL_DIV\r\n");
						fapb_cpri = (uint32_t *)0x8110F040;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0002214\r\n");
						*fapb_cpri = 0x0002214; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F078;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000003\r\n");
						*fapb_cpri = 0x00000003; //Write Data
						//read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						// JA Registers
							//TXPLL_JA_RST
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110040;
							*fapb_cpri = 0xFFFFFFFF; //Write Data   //JA Reset
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
						    //TXPLL_JA_1
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110018;
							*fapb_cpri = 0x00F8007C; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_2
							printf ("\n");
							fapb_cpri = (uint32_t *)0x8111001C;
							*fapb_cpri = 0x000007D0; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_3
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110020;
							*fapb_cpri = 0x000503E8; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_4
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110024;
							*fapb_cpri = 0x08B50019; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_5
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110028;
							*fapb_cpri = 0x1DDEBE9; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_6
							printf ("\n");
							fapb_cpri = (uint32_t *)0x8111002C;
							*fapb_cpri = 0x1E0007; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							//TXPLL_JA_7
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110030;
							*fapb_cpri = 0x73B6C1C; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_8
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110034;
							*fapb_cpri = 0x00000000; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_9
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110038;
							*fapb_cpri = 0x0028; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_10
							printf ("\n");
							fapb_cpri = (uint32_t *)0x8111003C;
							*fapb_cpri = 0x00000000; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_RST
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110040;
							*fapb_cpri = 0x00000000; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_9
							fapb_cpri = (uint32_t *)0x81110038;
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_10
							fapb_cpri = (uint32_t *)0x8111003C;
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);


						//TXPLL_CTRL
						//printf ("\n");
					//	printf ("TXPLL_CTRL\r\n");
					//	fapb_cpri = (uint32_t *)0x81090008;
					//	read_data = *fapb_cpri;
					//printf ("Read Value:%x\r\n",read_data);
						//Monitor TXPLL LOCK
					        /*while (1)
					        {
					          if ( ((read_data) & (0x01000000)) != 0)
					          {
					                  printf("TXPLL LOCKED \r\n");
					                  break;
					          }
					          else
					                  printf("TXPLL NOT LOCKED\n");
					          read_data = *fapb_cpri;
					          printf ("Read Value:%x\r\n",read_data);
					        }
			*/
						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F078;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
						*fapb_cpri = 0x00000001; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SERIALIZER_RTL_CTRL
						printf ("\n");
						printf ("SERIALIZER_RTL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F0C0;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

					//End TX PATH

					//RX PATH

						//DESERIALIZERA_CLOCK_CONTROL
						printf ("\n");
						printf ("DESERIALIZERA_CLOCK_CONTROL\r\n");
						fapb_cpri = (uint32_t *)0x8110F048;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0000003C\r\n");
						*fapb_cpri = 0x0000003C; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_PKDET
						printf ("\n");
						printf ("DES_PKDET\r\n");
						fapb_cpri = (uint32_t *)0x8110F034;
						read_data = *fapb_cpri;
						printf ("Writing 0000005D\r\n");
						*fapb_cpri = 0x0000005D; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F04C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000032\r\n");
						*fapb_cpri = 0x00000032; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);



					//End RX PATH

					//Additional registers

						//LOVR_R0
						printf ("\n");
						printf ("LOVR_R0\r\n");
						fapb_cpri = (uint32_t *)0x8010F008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000044\r\n");
						*fapb_cpri = 0x00000044; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//MAJOR
						printf ("\n");
						printf ("MAJOR\r\n");
						fapb_cpri = (uint32_t *)0x82050008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0000000A\r\n");
						*fapb_cpri = 0x0000000A; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//LPIP_R0
						printf ("\n");
						printf ("LPIP_R0\r\n");
						fapb_cpri = (uint32_t *)0x8010F00C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//L8_R0
						printf ("\n");
						printf ("L8_R0\r\n");
						fapb_cpri = (uint32_t *)0x8010F040;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//LCLK_R0
						printf ("\n");
						printf ("LCLK_R0\r\n");
						fapb_cpri = (uint32_t *)0x8010F058;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00051F11\r\n");
						*fapb_cpri = 0x00051F11; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//LCLK_R1
						printf ("\n");
						printf ("LCLK_R1\r\n");
						fapb_cpri = (uint32_t *)0x8010F05C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000F00\r\n");
						*fapb_cpri = 0x00000F00; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//LCLK_RST
						printf ("\n");
						printf ("LCLK_RST\r\n");
						fapb_cpri = (uint32_t *)0x8010F068;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
						*fapb_cpri = 0x00000D0D; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000004\r\n");
						*fapb_cpri = 0x00000404; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//LCLK_OPT
							printf ("\n");
							printf ("LCLK_OPT\r\n");
							fapb_cpri = (uint32_t *)0x8010F06C;
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							printf ("Writing 00000002\r\n");
							*fapb_cpri = 0x00000002; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

						//GSSCLK_CTRL
			//			printf ("\n");
			//			printf ("GSSCLK_CTRL\r\n");
			//			fapb_cpri = (uint32_t *)0x80110004;
			//			read_data = *fapb_cpri;
			//			printf ("Read Value:%x\r\n",read_data);
			//		//	printf ("Writing 00000909\r\n");
			//			*fapb_cpri = 0x00000909; //Write Data // JA Enabled   or 0x00000404 0x00000909
			//			read_data = *fapb_cpri;
			//			printf ("Read Value:%x\r\n",read_data);

						//QRST_R0
								printf ("\n");
								printf ("QRST_R0\r\n");
								fapb_cpri = (uint32_t *)0x82110008;
								read_data = *fapb_cpri;
								printf ("Read Value:%x\r\n",read_data);
							//	printf ("Writing 0000000A\r\n");
								*fapb_cpri = 0x0000000A; //Write Data
								read_data = *fapb_cpri;
								printf ("Read Value:%x\r\n",read_data);

					//Additional
						//Releasing soft resets
						printf ("\n");
						printf ("SR1 PCIESS Main\r\n");
						fapb_cpri = (uint32_t *)0x82110000;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						printf ("\n");
						printf ("SR2 PMA LANE\r\n");
						fapb_cpri = (uint32_t *)0x81110000;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 01040000\r\n");
						*fapb_cpri = 0x01040000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						printf ("\n");
						printf ("SR3 PCS CMN\r\n");
						fapb_cpri = (uint32_t *)0x80110000;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 00140000\r\n");
						*fapb_cpri = 0x00140000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


					//Drive settings
						//SER_DRV_CTRL
						printf ("\n");
						printf ("SER_DRV_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F09C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 07FFFFFF\r\n");
						*fapb_cpri = 0x07FFFFFF; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_DRV_DATA_CTRL
						printf ("\n");
						printf ("SER_DRV_DATA_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F098;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

					//Yoons and Barrys suggestion:

						//DES_IN_TERM
						printf ("\n");
						printf ("DES_IN_TERM\r\n");
						fapb_cpri = (uint32_t *)0x8110F030;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 000000F7\r\n");
						*fapb_cpri = 0x000000F7; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_RTL_LOCK_CTRL
						printf ("\n");
						printf ("DES_RTL_LOCK_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F03C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000008\r\n");
						*fapb_cpri = 0x00000008; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//SER_TERM_CTRL
						printf ("\n");
						printf ("SER_TERM_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F090;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00007700\r\n");
						*fapb_cpri = 0x00007700; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_CTRL
						printf ("\n");
						printf ("SER_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110F070;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
					        if (HSLPBKEN == 1)
					          *fapb_cpri = 0x00000801; //Write Data
					        else
					          *fapb_cpri = 0x00000001; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_DRV_CTRL_SEL
						printf ("\n");
						printf ("SER_DRV_CTRL_SEL\r\n");
						fapb_cpri = (uint32_t *)0x8110F0A0;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
						*fapb_cpri = 0x00000001; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


					//More additional settings
						//DES_CDR_CTRL_3
						printf ("\n");
						printf ("DES_CDR_CTRL_3\r\n");
						fapb_cpri = (uint32_t *)0x8110F00C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00040100\r\n");
						*fapb_cpri = 0x00040100; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//DES_DFE_CAL_BYPASS
						printf ("\n");
						printf ("DES_DFE_CAL_BYPASS\r\n");
						fapb_cpri = (uint32_t *)0x8110F0E0;
						read_data = *fapb_cpri;
					//	printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 00200000\r\n");
						*fapb_cpri = 0x00200000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_DFE_CAL_CTRL_0
						printf ("\n");
						printf ("DES_DFE_CAL_CTRL_0\r\n");
						fapb_cpri = (uint32_t *)0x8110F0D0;
					//	read_data = *fapb_cpri;
					//	printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 64100716\r\n");
						*fapb_cpri = 0x64100716; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//OVRLY
						printf ("\n");
						printf ("OVRLY\r\n");
						fapb_cpri = (uint32_t *)0x8110F0E0;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000202\r\n");
						*fapb_cpri = 0x00200000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F04C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000010\r\n");
						*fapb_cpri = 00000010; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


					        //DES_RTL_LOCK_CTRL
						printf ("\n");
						fapb_cpri = (uint32_t *)0x8110F03C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_CTRL
						printf ("\n");
						printf ("TXPLL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 007E0010\r\n");
						*fapb_cpri =  0x0000000D; //Write Data    // JA Enabled      0x007E0010
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_JA_9
						fapb_cpri = (uint32_t *)0x81110038;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_JA_10
						fapb_cpri = (uint32_t *)0x8111003C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_JA_10
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						while (1)
						 {
						  if ( ((read_data) & (0x01000000)) != 0)
						 {
							  printf("TXPLL LOCKED \r\n");
							    break;
						}
						   else
								   printf("TXPLL NOT LOCKED\n");
								     read_data = *fapb_cpri;
								      printf ("Read Value:%x\r\n",read_data);
					   }

						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F078;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000003\r\n");
						*fapb_cpri = 0x00000003; //Write Data
						//read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F078;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000003\r\n");
						*fapb_cpri = 0x00000001; //Write Data
						//read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F04C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000032\r\n");
						*fapb_cpri = 0x00000032; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110F04C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000032\r\n");
						*fapb_cpri = 0x00000010; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

#endif;


#if 1
			//TX PATH
						//TXPLL_CLKBUF
						printf ("\n");
						printf ("TXPLL_CLKBUF\r\n");
						fapb_cpri = (uint32_t *)0x81110004;
						printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 000000FF\r\n");
						*fapb_cpri = 0x000000FF; //Write Data
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_CLOCK_SELECT
						printf ("\n");
						printf ("TXPLL_CLOCK_SELECT\r\n");
						fapb_cpri = (uint32_t *)0x8111000C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 01FFE380\r\n");
						*fapb_cpri =0x3003A000; //Write Data  // JA Enabled     0x01FFE380 0x1803A000
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_CTRL
						printf ("\n");
						printf ("TXPLL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 007E0010\r\n");
						*fapb_cpri =  0x007E0010; //Write Data    // JA Enabled      0x007E0010
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_CTRL
						printf ("\n");
						printf ("TXPLL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 007E0010\r\n");
						*fapb_cpri =  0x00000010; //Write Data    // JA Enabled      0x007E0010
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_DIV_1
						printf ("\n");
						printf ("TXPLL_DIV_1\r\n");
						fapb_cpri = (uint32_t *)0x81110010;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0280000\r\n");
						*fapb_cpri = 0x0280014; //Write Data  // JA Enabled      0x0280000
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_DIV_2
						printf ("\n");
						printf ("TXPLL_DIV_2\r\n");
						fapb_cpri = (uint32_t *)0x81110014;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 2000000\r\n");
						*fapb_cpri = 0x2000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_CLK_CTRL
						printf ("\n");
						printf ("SER_CLK_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81102074;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0000071\r\n");
						*fapb_cpri = 0x0000071 ; //Write Data  // JA Enabled     0x0000071
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_RXPLL_DIV
						printf ("\n");
						printf ("DES_RXPLL_DIV\r\n");
						fapb_cpri = (uint32_t *)0x81102040;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0002214\r\n");
						*fapb_cpri = 0x0002214; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x81102078;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000003\r\n");
						*fapb_cpri = 0x00000003; //Write Data
						//read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						// JA Registers
							//TXPLL_JA_RST
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110040;
							*fapb_cpri = 0xFFFFFFFF; //Write Data   //JA Reset
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
						    //TXPLL_JA_1
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110018;
							*fapb_cpri = 0x00F8007C; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_2
							printf ("\n");
							fapb_cpri = (uint32_t *)0x8111001C;
							*fapb_cpri = 0x000007D0; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_3
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110020;
							*fapb_cpri = 0x000503E8; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_4
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110024;
							*fapb_cpri = 0x08B50019; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_5
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110028;
							*fapb_cpri = 0x1DDEBE9; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							 //TXPLL_JA_6
							printf ("\n");
							fapb_cpri = (uint32_t *)0x8111002C;
							*fapb_cpri = 0x1E0007; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							//TXPLL_JA_7
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110030;
							*fapb_cpri = 0x73B6C1C; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_8
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110034;
							*fapb_cpri = 0x00000000; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_9
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110038;
							*fapb_cpri = 0x0028; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_10
							printf ("\n");
							fapb_cpri = (uint32_t *)0x8111003C;
							*fapb_cpri = 0x00000000; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_RST
							printf ("\n");
							fapb_cpri = (uint32_t *)0x81110040;
							*fapb_cpri = 0x00000000; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_9
							fapb_cpri = (uint32_t *)0x81110038;
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

							//TXPLL_JA_10
							fapb_cpri = (uint32_t *)0x8111003C;
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);


						//TXPLL_CTRL
						//printf ("\n");
					//	printf ("TXPLL_CTRL\r\n");
					//	fapb_cpri = (uint32_t *)0x81090008;
					//	read_data = *fapb_cpri;
					//printf ("Read Value:%x\r\n",read_data);
						//Monitor TXPLL LOCK
					        /*while (1)
					        {
					          if ( ((read_data) & (0x01000000)) != 0)
					          {
					                  printf("TXPLL LOCKED \r\n");
					                  break;
					          }
					          else
					                  printf("TXPLL NOT LOCKED\n");
					          read_data = *fapb_cpri;
					          printf ("Read Value:%x\r\n",read_data);
					        }
			*/
						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x81102078;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
						*fapb_cpri = 0x00000001; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SERIALIZER_RTL_CTRL
						printf ("\n");
						printf ("SERIALIZER_RTL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x811020C0;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

					//End TX PATH

					//RX PATH

						//DESERIALIZERA_CLOCK_CONTROL
						printf ("\n");
						printf ("DESERIALIZERA_CLOCK_CONTROL\r\n");
						fapb_cpri = (uint32_t *)0x81102048;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0000003C\r\n");
						*fapb_cpri = 0x0000003C; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_PKDET
						printf ("\n");
						printf ("DES_PKDET\r\n");
						fapb_cpri = (uint32_t *)0x81102034;
						read_data = *fapb_cpri;
						printf ("Writing 0000005D\r\n");
						*fapb_cpri = 0x0000005D; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110204C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000032\r\n");
						*fapb_cpri = 0x00000032; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);



					//End RX PATH

					//Additional registers

						//LOVR_R0
						printf ("\n");
						printf ("LOVR_R0\r\n");
						fapb_cpri = (uint32_t *)0x80102008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000044\r\n");
						*fapb_cpri = 0x00000044; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//MAJOR
						printf ("\n");
						printf ("MAJOR\r\n");
						fapb_cpri = (uint32_t *)0x82050008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 0000000A\r\n");
						*fapb_cpri = 0x0000000A; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//LPIP_R0
						printf ("\n");
						printf ("LPIP_R0\r\n");
						fapb_cpri = (uint32_t *)0x8010200C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//L8_R0
						printf ("\n");
						printf ("L8_R0\r\n");
						fapb_cpri = (uint32_t *)0x80102040;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//LCLK_R0
						printf ("\n");
						printf ("LCLK_R0\r\n");
						fapb_cpri = (uint32_t *)0x80102058;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00051F11\r\n");
						*fapb_cpri = 0x00051F11; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//LCLK_R1
						printf ("\n");
						printf ("LCLK_R1\r\n");
						fapb_cpri = (uint32_t *)0x8010205C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000F00\r\n");
						*fapb_cpri = 0x00000F00; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//LCLK_RST
						printf ("\n");
						printf ("LCLK_RST\r\n");
						fapb_cpri = (uint32_t *)0x80102068;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
						*fapb_cpri = 0x00000D0D; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000004\r\n");
						*fapb_cpri = 0x00000404; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//LCLK_OPT
							printf ("\n");
							printf ("LCLK_OPT\r\n");
							fapb_cpri = (uint32_t *)0x8010206C;
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);
							printf ("Writing 00000002\r\n");
							*fapb_cpri = 0x00000002; //Write Data
							read_data = *fapb_cpri;
							printf ("Read Value:%x\r\n",read_data);

						//GSSCLK_CTRL
			//			printf ("\n");
			//			printf ("GSSCLK_CTRL\r\n");
			//			fapb_cpri = (uint32_t *)0x80110004;
			//			read_data = *fapb_cpri;
			//			printf ("Read Value:%x\r\n",read_data);
			//		//	printf ("Writing 00000909\r\n");
			//			*fapb_cpri = 0x00000909; //Write Data // JA Enabled   or 0x00000404 0x00000909
			//			read_data = *fapb_cpri;
			//			printf ("Read Value:%x\r\n",read_data);

						//QRST_R0
								printf ("\n");
								printf ("QRST_R0\r\n");
								fapb_cpri = (uint32_t *)0x82110008;
								read_data = *fapb_cpri;
								printf ("Read Value:%x\r\n",read_data);
							//	printf ("Writing 0000000A\r\n");
								*fapb_cpri = 0x0000000A; //Write Data
								read_data = *fapb_cpri;
								printf ("Read Value:%x\r\n",read_data);

					//Additional
						//Releasing soft resets
						printf ("\n");
						printf ("SR1 PCIESS Main\r\n");
						fapb_cpri = (uint32_t *)0x82110000;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						printf ("\n");
						printf ("SR2 PMA LANE\r\n");
						fapb_cpri = (uint32_t *)0x81110000;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 01040000\r\n");
						*fapb_cpri = 0x01040000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						printf ("\n");
						printf ("SR3 PCS CMN\r\n");
						fapb_cpri = (uint32_t *)0x80110000;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 00140000\r\n");
						*fapb_cpri = 0x00140000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


					//Drive settings
						//SER_DRV_CTRL
						printf ("\n");
						printf ("SER_DRV_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110209C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 07FFFFFF\r\n");
						*fapb_cpri = 0x07FFFFFF; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_DRV_DATA_CTRL
						printf ("\n");
						printf ("SER_DRV_DATA_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81102098;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000000\r\n");
						*fapb_cpri = 0x00000000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

					//Yoons and Barrys suggestion:

						//DES_IN_TERM
						printf ("\n");
						printf ("DES_IN_TERM\r\n");
						fapb_cpri = (uint32_t *)0x81102030;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 000000F7\r\n");
						*fapb_cpri = 0x000000F7; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_RTL_LOCK_CTRL
						printf ("\n");
						printf ("DES_RTL_LOCK_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x8110203C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000008\r\n");
						*fapb_cpri = 0x00000008; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//SER_TERM_CTRL
						printf ("\n");
						printf ("SER_TERM_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81102090;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00007700\r\n");
						*fapb_cpri = 0x00007700; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_CTRL
						printf ("\n");
						printf ("SER_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81102070;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
					        if (HSLPBKEN == 1)
					          *fapb_cpri = 0x00000801; //Write Data
					        else
					          *fapb_cpri = 0x00000001; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SER_DRV_CTRL_SEL
						printf ("\n");
						printf ("SER_DRV_CTRL_SEL\r\n");
						fapb_cpri = (uint32_t *)0x811020A0;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000001\r\n");
						*fapb_cpri = 0x00000001; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


					//More additional settings
						//DES_CDR_CTRL_3
						printf ("\n");
						printf ("DES_CDR_CTRL_3\r\n");
						fapb_cpri = (uint32_t *)0x8110200C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00040100\r\n");
						*fapb_cpri = 0x00040100; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//DES_DFE_CAL_BYPASS
						printf ("\n");
						printf ("DES_DFE_CAL_BYPASS\r\n");
						fapb_cpri = (uint32_t *)0x811020E0;
						read_data = *fapb_cpri;
					//	printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 00200000\r\n");
						*fapb_cpri = 0x00200000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DES_DFE_CAL_CTRL_0
						printf ("\n");
						printf ("DES_DFE_CAL_CTRL_0\r\n");
						fapb_cpri = (uint32_t *)0x811020D0;
					//	read_data = *fapb_cpri;
					//	printf ("Read Value:%x\r\n",read_data);
					//	printf ("Writing 64100716\r\n");
						*fapb_cpri = 0x64100716; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//OVRLY
						printf ("\n");
						printf ("OVRLY\r\n");
						fapb_cpri = (uint32_t *)0x811020E0;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000202\r\n");
						*fapb_cpri = 0x00200000; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110204C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000010\r\n");
						*fapb_cpri = 00000010; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


					        //DES_RTL_LOCK_CTRL
						printf ("\n");
						fapb_cpri = (uint32_t *)0x8110203C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_CTRL
						printf ("\n");
						printf ("TXPLL_CTRL\r\n");
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 007E0010\r\n");
						*fapb_cpri =  0x0000000D; //Write Data    // JA Enabled      0x007E0010
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_JA_9
						fapb_cpri = (uint32_t *)0x81110038;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);


						//TXPLL_JA_10
						fapb_cpri = (uint32_t *)0x8111003C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//TXPLL_JA_10
						fapb_cpri = (uint32_t *)0x81110008;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						while (1)
						 {
						  if ( ((read_data) & (0x01000000)) != 0)
						 {
							  printf("TXPLL LOCKED \r\n");
							    break;
						}
						   else
								   printf("TXPLL NOT LOCKED\n");
								     read_data = *fapb_cpri;
								      printf ("Read Value:%x\r\n",read_data);
					   }

						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x81102078;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000003\r\n");
						*fapb_cpri = 0x00000003; //Write Data
						//read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//SERIALIZERA_RESETPD
						printf ("\n");
						printf ("SERIALIZERA_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x81102078;
						//read_data = *fapb_cpri;
						//printf ("Read Value:%x\r\n",read_data);
						//printf ("Writing 00000003\r\n");
						*fapb_cpri = 0x00000001; //Write Data
						//read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110204C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000032\r\n");
						*fapb_cpri = 0x00000032; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

						//DESERIALIZER_RESETPD
						printf ("\n");
						printf ("DESERIALIZER_RESETPD\r\n");
						fapb_cpri = (uint32_t *)0x8110204C;
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);
						printf ("Writing 00000032\r\n");
						*fapb_cpri = 0x00000010; //Write Data
						read_data = *fapb_cpri;
						printf ("Read Value:%x\r\n",read_data);

#endif;



}
