-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/fix_lightsleep_current_leakage_on_usj_pad_v5.2' …
…into 'release/v5.2' fix(esp_hw_support): fix lightsleep current leakage on usb pad (backport v5.2) See merge request espressif/esp-idf!27199
- Loading branch information
Showing
15 changed files
with
438 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
components/esp_hw_support/include/esp_private/sleep_console.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
#include <stdint.h> | ||
#include "sdkconfig.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#if SOC_USB_SERIAL_JTAG_SUPPORTED | ||
typedef struct { | ||
bool usj_clock_enabled; | ||
bool usj_pad_enabled; | ||
} sleep_console_usj_enable_state_t; | ||
|
||
/** | ||
* @brief Disable usb-serial-jtag pad during light sleep to avoid current leakage and | ||
* backup the enable state before light sleep | ||
*/ | ||
void sleep_console_usj_pad_backup_and_disable(void); | ||
|
||
/** | ||
* @brief Restore initial usb-serial-jtag pad enable state when wakeup from light sleep | ||
*/ | ||
void sleep_console_usj_pad_restore(void); | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdbool.h> | ||
#include "soc/soc_caps.h" | ||
#include "esp_private/sleep_console.h" | ||
#include "esp_attr.h" | ||
|
||
#if SOC_USB_SERIAL_JTAG_SUPPORTED | ||
#include "hal/usb_serial_jtag_ll.h" | ||
|
||
static sleep_console_usj_enable_state_t s_usj_state = {0}; | ||
|
||
void sleep_console_usj_pad_backup_and_disable(void) | ||
{ | ||
// This function can be called in sleep process only, and sleep process code | ||
// is in critical region and thread safe already, so to avoid build errors/warnings | ||
// declare __DECLARE_RCC_ATOMIC_ENV here. | ||
int __DECLARE_RCC_ATOMIC_ENV __attribute__ ((unused)); | ||
|
||
s_usj_state.usj_clock_enabled = usb_serial_jtag_ll_module_is_enabled(); | ||
if (!s_usj_state.usj_clock_enabled) { | ||
// Enable USJ clock and clear reset | ||
usb_serial_jtag_ll_enable_bus_clock(true); | ||
usb_serial_jtag_ll_reset_register(); | ||
} | ||
s_usj_state.usj_pad_enabled = usb_serial_jtag_ll_pad_backup_and_disable(); | ||
// Disable USJ clock | ||
usb_serial_jtag_ll_enable_bus_clock(false); | ||
} | ||
|
||
void sleep_console_usj_pad_restore(void) | ||
{ | ||
// This function can be called in sleep process only, and sleep process code | ||
// is in critical region and thread safe already, so to avoid build errors/warnings | ||
// declare __DECLARE_RCC_ATOMIC_ENV here. | ||
int __DECLARE_RCC_ATOMIC_ENV __attribute__ ((unused)); | ||
|
||
usb_serial_jtag_ll_enable_bus_clock(true); | ||
usb_serial_jtag_ll_enable_pad(s_usj_state.usj_pad_enabled); | ||
if (!s_usj_state.usj_clock_enabled) { | ||
usb_serial_jtag_ll_enable_bus_clock(false); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.