1 /******************************************************************************
2 * Filename: aon_pmctl.h
3 *
4 * Description: Defines and prototypes for the AON Power-Management Controller
5 *
6 * Copyright (c) 2015 - 2022, Texas Instruments Incorporated
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1) Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2) Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36
37 //*****************************************************************************
38 //
39 //! \addtogroup aon_group
40 //! @{
41 //! \addtogroup aonpmctl_api
42 //! @{
43 //
44 //*****************************************************************************
45
46 #ifndef __AON_PMCTL_H__
47 #define __AON_PMCTL_H__
48
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include "../inc/hw_types.h"
63 #include "../inc/hw_memmap.h"
64 #include "../inc/hw_memmap_common.h"
65 #include "../inc/hw_aon_pmctl.h"
66 #include "debug.h"
67
68 //*****************************************************************************
69 //
70 // Defines that can be be used to enable/disable the retention on the SRAM
71 // banks during power off of the MCU BUS domain. The defines can be passed to
72 // AONPMCTLMcuSRamConfig) .
73 //
74 //*****************************************************************************
75 #define MCU_RAM_RET_NONE AON_PMCTL_RAMCFG_BUS_SRAM_RET_EN_RET_NONE
76 #define MCU_RAM_RET_LVL1 AON_PMCTL_RAMCFG_BUS_SRAM_RET_EN_RET_LEVEL1
77 #define MCU_RAM_RET_LVL2 AON_PMCTL_RAMCFG_BUS_SRAM_RET_EN_RET_LEVEL2
78 #define MCU_RAM_RET_LVL3 AON_PMCTL_RAMCFG_BUS_SRAM_RET_EN_RET_LEVEL3
79 #define MCU_RAM_RET_FULL AON_PMCTL_RAMCFG_BUS_SRAM_RET_EN_RET_FULL
80
81 //*****************************************************************************
82 //
83 // Defines for all the different power modes available through
84 // AONPMCTLPowerStatusGet() .
85 //
86 //*****************************************************************************
87 #define AONPMCTL_JTAG_POWER_ON AON_PMCTL_PWRSTAT_JTAG_PD_ON
88
89 //*****************************************************************************
90 //
91 // API Functions and prototypes
92 //
93 //*****************************************************************************
94
95 //*****************************************************************************
96 //
97 //! \brief Configure the retention on the block SRAM in the MCU BUS domain.
98 //!
99 //! MCU SRAM is partitioned into 5 banks of 16 KB each. The SRAM supports
100 //! retention on all 5 banks during MCU BUS domain power off. The retention
101 //! on the SRAM can be turned on and off. Use this function to enable the
102 //! retention on the banks.
103 //!
104 //! If a group of banks is not represented in the parameter \c ui32Retention
105 //! then the retention will be disabled for that bank group during MCU BUS
106 //! domain power off.
107 //!
108 //! \note Retention on all SRAM banks is enabled by default. Configuration of
109 //! individual SRAM banks is not supported. Configuration is only supported
110 //! on bank group level.
111 //!
112 //! \param ui32Retention defines which groups of SRAM banks to enable/disable
113 //! retention on:
114 //! - \ref MCU_RAM_RET_NONE Retention is disabled
115 //! - \ref MCU_RAM_RET_LVL1 Retention on for banks 0 and 1
116 //! - \ref MCU_RAM_RET_LVL2 Retention on for banks 0, 1 and 2
117 //! - \ref MCU_RAM_RET_LVL3 Retention on for banks 0, 1, 2 and 3
118 //! - \ref MCU_RAM_RET_FULL Retention on for all five banks
119 //!
120 //! \return None
121 //
122 //*****************************************************************************
123 __STATIC_INLINE void
AONPMCTLMcuSRamRetConfig(uint32_t ui32Retention)124 AONPMCTLMcuSRamRetConfig(uint32_t ui32Retention)
125 {
126 uint32_t ui32Reg;
127
128 // Check the arguments.
129 ASSERT((ui32Retention == MCU_RAM_RET_NONE) ||
130 (ui32Retention == MCU_RAM_RET_LVL1) ||
131 (ui32Retention == MCU_RAM_RET_LVL2) ||
132 (ui32Retention == MCU_RAM_RET_LVL3) ||
133 (ui32Retention == MCU_RAM_RET_FULL));
134
135 // Configure the retention.
136 ui32Reg = HWREG(AON_PMCTL_BASE + NONSECURE_OFFSET + AON_PMCTL_O_RAMCFG) & ~AON_PMCTL_RAMCFG_BUS_SRAM_RET_EN_M;
137 ui32Reg |= ui32Retention;
138 HWREG(AON_PMCTL_BASE + NONSECURE_OFFSET + AON_PMCTL_O_RAMCFG) = ui32Reg;
139 }
140
141 //*****************************************************************************
142 //
143 //! \brief Get the power status of the Always On (AON) domain.
144 //!
145 //! This function reports the power management status in AON.
146 //!
147 //! \return Returns the current power status of the device as a bitwise OR'ed
148 //! combination of these values:
149 //! - \ref AONPMCTL_JTAG_POWER_ON
150 //
151 //*****************************************************************************
152 __STATIC_INLINE uint32_t
AONPMCTLPowerStatusGet(void)153 AONPMCTLPowerStatusGet(void)
154 {
155 // Return the power status.
156 return (HWREG(AON_PMCTL_BASE + NONSECURE_OFFSET + AON_PMCTL_O_PWRSTAT));
157 }
158
159
160 //*****************************************************************************
161 //
162 //! \brief Request power off of the JTAG domain.
163 //!
164 //! The JTAG domain is automatically powered up on if a debugger is connected.
165 //! If a debugger is not connected this function can be used to power off the
166 //! JTAG domain.
167 //!
168 //! \note Achieving the lowest power modes (shutdown/powerdown) requires the
169 //! JTAG domain to be turned off. In general the JTAG domain should never be
170 //! powered in production code.
171 //!
172 //! \return None
173 //
174 //*****************************************************************************
175 __STATIC_INLINE void
AONPMCTLJtagPowerOff(void)176 AONPMCTLJtagPowerOff(void)
177 {
178 // Request the power off of the JTAG domain
179 HWREG(AON_PMCTL_BASE + AON_PMCTL_O_JTAGCFG) = 0;
180 }
181
182
183 //*****************************************************************************
184 //
185 // Mark the end of the C bindings section for C++ compilers.
186 //
187 //*****************************************************************************
188 #ifdef __cplusplus
189 }
190 #endif
191
192 #endif // __AON_PMCTL_H__
193
194 //*****************************************************************************
195 //
196 //! Close the Doxygen group.
197 //! @}
198 //! @}
199 //
200 //*****************************************************************************
201