Skip to content

Enable NXP USB Host controllers in Zephyr #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
6 changes: 6 additions & 0 deletions mcux/README
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ Patch List:
- Add missing CMAKE files device_system.cmake device_CMSIS.cmake and drivers/driver_reset.cmake to MCXW716C.
- Add missing CMAKE file to ccm32k driver driver_ccm32k.cmake.
- Add missing CMAKE file to flash_k4 driver driver_flash_k4.cmake.
- Add usb_host_mcux_drv_port.h file for using MCUX SDK USB host controller driver easily in Zephyr.
- usb_host_mcux_drv_port.h contains the simplified structs, enums and APIs that MCUX SDK USB host controller drivers need.
- Update usb_host_ehci.c, usb_host_khci.c, usb_host_ohci.c and usb_host_ip3516hs.c if in Zephyr environment.
- Add include of usb_host_mcux_drv_port.h.
- Remove include of usb_host.h, usb_host_hci.h, usb_host_devices.h and usb_host_framework.h.
- Update usb_host_ehci.c and usb_host_ip3516hs.c to not depend on usb_host_device_instance_t struct.
22 changes: 22 additions & 0 deletions mcux/hal_nxp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,28 @@ if (CONFIG_UDC_DRIVER)
zephyr_include_directories(${CMAKE_CURRENT_LIST_DIR}/middleware/mcux-sdk-middleware-usb/include)
endif()

if (CONFIG_UHC_DRIVER)
set(CONFIG_USE_component_osa_zephyr true)

list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/mcux-sdk/components/osa
)
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/middleware/mcux-sdk-middleware-usb
)
include_ifdef(CONFIG_DT_HAS_NXP_USBPHY_ENABLED middleware_usb_phy)
include_ifdef(CONFIG_UHC_NXP_EHCI middleware_usb_host_ehci)
include_ifdef(CONFIG_UHC_NXP_KHCI middleware_usb_host_khci)
include_ifdef(CONFIG_UHC_NXP_OHCI middleware_usb_host_ohci)
include_ifdef(CONFIG_UHC_NXP_IP3516HS middleware_usb_host_ip3516hs)
include(set_component_osa)

zephyr_include_directories(${CMAKE_CURRENT_LIST_DIR}/middleware/mcux-sdk-middleware-usb/host)
zephyr_include_directories_ifdef(CONFIG_DT_HAS_NXP_USBPHY_ENABLED, ${CMAKE_CURRENT_LIST_DIR}/middleware/mcux-sdk-middleware-usb/phy)
zephyr_include_directories(${CMAKE_CURRENT_LIST_DIR}/middleware/mcux-sdk-middleware-usb/include)
zephyr_include_directories(${CMAKE_CURRENT_LIST_DIR}/mcux-sdk/components/osa)
endif()

