drivers: wifi: esp_at: handle external reset sources
Add an option that signifies that the ESP modem may be reset at the same time as the SoC by an external source. When this is the case, we first wait for an unsolicited "ready" message from the modem, before attempting to reset the device. This prevents two initialisation sequences attempting to run at the same time. We still want to wait for the complete initialisation sequence to complete before returning in this case. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
542aec673d
commit
21ed808ba1
|
@ -1177,7 +1177,7 @@ static void esp_init_work(struct k_work *work)
|
|||
static int esp_reset(const struct device *dev)
|
||||
{
|
||||
struct esp_data *data = dev->data;
|
||||
int ret;
|
||||
int ret = -EAGAIN;
|
||||
|
||||
if (net_if_is_carrier_ok(data->net_iface)) {
|
||||
net_if_carrier_off(data->net_iface);
|
||||
|
@ -1196,9 +1196,14 @@ static int esp_reset(const struct device *dev)
|
|||
k_sleep(K_MSEC(100));
|
||||
gpio_pin_set_dt(&config->reset, 0);
|
||||
#else
|
||||
#if DT_INST_NODE_HAS_PROP(0, external_reset)
|
||||
/* Wait to see if the interface comes up by itself */
|
||||
ret = k_sem_take(&data->sem_if_ready, K_MSEC(CONFIG_WIFI_ESP_AT_RESET_TIMEOUT));
|
||||
#endif
|
||||
int retries = 3;
|
||||
|
||||
while (retries--) {
|
||||
/* Don't need to run this if the interface came up by itself */
|
||||
while ((ret != 0) && retries--) {
|
||||
ret = modem_cmd_send(&data->mctx.iface, &data->mctx.cmd_handler,
|
||||
NULL, 0, "AT+RST", &data->sem_if_ready,
|
||||
K_MSEC(CONFIG_WIFI_ESP_AT_RESET_TIMEOUT));
|
||||
|
|
|
@ -14,6 +14,12 @@ properties:
|
|||
reset-gpios:
|
||||
type: phandle-array
|
||||
|
||||
external-reset:
|
||||
type: boolean
|
||||
description:
|
||||
Modem is reset by an external source. In most situations this will
|
||||
be the microcontroller and the ESP modem on a common reset line.
|
||||
|
||||
target-speed:
|
||||
type: int
|
||||
description:
|
||||
|
|
Loading…
Reference in New Issue