-
Notifications
You must be signed in to change notification settings - Fork 13
[top,sw/dv] Clk pwr rst smoke tests #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5f5191d
0345940
7adf270
20e0f44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ static const uintptr_t dv_test_status_base = 0x20020000ul; | |
| static const uintptr_t gpio_base = 0x40000000ul; | ||
| static const uintptr_t clkmgr_base = 0x40020000ul; | ||
| static const uintptr_t rstmgr_base = 0x40030000ul; | ||
| static const uintptr_t pwrmgr_base = 0x40040000ul; | ||
| static const uintptr_t rom_ctrl_base = 0x40050000ul; | ||
| static const uintptr_t uart_base = 0x41000000ul; | ||
| static const uintptr_t i2c_base = 0x42000000ul; | ||
|
|
@@ -90,6 +91,15 @@ rstmgr_t mocha_system_rstmgr(void) | |
| #endif /* defined(__riscv_zcherihybrid) */ | ||
| } | ||
|
|
||
| pwrmgr_t mocha_system_pwrmgr(void) | ||
| { | ||
| #if defined(__riscv_zcherihybrid) | ||
| return (pwrmgr_t)create_mmio_capability(pwrmgr_base, 0x80u); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this length can be 0x44 |
||
| #else /* !defined(__riscv_zcherihybrid) */ | ||
| return (pwrmgr_t)pwrmgr_base; | ||
| #endif /* defined(__riscv_zcherihybrid) */ | ||
| } | ||
|
|
||
| rom_ctrl_t mocha_system_rom_ctrl(void) | ||
| { | ||
| #if defined(__riscv_zcherihybrid) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "hal/pwrmgr.h" | ||
| #include "hal/mmio.h" | ||
| #include <stdint.h> | ||
|
|
||
| static uint32_t pwrmgr_read(pwrmgr_t pwrmgr, uintptr_t reg) | ||
| { | ||
| return DEV_READ(pwrmgr + reg); | ||
| } | ||
|
|
||
| static void pwrmgr_write(pwrmgr_t pwrmgr, uintptr_t reg, uint32_t value) | ||
| { | ||
| DEV_WRITE(pwrmgr + reg, value); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_control_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return pwrmgr_read(pwrmgr, PWRMGR_CONTROL_REG); | ||
| } | ||
|
Comment on lines
+9
to
+22
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replicated from clock manager. |
||
|
|
||
| void pwrmgr_control_set(pwrmgr_t pwrmgr, uint32_t value) | ||
| { | ||
| pwrmgr_write(pwrmgr, PWRMGR_CONTROL_REG, value & PWRMGR_CONTROL_MASK); | ||
| } | ||
|
|
||
| void pwrmgr_cfg_sync(pwrmgr_t pwrmgr) | ||
| { | ||
| pwrmgr_write(pwrmgr, PWRMGR_CFG_CDC_SYNC_REG, 1u); | ||
| while ((pwrmgr_read(pwrmgr, PWRMGR_CFG_CDC_SYNC_REG) & 1u) != 0u) { | ||
| } | ||
| } | ||
|
|
||
| uint32_t pwrmgr_wakeup_enable_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return pwrmgr_read(pwrmgr, PWRMGR_WAKEUP_EN_REG); | ||
| } | ||
|
|
||
| void pwrmgr_wakeup_enable_set(pwrmgr_t pwrmgr, uint32_t value) | ||
| { | ||
| pwrmgr_write(pwrmgr, PWRMGR_WAKEUP_EN_REG, value); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_wakeup_status_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return pwrmgr_read(pwrmgr, PWRMGR_WAKE_STATUS_REG); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_reset_status_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return pwrmgr_read(pwrmgr, PWRMGR_RESET_STATUS_REG); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_escalate_reset_status_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return pwrmgr_read(pwrmgr, PWRMGR_ESCALATE_RESET_STATUS_REG); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_wake_info_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return pwrmgr_read(pwrmgr, PWRMGR_WAKE_INFO_REG); | ||
| } | ||
|
|
||
| void pwrmgr_wake_info_clear(pwrmgr_t pwrmgr, uint32_t mask) | ||
| { | ||
| pwrmgr_write(pwrmgr, PWRMGR_WAKE_INFO_REG, mask); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Power manager interface. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #define PWRMGR_CONTROL_REG (0x14) | ||
| #define PWRMGR_CFG_CDC_SYNC_REG (0x18) | ||
| #define PWRMGR_WAKEUP_EN_REG (0x20) | ||
| #define PWRMGR_WAKE_STATUS_REG (0x24) | ||
| #define PWRMGR_RESET_STATUS_REG (0x30) | ||
| #define PWRMGR_ESCALATE_RESET_STATUS_REG (0x34) | ||
| #define PWRMGR_WAKE_INFO_REG (0x3C) | ||
|
|
||
| #define PWRMGR_CONTROL_LOW_POWER_HINT_BIT (1u << 0) | ||
| #define PWRMGR_CONTROL_CORE_CLK_EN_BIT (1u << 4) | ||
| #define PWRMGR_CONTROL_IO_CLK_EN_BIT (1u << 5) | ||
| #define PWRMGR_CONTROL_MAIN_PD_N_BIT (1u << 6) | ||
| #define PWRMGR_CONTROL_MASK \ | ||
| (PWRMGR_CONTROL_LOW_POWER_HINT_BIT | PWRMGR_CONTROL_CORE_CLK_EN_BIT | \ | ||
| PWRMGR_CONTROL_IO_CLK_EN_BIT | PWRMGR_CONTROL_MAIN_PD_N_BIT) | ||
|
|
||
| #define PWRMGR_WAKEUP_EN_SOC_PROXY_EXT_WKUP_REQ_BIT (1u << 0) | ||
|
|
||
| #define PWRMGR_WAKE_INFO_REASONS_BIT (1u << 0) | ||
| #define PWRMGR_WAKE_INFO_FALL_THROUGH_BIT (1u << 1) | ||
| #define PWRMGR_WAKE_INFO_ABORT_BIT (1u << 2) | ||
|
|
||
| typedef void *pwrmgr_t; | ||
|
|
||
| #define PWRMGR_FROM_BASE_ADDR(addr) ((pwrmgr_t)(addr)) | ||
|
|
||
| uint32_t pwrmgr_control_get(pwrmgr_t pwrmgr); | ||
| void pwrmgr_control_set(pwrmgr_t pwrmgr, uint32_t value); | ||
|
|
||
| void pwrmgr_cfg_sync(pwrmgr_t pwrmgr); | ||
|
|
||
| uint32_t pwrmgr_wakeup_enable_get(pwrmgr_t pwrmgr); | ||
| void pwrmgr_wakeup_enable_set(pwrmgr_t pwrmgr, uint32_t value); | ||
|
|
||
| uint32_t pwrmgr_wakeup_status_get(pwrmgr_t pwrmgr); | ||
| uint32_t pwrmgr_reset_status_get(pwrmgr_t pwrmgr); | ||
| uint32_t pwrmgr_escalate_reset_status_get(pwrmgr_t pwrmgr); | ||
|
|
||
| uint32_t pwrmgr_wake_info_get(pwrmgr_t pwrmgr); | ||
| void pwrmgr_wake_info_clear(pwrmgr_t pwrmgr, uint32_t mask); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,19 +4,28 @@ | |
|
|
||
| #include "hal/rstmgr.h" | ||
| #include "hal/mmio.h" | ||
| #include "hal/mocha.h" | ||
| #include <stdint.h> | ||
|
|
||
| uint32_t rstmgr_reset_reason_get(rstmgr_t rstmgr) | ||
| { | ||
| return DEV_READ(rstmgr + RSTMGR_RESET_INFO_REG); | ||
| } | ||
|
|
||
| void rstmgr_reset_reason_clear(rstmgr_t rstmgr, uint32_t reason) | ||
| { | ||
| DEV_WRITE(rstmgr + RSTMGR_RESET_INFO_REG, reason); | ||
| } | ||
|
|
||
| void rstmgr_software_reset_request(rstmgr_t rstmgr) | ||
| { | ||
| DEV_WRITE(rstmgr + RSTMGR_RESET_REQ_REG, RSTMGR_RESET_REQ_TRUE); | ||
| } | ||
|
|
||
| bool rstmgr_software_reset_info_get(rstmgr_t rstmgr) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can now remove this function. I think it was only used in the software_reset test. |
||
| { | ||
| if (DEV_READ(rstmgr + RSTMGR_RESET_INFO_REG) & RSTMGR_RESET_INFO_SW_RESET) { | ||
| if (rstmgr_reset_reason_get(rstmgr) & RSTMGR_RESET_INFO_SW_RESET) { | ||
| // Clear the info bit before returning. | ||
| DEV_WRITE(rstmgr + RSTMGR_RESET_INFO_REG, RSTMGR_RESET_INFO_SW_RESET); | ||
| rstmgr_reset_reason_clear(rstmgr, RSTMGR_RESET_INFO_SW_RESET); | ||
| return true; | ||
| } | ||
| return false; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't look like clock manager specific functions. Do they already exist elsewhere in the repo?