blob: 8c012bec9d674b9455036adfe52a2167fbfca874 [file] [log] [blame] [view]
Timothy Chen1e68dd82020-09-22 16:20:17 -07001---
2title: "Reset Manager HWIP Technical Specification"
3---
4
5# Overview
6
7This document describes the functionality of the reset controller and its interaction with the rest of the OpenTitan system.
8
9## Features
10
11* Stretch incoming POR.
12* Cascaded system resets.
13* Peripheral system reset requests.
14* RISC-V non-debug-module reset support.
15* Limited and selective software controlled module reset.
16* Always-on reset information register.
Timothy Chenf92131e2021-03-31 16:17:38 -070017* Always-on alert crash dump register.
Dan McArdlea5ca8fc2022-09-27 12:48:08 -040018* Always-on CPU crash dump register.
Timothy Chen8ced7f22021-07-23 16:14:55 -070019* Reset consistency checks.
Timothy Chen1e68dd82020-09-22 16:20:17 -070020
21# Theory of Operation
22
23The OpenTitan reset topology and reset controller block diagram are shown in the diagram below.
24The reset controller is closely related to the [power controller]({{< relref "hw/ip/pwrmgr/doc" >}}), please refer to that spec for details on how reset controller inputs are controlled.
25
26![Reset Topology](reset_topology.svg)
27
28## Reset Topology
29
30The topology can be summarized as follows:
31
32* There are two reset domains
33 * Test Domain - Driven by `TRSTn`
Timothy Chenb1f413b2022-02-01 14:53:03 -080034 * Core Domain - Driven by internal [POR circuitry]({{< relref "hw/top_earlgrey/ip/ast/doc" >}}).
Timothy Chen1e68dd82020-09-22 16:20:17 -070035* Test domain is comprised of the following components
36 * SOC TAP and related DFT circuits
37 * RISC-V TAP (part of the `rv_dm` module)
38
39The test domain does not have sub reset trees.
40`TRSTn` is used directly by all components in the domain.
41
42The Core domain consists of all remaining logic and contains 4 sub reset trees, see table below.
43
44<table>
45 <tr>
46 <td>
47<strong>Reset Tree</strong>
48 </td>
49 <td><strong>Description</strong>
50 </td>
51 </tr>
52 <tr>
53 <td><code>rst_por_n</code>
54 </td>
55 <td><code>POR reset tree.</code>
56<p>
57<code>This reset is driven by ast, stretched inside the reset manager and resets all core domain logic in the design. </code>
58 </td>
59 </tr>
60 <tr>
61 <td><code>rst_lc_n</code>
62 </td>
63 <td><code>Life Cycle reset tree.</code>
64<p>
65<code>This reset is derived from rst_por_n and resets all logic in the design except:</code><ul>
66
67<li><code>Power manager</code>
68<li><code>Clock manager </code>
69<li><code>Reset manager</code></li></ul>
70
71 </td>
72 </tr>
73 <tr>
74 <td><code>rst_sys_n</code>
75 </td>
76 <td><code>System reset tree.</code>
77<p>
78<code>This reset is derived from rst_lc_n and resets all logic in the design except:</code><ul>
79
80<li><code>Power manager</code>
81<li><code>Clock manager</code>
82<li><code>Reset manager</code>
83<li><code>OTP controller</code>
84<li><code>Flash controller</code>
85<li><code>Life cycle controller</code>
86<li><code>Alert manager</code>
87<li><code>Always-on timers</code></li></ul>
88
89 </td>
90 </tr>
91 <tr>
92 <td><code>rst_{module}_n</code>
93 </td>
94 <td><code>Module specific reset.</code>
95<p>
96<code>This reset is derived from rst_sys_n and sets only the targeted module and nothing else.</code>
97<p>
98<code>For OpenTitan, the only current targets are spi_device and usb_device.</code>
99 </td>
100 </tr>
101</table>
102
103The reset trees are cascaded upon one another in this order:
104`rst_por_n` -> `rst_lc_n` -> `rst_sys_n` -> `rst_module_n`
105This means when a particular reset asserts, all downstream resets also assert.
106
Timothy Chenb1f413b2022-02-01 14:53:03 -0800107The primary difference between `rst_lc_n` and `rst_sys_n` is that the former controls the reset state of all non-volatile and life cycle related logic in the system, while the latter can be used to issue system resets for debug.
108This separation is required because the non-volatile controllers (`otp_ctrl` / `lc_ctrl`) are used to qualify DFT and debug functions of the design.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700109If these modules are reset along with the rest of the system, the TAP and related debug functions would also be reset.
110By keeping these reset trees separate, we allow the state of the test domain functions to persist while functionally resetting the rest of the core domain.
111
Timothy Chenb1f413b2022-02-01 14:53:03 -0800112Additionally, modules such as [alert handler](({{< relref "hw/top_earlgrey/ip_autogen/alert_handler/doc" >}})) and [aon timer]({{< relref "hw/ip/aon_timer/doc" >}}) (which contains the watchdog function) are also kept on the `rst_lc_n` tree.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700113This ensures that an erroneously requested system reset through `rst_sys_n` cannot silence the alert mechanism or prevent the system from triggering a watchdog mechanism.
114
115The reset topology also contains additional properties:
116* Selective processor HART resets, such as `hartreset` in `dmcontrol`, are not implemented, as it causes a security policy inconsistency with the remaining system.
117 * Specifically, these selective resets can cause the cascaded property shown above to not be obeyed.
Timothy Chenb1f413b2022-02-01 14:53:03 -0800118* Modules do not implement local resets that wipe configuration registers, especially if there are configuration locks.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700119 * 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.
120* In a production system, the Test Reset Input (`TRSTn`) should be explicitly asserted through system integration.
121 * In a production system, `TRSTn` only needs to be released for RMA transitions and nothing else.
122.
123
124## Reset Manager
125
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700126The 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 -0700127
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700128* {{< regref "RESET_INFO" >}} indicates why the system was reset.
129* {{< regref "ALERT_INFO" >}} contains the recorded alert status prior to system reset.
130 * This is useful in case the reset was triggered by an alert escalation.
131* {{< regref "CPU_INFO" >}} contains recorded CPU state prior to system reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700132 * This is useful in case the reset was triggered by a watchdog where the host hung on a particular bus transaction.
133
134Additionally, the reset manager, along with the power manager, accepts requests from the system and asserts resets for the appropriate clock trees.
135These requests primarily come from the following sources:
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700136* Peripherals capable of reset requests: such as [sysrst_ctrl]({{< relref "hw/ip/sysrst_ctrl/doc/_index.md" >}}) and [always on timers ]({{< relref "hw/ip/aon_timer/doc/_index.md" >}}).
Timothy Chen1e68dd82020-09-22 16:20:17 -0700137* Debug modules such as `rv_dm`.
138* Power manager request for low power entry and exit.
Timothy Chenb1f413b2022-02-01 14:53:03 -0800139* Direct software request for reset.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700140
141### Shadow Resets
142
Timothy Chenb1f413b2022-02-01 14:53:03 -0800143OpenTitan supports the shadow configuration registers.
144These 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 -0700145For these components, the reset manager outputs a shadow reset dedicated to resetting only the shadow storage.
146This reset separation ensures that a targetted attack on the reset line cannot easily defeat shadow registers.
147
Timothy Chen8ced7f22021-07-23 16:14:55 -0700148### Reset Consistency Checks
149
150The reset manager implements reset consistency checks to ensure that triggered resets are supposed to happen and not due to some fault in the system.
151Every leaf reset in the system has an associated consistency checker.
152
153The consistency check ensures that when a leaf reset asserts, either its parent reset must have asserted, or the software request, if available, has asserted.
154While this sounds simple in principle, the check itself crosses up to 3 clock domains and must be carefully managed.
155
156First, the parent and leaf resets are used to asynchronously assert a flag indication.
157This flag indication is then synchronized into the reset manager's local clock domain.
158
159The reset manager then checks as follows:
160- If a leaf reset has asserted, check to see either its parent or software request (synchronous to the local domain) has asserted.
161
162- If the condition is not true, it is possible the parent reset indication is still being synchronized, thus we wait for the parent indication.
163
164- 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.
165
166- A timeout period corresponding to the maximum synchronization delay is used to cover both waits.
167 - If the appropriate pairing is not seen in the given amount of time, signal an error, as the leaf reset asserted without cause.
168
169- If all reset conditions are satisfied, wait for the reset release to gracefully complete the cycle.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700170
171## Hardware Interfaces
172
Philipp Wagnere5203622021-03-15 19:59:09 +0000173{{< incGenFromIpDesc "/hw/top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson" "hwcfg" >}}
Timothy Chen1e68dd82020-09-22 16:20:17 -0700174
175### Signals
176
177Signal | Direction | Description
178------------------------|-----------|---------------
179`ast_i.aon_pok` | `input` | Input from `ast`. This signal is the root reset of the design and is used to generate `rst_por_n`.
180`cpu_i.rst_cpu_n` | `input` | CPU reset indication. This informs the reset manager that the processor has reset.
181`cpu_i.ndmreset_req` | `input` | Non-debug-module reset request from `rv_dm`.
Timothy Chen6818b132022-02-22 14:29:14 -0800182`cpu_dump_i` | `input` | CPU crash dump state from `rv_core_ibex`.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700183`pwr_i.rst_lc_req` | `input` | Power manager request to assert the `rst_lc_n` tree.
184`pwr_i.rst_sys_req` | `input` | Power manager request to assert the `rst_sys_n` tree.
185`pwr_i.reset_cause` | `input` | Power manager indication for why it requested reset, the cause can be low power entry or peripheral issued request.
186`pwr_i.rstreqs` | `input` | Peripheral reset requests.
187`pwr_o.rst_lc_src_n` | `output` | Current state of `rst_lc_n` tree.
188`pwr_o.rst_sys_src_n` | `output` | Current state of `rst_sys_n` tree.
189`resets_ast_o` | `output` | Resets used by `ast`.
190`resets_o` | `output` | Resets used by the rest of the core domain.
191
192## Design Details
193
194The reset manager generates the resets required by the system by synchronizing reset tree components to appropriate output clocks.
195As a result, a particular reset tree (for example `rst_lc_n`) may have multiple outputs depending on the clock domains of its consumers.
196
197Each reset tree is discussed in detail below.
198
199
200## POR Reset Tree
201
202The POR reset tree, `rst_por_n`, is the root reset of the entire device.
203If this reset ever asserts, everything in the design is reset.
204
205The `ast` input `aon_pok` is used as the root reset indication.
206It is filtered and stretched to cover any slow voltage ramp scenarios.
207The stretch parameters are design time configurations.
208
209* The filter acts as a synchronizer and is by default 3 stages.
210* The count by default is 32.
Timothy Chen7e5ab7a2022-02-23 17:24:51 -0800211 * The counter increments only when all stages of the filter are 1.
Timothy Chen1e68dd82020-09-22 16:20:17 -0700212 * If any stage at any point becomes '0', the reset counter returns to 0 and downstream logic is driven to reset again.
213* Both functions are expected to operate on slow, always available KHz clocks.
214
215
216## Life Cycle Reset Tree
217
218Life cycle reset, `rst_lc_n` asserts under the following conditions:
219* Whenever `rst_por_n` asserts.
220* Whenever a peripheral reset request (always on timer watchdog, rbox reset request, alert handler escalation) is received.
221
222The `rst_lc_n` tree contains both always-on and non-always-on versions.
223How many non-always-on versions is dependent on how many power domains are supported by the system.
224
225## System Reset Tree
226
227System reset, `rst_sys_n` asserts under the following conditions:
228* Whenever `rst_lc_n` asserts.
229* Whenever `ndmreset_req` asserts.
230
231The `rst_sys_n` tree contains both always-on and non-always-on versions.
232How many non-always-on versions is dependent on how many power domains are supported by the system.
233
234## Output Leaf Resets
235
236The reset trees discussed above are not directly output to the system for consumption.
237Instead, the output leaf resets are synchronized versions of the various root resets.
238How many leaf resets there are and to which clock is decided by the system and templated through the reset manager module.
239
240Assuming 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.
241
242## Power Domains and Reset Trees
243
244It is alluded above that reset trees may contain both always-on and non-always-on versions.
245This distinction is required to support power manager's various low power states.
Guillermo Maturanac95d1282021-08-12 11:09:23 -0700246When 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 -0700247
248For example, assume a system with two power domains - `Domain A` is always-on, and `Domain B` is non-always-on.
249When `Domain B` is powered off, all of `Domain B`'s resets, from `rst_lc_n`, `rst_sys_n` to `rst_module_n` are asserted.
250However, the corresponding resets for `Domain A` are left untouched because it has not been powered off.
251
252## Software Controlled Resets
253
254Certain leaf resets can be directly controlled by software.
255Due to security considerations, most leaf resets cannot be controlled, only a few blocks are given exceptions.
256The only blocks currently allowed to software reset are `usbdev` and `spidev`. Future potential candidates are `i2cdev`, `i2chost` and `spihost`.
257
258The criteria for selecting which block is software reset controllable is meant to be overly restrictive.
259Unless there is a clear need, the default option is to not provide reset control.
260
261In general, the following rules apply:
262* If a module has configuration register lockdown, it cannot be software resettable.
263* If a module operates on secret data (keys), it cannot be software resettable.
264 * Or a software reset should render the secret data unusable until some initialization routine is run to reduce the Hamming leakage of secret data.
265* If a module can alter the software's perception of time or general control flow (timer or interrupt aggregator), it cannot be software resettable.
266* If a module contains sensor functions for security, it cannot be software resettable.
267* If a module controls life cycle or related function, it cannot be software resettable.
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.
Timothy Chen7e5ab7a2022-02-23 17:24:51 -0800283`SW_REQ` | Warm boot, the system was reset through {{< regref "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.
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700325The {{< regref "ALERT_INFO_ATTR" >}} register indicates how many 32-bit data segments must be read.
Timothy Chen7e5ab7a2022-02-23 17:24:51 -0800326
327To enable alert crash dump capture, set {{< regref "ALERT_INFO_CTRL.EN" >}} to 1.
328Once the system has reset, check {{< regref "ALERT_INFO_ATTR.CNT_AVAIL" >}} for how many reads need to be done.
329Set {{< regref "ALERT_INFO_CTRL.INDEX" >}} to the desired segment, and then read the output from {{< regref "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
Dan McArdlea5ca8fc2022-09-27 12:48:08 -0400336For more details on the CPU dump details, please see [crash dump]({{< relref "hw/ip/rv_core_ibex/doc/_index.md#crash-dump-collection" >}}).
Timothy Chen6818b132022-02-22 14:29:14 -0800337
Guillermo Maturana67ff7722021-07-23 11:07:23 -0700338The {{< regref "CPU_INFO_ATTR" >}} register indicates how many 32-bit data segments must be read.
339Software then simply needs to write in {{< regref "CPU_INFO_CTRL.INDEX" >}} which segment it wishes and then read out the {{< regref "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
345{{< dif_listing "sw/device/lib/dif/dif_rstmgr.h" >}}
346
Timothy Chen1e68dd82020-09-22 16:20:17 -0700347## Register Table
348
Philipp Wagnere5203622021-03-15 19:59:09 +0000349{{< incGenFromIpDesc "/hw/top_earlgrey/ip/rstmgr/data/autogen/rstmgr.hjson" "registers" >}}