Software APIs
chip.h
Go to the documentation of this file.
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BASE_CHIP_H_
6#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BASE_CHIP_H_
7
8/**
9 * @file
10 * @brief Chip-level constants.
11 */
12
13/**
14 * Manifest size for boot stages stored in flash (in bytes).
15 */
16#define CHIP_MANIFEST_SIZE 1024
17
18/**
19 * Manifest format major and minor versions.
20 */
21#define CHIP_MANIFEST_VERSION_MINOR_1 0x6c47
22#define CHIP_MANIFEST_VERSION_MAJOR_1 0x71c3
23
24// TODO(moidx): Update to a valid number once we figure out a manifest
25// versioning scheme.
26#define CHIP_MANIFEST_VERSION_MAJOR_2 0x0002
27
28/**
29 * Number of entries in the manifest extensions table.
30 */
31#define CHIP_MANIFEST_EXT_TABLE_ENTRY_COUNT 15
32
33/**
34 * Size of the header of a boot services message.
35 */
36#define CHIP_BOOT_SVC_MSG_HEADER_SIZE 44
37
38/**
39 * Maximum size of a boot services message.
40 */
41#define CHIP_BOOT_SVC_MSG_SIZE_MAX 256
42
43/**
44 * Maximum payload size for a boot services message.
45 */
46#define CHIP_BOOT_SVC_MSG_PAYLOAD_SIZE_MAX \
47 (CHIP_BOOT_SVC_MSG_SIZE_MAX - CHIP_BOOT_SVC_MSG_HEADER_SIZE)
48
49/**
50 * First owner boot stage, e.g. BL0, manifest identifier (ASCII "OTB0").
51 */
52#define CHIP_BL0_IDENTIFIER 0x3042544f
53
54/**
55 * Allowed bounds for the `length` field of a first owner boot stage manifest.
56 */
57#define CHIP_BL0_SIZE_MIN CHIP_MANIFEST_SIZE
58#ifndef OT_COVERAGE_ENABLED
59#define CHIP_BL0_SIZE_MAX 0x70000
60#else // OT_COVERAGE_ENABLED
61#define CHIP_BL0_SIZE_MAX 0x60000
62#endif // OT_COVERAGE_ENABLED
63
64/**
65 * ROM_EXT manifest identifier (ASCII "OTRE").
66 */
67#define CHIP_ROM_EXT_IDENTIFIER 0x4552544f
68
69/**
70 * Allowed bounds for the `length` field of a ROM_EXT manifest.
71 */
72#define CHIP_ROM_EXT_SIZE_MIN CHIP_MANIFEST_SIZE
73#ifndef OT_COVERAGE_ENABLED
74#define CHIP_ROM_EXT_SIZE_MAX 0x10000
75#else // OT_COVERAGE_ENABLED
76#define CHIP_ROM_EXT_SIZE_MAX 0x20000
77#endif // OT_COVERAGE_ENABLED
78#define CHIP_ROM_EXT_RESIZABLE_SIZE_MAX \
79 (CHIP_ROM_EXT_SIZE_MAX + CHIP_BL0_SIZE_MAX)
80
81/**
82 * Value written to the end of the retention SRAM creator area by `test_rom` to
83 * be able to determine the type of ROM in tests (ASCII "TEST").
84 */
85#define TEST_ROM_IDENTIFIER 0x54534554
86
87/**
88 * Pinmux pull up/down wait delay.
89 *
90 * After enabling the pull-up/down on a pin, we need to wait for ~5us for the
91 * configuration to propagate to the physical pads. 5us is 500 clock cycles
92 * assuming a 100MHz clock.
93 */
94#define PINMUX_PAD_ATTR_PROP_CYCLES 500
95
96/**
97 * Pinmux peripheral input values for software strap pins.
98 */
99#define SW_STRAP_0_PERIPH 22
100#define SW_STRAP_1_PERIPH 23
101#define SW_STRAP_2_PERIPH 24
102
103/**
104 * Pinmux MIO input selector values for software strap pins.
105 */
106#define SW_STRAP_0_INSEL 24
107#define SW_STRAP_1_INSEL 25
108#define SW_STRAP_2_INSEL 26
109
110/**
111 * Pads of the software strap pins.
112 */
113#define SW_STRAP_0_PAD 22
114#define SW_STRAP_1_PAD 23
115#define SW_STRAP_2_PAD 24
116
117/**
118 * Mask for the software strap pins.
119 */
120#define SW_STRAP_MASK \
121 ((1 << SW_STRAP_2_PERIPH) | (1 << SW_STRAP_1_PERIPH) | \
122 (1 << SW_STRAP_0_PERIPH))
123
124/**
125 * RMA entry strap value.
126 *
127 * We expect strong pull-ups on SW_STRAP_2_PERIPH and SW_STRAP_1_PERIPH, and
128 * strong pull-down on SW_STRAP_0_PERIPH, i.e. `11_11_00`.
129 */
130#define SW_STRAP_RMA_ENTRY \
131 ((1 << SW_STRAP_2_PERIPH) | (1 << SW_STRAP_1_PERIPH) | \
132 (0 << SW_STRAP_0_PERIPH))
133
134/**
135 * Bootstrap strap value.
136 *
137 * We expect strong pull-ups on all software strap pins, i.e. `11_11_11`.
138 */
139#define SW_STRAP_BOOTSTRAP \
140 ((1 << SW_STRAP_2_PERIPH) | (1 << SW_STRAP_1_PERIPH) | \
141 (1 << SW_STRAP_0_PERIPH))
142
143#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BASE_CHIP_H_