Skip to content

Commit 51fd02d

Browse files
Merge branch 'fix/usb_phy_set_speed' into 'master'
fix(usb/phy): Fixed crash on external PHY init with speed != UNDEFINED See merge request espressif/esp-idf!37218
2 parents 8014ffa + ca24a11 commit 51fd02d

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

components/usb/include/esp_private/usb_phy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ esp_err_t usb_phy_otg_set_mode(usb_phy_handle_t handle, usb_otg_mode_t mode);
143143
* - ESP_ERR_INVALID_ARG Parameter error.
144144
* - ESP_FAIL OTG set speed fail.
145145
*/
146-
esp_err_t usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t speed);
146+
esp_err_t __attribute__((deprecated)) usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t speed);
147147

148148
/**
149149
* @brief Take a action for a USB PHY
@@ -156,7 +156,7 @@ esp_err_t usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t spe
156156
* - ESP_ERR_INVALID_ARG Parameter error.
157157
* - ESP_FAIL Action cannot be performed.
158158
*/
159-
esp_err_t usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action);
159+
esp_err_t __attribute__((deprecated)) usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action);
160160

161161
/**
162162
* @brief Delete a USB PHY

components/usb/usb_phy.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct phy_context_t {
3636
usb_phy_controller_t controller; /**< PHY controller */
3737
usb_phy_status_t status; /**< PHY status */
3838
usb_otg_mode_t otg_mode; /**< USB OTG mode */
39-
usb_phy_speed_t otg_speed; /**< USB speed */
4039
usb_phy_ext_io_conf_t *iopins; /**< external PHY I/O pins */
4140
usb_wrap_hal_context_t wrap_hal; /**< USB WRAP HAL context */
4241
};
@@ -174,13 +173,10 @@ esp_err_t usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t spe
174173
{
175174
ESP_RETURN_ON_FALSE(handle, ESP_ERR_INVALID_ARG, USBPHY_TAG, "handle argument is invalid");
176175
ESP_RETURN_ON_FALSE(speed < USB_PHY_SPEED_MAX, ESP_ERR_INVALID_ARG, USBPHY_TAG, "speed argument is invalid");
177-
ESP_RETURN_ON_FALSE(handle->controller == USB_PHY_CTRL_OTG, ESP_FAIL, USBPHY_TAG, "phy source is not USB_OTG");
178-
ESP_RETURN_ON_FALSE((handle->target != USB_PHY_TARGET_EXT && handle->otg_mode == USB_OTG_MODE_DEVICE), ESP_FAIL,
179-
USBPHY_TAG, "set speed not supported");
180176
ESP_RETURN_ON_FALSE((handle->target == USB_PHY_TARGET_UTMI) == (speed == USB_PHY_SPEED_HIGH), ESP_ERR_NOT_SUPPORTED, USBPHY_TAG, "UTMI can be HighSpeed only"); // This is our software limitation
181177

182-
handle->otg_speed = speed;
183-
// No need to configure anything neither for UTMI PHY nor for Internal USB FSLS PHY
178+
// Keeping this here for backward compatibility
179+
// No need to configure anything neither for UTMI PHY nor for USB FSLS PHY
184180
return ESP_OK;
185181
}
186182

@@ -370,9 +366,6 @@ esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_r
370366
if (config->otg_mode != USB_PHY_MODE_DEFAULT) {
371367
ESP_ERROR_CHECK(usb_phy_otg_set_mode(*handle_ret, config->otg_mode));
372368
}
373-
if (config->otg_speed != USB_PHY_SPEED_UNDEFINED) {
374-
ESP_ERROR_CHECK(usb_phy_otg_dev_set_speed(*handle_ret, config->otg_speed));
375-
}
376369
if (config->otg_io_conf && (phy_context->controller == USB_PHY_CTRL_OTG)) {
377370
const usb_otg_signal_conn_t *otg_sig = usb_dwc_info.controllers[otg11_index].otg_signals;
378371
ESP_ERROR_CHECK(phy_otg_iopins_configure(config->otg_io_conf, otg_sig));

0 commit comments

Comments
 (0)