Hugo McNally | f6298b3 | 2023-02-12 14:47:22 +0000 | [diff] [blame] | 1 | # System Reset Control Technical Specification |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 2 | |
| 3 | # Overview |
| 4 | |
Michael Schaffner | 88db0fb | 2022-01-20 15:42:33 -0800 | [diff] [blame] | 5 | This document specifies the functionality of the System Reset Controller (`sysrst_ctrl`) that provides programmable hardware-level responses to trusted IOs and basic board-level reset sequencing capabilities. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 6 | These capabilities include keyboard and button combination-triggered actions, reset stretching for system-level reset signals, and internal reset / wakeup requests that go to the OpenTitan reset and power manager blocks. |
Hugo McNally | aef0a66 | 2023-02-11 19:44:55 +0000 | [diff] [blame] | 7 | This module conforms to the [Comportable guideline for peripheral functionality](../../../doc/contributing/hw/comportability/README.md). |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 8 | See that document for integration overview within the broader top level system. |
| 9 | |
| 10 | ## Features |
| 11 | |
| 12 | The IP block implements the following features: |
| 13 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 14 | - Always-on: uses the always-on power and clock domain |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 15 | - EC reset pulse duration control and stretching |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 16 | - Keyboard and button combination (combo) triggered action |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 17 | - AC_present can trigger interrupt |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 18 | - Configuration registers can be set and locked until the next chip reset |
| 19 | - Pin output override |
| 20 | |
| 21 | ## Description |
| 22 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 23 | The `sysrst_ctrl` logic is very simple. |
Marno van der Maas | 87ffdef | 2023-02-17 14:23:35 +0000 | [diff] [blame] | 24 | It looks up the configuration registers to decide how long the EC reset pulse duration and how long the key presses should be. |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 25 | Also what actions to take (e.g. Interrupt, EC reset, OpenTitan reset request, disconnect the battery from the power tree). |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 26 | |
| 27 | ## Compatibility |
| 28 | |
| 29 | The configuration programming interface is not based on any existing interface. |
| 30 | |
| 31 | # Theory of Operations |
| 32 | |
Hugo McNally | aef0a66 | 2023-02-11 19:44:55 +0000 | [diff] [blame] | 33 |  |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 34 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 35 | The block diagram above shows a conceptual view of the `sysrst_ctrl` block, which consists of 3 main modules: |
| 36 | The first is the configuration and status registers, the second is the keyboard combo debounce and detection logic, and the third is the pinout override logic. |
Marno van der Maas | 87ffdef | 2023-02-17 14:23:35 +0000 | [diff] [blame] | 37 | The debounce logic does not implement a low-pass filter, instead it uses a simpler technique of sampling once when the timer starts and then again when the timer ends. |
| 38 | The detection logic does require the signal to stay active for the entire period, which can be used to detect any anomoulous signals that might elude the rudimentary debounce logic. |
| 39 | For the auto block, key interrupt and ultra-low-power features there is only a debounce timer so it is good to be aware of this behavior of sampling the signal only twice. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 40 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 41 | The `sysrst_ctrl` has four input pins (`pwrb_in_i`, `key[0,1,2]_in_i`) with corresponding output pins (`pwrb_out`, `key[0,1,2]_out`). |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 42 | During normal operation the `sysrst_ctrl` will pass the pin information directly from the input pins to the output pins with optional inversion. |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 43 | Combinations of the inputs being active for a specified time can be detected and used to trigger actions. |
| 44 | The override logic allows the output to be overridden (i.e. not follow the corresponding input) based either on trigger or software settings. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 45 | This allows the security chip to take over the inputs for its own use without disturbing the main user. |
| 46 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 47 | The `sysrst_ctrl` also controls two active-low open-drain I/Os named `flash_wp_l_i` / `flash_wp_l_o` and `ec_rst_l_i` / `ec_rst_l_o`. |
| 48 | The `ec_rst_l_i` / `ec_rst_l_o` signals are connected to the same bidirectional pin of the OpenTitan chip, and are used to either reset the embedded controller (EC), or to detect self-reset of the EC and stretch the reset pulse (hence the bidirectional nature of this pin). |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 49 | This output is always asserted when `sysrst_ctrl` is reset (allowing its use as a power-on reset) and remains asserted until released by software. |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 50 | The flash write-protect output `flash_wp_l_o` is typically connected to the BIOS flash chip in the system. |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 51 | This output is always asserted when the `sysrst_ctrl` block is reset and remains asserted until released by software. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 52 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 53 | ## Hardware Interfaces |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 54 | |
Hugo McNally | ba16bae | 2023-02-12 21:08:04 +0000 | [diff] [blame] | 55 | * [Interface Tables](data/sysrst_ctrl.hjson#interfaces) |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 56 | |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 57 | ## Combo detection |
| 58 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 59 | Software can program the `sysrst_ctrl` block to detect certain button combos and for how long they have to be asserted until they trigger a programmable action. |
Michael Schaffner | fee5874 | 2022-12-22 08:45:22 +0100 | [diff] [blame] | 60 | A combo is a combination of multiple keys that are pressed together for a programmable amount of time. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 61 | |
Michael Schaffner | fee5874 | 2022-12-22 08:45:22 +0100 | [diff] [blame] | 62 | In order to detect a combo, the hardware first OR's the active-low key-pressed indications and debounces the combined trigger signal. |
| 63 | The hardware then detects a negative edge on the combined trigger signal and checks whether it stays asserted low for the programmed amount of cycles. |
| 64 | If the combined trigger signal fulfills the programmed timing constraint, a combo is detected. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 65 | |
Michael Schaffner | fee5874 | 2022-12-22 08:45:22 +0100 | [diff] [blame] | 66 | Optionally, a combo detection channel may also specify a pre-condition. |
| 67 | Such a pre-condition is a set of keys that must remain pressed in order to activate the combo detection circuit. |
| 68 | The main difference with respect to the combo detection circuit is that the pre-condition checks for a low level of the combined key-pressed indications instead of checking for a negative edge. |
| 69 | The pre-condition debounce timing is the same as for combo detection, but the key-pressed timing can be configured independently. |
| 70 | |
| 71 | Let's use the "Power button + Key0 + Key1" combo with pre-condition "Key2" as an example: |
| 72 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 73 | 0. Software can define the key value `key2_in_i==0` as pre-condition in the [`COM_PRE_SEL_CTL_0`](../spi_host/data/spi_host.hjson#com_pre_sel_ctl_0) register. |
| 74 | 1. The key-pressed time for the pre-condition (e.g. 2 seconds) can be configured via the [`COM_DET_SEL_CTL_0`](../spi_host/data/spi_host.hjson#com_det_sel_ctl_0) register. |
| 75 | 2. Software can define the three key values `pwrb_in_i==0`, `key0_in_i==0` and `key1_in_i==0` as trigger combination in the [`COM_SEL_CTL_0`](../spi_host/data/spi_host.hjson#com_sel_ctl_0) register. |
| 76 | 3. The combo duration for which the above combo should be pressed (e.g. 10 seconds) can be configured via the [`COM_DET_CTL_0`](../spi_host/data/spi_host.hjson#com_det_ctl_0) register. |
| 77 | 4. Actions such as asserting `ec_rst_l_o` and raising an interrupt can be configured via the [`COM_OUT_CTL_0`](../spi_host/data/spi_host.hjson#com_out_ctl_0) register. |
| 78 | 5. The pulse width of the `ec_rst_l_o` pulse can be set in the [`EC_RST_CTL`](../spi_host/data/spi_host.hjson#ec_rst_ctl) register. |
| 79 | 6. The software can optionally lock the `sysrst_ctrl` configuration via [`REGWEN`](../spi_host/data/spi_host.hjson#regwen) |
Michael Schaffner | fee5874 | 2022-12-22 08:45:22 +0100 | [diff] [blame] | 80 | |
| 81 | Once the above configuration is active, `sysrst_ctrl` will start the timer when the pre-condition is valid (logic 0 level on all pre-condition signals). |
| 82 | If the timing condition (2 seconds) is met, `systrst_ctrl` will enable combo detection, and wait for a high (logic 1) to low (logic 0) transition of the combined trigger signal. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 83 | If a transition is seen, and the timing condition is met (10 seconds), `sysrst_ctrl` will assert `ec_rst_l_o`, the interrupt request and set the interrupt status register [`COMBO_INTR_STATUS`](../spi_host/data/spi_host.hjson#combo_intr_status) to indicate the interrupt cause. |
| 84 | The software interrupt handler should then read the [`COMBO_INTR_STATUS`](../spi_host/data/spi_host.hjson#combo_intr_status) register and clear the interrupt via the [`INTR_STATE`](../spi_host/data/spi_host.hjson#intr_state) register. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 85 | |
Michael Schaffner | 9c0b24d | 2022-08-05 13:56:09 -0700 | [diff] [blame] | 86 | Note that an interrupt will also issue a wakeup request to the OpenTitan power manager via `wkup_req_o`. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 87 | Software should therefore read and clear the [`WKUP_STATUS`](../spi_host/data/spi_host.hjson#wkup_status) register as well. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 88 | |
Michael Schaffner | 2babd94 | 2022-02-04 20:19:18 -0800 | [diff] [blame] | 89 | ### Combo actions |
| 90 | |
| 91 | The following four combo actions can be triggered: |
| 92 | |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 93 | - Drive the `bat_disable` output high until the next reset. |
Michael Schaffner | 9c0b24d | 2022-08-05 13:56:09 -0700 | [diff] [blame] | 94 | - Issue an interrupt to the processor via `intr_event_detected_o`. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 95 | - Assert `ec_rst_l_o` for the amount of cycles configured in [`EC_RST_CTL`](../spi_host/data/spi_host.hjson#ec_rst_ctl). |
Michael Schaffner | 9c0b24d | 2022-08-05 13:56:09 -0700 | [diff] [blame] | 96 | - Issue a reset request via `rst_req_o` to the reset manager of the OpenTitan system. Note that once a reset request is issued, it will remain asserted until the next reset. |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 97 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 98 | These actions can be configured via the [`COM_OUT_CTL_0`](../spi_host/data/spi_host.hjson#com_out_ctl_0) register for each of the combo blocks as described in the previous section. |
Michael Schaffner | 2babd94 | 2022-02-04 20:19:18 -0800 | [diff] [blame] | 99 | |
| 100 | ### Hardwired reset stretching functionality |
| 101 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 102 | In addition to the combo action described above, `ec_rst_l_o` is automatically asserted for the amount of cycles defined in the [`EC_RST_CTL`](../spi_host/data/spi_host.hjson#ec_rst_ctl) register whenever the `ec_rst_l_i` input is asserted (i.e., when it transitions from high to low). |
Michael Schaffner | 2babd94 | 2022-02-04 20:19:18 -0800 | [diff] [blame] | 103 | |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 104 | ## Auto-block key outputs |
| 105 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 106 | Software can program the `sysrst_ctrl` block to override the output value of specific passthrough signals, depending on whether certain input signals are asserted or not. |
| 107 | Let's use the "Power button + Esc + Refresh" combo as an example. |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 108 | When `pwrb_in_i` is asserted, `key1_out_o` (row) should be overridden so that `sysrst_ctrl` can detect if `key0_in_i` (column) is Refresh. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 109 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 110 | 1. The software enables the auto block feature and sets an appropriate debounce timer value in the [`AUTO_BLOCK_DEBOUNCE_CTL`](../spi_host/data/spi_host.hjson#auto_block_debounce_ctl) register. |
| 111 | 2. The software then defines the key outputs to auto override and their override values in the [`AUTO_BLOCK_OUT_CTL`](../spi_host/data/spi_host.hjson#auto_block_out_ctl) register. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 112 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 113 | Once the above configuration is active, `sysrst_ctrl` will detect a high (logic 1) to low (logic 0) transition on `pwrb_in_i` and check whether the key `pwrb_in_i` stays low for the programmed duration. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 114 | If this condition is met, `sysrst_ctrl` will drive `key1_out_o` to the value programmed in [`AUTO_BLOCK_OUT_CTL`](../spi_host/data/spi_host.hjson#auto_block_out_ctl). |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 115 | |
| 116 | ## Keyboard and input triggered interrupt |
| 117 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 118 | Software can program the `sysrst_ctrl` block to detect edge transitions on the `pwrb_in_i`, `key0_in_i`, `key1_in_i`, `key2_in_i`, `ac_present_i`, `ec_rst_l_i` and `flash_wp_l_i` signals and trigger an interrupt: |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 119 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 120 | 1. Software first defines the input signal and the edge transition to detect (H->L or L->H) via the [`KEY_INTR_CTL`](../spi_host/data/spi_host.hjson#key_intr_ctl) register. |
| 121 | 2. The software then programs an appropriate debounce timer value to the [`KEY_INTR_DEBOUNCE_CTL`](../spi_host/data/spi_host.hjson#key_intr_debounce_ctl) register. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 122 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 123 | For example, when the power button is pressed, `pwrb_in_i` goes from logic 1 to logic 0 which would amount to an H->L transition. |
| 124 | Likewise, when the power button is released, `pwrb_in_i` goes from logic 0 to logic 1 which would amount to an L->H transition. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 125 | When `sysrst_ctrl` detects a transition (H->L or L->H) as specified in [`KEY_INTR_CTL`](../spi_host/data/spi_host.hjson#key_intr_ctl) and it meets the debounce requirement in [`KEY_INTR_DEBOUNCE_CTL`](../spi_host/data/spi_host.hjson#key_intr_debounce_ctl), `sysrst_ctrl` sets the [`KEY_INTR_STATUS`](../spi_host/data/spi_host.hjson#key_intr_status) register to indicate the interrupt cause and send out a consolidated interrupt to the PLIC. |
| 126 | The software interrupt handler should then read the [`KEY_INTR_STATUS`](../spi_host/data/spi_host.hjson#key_intr_status) register and clear the interrupt via the [`INTR_STATE`](../spi_host/data/spi_host.hjson#intr_state) register. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 127 | |
Michael Schaffner | 9c0b24d | 2022-08-05 13:56:09 -0700 | [diff] [blame] | 128 | Note that an interrupt will also issue a wakeup request to the OpenTitan power manager via `wkup_req_o`. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 129 | Software should therefore read and clear the [`WKUP_STATUS`](../spi_host/data/spi_host.hjson#wkup_status) register as well. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 130 | |
| 131 | ## Ultra-low-power Wakeup Feature |
| 132 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 133 | Software can program the `sysrst_ctrl` block to detect certain specific signal transitions on the (possibly inverted) `ac_present_i`, `pwrb_in_i` and `lid_open_i` inputs. |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 134 | As opposed to the combo detection and general key interrupt features above, this is a fixed function feature with limited configurability. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 135 | In particular, the transitions that can be detected are fixed to the following: |
| 136 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 137 | - A high level on the `ac_present_i` signal |
| 138 | - A H -> L transition on the `pwrb_in_i` signal |
| 139 | - A L -> H transition on the `lid_open_i` signal |
Michael Schaffner | 88db0fb | 2022-01-20 15:42:33 -0800 | [diff] [blame] | 140 | |
Hugo McNally | ba16bae | 2023-02-12 21:08:04 +0000 | [diff] [blame] | 141 | Note that the signals may be potentially inverted due to the [input inversion feature]({{< relref "#inversion" >}}). |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 142 | |
| 143 | In order to activate this feature, software should do the following: |
| 144 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 145 | 1. Software can program the appropriate debounce times via the [`ULP_AC_DEBOUNCE_CTL`](../spi_host/data/spi_host.hjson#ulp_ac_debounce_ctl), [`ULP_LID_DEBOUNCE_CTL`](../spi_host/data/spi_host.hjson#ulp_lid_debounce_ctl) and [`ULP_PWRB_DEBOUNCE_CTL`](../spi_host/data/spi_host.hjson#ulp_pwrb_debounce_ctl) registers. |
| 146 | 2. Then, software can activate detection by setting the [`ULP_CTL`](../spi_host/data/spi_host.hjson#ulp_ctl) register to 1. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 147 | |
| 148 | Once the above configuration is active, `sysrst_ctrl` will start the timer when a transition is detected. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 149 | Once the timing condition is met, `sysrst_ctrl` will assert `z3_wakeup` output signal, the interrupt request and set the interrupt status register [`ULP_STATUS`](../spi_host/data/spi_host.hjson#ulp_status) to indicate the interrupt cause. |
| 150 | The software interrupt handler should then read the [`ULP_STATUS`](../spi_host/data/spi_host.hjson#ulp_status) register and clear the interrupt via the [`INTR_STATE`](../spi_host/data/spi_host.hjson#intr_state) register. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 151 | |
Michael Schaffner | 9c0b24d | 2022-08-05 13:56:09 -0700 | [diff] [blame] | 152 | Note that an interrupt will also issue a wakeup request to the OpenTitan power manager via `wkup_req_o`. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 153 | Software should therefore read and clear the [`WKUP_STATUS`](../spi_host/data/spi_host.hjson#wkup_status) register as well. |
Michael Schaffner | 816c816 | 2022-01-20 14:54:42 -0800 | [diff] [blame] | 154 | |
| 155 | Also note that the detection status is sticky. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 156 | I.e., software needs to explicitly disable this feature by setting [`ULP_CTL`](../spi_host/data/spi_host.hjson#ulp_ctl) to 0 in order to clear the FSM state. |
| 157 | If software wants to re-arm the mechanism right away, it should first read back [`ULP_CTL`](../spi_host/data/spi_host.hjson#ulp_ctl) to make sure it has been cleared before setting that register to 1 again. |
Dan McArdle | a5ca8fc | 2022-09-27 12:48:08 -0400 | [diff] [blame] | 158 | This is needed because this register has to be synchronized over to the AON clock domain. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 159 | |
| 160 | ## Pin input value accessibility |
| 161 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 162 | `sysrst_ctrl` allows the software to read the raw input pin values via the [`PIN_IN_VALUE`](../spi_host/data/spi_host.hjson#pin_in_value) register like GPIOs. |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 163 | To this end, the hardware samples the raw input values of `pwrb_in_i`, `key[0,1,2]_in_i`, `ac_present_i`, `ec_rst_l_i`, `flash_wp_l_i` before they are being inverted, and synchronizes them onto the bus clock domain. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 164 | |
Michael Schaffner | 88db0fb | 2022-01-20 15:42:33 -0800 | [diff] [blame] | 165 | ## Pin output and keyboard inversion control {#inversion} |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 166 | |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 167 | Software can optionally override all output signals, and change the signal polarity of some of the input and output signals. |
| 168 | The output signal override feature always has higher priority than any of the combo pattern detection mechanisms described above. |
| 169 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 170 | The selection of output signals to override, and the override values are programmable and lockable via the [`PIN_ALLOWED_CTL`](../spi_host/data/spi_host.hjson#pin_allowed_ctl) register. |
| 171 | For example, [`PIN_ALLOWED_CTL.EC_RST_L_0`](../spi_host/data/spi_host.hjson#pin_allowed_ctl) to 1 and [`PIN_ALLOWED_CTL.EC_RST_L_1`](../spi_host/data/spi_host.hjson#pin_allowed_ctl) to 0 means that software allows `ec_rst_l_o` to be overridden with logic 0, but not with logic 1. |
| 172 | If the SW locks the configuration with [`REGWEN`](../spi_host/data/spi_host.hjson#regwen), [`PIN_ALLOWED_CTL`](../spi_host/data/spi_host.hjson#pin_allowed_ctl) cannot be modified until the next OpenTitan reset. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 173 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 174 | When the system is up and running, the software can modify [`PIN_OUT_CTL`](../spi_host/data/spi_host.hjson#pin_out_ctl) and [`PIN_OUT_VALUE`](../spi_host/data/spi_host.hjson#pin_out_value) to enable or disable the feature. |
| 175 | For example, to release `ec_rst_l_o` after OpenTitan completes the reset, software can set [`PIN_OUT_CTL`](../spi_host/data/spi_host.hjson#pin_out_ctl) to 0 to stop the hardware from driving `ec_rst_l_o` to 0. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 176 | |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 177 | The input / output signal inversions can be programmed via the [`KEY_INVERT_CTL`](../spi_host/data/spi_host.hjson#key_invert_ctl) register. |
Michael Schaffner | cb4e579 | 2021-08-12 18:05:19 -0700 | [diff] [blame] | 178 | Input signals will be inverted before the combo detection logic, while output signals will be inverted after the output signal override logic. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 179 | |
| 180 | ## EC and Power-on-reset |
| 181 | |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 182 | OpenTitan and EC will be reset together during power-on. |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 183 | When OpenTitan is in reset, `ec_rst_l_o` will be asserted (active low). |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 184 | The power-on-reset value of [`PIN_ALLOWED_CTL.EC_RST_L_1`](../spi_host/data/spi_host.hjson#pin_allowed_ctl) and [`PIN_OUT_CTL.EC_RST_L`](../spi_host/data/spi_host.hjson#pin_out_ctl) will guarantee that `ec_rst_l_o` remains asserted after OpenTitan reset is released. |
| 185 | The software can release `ec_rst_l_o` explicitly by setting [`PIN_OUT_CTL.EC_RST_L`](../spi_host/data/spi_host.hjson#pin_out_ctl) to 0 during boot in order to complete the OpenTitan and EC power-on-reset sequence. |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 186 | |
Hugo McNally | aef0a66 | 2023-02-11 19:44:55 +0000 | [diff] [blame] | 187 | Note that since the `sysrst_ctrl` does not have control over the pad open-drain settings, software should properly initialize the pad attributes of the corresponding pad in the [pinmux configuration](../pinmux/README.md) before releasing `ec_rst_l_o`. |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 188 | |
| 189 | ## Flash Write Protect Output |
| 190 | |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 191 | Upon reset, the `flash_wp_l_o` signal will be asserted active low. |
Hugo McNally | 6321c5e | 2023-02-16 21:39:55 +0000 | [diff] [blame] | 192 | The software can release `flash_wp_l_o` explicitly by setting [`PIN_OUT_CTL.FLASH_WP_L`](../spi_host/data/spi_host.hjson#pin_out_ctl) to 0 when needed. |
Michael Schaffner | c544e11 | 2022-02-10 17:36:28 -0800 | [diff] [blame] | 193 | The `flash_wp_l_o` signal does have a corresponding input signal `flash_wp_l_i` - but that one is mainly intended for pad observability and does not have a bypass path to `flash_wp_l_o`. |
| 194 | Hence, the value of `flash_wp_l_o` defaults to logic 0 when it is not explicitly driven via the override function. |
Michael Schaffner | 9aefd16 | 2021-08-18 20:38:55 -0700 | [diff] [blame] | 195 | |
Hugo McNally | aef0a66 | 2023-02-11 19:44:55 +0000 | [diff] [blame] | 196 | Note that since the `sysrst_ctrl` does not have control over the pad open-drain settings, software should properly initialize the pad attributes of the corresponding pad in the [pinmux configuration](../pinmux/README.md) before releasing `flash_wp_l_o`. |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 197 | |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 198 | ## Device Interface Functions (DIFs) |
| 199 | |
Hugo McNally | ac9f9b5 | 2023-02-14 12:15:34 +0000 | [diff] [blame] | 200 | - [Device Interface Functions](../../../sw/device/lib/dif/dif_sysrst_ctrl.h) |
Timothy Trippel | f82e75a | 2022-07-27 14:42:22 -0700 | [diff] [blame] | 201 | |
Eric Shiu | 97b905a | 2021-04-09 15:11:27 -0700 | [diff] [blame] | 202 | ## Registers |
| 203 | |
Hugo McNally | ba16bae | 2023-02-12 21:08:04 +0000 | [diff] [blame] | 204 | * [Register Table](data/sysrst_ctrl.hjson#registers) |