if(${MCUX_DEVICE} MATCHES "RW61")
set(CONFIG_USE_component_osa_zephyr true)
if(CONFIG_NXP_FW_LOADER)
Expand Down
26 changes: 26 additions & 0 deletions mcux/mcux-sdk/devices/LPC55S28/drivers/fsl_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,32 @@ bool CLOCK_EnableUsbfs0HostClock(clock_usbfs_src_t src, uint32_t freq)
/* Select FRO 96 MHz */
CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
}
else if (kCLOCK_UsbfsSrcPll0 == src)
{
/*!< Configure XTAL32M */
POWER_DisablePD(kPDRUNCFG_PD_XTAL32M); /* Ensure XTAL32M is powered */
POWER_DisablePD(kPDRUNCFG_PD_LDOXO32M); /* Ensure XTAL32M is powered */
(void)CLOCK_SetupExtClocking(16000000U); /* Enable clk_in clock */
SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_CLKIN_ENA_MASK; /* Enable clk_in from XTAL32M clock */
ANACTRL->XO32M_CTRL |= ANACTRL_XO32M_CTRL_ENABLE_SYSTEM_CLK_OUT_MASK; /* Enable clk_in to system */

/*!< Set up PLL0 */
POWER_DisablePD(kPDRUNCFG_PD_PLL0);
CLOCK_AttachClk(kEXT_CLK_to_PLL0); /*!< Switch PLL0CLKSEL to EXT_CLK */
POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
const pll_setup_t pll1Setup = {
.pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(19U) | SYSCON_PLL0CTRL_SELP(9U),
.pllndec = SYSCON_PLL0NDEC_NDIV(1U),
.pllpdec = SYSCON_PLL0PDEC_PDIV(5U),
.pllsscg = {0x0U,(SYSCON_PLL0SSCG1_MDIV_EXT(30U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
.pllRate = 48000000U,
.flags = PLL_SETUPFLAG_WAITLOCK};
(void)CLOCK_SetPLL0Freq(&pll1Setup);

CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1U, false);
CLOCK_AttachClk(kPLL0_to_USB0_CLK);
SDK_DelayAtLeastUs(50U, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
}
else
{
/*!< Configure XTAL32M */
Expand Down
26 changes: 26 additions & 0 deletions mcux/mcux-sdk/devices/LPC55S69/drivers/fsl_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,32 @@ bool CLOCK_EnableUsbfs0HostClock(clock_usbfs_src_t src, uint32_t freq)
/* Select FRO 96 MHz */
CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
}
else if (kCLOCK_UsbfsSrcPll0 == src)
{
/*!< Configure XTAL32M */
POWER_DisablePD(kPDRUNCFG_PD_XTAL32M); /* Ensure XTAL32M is powered */
POWER_DisablePD(kPDRUNCFG_PD_LDOXO32M); /* Ensure XTAL32M is powered */
(void)CLOCK_SetupExtClocking(16000000U); /* Enable clk_in clock */
SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_CLKIN_ENA_MASK; /* Enable clk_in from XTAL32M clock */
ANACTRL->XO32M_CTRL |= ANACTRL_XO32M_CTRL_ENABLE_SYSTEM_CLK_OUT_MASK; /* Enable clk_in to system */

/*!< Set up PLL0 */
POWER_DisablePD(kPDRUNCFG_PD_PLL0);
CLOCK_AttachClk(kEXT_CLK_to_PLL0); /*!< Switch PLL0CLKSEL to EXT_CLK */
POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
const pll_setup_t pll1Setup = {
.pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(19U) | SYSCON_PLL0CTRL_SELP(9U),
.pllndec = SYSCON_PLL0NDEC_NDIV(1U),
.pllpdec = SYSCON_PLL0PDEC_PDIV(5U),
.pllsscg = {0x0U,(SYSCON_PLL0SSCG1_MDIV_EXT(30U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
.pllRate = 48000000U,
.flags = PLL_SETUPFLAG_WAITLOCK};
(void)CLOCK_SetPLL0Freq(&pll1Setup);

CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1U, false);
CLOCK_AttachClk(kPLL0_to_USB0_CLK);
SDK_DelayAtLeastUs(50U, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
}
else
{
/*!< Configure XTAL32M */
Expand Down
17 changes: 13 additions & 4 deletions mcux/middleware/mcux-sdk-middleware-usb/host/usb_host_ehci.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
*/
#include "usb_host_config.h"
#if ((defined USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U))
/* CONFIG_UHC_DRIVER is for Zephyr, it will not be defined in NXP MCUXpresso SDK */
#if (defined CONFIG_UHC_DRIVER)
#include "usb_host_mcux_drv_port.h"
#include "fsl_device_registers.h"
#include "usb_host_ehci.h"
#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT))
#include "usb_phy.h"
#endif
#else
#include "usb_host.h"
#include "usb_host_hci.h"
#include "usb_host_devices.h"
Expand All @@ -21,6 +30,7 @@
#if ((defined USB_HOST_CONFIG_COMPLIANCE_TEST) && (USB_HOST_CONFIG_COMPLIANCE_TEST))
#include "usb_host.h"
#endif
#endif
#if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET > 0U))
#include "fsl_memory.h"
#endif
Expand Down Expand Up @@ -3849,6 +3859,7 @@ static usb_status_t USB_HostEhciControlBus(usb_host_ehci_instance_t *ehciInstanc
case kUSB_HostBusL1Sleep:
if (0U != (ehciInstance->ehciIpBase->PORTSC1 & USBHS_PORTSC1_CCS_MASK))
{
uint32_t info_val;
volatile uint32_t lpm_count = 200000U;
OSA_SR_ALLOC();
/* set timer1 */
Expand All @@ -3874,11 +3885,9 @@ static usb_status_t USB_HostEhciControlBus(usb_host_ehci_instance_t *ehciInstanc
((uint32_t)ehciInstance->hirdValue << USBNC_LPM_CSR2_LPM_HST_BESL_SHIFT) |
((uint32_t)ehciInstance->L1remoteWakeupEnable << USBNC_LPM_CSR2_LPM_HST_RWKEN_SHIFT));
ehciInstance->registerNcBase->LPM_CSR2 = portScRegister;

usb_host_device_instance_t *deviceInstance;

ehciInstance->busSuspendStatus = kBus_EhciL1StartSleep;
deviceInstance = (usb_host_device_instance_t *)hostPointer->suspendedDevice;
USB_HostHelperGetPeripheralInformation(hostPointer->suspendedDevice, kUSB_HostGetDeviceAddress, &info_val);
OSA_ENTER_CRITICAL();
/* Workaroud for TKT0634948: begin */
ehciInstance->ehciIpBase->USBSTS |= USB_USBSTS_SRI_MASK;
Expand All @@ -3888,7 +3897,7 @@ static usb_status_t USB_HostEhciControlBus(usb_host_ehci_instance_t *ehciInstanc
lpm_count--;
}
ehciInstance->registerNcBase->LPM_CSR2 |= ((uint32_t)USBNC_LPM_CSR2_LPM_HST_SEND_MASK |
(((uint32_t)deviceInstance->setAddress << USBNC_LPM_CSR2_LPM_HST_DEVADD_SHIFT) &
(((uint32_t)info_val << USBNC_LPM_CSR2_LPM_HST_DEVADD_SHIFT) &
(uint32_t)USBNC_LPM_CSR2_LPM_HST_DEVADD_MASK));
/* Workaroud for TKT0634948: end */
OSA_EXIT_CRITICAL();
Expand Down
62 changes: 37 additions & 25 deletions mcux/middleware/mcux-sdk-middleware-usb/host/usb_host_ip3516hs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@

#include "usb_host_config.h"
#if (defined(USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
#if (defined CONFIG_UHC_DRIVER)
#include "usb_host_mcux_drv_port.h"
#include "fsl_device_registers.h"
#include "usb_host_ip3516hs.h"
#else
#include "usb_host.h"
#include "usb_host_hci.h"
#include "fsl_device_registers.h"
#include "usb_host_ip3516hs.h"
#include "usb_host_devices.h"
#endif
#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U))
#include "usb_phy.h"
#endif
Expand Down Expand Up @@ -352,6 +358,15 @@ static void USB_HostIp3516HsDelay(usb_host_ip3516hs_state_struct_t *usbHostState
(USB_HOST_IP3516HS_FLADJ_FRINDEX_MASK >> USB_HOST_IP3516HS_FLADJ_FRINDEX_SHIFT));
} while ((distance) < (ms)); /* compute the distance between sofStart and SofEnd */
}

static uint8_t USB_HostIp3516HsGetDeviceInfo(usb_device_handle deviceHandle, uint32_t infoCode)
{
uint32_t info_val;

USB_HostHelperGetPeripheralInformation(deviceHandle, (uint32_t)infoCode, &info_val);
return (uint8_t)info_val;
}

/*seperate bus control to standlone alone function for misra Rule17.2*/
static usb_status_t USB_HostIp3516HsControlBusReset(usb_host_ip3516hs_state_struct_t *usbHostState)
{
Expand Down Expand Up @@ -471,14 +486,11 @@ static usb_status_t USB_HostIp3516HsControlBus(usb_host_ip3516hs_state_struct_t
((uint32_t)usbHostState->L1remoteWakeupEnable << USB_HOST_IP3516HS_USBCMD_LPM_RWU_SHIFT));
usbHostState->usbRegBase->USBCMD = portStatus;

usb_host_device_instance_t *deviceInstance;

usbHostState->busSuspendStatus = (uint8_t)kBus_Ip3516HsL1StartSleep;

deviceInstance = (usb_host_device_instance_t *)hostPointer->suspendedDevice;
usbHostState->usbRegBase->PORTSC1 |= (uint32_t)(
(uint32_t)USB_HOST_IP3516HS_PORTSC1_SUSP_MASK | (uint32_t)USB_HOST_IP3516HS_PORTSC1_SUS_L1_MASK |
(((uint32_t)deviceInstance->setAddress << USB_HOST_IP3516HS_PORTSC1_DEV_ADD_SHIFT) &
(((uint32_t)USB_HostIp3516HsGetDeviceInfo(hostPointer->suspendedDevice, kUSB_HostGetDeviceAddress) << USB_HOST_IP3516HS_PORTSC1_DEV_ADD_SHIFT) &
(uint32_t)USB_HOST_IP3516HS_PORTSC1_DEV_ADD_MASK));
#if (defined(FSL_FEATURE_USBHSH_VERSION) && (FSL_FEATURE_USBHSH_VERSION >= 300U))
#else
Expand Down Expand Up @@ -1126,7 +1138,7 @@ static usb_status_t USB_HostIp3516HsFindStartFrame(usb_host_ip3516hs_state_struc
uint32_t total = 0U;
void *temp;
uint8_t slotTime[8];
uint8_t speed = ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed;
uint8_t speed = USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed);

pipe->startUFrame = 0U;

Expand Down Expand Up @@ -1280,7 +1292,7 @@ static usb_status_t USB_HostIp3516BaudWidthCheck(usb_host_ip3516hs_state_struct_
usb_host_ip3516hs_pipe_struct_t *pipe)
{
usb_status_t error;
uint8_t speed = ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed;
uint8_t speed = USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed);
OSA_SR_ALLOC();

pipe->busHsTime = (uint16_t)USB_HostIp3516HsBusTime(
Expand Down Expand Up @@ -1334,11 +1346,11 @@ static usb_status_t USB_HostIp3516HsOpenControlBulkPipe(usb_host_ip3516hs_state_
atl->control1Union.stateBitField.Mult = pipe->pipeCommon.numberPerUframe;
atl->control2Union.stateBitField.EP = pipe->pipeCommon.endpointAddress;
atl->control2Union.stateBitField.DeviceAddress =
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->setAddress;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceAddress);
if (USB_SPEED_HIGH == usbHostState->portState[0].portSpeed)
{
atl->control2Union.stateBitField.S =
(USB_SPEED_HIGH == ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed) ? 0U : 1U;
(USB_SPEED_HIGH == USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed)) ? 0U : 1U;
}
else
{
Expand All @@ -1347,16 +1359,16 @@ static usb_status_t USB_HostIp3516HsOpenControlBulkPipe(usb_host_ip3516hs_state_
atl->control2Union.stateBitField.RL = 0xFU;
atl->stateUnion.stateBitField.NakCnt = 0xFU;
atl->control2Union.stateBitField.SE =
(USB_SPEED_LOW == ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed) ? 2U : 0U;
(USB_SPEED_LOW == USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed)) ? 2U : 0U;
atl->control2Union.stateBitField.PortNumber =
#if (defined(USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB > 0U))
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->hsHubPort;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceHSHubPort);
#else
0U;
#endif
atl->control2Union.stateBitField.HubAddress =
#if (defined(USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB > 0U))
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->hsHubNumber;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceHSHubNumber);
#else
0U;
#endif
Expand Down Expand Up @@ -1433,11 +1445,11 @@ static usb_status_t USB_HostIp3516HsOpenIsoPipe(usb_host_ip3516hs_state_struct_t
ptl->control1Union.stateBitField.Mult = pipe->pipeCommon.numberPerUframe;
ptl->control2Union.stateBitField.EP = pipe->pipeCommon.endpointAddress;
ptl->control2Union.stateBitField.DeviceAddress =
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->setAddress;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceAddress);
if (USB_SPEED_HIGH == usbHostState->portState[0].portSpeed)
{
ptl->control2Union.stateBitField.S =
(USB_SPEED_HIGH == ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed) ? 0U : 1U;
(USB_SPEED_HIGH == USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed)) ? 0U : 1U;
}
else
{
Expand All @@ -1446,18 +1458,18 @@ static usb_status_t USB_HostIp3516HsOpenIsoPipe(usb_host_ip3516hs_state_struct_t
ptl->control2Union.stateBitField.RL = 0U;
ptl->stateUnion.stateBitField.NakCnt = 0U;
ptl->control2Union.stateBitField.SE =
(USB_SPEED_LOW == ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed) ? 2U : 0U;
(USB_SPEED_LOW == USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed)) ? 2U : 0U;
if (0U != ptl->control2Union.stateBitField.S)
{
sptl->control2Union.stateBitField.PortNumber =
#if (defined(USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB > 0U))
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->hsHubPort;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceHSHubPort);
#else
0U;
#endif
sptl->control2Union.stateBitField.HubAddress =
#if (defined(USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB > 0U))
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->hsHubNumber;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceHSHubNumber);
#else
0U;
#endif
Expand Down Expand Up @@ -1523,11 +1535,11 @@ static usb_status_t USB_HostIp3516HsOpenInterruptPipe(usb_host_ip3516hs_state_st
ptl->control1Union.stateBitField.Mult = pipe->pipeCommon.numberPerUframe;
ptl->control2Union.stateBitField.EP = pipe->pipeCommon.endpointAddress;
ptl->control2Union.stateBitField.DeviceAddress =
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->setAddress;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceAddress);
if (USB_SPEED_HIGH == usbHostState->portState[0].portSpeed)
{
ptl->control2Union.stateBitField.S =
(USB_SPEED_HIGH == ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed) ? 0U : 1U;
(USB_SPEED_HIGH == USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed)) ? 0U : 1U;
}
else
{
Expand All @@ -1536,18 +1548,18 @@ static usb_status_t USB_HostIp3516HsOpenInterruptPipe(usb_host_ip3516hs_state_st
ptl->control2Union.stateBitField.RL = 0xFU;
ptl->stateUnion.stateBitField.NakCnt = 0xFU;
ptl->control2Union.stateBitField.SE =
(USB_SPEED_LOW == ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed) ? 2U : 0U;
(USB_SPEED_LOW == USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed)) ? 2U : 0U;
if (0U != ptl->control2Union.stateBitField.S)
{
sptl->control2Union.stateBitField.PortNumber =
#if (defined(USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB > 0U))
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->hsHubPort;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceHSHubPort);
#else
0U;
#endif
sptl->control2Union.stateBitField.HubAddress =
#if (defined(USB_HOST_CONFIG_HUB) && (USB_HOST_CONFIG_HUB > 0U))
((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->hsHubNumber;
USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceHSHubNumber);
#else
0U;
#endif
Expand Down Expand Up @@ -2221,7 +2233,7 @@ static usb_status_t USB_HostIp3516HsWriteIsoPipe(usb_host_ip3516hs_state_struct_
indexLength_t indexLength;
uint8_t *bufferAddress;
void *temp;
uint8_t speed = ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed;
uint8_t speed = USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed);
OSA_SR_ALLOC();

OSA_ENTER_CRITICAL();
Expand Down Expand Up @@ -2425,7 +2437,7 @@ static usb_status_t USB_HostIp3516HsWriteInterruptPipe(usb_host_ip3516hs_state_s
uint32_t insertUFrame;
uint8_t *bufferAddress;
void *temp;
uint8_t speed = ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed;
uint8_t speed = USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed);
temp = (void *)ptl;
sptl = (usb_host_ip3516hs_sptl_struct_t *)temp;
OSA_SR_ALLOC();
Expand Down Expand Up @@ -3586,7 +3598,7 @@ usb_status_t USB_HostIp3516HsOpenPipe(usb_host_controller_handle controllerHandl
}
else if (USB_ENDPOINT_INTERRUPT == pipe->pipeCommon.pipeType)
{
if (USB_SPEED_HIGH != ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed)
if (USB_SPEED_HIGH != USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed))
{
uint32_t interval = 0U;
/* FS/LS interrupt interval should be the power of 2, it is used for ip3516hs bandwidth */
Expand All @@ -3613,7 +3625,7 @@ usb_status_t USB_HostIp3516HsOpenPipe(usb_host_controller_handle controllerHandl
pipe->pipeCommon.interval = 0U;
}

if (USB_SPEED_HIGH != ((usb_host_device_instance_t *)pipe->pipeCommon.deviceHandle)->speed)
if (USB_SPEED_HIGH != USB_HostIp3516HsGetDeviceInfo(pipe->pipeCommon.deviceHandle, kUSB_HostGetDeviceSpeed))
{
pipe->pipeCommon.interval = pipe->pipeCommon.interval << 3;
}
Expand Down
Loading