CC26xx Driver Library
setup.c File Reference
#include "../inc/hw_types.h"
#include "../inc/hw_memmap.h"
#include "../inc/hw_adi.h"
#include "../inc/hw_adi_2_refsys.h"
#include "../inc/hw_adi_3_refsys.h"
#include "../inc/hw_aon_ioc.h"
#include "../inc/hw_aon_sysctl.h"
#include "../inc/hw_aon_wuc.h"
#include "../inc/hw_aux_wuc.h"
#include "../inc/hw_ddi_0_osc.h"
#include "../inc/hw_ddi.h"
#include "../inc/hw_ccfg.h"
#include "../inc/hw_fcfg1.h"
#include "../inc/hw_flash.h"
#include "../inc/hw_prcm.h"
#include "../inc/hw_vims.h"
#include "aon_wuc.h"
#include "aux_wuc.h"
#include "chipinfo.h"
#include "setup.h"
#include "setup_rom.h"

Macros

#define CPU_DELAY_MICRO_SECONDS(x)   CPUdelay(((uint32_t)((( x ) * 48.0 ) / 5.0 )) - 1 )
 

Functions

static void TrimAfterColdReset (void)
 Trims to be applied when coming from PIN_RESET. More...
 
static void TrimAfterColdResetWakeupFromShutDown (uint32_t ui32Fcfg1Revision)
 Trims to be applied when coming from SHUTDOWN (also called when coming from PIN_RESET). More...
 
static void TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown (void)
 Trims to be applied when coming from POWER_DOWN (also called when coming from SHUTDOWN and PIN_RESET). More...
 
void SetupTrimDevice (void)
 Performs the necessary trim of the device which is not done in ROM boot code. More...
 

Macro Definition Documentation

#define CPU_DELAY_MICRO_SECONDS (   x)    CPUdelay(((uint32_t)((( x ) * 48.0 ) / 5.0 )) - 1 )

Function Documentation

static void TrimAfterColdReset ( void  )
static

Trims to be applied when coming from PIN_RESET.

Returns
None

Referenced by SetupTrimDevice().

337 {
338  // Currently no specific trim for Cold Reset
339 }
static void TrimAfterColdResetWakeupFromShutDown ( uint32_t  ui32Fcfg1Revision)
static

Trims to be applied when coming from SHUTDOWN (also called when coming from PIN_RESET).

Parameters
ui32Fcfg1Revision
Returns
None

Referenced by SetupTrimDevice().

