Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void srio_init(uint laneIndex) {
- int i;
- uint8 temp8, temp8_2;
- uint32 rxCfg, txCfg, temp;
- SRIO_PE_FEATURES peFeatures;
- SRIO_OP_CAR opCar;
- lsuNum = 0;
- SRIO_PLM_POLARITY_CONTROL polCtrl;
- // Qmss_QueueHnd queueHnd;
- // uint8_t isAllocated;
- // uint32_t gargbageQueue[] = { GARBAGE_LEN_QUEUE, GARBAGE_TOUT_QUEUE,
- // GARBAGE_RETRY_QUEUE, GARBAGE_TRANS_ERR_QUEUE,
- // GARBAGE_PROG_QUEUE, GARBAGE_SSIZE_QUEUE };
- /* Get the CSL SRIO Handle. */
- sjlHSrio = CSL_SRIO_Open(0);
- /* Disable the SRIO Global block */
- CSL_SRIO_GlobalDisable(sjlHSrio);
- /* Disable each of the individual SRIO blocks. */
- for(i = 0; i <= 9; i++) {
- CSL_SRIO_DisableBlock(sjlHSrio, i);
- }
- /* Set boot complete to be 0; we are not done with the initialization. */
- temp = SRIO_REGS->RIO_PER_SET_CNTL;
- CSL_SRIO_SetBootComplete(sjlHSrio, 0);
- temp = SRIO_REGS->RIO_PER_SET_CNTL;
- /* Now enable the SRIO block and all the individual blocks also. */
- CSL_SRIO_GlobalEnable(sjlHSrio);
- for(i = 0; i <= 9; i++) {
- CSL_SRIO_EnableBlock(sjlHSrio, i);
- }
- /* Register settings after coming up in SRIO Boot Mode:
- *
- * PER_SER_CNTL 0x0D053860
- * PER_SET_CNTL1 0x00000000
- *
- * GBL_EN 0x00000001
- * GBL_EN_STAT 0x000007FF
- *
- * LSU_SETUP_REG0 0x44444444
- * LSU_SETUP_REG1 0x00000000
- *
- */
- /* Configure SRIO ports to operate in normal mode. */
- CSL_SRIO_SetNormalMode(sjlHSrio, 0);
- CSL_SRIO_SetMAUSwappingMode(sjlHSrio, 0);
- CSL_SRIO_SetLSUSwappingMode(sjlHSrio, 0);
- /* Set to respond to andy target id */
- CSL_SRIO_EnablePromiscuous(sjlHSrio);
- CSL_SRIO_SetAMUSwappingMode(sjlHSrio, 0);
- CSL_SRIO_SetTXURXUSwappingMode(sjlHSrio, 0);
- /* Enable Automatic Priority Promotion of response packets. */
- CSL_SRIO_EnableAutomaticPriorityPromotion(sjlHSrio);
- /* Set the SRIO Prescalar select to operate in the range of 313.2 to 626.4 */
- CSL_SRIO_SetPrescalarSelect(sjlHSrio, 6);
- /* Unlock the Boot Configuration Kicker */
- CSL_BootCfgUnlockKicker();
- /* Assuming the link rate is 5000; program the PLL accordingly. [From sprugw1a (SRIO Rev A) Section 2.3.1.1 pg.41-43] */
- temp = (0 << 13) | // CLKBYP - Clock Bypass disabled
- (0 << 11) | // LOOP_BANDWIDTH - 0 -> Freq dependent bandwidth
- (0 << 10) | // SLEEPPLL - disabled
- (1 << 9) | // VRANGE - HI/LOW VCO range
- (0x28 << 1) | // MPY - 0x28 -> 10x (for 3.125Gbps) //0x40 -> 16x (for 5Gbps) (used for 156.25 MHz ref clock)
- (1 << 0); // ENPLL - Enable PLL
- CSL_BootCfgSetSRIOSERDESConfigPLL(temp);
- /* Configure the SRIO SERDES Receive Configuration values. [From sprugw1a (SRIO Rev A) Section 2.3.1.2 pg.44-47]
- * Note: SRIO Boot Mode comes up as 0x00440495 */
- rxCfg = (0 << 25) | // TESTPATTERN - disabled
- #ifdef LOOPBACK_TEST_MODE
- (3 << 23) | // LOOPBACK - enabled
- #else
- (0 << 23) | // LOOPBACK - disabled
- #endif
- (1 << 22) | // ENOC - enable? (initial disable)
- (0 << 21) | // EQHLD - disabled
- (1 << 18) | // EQ - 1 for Adaptive
- (1 << 15) | // CDR (Clock/Data Recovery) - 1 for Second order
- (0 << 12) | // LOS (Loss of Signal) - 0 to disable
- (1 << 10) | // ALIGN - 1 for Comma alignment enabled
- (1 << 7) | // TERM - Must be set to 1
- (0 << 6) | // INVPAIR - 0 for Normal polarity
- (1 << 4) | // RATE - 0=Full, 1=Half, 2=Quarter
- (2 << 1) | // BUSWIDTH - Always write 010b to this field to indicate a 20-bit wide parallel bus to the clock (see note on pg 46) ***6474 set to 0
- (1 << 0); // ENRX - 1 to Enable this receiver
- /* Configure the SRIO SERDES Transmit Configuration values. [From sprugw1a (SRIO Rev A) Section 2.3.1.3 pg.47-49]
- * Note: SRIO Boot Mode comes up as 0x00180795 */
- txCfg = (0 << 23) | // TESTPATTERN - disabled
- #ifdef LOOPBACK_TEST_MODE
- (3 << 23) | // LOOPBACK - enabled
- #else
- (0 << 23) | // LOOPBACK - disabled
- #endif
- (0 << 20) | // MSYNC - Synchronization master Enables the channel as the master lane
- (1 << 19) | // FIRUPT - Transmitter pre and post cursor FIR filter update
- (0 << 14) | // TWPST1 - Adjacent post cursor Tap weight, 0-15 -> -37.5 to +37.5% in 2.5% steps
- (0 << 11) | // TWPRE - Precursor Tap weight, 0-7 -> 0 to -17.5% in 2.5% steps
- (0xF << 7) | // SWING - Output swing, 0-F See Table 2-13 (pg 48) ***Comes up as 0xF in SRIO Boot mode, 6474 set to 4
- (0 << 6) | // INVPAIR - 0 for Normal polarity
- (1 << 4) | // RATE - 0=Full, 1=Half, 2=Quarter
- (2 << 1) | // BUSWIDTH - Always write 010b to this field to indicate a 20-bit wide parallel bus to the clock (see note on pg 48) ***6474 set to 0
- (1 << 0); // ENRX - 1 to Enable this transmitter
- for(i = 0; i < 4; i++) {
- /* Set the SRIO SERDES Receive Configuration. */
- CSL_BootCfgSetSRIOSERDESRxConfig(i, rxCfg);
- /* Set the SRIO SERDES Transmit Configuration. */
- if(laneIndex == LANE_WIDTH_1x) {
- CSL_BootCfgSetSRIOSERDESTxConfig(i, txCfg | (1 << 20));
- } else if(laneIndex == LANE_WIDTH_2x) {
- if((i & 1) == 0) {
- /* Make Lane 0 and 2 Master Lanes (in 2x mode) */
- CSL_BootCfgSetSRIOSERDESTxConfig(i, txCfg | (1 << 20));
- } else {
- CSL_BootCfgSetSRIOSERDESTxConfig(i, txCfg);
- }
- } else if(laneIndex == LANE_WIDTH_4x) {
- if(i == 0) {
- /* Make Lane 0 Master Lane (in 4x mode) */
- CSL_BootCfgSetSRIOSERDESTxConfig(i, txCfg | (1 << 20));
- } else {
- CSL_BootCfgSetSRIOSERDESTxConfig(i, txCfg);
- }
- }
- }
- //delayCycles(5000);
- while(1) {
- uint32_t status;
- /* Get the SRIO SERDES Status */
- CSL_BootCfgGetSRIOSERDESStatus(&status);
- if (status & 0x1)
- break;
- }
- #ifdef CHANGE_BOOT_FIELDS
- /* Set the Host Device Identifier. */
- CSL_SRIO_SetHostDeviceID(sjlHSrio, 0x00000001);
- #endif
- /* Configure the component tag CSR */
- CSL_SRIO_SetCompTagCSR (sjlHSrio, 0x1492);
- polCtrl.rx0Pol = 0;
- polCtrl.rx1Pol = 0;
- polCtrl.rx2Pol = 0;
- polCtrl.rx3Pol = 0;
- polCtrl.tx0Pol = 0;
- polCtrl.tx1Pol = 0;
- polCtrl.tx2Pol = 0;
- polCtrl.tx3Pol = 0;
- for(i = 0; i < 4; i++) {
- /* Set the PLM Port Silence Timer. */
- CSL_SRIO_SetPLMPortSilenceTimer(sjlHSrio, i, 0x2);
- if(laneIndex == LANE_WIDTH_1x) {
- /* Setup port width to be 1x mode */
- CSL_SRIO_SetPLMPortPathControlMode(sjlHSrio, i, 0);
- CSL_SRIO_ClearPLMPortLinkInitialized(sjlHSrio, i);
- CSL_SRIO_SetPLMPortPolarityControl(sjlHSrio, i, &polCtrl);
- } else if(laneIndex == LANE_WIDTH_2x) {
- /* Setup port width to be 2x mode */
- CSL_SRIO_SetPLMPortPathControlMode(sjlHSrio, i, 3);
- if((i & 1) == 0) {
- CSL_SRIO_ClearPLMPortLinkInitialized(sjlHSrio, i);
- CSL_SRIO_SetPLMPortPolarityControl(sjlHSrio, i, &polCtrl);
- }
- } else if(laneIndex == LANE_WIDTH_4x) {
- /* Setup port width to be 4x mode */
- CSL_SRIO_SetPLMPortPathControlMode(sjlHSrio, i, 4);
- if(i == 0) {
- CSL_SRIO_ClearPLMPortLinkInitialized(sjlHSrio, i);
- CSL_SRIO_SetPLMPortPolarityControl(sjlHSrio, i, &polCtrl);
- }
- }
- // CSL_SRIO_Enable3_125GBaud(sjlHSrio, i); //SPn_CTL2
- /* Enable Ports */
- CSL_SRIO_EnableInputPort(sjlHSrio, i);
- CSL_SRIO_EnableOutputPort(sjlHSrio, i);
- CSL_SRIO_EnablePort(sjlHSrio, i);
- CSL_SRIO_DisablePortLockout(sjlHSrio, i);
- CSL_SRIO_EnablePortErrorChecking(sjlHSrio, i);
- /* Set the PLM Port Discovery Timer. */
- CSL_SRIO_SetPLMPortDiscoveryTimer(sjlHSrio, i, 0x2);
- /* Reset the Port Write Reception capture. */
- CSL_SRIO_SetPortWriteReceptionCapture(sjlHSrio, i, 0x0);
- }
- /* Clear the LSU pending interrupts. */
- CSL_SRIO_ClearLSUPendingInterrupt (sjlHSrio, 0xFFFFFFFF, 0xFFFFFFFF);
- /* Set the Device Information */
- CSL_SRIO_SetDeviceInfo (sjlHSrio, DEVICE_ID1_16BIT, DEVICE_VENDOR_ID, DEVICE_REVISION);
- /* Set the Assembly Information */
- CSL_SRIO_SetAssemblyInfo(sjlHSrio, DEVICE_ASSEMBLY_ID, DEVICE_ASSEMBLY_VENDOR_ID,
- DEVICE_ASSEMBLY_REVISION, DEVICE_ASSEMBLY_INFO);
- /* Configure the processing element features
- * The SRIO RL file is missing the Re-transmit Suppression Support (Bit6) field definition */
- peFeatures.isBridge = 0;
- peFeatures.isEndpoint = 0;
- peFeatures.isProcessor = 1;
- peFeatures.isSwitch = 0;
- peFeatures.isMultiport = 0;
- peFeatures.isFlowArbiterationSupported = 0;
- peFeatures.isMulticastSupported = 0;
- peFeatures.isExtendedRouteConfigSupported = 1;
- peFeatures.isStandardRouteConfigSupported = 1;
- peFeatures.isFlowControlSupported = 1;
- peFeatures.isCRFSupported = 0;
- peFeatures.isCTLSSupported = 1;
- peFeatures.isExtendedFeaturePtrValid = 1;
- peFeatures.numAddressBitSupported = 1;
- CSL_SRIO_SetProcessingElementFeatures(sjlHSrio, &peFeatures);
- /* Configure the source operation CAR */
- memset ((void *) &opCar, 0, sizeof (opCar));
- opCar.portWriteOperationSupport = 1;
- opCar.atomicClearSupport = 1;
- opCar.atomicSetSupport = 1;
- opCar.atomicDecSupport = 1;
- opCar.atomicIncSupport = 1;
- opCar.atomicTestSwapSupport = 1;
- opCar.doorbellSupport = 1;
- opCar.dataMessageSupport = 1;
- opCar.writeResponseSupport = 1;
- opCar.streamWriteSupport = 1;
- opCar.writeSupport = 1;
- opCar.readSupport = 1;
- opCar.dataStreamingSupport = 1;
- CSL_SRIO_SetSourceOperationCAR (sjlHSrio, &opCar);
- /* Configure the destination operation CAR */
- memset ((void *) &opCar, 0, sizeof (opCar));
- opCar.portWriteOperationSupport = 1;
- opCar.doorbellSupport = 1;
- opCar.dataMessageSupport = 1;
- opCar.writeResponseSupport = 1;
- opCar.streamWriteSupport = 1;
- opCar.writeSupport = 1;
- opCar.readSupport = 1;
- CSL_SRIO_SetDestOperationCAR (sjlHSrio, &opCar);
- /* Set the 16 bit and 8 bit identifier for the SRIO Device. */
- CSL_SRIO_SetDeviceIDCSR (sjlHSrio, DEVICE_ID1_8BIT, DEVICE_ID1_16BIT);
- /* Enable TLM Base Routing Information for Maintainance Requests & ensure that
- * the BRR's can be used by all the ports. */
- CSL_SRIO_SetTLMPortBaseRoutingInfo(sjlHSrio, 0, 1, 1, 1, 0);
- CSL_SRIO_SetTLMPortBaseRoutingInfo(sjlHSrio, 0, 2, 1, 1, 0);
- CSL_SRIO_SetTLMPortBaseRoutingInfo(sjlHSrio, 0, 3, 1, 1, 0);
- CSL_SRIO_SetTLMPortBaseRoutingInfo(sjlHSrio, 1, 0, 1, 1, 0);
- /* Configure the Base Routing Register to ensure that all packets matching the
- * Device Identifier & the Secondary Device Id are admitted. */
- CSL_SRIO_SetTLMPortBaseRoutingPatternMatch(sjlHSrio, 0, 1, DEVICE_ID2_16BIT, 0xFFFF);
- CSL_SRIO_SetTLMPortBaseRoutingPatternMatch(sjlHSrio, 0, 2, DEVICE_ID3_16BIT, 0xFFFF);
- CSL_SRIO_SetTLMPortBaseRoutingPatternMatch(sjlHSrio, 0, 3, DEVICE_ID4_16BIT, 0xFFFF);
- CSL_SRIO_SetTLMPortBaseRoutingPatternMatch(sjlHSrio, 1, 0, DEVICE_ID2_8BIT, 0xFF);
- /* Set the Port link timeout CSR */
- CSL_SRIO_SetPortLinkTimeoutCSR(sjlHSrio, 0x000FFF);
- /* Set the Port General CSR: executing as Host, Master Enabled, Discoved */
- CSL_SRIO_SetPortGeneralCSR(sjlHSrio, 1, 1, 1);
- /* Clear the sticky register bits. */
- CSL_SRIO_SetLLMResetControl(sjlHSrio, 1);
- /* Set the device id to be 0 for the Maintenance Port-Write operation
- * to report errors to a system host. */
- CSL_SRIO_SetPortWriteDeviceId(sjlHSrio, 0x0, 0x0, 0x0);
- /* Set the Data Streaming MTU */
- CSL_SRIO_SetDataStreamingMTU(sjlHSrio, 0x40);
- /* Configure the path mode for the ports. */
- /* Set the LLM Port IP Prescalar. */
- CSL_SRIO_SetLLMPortIPPrescalar(sjlHSrio, 0x1E);
- #ifdef LOOPBACK_TEST_MODE
- SRIO_REGS->RIO_PER_SET_CNTL1 = (0xF << 4); /* Set all ports to loopback */
- #else
- SRIO_REGS->RIO_PER_SET_CNTL1 = 0x0;
- #endif
- /* Enable the peripheral. */
- CSL_SRIO_EnablePeripheral(sjlHSrio);
- /* Set boot complete to be 1; we are done with the initialization. */
- CSL_SRIO_SetBootComplete(sjlHSrio, 1);
- debug_srio();
- init_port_link(0);
- /* Initialize Constants */
- ti_srio_init_const();
- }
Advertisement
Add Comment
Please, Sign In to add comment