Skip to content

Commit 71c5269

Browse files
AlexJones0jwnrt
authored andcommitted
[dif,pwrmgr,rstmgr] Add Darjeeling pwrmgr/rstmgr changes
Adds conditional compilation for Darjeeling to match the changed register definitions, including a change in the number of wakeup reasons for the rstmgr. Ideally this can be better modularised through some devicetable extension API in the future for these blocks, but for now we introduce `ifdef`s to the DIFs to enable this functionality. Signed-off-by: Alex Jones <[email protected]>
1 parent 8bc77be commit 71c5269

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

sw/device/lib/dif/dif_pwrmgr.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static const bitfield_field32_t kDomainConfigBitfield = {
6666
* Relevant bits of the WAKEUP_EN and WAKE_INFO registers must start at `0` and
6767
* be in the same order as `dif_pwrmgr_wakeup_request_source_t` constants.
6868
*/
69+
#if defined(OPENTITAN_IS_EARLGREY)
6970
static_assert(kDifPwrmgrWakeupRequestSourceOne ==
7071
(1u << PWRMGR_WAKEUP_EN_EN_0_BIT),
7172
"Layout of WAKEUP_EN register changed.");
@@ -87,6 +88,22 @@ static_assert(kDifPwrmgrWakeupRequestSourceFive ==
8788
static_assert(kDifPwrmgrWakeupRequestSourceSix ==
8889
(1u << PWRMGR_PARAM_SENSOR_CTRL_AON_WKUP_REQ_IDX),
8990
"Layout of WAKE_INFO register changed.");
91+
#elif defined(OPENTITAN_IS_DARJEELING)
92+
static_assert(kDifPwrmgrWakeupRequestSourceOne ==
93+
(1u << PWRMGR_PARAM_PINMUX_AON_PIN_WKUP_REQ_IDX),
94+
"Layout of WAKE_INFO register changed.");
95+
static_assert(kDifPwrmgrWakeupRequestSourceTwo ==
96+
(1u << PWRMGR_PARAM_AON_TIMER_AON_WKUP_REQ_IDX),
97+
"Layout of WAKE_INFO register changed.");
98+
static_assert(kDifPwrmgrWakeupRequestSourceThree ==
99+
(1u << PWRMGR_PARAM_SOC_PROXY_WKUP_INTERNAL_REQ_IDX),
100+
"Layout of WAKE_INFO register changed.");
101+
static_assert(kDifPwrmgrWakeupRequestSourceFour ==
102+
(1u << PWRMGR_PARAM_SOC_PROXY_WKUP_EXTERNAL_REQ_IDX),
103+
"Layout of WAKE_INFO register changed.");
104+
#else
105+
#error "dif_pwrmgr does not support this top"
106+
#endif
90107

91108
/**
92109
* Relevant bits of the RESET_EN register must start at `0` and be in the same
@@ -135,9 +152,15 @@ static const request_reg_info_t request_reg_infos[2] = {
135152
.mask = kDifPwrmgrWakeupRequestSourceOne |
136153
kDifPwrmgrWakeupRequestSourceTwo |
137154
kDifPwrmgrWakeupRequestSourceThree |
155+
#if defined(OPENTITAN_IS_EARLGREY)
138156
kDifPwrmgrWakeupRequestSourceFour |
139157
kDifPwrmgrWakeupRequestSourceFive |
140158
kDifPwrmgrWakeupRequestSourceSix,
159+
#elif defined(OPENTITAN_IS_DARJEELING)
160+
kDifPwrmgrWakeupRequestSourceFour,
161+
#else
162+
#error "dif_pwrmgr does not support this top"
163+
#endif
141164
.index = 0,
142165
},
143166
},

sw/device/lib/dif/dif_pwrmgr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,14 @@ typedef enum dif_pwrmgr_wakeup_request_source {
9393
kDifPwrmgrWakeupRequestSourceTwo = (1u << 1),
9494
kDifPwrmgrWakeupRequestSourceThree = (1u << 2),
9595
kDifPwrmgrWakeupRequestSourceFour = (1u << 3),
96+
#if defined(OPENTITAN_IS_EARLGREY)
9697
kDifPwrmgrWakeupRequestSourceFive = (1u << 4),
9798
kDifPwrmgrWakeupRequestSourceSix = (1u << 5),
99+
#elif defined(OPENTITAN_IS_DARJEELING)
100+
// Darjeeling only has four wakeup request sources
101+
#else
102+
#error "dif_pwrmgr does not support this top"
103+
#endif
98104
} dif_pwrmgr_wakeup_request_source_t;
99105

100106
/**

sw/device/lib/dif/dif_rstmgr.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "rstmgr_regs.h" // Generated.
1717

1818
// These assertions are only defined for the Earl Grey chip.
19-
#ifdef OPENTITAN_IS_EARLGREY
19+
#if defined(OPENTITAN_IS_EARLGREY)
2020
// This macro simplifies the `static_assert` check to make sure that the
2121
// public reset info register bitfield matches register bits.
2222
#define RSTMGR_RESET_INFO_CHECK(pub_name, priv_name) \
@@ -53,7 +53,11 @@ static_assert(
5353
static_assert(
5454
DIF_RSTMGR_ALERT_INFO_MAX_SIZE == RSTMGR_ALERT_INFO_CTRL_INDEX_MASK,
5555
"Alert info dump max size has grown, please update the public define!");
56-
#endif // OPENTITAN_IS_EARLGREY
56+
#elif defined(OPENTITAN_IS_DARJEELING)
57+
// TODO: equivalent assertations are not yet defined for Darjeeling
58+
#else
59+
#error "dif_rstmgr does not support this top"
60+
#endif
5761

5862
/**
5963
* Checks whether alert_info capture is disabled.

sw/device/lib/dif/dif_rstmgr.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ typedef enum dif_rstmgr_reset_info {
8383
* escalation, watchdog or anything else.
8484
*/
8585
kDifRstmgrResetInfoHwReq = (0x1f << 3),
86+
#if defined(OPENTITAN_IS_EARLGREY)
8687
/**
8788
* Device has reset due to the peripheral system reset control request.
8889
*/
@@ -91,6 +92,18 @@ typedef enum dif_rstmgr_reset_info {
9192
* Device has reset due to watchdog bite.
9293
*/
9394
kDifRstmgrResetInfoWatchdog = (1 << 4),
95+
#elif defined(OPENTITAN_IS_DARJEELING)
96+
/**
97+
* Device has reset due to watchdog bite.
98+
*/
99+
kDifRstmgrResetInfoWatchdog = (1 << 3),
100+
/**
101+
* Device has reset due to an external reset request via soc_proxy.
102+
*/
103+
kDifRstmgrResetInfoExternalRst = (1 << 4),
104+
#else
105+
#error "dif_rstmgr does not support this top"
106+
#endif
94107
/**
95108
* Device has reset due to power unstable.
96109
*/

0 commit comments

Comments
 (0)