Skip to content
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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Conversation

cepetr
Copy link
Contributor

@cepetr cepetr commented Dec 19, 2024

This PR improves the handling of suspending and resuming to/from low power mode on T3W1, aiming to achieve the lowest possible power consumption.

  1. 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 driver
    • button driver
    • dma2d driver
  2. Adds new POWERCTL_SUSPEND syscall

  3. Introduces a new USE_USB feature utilized in the boardloader code.

  4. Adds a return value for the display_init() function, although it is not yet used anywhere.

@cepetr cepetr self-assigned this Dec 19, 2024
@cepetr cepetr added the T3W1 label Dec 19, 2024
Copy link

github-actions bot commented Dec 19, 2024

core UI changes device test click test persistence test
T2T1 Model T test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3B1 Safe 3 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3T1 Safe 5 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
All main(screens)

@cepetr cepetr force-pushed the cepetr/powerctl-suspend branch from 289536e to 2e41fe6 Compare December 19, 2024 14:11
@cepetr cepetr requested a review from TychoVrahe December 19, 2024 14:31
@@ -8,6 +8,8 @@

#include "../../display_internal.h"

#pragma GCC optimize("-O0")
Copy link
Contributor

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")
Copy link
Contributor

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();
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🔎 Needs review
Development

Successfully merging this pull request may close these issues.

2 participants