248 {
249  uint32_t ccfg_ModeConfReg ;
250 
251  // Force AUX on and enable clocks
252  //
253  // No need to save the current status of the power/clock registers.
254  // At this point both AUX and AON should have been reset to 0x0.
255  HWREG(AON_WUC_BASE + AON_WUC_O_AUXCTL) = AON_WUC_AUXCTL_AUX_FORCE_ON;
256 
257  // Wait for power on on the AUX domain
258  while( ! ( HWREGBITW( AON_WUC_BASE + AON_WUC_O_PWRSTAT, AON_WUC_PWRSTAT_AUX_PD_ON_BITN )));
259 
260  // Enable the clocks for AUX_DDI0_OSC and AUX_ADI4
261  HWREG(AUX_WUC_BASE + AUX_WUC_O_MODCLKEN0) = AUX_WUC_MODCLKEN0_AUX_DDI0_OSC |
262  AUX_WUC_MODCLKEN0_AUX_ADI4;
263 
264  // Check in CCFG for alternative DCDC setting
265  if (( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_ALT_DCDC_SETTING ) == 0 ) {
266  // ADI_3_REFSYS:DCDCCTL5[3] (=DITHER_EN) = CCFG_MODE_CONF_1[19] (=ALT_DCDC_DITHER_EN)
267  // ADI_3_REFSYS:DCDCCTL5[2:0](=IPEAK ) = CCFG_MODE_CONF_1[18:16](=ALT_DCDC_IPEAK )
268  // Using a single 4-bit masked write since layout is equal for both source and destination
269  HWREGB( ADI3_BASE + ADI_O_MASK4B + ( ADI_3_REFSYS_O_DCDCCTL5 * 2 )) = ( 0xF0 |
270  ( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) >> CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_S ));
271 
272  }
273 
274  //
275  // Enable for JTAG to be powered down (will still be powered on if debugger is connected)
277 
278  {
279  // Check if the RCOSC_HF trims have to be reloaded - this is a workaround needed on one specific production lot
280  uint32_t fcfg1MiscTrimReg = HWREG( FCFG1_BASE + FCFG1_O_MISC_TRIM );
281  if (( fcfg1MiscTrimReg & 0x80000000 ) == 0 ) {
282  // Reload the RCOSCHF_CTRIM with the CTRIM found in the FCFG1 shadow register.
283  HWREGB( AUX_DDI0_OSC_BASE + DDI_0_OSC_O_RCOSCHFCTL + 1 ) =
284  ((( HWREG( FCFG1_BASE + FCFG1_O_SHDW_OSC_BIAS_LDO_TRIM ) & FCFG1_SHDW_OSC_BIAS_LDO_TRIM_RCOSCHF_CTRIM_M ) >> FCFG1_SHDW_OSC_BIAS_LDO_TRIM_RCOSCHF_CTRIM_S ) ^ 0xC0 );
285  // Reload the RCOSCHF_FINE_RESISTOR trim with the MISC_TRIM[30:29] (Mask bits in [7:6]=0xC0, Data in [3:2](0xC) (shift(29-2))
286  HWREGB( AUX_DDI0_OSC_BASE + DDI_O_MASK4B + ( DDI_0_OSC_O_ATESTCTL * 2 ) + 2 ) = ( 0xC0 | (( fcfg1MiscTrimReg >> 27 ) & 0xC ));
287  // Set HFCTRIMFRACT_EN
288  HWREG( AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_CTL1 ) = DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_EN ;
289  }
290  }
291 
292  // read the MODE_CONF register in CCFG
293  ccfg_ModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF );
294 
295  // First part of trim done after cold reset and wakeup from shutdown:
296  // -Adjust the VDDR_TRIM_SLEEP value.
297  // -Configure DCDC.
298  SetupAfterColdResetWakeupFromShutDownCfg1( ccfg_ModeConfReg );
299 
300  // Second part of trim done after cold reset and wakeup from shutdown:
301  // -Configure XOSC.
302 #if ( CCFG_BASE == CCFG_BASE_DEFAULT )
303  SetupAfterColdResetWakeupFromShutDownCfg2( ui32Fcfg1Revision, ccfg_ModeConfReg );
304 #else
305  NOROM_SetupAfterColdResetWakeupFromShutDownCfg2( ui32Fcfg1Revision, ccfg_ModeConfReg );
306 #endif
307 
308  // Third part of trim done after cold reset and wakeup from shutdown:
309  // -Configure HPOSC.
310  // -Setup the LF clock.
311 #if ( CCFG_BASE == CCFG_BASE_DEFAULT )
312  SetupAfterColdResetWakeupFromShutDownCfg3( ccfg_ModeConfReg );
313 #else
314  NOROM_SetupAfterColdResetWakeupFromShutDownCfg3( ccfg_ModeConfReg );
315 #endif
316 
317  // Allow AUX to power down
319 
320  // Leaving on AUX and clock for AUX_DDI0_OSC on but turn off clock for AUX_ADI4
321  HWREG( AUX_WUC_BASE + AUX_WUC_O_MODCLKEN0 ) = AUX_WUC_MODCLKEN0_AUX_DDI0_OSC;
322 
323  // Disable EFUSE clock
324  HWREGBITW( FLASH_BASE + FLASH_O_CFG, FLASH_CFG_DIS_EFUSECLK_BITN ) = 1;
325 }
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:254
void SetupAfterColdResetWakeupFromShutDownCfg3(uint32_t ccfg_ModeConfReg)
Third part of configuration required after cold reset and when waking up from shutdown.
Definition: setup_rom.c:277
void SetupAfterColdResetWakeupFromShutDownCfg1(uint32_t ccfg_ModeConfReg)
First part of configuration required after cold reset and when waking up from shutdown.
Definition: setup_rom.c:117
void SetupAfterColdResetWakeupFromShutDownCfg2(uint32_t ui32Fcfg1Revision, uint32_t ccfg_ModeConfReg)
Second part of configuration required after cold reset and when waking up from shutdown.
Definition: setup_rom.c:172
static void AONWUCJtagPowerOff(void)
Request power off of the JTAG domain.
Definition: aon_wuc.h:792

Here is the call graph for this function:

static void TrimAfterColdResetWakeupFromShutDownWakeupFromPowerDown ( void  )
static

Trims to be applied when coming from POWER_DOWN (also called when coming from SHUTDOWN and PIN_RESET).

Returns
None

Referenced by SetupTrimDevice().

232 {
233  // Currently no specific trim for Powerdown
234 }