Skip to content

Commit ed7a2d9

Browse files
committed
[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 6a30f2d commit ed7a2d9

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ 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+
#error "dif_pwrmgr does not support this top"
101+
#endif
98102
} dif_pwrmgr_wakeup_request_source_t;
99103

100104
/**

sw/device/lib/dif/dif_rstmgr.c

Lines changed: 4 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,9 @@ 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+
#error "dif_rstmgr does not support this top"
58+
#endif
5759

5860
/**
5961
* 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
*/

sw/host/opentitanlib/src/dif/rstmgr.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub enum RstmgrReg {
2626
ErrCode = bindgen::dif::RSTMGR_ERR_CODE_REG_OFFSET,
2727
}
2828

29+
#[cfg(feature = "earlgrey")]
2930
with_unknown! {
3031
pub enum DifRstmgrResetInfo: u32 {
3132
Por = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoPor,
@@ -39,3 +40,18 @@ with_unknown! {
3940
Ndm = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoNdm,
4041
}
4142
}
43+
44+
#[cfg(feature = "darjeeling")]
45+
with_unknown! {
46+
pub enum DifRstmgrResetInfo: u32 {
47+
Por = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoPor,
48+
LowPowerExit = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoLowPowerExit,
49+
Sw = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoSw,
50+
HwReq = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoHwReq,
51+
ExternalRst = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoExternalRst,
52+
Watchdog = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoWatchdog,
53+
PowerUnstable = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoPowerUnstable,
54+
Escalation = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoEscalation,
55+
Ndm = bindgen::dif::dif_rstmgr_reset_info_kDifRstmgrResetInfoNdm,
56+
}
57+
}

0 commit comments

Comments
 (0)