8
8
9
9
#include "usb_host_config.h"
10
10
#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
11
16
#include "usb_host.h"
12
17
#include "usb_host_hci.h"
13
18
#include "fsl_device_registers.h"
14
19
#include "usb_host_ip3516hs.h"
15
20
#include "usb_host_devices.h"
21
+ #endif
16
22
#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT ) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U ))
17
23
#include "usb_phy.h"
18
24
#endif
@@ -352,6 +358,15 @@ static void USB_HostIp3516HsDelay(usb_host_ip3516hs_state_struct_t *usbHostState
352
358
(USB_HOST_IP3516HS_FLADJ_FRINDEX_MASK >> USB_HOST_IP3516HS_FLADJ_FRINDEX_SHIFT ));
353
359
} while ((distance ) < (ms )); /* compute the distance between sofStart and SofEnd */
354
360
}
361
+
362
+ static uint8_t USB_HostIp3516HsGetDeviceInfo (usb_device_handle deviceHandle , uint32_t infoCode )
363
+ {
364
+ uint32_t info_val = 0U ;
365
+
366
+ USB_HostHelperGetPeripheralInformation (deviceHandle , (uint32_t )infoCode , & info_val );
367
+ return (uint8_t )info_val ;
368
+ }
369
+
355
370
/*seperate bus control to standlone alone function for misra Rule17.2*/
356
371
static usb_status_t USB_HostIp3516HsControlBusReset (usb_host_ip3516hs_state_struct_t * usbHostState )
357
372
{
@@ -471,14 +486,11 @@ static usb_status_t USB_HostIp3516HsControlBus(usb_host_ip3516hs_state_struct_t
471
486
((uint32_t )usbHostState -> L1remoteWakeupEnable << USB_HOST_IP3516HS_USBCMD_LPM_RWU_SHIFT ));
472
487
usbHostState -> usbRegBase -> USBCMD = portStatus ;
473
488
474
- usb_host_device_instance_t * deviceInstance ;
475
-
476
489
usbHostState -> busSuspendStatus = (uint8_t )kBus_Ip3516HsL1StartSleep ;
477
490
478
- deviceInstance = (usb_host_device_instance_t * )hostPointer -> suspendedDevice ;
479
491
usbHostState -> usbRegBase -> PORTSC1 |= (uint32_t )(
480
492
(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 ) &
482
494
(uint32_t )USB_HOST_IP3516HS_PORTSC1_DEV_ADD_MASK ));
483
495
#if (defined(FSL_FEATURE_USBHSH_VERSION ) && (FSL_FEATURE_USBHSH_VERSION >= 300U ))
484
496
#else
@@ -1126,7 +1138,7 @@ static usb_status_t USB_HostIp3516HsFindStartFrame(usb_host_ip3516hs_state_struc
1126
1138
uint32_t total = 0U ;
1127
1139
void * temp ;
1128
1140
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 ) ;
1130
1142
1131
1143
pipe -> startUFrame = 0U ;
1132
1144
@@ -1280,7 +1292,7 @@ static usb_status_t USB_HostIp3516BaudWidthCheck(usb_host_ip3516hs_state_struct_
1280
1292
usb_host_ip3516hs_pipe_struct_t * pipe )
1281
1293
{
1282
1294
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 ) ;
1284
1296
OSA_SR_ALLOC ();
1285
1297
1286
1298
pipe -> busHsTime = (uint16_t )USB_HostIp3516HsBusTime (
@@ -1334,11 +1346,11 @@ static usb_status_t USB_HostIp3516HsOpenControlBulkPipe(usb_host_ip3516hs_state_
1334
1346
atl -> control1Union .stateBitField .Mult = pipe -> pipeCommon .numberPerUframe ;
1335
1347
atl -> control2Union .stateBitField .EP = pipe -> pipeCommon .endpointAddress ;
1336
1348
atl -> control2Union .stateBitField .DeviceAddress =
1337
- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> setAddress ;
1349
+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceAddress ) ;
1338
1350
if (USB_SPEED_HIGH == usbHostState -> portState [0 ].portSpeed )
1339
1351
{
1340
1352
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 ;
1342
1354
}
1343
1355
else
1344
1356
{
@@ -1347,16 +1359,16 @@ static usb_status_t USB_HostIp3516HsOpenControlBulkPipe(usb_host_ip3516hs_state_
1347
1359
atl -> control2Union .stateBitField .RL = 0xFU ;
1348
1360
atl -> stateUnion .stateBitField .NakCnt = 0xFU ;
1349
1361
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 ;
1351
1363
atl -> control2Union .stateBitField .PortNumber =
1352
1364
#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 ) ;
1354
1366
#else
1355
1367
0U ;
1356
1368
#endif
1357
1369
atl -> control2Union .stateBitField .HubAddress =
1358
1370
#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 ) ;
1360
1372
#else
1361
1373
0U ;
1362
1374
#endif
@@ -1433,11 +1445,11 @@ static usb_status_t USB_HostIp3516HsOpenIsoPipe(usb_host_ip3516hs_state_struct_t
1433
1445
ptl -> control1Union .stateBitField .Mult = pipe -> pipeCommon .numberPerUframe ;
1434
1446
ptl -> control2Union .stateBitField .EP = pipe -> pipeCommon .endpointAddress ;
1435
1447
ptl -> control2Union .stateBitField .DeviceAddress =
1436
- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> setAddress ;
1448
+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceAddress ) ;
1437
1449
if (USB_SPEED_HIGH == usbHostState -> portState [0 ].portSpeed )
1438
1450
{
1439
1451
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 ;
1441
1453
}
1442
1454
else
1443
1455
{
@@ -1446,18 +1458,18 @@ static usb_status_t USB_HostIp3516HsOpenIsoPipe(usb_host_ip3516hs_state_struct_t
1446
1458
ptl -> control2Union .stateBitField .RL = 0U ;
1447
1459
ptl -> stateUnion .stateBitField .NakCnt = 0U ;
1448
1460
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 ;
1450
1462
if (0U != ptl -> control2Union .stateBitField .S )
1451
1463
{
1452
1464
sptl -> control2Union .stateBitField .PortNumber =
1453
1465
#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 ) ;
1455
1467
#else
1456
1468
0U ;
1457
1469
#endif
1458
1470
sptl -> control2Union .stateBitField .HubAddress =
1459
1471
#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 ) ;
1461
1473
#else
1462
1474
0U ;
1463
1475
#endif
@@ -1523,11 +1535,11 @@ static usb_status_t USB_HostIp3516HsOpenInterruptPipe(usb_host_ip3516hs_state_st
1523
1535
ptl -> control1Union .stateBitField .Mult = pipe -> pipeCommon .numberPerUframe ;
1524
1536
ptl -> control2Union .stateBitField .EP = pipe -> pipeCommon .endpointAddress ;
1525
1537
ptl -> control2Union .stateBitField .DeviceAddress =
1526
- (( usb_host_device_instance_t * ) pipe -> pipeCommon .deviceHandle ) -> setAddress ;
1538
+ USB_HostIp3516HsGetDeviceInfo ( pipe -> pipeCommon .deviceHandle , kUSB_HostGetDeviceAddress ) ;
1527
1539
if (USB_SPEED_HIGH == usbHostState -> portState [0 ].portSpeed )
1528
1540
{
1529
1541
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 ;
1531
1543
}
1532
1544
else
1533
1545
{
@@ -1536,18 +1548,18 @@ static usb_status_t USB_HostIp3516HsOpenInterruptPipe(usb_host_ip3516hs_state_st
1536
1548
ptl -> control2Union .stateBitField .RL = 0xFU ;
1537
1549
ptl -> stateUnion .stateBitField .NakCnt = 0xFU ;
1538
1550
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 ;
1540
1552
if (0U != ptl -> control2Union .stateBitField .S )
1541
1553
{
1542
1554
sptl -> control2Union .stateBitField .PortNumber =
1543
1555
#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 ) ;
1545
1557
#else
1546
1558
0U ;
1547
1559
#endif
1548
1560
sptl -> control2Union .stateBitField .HubAddress =
1549
1561
#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 ) ;
1551
1563
#else
1552
1564
0U ;
1553
1565
#endif
@@ -2221,7 +2233,7 @@ static usb_status_t USB_HostIp3516HsWriteIsoPipe(usb_host_ip3516hs_state_struct_
2221
2233
indexLength_t indexLength ;
2222
2234
uint8_t * bufferAddress ;
2223
2235
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 ) ;
2225
2237
OSA_SR_ALLOC ();
2226
2238
2227
2239
OSA_ENTER_CRITICAL ();
@@ -2425,7 +2437,7 @@ static usb_status_t USB_HostIp3516HsWriteInterruptPipe(usb_host_ip3516hs_state_s
2425
2437
uint32_t insertUFrame ;
2426
2438
uint8_t * bufferAddress ;
2427
2439
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 ) ;
2429
2441
temp = (void * )ptl ;
2430
2442
sptl = (usb_host_ip3516hs_sptl_struct_t * )temp ;
2431
2443
OSA_SR_ALLOC ();
@@ -3586,7 +3598,7 @@ usb_status_t USB_HostIp3516HsOpenPipe(usb_host_controller_handle controllerHandl
3586
3598
}
3587
3599
else if (USB_ENDPOINT_INTERRUPT == pipe -> pipeCommon .pipeType )
3588
3600
{
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 ) )
3590
3602
{
3591
3603
uint32_t interval = 0U ;
3592
3604
/* 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
3613
3625
pipe -> pipeCommon .interval = 0U ;
3614
3626
}
3615
3627
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 ) )
3617
3629
{
3618
3630
pipe -> pipeCommon .interval = pipe -> pipeCommon .interval << 3 ;
3619
3631
}
0 commit comments