88
99#include "usb_host_config.h"
1010#if (defined(USB_HOST_CONFIG_IP3516HS ) && (USB_HOST_CONFIG_IP3516HS > 0U ))
11+ #if (defined CONFIG_UHC_DRIVER )
12+ #include "usb_host_mcux_drv_port.h"
13+ #include "fsl_device_registers.h"
14+ #include "usb_host_ip3516hs.h"
15+ #else
1116#include "usb_host.h"
1217#include "usb_host_hci.h"
1318#include "fsl_device_registers.h"
1419#include "usb_host_ip3516hs.h"
1520#include "usb_host_devices.h"
21+ #endif
1622#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT ) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U ))
1723#include "usb_phy.h"
1824#endif
@@ -352,6 +358,15 @@ static void USB_HostIp3516HsDelay(usb_host_ip3516hs_state_struct_t *usbHostState
352358 (USB_HOST_IP3516HS_FLADJ_FRINDEX_MASK >> USB_HOST_IP3516HS_FLADJ_FRINDEX_SHIFT ));
353359 } while ((distance ) < (ms )); /* compute the distance between sofStart and SofEnd */
354360}
361+
362+ static uint8_t USB_HostIp3516HsGetDeviceInfo (usb_device_handle deviceHandle , uint32_t infoCode )
363+ {
364+ uint32_t info_val ;
365+
366+ USB_HostHelperGetPeripheralInformation (deviceHandle , (uint32_t )infoCode , & info_val );
367+ return (uint8_t )info_val ;
368+ }
369+
355370/*seperate bus control to standlone alone function for misra Rule17.2*/
356371static usb_status_t USB_HostIp3516HsControlBusReset (usb_host_ip3516hs_state_struct_t * usbHostState )
357372{
@@ -471,14 +486,11 @@ static usb_status_t USB_HostIp3516HsControlBus(usb_host_ip3516hs_state_struct_t
471486 ((uint32_t )usbHostState -> L1remoteWakeupEnable << USB_HOST_IP3516HS_USBCMD_LPM_RWU_SHIFT ));
472487 usbHostState -> usbRegBase -> USBCMD = portStatus ;
473488
474- usb_host_device_instance_t * deviceInstance ;
475-
476489 usbHostState -> busSuspendStatus = (uint8_t )kBus_Ip3516HsL1StartSleep ;
477490
478- deviceInstance = (usb_host_device_instance_t * )hostPointer -> suspendedDevice ;
479491 usbHostState -> usbRegBase -> PORTSC1 |= (uint32_t )(
480492 (uint32_t )USB_HOST_IP3516HS_PORTSC1_SUSP_MASK | (uint32_t )USB_HOST_IP3516HS_PORTSC1_SUS_L1_MASK |
481- (((uint32_t )deviceInstance -> setAddress << USB_HOST_IP3516HS_PORTSC1_DEV_ADD_SHIFT ) &
493+ (((uint32_t )USB_HostIp3516HsGetDeviceInfo ( hostPointer -> suspendedDevice , kUSB_HostGetDeviceAddress ) << USB_HOST_IP3516HS_PORTSC1_DEV_ADD_SHIFT ) &
482494 (uint32_t )USB_HOST_IP3516HS_PORTSC1_DEV_ADD_MASK ));
483495#if (defined(FSL_FEATURE_USBHSH_VERSION ) && (FSL_FEATURE_USBHSH_VERSION >= 300U ))
484496#else
@@ -1126,7 +1138,7 @@ static usb_status_t USB_HostIp3516HsFindStartFrame(usb_host_ip3516hs_state_struc
11261138 uint32_t total = 0U ;
11271139 void * temp ;
11281140 uint8_t slotTime [8 ];
1129- uint8_t speed = (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ;
1141+ uint8_t speed = USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ;
11301142
11311143 pipe -> startUFrame = 0U ;
11321144
@@ -1280,7 +1292,7 @@ static usb_status_t USB_HostIp3516BaudWidthCheck(usb_host_ip3516hs_state_struct_
12801292 usb_host_ip3516hs_pipe_struct_t * pipe )
12811293{
12821294 usb_status_t error ;
1283- uint8_t speed = (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ;
1295+ uint8_t speed = USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ;
12841296 OSA_SR_ALLOC ();
12851297
12861298 pipe -> busHsTime = (uint16_t )USB_HostIp3516HsBusTime (
@@ -1334,11 +1346,11 @@ static usb_status_t USB_HostIp3516HsOpenControlBulkPipe(usb_host_ip3516hs_state_
13341346 atl -> control1Union .stateBitField .Mult = pipe -> pipeCommon .numberPerUframe ;
13351347 atl -> control2Union .stateBitField .EP = pipe -> pipeCommon .endpointAddress ;
13361348 atl -> control2Union .stateBitField .DeviceAddress =
1337- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> setAddress ;
1349+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceAddress ) ;
13381350 if (USB_SPEED_HIGH == usbHostState -> portState [0 ].portSpeed )
13391351 {
13401352 atl -> control2Union .stateBitField .S =
1341- (USB_SPEED_HIGH == (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ) ? 0U : 1U ;
1353+ (USB_SPEED_HIGH == USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ) ? 0U : 1U ;
13421354 }
13431355 else
13441356 {
@@ -1347,16 +1359,16 @@ static usb_status_t USB_HostIp3516HsOpenControlBulkPipe(usb_host_ip3516hs_state_
13471359 atl -> control2Union .stateBitField .RL = 0xFU ;
13481360 atl -> stateUnion .stateBitField .NakCnt = 0xFU ;
13491361 atl -> control2Union .stateBitField .SE =
1350- (USB_SPEED_LOW == (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ) ? 2U : 0U ;
1362+ (USB_SPEED_LOW == USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ) ? 2U : 0U ;
13511363 atl -> control2Union .stateBitField .PortNumber =
13521364#if (defined (USB_HOST_CONFIG_HUB ) && (USB_HOST_CONFIG_HUB > 0U ))
1353- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> hsHubPort ;
1365+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceHSHubPort ) ;
13541366#else
13551367 0U ;
13561368#endif
13571369 atl -> control2Union .stateBitField .HubAddress =
13581370#if (defined (USB_HOST_CONFIG_HUB ) && (USB_HOST_CONFIG_HUB > 0U ))
1359- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> hsHubNumber ;
1371+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceHSHubNumber ) ;
13601372#else
13611373 0U ;
13621374#endif
@@ -1433,11 +1445,11 @@ static usb_status_t USB_HostIp3516HsOpenIsoPipe(usb_host_ip3516hs_state_struct_t
14331445 ptl -> control1Union .stateBitField .Mult = pipe -> pipeCommon .numberPerUframe ;
14341446 ptl -> control2Union .stateBitField .EP = pipe -> pipeCommon .endpointAddress ;
14351447 ptl -> control2Union .stateBitField .DeviceAddress =
1436- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> setAddress ;
1448+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceAddress ) ;
14371449 if (USB_SPEED_HIGH == usbHostState -> portState [0 ].portSpeed )
14381450 {
14391451 ptl -> control2Union .stateBitField .S =
1440- (USB_SPEED_HIGH == (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ) ? 0U : 1U ;
1452+ (USB_SPEED_HIGH == USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ) ? 0U : 1U ;
14411453 }
14421454 else
14431455 {
@@ -1446,18 +1458,18 @@ static usb_status_t USB_HostIp3516HsOpenIsoPipe(usb_host_ip3516hs_state_struct_t
14461458 ptl -> control2Union .stateBitField .RL = 0U ;
14471459 ptl -> stateUnion .stateBitField .NakCnt = 0U ;
14481460 ptl -> control2Union .stateBitField .SE =
1449- (USB_SPEED_LOW == (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ) ? 2U : 0U ;
1461+ (USB_SPEED_LOW == USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ) ? 2U : 0U ;
14501462 if (0U != ptl -> control2Union .stateBitField .S )
14511463 {
14521464 sptl -> control2Union .stateBitField .PortNumber =
14531465#if (defined (USB_HOST_CONFIG_HUB ) && (USB_HOST_CONFIG_HUB > 0U ))
1454- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> hsHubPort ;
1466+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceHSHubPort ) ;
14551467#else
14561468 0U ;
14571469#endif
14581470 sptl -> control2Union .stateBitField .HubAddress =
14591471#if (defined (USB_HOST_CONFIG_HUB ) && (USB_HOST_CONFIG_HUB > 0U ))
1460- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> hsHubNumber ;
1472+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceHSHubNumber ) ;
14611473#else
14621474 0U ;
14631475#endif
@@ -1523,11 +1535,11 @@ static usb_status_t USB_HostIp3516HsOpenInterruptPipe(usb_host_ip3516hs_state_st
15231535 ptl -> control1Union .stateBitField .Mult = pipe -> pipeCommon .numberPerUframe ;
15241536 ptl -> control2Union .stateBitField .EP = pipe -> pipeCommon .endpointAddress ;
15251537 ptl -> control2Union .stateBitField .DeviceAddress =
1526- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> setAddress ;
1538+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceAddress ) ;
15271539 if (USB_SPEED_HIGH == usbHostState -> portState [0 ].portSpeed )
15281540 {
15291541 ptl -> control2Union .stateBitField .S =
1530- (USB_SPEED_HIGH == (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ) ? 0U : 1U ;
1542+ (USB_SPEED_HIGH == USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ) ? 0U : 1U ;
15311543 }
15321544 else
15331545 {
@@ -1536,18 +1548,18 @@ static usb_status_t USB_HostIp3516HsOpenInterruptPipe(usb_host_ip3516hs_state_st
15361548 ptl -> control2Union .stateBitField .RL = 0xFU ;
15371549 ptl -> stateUnion .stateBitField .NakCnt = 0xFU ;
15381550 ptl -> control2Union .stateBitField .SE =
1539- (USB_SPEED_LOW == (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ) ? 2U : 0U ;
1551+ (USB_SPEED_LOW == USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ) ? 2U : 0U ;
15401552 if (0U != ptl -> control2Union .stateBitField .S )
15411553 {
15421554 sptl -> control2Union .stateBitField .PortNumber =
15431555#if (defined (USB_HOST_CONFIG_HUB ) && (USB_HOST_CONFIG_HUB > 0U ))
1544- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> hsHubPort ;
1556+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceHSHubPort ) ;
15451557#else
15461558 0U ;
15471559#endif
15481560 sptl -> control2Union .stateBitField .HubAddress =
15491561#if (defined (USB_HOST_CONFIG_HUB ) && (USB_HOST_CONFIG_HUB > 0U ))
1550- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> hsHubNumber ;
1562+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceHSHubNumber ) ;
15511563#else
15521564 0U ;
15531565#endif
@@ -2221,7 +2233,7 @@ static usb_status_t USB_HostIp3516HsWriteIsoPipe(usb_host_ip3516hs_state_struct_
22212233 indexLength_t indexLength ;
22222234 uint8_t * bufferAddress ;
22232235 void * temp ;
2224- uint8_t speed = (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ;
2236+ uint8_t speed = USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ;
22252237 OSA_SR_ALLOC ();
22262238
22272239 OSA_ENTER_CRITICAL ();
@@ -2425,7 +2437,7 @@ static usb_status_t USB_HostIp3516HsWriteInterruptPipe(usb_host_ip3516hs_state_s
24252437 uint32_t insertUFrame ;
24262438 uint8_t * bufferAddress ;
24272439 void * temp ;
2428- uint8_t speed = (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed ;
2440+ uint8_t speed = USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) ;
24292441 temp = (void * )ptl ;
24302442 sptl = (usb_host_ip3516hs_sptl_struct_t * )temp ;
24312443 OSA_SR_ALLOC ();
@@ -3586,7 +3598,7 @@ usb_status_t USB_HostIp3516HsOpenPipe(usb_host_controller_handle controllerHandl
35863598 }
35873599 else if (USB_ENDPOINT_INTERRUPT == pipe -> pipeCommon .pipeType )
35883600 {
3589- if (USB_SPEED_HIGH != (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed )
3601+ if (USB_SPEED_HIGH != USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) )
35903602 {
35913603 uint32_t interval = 0U ;
35923604 /* FS/LS interrupt interval should be the power of 2, it is used for ip3516hs bandwidth */
@@ -3613,7 +3625,7 @@ usb_status_t USB_HostIp3516HsOpenPipe(usb_host_controller_handle controllerHandl
36133625 pipe -> pipeCommon .interval = 0U ;
36143626 }
36153627
3616- if (USB_SPEED_HIGH != (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> speed )
3628+ if (USB_SPEED_HIGH != USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceSpeed ) )
36173629 {
36183630 pipe -> pipeCommon .interval = pipe -> pipeCommon .interval << 3 ;
36193631 }
0 commit comments