1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Universal Host Controller Driver (UHCI)
*
* The UHCI driver is a driver which interfaces to the Universal
* Serial Bus Driver (USBA) and the Host Controller (HC). The interface to
* the Host Controller is defined by the Universal Host Controller Interface.
* This file contains the code for HCDI entry points.
*/
#include <sys/usb/hcd/uhci/uhcid.h>
#include <sys/usb/hcd/uhci/uhcitgt.h>
#include <sys/usb/hcd/uhci/uhciutil.h>
#include <sys/strsun.h>
/* function prototypes */
static int uhci_pipe_send_isoc_data(uhci_state_t *uhcip,
usba_pipe_handle_data_t *ph, usb_isoc_req_t *isoc_req,
usb_flags_t usb_flags);
static int uhci_send_intr_data(uhci_state_t *uhcip,
usba_pipe_handle_data_t *pipe_handle,
usb_intr_req_t *req,
usb_flags_t flags);
static int uhci_start_periodic_pipe_polling(uhci_state_t *uhcip,
usba_pipe_handle_data_t *ph,
usb_opaque_t reqp,
usb_flags_t flags);
static int uhci_stop_periodic_pipe_polling(uhci_state_t *uhcip,
usba_pipe_handle_data_t *ph,
usb_flags_t flags);
static void uhci_update_intr_td_data_toggle(uhci_state_t *uhcip,
uhci_pipe_private_t *pp);
/* Maximum bulk transfer size */
int uhci_bulk_transfer_size = UHCI_BULK_MAX_XFER_SIZE;
/*
* uhci_hcdi_pipe_open:
* Member of HCD Ops structure and called during client specific pipe open
* Add the pipe to the data structure representing the device and allocate
* bandwidth for the pipe if it is a interrupt or isochronous endpoint.
*/
int
uhci_hcdi_pipe_open(usba_pipe_handle_data_t *ph, usb_flags_t flags)
{
uint_t node = 0;
usb_addr_t usb_addr;
uhci_state_t *uhcip;
uhci_pipe_private_t *pp;
int rval, error = USB_SUCCESS;
ASSERT(ph);
usb_addr = ph->p_usba_device->usb_addr;
uhcip = uhci_obtain_state(ph->p_usba_device->usb_root_hub_dip);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: addr = 0x%x, ep%d", usb_addr,
ph->p_ep.bEndpointAddress & USB_EP_NUM_MASK);
sema_p(&uhcip->uhci_ocsem);
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
mutex_exit(&uhcip->uhci_int_mutex);
if (rval != USB_SUCCESS) {
sema_v(&uhcip->uhci_ocsem);
return (rval);
}
/*
* Return failure immediately for any other pipe open on the root hub
* except control or interrupt pipe.
*/
if (usb_addr == ROOT_HUB_ADDR) {
switch (UHCI_XFER_TYPE(&ph->p_ep)) {
case USB_EP_ATTR_CONTROL:
USB_DPRINTF_L3(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: Root hub control pipe");
break;
case USB_EP_ATTR_INTR:
ASSERT(UHCI_XFER_DIR(&ph->p_ep) == USB_EP_DIR_IN);
mutex_enter(&uhcip->uhci_int_mutex);
uhcip->uhci_root_hub.rh_intr_pipe_handle = ph;
/*
* Set the state of the root hub interrupt
* pipe as IDLE.
*/
uhcip->uhci_root_hub.rh_pipe_state =
UHCI_PIPE_STATE_IDLE;
ASSERT(uhcip->uhci_root_hub.rh_client_intr_req == NULL);
uhcip->uhci_root_hub.rh_client_intr_req = NULL;
ASSERT(uhcip->uhci_root_hub.rh_curr_intr_reqp == NULL);
uhcip->uhci_root_hub.rh_curr_intr_reqp = NULL;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: Root hub interrupt "
"pipe open succeeded");
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
return (USB_SUCCESS);
default:
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: Root hub pipe open failed");
sema_v(&uhcip->uhci_ocsem);
return (USB_FAILURE);
}
}
/*
* A portion of the bandwidth is reserved for the non-periodic
* transfers i.e control and bulk transfers in each of one
* mill second frame period & usually it will be 10% of frame
* period. Hence there is no need to check for the available
* bandwidth before adding the control or bulk endpoints.
*
* There is a need to check for the available bandwidth before
* adding the periodic transfers i.e interrupt & isochronous, since
* all these periodic transfers are guaranteed transfers. Usually,
* 90% of the total frame time is reserved for periodic transfers.
*/
if (UHCI_PERIODIC_ENDPOINT(&ph->p_ep)) {
/* Zero Max Packet size endpoints are not supported */
if (ph->p_ep.wMaxPacketSize == 0) {
USB_DPRINTF_L3(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: Zero length packet");
sema_v(&uhcip->uhci_ocsem);
return (USB_FAILURE);
}
mutex_enter(&uhcip->uhci_int_mutex);
mutex_enter(&ph->p_mutex);
error = uhci_allocate_bandwidth(uhcip, ph, &node);
if (error != USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: Bandwidth allocation failed");
mutex_exit(&ph->p_mutex);
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
return (error);
}
mutex_exit(&ph->p_mutex);
mutex_exit(&uhcip->uhci_int_mutex);
}
/* Create the HCD pipe private structure */
pp = kmem_zalloc(sizeof (uhci_pipe_private_t),
(flags & USB_FLAGS_SLEEP) ? KM_SLEEP : KM_NOSLEEP);
if (pp == NULL) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: pp allocation failure");
if (UHCI_PERIODIC_ENDPOINT(&ph->p_ep)) {
mutex_enter(&uhcip->uhci_int_mutex);
uhci_deallocate_bandwidth(uhcip, ph);
mutex_exit(&uhcip->uhci_int_mutex);
}
sema_v(&uhcip->uhci_ocsem);
return (USB_NO_RESOURCES);
}
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
if (rval != USB_SUCCESS) {
kmem_free(ph, sizeof (uhci_pipe_private_t));
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
return (rval);
}
pp->pp_node = node; /* Store the node in the interrupt lattice */
/* Initialize frame number */
pp->pp_frame_num = INVALID_FRNUM;
/* Set the state of pipe as IDLE */
pp->pp_state = UHCI_PIPE_STATE_IDLE;
/* Store a pointer to the pipe handle */
pp->pp_pipe_handle = ph;
/* Store the pointer in the pipe handle */
mutex_enter(&ph->p_mutex);
ph->p_hcd_private = (usb_opaque_t)pp;
/* Store a copy of the pipe policy */
bcopy(&ph->p_policy, &pp->pp_policy, sizeof (usb_pipe_policy_t));
mutex_exit(&ph->p_mutex);
/* don't check for ROOT_HUB here anymore */
if (UHCI_XFER_TYPE(&ph->p_ep) != USB_EP_ATTR_ISOCH) {
/* Allocate the host controller endpoint descriptor */
pp->pp_qh = uhci_alloc_queue_head(uhcip);
if (pp->pp_qh == NULL) {
USB_DPRINTF_L2(PRINT_MASK_LISTS, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: QH allocation failed");
if (UHCI_PERIODIC_ENDPOINT(&ph->p_ep)) {
uhci_deallocate_bandwidth(uhcip, ph);
}
mutex_enter(&ph->p_mutex);
/*
* Deallocate the hcd private portion
* of the pipe handle.
*/
kmem_free(ph->p_hcd_private,
sizeof (uhci_pipe_private_t));
/*
* Set the private structure in the
* pipe handle equal to NULL.
*/
ph->p_hcd_private = NULL;
mutex_exit(&ph->p_mutex);
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
return (USB_NO_RESOURCES);
}
/*
* Insert the endpoint onto the host controller's
* appropriate endpoint list. The host controller
* will not schedule this endpoint until there are
* any TD's to process.
*/
uhci_insert_qh(uhcip, ph);
}
/*
* Restore the data toggle from usb device structure.
*/
if (((ph->p_ep.bmAttributes) & USB_EP_ATTR_MASK) == USB_EP_ATTR_INTR ||
((ph->p_ep.bmAttributes) & USB_EP_ATTR_MASK) == USB_EP_ATTR_BULK) {
mutex_enter(&ph->p_mutex);
pp->pp_data_toggle = usba_hcdi_get_data_toggle(
ph->p_usba_device, ph->p_ep.bEndpointAddress);
mutex_exit(&ph->p_mutex);
}
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_open: ph = 0x%p", (void *)ph);
return (USB_SUCCESS);
}
/*
* uhci_hcdi_pipe_close:
* Member of HCD Ops structure and called during the client specific pipe
* close. Remove the pipe to the data structure representing the device
* deallocate bandwidth for the pipe if it is an intr or isoch endpoint.
*/
int
uhci_hcdi_pipe_close(usba_pipe_handle_data_t *ph, usb_flags_t usb_flags)
{
usb_addr_t usb_addr;
uhci_state_t *uhcip;
usb_ep_descr_t *eptd = &ph->p_ep;
uhci_pipe_private_t *pp;
uhcip = uhci_obtain_state(ph->p_usba_device->usb_root_hub_dip);
pp = (uhci_pipe_private_t *)ph->p_hcd_private;
usb_addr = ph->p_usba_device->usb_addr;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_close: addr = 0x%x, ep%d, flags = 0x%x", usb_addr,
eptd->bEndpointAddress, usb_flags);
sema_p(&uhcip->uhci_ocsem);
mutex_enter(&uhcip->uhci_int_mutex);
/*
* Check whether the pipe is a root hub
*/
if (usb_addr == ROOT_HUB_ADDR) {
switch (UHCI_XFER_TYPE(eptd)) {
case USB_EP_ATTR_CONTROL:
USB_DPRINTF_L3(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_close: Root hub control pipe "
"close succeeded");
break;
case USB_EP_ATTR_INTR:
ASSERT((eptd->bEndpointAddress &
USB_EP_NUM_MASK) == 1);
/* Do interrupt pipe cleanup */
uhci_root_hub_intr_pipe_cleanup(uhcip,
USB_CR_PIPE_CLOSING);
ASSERT(uhcip->uhci_root_hub.rh_pipe_state ==
UHCI_PIPE_STATE_IDLE);
uhcip->uhci_root_hub.rh_intr_pipe_handle = NULL;
USB_DPRINTF_L3(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_close: Root hub interrupt "
"pipe close succeeded");
uhcip->uhci_root_hub.rh_pipe_state =
UHCI_PIPE_STATE_IDLE;
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
return (USB_SUCCESS);
}
} else {
/*
* Stop all the transactions if it is not the root hub.
*/
if (UHCI_XFER_TYPE(eptd) == USB_EP_ATTR_INTR) {
/*
* Stop polling on the pipe to prevent any subsequently
* queued tds (while we're waiting for SOF, below)
* from being executed
*/
pp->pp_state = UHCI_PIPE_STATE_IDLE;
}
/* Disable all outstanding tds */
uhci_modify_td_active_bits(uhcip, pp);
/* Prevent this queue from being executed */
if (UHCI_XFER_TYPE(eptd) != USB_EP_ATTR_ISOCH) {
UHCI_SET_TERMINATE_BIT(pp->pp_qh->element_ptr);
}
/* Wait for the next start of frame */
(void) uhci_wait_for_sof(uhcip);
ASSERT(eptd != NULL);
switch (UHCI_XFER_TYPE(eptd)) {
case USB_EP_ATTR_INTR:
uhci_update_intr_td_data_toggle(uhcip, pp);
/* FALLTHROUGH */
case USB_EP_ATTR_CONTROL:
uhci_remove_tds_tws(uhcip, ph);
break;
case USB_EP_ATTR_BULK:
SetQH32(uhcip, pp->pp_qh->element_ptr,
TD_PADDR(pp->pp_qh->td_tailp));
uhci_remove_bulk_tds_tws(uhcip, pp, UHCI_IN_CLOSE);
uhci_save_data_toggle(pp);
break;
case USB_EP_ATTR_ISOCH:
uhci_remove_isoc_tds_tws(uhcip, pp);
break;
default:
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_close: Unknown xfer type");
break;
}
/*
* Remove the endoint descriptor from Host Controller's
* appropriate endpoint list. Isochronous pipes dont have
* any queue heads attached to it.
*/
if (UHCI_XFER_TYPE(eptd) != USB_EP_ATTR_ISOCH) {
uhci_remove_qh(uhcip, pp);
}
/*
* Do the callback for the original client
* periodic IN request.
*/
if (pp->pp_client_periodic_in_reqp) {
uhci_hcdi_callback(uhcip, pp, ph, NULL,
USB_CR_PIPE_CLOSING);
}
/* Deallocate bandwidth */
if (UHCI_PERIODIC_ENDPOINT(eptd)) {
mutex_enter(&ph->p_mutex);
uhci_deallocate_bandwidth(uhcip, ph);
mutex_exit(&ph->p_mutex);
}
}
/* Deallocate the hcd private portion of the pipe handle. */
mutex_enter(&ph->p_mutex);
kmem_free(ph->p_hcd_private, sizeof (uhci_pipe_private_t));
ph->p_hcd_private = NULL;
mutex_exit(&ph->p_mutex);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_close: ph = 0x%p", (void *)ph);
mutex_exit(&uhcip->uhci_int_mutex);
sema_v(&uhcip->uhci_ocsem);
return (USB_SUCCESS);
}
/*
* uhci_hcdi_pipe_reset:
*/
int
uhci_hcdi_pipe_reset(usba_pipe_handle_data_t *ph, usb_flags_t usb_flags)
{
uhci_state_t *uhcip = uhci_obtain_state(
ph->p_usba_device->usb_root_hub_dip);
uhci_pipe_private_t *pp = (uhci_pipe_private_t *)ph->p_hcd_private;
usb_ep_descr_t *eptd = &ph->p_ep;
usb_port_t port;
uint_t port_status = 0;
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset: usb_flags = 0x%x", usb_flags);
/*
* Under some circumstances, uhci internal hub's port
* may become disabled because of some errors(see UHCI HCD Spec)
* to make the UHCI driver robust enough, we should try to
* re-enable it again here because HCD has already know something
* bad happened.
*/
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset: try "
"to enable disabled ports if necessary.");
for (port = 0; port < uhcip->uhci_root_hub.rh_num_ports; port++) {
port_status = Get_OpReg16(PORTSC[port]);
if ((!(port_status & HCR_PORT_ENABLE)) &&
(port_status & HCR_PORT_CCS) &&
(!(port_status & HCR_PORT_CSC))) {
Set_OpReg16(PORTSC[port],
(port_status | HCR_PORT_ENABLE));
drv_usecwait(UHCI_ONE_MS * 2);
}
}
/*
* Return failure immediately for any other pipe reset on the root
* hub except control or interrupt pipe.
*/
if (ph->p_usba_device->usb_addr == ROOT_HUB_ADDR) {
switch (UHCI_XFER_TYPE(&ph->p_ep)) {
case USB_EP_ATTR_CONTROL:
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset: Pipe reset for root"
"hub control pipe successful");
break;
case USB_EP_ATTR_INTR:
mutex_enter(&uhcip->uhci_int_mutex);
uhcip->uhci_root_hub.rh_pipe_state =
UHCI_PIPE_STATE_IDLE;
/* Do interrupt pipe cleanup */
uhci_root_hub_intr_pipe_cleanup(uhcip,
USB_CR_PIPE_RESET);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset: Pipe reset for "
"root hub interrupt pipe successful");
mutex_exit(&uhcip->uhci_int_mutex);
break;
default:
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset: Root hub pipe reset failed");
return (USB_FAILURE);
}
return (USB_SUCCESS);
}
mutex_enter(&uhcip->uhci_int_mutex);
/*
* Set the active bit in to INACTIVE for all the remaining TD's of
* this end point. Set the active bit for the dummy td. This will
* generate an interrupt at the end of the frame. After receiving
* the interrupt, it is safe to to manipulate the lattice.
*/
uhci_modify_td_active_bits(uhcip, pp);
/* Initialize the element pointer */
if (UHCI_XFER_TYPE(eptd) != USB_EP_ATTR_ISOCH) {
UHCI_SET_TERMINATE_BIT(pp->pp_qh->element_ptr);
SetQH32(uhcip, pp->pp_qh->element_ptr,
TD_PADDR(pp->pp_qh->td_tailp));
}
(void) uhci_wait_for_sof(uhcip);
/*
* Save the data toggle and clear the pipe.
*/
switch (UHCI_XFER_TYPE(eptd)) {
case USB_EP_ATTR_CONTROL:
case USB_EP_ATTR_INTR:
uhci_remove_tds_tws(uhcip, ph);
break;
case USB_EP_ATTR_BULK:
SetQH32(uhcip, pp->pp_qh->element_ptr,
TD_PADDR(pp->pp_qh->td_tailp));
uhci_remove_bulk_tds_tws(uhcip, pp, UHCI_IN_RESET);
break;
case USB_EP_ATTR_ISOCH:
uhci_remove_isoc_tds_tws(uhcip, pp);
break;
default:
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset: Unknown xfer type");
break;
}
/*
* Do the callback for the original client
* periodic IN request.
*/
if (pp->pp_client_periodic_in_reqp) {
uhci_hcdi_callback(uhcip, pp, ph, NULL, USB_CR_PIPE_RESET);
}
/*
* Since the endpoint is stripped of Transfer Descriptors (TD),
* reset the state of the periodic pipe to IDLE.
*/
pp->pp_state = UHCI_PIPE_STATE_IDLE;
mutex_exit(&uhcip->uhci_int_mutex);
return (USB_SUCCESS);
}
/*
* uhci_hcdi_pipe_reset_data_toggle:
*/
void
uhci_hcdi_pipe_reset_data_toggle(
usba_pipe_handle_data_t *ph)
{
uhci_state_t *uhcip = uhci_obtain_state(
ph->p_usba_device->usb_root_hub_dip);
uhci_pipe_private_t *pp = (uhci_pipe_private_t *)ph->p_hcd_private;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_reset_data_toggle:");
mutex_enter(&uhcip->uhci_int_mutex);
mutex_enter(&ph->p_mutex);
pp->pp_data_toggle = 0;
usba_hcdi_set_data_toggle(ph->p_usba_device, ph->p_ep.bEndpointAddress,
pp->pp_data_toggle);
mutex_exit(&ph->p_mutex);
mutex_exit(&uhcip->uhci_int_mutex);
}
/*
* uhci_hcdi_pipe_ctrl_xfer:
*/
int
uhci_hcdi_pipe_ctrl_xfer(
usba_pipe_handle_data_t *ph,
usb_ctrl_req_t *ctrl_reqp,
usb_flags_t flags)
{
uhci_state_t *uhcip = uhci_obtain_state(
ph->p_usba_device->usb_root_hub_dip);
uhci_pipe_private_t *pp = (uhci_pipe_private_t *)ph->p_hcd_private;
int error;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_ctrl_xfer: req=0x%p, ph=0x%p, flags=0x%x",
(void *)ctrl_reqp, (void *)ph, flags);
mutex_enter(&uhcip->uhci_int_mutex);
error = uhci_state_is_operational(uhcip);
if (error != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
ASSERT(pp->pp_state == UHCI_PIPE_STATE_IDLE);
/*
* Check and handle root hub control request.
*/
if (ph->p_usba_device->usb_addr == ROOT_HUB_ADDR) {
error = uhci_handle_root_hub_request(uhcip, ph, ctrl_reqp);
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/* Insert the td's on the endpoint */
if ((error = uhci_insert_ctrl_td(uhcip, ph, ctrl_reqp, flags)) !=
USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_ctrl_xfer: No resources");
}
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/*
* uhci_hcdi_pipe_bulk_xfer:
*/
int
uhci_hcdi_pipe_bulk_xfer(usba_pipe_handle_data_t *pipe_handle,
usb_bulk_req_t *bulk_reqp, usb_flags_t usb_flags)
{
int error;
uhci_state_t *uhcip;
uhcip = uhci_obtain_state(pipe_handle->p_usba_device->usb_root_hub_dip);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_bulk_xfer: Flags = 0x%x", usb_flags);
/* Check the size of bulk request */
if (bulk_reqp->bulk_len > UHCI_BULK_MAX_XFER_SIZE) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_bulk_xfer: req size 0x%x is more than 0x%x",
bulk_reqp->bulk_len, UHCI_BULK_MAX_XFER_SIZE);
return (USB_FAILURE);
}
mutex_enter(&uhcip->uhci_int_mutex);
error = uhci_state_is_operational(uhcip);
if (error != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/* Add the TD into the Host Controller's bulk list */
if ((error = uhci_insert_bulk_td(uhcip, pipe_handle, bulk_reqp,
usb_flags)) != USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_bulk_xfer: uhci_insert_bulk_td failed");
}
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/*
* uhci_hcdi_bulk_transfer_size:
* Return maximum bulk transfer size
*/
int
uhci_hcdi_bulk_transfer_size(
usba_device_t *usba_device,
size_t *size)
{
uhci_state_t *uhcip = uhci_obtain_state(
usba_device->usb_root_hub_dip);
int rval;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_bulk_transfer_size:");
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
if (rval != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
*size = uhci_bulk_transfer_size;
mutex_exit(&uhcip->uhci_int_mutex);
return (USB_SUCCESS);
}
/*
* uhci_hcdi_pipe_intr_xfer:
*/
int
uhci_hcdi_pipe_intr_xfer(
usba_pipe_handle_data_t *ph,
usb_intr_req_t *req,
usb_flags_t flags)
{
uhci_state_t *uhcip = uhci_obtain_state(
ph->p_usba_device->usb_root_hub_dip);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_intr_xfer: req=0x%p, uf=0x%x", (void *)req, flags);
if (UHCI_XFER_DIR(&ph->p_ep) == USB_EP_DIR_IN) {
return (uhci_start_periodic_pipe_polling(uhcip, ph,
(usb_opaque_t)req, flags));
} else {
return (uhci_send_intr_data(uhcip, ph, req, flags));
}
}
/*
* uhci_send_intr_data():
* send data to interrupt out pipe
*/
static int
uhci_send_intr_data(
uhci_state_t *uhcip,
usba_pipe_handle_data_t *pipe_handle,
usb_intr_req_t *req,
usb_flags_t flags)
{
int rval;
USB_DPRINTF_L4(PRINT_MASK_LISTS, uhcip->uhci_log_hdl,
"uhci_send_intr_data:");
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
if (rval != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
/* Add the TD into the Host Controller's interrupt list */
if ((rval = uhci_insert_intr_td(uhcip, pipe_handle, req, flags)) !=
USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_send_intr_data: No resources");
}
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
/*
* uhci_hcdi_pipe_stop_intr_polling()
*/
int
uhci_hcdi_pipe_stop_intr_polling(
usba_pipe_handle_data_t *pipe_handle,
usb_flags_t flags)
{
uhci_state_t *uhcip =
uhci_obtain_state(pipe_handle->p_usba_device->usb_root_hub_dip);
int rval;
USB_DPRINTF_L4(PRINT_MASK_LISTS, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_stop_intr_polling: ph = 0x%p fl = 0x%x",
(void *)pipe_handle, flags);
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_stop_periodic_pipe_polling(uhcip, pipe_handle, flags);
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
/*
* uhci_hcdi_get_current_frame_number
* Get the current frame number.
* Return whether the request is handled successfully.
*/
int
uhci_hcdi_get_current_frame_number(
usba_device_t *usba_device,
usb_frame_number_t *frame_number)
{
uhci_state_t *uhcip = uhci_obtain_state(usba_device->usb_root_hub_dip);
int rval;
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
if (rval != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
*frame_number = uhci_get_sw_frame_number(uhcip);
mutex_exit(&uhcip->uhci_int_mutex);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_get_current_frame_number: %llx",
(unsigned long long)(*frame_number));
return (rval);
}
/*
* uhci_hcdi_get_max_isoc_pkts
* Get the maximum number of isoc packets per USB Isoch request.
* Return whether the request is handled successfully.
*/
int
uhci_hcdi_get_max_isoc_pkts(
usba_device_t *usba_device,
uint_t *max_isoc_pkts_per_request)
{
uhci_state_t *uhcip = uhci_obtain_state(usba_device->usb_root_hub_dip);
int rval;
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
if (rval != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
*max_isoc_pkts_per_request = UHCI_MAX_ISOC_PKTS;
mutex_exit(&uhcip->uhci_int_mutex);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_get_max_isoc_pkts: 0x%x", UHCI_MAX_ISOC_PKTS);
return (rval);
}
/*
* uhci_hcdi_pipe_isoc_xfer:
*/
int
uhci_hcdi_pipe_isoc_xfer(
usba_pipe_handle_data_t *ph,
usb_isoc_req_t *isoc_reqp,
usb_flags_t flags)
{
uhci_state_t *uhcip;
uhcip = uhci_obtain_state(ph->p_usba_device->usb_root_hub_dip);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_isoc_xfer: req=0x%p, uf=0x%x",
(void *)isoc_reqp, flags);
if (UHCI_XFER_DIR(&ph->p_ep) == USB_EP_DIR_IN) {
return (uhci_start_periodic_pipe_polling(uhcip, ph,
(usb_opaque_t)isoc_reqp, flags));
} else {
return (uhci_pipe_send_isoc_data(uhcip, ph, isoc_reqp, flags));
}
}
/*
* uhci_hcdi_pipe_stop_isoc_polling()
*/
int
uhci_hcdi_pipe_stop_isoc_polling(
usba_pipe_handle_data_t *ph,
usb_flags_t flags)
{
uhci_state_t *uhcip =
uhci_obtain_state(ph->p_usba_device->usb_root_hub_dip);
int rval;
USB_DPRINTF_L4(PRINT_MASK_LISTS, uhcip->uhci_log_hdl,
"uhci_hcdi_pipe_stop_isoc_polling: ph = 0x%p fl = 0x%x",
(void *)ph, flags);
mutex_enter(&uhcip->uhci_int_mutex);
rval = uhci_state_is_operational(uhcip);
if (rval != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
rval = uhci_stop_periodic_pipe_polling(uhcip, ph, flags);
mutex_exit(&uhcip->uhci_int_mutex);
return (rval);
}
/*
* uhci_start_periodic_pipe_polling:
*/
static int
uhci_start_periodic_pipe_polling(
uhci_state_t *uhcip,
usba_pipe_handle_data_t *ph,
usb_opaque_t in_reqp,
usb_flags_t flags)
{
int n, num_tds;
int error;
usb_intr_req_t *intr_reqp = (usb_intr_req_t *)in_reqp;
usb_ep_descr_t *eptd = &ph->p_ep;
uhci_pipe_private_t *pp = (uhci_pipe_private_t *)ph->p_hcd_private;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_start_periodic_pipe_polling: flags: 0x%x, ep%d",
flags, eptd->bEndpointAddress);
mutex_enter(&uhcip->uhci_int_mutex);
error = uhci_state_is_operational(uhcip);
if (error != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
if (ph->p_usba_device->usb_addr == ROOT_HUB_ADDR) {
uint_t pipe_state = uhcip->uhci_root_hub.rh_pipe_state;
ASSERT(pipe_state == UHCI_PIPE_STATE_IDLE);
ASSERT(UHCI_XFER_DIR(eptd) == USB_EP_DIR_IN);
/* ONE_XFER not supported */
ASSERT((intr_reqp->intr_attributes &
USB_ATTRS_ONE_XFER) == 0);
ASSERT(uhcip->uhci_root_hub.rh_client_intr_req == NULL);
uhcip->uhci_root_hub.rh_client_intr_req = intr_reqp;
if ((error = uhci_root_hub_allocate_intr_pipe_resource(
uhcip, flags)) != USB_SUCCESS) {
/* reset the client interrupt request pointer */
uhcip->uhci_root_hub.rh_client_intr_req = NULL;
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
uhcip->uhci_root_hub.rh_pipe_state = USB_PIPE_STATE_ACTIVE;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_start_periodic_pipe_polling: "
"Start intr polling for root hub successful");
/* check if we need to send the reset data up? */
if (uhcip->uhci_root_hub.rh_status) {
uhci_root_hub_reset_occurred(uhcip,
uhcip->uhci_root_hub.rh_status - 1);
uhcip->uhci_root_hub.rh_status = 0;
}
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/* save the original client's periodic IN request */
pp->pp_client_periodic_in_reqp = in_reqp;
ASSERT(pp->pp_state != UHCI_PIPE_STATE_ACTIVE);
/*
*
* This pipe is uninitialized. If it is an isoc
* receive request, insert four times the same
* request so that we do not lose any frames.
*/
if (UHCI_XFER_TYPE(eptd) == USB_EP_ATTR_ISOCH) {
for (n = 0; n < 5; n++) {
if ((error = uhci_start_isoc_receive_polling(
uhcip, ph, NULL, flags)) != USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_INTR,
uhcip->uhci_log_hdl,
"uhci_start_periodic_pipe_polling: "
"Start isoc polling failed %d", n);
pp->pp_client_periodic_in_reqp = NULL;
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
}
}
if (UHCI_XFER_TYPE(eptd) == USB_EP_ATTR_INTR) {
if ((pp->pp_node < POLLING_FREQ_7MS) &&
(!(intr_reqp->intr_attributes & USB_ATTRS_ONE_XFER))) {
num_tds = 5;
} else {
num_tds = 1;
}
/*
* This pipe is uninitialized.
* Insert a TD on the interrupt ED.
*/
for (n = 0; n < num_tds; n++) {
if ((error = uhci_insert_intr_td(uhcip, ph, NULL,
flags)) != USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_INTR,
uhcip->uhci_log_hdl,
"uhci_start_periodic_pipe_polling: "
"Start polling failed");
pp->pp_client_periodic_in_reqp = NULL;
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
}
}
pp->pp_state = UHCI_PIPE_STATE_ACTIVE;
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/*
* uhci_hcdi_periodic_pipe_stop_polling:
*/
static int
uhci_stop_periodic_pipe_polling(uhci_state_t *uhcip,
usba_pipe_handle_data_t *ph, usb_flags_t flags)
{
uhci_pipe_private_t *pp = (uhci_pipe_private_t *)ph->p_hcd_private;
usb_ep_descr_t *eptd = &ph->p_ep;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_stop_periodic_pipe_polling: flags = 0x%x", flags);
ASSERT(mutex_owned(&uhcip->uhci_int_mutex));
if (ph->p_usba_device->usb_addr == ROOT_HUB_ADDR) {
ASSERT(UHCI_XFER_DIR(eptd) == USB_EP_DIR_IN);
if (uhcip->uhci_root_hub.rh_pipe_state ==
UHCI_PIPE_STATE_ACTIVE) {
uhcip->uhci_root_hub.rh_pipe_state =
UHCI_PIPE_STATE_IDLE;
/* Do interrupt pipe cleanup */
uhci_root_hub_intr_pipe_cleanup(uhcip,
USB_CR_STOPPED_POLLING);
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_stop_periodic_pipe_polling: Stop intr "
"polling for root hub successful");
} else {
USB_DPRINTF_L2(PRINT_MASK_INTR, uhcip->uhci_log_hdl,
"uhci_stop_periodic_pipe_polling: "
"Intr polling for root hub is already stopped");
}
return (USB_SUCCESS);
}
if (pp->pp_state != UHCI_PIPE_STATE_ACTIVE) {
USB_DPRINTF_L2(PRINT_MASK_INTR, uhcip->uhci_log_hdl,
"uhci_stop_periodic_pipe_polling: Polling already stopped");
return (USB_SUCCESS);
}
/*
* Set the terminate bits in all the tds in the queue and
* in the element_ptr.
* Do not deallocate the bandwidth or tear down the DMA
*/
uhci_modify_td_active_bits(uhcip, pp);
(void) uhci_wait_for_sof(uhcip);
if (UHCI_XFER_TYPE(eptd) == USB_EP_ATTR_ISOCH) {
uhci_remove_isoc_tds_tws(uhcip, pp);
pp->pp_state = UHCI_PIPE_STATE_IDLE;
} else {
UHCI_SET_TERMINATE_BIT(pp->pp_qh->element_ptr);
uhci_update_intr_td_data_toggle(uhcip, pp);
SetQH32(uhcip, pp->pp_qh->element_ptr,
TD_PADDR(pp->pp_qh->td_tailp));
uhci_remove_tds_tws(uhcip, ph);
}
pp->pp_state = UHCI_PIPE_STATE_IDLE;
if (pp->pp_client_periodic_in_reqp) {
uhci_hcdi_callback(uhcip, pp, ph, NULL, USB_CR_STOPPED_POLLING);
}
return (USB_SUCCESS);
}
/*
* uhci_hcdi_pipe_send_isoc_data:
* Handles the isoc write request.
*/
static int
uhci_pipe_send_isoc_data(
uhci_state_t *uhcip,
usba_pipe_handle_data_t *ph,
usb_isoc_req_t *isoc_req,
usb_flags_t usb_flags)
{
int error;
size_t max_isoc_xfer_sz, length;
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_pipe_send_isoc_data: isoc_req = %p flags = %x",
(void *)isoc_req, usb_flags);
ASSERT(isoc_req->isoc_pkts_count < UHCI_MAX_ISOC_PKTS);
/* Calculate the maximum isochronous transfer size */
max_isoc_xfer_sz = UHCI_MAX_ISOC_PKTS * ph->p_ep.wMaxPacketSize;
/* Check the size of isochronous request */
ASSERT(isoc_req->isoc_data != NULL);
length = MBLKL(isoc_req->isoc_data);
if (length > max_isoc_xfer_sz) {
USB_DPRINTF_L2(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_pipe_send_isoc_data: Maximum isoc request size %lx "
"Given isoc request size %lx", max_isoc_xfer_sz, length);
return (USB_INVALID_REQUEST);
}
/*
* Check whether we can insert these tds?
* At any point of time, we can insert maximum of 1024 isoc td's,
* size of frame list table.
*/
if (isoc_req->isoc_pkts_count > UHCI_MAX_ISOC_PKTS) {
USB_DPRINTF_L2(PRINT_MASK_ISOC, uhcip->uhci_log_hdl,
"uhci_pipe_send_isoc_data: request too big");
return (USB_INVALID_REQUEST);
}
/* Add the TD into the Host Controller's isoc list */
mutex_enter(&uhcip->uhci_int_mutex);
error = uhci_state_is_operational(uhcip);
if (error != USB_SUCCESS) {
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
if ((error = uhci_insert_isoc_td(uhcip, ph, isoc_req,
length, usb_flags)) != USB_SUCCESS) {
USB_DPRINTF_L2(PRINT_MASK_ISOC, uhcip->uhci_log_hdl,
"uhci_pipe_send_isoc_data: Unable to insert the isoc_req,"
"Error = %d", error);
}
mutex_exit(&uhcip->uhci_int_mutex);
return (error);
}
/*
* uhci_update_intr_td_data_toggle
* Update the data toggle and save in the usba_device structure
*/
static void
uhci_update_intr_td_data_toggle(uhci_state_t *uhcip, uhci_pipe_private_t *pp)
{
uint32_t paddr_tail, element_ptr;
uhci_td_t *next_td;
/* Find the next td that would have been executed */
element_ptr = GetQH32(uhcip, pp->pp_qh->element_ptr) &
QH_ELEMENT_PTR_MASK;
next_td = TD_VADDR(element_ptr);
paddr_tail = TD_PADDR(pp->pp_qh->td_tailp);
/*
* If element_ptr points to the dummy td, then the data toggle in
* pp_data_toggle is correct. Otherwise update the data toggle in
* the pipe private
*/
if (element_ptr != paddr_tail) {
pp->pp_data_toggle = GetTD_dtogg(uhcip, next_td);
}
USB_DPRINTF_L4(PRINT_MASK_HCDI, uhcip->uhci_log_hdl,
"uhci_update_intr_td_data_toggle: "
"pp %p toggle %x element ptr %x ptail %x",
(void *)pp, pp->pp_data_toggle, element_ptr, paddr_tail);
uhci_save_data_toggle(pp);
}
|