Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,6 @@ ESP32XX_SPI_CLK_FREQ_RANGE_MAX := 40
menu "Hosted SDIO Configuration"
depends on ESP_HOSTED_SDIO_HOST_INTERFACE

choice ESP_HOSTED_SDIO_RESET_GPIO_CONFIG
bool "RESET GPIO Config"
default ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH
help
"If Active High, High->Low->High will trigger reset (Low will trigger reset)
If Active Low, Low->High->Low will trigger reset (High will trigger reset)"

config ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH
bool "RESET: Active High"
config ESP_HOSTED_SDIO_RESET_ACTIVE_LOW
bool "RESET: Active Low"
endchoice

choice ESP_HOSTED_SDIO_RX_OPTIMIZATION
bool "SDIO Receive Optimization"
default ESP_HOSTED_SDIO_OPTIMIZATION_RX_STREAMING_MODE
Expand Down Expand Up @@ -852,7 +839,29 @@ ESP32XX_SDIO_CLK_FREQ_KHZ_RANGE_MAX := 50000
D1 GPIO pin for SDIO. Range enforced dynamically based on slave target to ensure IOMUX compliance.
endif

config ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
bool "Reset slave using callback function"
help
Select this option if you want to reset the slave device using a callback function instead of using a GPIO pin.
This is useful if the reset line of the slave device is not connected to a GPIO pin of the host device.
The callback function should be defined as esp_err_t hosted_sdio_reset_slave_callback(void); in user code.

choice ESP_HOSTED_SDIO_RESET_GPIO_CONFIG
depends on !ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
bool "RESET GPIO Config"
default ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH
help
"If Active High, High->Low->High will trigger reset (Low will trigger reset)
If Active Low, Low->High->Low will trigger reset (High will trigger reset)"

config ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH
bool "RESET: Active High"
config ESP_HOSTED_SDIO_RESET_ACTIVE_LOW
bool "RESET: Active Low"
endchoice

config ESP_HOSTED_SDIO_GPIO_RESET_SLAVE
depends on !ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
int "GPIO pin for Reseting slave ESP"
default 54 if IDF_TARGET_ESP32P4
default 42 if IDF_TARGET_ESP32S3
Expand Down
4 changes: 4 additions & 0 deletions host/api/src/esp_hosted_transport_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ esp_hosted_transport_err_t esp_hosted_transport_get_reset_config(gpio_pin_t *pin
default:
// transport config not yet initialised. Use default Reset pin config
pin_config->port = H_GPIO_PORT_RESET;
#ifndef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
pin_config->pin = H_GPIO_PIN_RESET;
#else
pin_config->pin = -1;
#endif
break;
}

Expand Down
13 changes: 13 additions & 0 deletions host/drivers/transport/sdio/sdio_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,10 @@ static esp_err_t transport_card_init(void *bus_handle, uint32_t timeout_ms)

static esp_err_t transport_gpio_reset(void *bus_handle, gpio_pin_t reset_pin)
{
#ifdef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
extern esp_err_t hosted_sdio_reset_slave_callback(void);
return hosted_sdio_reset_slave_callback();
#else
g_h.funcs->_h_config_gpio(reset_pin.port, reset_pin.pin, H_GPIO_MODE_DEF_OUTPUT);
g_h.funcs->_h_write_gpio(reset_pin.port, reset_pin.pin, H_RESET_VAL_ACTIVE);
g_h.funcs->_h_msleep(10);
Expand All @@ -1433,13 +1437,15 @@ static esp_err_t transport_gpio_reset(void *bus_handle, gpio_pin_t reset_pin)
g_h.funcs->_h_write_gpio(reset_pin.port, reset_pin.pin, H_RESET_VAL_ACTIVE);
g_h.funcs->_h_msleep(H_HOST_SDIO_RESET_DELAY_MS);
return ESP_OK;
#endif
}

#define CARD_INIT_TIMEOUT_MS 1500

