-
Notifications
You must be signed in to change notification settings - Fork 15
[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
d6d8dfe
9d3cac1
3b4a677
7364ed3
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 |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // 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> | ||
|
|
||
| uint32_t pwrmgr_control_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return DEV_READ(pwrmgr + PWRMGR_CONTROL_REG); | ||
| } | ||
|
|
||
| void pwrmgr_control_set(pwrmgr_t pwrmgr, uint32_t value) | ||
| { | ||
| DEV_WRITE(pwrmgr + PWRMGR_CONTROL_REG, value & PWRMGR_CONTROL_MASK); | ||
| } | ||
|
|
||
| void pwrmgr_cfg_sync(pwrmgr_t pwrmgr) | ||
| { | ||
| DEV_WRITE(pwrmgr + PWRMGR_CFG_CDC_SYNC_REG, 1u); | ||
| while ((DEV_READ(pwrmgr + PWRMGR_CFG_CDC_SYNC_REG) & 1u) != 0u) { | ||
| } | ||
| } | ||
|
|
||
| uint32_t pwrmgr_wakeup_enable_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return DEV_READ(pwrmgr + PWRMGR_WAKEUP_EN_REG); | ||
| } | ||
|
|
||
| void pwrmgr_wakeup_enable_set(pwrmgr_t pwrmgr, uint32_t value) | ||
| { | ||
| DEV_WRITE(pwrmgr + PWRMGR_WAKEUP_EN_REG, value); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_wakeup_status_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return DEV_READ(pwrmgr + PWRMGR_WAKE_STATUS_REG); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_reset_status_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return DEV_READ(pwrmgr + PWRMGR_RESET_STATUS_REG); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_escalate_reset_status_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return DEV_READ(pwrmgr + PWRMGR_ESCALATE_RESET_STATUS_REG); | ||
| } | ||
|
|
||
| uint32_t pwrmgr_wake_info_get(pwrmgr_t pwrmgr) | ||
| { | ||
| return DEV_READ(pwrmgr + PWRMGR_WAKE_INFO_REG); | ||
| } | ||
|
|
||
| void pwrmgr_wake_info_clear(pwrmgr_t pwrmgr, uint32_t mask) | ||
| { | ||
| DEV_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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,14 +10,16 @@ mocha_add_test(NAME axi_sram_smoketest SOURCES axi_sram/smoketest.c LIBRARIES ${ | |||||
| mocha_add_test(NAME axi_sram_tag_test SOURCES axi_sram/tag_test.c LIBRARIES ${LIBS}) | ||||||
| # Cannot run this on verilator as the ethernet MAC is not in the verilator top | ||||||
| mocha_add_test(NAME ethernet_smoketest SOURCES ethernet/smoketest.c LIBRARIES ${LIBS} SKIP_VERILATOR) | ||||||
| mocha_add_test(NAME clkmgr_smoketest SOURCES clkmgr/smoketest.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME gpio_reg_access_test SOURCES gpio/reg_access_test.c LIBRARIES ${LIBS}) | ||||||
| # Can't run this test on FPGA or verilator tops and this test thinks that the GPIO inputs can be | ||||||
| # driven externally | ||||||
| mocha_add_test(NAME gpio_smoketest SOURCES gpio/smoketest.c LIBRARIES ${LIBS} SKIP_VERILATOR SKIP_FPGA) | ||||||
| mocha_add_test(NAME i2c_smoketest SOURCES i2c/smoketest.c LIBRARIES ${LIBS}) | ||||||
|
martin-velay marked this conversation as resolved.
|
||||||
| mocha_add_test(NAME mailbox_smoketest SOURCES mailbox/smoketest.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME plic_smoketest SOURCES plic/smoketest.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME rstmgr_software_reset SOURCES rstmgr/software_reset.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME pwrmgr_smoketest SOURCES pwrmgr/smoketest.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME rstmgr_smoketest SOURCES rstmgr/smoketest.c LIBRARIES ${LIBS}) | ||||||
|
Contributor
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 if you don't want this test to run on FPGA you need to add this:
Suggested change
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. The reset test has been enabled for the FPGA in main, bootrom now supports this, please this back. |
||||||
| mocha_add_test(NAME spi_device_smoketest SOURCES spi_device/smoketest.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME spi_host_smoketest SOURCES spi_host/smoketest.c LIBRARIES ${LIBS}) | ||||||
| mocha_add_test(NAME tag_controller_smoketest SOURCES tag_controller/smoketest.c LIBRARIES ${LIBS}) | ||||||
|
|
||||||
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.
I think we can now remove this function. I think it was only used in the software_reset test.
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.
Good point. The test now reads and clears the reset reason directly, so this function is not needed anymore. I will remove it from the HAL source and header.