-
-
Notifications
You must be signed in to change notification settings - Fork 669
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
Suspend to lower power mode on T3W1 #4454
base: main
Are you sure you want to change the base?
Conversation
[no changelog]
[no changelog]
[no changelog]
[no changelog]
[no changelog]
[no changelog]
|
[no changelog]
[no changelog]
[no changelog]
[no changelog]
289536e
to
2e41fe6
Compare
@@ -8,6 +8,8 @@ | |||
|
|||
#include "../../display_internal.h" | |||
|
|||
#pragma GCC optimize("-O0") |
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.
forgotten from debug?
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma GCC optimize("-O0") |
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.
debug?
@@ -93,6 +95,10 @@ void powerctl_suspend(void) { | |||
// immediately after exiting STOP2 mode. | |||
irq_key_t irq_key = irq_lock(); | |||
|
|||
// Enable PWR peripheral clock | |||
// (required by the following HAL_PWREx_EnterSTOP2Mode) | |||
__HAL_RCC_PWR_CLK_ENABLE(); |
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.
maybe we should disable after waking up? (it is enabled again in SystemInit and then disabled, so end effect zero, but it is not very clear from this function here)
@@ -150,6 +154,15 @@ STATIC mp_obj_t mod_trezorio_poll(mp_obj_t ifaces, mp_obj_t list_ref, | |||
#if USE_BUTTON | |||
else if (iface == BUTTON_IFACE) { | |||
const uint32_t evt = button_get_event(); | |||
|
|||
// --- experimental --- | |||
#ifdef USE_POWERCTL |
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.
shouldn't go into main
void optiga_hal_deinit(void) { | ||
GPIO_InitTypeDef GPIO_InitStructure = {0}; | ||
|
||
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; |
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.
As setting pins as ANALOG when shutting down or going to low power is frequently repeating, maybe we could introduce some helper function for this, maybe in powerctl driver or introduce a gpio driver. Not very important, but it would save some typing and would be easier to understand.
This PR improves the handling of suspending and resuming to/from low power mode on T3W1, aiming to achieve the lowest possible power consumption.
It enhances the initialization and deinitialization of the following drivers to enable achieving the lowest power consumption in STOP2 mode:
ltd_dsi
display driver (used only on T3W1 and disc2)backlight_pwm
(used on also on T and T3T1 models)drv2625
driverbutton
driverdma2d
driverAdds new POWERCTL_SUSPEND syscall
Introduces a new
USE_USB
feature utilized in the boardloader code.Adds a return value for the
display_init()
function, although it is not yet used anywhere.