int ensure_slave_bus_ready(void *bus_handle)
{
int res = -1;
#ifndef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
gpio_pin_t reset_pin = { .port = H_GPIO_PORT_RESET, .pin = H_GPIO_PIN_RESET };

if (ESP_TRANSPORT_OK != esp_hosted_transport_get_reset_config(&reset_pin)) {
Expand All @@ -1448,6 +1454,9 @@ int ensure_slave_bus_ready(void *bus_handle)
}

assert(reset_pin.pin != -1);
#else
gpio_pin_t reset_pin = { .port = NULL, .pin = -1 };
#endif

release_slave_reset_gpio_post_wakeup();

Expand Down Expand Up @@ -1494,7 +1503,11 @@ int ensure_slave_bus_ready(void *bus_handle)
}
} else {
/* Always reset slave on host bootup */
#ifndef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
ESP_LOGW(TAG, "Reset slave using GPIO[%u]", reset_pin.pin);
#else
ESP_LOGW(TAG, "Reset slave using callback");
#endif
transport_gpio_reset(bus_handle, reset_pin);

res = transport_card_init(bus_handle, CARD_INIT_TIMEOUT_MS);
Expand Down
13 changes: 13 additions & 0 deletions host/port/esp/freertos/src/port_esp_hosted_host_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,29 @@ int hosted_sdio_card_init(void *ctx, bool show_config)
sdio_config->bus_width==4? 4:1,
config.max_freq_khz);
if (sdio_config->bus_width == 4) {
#ifndef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_CALLBACK_FUNCTION
ESP_LOGI(TAG, "GPIOs: CLK[%u] CMD[%u] D0[%u] D1[%u] D2[%u] D3[%u] Slave_Reset[%u]",
sdio_config->pin_clk.pin, sdio_config->pin_cmd.pin,
sdio_config->pin_d0.pin, sdio_config->pin_d1.pin,
sdio_config->pin_d2.pin, sdio_config->pin_d3.pin,
sdio_config->pin_reset.pin);
#else
ESP_LOGI(TAG, "GPIOs: CLK[%u] CMD[%u] D0[%u] D1[%u] D2[%u] D3[%u]",
sdio_config->pin_clk.pin, sdio_config->pin_cmd.pin,
sdio_config->pin_d0.pin, sdio_config->pin_d1.pin,
sdio_config->pin_d2.pin, sdio_config->pin_d3.pin);
#endif
} else {
#ifndef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_CALLBACK_FUNCTION
ESP_LOGI(TAG, "GPIOs: CLK[%u] CMD[%u] D0[%u] D1[%u] Slave_Reset[%u]",
sdio_config->pin_clk.pin, sdio_config->pin_cmd.pin,
sdio_config->pin_d0.pin, sdio_config->pin_d1.pin,
sdio_config->pin_reset.pin);
#else
ESP_LOGI(TAG, "GPIOs: CLK[%u] CMD[%u] D0[%u] D1[%u]",
sdio_config->pin_clk.pin, sdio_config->pin_cmd.pin,
sdio_config->pin_d0.pin, sdio_config->pin_d1.pin);
#endif
}
ESP_LOGI(TAG, "Queues: Tx[%u] Rx[%u] SDIO-Rx-Mode[%u]",
sdio_config->tx_queue_size, sdio_config->rx_queue_size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ struct esp_hosted_sdio_config esp_hosted_get_default_sdio_config(void)
.pin_d1 = {.port = H_SDIO_PORT_D1, .pin = H_SDIO_PIN_D1},
.pin_d2 = {.port = H_SDIO_PORT_D2, .pin = H_SDIO_PIN_D2},
.pin_d3 = {.port = H_SDIO_PORT_D3, .pin = H_SDIO_PIN_D3},
#ifndef CONFIG_ESP_HOSTED_SDIO_RESET_SLAVE_USING_CALLBACK
.pin_reset = {.port = H_GPIO_PORT_RESET, .pin = H_GPIO_PIN_RESET},
#else
.pin_reset = {.port = NULL, .pin = -1},
#endif
.rx_mode = H_SDIO_HOST_RX_MODE,
.block_mode = H_SDIO_TX_BLOCK_ONLY_XFER && H_SDIO_RX_BLOCK_ONLY_XFER,
.iomux_enable = false,
Expand Down