mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(usb/phy): Fixed crash on external PHY init with speed != UNDEFINED
Also deprecated usb_phy_otg_dev_set_speed() and usb_phy_action() which are no longer used in esp-idf
This commit is contained in:
parent
26a1b69a2a
commit
ca24a117c7
@ -143,7 +143,7 @@ esp_err_t usb_phy_otg_set_mode(usb_phy_handle_t handle, usb_otg_mode_t mode);
|
|||||||
* - ESP_ERR_INVALID_ARG Parameter error.
|
* - ESP_ERR_INVALID_ARG Parameter error.
|
||||||
* - ESP_FAIL OTG set speed fail.
|
* - ESP_FAIL OTG set speed fail.
|
||||||
*/
|
*/
|
||||||
esp_err_t usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t speed);
|
esp_err_t __attribute__((deprecated)) usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t speed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Take a action for a USB PHY
|
* @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
|
|||||||
* - ESP_ERR_INVALID_ARG Parameter error.
|
* - ESP_ERR_INVALID_ARG Parameter error.
|
||||||
* - ESP_FAIL Action cannot be performed.
|
* - ESP_FAIL Action cannot be performed.
|
||||||
*/
|
*/
|
||||||
esp_err_t usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action);
|
esp_err_t __attribute__((deprecated)) usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete a USB PHY
|
* @brief Delete a USB PHY
|
||||||
|
@ -36,7 +36,6 @@ struct phy_context_t {
|
|||||||
usb_phy_controller_t controller; /**< PHY controller */
|
usb_phy_controller_t controller; /**< PHY controller */
|
||||||
usb_phy_status_t status; /**< PHY status */
|
usb_phy_status_t status; /**< PHY status */
|
||||||
usb_otg_mode_t otg_mode; /**< USB OTG mode */
|
usb_otg_mode_t otg_mode; /**< USB OTG mode */
|
||||||
usb_phy_speed_t otg_speed; /**< USB speed */
|
|
||||||
usb_phy_ext_io_conf_t *iopins; /**< external PHY I/O pins */
|
usb_phy_ext_io_conf_t *iopins; /**< external PHY I/O pins */
|
||||||
usb_wrap_hal_context_t wrap_hal; /**< USB WRAP HAL context */
|
usb_wrap_hal_context_t wrap_hal; /**< USB WRAP HAL context */
|
||||||
};
|
};
|
||||||
@ -174,13 +173,10 @@ esp_err_t usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t spe
|
|||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(handle, ESP_ERR_INVALID_ARG, USBPHY_TAG, "handle argument is invalid");
|
ESP_RETURN_ON_FALSE(handle, ESP_ERR_INVALID_ARG, USBPHY_TAG, "handle argument is invalid");
|
||||||
ESP_RETURN_ON_FALSE(speed < USB_PHY_SPEED_MAX, ESP_ERR_INVALID_ARG, USBPHY_TAG, "speed argument is invalid");
|
ESP_RETURN_ON_FALSE(speed < USB_PHY_SPEED_MAX, ESP_ERR_INVALID_ARG, USBPHY_TAG, "speed argument is invalid");
|
||||||
ESP_RETURN_ON_FALSE(handle->controller == USB_PHY_CTRL_OTG, ESP_FAIL, USBPHY_TAG, "phy source is not USB_OTG");
|
|
||||||
ESP_RETURN_ON_FALSE((handle->target != USB_PHY_TARGET_EXT && handle->otg_mode == USB_OTG_MODE_DEVICE), ESP_FAIL,
|
|
||||||
USBPHY_TAG, "set speed not supported");
|
|
||||||
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
|
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
|
||||||
|
|
||||||
handle->otg_speed = speed;
|
// Keeping this here for backward compatibility
|
||||||
// No need to configure anything neither for UTMI PHY nor for Internal USB FSLS PHY
|
// No need to configure anything neither for UTMI PHY nor for USB FSLS PHY
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,9 +366,6 @@ esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_r
|
|||||||
if (config->otg_mode != USB_PHY_MODE_DEFAULT) {
|
if (config->otg_mode != USB_PHY_MODE_DEFAULT) {
|
||||||
ESP_ERROR_CHECK(usb_phy_otg_set_mode(*handle_ret, config->otg_mode));
|
ESP_ERROR_CHECK(usb_phy_otg_set_mode(*handle_ret, config->otg_mode));
|
||||||
}
|
}
|
||||||
if (config->otg_speed != USB_PHY_SPEED_UNDEFINED) {
|
|
||||||
ESP_ERROR_CHECK(usb_phy_otg_dev_set_speed(*handle_ret, config->otg_speed));
|
|
||||||
}
|
|
||||||
if (config->otg_io_conf && (phy_context->controller == USB_PHY_CTRL_OTG)) {
|
if (config->otg_io_conf && (phy_context->controller == USB_PHY_CTRL_OTG)) {
|
||||||
const usb_otg_signal_conn_t *otg_sig = usb_dwc_info.controllers[otg11_index].otg_signals;
|
const usb_otg_signal_conn_t *otg_sig = usb_dwc_info.controllers[otg11_index].otg_signals;
|
||||||
ESP_ERROR_CHECK(phy_otg_iopins_configure(config->otg_io_conf, otg_sig));
|
ESP_ERROR_CHECK(phy_otg_iopins_configure(config->otg_io_conf, otg_sig));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user