blob: 925530472011323f7753a61c4f939f38239e2415 [file] [log] [blame] [view]
Hugo McNallyf6298b32023-02-12 14:47:22 +00001# Pinmux Technical Specification
Michael Schaffner1b1ede92019-09-24 18:49:47 -07002
3
Garret Kelly9eebde02019-10-22 15:36:49 -04004# Overview
Michael Schaffner1b1ede92019-09-24 18:49:47 -07005
6This document specifies the functionality of the pin multiplexer (`pinmux`) peripheral.
Hugo McNallyaef0a662023-02-11 19:44:55 +00007This module conforms to the [OpenTitan guideline for peripheral device functionality](../../../doc/contributing/hw/comportability/README.md).
Michael Schaffner1b1ede92019-09-24 18:49:47 -07008See that document for integration overview within the broader OpenTitan top level system.
Timothy Chen7f4b5572019-11-02 17:42:27 -07009The module provides a mechanism to reconfigure the peripheral-to-pin mapping at runtime, which greatly enhances the system flexibility.
Michael Schaffner00768a22021-06-11 22:07:56 -070010In addition to that, the `pinmux` also allows the user to control pad attributes (such as pull-up, pull-down, open-drain, drive-strength, keeper and inversion), and it contains features that facilitate low-power modes of the system.
Michael Schaffnerd136b232022-01-11 10:57:29 -080011For example, the sleep behavior of each pad can be programmed individually, and the module contains additional pattern detectors that can listen on any IO and wake up the system if a specific pattern has been detected.
Michael Schaffner1b1ede92019-09-24 18:49:47 -070012
Garret Kelly9eebde02019-10-22 15:36:49 -040013## Features
Michael Schaffner1b1ede92019-09-24 18:49:47 -070014
Michael Schaffner00768a22021-06-11 22:07:56 -070015- Configurable number of chip bidirectional IOs
Michael Schaffner1b1ede92019-09-24 18:49:47 -070016
17- Configurable number of peripheral inputs and outputs
18
19- Programmable mapping from peripheral outputs (and output enables) to top-level outputs (and output enables)
20
21- Programmable mapping from top-level inputs to peripheral inputs
22
Michael Schaffner00768a22021-06-11 22:07:56 -070023- Programmable control of chip pad attributes like output drive-strength, pull-up, pull-down and virtual open-drain
Michael Schaffner1b1ede92019-09-24 18:49:47 -070024
Michael Schaffner00768a22021-06-11 22:07:56 -070025- Programmable pattern detectors to detect wakeup conditions during sleep mode
Michael Schaffner1b1ede92019-09-24 18:49:47 -070026
Michael Schaffner00768a22021-06-11 22:07:56 -070027- Programmable sleep mode behavior
Michael Schaffner1b1ede92019-09-24 18:49:47 -070028
Michael Schaffner00768a22021-06-11 22:07:56 -070029- Support for life-cycle-based JTAG (TAP) isolation and muxing
Michael Schaffner1b1ede92019-09-24 18:49:47 -070030
Garret Kelly9eebde02019-10-22 15:36:49 -040031# Theory of Operations
Michael Schaffner1b1ede92019-09-24 18:49:47 -070032
Michael Schaffner00768a22021-06-11 22:07:56 -070033## Block Diagram and Overview
Michael Schaffner1b1ede92019-09-24 18:49:47 -070034
Michael Schaffner00768a22021-06-11 22:07:56 -070035The `pinmux` peripheral is a programmable module designed to wire arbitrary peripheral inputs and outputs to arbitrary multiplexable chip bidirectional pins.
36It gives much flexibility at the top level of the device, allowing most data pins to be flexibly wired and controlled by many peripherals.
37Even though the `pinmux` is referred to as one IP, it is logically split into two modules that are instantiated on the top-level and the chip-level, respectively, as can be seen in the block diagram below.
38The top-level module `pinmux` contains the CSRs accessible via the TL-UL interface, the main muxing matrix, retention registers, a set of programmable wakeup detectors, and the HW strap sampling and TAP / JTAG muxing logic.
39The chip-level module `padring` instantiates the bidirectional pads and connects the physical pad attributes.
Michael Schaffner1b1ede92019-09-24 18:49:47 -070040
Hugo McNallyaef0a662023-02-11 19:44:55 +000041![Pinmux Block Diagram](./doc/pinmux_overview_block_diagram.svg)
Michael Schaffner1b1ede92019-09-24 18:49:47 -070042
Michael Schaffner00768a22021-06-11 22:07:56 -070043### MIO and DIO Signal Categories
Michael Schaffner1b1ede92019-09-24 18:49:47 -070044
Michael Schaffner00768a22021-06-11 22:07:56 -070045The `pinmux` supports two different IO signal categories:
46Muxed IO (MIO) signals that are routed through the `pinmux` matrix, and dedicated IO (DIO) signals that bypass the `pinmux` matrix.
47This distinction is useful for accommodating IO signals that are timing critical or that must have a fixed IO mapping for another reason.
48Note that although DIO signals are not routed through the `pinmux` matrix, they are still connected to the retention logic and the wakeup detectors (see next section below).
Michael Schaffner1b1ede92019-09-24 18:49:47 -070049
Michael Schaffner00768a22021-06-11 22:07:56 -070050The number of available peripheral IOs, pads, and their assignment to the MIO / DIO categories is done at design time as part of the top-level configuration.
51This configurability is achieved by representing inputs / outputs as packed arrays, in combination with the SystemVerilog parameters `NPeriphIn`, `NPeriphOut`, `NMioPads` and `NDioPads`.
52Note however that the register file is also affected by this configuration and needs to be regenerated for each design instance.
53
54It is assumed that all available pins that the `pinmux` connects to are bidirectional, controlled by logic within this module.
55By default, all muxed peripheral inputs are tied to zero.
56Further, all output enables are set to zero, which essentially causes all pads to be in high-Z state after reset.
57In addition to wiring programmability, each muxed peripheral input can be set constantly to 0 or 1, and each muxed chip output can be set constantly to 0, 1 or high-Z.
58
Hugo McNally544e7a62023-02-12 01:12:36 +000059See the [muxing matrix](#muxing-matrix) section for more details about the mux implementation.
Michael Schaffner00768a22021-06-11 22:07:56 -070060
61### Retention and Wakeup Features
62
Michael Schaffnerd136b232022-01-11 10:57:29 -080063The retention logic allows SW to specify a certain behavior during sleep for each muxed and dedicated output.
Michael Schaffner00768a22021-06-11 22:07:56 -070064Legal behaviors are tie low, tie high, high-Z, keeping the previous state, or driving the current value (useful for peripherals that are always on).
65
66The wakeup detectors can detect patterns such as rising / falling edges and pulses of a certain width up to 255 AON clock cycles.
67Each wakeup detector can listen on any one of the MIO / DIO signals that are routed through the `pinmux`, and if a pattern is detected, the power manager is informed of that event via a wakeup request.
68
Michael Schaffnerd136b232022-01-11 10:57:29 -080069The `pinmux` module itself is in the always-on (AON) power domain, and as such does not loose configuration state when a sleep power cycle is performed.
70However, only the wakeup detector logic will be actively clocked during sleep in order to save power.
Michael Schaffner00768a22021-06-11 22:07:56 -070071
Hugo McNally544e7a62023-02-12 01:12:36 +000072See the [retention logic](#retention-logic) and [wakeup detectors](#wakeup-detectors) sections for more details about the mux implementation.
Michael Schaffner00768a22021-06-11 22:07:56 -070073
74### Test and Debug Access
75
76The hardware strap sampling and TAP isolation logic provides test and debug access to the chip during specific life cycle states.
Hugo McNally544e7a62023-02-12 01:12:36 +000077This mechanism is explained in more detail in the [strap sampling and TAP isolation](#strap-sampling-and-tap-isolation) section.
Michael Schaffner00768a22021-06-11 22:07:56 -070078
79### Pad Attributes
80
81Additional pad-specific features such as inversion, pull-up, pull-down, virtual open-drain, drive-strength and input/output inversion etc. can be exercise via the pad attribute CSRs.
82The `pinmux` module supports a comprehensive set of such pad attributes, but it is permissible that some of them may not be supported by the underlying pad implementation.
83For example, certain ASIC libraries may not provide open-drain outputs, and FPGAs typically do not allow all of these attributes to be programmed dynamically at runtime.
Hugo McNally544e7a62023-02-12 01:12:36 +000084See the [generic pad wrapper](#generic-pad-wrapper) section below for more details.
Michael Schaffner00768a22021-06-11 22:07:56 -070085Note that static pad attributes for FPGAs are currently not covered in this specification.
Michael Schaffner1b1ede92019-09-24 18:49:47 -070086
Timothy Chen7f4b5572019-11-02 17:42:27 -070087## Hardware Interfaces
88
Hugo McNallyba16bae2023-02-12 21:08:04 +000089* [Interface Tables](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#interfaces)
Michael Schaffner1b1ede92019-09-24 18:49:47 -070090
Michael Schaffner00768a22021-06-11 22:07:56 -070091### Parameters
Michael Schaffner1b1ede92019-09-24 18:49:47 -070092
93The following table lists the main parameters used throughout the `pinmux` design.
Michael Schaffner00768a22021-06-11 22:07:56 -070094Note that the `pinmux` is generated based on the system configuration, and hence these parameters are placed into a package.
Hugo McNally544e7a62023-02-12 01:12:36 +000095The pinout and `pinmux` mappings are listed under [Pinout and Pinmux Mapping](#pinout-and-pinmux-mapping) for specific top-level configurations.
Michael Schaffner1b1ede92019-09-24 18:49:47 -070096
Michael Schaffner00768a22021-06-11 22:07:56 -070097Parameter | Description
98---------------|---------------
99`NPeriphOut` | Number of peripheral outputs.
100`NPeriphIn` | Number of peripheral input.
101`NMioPads` | Number of muxed bidirectional pads.
102`NDioPads` | Number of dedicated pads.
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700103
Michael Schaffnera3af1eb2022-11-03 21:38:19 -0700104### Primary IO Signals
Michael Schaffnera60c1ba2019-10-09 18:05:30 -0700105
Michael Schaffnera3af1eb2022-11-03 21:38:19 -0700106The table below lists the primary `pinmux` IO signals to/from the pad ring.
107The number of dedicated and muxed IOs is parametric, and hence the signals are stacked in packed arrays.
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700108
Michael Schaffner00768a22021-06-11 22:07:56 -0700109Signal | Direction | Type | Description
110---------------------------------------|-----------|------------------------------------|---------------
Michael Schaffner00768a22021-06-11 22:07:56 -0700111`periph_to_mio_i[NPeriphOut-1:0]` | `input` | packed `logic` | Signals from `NPeriphOut` muxed peripheral outputs coming into the `pinmux`.
112`periph_to_mio_oe_i[NPeriphOut-1:0]` | `input` | packed `logic` | Signals from `NPeriphOut` muxed peripheral output enables coming into the `pinmux`.
113`mio_to_periph_o[NPeriphIn-1:0]` | `output` | packed `logic` | Signals to `NPeriphIn` muxed peripherals coming from the `pinmux`.
114`periph_to_dio_i[NDioPads-1:0]` | `input` | packed `logic` | Signals from `NDioPads` dedicated peripheral outputs coming into the `pinmux`.
115`periph_to_dio_oe_i[NDioPads-1:0]` | `input` | packed `logic` | Signals from `NDioPads` dedicated peripheral output enables coming into the `pinmux`.
116`dio_to_periph_o[NDioPads-1:0]` | `output` | packed `logic` | Signals to `NDioPads` dedicated peripherals coming from the `pinmux`.
117`mio_attr_o[NMioPads-1:0]` | `output` | prim_pad_wrapper_pkg::pad_attr_t | Packed array containing the pad attributes of all muxed IOs.
118`mio_out_o[NMioPads-1:0]` | `output` | packed `logic` | Signals to `NMioPads` bidirectional muxed pads as output data.
119`mio_oe_o[NMioPads-1:0]` | `output` | packed `logic` | Signals to `NMioPads` bidirectional muxed pads as output enables.
120`mio_in_i[NMioPads-1:0]` | `input` | packed `logic` | Signals from `NMioPads` bidirectional muxed pads as input data.
121`dio_attr_o[NDioPads-1:0]` | `output` | prim_pad_wrapper_pkg::pad_attr_t | Packed array containing the pad attributes of all dedicated IOs.
122`dio_out_o[NDioPads-1:0]` | `output` | packed `logic` | Signals to `NDioPads` bidirectional dedicated pads as output data.
123`dio_oe_o[NDioPads-1:0]` | `output` | packed `logic` | Signals to `NDioPads` bidirectional dedicated pads as output enables.
124`dio_in_i[NDioPads-1:0]` | `input` | packed `logic` | Signals from `NDioPads` bidirectional dedicated pads as input data.
125
126
127## Muxing Matrix
128
129The diagram below shows connectivity between four arbitrary chip pins, named `MIO0` .. `MIO3`, and several muxed peripheral inputs and outputs.
130This shows the connectivity available in all directions, as well as the control registers described later in this document.
131Two example peripherals (`uart` and `spidev`) are attached to the `pinmux` in this example, one with one input and one output, the other with three inputs and one output.
132The diagram also shows the `padring` module which instantiates the bidirectional chip pads with output enable control.
133
Hugo McNallyaef0a662023-02-11 19:44:55 +0000134![Pinmux Block Diagram](./doc/pinmux_muxing_matrix.svg)
Michael Schaffner00768a22021-06-11 22:07:56 -0700135
136Note that apart from selecting a specific input pad, the `periph_insel[*]` signals can also be used to tie the peripheral input to 0 or 1.
137Likewise, the output select signals `mio_outsel[*]` can also be used to constantly drive an output pin to 0/1 or to put it into high-Z state (default).
138The output enable and the associated data signal (i.e. `periph_to_mio` and `periph_to_mio_oe`) are indexed with the same select signal to allow the peripheral hardware to determine the pad direction instead of demoting that control to SW.
139
140## Retention Logic
141
142As illustrated in the picture above, all muxing matrix and DIO outputs are routed through the retention logic, which essentially consists of a set of multiplexors and two retention registers per output (one register is for the output data and one for the output enable).
Michael Schaffnerd136b232022-01-11 10:57:29 -0800143This multiplexor can be configured to be automatically activated upon sleep entry in order to either drive the output low, high, high-Z or to the last seen value (keep).
Michael Schaffner00768a22021-06-11 22:07:56 -0700144If no sleep behavior is specified, the retention logic will continue to drive out the value coming from the peripheral side, which can be useful for peripherals that reside in the AON domain.
145
146The sleep behavior of all outputs is activated in parallel via a trigger signal asserted by the power manager.
Michael Schaffnerd136b232022-01-11 10:57:29 -0800147Once activated, it is the task of SW to disable the sleep behavior for each individual pin when waking up from sleep.
Michael Schaffner00768a22021-06-11 22:07:56 -0700148This ensures that the output values remain stable until the system and its peripherals have been re-initialized.
149
150## Wakeup Detectors
151
152The `pinmux` contains eight programmable wakeup detector modules that can listen on any of the MIO or DIO pins.
153Each detector contains a debounce filter and an 8bit counter running on the AON clock domain.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000154The detectors can be programmed via the [`WKUP_DETECTOR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_0) and [`WKUP_DETECTOR_CNT_TH_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_cnt_th_0) registers to detect the following patterns:
Michael Schaffner00768a22021-06-11 22:07:56 -0700155
156- rising edge
157- falling edge
158- rising or falling edge
159- positive pulse up to 255 AON clock cycles in length
160- negative pulse up to 255 AON clock cycles in length
161
162Note that for all patterns listed above, the input signal is sampled with the AON clock.
163This means that the input signal needs to remain stable for at least one AON clock cycle after a level change for the detector to recognize the event (depending on the debounce filter configuration, the signal needs to remain stable for multiple clock cycles).
164
Hugo McNally6321c5e2023-02-16 21:39:55 +0000165If a pattern is detected, the wakeup detector will send a wakeup request to the power manager, and the cause bit corresponding to that detector will be set in the [`WKUP_CAUSE`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_cause) register.
Michael Schaffner00768a22021-06-11 22:07:56 -0700166
Hugo McNally6321c5e2023-02-16 21:39:55 +0000167Note that the wkup detector should be disabled by setting [`WKUP_DETECTOR_EN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_en_0) before changing the detection mode.
Michael Schaffner4e0e44a2022-03-02 15:13:58 -0800168The reason for that is that the pulse width counter is NOT cleared upon a mode change while the detector is enabled.
169
Michael Schaffner00768a22021-06-11 22:07:56 -0700170## Strap Sampling and TAP Isolation
171
172The `pinmux` contains a set of dedicated HW "straps", which are essentially signals that are multiplexed onto fixed MIO pad locations.
173Depending on the life cycle state, these straps are either continuously sampled, or latched right after POR.
174
175There are two groups of HW straps:
1761. Three DFT straps that determine the DFT mode.
177 These bits are output via the `dft_strap_test_o` signal such that they can be routed to the tool-inserted DFT controller.
1782. Two TAP selection straps for determining which TAP should be multiplexed onto the JTAG IOs.
179
180The conditions under which these two strap groups are sampled are listed in the tables below.
181Note that the HW straps can be used just like regular GPIOs once they have been sampled.
182
183Strap Group \ Life Cycle State | TEST_UNLOCKED* | RMA | DEV | All Other States
184--------------------------------|----------------|--------------|--------------|------------------
185DFT straps | Once at boot | Once at boot | - | -
186TAP strap 0 | Continuously | Continuously | Once at boot | Once at boot
187TAP strap 1 | Continuously | Continuously | Once at boot | -
188
189*Once at boot:* Sampled once after life cycle initialization (sampling event is initiated by pwrmgr).
190
Dan McArdlea5ca8fc2022-09-27 12:48:08 -0400191*Continuously:* Sampled continuously after life cycle initialization.
Michael Schaffner00768a22021-06-11 22:07:56 -0700192
193The TAP muxing logic is further qualified by the life cycle state in order to isolate the TAPs in certain life cycle states.
194The following table lists the TAP strap encoding and the life cycle states in which the associated TAPs can be selected and accessed.
195
196TAP strap 1 | TAP strap 0 | Life Cycle State | Selected TAP
197------------|--------------|--------------------------|---------------
1980 | 0 | All states | -
1990 | 1 | All states | Life Cycle
2001 | 0 | TEST_UNLOCKED*, RMA, DEV | RISC-V
2011 | 1 | TEST_UNLOCKED*, RMA | DFT
202
203Note that the tool-inserted DFT controller may assert the `dft_hold_tap_sel_i` during a test (e.g. boundary scan) in which case the `pinmux` will temporarily pause sampling of the TAP selection straps.
204
Michael Schaffner827b2322022-01-10 11:23:50 -0800205Also, it should be noted that the pad attributes of all JTAG IOs will be gated to all-zero temporarily, while the JTAG is enabled (this does not affect the values in the CSRs).
206This is to ensure that any functional attributes like inversion or pull-ups / pull-downs do not interfere with the JTAG while it is in use.
207
Hugo McNallyaef0a662023-02-11 19:44:55 +0000208For more information about the life cycle states, see [Life Cycle Controller Specification](../lc_ctrl/README.md) and the [Life Cycle Definition Table](../../../doc/security/specs/device_life_cycle/README.md#manufacturing-states).
Michael Schaffner00768a22021-06-11 22:07:56 -0700209
210
211## Generic Pad Wrapper
212
213<center>
214<img src="generic_pad_wrapper.svg" width="50%">
215</center>
216
217The generic pad wrapper is intended to abstract away implementation differences between the target technologies by providing a generic interface that is compatible with the `padring` module.
218It is the task of the RTL build flow to select the appropriate pad wrapper implementation.
219
220A specific implementation of a pad wrapper may choose to instantiate a technology primitive (as it is common in ASIC flows), or it may choose to model the functionality behaviorally such that it can be inferred by the technology mapping tool (e.g., in the case of an FPGA target).
221It is permissible to omit the implementation of all IO attributes except input/output inversion.
222
223The generic pad wrapper must expose the following IOs and parameters, even if they are not connected internally.
224In particular, the pad attribute struct `attr_i` must contain all fields listed below, even if not all attributes are supported (it is permissible to just leave them unconnected in the pad wrapper implementation).
225
226Parameter | Default | Description
227---------------|------------|-----------------------------------------------------
228`PadType` | `BidirStd` | Pad variant to be instantiated (technology-specific)
229`ScanRole` | `NoScan` | Scan role, can be `NoScan`, `ScanIn` or `ScanOut`
230
231Note that `PadType` is a technology-specific parameter.
232The generic pad wrapper only implements variant `BidirStd`, but for other target technologies, this parameter can be used to select among a variety of different pad flavors.
233
234The `ScanRole` parameter determines the behavior when scanmode is enabled.
235Depending on whether a given pad acts as a scan input or output, certain pad attributes and functionalities need to be bypassed.
236This parameter is typically only relevant for ASIC targets and therefore not modeled in the generic pad model.
237
238Also note that the pad wrapper may implement a "virtual" open-drain termination, where standard bidirectional pads are employed, but instead of driving the output high for a logic 1 the pad is put into tristate mode.
239
240Signal | Direction | Type | Description
241---------------------|------------|-------------|-----------------------------------------------
242`clk_scan_i` | `input` | `logic` | Scan clock of the pad
243`scanmode_i` | `input` | `logic` | Scan mode enable of the pad
244`pok_i` | `input` | `pad_pok_t` | Technology-specific power sequencing signals
245`inout_io` | `inout` | `wire` | Bidirectional inout of the pad
246`in_o` | `output` | `logic` | Input data signal
247`in_raw_o` | `output` | `logic` | Un-inverted input data signal
248`out_i` | `input` | `logic` | Output data signal
249`oe_i` | `input` | `logic` | Output data enable
250`attr_i[0]` | `input` | `logic` | Input/output inversion
251`attr_i[1]` | `input` | `logic` | Virtual open-drain enable
252`attr_i[2]` | `input` | `logic` | Pull enable
253`attr_i[3]` | `input` | `logic` | Pull select (0: pull-down, 1: pull-up)
254`attr_i[4]` | `input` | `logic` | Keeper enable
255`attr_i[5]` | `input` | `logic` | Schmitt trigger enable
Cindy Chen18d6a962022-01-08 11:58:52 -0800256`attr_i[6]` | `input` | `logic` | Open drain enable
Michael Schaffner00768a22021-06-11 22:07:56 -0700257`attr_i[8:7]` | `input` | `logic` | Slew rate (0x0: slowest, 0x3: fastest)
258`attr_i[12:9]` | `input` | `logic` | Drive strength (0x0: weakest, 0xf: strongest)
259
Hugo McNally6321c5e2023-02-16 21:39:55 +0000260Note that the corresponding pad attribute registers [`MIO_PAD_ATTR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_attr_0) and [`DIO_PAD_ATTR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_attr_0) have "writes-any-reads-legal" (WARL) behavior (see also [pad attributes](#pad-attributes)).
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700261
Timothy Chen7f4b5572019-11-02 17:42:27 -0700262# Programmers Guide
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700263
Michael Schaffner00768a22021-06-11 22:07:56 -0700264## Pad Attributes
265
266Software should determine and program the pad attributes at startup, or reprogram the attributes when the functionality requirements change at runtime.
267
Hugo McNally6321c5e2023-02-16 21:39:55 +0000268This can be achieved by writing to the [`MIO_PAD_ATTR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_attr_0) and [`DIO_PAD_ATTR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_attr_0) registers.
Michael Schaffner00768a22021-06-11 22:07:56 -0700269Note that the IO attributes should be configured before enabling muxed IOs going through the `pinmux` matrix in order to avoid undesired electrical behavior and/or contention at the pads.
270
Hugo McNally6321c5e2023-02-16 21:39:55 +0000271The pad attributes configuration can be locked down individually for each pad via the [`MIO_PAD_ATTR_REGWEN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_attr_regwen_0) and [`DIO_PAD_ATTR_REGWEN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_attr_regwen_0) registers.
Michael Schaffner00768a22021-06-11 22:07:56 -0700272The configuration can then not be altered anymore until the next system reset.
273
274The following pad attributes are supported by this register layout by default:
275
276ATTR Bits | Description | Access
277----------|-----------------------------------------------|---------
Michael Schaffner827b2322022-01-10 11:23:50 -08002780 | Input/output inversion | WARL
2791 | Virtual open drain enable | WARL
Michael Schaffner00768a22021-06-11 22:07:56 -07002802 | Pull enable | WARL
2813 | Pull select (0: down, 1: up) | WARL
2824 | Keeper enable | WARL
2835 | Schmitt trigger enable | WARL
Cindy Chen18d6a962022-01-08 11:58:52 -08002846 | Open drain enable | WARL
Michael Schaffner00768a22021-06-11 22:07:56 -07002858:7 | Slew rate (0x0: slowest, 0x3: fastest) | WARL
28612:9 | Drive strength (0x0: weakest, 0xf: strongest) | WARL
287
288Since some of the pad attributes may not be implemented, SW can probe this capability by writing the CSRs and read them back to determine whether the value was legal.
289This behavior is also referred to as "writes-any-reads-legal" or "WARL" in the RISC-V world.
290For example, certain pads may only support two drive-strength bits, instead of four.
291The unsupported drive-strength bits in the corresponding CSRs would then always read as zero, even if SW attempts to set them to 1.
292
293## Pinmux Configuration
294
295Upon POR, the `pinmux` state is such that all MIO outputs are high-Z, and all MIO peripheral inputs are tied off to 0.
296Software should determine and program the `pinmux` mapping at startup, or reprogram it when the functionality requirements change at runtime.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000297This can be achieved by writing the following values to the [`PERIPH_INSEL_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#periph_insel_0) and [`MIO_OUTSEL_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_outsel_0) registers.
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700298
299`periph_insel` Value | Selected Input Signal
300----------------------|-----------------------
Michael Schaffner00768a22021-06-11 22:07:56 -07003010 | Constant zero (default)
Michael Schaffner1b1ede92019-09-24 18:49:47 -07003021 | Constant one
3032 + k | Corresponding MIO input signal at index k
304
305The global default at reset is `0`, but the default of individual signals can be overridden at design time, if needed.
306
307`mio_outsel` Value | Selected Output signal
308----------------------|-----------------------
Michael Schaffner00768a22021-06-11 22:07:56 -07003090 | Constant zero (default)
Michael Schaffner1b1ede92019-09-24 18:49:47 -07003101 | Constant one
3112 | High-Z
3123 + k | Corresponding peripheral output signal at index k
313
314The global default at reset is `2`, but the default of individual signals can be overridden at design time, if needed.
315
Hugo McNally6321c5e2023-02-16 21:39:55 +0000316Note that the `pinmux` configuration should be sequenced after any IO attribute-specific configuration in the [`MIO_PAD_ATTR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_attr_0) and [`DIO_PAD_ATTR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_attr_0) registers to avoid any unwanted electric behavior and/or contention.
317If needed, each select signal can be individually locked down via [`MIO_PERIPH_INSEL_REGWEN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_periph_insel_regwen_0) or [`MIO_OUTSEL_REGWEN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_outsel_regwen_0).
Michael Schaffner00768a22021-06-11 22:07:56 -0700318The configuration can then not be altered anymore until the next system reset.
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700319
Michael Schaffnerd136b232022-01-11 10:57:29 -0800320## Sleep Features
Michael Schaffner00768a22021-06-11 22:07:56 -0700321
Hugo McNally6321c5e2023-02-16 21:39:55 +0000322The sleep behavior of each individual MIO or DIO can be defined via the ([`MIO_PAD_SLEEP_EN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_sleep_en_0), [`DIO_PAD_SLEEP_EN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_sleep_en_0), [`MIO_PAD_SLEEP_MODE_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_sleep_mode_0) and [`DIO_PAD_SLEEP_MODE_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_sleep_mode_0)) registers.
Michael Schaffner00768a22021-06-11 22:07:56 -0700323Available sleep behaviors are:
324`dio/mio_pad_sleep_en` Value | `dio/mio_pad_sleep_mode` Value | Sleep Behavior
325------------------------------|--------------------------------|-----------------------
3260 | - | Drive (default)
3271 | 0 | Tie-low
3281 | 1 | Tie-high
3291 | 2 | High-Z
3301 | 3 | Keep last value
331
Michael Schaffnerd136b232022-01-11 10:57:29 -0800332Note that if the behavior is set to "Drive", the sleep mode will not be activated upon sleep entry.
Michael Schaffner00768a22021-06-11 22:07:56 -0700333Rather, the retention logic continues to drive the value coming from the peripheral side.
334Also note that the sleep logic is located after the `pinmux` matrix, hence the sleep configuration is per MIO pad and not per MIO peripheral.
335
Hugo McNally6321c5e2023-02-16 21:39:55 +0000336Before sleep entry, SW should configure the appropriate sleep behavior of all MIOs/DIOs via [`MIO_PAD_SLEEP_MODE_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_sleep_mode_0), [`DIO_PAD_SLEEP_MODE_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_sleep_mode_0).
Michael Schaffner00768a22021-06-11 22:07:56 -0700337This configuration can be optionally locked down, in which case it cannot be modified again until POR.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000338The configured behavior is then activated for all pads that have sleep mode set to enabled ([`MIO_PAD_SLEEP_EN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_sleep_en_0) and [`DIO_PAD_SLEEP_EN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_sleep_en_0)) at once by the power manager during the sleep entry sequence.
Michael Schaffner00768a22021-06-11 22:07:56 -0700339
340When exiting sleep, the task of disabling the sleep behavior is however up to SW.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000341I.e., it must clear the per-pad sleep status bits in registers [`MIO_PAD_SLEEP_STATUS_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#mio_pad_sleep_status_0) and [`DIO_PAD_SLEEP_STATUS_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#dio_pad_sleep_status_0) that have been set upon sleep entry.
Michael Schaffner00768a22021-06-11 22:07:56 -0700342The rationale for this is that it may not be desirable to disable sleep behavior on all pads at once due to some additional book keeping / re-initialization that needs to be performed while exiting sleep.
343
344## Wakeup Features
345
346The `pinmux` contains eight wakeup detectors.
347These detectors can be individually enabled and disabled regardless of the sleep state.
348This ensures that SW can set them up before and disable them after sleep in order to ensure that no events are missed during sleep entry and exit.
349
Hugo McNally544e7a62023-02-12 01:12:36 +0000350For more information on the patterns supported by the wakeup detectors, see [wakeup detectors](#wakeup-detectors).
Michael Schaffner00768a22021-06-11 22:07:56 -0700351
352A typical programming sequence for the wakeup detectors looks as follows:
353
Hugo McNally6321c5e2023-02-16 21:39:55 +00003541. Before initiating any sleep mode, SW should configure the wakeup detectors appropriately and enable them via the [`WKUP_DETECTOR_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_0), [`WKUP_DETECTOR_CNT_TH_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_cnt_th_0) and [`WKUP_DETECTOR_PADSEL_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_padsel_0) registers.
Michael Schaffner00768a22021-06-11 22:07:56 -0700355
Hugo McNally6321c5e2023-02-16 21:39:55 +00003562. Optionally, lock the wakeup detector configuration via the [`WKUP_DETECTOR_REGWEN_0`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_detector_regwen_0) registers.
Michael Schaffner00768a22021-06-11 22:07:56 -0700357
Cindy Chen17ba69c2022-01-04 12:26:01 -08003583. During sleep, the wakeup detectors will trigger a wakeup request if a matching pattern has been observed.
Hugo McNally6321c5e2023-02-16 21:39:55 +0000359 A bit corresponding to the wakeup detector that has observed the pattern will be set in the [`WKUP_CAUSE`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_cause) register.
Michael Schaffner00768a22021-06-11 22:07:56 -0700360
Hugo McNallyaef0a662023-02-11 19:44:55 +00003614. When exiting sleep, SW should read the wake info register in the [power manager](../pwrmgr/README.md) to determine the reason(s) for the wakeup request.
Michael Schaffner00768a22021-06-11 22:07:56 -0700362
Hugo McNally6321c5e2023-02-16 21:39:55 +00003635. If the wakeup request was due to a pin wakeup pattern detector, SW should inspect the [`WKUP_CAUSE`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_cause) registers in order to determine the exact cause.
Michael Schaffner00768a22021-06-11 22:07:56 -0700364
Hugo McNally6321c5e2023-02-16 21:39:55 +00003656. SW should in any case disable the wakeup detectors and clear the [`WKUP_CAUSE`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_cause) registers once it is safe to do so (in order to not miss any events).
366 Note that the [`WKUP_CAUSE`](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#wkup_cause) registers reside in the slow AON clock domain, and hence clearing them takes a few uS to take effect.
Michael Schaffner00768a22021-06-11 22:07:56 -0700367 If needed, a SW readback can be performed to ensure that the clear operation has completed successfully.
368
369## Pinout and Pinmux Mapping
370
Michael Schaffner426ed202021-08-02 17:44:42 -0700371The tables below summarize the pinout and pinmux connectivity for certain top-level designs.
372
373### Top Earlgrey
374
Amaury Pouly934f0882023-02-10 13:38:09 +0000375{{#include ../../top_earlgrey/ip/pinmux/doc/autogen/targets.md}}
Michael Schaffner1b1ede92019-09-24 18:49:47 -0700376
Timothy Trippelf82e75a2022-07-27 14:42:22 -0700377## Device Interface Functions (DIFs)
378
Hugo McNallyac9f9b52023-02-14 12:15:34 +0000379- [Device Interface Functions](../../../sw/device/lib/dif/dif_pinmux.h)
Timothy Trippelf82e75a2022-07-27 14:42:22 -0700380
Timothy Chen7f4b5572019-11-02 17:42:27 -0700381## Register Table
Michael Schaffner31da0392019-10-02 10:22:54 -0700382
Sam Elliottd834c702020-02-12 11:18:47 +0000383The register description below matches the instance in the [Earl Grey top level
Hugo McNallyaef0a662023-02-11 19:44:55 +0000384design](../../top_earlgrey/doc/specification.md).
Michael Schaffnera60c1ba2019-10-09 18:05:30 -0700385
Sam Elliottd834c702020-02-12 11:18:47 +0000386Similar register descriptions can be generated with different parameterizations.
387
Hugo McNallyba16bae2023-02-12 21:08:04 +0000388* [Register Table](../../top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson#registers)