mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
arch/arm/src/tiva/cc13xx/cc13x2_v1_trim.c and cc13x2_cc26x2_v1_rom.c: Review and modified for coding style. Now pass tools/nxstyle wihout complaint.
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/tiva/cc13xx/cc13x2_cc26x2_v1_rom.c
|
* arch/arm/src/tiva/cc13xx/cc13x2_cc26x2_v1_rom.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* This is a port of TI's setup_rom.c file which has a fully compatible BSD license:
|
* This is a port of TI's setup_rom.c file which has a fully compatible BSD
|
||||||
|
* license:
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015-2017, Texas Instruments Incorporated
|
* Copyright (c) 2015-2017, Texas Instruments Incorporated
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@@ -36,11 +37,11 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -59,13 +60,13 @@
|
|||||||
|
|
||||||
#include "cc13xx/cc13x2_cc26x2_v1_rom.h"
|
#include "cc13xx/cc13x2_cc26x2_v1_rom.h"
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: rom_setup_stepvaddrtrimto
|
* Name: rom_setup_stepvaddrtrimto
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void rom_setup_stepvaddrtrimto(uint32_t tocode)
|
void rom_setup_stepvaddrtrimto(uint32_t tocode)
|
||||||
{
|
{
|
||||||
@@ -74,8 +75,7 @@ void rom_setup_stepvaddrtrimto(uint32_t tocode)
|
|||||||
int32_t current_trim;
|
int32_t current_trim;
|
||||||
|
|
||||||
target_trim =
|
target_trim =
|
||||||
rom_signextend_vddrtrim(tocode &
|
rom_signextend_vddrtrim(tocode & (ADI3_REFSYS_DCDCCTL0_VDDR_TRIM_MASK >>
|
||||||
(ADI3_REFSYS_DCDCCTL0_VDDR_TRIM_MASK >>
|
|
||||||
ADI3_REFSYS_DCDCCTL0_VDDR_TRIM_SHIFT));
|
ADI3_REFSYS_DCDCCTL0_VDDR_TRIM_SHIFT));
|
||||||
current_trim =
|
current_trim =
|
||||||
rom_signextend_vddrtrim((getreg16(TIVA_ADI3_REFSYS_DCDCCTL0) &
|
rom_signextend_vddrtrim((getreg16(TIVA_ADI3_REFSYS_DCDCCTL0) &
|
||||||
@@ -84,27 +84,32 @@ void rom_setup_stepvaddrtrimto(uint32_t tocode)
|
|||||||
|
|
||||||
if (target_trim != current_trim)
|
if (target_trim != current_trim)
|
||||||
{
|
{
|
||||||
pmctl_regsetctrl =
|
pmctl_regsetctrl = (getreg32(TIVA_AON_PMCTL_RESETCTL) &
|
||||||
(getreg32(TIVA_AON_PMCTL_RESETCTL) &
|
|
||||||
~AON_PMCTL_RESETCTL_MCU_WARM_RESET);
|
~AON_PMCTL_RESETCTL_MCU_WARM_RESET);
|
||||||
if (pmctl_regsetctrl & AON_PMCTL_RESETCTL_VDDR_LOSS_EN)
|
if (pmctl_regsetctrl & AON_PMCTL_RESETCTL_VDDR_LOSS_EN)
|
||||||
{
|
{
|
||||||
putreg32(pmctl_regsetctrl & ~AON_PMCTL_RESETCTL_VDDR_LOSS_EN,
|
putreg32(pmctl_regsetctrl & ~AON_PMCTL_RESETCTL_VDDR_LOSS_EN,
|
||||||
TIVA_AON_PMCTL_RESETCTL);
|
TIVA_AON_PMCTL_RESETCTL);
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNC); /* Wait for VDDR_LOSS_EN
|
|
||||||
* setting to propagate */
|
/* Wait for VDDR_LOSS_EN setting to propagate */
|
||||||
|
|
||||||
|
(void)getreg32(TIVA_AON_RTC_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (target_trim != current_trim)
|
while (target_trim != current_trim)
|
||||||
{
|
{
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF); /* Wait for next edge
|
/* Wait for next edge on SCLK_LF (positive or negative) */
|
||||||
* on SCLK_LF (positive
|
|
||||||
* or negative) */
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
|
|
||||||
if (target_trim > current_trim)
|
if (target_trim > current_trim)
|
||||||
|
{
|
||||||
current_trim++;
|
current_trim++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
current_trim--;
|
current_trim--;
|
||||||
|
}
|
||||||
|
|
||||||
putreg8(((getreg8(TIVA_ADI3_REFSYS_DCDCCTL0) &
|
putreg8(((getreg8(TIVA_ADI3_REFSYS_DCDCCTL0) &
|
||||||
~ADI3_REFSYS_DCDCCTL0_VDDR_TRIM_MASK) |
|
~ADI3_REFSYS_DCDCCTL0_VDDR_TRIM_MASK) |
|
||||||
@@ -114,32 +119,32 @@ void rom_setup_stepvaddrtrimto(uint32_t tocode)
|
|||||||
TIVA_ADI3_REFSYS_DCDCCTL0);
|
TIVA_ADI3_REFSYS_DCDCCTL0);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF); /* Wait for next edge on
|
/* Wait for next edge on SCLK_LF (positive or negative) */
|
||||||
* SCLK_LF (positive or
|
|
||||||
* negative) */
|
|
||||||
|
|
||||||
if (pmctl_regsetctrl & AON_PMCTL_RESETCTL_VDDR_LOSS_EN)
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
|
|
||||||
|
if ((pmctl_regsetctrl & AON_PMCTL_RESETCTL_VDDR_LOSS_EN) != 0)
|
||||||
{
|
{
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF); /* Wait for next edge
|
/* Wait for next edge on SCLK_LF (positive or negative) */
|
||||||
* on SCLK_LF (positive
|
|
||||||
* or negative) */
|
|
||||||
|
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF); /* Wait for next edge
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
* on SCLK_LF (positive
|
|
||||||
* or negative) */
|
/* Wait for next edge on SCLK_LF (positive or negative) */
|
||||||
|
|
||||||
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
|
|
||||||
putreg32(pmctl_regsetctrl, TIVA_AON_PMCTL_RESETCTL);
|
putreg32(pmctl_regsetctrl, TIVA_AON_PMCTL_RESETCTL);
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNC); /* And finally wait for
|
|
||||||
* VDDR_LOSS_EN setting to
|
|
||||||
* propagate */
|
|
||||||
|
|
||||||
|
/* And finally wait for VDDR_LOSS_EN setting to propagate */
|
||||||
|
|
||||||
|
(void)getreg32(TIVA_AON_RTC_SYNC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: rom_setup_coldreset_from_shutdown_cfg1
|
* Name: rom_setup_coldreset_from_shutdown_cfg1
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void rom_setup_coldreset_from_shutdown_cfg1(uint32_t ccfg_modeconf)
|
void rom_setup_coldreset_from_shutdown_cfg1(uint32_t ccfg_modeconf)
|
||||||
{
|
{
|
||||||
@@ -147,15 +152,17 @@ void rom_setup_coldreset_from_shutdown_cfg1(uint32_t ccfg_modeconf)
|
|||||||
uint32_t clrbits;
|
uint32_t clrbits;
|
||||||
|
|
||||||
/* Check for CC1352 boost mode The combination VDDR_EXT_LOAD=0 and
|
/* Check for CC1352 boost mode The combination VDDR_EXT_LOAD=0 and
|
||||||
* VDDS_BOD_LEVEL=1 is defined to select boost mode */
|
* VDDS_BOD_LEVEL=1 is defined to select boost mode
|
||||||
|
*/
|
||||||
|
|
||||||
if (((ccfg_modeconf & CCFG_MODE_CONF_VDDR_EXT_LOAD) == 0) &&
|
if ((ccfg_modeconf & CCFG_MODE_CONF_VDDR_EXT_LOAD) == 0 &&
|
||||||
((ccfg_modeconf & CCFG_MODE_CONF_VDDS_BOD_LEVEL) != 0))
|
(ccfg_modeconf & CCFG_MODE_CONF_VDDS_BOD_LEVEL) != 0)
|
||||||
{
|
{
|
||||||
/* Set VDDS_BOD trim - using masked write {MASK8:DATA8} - TRIM_VDDS_BOD
|
/* Set VDDS_BOD trim - using masked write {MASK8:DATA8} - TRIM_VDDS_BOD
|
||||||
* is bits[7:3] of ADI3..REFSYSCTL1 - Needs a positive transition on
|
* is bits[7:3] of ADI3..REFSYSCTL1 - Needs a positive transition on
|
||||||
* BOD_BG_TRIM_EN (bit[7] of REFSYSCTL3) to latch new VDDS BOD. Set to 0
|
* BOD_BG_TRIM_EN (bit[7] of REFSYSCTL3) to latch new VDDS BOD. Set to 0
|
||||||
* first to guarantee a positive transition. */
|
* first to guarantee a positive transition.
|
||||||
|
*/
|
||||||
|
|
||||||
putreg8(ADI3_REFSYS_REFSYSCTL3_BOD_BG_TRIM_EN,
|
putreg8(ADI3_REFSYS_REFSYSCTL3_BOD_BG_TRIM_EN,
|
||||||
TIVA_ADI3_REFSYS_CLR + TIVA_ADI3_REFSYS_REFSYSCTL3_OFFSET);
|
TIVA_ADI3_REFSYS_CLR + TIVA_ADI3_REFSYS_REFSYSCTL3_OFFSET);
|
||||||
@@ -166,7 +173,8 @@ void rom_setup_coldreset_from_shutdown_cfg1(uint32_t ccfg_modeconf)
|
|||||||
|
|
||||||
putreg16((ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_MASK << 8) |
|
putreg16((ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_MASK << 8) |
|
||||||
(ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_POS_31),
|
(ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_POS_31),
|
||||||
TIVA_ADI3_REFSYS_MASK8B + (TIVA_ADI3_REFSYS_REFSYSCTL1_OFFSET * 2));
|
TIVA_ADI3_REFSYS_MASK8B +
|
||||||
|
(TIVA_ADI3_REFSYS_REFSYSCTL1_OFFSET * 2));
|
||||||
|
|
||||||
putreg8(ADI3_REFSYS_REFSYSCTL3_BOD_BG_TRIM_EN,
|
putreg8(ADI3_REFSYS_REFSYSCTL3_BOD_BG_TRIM_EN,
|
||||||
TIVA_ADI3_REFSYS_SET + TIVA_ADI3_REFSYS_REFSYSCTL3_OFFSET);
|
TIVA_ADI3_REFSYS_SET + TIVA_ADI3_REFSYS_REFSYSCTL3_OFFSET);
|
||||||
@@ -177,14 +185,14 @@ void rom_setup_coldreset_from_shutdown_cfg1(uint32_t ccfg_modeconf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 1. Do not allow DCDC to be enabled if in external regulator mode.
|
/* 1. Do not allow DCDC to be enabled if in external regulator mode.
|
||||||
* Preventing this by setting both the RECHARGE and the ACTIVE bits bit in
|
* Preventing this by setting both the RECHARGE and the ACTIVE bits bit
|
||||||
* the CCFG_MODE_CONF copy register (ccfg_modeconf). 2. Adjusted battery
|
* in the CCFG_MODE_CONF copy register (ccfg_modeconf).
|
||||||
* monitor low limit in internal regulator mode. This is done by setting
|
* 2. Adjusted battery monitor low limit in internal regulator mode. This
|
||||||
* AON_BATMON_FLASHPUMPP0_LOWLIM=0 in internal regulator mode.
|
* is done by setting AON_BATMON_FLASHPUMPP0_LOWLIM=0 in internal
|
||||||
|
* regulator mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (getreg32(TIVA_AON_PMCTL_PWRCTL) &
|
if ((getreg32(TIVA_AON_PMCTL_PWRCTL) & AON_PMCTL_PWRCTL_EXT_REG_MODE) != 0)
|
||||||
AON_PMCTL_PWRCTL_EXT_REG_MODE)
|
|
||||||
{
|
{
|
||||||
ccfg_modeconf |= (CCFG_MODE_CONF_DCDC_RECHARGE |
|
ccfg_modeconf |= (CCFG_MODE_CONF_DCDC_RECHARGE |
|
||||||
CCFG_MODE_CONF_DCDC_ACTIVE);
|
CCFG_MODE_CONF_DCDC_ACTIVE);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/tiva/cc13xx/cc13x2_v1_trim.c
|
* arch/arm/src/tiva/cc13xx/cc13x2_v1_trim.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||||
@@ -11,18 +11,19 @@
|
|||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
*
|
*
|
||||||
* 1) Redistributions of source code must retain the above copyright notice,
|
* 1) Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
* 2) Redistributions in binary form must reproduce the above copyright
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3) Neither the name NuttX nor the names of its contributors may be used to
|
* 3) Neither the name NuttX nor the names of its contributors may be used
|
||||||
* endorse or promote products derived from this software without specific
|
* to endorse or promote products derived from this software without
|
||||||
* prior written permission.
|
* specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
@@ -36,11 +37,11 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@@ -60,22 +61,11 @@
|
|||||||
#include "cc13xx/cc13x2_cc26x2_v1_rom.h"
|
#include "cc13xx/cc13x2_cc26x2_v1_rom.h"
|
||||||
#include "cc13xx/cc13x2_aux_sysif.h"
|
#include "cc13xx/cc13x2_aux_sysif.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
/* Handle support for DriverLib in ROM:
|
|
||||||
* This section will undo prototype renaming made in the header file
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef cc13x2_cc26x2_trim_device
|
|
||||||
#define cc13x2_cc26x2_trim_device NOROM_cc13x2_cc26x2_trim_device
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Private Functions
|
* Private Functions
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Name: trim_wakeup_frompowerdown
|
* Name: trim_wakeup_frompowerdown
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -85,14 +75,14 @@
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void trim_wakeup_frompowerdown(void)
|
static void trim_wakeup_frompowerdown(void)
|
||||||
{
|
{
|
||||||
/* Currently no specific trim for Powerdown */
|
/* Currently no specific trim for Powerdown */
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Name: Step_RCOSCHF_CTRIM
|
* Name: Step_RCOSCHF_CTRIM
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -101,19 +91,19 @@ static void trim_wakeup_frompowerdown(void)
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void Step_RCOSCHF_CTRIM(uint32_t toCode)
|
static void Step_RCOSCHF_CTRIM(uint32_t tocode)
|
||||||
{
|
{
|
||||||
uint32_t current_rcoschfctrl;
|
uint32_t current_rcoschfctrl;
|
||||||
uint32_t current_trim;
|
uint32_t current_trim;
|
||||||
|
|
||||||
current_rcoschfctrl = getreg16(TIVA_DDI0_OSC_RCOSCMFCTL);
|
current_rcoschfctrl = getreg16(TIVA_DDI0_OSC_RCOSCMFCTL);
|
||||||
current_trim =
|
current_trim = (((current_rcoschfctrl &
|
||||||
(((current_rcoschfctrl & DDI0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_MASK) >>
|
DDI0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_MASK) >>
|
||||||
DDI0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_SHIFT) ^ 0xc0);
|
DDI0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_SHIFT) ^ 0xc0);
|
||||||
|
|
||||||
while (toCode != current_trim)
|
while (tocode != current_trim)
|
||||||
{
|
{
|
||||||
uint16_t regval16;
|
uint16_t regval16;
|
||||||
|
|
||||||
@@ -121,7 +111,7 @@ static void Step_RCOSCHF_CTRIM(uint32_t toCode)
|
|||||||
|
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
|
|
||||||
if (toCode > current_trim)
|
if (tocode > current_trim)
|
||||||
{
|
{
|
||||||
current_trim++;
|
current_trim++;
|
||||||
}
|
}
|
||||||
@@ -138,7 +128,7 @@ static void Step_RCOSCHF_CTRIM(uint32_t toCode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Name: step_vbg
|
* Name: step_vbg
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -147,14 +137,14 @@ static void Step_RCOSCHF_CTRIM(uint32_t toCode)
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void step_vbg(int32_t target_signed)
|
static void step_vbg(int32_t target_signed)
|
||||||
{
|
{
|
||||||
/* VBG (ANA_TRIM[5:0]=TRIMTEMP --> ADI3_REFSYS:REFSYSCTL3.TRIM_VBG) */
|
|
||||||
|
|
||||||
int32_t current_signed;
|
int32_t current_signed;
|
||||||
|
|
||||||
|
/* VBG (ANA_TRIM[5:0]=TRIMTEMP --> ADI3_REFSYS:REFSYSCTL3.TRIM_VBG) */
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint8_t ref_sysctl;
|
uint8_t ref_sysctl;
|
||||||
@@ -199,7 +189,7 @@ static void step_vbg(int32_t target_signed)
|
|||||||
while (target_signed != current_signed);
|
while (target_signed != current_signed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Name: trim_wakeup_fromshutdown
|
* Name: trim_wakeup_fromshutdown
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -212,12 +202,20 @@ static void step_vbg(int32_t target_signed)
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
||||||
{
|
{
|
||||||
uint32_t ccfg_modeconf;
|
uint32_t ccfg_modeconf;
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
uint32_t fusedata;
|
||||||
|
uint32_t org_resetctl;
|
||||||
|
uint32_t trimreg;
|
||||||
|
uint32_t trimvalue;
|
||||||
|
uint16_t regval16;
|
||||||
|
uint8_t regval8;
|
||||||
|
int lshift;
|
||||||
|
int rshift;
|
||||||
|
|
||||||
/* Check in CCFG for alternative DCDC setting */
|
/* Check in CCFG for alternative DCDC setting */
|
||||||
|
|
||||||
@@ -233,7 +231,8 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
regval = getreg32(TIVA_CCFG_MODE_CONF_1);
|
regval = getreg32(TIVA_CCFG_MODE_CONF_1);
|
||||||
regval = (0xf0 | (regval >> CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_SHIFT));
|
regval = (0xf0 | (regval >> CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_SHIFT));
|
||||||
putreg8((uint8_t)regval,
|
putreg8((uint8_t)regval,
|
||||||
TIVA_ADI3_REFSYS_MASK4B + (TIVA_ADI3_REFSYS_DCDCCTL5_OFFSET * 2));
|
TIVA_ADI3_REFSYS_MASK4B +
|
||||||
|
(TIVA_ADI3_REFSYS_DCDCCTL5_OFFSET * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TBD - Temporarily removed for CC13x2 / CC26x2 */
|
/* TBD - Temporarily removed for CC13x2 / CC26x2 */
|
||||||
@@ -247,7 +246,8 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
|
|
||||||
regval = DDI0_OSC_CTL0_CLK_DCDC_SRC_SEL |
|
regval = DDI0_OSC_CTL0_CLK_DCDC_SRC_SEL |
|
||||||
(DDI0_OSC_CTL0_CLK_DCDC_SRC_SEL >> 16);
|
(DDI0_OSC_CTL0_CLK_DCDC_SRC_SEL >> 16);
|
||||||
putreg32(regval, TIVA_DDI0_OSC_MASK16B + (TIVA_DDI0_OSC_CTL0_OFFSET << 1) + 4);
|
putreg32(regval, TIVA_DDI0_OSC_MASK16B +
|
||||||
|
(TIVA_DDI0_OSC_CTL0_OFFSET << 1) + 4);
|
||||||
|
|
||||||
/* Dummy read to ensure that the write has propagated */
|
/* Dummy read to ensure that the write has propagated */
|
||||||
|
|
||||||
@@ -257,8 +257,8 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
|
|
||||||
ccfg_modeconf = getreg32(TIVA_CCFG_MODE_CONF);
|
ccfg_modeconf = getreg32(TIVA_CCFG_MODE_CONF);
|
||||||
|
|
||||||
/* First part of trim done after cold reset and wakeup from shutdown: -Adjust
|
/* First part of trim done after cold reset and wakeup from shutdown:
|
||||||
* the VDDR_TRIM_SLEEP value. -Configure DCDC.
|
* Adjust the VDDR_TRIM_SLEEP value. Configure DCDC.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rom_setup_coldreset_from_shutdown_cfg1(ccfg_modeconf);
|
rom_setup_coldreset_from_shutdown_cfg1(ccfg_modeconf);
|
||||||
@@ -271,14 +271,6 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
|
|
||||||
/* Special shadow register trim propagation on first batch of devices */
|
/* Special shadow register trim propagation on first batch of devices */
|
||||||
|
|
||||||
{
|
|
||||||
uint32_t fusedata;
|
|
||||||
uint32_t org_resetctl;
|
|
||||||
uint16_t regval16;
|
|
||||||
uint8_t regval8;
|
|
||||||
int lshift;
|
|
||||||
int rshift;
|
|
||||||
|
|
||||||
/* Get VTRIM_COARSE and VTRIM_DIG from EFUSE shadow register
|
/* Get VTRIM_COARSE and VTRIM_DIG from EFUSE shadow register
|
||||||
* OSC_BIAS_LDO_TRIM
|
* OSC_BIAS_LDO_TRIM
|
||||||
*/
|
*/
|
||||||
@@ -330,12 +322,13 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
|
|
||||||
fusedata = getreg32(TIVA_FCFG1_SHDW_ANA_TRIM);
|
fusedata = getreg32(TIVA_FCFG1_SHDW_ANA_TRIM);
|
||||||
|
|
||||||
org_resetctl =
|
org_resetctl = (getreg32(TIVA_AON_PMCTL_RESETCTL) &
|
||||||
(getreg32(TIVA_AON_PMCTL_RESETCTL) & ~AON_PMCTL_RESETCTL_MCU_WARM_RESET);
|
~AON_PMCTL_RESETCTL_MCU_WARM_RESET);
|
||||||
|
|
||||||
regval = (org_resetctl &
|
regval = (org_resetctl & ~(AON_PMCTL_RESETCTL_CLK_LOSS_EN |
|
||||||
~(AON_PMCTL_RESETCTL_CLK_LOSS_EN | AON_PMCTL_RESETCTL_VDD_LOSS_EN |
|
AON_PMCTL_RESETCTL_VDD_LOSS_EN |
|
||||||
AON_PMCTL_RESETCTL_VDDR_LOSS_EN | AON_PMCTL_RESETCTL_VDDS_LOSS_EN));
|
AON_PMCTL_RESETCTL_VDDR_LOSS_EN |
|
||||||
|
AON_PMCTL_RESETCTL_VDDS_LOSS_EN));
|
||||||
putreg32(regval, TIVA_AON_PMCTL_RESETCTL);
|
putreg32(regval, TIVA_AON_PMCTL_RESETCTL);
|
||||||
|
|
||||||
/* Wait for xxx_LOSS_EN setting to propagate */
|
/* Wait for xxx_LOSS_EN setting to propagate */
|
||||||
@@ -358,7 +351,8 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
regval16 = (ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_MASK << 8) |
|
regval16 = (ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_MASK << 8) |
|
||||||
(((fusedata & FCFG1_SHDW_ANA_TRIM_TRIMBOD_EXTMODE_MASK) >>
|
(((fusedata &
|
||||||
|
FCFG1_SHDW_ANA_TRIM_TRIMBOD_EXTMODE_MASK) >>
|
||||||
FCFG1_SHDW_ANA_TRIM_TRIMBOD_EXTMODE_SHIFT) <<
|
FCFG1_SHDW_ANA_TRIM_TRIMBOD_EXTMODE_SHIFT) <<
|
||||||
ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_SHIFT);
|
ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_SHIFT);
|
||||||
putreg16(regval16,
|
putreg16(regval16,
|
||||||
@@ -372,7 +366,8 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
regval16 = (ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_MASK << 8) |
|
regval16 = (ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_MASK << 8) |
|
||||||
(((fusedata & FCFG1_SHDW_ANA_TRIM_TRIMBOD_INTMODE_MASK) >>
|
(((fusedata &
|
||||||
|
FCFG1_SHDW_ANA_TRIM_TRIMBOD_INTMODE_MASK) >>
|
||||||
FCFG1_SHDW_ANA_TRIM_TRIMBOD_INTMODE_SHIFT) <<
|
FCFG1_SHDW_ANA_TRIM_TRIMBOD_INTMODE_SHIFT) <<
|
||||||
ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_SHIFT);
|
ADI3_REFSYS_REFSYSCTL1_TRIM_VDDS_BOD_SHIFT);
|
||||||
putreg16(regval16,
|
putreg16(regval16,
|
||||||
@@ -403,13 +398,13 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
rshift = (32 - FCFG1_SHDW_ANA_TRIM_TRIMTEMP_WIDTH);
|
rshift = (32 - FCFG1_SHDW_ANA_TRIM_TRIMTEMP_WIDTH);
|
||||||
step_vbg(((int32_t)fusedata << lshift) >> rshift);
|
step_vbg(((int32_t)fusedata << lshift) >> rshift);
|
||||||
|
|
||||||
/* Wait two more LF edges before restoring xxx_LOSS_EN settings */
|
/* Wait two more LF edges before restoring xxx_LOSS_EN settings:
|
||||||
|
* Wait for first edge on SCLK_LF (positive or negative)
|
||||||
/* Wait for next edge on SCLK_LF (positive or negative) */
|
*/
|
||||||
|
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
|
|
||||||
/* Wait for next edge on SCLK_LF (positive or negative) */
|
/* Wait for second edge on SCLK_LF (positive or negative) */
|
||||||
|
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
(void)getreg32(TIVA_AON_RTC_SYNCLF);
|
||||||
|
|
||||||
@@ -418,13 +413,6 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
/* Wait for xxx_LOSS_EN setting to propagate */
|
/* Wait for xxx_LOSS_EN setting to propagate */
|
||||||
|
|
||||||
(void)getreg32(TIVA_AON_RTC_SYNC);
|
(void)getreg32(TIVA_AON_RTC_SYNC);
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
uint32_t trimreg;
|
|
||||||
uint32_t trimvalue;
|
|
||||||
uint16_t regval16;
|
|
||||||
uint8_t regval8;
|
|
||||||
|
|
||||||
/* Propagate the LPM_BIAS trim */
|
/* Propagate the LPM_BIAS trim */
|
||||||
|
|
||||||
@@ -450,8 +438,8 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
|
|
||||||
regval16 = ((ADI4_AUX_COMP_LPM_BIAS_WIDTH_TRIM_MASK << 8) |
|
regval16 = ((ADI4_AUX_COMP_LPM_BIAS_WIDTH_TRIM_MASK << 8) |
|
||||||
(3 << ADI4_AUX_COMP_LPM_BIAS_WIDTH_TRIM_SHIFT));
|
(3 << ADI4_AUX_COMP_LPM_BIAS_WIDTH_TRIM_SHIFT));
|
||||||
putreg16(regval16, TIVA_ADI4_AUX_MASK8B + (TIVA_ADI4_AUX_COMP_OFFSET * 2));
|
putreg16(regval16, TIVA_ADI4_AUX_MASK8B +
|
||||||
}
|
(TIVA_ADI4_AUX_COMP_OFFSET * 2));
|
||||||
|
|
||||||
/* Third part of trim done after cold reset and wakeup from shutdown:
|
/* Third part of trim done after cold reset and wakeup from shutdown:
|
||||||
* -Configure HPOSC. -Setup the LF clock.
|
* -Configure HPOSC. -Setup the LF clock.
|
||||||
@@ -470,7 +458,7 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
putreg32(regval, TIVA_FLASH_CFG);
|
putreg32(regval, TIVA_FLASH_CFG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Name: trim_coldreset
|
* Name: trim_coldreset
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -479,18 +467,18 @@ static void trim_wakeup_fromshutdown(uint32_t fcfg1_revision)
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void trim_coldreset(void)
|
static void trim_coldreset(void)
|
||||||
{
|
{
|
||||||
/* Currently no specific trim for Cold Reset */
|
/* Currently no specific trim for Cold Reset */
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/******************************************************************************
|
/****************************************************************************
|
||||||
* Name: cc13xx_trim_device
|
* Name: cc13xx_trim_device
|
||||||
*
|
*
|
||||||
* Descriptions:
|
* Descriptions:
|
||||||
@@ -500,7 +488,7 @@ static void trim_coldreset(void)
|
|||||||
* implementation does not take soft reset into account. However, it does no
|
* implementation does not take soft reset into account. However, it does no
|
||||||
* damage to execute it again. It only consumes time.
|
* damage to execute it again. It only consumes time.
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void cc13xx_trim_device(void)
|
void cc13xx_trim_device(void)
|
||||||
{
|
{
|
||||||
@@ -545,8 +533,7 @@ void cc13xx_trim_device(void)
|
|||||||
if ((getreg32(TIVA_AON_IOC_IOCLATCH) & AON_IOC_IOCLATCH_EN) == 0)
|
if ((getreg32(TIVA_AON_IOC_IOCLATCH) & AON_IOC_IOCLATCH_EN) == 0)
|
||||||
{
|
{
|
||||||
/* NB. This should be calling a ROM implementation of required trim and
|
/* NB. This should be calling a ROM implementation of required trim and
|
||||||
* compensation e.g.
|
* compensation e.g. trim_wakeup_frompowerdown()
|
||||||
* trim_wakeup_frompowerdown()
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
trim_wakeup_frompowerdown();
|
trim_wakeup_frompowerdown();
|
||||||
@@ -559,8 +546,8 @@ void cc13xx_trim_device(void)
|
|||||||
* re-established.
|
* re-established.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if ((getreg32(TIVA_AON_PMCTL_SLEEPCTL) & AON_PMCTL_SLEEPCTL_IO_PAD_SLEEP_DIS)
|
else if ((getreg32(TIVA_AON_PMCTL_SLEEPCTL) &
|
||||||
== 0)
|
AON_PMCTL_SLEEPCTL_IO_PAD_SLEEP_DIS) == 0)
|
||||||
{
|
{
|
||||||
/* NB. This should be calling a ROM implementation of required trim and
|
/* NB. This should be calling a ROM implementation of required trim and
|
||||||
* compensation e.g. trim_wakeup_fromshutdown() -->
|
* compensation e.g. trim_wakeup_fromshutdown() -->
|
||||||
@@ -572,8 +559,8 @@ void cc13xx_trim_device(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Consider adding a check for soft reset to allow debugging to skip this
|
/* Consider adding a check for soft reset to allow debugging to skip
|
||||||
* section!!! NB. This should be calling a ROM implementation of
|
* this section!!! NB. This should be calling a ROM implementation of
|
||||||
* required trim and compensation e.g. trim_coldreset() -->
|
* required trim and compensation e.g. trim_coldreset() -->
|
||||||
* trim_wakeup_fromshutdown() -->
|
* trim_wakeup_fromshutdown() -->
|
||||||
* trim_wakeup_frompowerdown()
|
* trim_wakeup_frompowerdown()
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ void __start(void)
|
|||||||
showprogress('E');
|
showprogress('E');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_TIVA_CC26X2_POWERLIB /* REVISIT */
|
#ifdef CONFIG_TIVA_CC26X2_POWERLIB /* REVISIT: Used with CC13x2 as well. */
|
||||||
/* Initialize the Power Manager internal state. This must be called prior
|
/* Initialize the Power Manager internal state. This must be called prior
|
||||||
* to any other Power API.
|
* to any other Power API.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user