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 #define CHIP_BL0_SIZE_MAX 0x70000
59 
60 /**
61  * ROM_EXT manifest identifier (ASCII "OTRE").
62  */
63 #define CHIP_ROM_EXT_IDENTIFIER 0x4552544f
64 
65 /**
66  * Allowed bounds for the `length` field of a ROM_EXT manifest.
67  */
68 #define CHIP_ROM_EXT_SIZE_MIN CHIP_MANIFEST_SIZE
69 #define CHIP_ROM_EXT_SIZE_MAX 0x10000
70 #define CHIP_ROM_EXT_RESIZABLE_SIZE_MAX \
71  (CHIP_ROM_EXT_SIZE_MAX + CHIP_BL0_SIZE_MAX)
72 
73 /**
74  * Value written to the end of the retention SRAM creator area by `test_rom` to
75  * be able to determine the type of ROM in tests (ASCII "TEST").
76  */
77 #define TEST_ROM_IDENTIFIER 0x54534554
78 
79 /**
80  * Pinmux pull up/down wait delay.
81  *
82  * After enabling the pull-up/down on a pin, we need to wait for ~5us for the
83  * configuration to propagate to the physical pads. 5us is 500 clock cycles
84  * assuming a 100MHz clock.
85  */
86 #define PINMUX_PAD_ATTR_PROP_CYCLES 500
87 
88 /**
89  * Pinmux peripheral input values for software strap pins.
90  */
91 #define SW_STRAP_0_PERIPH 22
92 #define SW_STRAP_1_PERIPH 23
93 #define SW_STRAP_2_PERIPH 24
94 
95 /**
96  * Pinmux MIO input selector values for software strap pins.
97  */
98 #define SW_STRAP_0_INSEL 24
99 #define SW_STRAP_1_INSEL 25
100 #define SW_STRAP_2_INSEL 26
101 
102 /**
103  * Pads of the software strap pins.
104  */
105 #define SW_STRAP_0_PAD 22
106 #define SW_STRAP_1_PAD 23
107 #define SW_STRAP_2_PAD 24
108 
109 /**
110  * Mask for the software strap pins.
111  */
112 #define SW_STRAP_MASK \
113  ((1 << SW_STRAP_2_PERIPH) | (1 << SW_STRAP_1_PERIPH) | \
114  (1 << SW_STRAP_0_PERIPH))
115 
116 /**
117  * RMA entry strap value.
118  *
119  * We expect strong pull-ups on SW_STRAP_2_PERIPH and SW_STRAP_1_PERIPH, and
120  * strong pull-down on SW_STRAP_0_PERIPH, i.e. `11_11_00`.
121  */
122 #define SW_STRAP_RMA_ENTRY \
123  ((1 << SW_STRAP_2_PERIPH) | (1 << SW_STRAP_1_PERIPH) | \
124  (0 << SW_STRAP_0_PERIPH))
125 
126 /**
127  * Bootstrap strap value.
128  *
129  * We expect strong pull-ups on all software strap pins, i.e. `11_11_11`.
130  */
131 #define SW_STRAP_BOOTSTRAP \
132  ((1 << SW_STRAP_2_PERIPH) | (1 << SW_STRAP_1_PERIPH) | \
133  (1 << SW_STRAP_0_PERIPH))
134 
135 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BASE_CHIP_H_