feat(esp32p4): Add USB-OTG support for ESP32-P4

This commit is contained in:
Tomas Rezucha
2024-01-30 15:07:11 +01:00
parent bc7e87b416
commit f13ae0fc08
45 changed files with 208 additions and 71 deletions
+4 -3
View File
@@ -248,9 +248,10 @@ if(NOT BOOTLOADER_BUILD)
endif()
if(CONFIG_SOC_USB_OTG_SUPPORTED)
list(APPEND srcs
"usb_dwc_hal.c"
"usb_fsls_phy_hal.c")
list(APPEND srcs "usb_dwc_hal.c")
if(NOT ${target} STREQUAL "esp32p4")
list(APPEND srcs "usb_fsls_phy_hal.c")
endif()
endif()
if(${target} STREQUAL "esp32")
+4 -2
View File
@@ -114,8 +114,10 @@ if(CONFIG_SOC_IEEE802154_SUPPORTED)
endif()
if(CONFIG_SOC_USB_OTG_SUPPORTED)
list(APPEND srcs "${target}/usb_periph.c"
"${target}/usb_dwc_periph.c")
if(NOT ${target} STREQUAL "esp32p4")
list(APPEND srcs "${target}/usb_periph.c"
"${target}/usb_dwc_periph.c")
endif()
endif()
if(CONFIG_SOC_DAC_SUPPORTED)
@@ -63,6 +63,10 @@ config SOC_EMAC_SUPPORTED
bool
default y
config SOC_USB_OTG_SUPPORTED
bool
default y
config SOC_TEMP_SENSOR_SUPPORTED
bool
default y
@@ -36,6 +36,7 @@
// #define SOC_PARLIO_SUPPORTED 1 //TODO: IDF-7471
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
#define SOC_EMAC_SUPPORTED 1
#define SOC_USB_OTG_SUPPORTED 1
// disable usb serial jtag for esp32p4, current image does not support
// #define SOC_USB_SERIAL_JTAG_SUPPORTED 1 //TODO: IDF-7496
#define SOC_TEMP_SENSOR_SUPPORTED 1
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
/*
Note: These macros are deprecated.
We define them for P4 only for backward compatibility with older version of esp_tinyusb
Todo: Remove in IDF v6.0 (IDF-9029)
*/
#define USBPHY_VP_NUM -1
#define USBPHY_VM_NUM -1
#define USBPHY_RCV_NUM -1
#define USBPHY_OEN_NUM -1
#define USBPHY_VPO_NUM -1
#define USBPHY_VMO_NUM -1
+6 -2
View File
@@ -18,8 +18,12 @@ if(CONFIG_SOC_USB_OTG_SUPPORTED)
"usb_helpers.c"
"usb_host.c"
"usb_private.c"
"usbh.c"
"usb_phy.c")
"usbh.c")
if(NOT ${target} STREQUAL "esp32p4")
list(APPEND srcs "usb_phy.c")
else()
list(APPEND srcs "usb_phy_p4.c")
endif()
list(APPEND include "include")
list(APPEND priv_includes "private_include")
endif()
+1 -1
View File
@@ -7,7 +7,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "soc/soc_caps.h"
#include "hal/usb_phy_types.h"
@@ -3,8 +3,17 @@
components/usb/test_apps:
enable:
- if: SOC_USB_OTG_SUPPORTED == 1
disable_test:
- if: IDF_TARGET not in ["esp32s3"]
temporary: true
reason: lack of runners with usb_host_flash_disk tag
depends_components:
- usb
depends_filepatterns:
- components/hal/usb*.c
- components/hal/include/hal/usb*.h
- components/hal/esp32*/include/hal/usb*.h
- components/soc/esp32*/usb*.c
- components/soc/include/soc/usb*.h
- components/soc/esp32*/include/soc/usb_dwc_*.h
- components/soc/esp32*/include/soc/usb_wrap_*.h
+2 -2
View File
@@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB: Host test application
@@ -1,12 +1,13 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s2', 'esp32p4'], reason='lack of runners with usb_host_flash_disk tag')
@pytest.mark.usb_host_flash_disk
def test_usb_hcd(dut: Dut) -> None:
dut.run_all_single_board_cases(group='full_speed')
+2 -2
View File
@@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB: Host test application
@@ -1,12 +1,13 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s2', 'esp32p4'], reason='lack of runners with usb_host_flash_disk tag')
@pytest.mark.usb_host_flash_disk
def test_usb_host(dut: Dut) -> None:
dut.run_all_single_board_cases(group='full_speed')
+30
View File
@@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
// This is only a dummy USB PHY file for successful linking of ESP32-P4 target
// The internal HS PHY is enabled by default, therefore it needs no configuration
// TODO: Remove this file when proper support of P4 PHYs is implemented IDF-7323
#include "esp_private/usb_phy.h"
esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_ret)
{
return ESP_OK;
}
esp_err_t usb_del_phy(usb_phy_handle_t handle)
{
return ESP_OK;
}
esp_err_t usb_phy_get_phy_status(usb_phy_target_t target, usb_phy_status_t *status)
{
return ESP_OK;
}
esp_err_t usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action)
{
return ESP_OK;
}