/************************************************************************************ * FUNCTION PURPOSE: Enable and configure serdes ************************************************************************************ * DESCRIPTION: The serdes is configured and enabled ************************************************************************************/ SINT16 hwSerdesConfig (UINT32 sBase, serdesConfig_t *scfg) { UINT32 reg; UINT32 regb; SINT32 i; /* If the serdes is already enabled and the new value does not match * the current value, the serdes is first disabled. Dont compare * the sleep value in the register, which can be toggled dynamically */ reg = DEVICE_REG32_R (sBase + SERDES_REG_CFG); reg = SERDES_SET_CFG_SLEEP(reg, 0); regb = SERDES_SET_CFG_SLEEP(scfg->cfg, 0); chipKickOpenSerdes(sBase); if ( (SERDES_GET_ENABLE(reg) == 1) && (SERDES_GET_ENABLE(scfg->cfg) == 1) && (reg != regb) ) { reg = SERDES_SET_ENABLE(reg, 0); DEVICE_REG32_W (sBase + SERDES_REG_CFG, reg); chipDelay32 (100); } /* Config register. After enable it takes upt to 350ns, or 200 cycles to * stabalize. Although these are serdes clock cycles the delay here is * in cpu cycles. The PLL status will be checked by the peripheral * using the PLL */ DEVICE_REG32_W (sBase + SERDES_REG_CFG, regb); chipDelay32 (200); /* Some devices have unreliable lock status bits. Add an extra delay * to allow the serdes to lock */ chipDelay32 (TARGET_SERDES_LOCK_DELAY); /* rx and tx config registers */ for (i = 0; i < scfg->nLanes; i++) { DEVICE_REG32_W (sBase + SERDES_REG_RX(i), scfg->rxCfg[i]); DEVICE_REG32_W (sBase + SERDES_REG_TX(i), scfg->txCfg[i]); } chipKickClosedSerdes(sBase); return (0); } /* hwSerdesConfig */
/* * FUNCTION PURPOSE: Power up/down a module * * DESCRIPTION: Powers up/down the requested module and the associated power * domain if required. No action is taken it the module is * already powered up/down. * * This only controls modules. The domain in which the module * resides will be left in the power on state. Multiple modules * can exist in a power domain, so powering down the domain based * on a single module is not done. * * Returns 0 on success, -1 if the module can't be powered up, or * if there is a timeout waiting for the transition. */ int psc_set_state(u32 mod_num, u32 state) { u32 domain_num; u32 pdctl; u32 mdctl; u32 ptcmd; u32 reset_iso; u32 v; /* * Get the power domain associated with the module number, and reset * isolation functionality */ v = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCFG(mod_num)); domain_num = PSC_REG_MDCFG_GET_PD(v); reset_iso = PSC_REG_MDCFG_GET_RESET_ISO(v); /* Wait for the status of the domain/module to be non-transitional */ if (psc_wait(domain_num) != 0) return -1; /* * Perform configuration even if the current status matches the * existing state * * Set the next state of the power domain to on. It's OK if the domain * is always on. This code will not ever power down a domain, so no * change is made if the new state is power down. */ if (state == PSC_REG_VAL_MDCTL_NEXT_ON) { pdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num)); pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl, PSC_REG_VAL_PDCTL_NEXT_ON); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num), pdctl); } /* Set the next state for the module to enabled/disabled */ mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num)); mdctl = PSC_REG_MDCTL_SET_NEXT(mdctl, state); mdctl = PSC_REG_MDCTL_SET_RESET_ISO(mdctl, reset_iso); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num), mdctl); /* Trigger the enable */ ptcmd = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PTCMD); ptcmd |= (u32)(1<<domain_num); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd); /* Wait on the complete */ return psc_wait(domain_num); }
/* * FUNCTION PURPOSE: Disable a power domain * * DESCRIPTION: The power domain is disabled */ int psc_disable_domain(u32 domain_num) { u32 pdctl; u32 ptcmd; pdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num)); pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl, PSC_REG_VAL_PDCTL_NEXT_OFF); pdctl = PSC_REG_PDCTL_SET_PDMODE(pdctl, PSC_REG_VAL_PDCTL_PDMODE_SLEEP); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num), pdctl); ptcmd = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PTCMD); ptcmd |= (u32)(1 << domain_num); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd); return psc_wait(domain_num); }
/******************************************************************************* * FUNCTION PURPOSE: Setup a mux value ******************************************************************************* * DESCRIPTION: Configures one of the 12 interrupt mux values. Original value * is lost. ******************************************************************************/ void hwIntctlRoute (uint32_t vector, uint32_t eventNum) { uint32_t muxp; uint32_t muxv; uint32_t base; if (vector > 3 && vector < 8) muxp = 1; else if (vector < 12) muxp = 2; else if (vector < 16) muxp = 3; else return; /* Invalid vector */ /* Which of the four events in each register (0-3) is determined by the the * two lsbs of the vector number. The least significant bit of the mux * valud (0, 8, 16, or 24) is found. */ base = (vector & 0x3) * 8; /* Read the active mux, overwrite the event num with the desired value */ muxv = DEVICE_REG32_R (DEVICE_INTCTL_BASE + INTCTL_REG_MUX(muxp)); muxv = BOOT_SET_BITFIELD (muxv, eventNum, base+7, base); DEVICE_REG32_W (DEVICE_INTCTL_BASE + INTCTL_REG_MUX(muxp), muxv); } /* hwIntctlRoute */
/************************************************************************* * @b EVM_init() * * @n * * Initializes the platform hardware. This routine is configured to start in * the evm.cfg configuration file. It is the first routine that BIOS * calls and is executed before Main is called. If you are debugging within * CCS the default option in your target configuration file may be to execute * all code up until Main as the image loads. To debug this you should disable * that option. * * @param[in] None * * @retval * None ************************************************************************/ void EVM_init() { platform_init_flags sFlags; platform_init_config sConfig; /* Status of the call to initialize the platform */ int32_t pform_status; /* Platform Information - we will read it form the Platform Library */ platform_info sPlatformInfo; int core; /* * You can choose what to initialize on the platform by setting the following * flags. Things like the DDR, PLL, etc should have been set by the boot loader. */ memset( (void *) &sFlags, 0, sizeof(platform_init_flags)); memset( (void *) &sConfig, 0, sizeof(platform_init_config)); sFlags.pll = 0; /* PLLs for clocking */ sFlags.ddr = 0; /* External memory */ sFlags.tcsl = 1; /* Time stamp counter */ sFlags.phy = 1; /* Ethernet */ //ToDo: Shouldn't this better be 0 ? sFlags.ecc = 0; /* Memory ECC */ sConfig.pllm = 0; /* Use libraries default clock divisor */ pform_status = platform_init(&sFlags, &sConfig); /* If we initialized the platform okay */ if (pform_status == Platform_EOK) { /* Get information about the platform so we can use it in various places */ memset( (void *) &sPlatformInfo, 0, sizeof(platform_info)); platform_get_info(&sPlatformInfo); number_of_cores = sPlatformInfo.cpu.core_count; MultiProc_setLocalId((Uint16) platform_get_coreid()); } else { /* Initialization of the platform failed... die */ logout("Platform failed to initialize. Error code %d \n", pform_status); while (1) { (void) platform_led(1, PLATFORM_LED_ON, PLATFORM_USER_LED_CLASS); (void) platform_delay(50000); (void) platform_led(1, PLATFORM_LED_OFF, PLATFORM_USER_LED_CLASS); (void) platform_delay(50000); } } /* Unlock the chip registers */ CSL_BootCfgUnlockKicker(); /* wake up the other core to run slave part */ for (core = 1; core < CORE_AMOUNT; core++) { /* IPC interrupt other cores */ DEVICE_REG32_W(IPCGR(core), 1); platform_delay(1000); } }
/* * FUNCTION PURPOSE: Power down a module * * DESCRIPTION: Powers down the requested module. * * Returns 0 on success, -1 on failure or timeout. */ int psc_disable_module(u32 mod_num) { u32 mdctl; /* Set the bit to apply reset */ mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num)); if ((mdctl & 0x3f) == 0) return 0; mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num), mdctl); return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE); }
/******************************************************************************************* * FUNCTION PURPOSE: Configure the gmac sliver ******************************************************************************************* * DESCRIPTION: The emac sliver is configured. *******************************************************************************************/ SINT16 hwGmacSlConfig (UINT16 port, hwGmacSlCfg_t *cfg) { UINT32 v; UINT32 i; SINT16 ret = GMACSL_RET_OK; if (port >= DEVICE_N_GMACSL_PORTS) return (GMACSL_RET_INVALID_PORT); if (cfg->maxRxLen > CPGMAC_REG_MAXLEN_LEN) { cfg->maxRxLen = CPGMAC_REG_MAXLEN_LEN; ret = GMACSL_RET_WARN_MAXLEN_TOO_BIG; } /* Must wait if the device is undergoing reset */ for (i = 0; i < DEVICE_EMACSL_RESET_POLL_COUNT; i++) { v = DEVICE_REG32_R (DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_RESET); if ( (v & CPGMAC_REG_RESET_VAL_RESET_MASK) != CPGMAC_REG_RESET_VAL_RESET) break; } if (i == DEVICE_EMACSL_RESET_POLL_COUNT) return (GMACSL_RET_CONFIG_FAIL_RESET_ACTIVE); DEVICE_REG32_W(DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_MAXLEN, cfg->maxRxLen); DEVICE_REG32_W(DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_CTL, cfg->ctl); return (ret); } /* hwGmacSlConfig */
/************************************************************************************************ * FUNCTION PURPOSE: Configure the switch ************************************************************************************************ * DESCRIPTION: The switch is setup without respect to its current state. The ALE * is reset during the configuration. ************************************************************************************************/ SINT16 hwCpswConfig (UINT32 ctl, UINT32 maxPktSize) { UINT32 i; /* Max length register */ DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_MAXLEN, maxPktSize); /* Control register */ DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_CTL, ctl); /* All statistics enabled by default */ DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_STAT_PORT_EN, CPSW_REG_VAL_STAT_ENABLE_ALL); /* Reset and enable the ALE */ DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_ALE_CONTROL, CPSW_REG_VAL_ALE_CTL_RESET_AND_ENABLE); /* All ports put into forward mode */ for (i = 0; i < DEVICE_CPSW_NUM_PORTS; i++) DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_ALE_PORTCTL(i), CPSW_REG_VAL_PORTCTL_FORWARD_MODE); return (0); } /* hwCpswConfig */
/* * FUNCTION PURPOSE: Set the reset isolation bit in mdctl * * DESCRIPTION: The reset isolation enable bit is set. The state of the module * is not changed. Returns 0 if the module config showed that * reset isolation is supported. Returns 1 otherwise. This is not * an error, but setting the bit in mdctl has no effect. */ int psc_set_reset_iso(u32 mod_num) { u32 v; u32 mdctl; /* Set the reset isolation bit */ mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num)); mdctl = PSC_REG_MDCTL_SET_RESET_ISO(mdctl, 1); DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num), mdctl); v = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCFG(mod_num)); if (PSC_REG_MDCFG_GET_RESET_ISO(v) == 1) return 0; return 1; }
/******************************************************************************************** * FUNCTION PURPOSE: Reset the the gmac sliver ******************************************************************************************** * DESCRIPTION: Soft reset is set and polled until clear, or until a timeout occurs ********************************************************************************************/ SINT16 hwGmacSlReset (UINT16 port) { UINT32 i; UINT32 v; if (port >= DEVICE_N_GMACSL_PORTS) return (GMACSL_RET_INVALID_PORT); /* Set the soft reset bit */ DEVICE_REG32_W (DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_RESET, CPGMAC_REG_RESET_VAL_RESET); /* Wait for the bit to clear */ for (i = 0; i < DEVICE_EMACSL_RESET_POLL_COUNT; i++) { v = DEVICE_REG32_R (DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_RESET); if ( (v & CPGMAC_REG_RESET_VAL_RESET_MASK) != CPGMAC_REG_RESET_VAL_RESET) return (GMACSL_RET_OK); } /* Timeout on the reset */ return (GMACSL_RET_WARN_RESET_INCOMPLETE); } /* hwGmacSlReset */
/****************************************************************************** * hwWbInvL1DInline ******************************************************************************/ void inline hwWbInvL1DInline(void) { DEVICE_REG32_W (DEVICE_CACHE_BASE + CACHE_REG_L1DWBIV, 1); }