blob: 902e52a6094ba11126051f1c17663abc22321c14 [file] [log] [blame] [view]
Hugo McNallyf6298b32023-02-12 14:47:22 +00001# Reset Manager HWIP Technical Specification
Timothy Chen1e68dd82020-09-22 16:20:17 -07002
3# Overview
4
5This document describes the functionality of the reset controller and its interaction with the rest of the OpenTitan system.
6
7## Features
8
9* Stretch incoming POR.
10* Cascaded system resets.
11* Peripheral system reset requests.
12* RISC-V non-debug-module reset support.
13* Limited and selective software controlled module reset.
14* Always-on reset information register.
Timothy Chenf92131e2021-03-31 16:17:38 -070015* Always-on alert crash dump register.
Dan McArdlea5ca8fc2022-09-27 12:48:08 -040016* Always-on CPU crash dump register.
Timothy Chen8ced7f22021-07-23 16:14:55 -070017* Reset consistency checks.
Timothy Chen1e68dd82020-09-22 16:20:17 -070018
19# Theory of Operation
20
21The OpenTitan reset topology and reset controller block diagram are shown in the diagram below.
Hugo McNallyaef0a662023-02-11 19:44:55 +000022The reset controller is closely related to the [power controller](../pwrmgr/README.md), please refer to that spec for details on how reset controller inputs are controlled.
Timothy Chen1e68dd82020-09-22 16:20:17 -070023
Hugo McNallyaef0a662023-02-11 19:44:55 +000024![Reset Topology](./doc/reset_topology.svg)
Timothy Chen1e68dd82020-09-22 16:20:17 -070025
26## Reset Topology
27
28The topology can be summarized as follows:
29
30* There are two reset domains
31 * Test Domain - Driven by `TRSTn`
Hugo McNallyaef0a662023-02-11 19:44:55 +000032 * Core Domain - Driven by internal [POR circuitry](../../top_earlgrey/ip/ast/README.md).
Timothy Chen1e68dd82020-09-22 16:20:17 -070033* Test domain is comprised of the following components
34 * SOC TAP and related DFT circuits
35 * RISC-V TAP (part of the `rv_dm` module)
36
37The test domain does not have sub reset trees.
38`TRSTn` is used directly by all components in the domain.
39
40The Core domain consists of all remaining logic and contains 4 sub reset trees, see table below.
41
42<table>
43 <tr>
44 <td>
45<strong>Reset Tree</strong>
46 </td>
47 <td><strong>Description</strong>
48 </td>
49 </tr>
50 <tr>
51 <td><code>rst_por_n</code>
52 </td>
53 <td><code>POR reset tree.</code>
54<p>
55<code>This reset is driven by ast, stretched inside the reset manager and resets all core domain logic in the design. </code>
56 </td>
57 </tr>
58 <tr>
59 <td><code>rst_lc_n</code>
60 </td>
61 <td><code>Life Cycle reset tree.</code>
62<p>
63<code>This reset is derived from rst_por_n and resets all logic in the design except:</code><ul>
64
Timothy Chen10ffeb62022-12-05 15:38:15 -080065<li><code>rv_dm</code>
66<li><code>A small portion of pinmux</code></li></ul>
Timothy Chen1e68dd82020-09-22 16:20:17 -070067 </td>
68 </tr>
69 <tr>
70 <td><code>rst_sys_n</code>
71 </td>
Timothy Chen10ffeb62022-12-05 15:38:15 -080072 <td><code>Debug reset tree.</code>
Timothy Chen1e68dd82020-09-22 16:20:17 -070073<p>
Timothy Chen10ffeb62022-12-05 15:38:15 -080074<code>This reset is derived from rst_por_n and resets debug domain logic excluded in the life cycle reset tree</code><ul>
Timothy Chen1e68dd82020-09-22 16:20:17 -070075 </td>
76 </tr>
77 <tr>
78 <td><code>rst_{module}_n</code>
79 </td>
80 <td><code>Module specific reset.</code>
81<p>
Timothy Chen10ffeb62022-12-05 15:38:15 -080082<code>This reset is derived from rst_lc_n and sets only the targeted module and nothing else.</code>
Timothy Chen1e68dd82020-09-22 16:20:17 -070083<p>
Timothy Chen10ffeb62022-12-05 15:38:15 -080084<code>For OpenTitan, the only current targets are spi_device, all instances of spi_host, all instances of i2c and usbdev</code>
Timothy Chen1e68dd82020-09-22 16:20:17 -070085 </td>
86 </tr>
87</table>
88
89The reset trees are cascaded upon one another in this order:
Timothy Chen10ffeb62022-12-05 15:38:15 -080090- `rst_por_n` -> `rst_lc_n` -> `rst_module_n`
91- `rst_por_n` -> `rst_sys_n` -> `rst_module_n`
Timothy Chen1e68dd82020-09-22 16:20:17 -070092This means when a particular reset asserts, all downstream resets also assert.
93
Timothy Chen10ffeb62022-12-05 15:38:15 -080094The primary difference between `rst_lc_n` and `rst_sys_n` is that the former controls the reset state of most logic in the system, while the latter controls the reset state only of the debug domain.
95This separation is required because the debug domain may request the system to reset while retaining debug info and control.
96This is particularly useful if one wanted to debug something early during the boot flow, and thus needed to set a break point after requesting a debug reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -070097
98The reset topology also contains additional properties:
99* Selective processor HART resets, such as `hartreset` in `dmcontrol`, are not implemented, as it causes a security policy inconsistency with the remaining system.
100 * Specifically, these selective resets can cause the cascaded property shown above to not be obeyed.
Timothy Chenb1f413b2022-02-01 14:53:03 -0800101* Modules do not implement local resets that wipe configuration registers, especially if there are configuration locks.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700102 * Modules are allowed to implement local soft resets that clear datapaths; but these are examined on a case by case basis for possible security side channels.
103* In a production system, the Test Reset Input (`TRSTn`) should be explicitly asserted through system integration.
104 * In a production system, `TRSTn` only needs to be released for RMA transitions and nothing else.
105.
106
107## Reset Manager
108
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700109The reset manager handles the reset of the core domain, and also holds relevant reset information in CSR registers, such as:
Timothy Chen1e68dd82020-09-22 16:20:17 -0700110
Hugo McNally6321c5e2023-02-16 21:39:55 +0000111* [`RESET_INFO`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#reset_info) indicates why the system was reset.
112* [`ALERT_INFO`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#alert_info) contains the recorded alert status prior to system reset.
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700113 * This is useful in case the reset was triggered by an alert escalation.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000114* [`CPU_INFO`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#cpu_info) contains recorded CPU state prior to system reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700115 * This is useful in case the reset was triggered by a watchdog where the host hung on a particular bus transaction.
116
117Additionally, the reset manager, along with the power manager, accepts requests from the system and asserts resets for the appropriate clock trees.
118These requests primarily come from the following sources:
Hugo McNallyaef0a662023-02-11 19:44:55 +0000119* Peripherals capable of reset requests: such as [sysrst_ctrl](../sysrst_ctrl/README.md) and [always on timers ](../aon_timer/README.md).
Timothy Chen1e68dd82020-09-22 16:20:17 -0700120* Debug modules such as `rv_dm`.
121* Power manager request for low power entry and exit.
Timothy Chen10ffeb62022-12-05 15:38:15 -0800122* Escalation reset requests such as those from `alert_handler` or `pwrmgr` itself.
Timothy Chenb1f413b2022-02-01 14:53:03 -0800123* Direct software request for reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700124
125### Shadow Resets
126
Timothy Chenb1f413b2022-02-01 14:53:03 -0800127OpenTitan supports the shadow configuration registers.
128These are registers stored in two constantly checking copies to ensure the values are not maliciously or accidentally disturbed.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700129For these components, the reset manager outputs a shadow reset dedicated to resetting only the shadow storage.
130This reset separation ensures that a targetted attack on the reset line cannot easily defeat shadow registers.
131
Timothy Chen8ced7f22021-07-23 16:14:55 -0700132### Reset Consistency Checks
133
134The reset manager implements reset consistency checks to ensure that triggered resets are supposed to happen and not due to some fault in the system.
135Every leaf reset in the system has an associated consistency checker.
136
137The consistency check ensures that when a leaf reset asserts, either its parent reset must have asserted, or the software request, if available, has asserted.
138While this sounds simple in principle, the check itself crosses up to 3 clock domains and must be carefully managed.
139
140First, the parent and leaf resets are used to asynchronously assert a flag indication.
141This flag indication is then synchronized into the reset manager's local clock domain.
142
143The reset manager then checks as follows:
144- If a leaf reset has asserted, check to see either its parent or software request (synchronous to the local domain) has asserted.
145
146- If the condition is not true, it is possible the parent reset indication is still being synchronized, thus we wait for the parent indication.
147
148- It is also possible the parent indication was seen first, but the leaf condition was not, in this case, we wait for the leaf indication.
149
150- A timeout period corresponding to the maximum synchronization delay is used to cover both waits.
151 - If the appropriate pairing is not seen in the given amount of time, signal an error, as the leaf reset asserted without cause.
152
153- If all reset conditions are satisfied, wait for the reset release to gracefully complete the cycle.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700154
155## Hardware Interfaces
156
Timothy Chen10ffeb62022-12-05 15:38:15 -0800157### Parameters
158
159The following table lists the instantiation parameters of `rstmgr`.
160
161
162Parameter | Default | Description
163----------------------------|---------------|---------------
164`SecCheck` | 1 | Enables reset consistency checks on the leaf reset. Each check contains a small FSM.
165`SecMaxSyncDelay` | 2 | The default synchronization delay assumptions used in reset consistency checks. If a design uses a sync cell with more stages of delay, that value should be supplied.
166
Timothy Chen1e68dd82020-09-22 16:20:17 -0700167
168### Signals
169
Hugo McNallyba16bae2023-02-12 21:08:04 +0000170* [Interface Tables](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#interfaces)
Timothy Chen1e68dd82020-09-22 16:20:17 -0700171
172## Design Details
173
174The reset manager generates the resets required by the system by synchronizing reset tree components to appropriate output clocks.
175As a result, a particular reset tree (for example `rst_lc_n`) may have multiple outputs depending on the clock domains of its consumers.
176
177Each reset tree is discussed in detail below.
178
Timothy Chen1e68dd82020-09-22 16:20:17 -0700179## POR Reset Tree
180
181The POR reset tree, `rst_por_n`, is the root reset of the entire device.
182If this reset ever asserts, everything in the design is reset.
183
184The `ast` input `aon_pok` is used as the root reset indication.
185It is filtered and stretched to cover any slow voltage ramp scenarios.
186The stretch parameters are design time configurations.
187
188* The filter acts as a synchronizer and is by default 3 stages.
189* The count by default is 32.
Timothy Chen7e5ab7a2022-02-23 17:24:51 -0800190 * The counter increments only when all stages of the filter are 1.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700191 * If any stage at any point becomes '0', the reset counter returns to 0 and downstream logic is driven to reset again.
192* Both functions are expected to operate on slow, always available KHz clocks.
193
194
195## Life Cycle Reset Tree
196
197Life cycle reset, `rst_lc_n` asserts under the following conditions:
198* Whenever `rst_por_n` asserts.
Timothy Chen10ffeb62022-12-05 15:38:15 -0800199* Whenever a peripheral reset request (always on timer watchdog, rbox reset request, alert handler escalation, direct software request) is received.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700200
201The `rst_lc_n` tree contains both always-on and non-always-on versions.
202How many non-always-on versions is dependent on how many power domains are supported by the system.
203
204## System Reset Tree
205
Timothy Chen10ffeb62022-12-05 15:38:15 -0800206System reset, `rst_sys_n` , assertion depends on life cycle state.
207
208When in PROD and PROD_END states, `rst_sys_n` is identical to `rst_lc_n`.
209
210When in TEST, RMA and DEV states, `rst_sys_n` is identical to `rst_lc_n` unless the reset request is `ndmreset_req`.
211`ndmreset_req` is issued by the debug module of the system, it requests for all logic, except those needed to maintain debug state to reset.
212
213Since `ndmreset_req` is valid only during TEST, RMA and DEV states, it is the only place where the reset is differentiated.
214During these states, when `ndmreset_req` is issued, all logic except the debug module and associated glue logic are reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700215
216The `rst_sys_n` tree contains both always-on and non-always-on versions.
217How many non-always-on versions is dependent on how many power domains are supported by the system.
218
219## Output Leaf Resets
220
221The reset trees discussed above are not directly output to the system for consumption.
222Instead, the output leaf resets are synchronized versions of the various root resets.
223How many leaf resets there are and to which clock is decided by the system and templated through the reset manager module.
224
225Assuming a leaf output has N power domains and M clock domains, it potentially means one reset tree may output NxM outputs to satisfy all the reset scenario combinations.
226
227## Power Domains and Reset Trees
228
229It is alluded above that reset trees may contain both always-on and non-always-on versions.
230This distinction is required to support power manager's various low power states.
Guillermo Maturanac95d1282021-08-12 11:09:23 -0700231When a power domain goes offline, all of its components must reset, regardless of the reset tree to which it belongs.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700232
233For example, assume a system with two power domains - `Domain A` is always-on, and `Domain B` is non-always-on.
234When `Domain B` is powered off, all of `Domain B`'s resets, from `rst_lc_n`, `rst_sys_n` to `rst_module_n` are asserted.
235However, the corresponding resets for `Domain A` are left untouched because it has not been powered off.
236
237## Software Controlled Resets
238
239Certain leaf resets can be directly controlled by software.
240Due to security considerations, most leaf resets cannot be controlled, only a few blocks are given exceptions.
Timothy Chen10ffeb62022-12-05 15:38:15 -0800241The only blocks currently allowed to software reset are `spi_device`, `usbdev`, `spi_host` and `i2c`.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700242
243The criteria for selecting which block is software reset controllable is meant to be overly restrictive.
244Unless there is a clear need, the default option is to not provide reset control.
245
246In general, the following rules apply:
247* If a module has configuration register lockdown, it cannot be software resettable.
248* If a module operates on secret data (keys), it cannot be software resettable.
249 * Or a software reset should render the secret data unusable until some initialization routine is run to reduce the Hamming leakage of secret data.
250* If a module can alter the software's perception of time or general control flow (timer or interrupt aggregator), it cannot be software resettable.
251* If a module contains sensor functions for security, it cannot be software resettable.
252* If a module controls life cycle or related function, it cannot be software resettable.
253
Timothy Chen10ffeb62022-12-05 15:38:15 -0800254## Summary
255
256The following table summarizes the different reset requests and which part of each reset tree, along with what power domain is affected.
257
258Reset Request Type | Example | POR Reset Tree | LC Reset Tree | SYS Reset Tree | Module Specific Reset
259----------------------------------| --------------------------------------------------------------| ---------------| ------------- | --------------- | ----------------------
260POR | VCC toggle, POR_N pad toggle | all domains | all domains | all domains | all domains
261HW reset Request | `aon_timer` reset request, `alert_handler` escalation request | | all domains | all domains | all domains
262Directed SW system reset request | `rstmgr` SW_RESET | | all domains | all domains | all domains
263Ndm reset request (PROD/PROD_END) | `rv_dm` non-debug-module reset request in PROD | | all domains | all domains | all domains
264Ndm reset request (Other states) | `rv_dm` non-debug-module reset request in DEV | | all domains | | all domains
265SW low power entry | wait-for-interrupt deep sleep entry | | non-aon domains | non-aon domains | non-aon domains
266SW controlled reset request | `rstmgr` SW_RST_CTRL_N | | | | all domains
267
268
Timothy Chen1e68dd82020-09-22 16:20:17 -0700269## Reset Information
270
271The reset information register is a reflection of the reset state from the perspective of the system.
272In OpenTitan, since there is only 1 host, it is thus from the perspective of the processor.
273This also suggests that if the design had multiple processors, there would need to be multiple such registers.
274
275If a reset does not cause the processor to reset, there is no reason for the reset information to change (this is also why there is a strong security link between the reset of the processor and the rest of the system).
276The following are the currently defined reset reasons and their meaning:
277
278Reset Cause | Description
279------------------------|---------------
280`POR` | Cold boot, the system was reset through POR circuitry.
281`LOW_POWER_EXIT` | Warm boot, the system was reset through low power exit.
282`NDM RESET` | Warm boot, the system was reset through `rv_dm` non-debug-module request.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000283`SW_REQ` | Warm boot, the system was reset through [`RESET_REQ`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#reset_req).
Timothy Chen1e68dd82020-09-22 16:20:17 -0700284`HW_REQ` | Warm boot, the system was reset through peripheral requests. There may be multiple such requests.
285
286
287The reset info register is write 1 clear.
288It is software responsibility to clear old reset reasons; the reset manager simply records based on the rules below.
289
290Excluding power on reset, which is always recorded when the device POR circuitry is triggered, the other resets are recorded when authorized by the reset manager.
Timothy Chen1a55b242022-01-27 15:24:10 -0800291Reset manager authorization is based on reset categories as indicated by the power manager.
292The power manager has three reset categories that are mutually exclusive:
293* No reset has been triggered by pwrmgr.
294* Low power entry reset has been triggered by pwrmgr.
295* Software or peripheral reset request has been triggered by pwrmgr.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700296
Timothy Chen1a55b242022-01-27 15:24:10 -0800297The reset categories are sent to the reset manager so that it can decide which reason to record when the processor reset is observed.
298Non-debug-module resets are allowed only when no resets have been triggered by pwrmgr.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700299
300Since a reset could be motivated by multiple reasons (a security escalation during low power transition for example), the reset information registers constantly record all reset causes in which it is allowed.
301The only case where this is not done is `POR`, where active recording is silenced until the first processor reset release.
302
Timothy Chen1a55b242022-01-27 15:24:10 -0800303Even though four reset causes are labeled as warm boot, their effects on the system are not identical.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700304
Timothy Chen1a55b242022-01-27 15:24:10 -0800305* When the reset cause is `LOW_POWER_EXIT`, it means only the non-always-on domains have been reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700306 * Always-on domains retain their pre-low power values.
307* When the reset cause is `NDM_RESET`, it means only the `rst_sys_n` tree has asserted for all power domains.
Timothy Chen1a55b242022-01-27 15:24:10 -0800308* When the reset cause is `HW_REQ` or `SW_REQ`, it means everything other than power / clock / reset managers have reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700309
310This behavioral difference may be important to software, as it implies the configuration of the system may need to be different.
311
Timothy Chenf92131e2021-03-31 16:17:38 -0700312## Crash Dump Information
313
314The reset manager manages crash dump information for software debugging across unexpected resets and watchdogs.
Dan McArdlea5ca8fc2022-09-27 12:48:08 -0400315When enabled, the latest alert information and latest CPU information are captured in always-on registers.
Timothy Chenf92131e2021-03-31 16:17:38 -0700316
Dan McArdlea5ca8fc2022-09-27 12:48:08 -0400317When the software resumes after the reset, it is then able to examine the last CPU state or the last set of alert information to understand why the system has reset.
Timothy Chenf92131e2021-03-31 16:17:38 -0700318
319The enable for such debug capture can be locked such that it never captures.
320
321### Alert Information
Timothy Chen1e68dd82020-09-22 16:20:17 -0700322
323The alert information register contains the value of the alert crash dump prior to a triggered reset.
324Since this information differs in length between system implementation, the alert information register only displays 32-bits at a time.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000325The [`ALERT_INFO_ATTR`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#alert_info_attr) register indicates how many 32-bit data segments must be read.
Timothy Chen7e5ab7a2022-02-23 17:24:51 -0800326
Hugo McNally6321c5e2023-02-16 21:39:55 +0000327To enable alert crash dump capture, set [`ALERT_INFO_CTRL.EN`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#alert_info_ctrl) to 1.
328Once the system has reset, check [`ALERT_INFO_ATTR.CNT_AVAIL`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#alert_info_attr) for how many reads need to be done.
329Set [`ALERT_INFO_CTRL.INDEX`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#alert_info_ctrl) to the desired segment, and then read the output from [`ALERT_INFO`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#alert_info).
Timothy Chenf92131e2021-03-31 16:17:38 -0700330
331### CPU Information
332
Dan McArdlea5ca8fc2022-09-27 12:48:08 -0400333The CPU information register contains the value of the CPU state prior to a triggered reset.
Timothy Chenf92131e2021-03-31 16:17:38 -0700334Since this information differs in length between system implementation, the information register only displays 32-bits at a time.
335
Hugo McNallyaef0a662023-02-11 19:44:55 +0000336For more details on the CPU dump details, please see [crash dump](../rv_core_ibex/README.md#crash-dump-collection).
Timothy Chen6818b132022-02-22 14:29:14 -0800337
Hugo McNally6321c5e2023-02-16 21:39:55 +0000338The [`CPU_INFO_ATTR`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#cpu_info_attr) register indicates how many 32-bit data segments must be read.
339Software then simply needs to write in [`CPU_INFO_CTRL.INDEX`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#cpu_info_ctrl) which segment it wishes and then read out the [`CPU_INFO`](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#cpu_info) register.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700340
341# Programmers Guide
342
Timothy Trippelf82e75a2022-07-27 14:42:22 -0700343## Device Interface Functions (DIFs)
344
Hugo McNallyac9f9b52023-02-14 12:15:34 +0000345- [Device Interface Functions](../../../sw/device/lib/dif/dif_rstmgr.h)
Timothy Trippelf82e75a2022-07-27 14:42:22 -0700346
Timothy Chen1e68dd82020-09-22 16:20:17 -0700347## Register Table
348
Hugo McNallyba16bae2023-02-12 21:08:04 +0000349* [Register Table](../../top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson#registers)