Skip to content

Commit

Permalink
draft(i2c): need to support regdma_i2c for esp32c5beta3
Browse files Browse the repository at this point in the history
  • Loading branch information
10086loutianhao committed Apr 12, 2024
1 parent 534e7a5 commit 4061e28
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions components/driver/i2c/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static void i2c_hw_enable(i2c_port_t i2c_num)
I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock));
}

#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_I2C_SUPPORT_SLEEP_RETENTION
static esp_err_t i2c_sleep_retention_init(void *arg)
{
i2c_port_t i2c_num = *(i2c_port_t *)arg;
Expand Down Expand Up @@ -424,7 +424,7 @@ esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_
}
#endif // SOC_I2C_SUPPORT_SLAVE

#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-9353
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_I2C_SUPPORT_SLEEP_RETENTION
sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = i2c_sleep_retention_init, .arg = &i2c_num } }
};
Expand Down Expand Up @@ -485,7 +485,7 @@ esp_err_t i2c_driver_delete(i2c_port_t i2c_num)
esp_intr_free(p_i2c->intr_handle);
p_i2c->intr_handle = NULL;

#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-9353
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_I2C_SUPPORT_SLEEP_RETENTION
esp_err_t err = sleep_retention_module_free(I2C_SLEEP_RETENTION_MODULE(i2c_num));
if (err == ESP_OK) {
err = sleep_retention_module_deinit(I2C_SLEEP_RETENTION_MODULE(i2c_num));
Expand Down
6 changes: 3 additions & 3 deletions components/esp_driver_i2c/i2c_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef struct i2c_platform_t {

static i2c_platform_t s_i2c_platform = {}; // singleton platform

#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_I2C_SUPPORT_SLEEP_RETENTION
static esp_err_t s_i2c_sleep_retention_init(void *arg)
{
i2c_bus_t *bus = (i2c_bus_t *)arg;
Expand Down Expand Up @@ -77,7 +77,7 @@ static esp_err_t s_i2c_bus_handle_acquire(i2c_port_num_t port_num, i2c_bus_handl
bus->bus_mode = mode;
bus->is_lp_i2c = (bus->port_num < SOC_HP_I2C_NUM) ? false : true;

#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-9353
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_I2C_SUPPORT_SLEEP_RETENTION
if (bus->is_lp_i2c == false) {
sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = s_i2c_sleep_retention_init, .arg = (void *)bus } }
Expand Down Expand Up @@ -175,7 +175,7 @@ esp_err_t i2c_release_bus_handle(i2c_bus_handle_t i2c_bus)
if (s_i2c_platform.count[port_num] == 0) {
do_deinitialize = true;
s_i2c_platform.buses[port_num] = NULL;
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-9353
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_I2C_SUPPORT_SLEEP_RETENTION
if (i2c_bus->is_lp_i2c == false) {
esp_err_t err = sleep_retention_module_free(I2C_SLEEP_RETENTION_MODULE(port_num));
if (err == ESP_OK) {
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32c5/beta3/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@
#define SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE (1)
#define SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS (1)

// #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) // TODO: IDF-9693

/*-------------------------- LP_I2C CAPS -------------------------------------*/
// ESP32-C5 has 1 LP_I2C
// #define SOC_LP_I2C_NUM (1U)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ extern "C"
{
#endif

#if SOC_PAU_SUPPORTED // TODO: [ESP32C5] IDF-8640
#if SOC_PAU_SUPPORTED
/**
* @brief Provide access to interrupt matrix configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -28,7 +28,7 @@ extern const regdma_entries_config_t intr_matrix_regs_retention[INT_MTX_RETENTIO

/**
* @brief Provide access to hp_system configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -38,7 +38,7 @@ extern const regdma_entries_config_t hp_system_regs_retention[HP_SYSTEM_RETENTIO

/**
* @brief Provide access to TEE_APM configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -50,7 +50,7 @@ extern const regdma_entries_config_t tee_apm_highpri_regs_retention[TEE_APM_HIGH

/**
* @brief Provide access to uart configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -60,7 +60,7 @@ extern const regdma_entries_config_t uart_regs_retention[UART_RETENTION_LINK_LEN

/**
* @brief Provide access to timer group configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -70,7 +70,7 @@ extern const regdma_entries_config_t tg_regs_retention[TIMG_RETENTION_LINK_LEN];

/**
* @brief Provide access to IOMUX configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -80,7 +80,7 @@ extern const regdma_entries_config_t iomux_regs_retention[IOMUX_RETENTION_LINK_L

/**
* @brief Provide access to spimem configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand All @@ -90,7 +90,7 @@ extern const regdma_entries_config_t spimem_regs_retention[SPIMEM_RETENTION_LINK

/**
* @brief Provide access to systimer configuration registers retention
* context defination.
* context definition.
*
* This is an internal function of the sleep retention driver, and is not
* useful for external use.
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32c5/mp/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
// #define SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS (1)
// #define SOC_I2C_SLAVE_SUPPORT_SLAVE_UNMATCH (1)

// #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) // TODO: IDF-9693

/*-------------------------- LP_I2C CAPS -------------------------------------*/
// ESP32-C5 has 1 LP_I2C
// #define SOC_LP_I2C_NUM (1U)
Expand Down
2 changes: 2 additions & 0 deletions components/soc/esp32p4/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@
#define SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS (1)
#define SOC_I2C_SLAVE_SUPPORT_SLAVE_UNMATCH (1)

// #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) // TODO: IDF-9353

/*-------------------------- LP_I2C CAPS -------------------------------------*/
// ESP32-P4 has 1 LP_I2C
#define SOC_LP_I2C_NUM (1U)
Expand Down

0 comments on commit 4061e28

Please sign in to comment.