12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673 |
- /*****************************************************************************
- * Copyright 2003 - 2008 Broadcom Corporation. All rights reserved.
- *
- * Unless you and Broadcom execute a separate written software license
- * agreement governing use of this software, this software is licensed to you
- * under the terms of the GNU General Public License version 2, available at
- * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
- *
- * Notwithstanding the above, under no circumstances may you combine this
- * software in any way with any other Broadcom software provided under a
- * license other than the GPL, without Broadcom's express prior written
- * consent.
- *****************************************************************************/
- #ifndef CHIPC_INLINE_H
- #define CHIPC_INLINE_H
- /* ---- Include Files ----------------------------------------------------- */
- #include <csp/errno.h>
- #include <csp/reg.h>
- #include <mach/csp/chipcHw_reg.h>
- #include <mach/csp/chipcHw_def.h>
- /* ---- Private Constants and Types --------------------------------------- */
- typedef enum {
- chipcHw_OPTYPE_BYPASS, /* Bypass operation */
- chipcHw_OPTYPE_OUTPUT /* Output operation */
- } chipcHw_OPTYPE_e;
- /* ---- Public Constants and Types ---------------------------------------- */
- /* ---- Public Variable Externs ------------------------------------------- */
- /* ---- Public Function Prototypes ---------------------------------------- */
- /* ---- Private Function Prototypes --------------------------------------- */
- static inline void chipcHw_setClock(chipcHw_CLOCK_e clock,
- chipcHw_OPTYPE_e type, int mode);
- /****************************************************************************/
- /**
- * @brief Get Numeric Chip ID
- *
- * This function returns Chip ID that includes the revison number
- *
- * @return Complete numeric Chip ID
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getChipId(void)
- {
- return pChipcHw->ChipId;
- }
- /****************************************************************************/
- /**
- * @brief Enable Spread Spectrum
- *
- * @note chipcHw_Init() must be called earlier
- */
- /****************************************************************************/
- static inline void chipcHw_enableSpreadSpectrum(void)
- {
- if ((pChipcHw->
- PLLPreDivider & chipcHw_REG_PLL_PREDIVIDER_NDIV_MODE_MASK) !=
- chipcHw_REG_PLL_PREDIVIDER_NDIV_MODE_INTEGER) {
- ddrcReg_PHY_ADDR_CTL_REGP->ssCfg =
- (0xFFFF << ddrcReg_PHY_ADDR_SS_CFG_NDIV_AMPLITUDE_SHIFT) |
- (ddrcReg_PHY_ADDR_SS_CFG_MIN_CYCLE_PER_TICK <<
- ddrcReg_PHY_ADDR_SS_CFG_CYCLE_PER_TICK_SHIFT);
- ddrcReg_PHY_ADDR_CTL_REGP->ssCtl |=
- ddrcReg_PHY_ADDR_SS_CTRL_ENABLE;
- }
- }
- /****************************************************************************/
- /**
- * @brief Disable Spread Spectrum
- *
- */
- /****************************************************************************/
- static inline void chipcHw_disableSpreadSpectrum(void)
- {
- ddrcReg_PHY_ADDR_CTL_REGP->ssCtl &= ~ddrcReg_PHY_ADDR_SS_CTRL_ENABLE;
- }
- /****************************************************************************/
- /**
- * @brief Get Chip Product ID
- *
- * This function returns Chip Product ID
- *
- * @return Chip Product ID
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getChipProductId(void)
- {
- return (pChipcHw->
- ChipId & chipcHw_REG_CHIPID_BASE_MASK) >>
- chipcHw_REG_CHIPID_BASE_SHIFT;
- }
- /****************************************************************************/
- /**
- * @brief Get revision number
- *
- * This function returns revision number of the chip
- *
- * @return Revision number
- */
- /****************************************************************************/
- static inline chipcHw_REV_NUMBER_e chipcHw_getChipRevisionNumber(void)
- {
- return pChipcHw->ChipId & chipcHw_REG_CHIPID_REV_MASK;
- }
- /****************************************************************************/
- /**
- * @brief Enables bus interface clock
- *
- * Enables bus interface clock of various device
- *
- * @return void
- *
- * @note use chipcHw_REG_BUS_CLOCK_XXXX for mask
- */
- /****************************************************************************/
- static inline void chipcHw_busInterfaceClockEnable(uint32_t mask)
- {
- reg32_modify_or(&pChipcHw->BusIntfClock, mask);
- }
- /****************************************************************************/
- /**
- * @brief Disables bus interface clock
- *
- * Disables bus interface clock of various device
- *
- * @return void
- *
- * @note use chipcHw_REG_BUS_CLOCK_XXXX
- */
- /****************************************************************************/
- static inline void chipcHw_busInterfaceClockDisable(uint32_t mask)
- {
- reg32_modify_and(&pChipcHw->BusIntfClock, ~mask);
- }
- /****************************************************************************/
- /**
- * @brief Get status (enabled/disabled) of bus interface clock
- *
- * This function returns the status of devices' bus interface clock
- *
- * @return Bus interface clock
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getBusInterfaceClockStatus(void)
- {
- return pChipcHw->BusIntfClock;
- }
- /****************************************************************************/
- /**
- * @brief Enables various audio channels
- *
- * Enables audio channel
- *
- * @return void
- *
- * @note use chipcHw_REG_AUDIO_CHANNEL_XXXXXX
- */
- /****************************************************************************/
- static inline void chipcHw_audioChannelEnable(uint32_t mask)
- {
- reg32_modify_or(&pChipcHw->AudioEnable, mask);
- }
- /****************************************************************************/
- /**
- * @brief Disables various audio channels
- *
- * Disables audio channel
- *
- * @return void
- *
- * @note use chipcHw_REG_AUDIO_CHANNEL_XXXXXX
- */
- /****************************************************************************/
- static inline void chipcHw_audioChannelDisable(uint32_t mask)
- {
- reg32_modify_and(&pChipcHw->AudioEnable, ~mask);
- }
- /****************************************************************************/
- /**
- * @brief Soft resets devices
- *
- * Soft resets various devices
- *
- * @return void
- *
- * @note use chipcHw_REG_SOFT_RESET_XXXXXX defines
- */
- /****************************************************************************/
- static inline void chipcHw_softReset(uint64_t mask)
- {
- chipcHw_softResetEnable(mask);
- chipcHw_softResetDisable(mask);
- }
- static inline void chipcHw_softResetDisable(uint64_t mask)
- {
- uint32_t ctrl1 = (uint32_t) mask;
- uint32_t ctrl2 = (uint32_t) (mask >> 32);
- /* Deassert module soft reset */
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->SoftReset1 ^= ctrl1;
- pChipcHw->SoftReset2 ^= (ctrl2 & (~chipcHw_REG_SOFT_RESET_UNHOLD_MASK));
- REG_LOCAL_IRQ_RESTORE;
- }
- static inline void chipcHw_softResetEnable(uint64_t mask)
- {
- uint32_t ctrl1 = (uint32_t) mask;
- uint32_t ctrl2 = (uint32_t) (mask >> 32);
- uint32_t unhold = 0;
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->SoftReset1 |= ctrl1;
- /* Mask out unhold request bits */
- pChipcHw->SoftReset2 |= (ctrl2 & (~chipcHw_REG_SOFT_RESET_UNHOLD_MASK));
- /* Process unhold requests */
- if (ctrl2 & chipcHw_REG_SOFT_RESET_VPM_GLOBAL_UNHOLD) {
- unhold = chipcHw_REG_SOFT_RESET_VPM_GLOBAL_HOLD;
- }
- if (ctrl2 & chipcHw_REG_SOFT_RESET_VPM_UNHOLD) {
- unhold |= chipcHw_REG_SOFT_RESET_VPM_HOLD;
- }
- if (ctrl2 & chipcHw_REG_SOFT_RESET_ARM_UNHOLD) {
- unhold |= chipcHw_REG_SOFT_RESET_ARM_HOLD;
- }
- if (unhold) {
- /* Make sure unhold request is effective */
- pChipcHw->SoftReset1 &= ~unhold;
- }
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Configures misc CHIP functionality
- *
- * Configures CHIP functionality
- *
- * @return void
- *
- * @note use chipcHw_REG_MISC_CTRL_XXXXXX
- */
- /****************************************************************************/
- static inline void chipcHw_miscControl(uint32_t mask)
- {
- reg32_write(&pChipcHw->MiscCtrl, mask);
- }
- static inline void chipcHw_miscControlDisable(uint32_t mask)
- {
- reg32_modify_and(&pChipcHw->MiscCtrl, ~mask);
- }
- static inline void chipcHw_miscControlEnable(uint32_t mask)
- {
- reg32_modify_or(&pChipcHw->MiscCtrl, mask);
- }
- /****************************************************************************/
- /**
- * @brief Set OTP options
- *
- * Set OTP options
- *
- * @return void
- *
- * @note use chipcHw_REG_OTP_XXXXXX
- */
- /****************************************************************************/
- static inline void chipcHw_setOTPOption(uint64_t mask)
- {
- uint32_t ctrl1 = (uint32_t) mask;
- uint32_t ctrl2 = (uint32_t) (mask >> 32);
- reg32_modify_or(&pChipcHw->SoftOTP1, ctrl1);
- reg32_modify_or(&pChipcHw->SoftOTP2, ctrl2);
- }
- /****************************************************************************/
- /**
- * @brief Get sticky bits
- *
- * @return Sticky bit options of type chipcHw_REG_STICKY_XXXXXX
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getStickyBits(void)
- {
- return pChipcHw->Sticky;
- }
- /****************************************************************************/
- /**
- * @brief Set sticky bits
- *
- * @return void
- *
- * @note use chipcHw_REG_STICKY_XXXXXX
- */
- /****************************************************************************/
- static inline void chipcHw_setStickyBits(uint32_t mask)
- {
- uint32_t bits = 0;
- REG_LOCAL_IRQ_SAVE;
- if (mask & chipcHw_REG_STICKY_POR_BROM) {
- bits |= chipcHw_REG_STICKY_POR_BROM;
- } else {
- uint32_t sticky;
- sticky = pChipcHw->Sticky;
- if ((mask & chipcHw_REG_STICKY_BOOT_DONE)
- && (sticky & chipcHw_REG_STICKY_BOOT_DONE) == 0) {
- bits |= chipcHw_REG_STICKY_BOOT_DONE;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_1)
- && (sticky & chipcHw_REG_STICKY_GENERAL_1) == 0) {
- bits |= chipcHw_REG_STICKY_GENERAL_1;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_2)
- && (sticky & chipcHw_REG_STICKY_GENERAL_2) == 0) {
- bits |= chipcHw_REG_STICKY_GENERAL_2;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_3)
- && (sticky & chipcHw_REG_STICKY_GENERAL_3) == 0) {
- bits |= chipcHw_REG_STICKY_GENERAL_3;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_4)
- && (sticky & chipcHw_REG_STICKY_GENERAL_4) == 0) {
- bits |= chipcHw_REG_STICKY_GENERAL_4;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_5)
- && (sticky & chipcHw_REG_STICKY_GENERAL_5) == 0) {
- bits |= chipcHw_REG_STICKY_GENERAL_5;
- }
- }
- pChipcHw->Sticky = bits;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Clear sticky bits
- *
- * @return void
- *
- * @note use chipcHw_REG_STICKY_XXXXXX
- */
- /****************************************************************************/
- static inline void chipcHw_clearStickyBits(uint32_t mask)
- {
- uint32_t bits = 0;
- REG_LOCAL_IRQ_SAVE;
- if (mask &
- (chipcHw_REG_STICKY_BOOT_DONE | chipcHw_REG_STICKY_GENERAL_1 |
- chipcHw_REG_STICKY_GENERAL_2 | chipcHw_REG_STICKY_GENERAL_3 |
- chipcHw_REG_STICKY_GENERAL_4 | chipcHw_REG_STICKY_GENERAL_5)) {
- uint32_t sticky = pChipcHw->Sticky;
- if ((mask & chipcHw_REG_STICKY_BOOT_DONE)
- && (sticky & chipcHw_REG_STICKY_BOOT_DONE)) {
- bits = chipcHw_REG_STICKY_BOOT_DONE;
- mask &= ~chipcHw_REG_STICKY_BOOT_DONE;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_1)
- && (sticky & chipcHw_REG_STICKY_GENERAL_1)) {
- bits |= chipcHw_REG_STICKY_GENERAL_1;
- mask &= ~chipcHw_REG_STICKY_GENERAL_1;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_2)
- && (sticky & chipcHw_REG_STICKY_GENERAL_2)) {
- bits |= chipcHw_REG_STICKY_GENERAL_2;
- mask &= ~chipcHw_REG_STICKY_GENERAL_2;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_3)
- && (sticky & chipcHw_REG_STICKY_GENERAL_3)) {
- bits |= chipcHw_REG_STICKY_GENERAL_3;
- mask &= ~chipcHw_REG_STICKY_GENERAL_3;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_4)
- && (sticky & chipcHw_REG_STICKY_GENERAL_4)) {
- bits |= chipcHw_REG_STICKY_GENERAL_4;
- mask &= ~chipcHw_REG_STICKY_GENERAL_4;
- }
- if ((mask & chipcHw_REG_STICKY_GENERAL_5)
- && (sticky & chipcHw_REG_STICKY_GENERAL_5)) {
- bits |= chipcHw_REG_STICKY_GENERAL_5;
- mask &= ~chipcHw_REG_STICKY_GENERAL_5;
- }
- }
- pChipcHw->Sticky = bits | mask;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Get software strap value
- *
- * Retrieves software strap value
- *
- * @return Software strap value
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getSoftStraps(void)
- {
- return pChipcHw->SoftStraps;
- }
- /****************************************************************************/
- /**
- * @brief Set software override strap options
- *
- * set software override strap options
- *
- * @return nothing
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setSoftStraps(uint32_t strapOptions)
- {
- reg32_write(&pChipcHw->SoftStraps, strapOptions);
- }
- /****************************************************************************/
- /**
- * @brief Get Pin Strap Options
- *
- * This function returns the raw boot strap options
- *
- * @return strap options
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getPinStraps(void)
- {
- return pChipcHw->PinStraps;
- }
- /****************************************************************************/
- /**
- * @brief Get Valid Strap Options
- *
- * This function returns the valid raw boot strap options
- *
- * @return strap options
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getValidStraps(void)
- {
- uint32_t softStraps;
- /*
- ** Always return the SoftStraps - bootROM calls chipcHw_initValidStraps
- ** which copies HW straps to soft straps if there is no override
- */
- softStraps = chipcHw_getSoftStraps();
- return softStraps;
- }
- /****************************************************************************/
- /**
- * @brief Initialize valid pin strap options
- *
- * Retrieves valid pin strap options by copying HW strap options to soft register
- * (if chipcHw_STRAPS_SOFT_OVERRIDE not set)
- *
- * @return nothing
- *
- */
- /****************************************************************************/
- static inline void chipcHw_initValidStraps(void)
- {
- uint32_t softStraps;
- REG_LOCAL_IRQ_SAVE;
- softStraps = chipcHw_getSoftStraps();
- if ((softStraps & chipcHw_STRAPS_SOFT_OVERRIDE) == 0) {
- /* Copy HW straps to software straps */
- chipcHw_setSoftStraps(chipcHw_getPinStraps());
- }
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Get boot device
- *
- * This function returns the device type used in booting the system
- *
- * @return Boot device of type chipcHw_BOOT_DEVICE
- *
- */
- /****************************************************************************/
- static inline chipcHw_BOOT_DEVICE_e chipcHw_getBootDevice(void)
- {
- return chipcHw_getValidStraps() & chipcHw_STRAPS_BOOT_DEVICE_MASK;
- }
- /****************************************************************************/
- /**
- * @brief Get boot mode
- *
- * This function returns the way the system was booted
- *
- * @return Boot mode of type chipcHw_BOOT_MODE
- *
- */
- /****************************************************************************/
- static inline chipcHw_BOOT_MODE_e chipcHw_getBootMode(void)
- {
- return chipcHw_getValidStraps() & chipcHw_STRAPS_BOOT_MODE_MASK;
- }
- /****************************************************************************/
- /**
- * @brief Get NAND flash page size
- *
- * This function returns the NAND device page size
- *
- * @return Boot NAND device page size
- *
- */
- /****************************************************************************/
- static inline chipcHw_NAND_PAGESIZE_e chipcHw_getNandPageSize(void)
- {
- return chipcHw_getValidStraps() & chipcHw_STRAPS_NAND_PAGESIZE_MASK;
- }
- /****************************************************************************/
- /**
- * @brief Get NAND flash address cycle configuration
- *
- * This function returns the NAND flash address cycle configuration
- *
- * @return 0 = Do not extra address cycle, 1 = Add extra cycle
- *
- */
- /****************************************************************************/
- static inline int chipcHw_getNandExtraCycle(void)
- {
- if (chipcHw_getValidStraps() & chipcHw_STRAPS_NAND_EXTRA_CYCLE) {
- return 1;
- } else {
- return 0;
- }
- }
- /****************************************************************************/
- /**
- * @brief Activates PIF interface
- *
- * This function activates PIF interface by taking control of LCD pins
- *
- * @note
- * When activated, LCD pins will be defined as follows for PIF operation
- *
- * CLD[17:0] = pif_data[17:0]
- * CLD[23:18] = pif_address[5:0]
- * CLPOWER = pif_wr_str
- * CLCP = pif_rd_str
- * CLAC = pif_hat1
- * CLFP = pif_hrdy1
- * CLLP = pif_hat2
- * GPIO[42] = pif_hrdy2
- *
- * In PIF mode, "pif_hrdy2" overrides other shared function for GPIO[42] pin
- *
- */
- /****************************************************************************/
- static inline void chipcHw_activatePifInterface(void)
- {
- reg32_write(&pChipcHw->LcdPifMode, chipcHw_REG_PIF_PIN_ENABLE);
- }
- /****************************************************************************/
- /**
- * @brief Activates LCD interface
- *
- * This function activates LCD interface
- *
- * @note
- * When activated, LCD pins will be defined as follows
- *
- * CLD[17:0] = LCD data
- * CLD[23:18] = LCD data
- * CLPOWER = LCD power
- * CLCP =
- * CLAC = LCD ack
- * CLFP =
- * CLLP =
- */
- /****************************************************************************/
- static inline void chipcHw_activateLcdInterface(void)
- {
- reg32_write(&pChipcHw->LcdPifMode, chipcHw_REG_LCD_PIN_ENABLE);
- }
- /****************************************************************************/
- /**
- * @brief Deactivates PIF/LCD interface
- *
- * This function deactivates PIF/LCD interface
- *
- * @note
- * When deactivated LCD pins will be in rti-stated
- *
- */
- /****************************************************************************/
- static inline void chipcHw_deactivatePifLcdInterface(void)
- {
- reg32_write(&pChipcHw->LcdPifMode, 0);
- }
- /****************************************************************************/
- /**
- * @brief Select GE2
- *
- * This function select GE2 as the graphic engine
- *
- */
- /****************************************************************************/
- static inline void chipcHw_selectGE2(void)
- {
- reg32_modify_and(&pChipcHw->MiscCtrl, ~chipcHw_REG_MISC_CTRL_GE_SEL);
- }
- /****************************************************************************/
- /**
- * @brief Select GE3
- *
- * This function select GE3 as the graphic engine
- *
- */
- /****************************************************************************/
- static inline void chipcHw_selectGE3(void)
- {
- reg32_modify_or(&pChipcHw->MiscCtrl, chipcHw_REG_MISC_CTRL_GE_SEL);
- }
- /****************************************************************************/
- /**
- * @brief Get to know the configuration of GPIO pin
- *
- */
- /****************************************************************************/
- static inline chipcHw_GPIO_FUNCTION_e chipcHw_getGpioPinFunction(int pin)
- {
- return (*((uint32_t *) chipcHw_REG_GPIO_MUX(pin)) &
- (chipcHw_REG_GPIO_MUX_MASK <<
- chipcHw_REG_GPIO_MUX_POSITION(pin))) >>
- chipcHw_REG_GPIO_MUX_POSITION(pin);
- }
- /****************************************************************************/
- /**
- * @brief Configure GPIO pin function
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setGpioPinFunction(int pin,
- chipcHw_GPIO_FUNCTION_e func)
- {
- REG_LOCAL_IRQ_SAVE;
- *((uint32_t *) chipcHw_REG_GPIO_MUX(pin)) &=
- ~(chipcHw_REG_GPIO_MUX_MASK << chipcHw_REG_GPIO_MUX_POSITION(pin));
- *((uint32_t *) chipcHw_REG_GPIO_MUX(pin)) |=
- func << chipcHw_REG_GPIO_MUX_POSITION(pin);
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Set Pin slew rate
- *
- * This function sets the slew of individual pin
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setPinSlewRate(uint32_t pin,
- chipcHw_PIN_SLEW_RATE_e slewRate)
- {
- REG_LOCAL_IRQ_SAVE;
- *((uint32_t *) chipcHw_REG_SLEW_RATE(pin)) &=
- ~(chipcHw_REG_SLEW_RATE_MASK <<
- chipcHw_REG_SLEW_RATE_POSITION(pin));
- *((uint32_t *) chipcHw_REG_SLEW_RATE(pin)) |=
- (uint32_t) slewRate << chipcHw_REG_SLEW_RATE_POSITION(pin);
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Set Pin output drive current
- *
- * This function sets output drive current of individual pin
- *
- * Note: Avoid the use of the word 'current' since linux headers define this
- * to be the current task.
- */
- /****************************************************************************/
- static inline void chipcHw_setPinOutputCurrent(uint32_t pin,
- chipcHw_PIN_CURRENT_STRENGTH_e
- curr)
- {
- REG_LOCAL_IRQ_SAVE;
- *((uint32_t *) chipcHw_REG_CURRENT(pin)) &=
- ~(chipcHw_REG_CURRENT_MASK << chipcHw_REG_CURRENT_POSITION(pin));
- *((uint32_t *) chipcHw_REG_CURRENT(pin)) |=
- (uint32_t) curr << chipcHw_REG_CURRENT_POSITION(pin);
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Set Pin pullup register
- *
- * This function sets pullup register of individual pin
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setPinPullup(uint32_t pin, chipcHw_PIN_PULL_e pullup)
- {
- REG_LOCAL_IRQ_SAVE;
- *((uint32_t *) chipcHw_REG_PULLUP(pin)) &=
- ~(chipcHw_REG_PULLUP_MASK << chipcHw_REG_PULLUP_POSITION(pin));
- *((uint32_t *) chipcHw_REG_PULLUP(pin)) |=
- (uint32_t) pullup << chipcHw_REG_PULLUP_POSITION(pin);
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Set Pin input type
- *
- * This function sets input type of individual pin
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setPinInputType(uint32_t pin,
- chipcHw_PIN_INPUTTYPE_e inputType)
- {
- REG_LOCAL_IRQ_SAVE;
- *((uint32_t *) chipcHw_REG_INPUTTYPE(pin)) &=
- ~(chipcHw_REG_INPUTTYPE_MASK <<
- chipcHw_REG_INPUTTYPE_POSITION(pin));
- *((uint32_t *) chipcHw_REG_INPUTTYPE(pin)) |=
- (uint32_t) inputType << chipcHw_REG_INPUTTYPE_POSITION(pin);
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Power up the USB PHY
- *
- * This function powers up the USB PHY
- *
- */
- /****************************************************************************/
- static inline void chipcHw_powerUpUsbPhy(void)
- {
- reg32_modify_and(&pChipcHw->MiscCtrl,
- chipcHw_REG_MISC_CTRL_USB_POWERON);
- }
- /****************************************************************************/
- /**
- * @brief Power down the USB PHY
- *
- * This function powers down the USB PHY
- *
- */
- /****************************************************************************/
- static inline void chipcHw_powerDownUsbPhy(void)
- {
- reg32_modify_or(&pChipcHw->MiscCtrl,
- chipcHw_REG_MISC_CTRL_USB_POWEROFF);
- }
- /****************************************************************************/
- /**
- * @brief Set the 2nd USB as host
- *
- * This function sets the 2nd USB as host
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setUsbHost(void)
- {
- reg32_modify_or(&pChipcHw->MiscCtrl,
- chipcHw_REG_MISC_CTRL_USB_MODE_HOST);
- }
- /****************************************************************************/
- /**
- * @brief Set the 2nd USB as device
- *
- * This function sets the 2nd USB as device
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setUsbDevice(void)
- {
- reg32_modify_and(&pChipcHw->MiscCtrl,
- chipcHw_REG_MISC_CTRL_USB_MODE_DEVICE);
- }
- /****************************************************************************/
- /**
- * @brief Lower layer funtion to enable/disable a clock of a certain device
- *
- * This function enables/disables a core clock
- *
- */
- /****************************************************************************/
- static inline void chipcHw_setClock(chipcHw_CLOCK_e clock,
- chipcHw_OPTYPE_e type, int mode)
- {
- volatile uint32_t *pPLLReg = (uint32_t *) 0x0;
- volatile uint32_t *pClockCtrl = (uint32_t *) 0x0;
- switch (clock) {
- case chipcHw_CLOCK_DDR:
- pPLLReg = &pChipcHw->DDRClock;
- break;
- case chipcHw_CLOCK_ARM:
- pPLLReg = &pChipcHw->ARMClock;
- break;
- case chipcHw_CLOCK_ESW:
- pPLLReg = &pChipcHw->ESWClock;
- break;
- case chipcHw_CLOCK_VPM:
- pPLLReg = &pChipcHw->VPMClock;
- break;
- case chipcHw_CLOCK_ESW125:
- pPLLReg = &pChipcHw->ESW125Clock;
- break;
- case chipcHw_CLOCK_UART:
- pPLLReg = &pChipcHw->UARTClock;
- break;
- case chipcHw_CLOCK_SDIO0:
- pPLLReg = &pChipcHw->SDIO0Clock;
- break;
- case chipcHw_CLOCK_SDIO1:
- pPLLReg = &pChipcHw->SDIO1Clock;
- break;
- case chipcHw_CLOCK_SPI:
- pPLLReg = &pChipcHw->SPIClock;
- break;
- case chipcHw_CLOCK_ETM:
- pPLLReg = &pChipcHw->ETMClock;
- break;
- case chipcHw_CLOCK_USB:
- pPLLReg = &pChipcHw->USBClock;
- if (type == chipcHw_OPTYPE_OUTPUT) {
- if (mode) {
- reg32_modify_and(pPLLReg,
- ~chipcHw_REG_PLL_CLOCK_POWER_DOWN);
- } else {
- reg32_modify_or(pPLLReg,
- chipcHw_REG_PLL_CLOCK_POWER_DOWN);
- }
- }
- break;
- case chipcHw_CLOCK_LCD:
- pPLLReg = &pChipcHw->LCDClock;
- if (type == chipcHw_OPTYPE_OUTPUT) {
- if (mode) {
- reg32_modify_and(pPLLReg,
- ~chipcHw_REG_PLL_CLOCK_POWER_DOWN);
- } else {
- reg32_modify_or(pPLLReg,
- chipcHw_REG_PLL_CLOCK_POWER_DOWN);
- }
- }
- break;
- case chipcHw_CLOCK_APM:
- pPLLReg = &pChipcHw->APMClock;
- if (type == chipcHw_OPTYPE_OUTPUT) {
- if (mode) {
- reg32_modify_and(pPLLReg,
- ~chipcHw_REG_PLL_CLOCK_POWER_DOWN);
- } else {
- reg32_modify_or(pPLLReg,
- chipcHw_REG_PLL_CLOCK_POWER_DOWN);
- }
- }
- break;
- case chipcHw_CLOCK_BUS:
- pClockCtrl = &pChipcHw->ACLKClock;
- break;
- case chipcHw_CLOCK_OTP:
- pClockCtrl = &pChipcHw->OTPClock;
- break;
- case chipcHw_CLOCK_I2C:
- pClockCtrl = &pChipcHw->I2CClock;
- break;
- case chipcHw_CLOCK_I2S0:
- pClockCtrl = &pChipcHw->I2S0Clock;
- break;
- case chipcHw_CLOCK_RTBUS:
- pClockCtrl = &pChipcHw->RTBUSClock;
- break;
- case chipcHw_CLOCK_APM100:
- pClockCtrl = &pChipcHw->APM100Clock;
- break;
- case chipcHw_CLOCK_TSC:
- pClockCtrl = &pChipcHw->TSCClock;
- break;
- case chipcHw_CLOCK_LED:
- pClockCtrl = &pChipcHw->LEDClock;
- break;
- case chipcHw_CLOCK_I2S1:
- pClockCtrl = &pChipcHw->I2S1Clock;
- break;
- }
- if (pPLLReg) {
- switch (type) {
- case chipcHw_OPTYPE_OUTPUT:
- /* PLL clock output enable/disable */
- if (mode) {
- if (clock == chipcHw_CLOCK_DDR) {
- /* DDR clock enable is inverted */
- reg32_modify_and(pPLLReg,
- ~chipcHw_REG_PLL_CLOCK_OUTPUT_ENABLE);
- } else {
- reg32_modify_or(pPLLReg,
- chipcHw_REG_PLL_CLOCK_OUTPUT_ENABLE);
- }
- } else {
- if (clock == chipcHw_CLOCK_DDR) {
- /* DDR clock disable is inverted */
- reg32_modify_or(pPLLReg,
- chipcHw_REG_PLL_CLOCK_OUTPUT_ENABLE);
- } else {
- reg32_modify_and(pPLLReg,
- ~chipcHw_REG_PLL_CLOCK_OUTPUT_ENABLE);
- }
- }
- break;
- case chipcHw_OPTYPE_BYPASS:
- /* PLL clock bypass enable/disable */
- if (mode) {
- reg32_modify_or(pPLLReg,
- chipcHw_REG_PLL_CLOCK_BYPASS_SELECT);
- } else {
- reg32_modify_and(pPLLReg,
- ~chipcHw_REG_PLL_CLOCK_BYPASS_SELECT);
- }
- break;
- }
- } else if (pClockCtrl) {
- switch (type) {
- case chipcHw_OPTYPE_OUTPUT:
- if (mode) {
- reg32_modify_or(pClockCtrl,
- chipcHw_REG_DIV_CLOCK_OUTPUT_ENABLE);
- } else {
- reg32_modify_and(pClockCtrl,
- ~chipcHw_REG_DIV_CLOCK_OUTPUT_ENABLE);
- }
- break;
- case chipcHw_OPTYPE_BYPASS:
- if (mode) {
- reg32_modify_or(pClockCtrl,
- chipcHw_REG_DIV_CLOCK_BYPASS_SELECT);
- } else {
- reg32_modify_and(pClockCtrl,
- ~chipcHw_REG_DIV_CLOCK_BYPASS_SELECT);
- }
- break;
- }
- }
- }
- /****************************************************************************/
- /**
- * @brief Disables a core clock of a certain device
- *
- * This function disables a core clock
- *
- * @note no change in power consumption
- */
- /****************************************************************************/
- static inline void chipcHw_setClockDisable(chipcHw_CLOCK_e clock)
- {
- /* Disable output of the clock */
- chipcHw_setClock(clock, chipcHw_OPTYPE_OUTPUT, 0);
- }
- /****************************************************************************/
- /**
- * @brief Enable a core clock of a certain device
- *
- * This function enables a core clock
- *
- * @note no change in power consumption
- */
- /****************************************************************************/
- static inline void chipcHw_setClockEnable(chipcHw_CLOCK_e clock)
- {
- /* Enable output of the clock */
- chipcHw_setClock(clock, chipcHw_OPTYPE_OUTPUT, 1);
- }
- /****************************************************************************/
- /**
- * @brief Enables bypass clock of a certain device
- *
- * This function enables bypass clock
- *
- * @note Doesnot affect the bus interface clock
- */
- /****************************************************************************/
- static inline void chipcHw_bypassClockEnable(chipcHw_CLOCK_e clock)
- {
- /* Enable bypass clock */
- chipcHw_setClock(clock, chipcHw_OPTYPE_BYPASS, 1);
- }
- /****************************************************************************/
- /**
- * @brief Disabled bypass clock of a certain device
- *
- * This function disables bypass clock
- *
- * @note Doesnot affect the bus interface clock
- */
- /****************************************************************************/
- static inline void chipcHw_bypassClockDisable(chipcHw_CLOCK_e clock)
- {
- /* Disable bypass clock */
- chipcHw_setClock(clock, chipcHw_OPTYPE_BYPASS, 0);
- }
- /****************************************************************************/
- /** @brief Checks if software strap is enabled
- *
- * @return 1 : When enable
- * 0 : When disable
- */
- /****************************************************************************/
- static inline int chipcHw_isSoftwareStrapsEnable(void)
- {
- return pChipcHw->SoftStraps & 0x00000001;
- }
- /****************************************************************************/
- /** @brief Enable software strap
- */
- /****************************************************************************/
- static inline void chipcHw_softwareStrapsEnable(void)
- {
- reg32_modify_or(&pChipcHw->SoftStraps, 0x00000001);
- }
- /****************************************************************************/
- /** @brief Disable software strap
- */
- /****************************************************************************/
- static inline void chipcHw_softwareStrapsDisable(void)
- {
- reg32_modify_and(&pChipcHw->SoftStraps, (~0x00000001));
- }
- /****************************************************************************/
- /** @brief PLL test enable
- */
- /****************************************************************************/
- static inline void chipcHw_pllTestEnable(void)
- {
- reg32_modify_or(&pChipcHw->PLLConfig,
- chipcHw_REG_PLL_CONFIG_TEST_ENABLE);
- }
- /****************************************************************************/
- /** @brief PLL2 test enable
- */
- /****************************************************************************/
- static inline void chipcHw_pll2TestEnable(void)
- {
- reg32_modify_or(&pChipcHw->PLLConfig2,
- chipcHw_REG_PLL_CONFIG_TEST_ENABLE);
- }
- /****************************************************************************/
- /** @brief PLL test disable
- */
- /****************************************************************************/
- static inline void chipcHw_pllTestDisable(void)
- {
- reg32_modify_and(&pChipcHw->PLLConfig,
- ~chipcHw_REG_PLL_CONFIG_TEST_ENABLE);
- }
- /****************************************************************************/
- /** @brief PLL2 test disable
- */
- /****************************************************************************/
- static inline void chipcHw_pll2TestDisable(void)
- {
- reg32_modify_and(&pChipcHw->PLLConfig2,
- ~chipcHw_REG_PLL_CONFIG_TEST_ENABLE);
- }
- /****************************************************************************/
- /** @brief Get PLL test status
- */
- /****************************************************************************/
- static inline int chipcHw_isPllTestEnable(void)
- {
- return pChipcHw->PLLConfig & chipcHw_REG_PLL_CONFIG_TEST_ENABLE;
- }
- /****************************************************************************/
- /** @brief Get PLL2 test status
- */
- /****************************************************************************/
- static inline int chipcHw_isPll2TestEnable(void)
- {
- return pChipcHw->PLLConfig2 & chipcHw_REG_PLL_CONFIG_TEST_ENABLE;
- }
- /****************************************************************************/
- /** @brief PLL test select
- */
- /****************************************************************************/
- static inline void chipcHw_pllTestSelect(uint32_t val)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->PLLConfig &= ~chipcHw_REG_PLL_CONFIG_TEST_SELECT_MASK;
- pChipcHw->PLLConfig |=
- (val) << chipcHw_REG_PLL_CONFIG_TEST_SELECT_SHIFT;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /** @brief PLL2 test select
- */
- /****************************************************************************/
- static inline void chipcHw_pll2TestSelect(uint32_t val)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->PLLConfig2 &= ~chipcHw_REG_PLL_CONFIG_TEST_SELECT_MASK;
- pChipcHw->PLLConfig2 |=
- (val) << chipcHw_REG_PLL_CONFIG_TEST_SELECT_SHIFT;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /** @brief Get PLL test selected option
- */
- /****************************************************************************/
- static inline uint8_t chipcHw_getPllTestSelected(void)
- {
- return (uint8_t) ((pChipcHw->
- PLLConfig & chipcHw_REG_PLL_CONFIG_TEST_SELECT_MASK)
- >> chipcHw_REG_PLL_CONFIG_TEST_SELECT_SHIFT);
- }
- /****************************************************************************/
- /** @brief Get PLL2 test selected option
- */
- /****************************************************************************/
- static inline uint8_t chipcHw_getPll2TestSelected(void)
- {
- return (uint8_t) ((pChipcHw->
- PLLConfig2 & chipcHw_REG_PLL_CONFIG_TEST_SELECT_MASK)
- >> chipcHw_REG_PLL_CONFIG_TEST_SELECT_SHIFT);
- }
- /****************************************************************************/
- /**
- * @brief Disable the PLL1
- *
- */
- /****************************************************************************/
- static inline void chipcHw_pll1Disable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->PLLConfig |= chipcHw_REG_PLL_CONFIG_POWER_DOWN;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Disable the PLL2
- *
- */
- /****************************************************************************/
- static inline void chipcHw_pll2Disable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->PLLConfig2 |= chipcHw_REG_PLL_CONFIG_POWER_DOWN;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Enables DDR SW phase alignment interrupt
- */
- /****************************************************************************/
- static inline void chipcHw_ddrPhaseAlignInterruptEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->Spare1 |= chipcHw_REG_SPARE1_DDR_PHASE_INTR_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Disables DDR SW phase alignment interrupt
- */
- /****************************************************************************/
- static inline void chipcHw_ddrPhaseAlignInterruptDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->Spare1 &= ~chipcHw_REG_SPARE1_DDR_PHASE_INTR_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Set VPM SW phase alignment interrupt mode
- *
- * This function sets VPM phase alignment interrupt
- */
- /****************************************************************************/
- static inline void
- chipcHw_vpmPhaseAlignInterruptMode(chipcHw_VPM_HW_PHASE_INTR_e mode)
- {
- REG_LOCAL_IRQ_SAVE;
- if (mode == chipcHw_VPM_HW_PHASE_INTR_DISABLE) {
- pChipcHw->Spare1 &= ~chipcHw_REG_SPARE1_VPM_PHASE_INTR_ENABLE;
- } else {
- pChipcHw->Spare1 |= chipcHw_REG_SPARE1_VPM_PHASE_INTR_ENABLE;
- }
- pChipcHw->VPMPhaseCtrl2 =
- (pChipcHw->
- VPMPhaseCtrl2 & ~(chipcHw_REG_VPM_INTR_SELECT_MASK <<
- chipcHw_REG_VPM_INTR_SELECT_SHIFT)) | mode;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Enable DDR phase alignment in software
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrSwPhaseAlignEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl1 |= chipcHw_REG_DDR_SW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Disable DDR phase alignment in software
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrSwPhaseAlignDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl1 &= ~chipcHw_REG_DDR_SW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Enable DDR phase alignment in hardware
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrHwPhaseAlignEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl1 |= chipcHw_REG_DDR_HW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Disable DDR phase alignment in hardware
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrHwPhaseAlignDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl1 &= ~chipcHw_REG_DDR_HW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Enable VPM phase alignment in software
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmSwPhaseAlignEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl1 |= chipcHw_REG_VPM_SW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Disable VPM phase alignment in software
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmSwPhaseAlignDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl1 &= ~chipcHw_REG_VPM_SW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Enable VPM phase alignment in hardware
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmHwPhaseAlignEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl1 |= chipcHw_REG_VPM_HW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Disable VPM phase alignment in hardware
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmHwPhaseAlignDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl1 &= ~chipcHw_REG_VPM_HW_PHASE_CTRL_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Set DDR phase alignment margin in hardware
- *
- */
- /****************************************************************************/
- static inline void
- chipcHw_setDdrHwPhaseAlignMargin(chipcHw_DDR_HW_PHASE_MARGIN_e margin)
- {
- uint32_t ge = 0;
- uint32_t le = 0;
- switch (margin) {
- case chipcHw_DDR_HW_PHASE_MARGIN_STRICT:
- ge = 0x0F;
- le = 0x0F;
- break;
- case chipcHw_DDR_HW_PHASE_MARGIN_MEDIUM:
- ge = 0x03;
- le = 0x3F;
- break;
- case chipcHw_DDR_HW_PHASE_MARGIN_WIDE:
- ge = 0x01;
- le = 0x7F;
- break;
- }
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl1 &=
- ~((chipcHw_REG_DDR_PHASE_VALUE_GE_MASK <<
- chipcHw_REG_DDR_PHASE_VALUE_GE_SHIFT)
- || (chipcHw_REG_DDR_PHASE_VALUE_LE_MASK <<
- chipcHw_REG_DDR_PHASE_VALUE_LE_SHIFT));
- pChipcHw->DDRPhaseCtrl1 |=
- ((ge << chipcHw_REG_DDR_PHASE_VALUE_GE_SHIFT)
- || (le << chipcHw_REG_DDR_PHASE_VALUE_LE_SHIFT));
- REG_LOCAL_IRQ_RESTORE;
- }
- }
- /****************************************************************************/
- /**
- * @brief Set VPM phase alignment margin in hardware
- *
- */
- /****************************************************************************/
- static inline void
- chipcHw_setVpmHwPhaseAlignMargin(chipcHw_VPM_HW_PHASE_MARGIN_e margin)
- {
- uint32_t ge = 0;
- uint32_t le = 0;
- switch (margin) {
- case chipcHw_VPM_HW_PHASE_MARGIN_STRICT:
- ge = 0x0F;
- le = 0x0F;
- break;
- case chipcHw_VPM_HW_PHASE_MARGIN_MEDIUM:
- ge = 0x03;
- le = 0x3F;
- break;
- case chipcHw_VPM_HW_PHASE_MARGIN_WIDE:
- ge = 0x01;
- le = 0x7F;
- break;
- }
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl1 &=
- ~((chipcHw_REG_VPM_PHASE_VALUE_GE_MASK <<
- chipcHw_REG_VPM_PHASE_VALUE_GE_SHIFT)
- || (chipcHw_REG_VPM_PHASE_VALUE_LE_MASK <<
- chipcHw_REG_VPM_PHASE_VALUE_LE_SHIFT));
- pChipcHw->VPMPhaseCtrl1 |=
- ((ge << chipcHw_REG_VPM_PHASE_VALUE_GE_SHIFT)
- || (le << chipcHw_REG_VPM_PHASE_VALUE_LE_SHIFT));
- REG_LOCAL_IRQ_RESTORE;
- }
- }
- /****************************************************************************/
- /**
- * @brief Checks DDR phase aligned status done by HW
- *
- * @return 1: When aligned
- * 0: When not aligned
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_isDdrHwPhaseAligned(void)
- {
- return (pChipcHw->
- PhaseAlignStatus & chipcHw_REG_DDR_PHASE_ALIGNED) ? 1 : 0;
- }
- /****************************************************************************/
- /**
- * @brief Checks VPM phase aligned status done by HW
- *
- * @return 1: When aligned
- * 0: When not aligned
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_isVpmHwPhaseAligned(void)
- {
- return (pChipcHw->
- PhaseAlignStatus & chipcHw_REG_VPM_PHASE_ALIGNED) ? 1 : 0;
- }
- /****************************************************************************/
- /**
- * @brief Get DDR phase aligned status done by HW
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getDdrHwPhaseAlignStatus(void)
- {
- return (pChipcHw->
- PhaseAlignStatus & chipcHw_REG_DDR_PHASE_STATUS_MASK) >>
- chipcHw_REG_DDR_PHASE_STATUS_SHIFT;
- }
- /****************************************************************************/
- /**
- * @brief Get VPM phase aligned status done by HW
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getVpmHwPhaseAlignStatus(void)
- {
- return (pChipcHw->
- PhaseAlignStatus & chipcHw_REG_VPM_PHASE_STATUS_MASK) >>
- chipcHw_REG_VPM_PHASE_STATUS_SHIFT;
- }
- /****************************************************************************/
- /**
- * @brief Get DDR phase control value
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getDdrPhaseControl(void)
- {
- return (pChipcHw->
- PhaseAlignStatus & chipcHw_REG_DDR_PHASE_CTRL_MASK) >>
- chipcHw_REG_DDR_PHASE_CTRL_SHIFT;
- }
- /****************************************************************************/
- /**
- * @brief Get VPM phase control value
- *
- */
- /****************************************************************************/
- static inline uint32_t chipcHw_getVpmPhaseControl(void)
- {
- return (pChipcHw->
- PhaseAlignStatus & chipcHw_REG_VPM_PHASE_CTRL_MASK) >>
- chipcHw_REG_VPM_PHASE_CTRL_SHIFT;
- }
- /****************************************************************************/
- /**
- * @brief DDR phase alignment timeout count
- *
- * @note If HW fails to perform the phase alignment, it will trigger
- * a DDR phase alignment timeout interrupt.
- */
- /****************************************************************************/
- static inline void chipcHw_ddrHwPhaseAlignTimeout(uint32_t busCycle)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl2 &=
- ~(chipcHw_REG_DDR_PHASE_TIMEOUT_COUNT_MASK <<
- chipcHw_REG_DDR_PHASE_TIMEOUT_COUNT_SHIFT);
- pChipcHw->DDRPhaseCtrl2 |=
- (busCycle & chipcHw_REG_DDR_PHASE_TIMEOUT_COUNT_MASK) <<
- chipcHw_REG_DDR_PHASE_TIMEOUT_COUNT_SHIFT;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief VPM phase alignment timeout count
- *
- * @note If HW fails to perform the phase alignment, it will trigger
- * a VPM phase alignment timeout interrupt.
- */
- /****************************************************************************/
- static inline void chipcHw_vpmHwPhaseAlignTimeout(uint32_t busCycle)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl2 &=
- ~(chipcHw_REG_VPM_PHASE_TIMEOUT_COUNT_MASK <<
- chipcHw_REG_VPM_PHASE_TIMEOUT_COUNT_SHIFT);
- pChipcHw->VPMPhaseCtrl2 |=
- (busCycle & chipcHw_REG_VPM_PHASE_TIMEOUT_COUNT_MASK) <<
- chipcHw_REG_VPM_PHASE_TIMEOUT_COUNT_SHIFT;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Clear DDR phase alignment timeout interrupt
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrHwPhaseAlignTimeoutInterruptClear(void)
- {
- REG_LOCAL_IRQ_SAVE;
- /* Clear timeout interrupt service bit */
- pChipcHw->DDRPhaseCtrl2 |= chipcHw_REG_DDR_INTR_SERVICED;
- pChipcHw->DDRPhaseCtrl2 &= ~chipcHw_REG_DDR_INTR_SERVICED;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief Clear VPM phase alignment timeout interrupt
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmHwPhaseAlignTimeoutInterruptClear(void)
- {
- REG_LOCAL_IRQ_SAVE;
- /* Clear timeout interrupt service bit */
- pChipcHw->VPMPhaseCtrl2 |= chipcHw_REG_VPM_INTR_SERVICED;
- pChipcHw->VPMPhaseCtrl2 &= ~chipcHw_REG_VPM_INTR_SERVICED;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief DDR phase alignment timeout interrupt enable
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrHwPhaseAlignTimeoutInterruptEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- chipcHw_ddrHwPhaseAlignTimeoutInterruptClear(); /* Recommended */
- /* Enable timeout interrupt */
- pChipcHw->DDRPhaseCtrl2 |= chipcHw_REG_DDR_TIMEOUT_INTR_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief VPM phase alignment timeout interrupt enable
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmHwPhaseAlignTimeoutInterruptEnable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- chipcHw_vpmHwPhaseAlignTimeoutInterruptClear(); /* Recommended */
- /* Enable timeout interrupt */
- pChipcHw->VPMPhaseCtrl2 |= chipcHw_REG_VPM_TIMEOUT_INTR_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief DDR phase alignment timeout interrupt disable
- *
- */
- /****************************************************************************/
- static inline void chipcHw_ddrHwPhaseAlignTimeoutInterruptDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->DDRPhaseCtrl2 &= ~chipcHw_REG_DDR_TIMEOUT_INTR_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- /****************************************************************************/
- /**
- * @brief VPM phase alignment timeout interrupt disable
- *
- */
- /****************************************************************************/
- static inline void chipcHw_vpmHwPhaseAlignTimeoutInterruptDisable(void)
- {
- REG_LOCAL_IRQ_SAVE;
- pChipcHw->VPMPhaseCtrl2 &= ~chipcHw_REG_VPM_TIMEOUT_INTR_ENABLE;
- REG_LOCAL_IRQ_RESTORE;
- }
- #endif /* CHIPC_INLINE_H */
|