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
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* hci1394_s1394if.c
* The interface into the HAL from the services layer.
*/
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/modctl.h>
#include <sys/stat.h>
#include <sys/sunddi.h>
#include <sys/cmn_err.h>
#include <sys/1394/h1394.h>
#include <sys/1394/ixl1394.h>
#include <sys/1394/adapters/hci1394.h>
static void hci1394_s1394if_shutdown(void *hal_private);
static int hci1394_s1394if_phy(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result);
static int hci1394_s1394if_write(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result);
static int hci1394_s1394if_read(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result);
static int hci1394_s1394if_lock(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result);
static int hci1394_s1394if_write_response(void *hal_private,
cmd1394_cmd_t *cmd_id, h1394_cmd_priv_t *cmd_private, int *result);
static int hci1394_s1394if_read_response(void *hal_private,
cmd1394_cmd_t *cmd_id, h1394_cmd_priv_t *cmd_private, int *result);
static int hci1394_s1394if_lock_response(void *hal_private,
cmd1394_cmd_t *cmd_id, h1394_cmd_priv_t *cmd_private, int *result);
static void hci1394_s1394if_response_complete(void *hal_private,
cmd1394_cmd_t *cmd_id, h1394_cmd_priv_t *cmd_private);
static int hci1394_s1394if_reset_bus(void *hal_private);
static int hci1394_s1394if_set_contender_bit(void *hal_private);
static int hci1394_s1394if_set_root_holdoff_bit(void *hal_private);
static int hci1394_s1394if_set_gap_count(void *hal_private, uint_t gap_count);
static int hci1394_s1394if_update_config_rom(void *hal_private,
void *local_buf, uint_t quadlet_count);
static int hci1394_s1394if_phy_filter_set(void *hal_private,
uint64_t mask, uint_t generation);
static int hci1394_s1394if_phy_filter_clr(void *hal_private,
uint64_t mask, uint_t generation);
static int hci1394_s1394if_short_bus_reset(void *hal_private);
static int hci1394_s1394if_csr_read(void *hal_private,
uint_t offset, uint32_t *data);
static int hci1394_s1394if_csr_write(void *hal_private,
uint_t offset, uint32_t data);
static int hci1394_s1394if_csr_cswap32(void *hal_private, uint_t generation,
uint_t offset, uint32_t compare, uint32_t swap, uint32_t *old);
static void hci1394_s1394if_power_state_change(void *hal_private,
h1394_node_pwr_flags_t nodeflags);
/* entry points into HAL from Services Layer */
h1394_evts_t hci1394_evts = {
H1394_EVTS_V1, /* hal_version */
0, /* reserved */
hci1394_s1394if_shutdown, /* shutdown */
hci1394_s1394if_phy, /* send_phy_config_pkt */
hci1394_s1394if_read, /* read */
hci1394_s1394if_read_response, /* read_response */
hci1394_s1394if_write, /* write */
hci1394_s1394if_write_response, /* write_response */
hci1394_s1394if_response_complete, /* response_complete */
hci1394_s1394if_lock, /* lock */
hci1394_s1394if_lock_response, /* lock_response */
hci1394_alloc_isoch_dma, /* allocate_isoch_dma */
hci1394_free_isoch_dma, /* free_isoch_dma */
hci1394_start_isoch_dma, /* start_isoch_dma */
hci1394_stop_isoch_dma, /* stop_isoch_dma */
hci1394_update_isoch_dma, /* update_isoch_dma */
hci1394_s1394if_update_config_rom, /* update_config_rom */
hci1394_s1394if_reset_bus, /* bus_reset */
hci1394_s1394if_short_bus_reset, /* short_bus_reset */
hci1394_s1394if_set_contender_bit, /* set_contender_bit */
hci1394_s1394if_set_root_holdoff_bit, /* set_root_holdoff_bit */
hci1394_s1394if_set_gap_count, /* set_gap_count */
hci1394_s1394if_csr_read, /* csr_read */
hci1394_s1394if_csr_write, /* csr_write */
hci1394_s1394if_csr_cswap32, /* csr_cswap32 */
hci1394_s1394if_phy_filter_set, /* phys_arreq_enable_set */
hci1394_s1394if_phy_filter_clr, /* phys_arreq_enable_clr */
hci1394_s1394if_power_state_change /* node_power_state_change */
};
/*
* hci1394_s1394if_shutdown()
* Shutdown the HAL. This is called when a critical error has been detected.
* This routine should shutdown the HAL so that it will no longer send or
* receive information to/from the 1394 bus. The purpose of this function is
* to try and keep the machine from crashing.
*/
static void
hci1394_s1394if_shutdown(void *hal_private)
{
hci1394_state_t *soft_state;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
hci1394_shutdown(soft_state->drvinfo.di_dip);
}
/*
* hci1394_s1394if_phy()
* write a phy packet out to the 1394 bus. A phy packet consists of one
* quadlet of data.
*/
static int
hci1394_s1394if_phy(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_phy(soft_state->async, cmd_id, cmd_private,
result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_write()
* Perform a 1394 write operation. This can be either a quadlet or block
* write.
*/
static int
hci1394_s1394if_write(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_write(soft_state->async, cmd_id, cmd_private,
result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_read()
* Perform a 1394 read operation. This can be either a quadlet or block
* read.
*/
static int
hci1394_s1394if_read(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_read(soft_state->async, cmd_id, cmd_private,
result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_lock()
* Perform a 1394/1212 lock operation. This can be one of the following lock
* operations: (CMD1394_LOCK_MASK_SWAP, CMD1394_LOCK_COMPARE_SWAP
* CMD1394_LOCK_FETCH_ADD, CMD1394_LOCK_LITTLE_ADD, CMD1394_LOCK_BOUNDED_ADD
* CMD1394_LOCK_WRAP_ADD)
*/
static int
hci1394_s1394if_lock(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_lock(soft_state->async, cmd_id, cmd_private,
result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_write_response()
* Send a response to a write request received off of the 1394 bus. This
* could have been with a quadlet or block write request.
*/
static int
hci1394_s1394if_write_response(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_write_response(soft_state->async, cmd_id,
cmd_private, result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_read_response()
* Send a response to a read request received off of the 1394 bus. This
* could have been with a quadlet or block read request.
*/
static int
hci1394_s1394if_read_response(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_read_response(soft_state->async, cmd_id,
cmd_private, result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_lock_response()
* Send a response to a lock request received off of the 1394 bus. This
* could have been one of the following lock operations:
* (CMD1394_LOCK_MASK_SWAP, CMD1394_LOCK_COMPARE_SWAP CMD1394_LOCK_FETCH_ADD,
* CMD1394_LOCK_LITTLE_ADD, CMD1394_LOCK_BOUNDED_ADD, CMD1394_LOCK_WRAP_ADD)
*/
static int
hci1394_s1394if_lock_response(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private, int *result)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not in a bus reset or shutdown */
if (hci1394_state(&soft_state->drvinfo) != HCI1394_NORMAL) {
if (hci1394_state(&soft_state->drvinfo) == HCI1394_BUS_RESET) {
*result = H1394_STATUS_INVALID_BUSGEN;
} else {
*result = H1394_STATUS_INTERNAL_ERROR;
}
return (DDI_FAILURE);
}
status = hci1394_async_lock_response(soft_state->async, cmd_id,
cmd_private, result);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_response_complete()
* This notifies the HAL that the services layer and target driver are done
* with a command that was received off of the 1394 bus. This will usually
* be called after the response to the command has been command_complete'd.
* The HAL is free to re-use the command or free up the memory from this
* command after this call has returned. This should only be called for
* ARREQ's.
*/
static void
hci1394_s1394if_response_complete(void *hal_private, cmd1394_cmd_t *cmd_id,
h1394_cmd_priv_t *cmd_private)
{
hci1394_state_t *soft_state;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
hci1394_async_response_complete(soft_state->async, cmd_id, cmd_private);
}
/*
* hci1394_s1394if_reset_bus()
* This routine resets the 1394 bus. It performs a "long" bus reset. It
* should work on all OpenHCI adapters.
*/
static int
hci1394_s1394if_reset_bus(void *hal_private)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
status = hci1394_ohci_bus_reset(soft_state->ohci);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_set_contender_bit()
* This routine sets up the PHY so that the selfid contender bit will be set
* on subsequent bus resets. This routine will fail when we have a 1394-1995
* PHY since this PHY does not have a SW controllable contender bit.
*/
static int
hci1394_s1394if_set_contender_bit(void *hal_private)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
if (soft_state->halinfo.phy == H1394_PHY_1995) {
return (DDI_FAILURE);
}
status = hci1394_ohci_contender_enable(soft_state->ohci);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_set_root_holdoff_bit()
* This routine will set the root holdoff bit in the PHY. The Services Layer
* should send out a PHY configuration packet first to tell everyone which
* node to set the root holdoff bit on. If it is our root holdoff bit we
* are setting, the PHY will automatically set it unless we have an old
* (1394-1995) PHY. If we have a 1394-1995 PHY, the SL needs to call this
* routine after sending the PHY configuration packet. The SL also needs to
* call this if they want to perform a long bus reset and have the root
* holdoff bit set. We do this so that we do not have to do a read before
* the write. A PHY register write has less of a chance of failing.
*/
static int
hci1394_s1394if_set_root_holdoff_bit(void *hal_private)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
status = hci1394_ohci_root_holdoff_enable(soft_state->ohci);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_set_gap_count()
* This routine will set the gap count bit in the PHY. The Services Layer
* should send out a PHY configuration packet first to tell everyone what
* gap count to use. Our PHY will automatically set the gap count unless we
* have an old (1394-1995) PHY. If we have a 1394-1995 PHY, the SL needs to
* call this routine after sending the PHY configuration packet and before
* generating a bus reset. The SL also needs to call before the they call to
* perform a long bus reset. We do this so that we do not have to do a PHY
* read before the write. A PHY register write has less of a chance of
* failing.
*/
static int
hci1394_s1394if_set_gap_count(void *hal_private, uint_t gap_count)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
status = hci1394_ohci_gap_count_set(soft_state->ohci, gap_count);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_phy_filter_set()
* reads/writes to physically mapped memory from devices on the bus are
* disabled by default. They can be enabled on a node by node basis. All
* physical accesses are disabled every bus reset so they must be re-enabled
* every bus reset (This is due to the fact the the node ids change every bus
* reset). A 64-bit mask is passed in to enable nodes to be able to rd/wr
* physically mapped memory over the 1394 bus. A bit = to 1 enables that
* node's physical accesses, a bit = to 0 does nothing (i.e. a bitwise or is
* performed). The LSB of the mask (bit 0), maps to node #0, bit #62, maps to
* node 62. The MSB (#63) is not used since the can only be 63 nodes
* (0 - 62) on the bus.
*
* hci1394_s1394if_phy_filter_clr() is used to disable access to physical
* memory. This is only required if the node had previously been enabled.
*
* generation is used to verify that we are have not gotten a bus reset since
* the mask was built.
*/
static int
hci1394_s1394if_phy_filter_set(void *hal_private,
uint64_t mask, uint_t generation)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
status = hci1394_ohci_phy_filter_set(soft_state->ohci, mask,
generation);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_phy_filter_clr()
* reads/writes to physically mapped memory from devices on the bus are
* disabled by default. They can be enabled/disabled on a node by node basis.
* All physical accesses are disabled every bus reset so they must be
* re-enabled every bus reset (This is due to the fact the the node ids
* change every bus reset). Only nodes which have been enabled and no longer
* need access to physical memory need to be disabled.
*
* A 64-bit mask is passed in to disable nodes from being able to rd/wr
* physically mapped memory over the 1394 bus. A bit = to 1 disables that
* node's physical accesses, a bit = to 0 does nothing (i.e. a bitwise or is
* performed). The LSB of the mask (bit 0), maps to node #0, bit #62, maps to
* node 62. The MSB (#63) is not used since there can only be 63 nodes
* (0 - 62) on the bus.
*
* hci1394_s1394if_phy_filter_set() is used to enable access to physical
* memory.
*
* generation is used to verify that we are have not gotten a bus reset since
* the mask was build.
*/
static int
hci1394_s1394if_phy_filter_clr(void *hal_private,
uint64_t mask, uint_t generation)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
status = hci1394_ohci_phy_filter_clr(soft_state->ohci, mask,
generation);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_short_bus_reset()
* This routine resets the 1394 bus. It performs a "short" bus reset. It
* will only work on adapters with a 1394A or later PHY. Calling this routine
* when we have a 1394-1995 PHY is an error.
*/
static int
hci1394_s1394if_short_bus_reset(void *hal_private)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
if (soft_state->halinfo.phy == H1394_PHY_1995) {
return (DDI_FAILURE);
}
status = hci1394_ohci_bus_reset_short(soft_state->ohci);
if (status != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_update_config_rom()
* This routine updates the configuration ROM. It copies "quadlet_count"
* 32-bit words from "local_buf" to the config ROM starting at the first
* location in config ROM. This routine is meant to update the entire config
* ROM and not meant for a partial update.
*/
static int
hci1394_s1394if_update_config_rom(void *hal_private,
void *local_buf, uint_t quadlet_count)
{
hci1394_state_t *soft_state;
ASSERT(hal_private != NULL);
ASSERT(local_buf != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
hci1394_ohci_cfgrom_update(soft_state->ohci, local_buf, quadlet_count);
return (DDI_SUCCESS);
}
/*
* hci1394_s1394if_csr_read()
* CSR register read interface
* For more information on CSR registers, see
* IEEE 1212
* IEEE 1394-1995
* section 8.3.2
* IEEE P1394A Draft 3.0
* sections 10.32,10.33
*/
static int
hci1394_s1394if_csr_read(void *hal_private, uint_t offset, uint32_t *data)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
ASSERT(data != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
switch (offset) {
case CSR_STATE_CLEAR:
hci1394_csr_state_get(soft_state->csr, data);
status = DDI_SUCCESS;
break;
case CSR_STATE_SET:
/* Write Only Register */
status = DDI_FAILURE;
break;
case CSR_NODE_IDS:
hci1394_ohci_nodeid_get(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_RESET_START:
/* Not supported */
status = DDI_FAILURE;
break;
case CSR_SPLIT_TIMEOUT_HI:
hci1394_csr_split_timeout_hi_get(soft_state->csr, data);
status = DDI_SUCCESS;
break;
case CSR_SPLIT_TIMEOUT_LO:
hci1394_csr_split_timeout_lo_get(soft_state->csr, data);
status = DDI_SUCCESS;
break;
case CSR_CYCLE_TIME:
/* CYCLE_TIME is implemented in HW */
hci1394_ohci_cycletime_get(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_BUS_TIME:
/* BUS_TIME is implemented in the hci1394_ohci_* SW */
hci1394_ohci_bustime_get(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_BUSY_TIMEOUT:
hci1394_ohci_atreq_retries_get(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_BUS_MANAGER_ID:
/* BUS_MANAGER_ID is implemented in HW */
status = hci1394_ohci_csr_read(soft_state->ohci, 0, data);
break;
case CSR_BANDWIDTH_AVAILABLE:
/* BANDWIDTH_AVAILABLE is implemented in HW */
status = hci1394_ohci_csr_read(soft_state->ohci, 1, data);
break;
case CSR_CHANNELS_AVAILABLE_HI:
/* CHANNELS_AVAILABLE_HI is implemented in HW */
status = hci1394_ohci_csr_read(soft_state->ohci, 2, data);
break;
case CSR_CHANNELS_AVAILABLE_LO:
/* CHANNELS_AVAILABLE_LO is implemented in HW */
status = hci1394_ohci_csr_read(soft_state->ohci, 3, data);
break;
default:
status = DDI_FAILURE;
break;
}
return (status);
}
/*
* hci1394_s1394if_csr_write()
* CSR register write interface
* For more information on CSR registers, see
* IEEE 1212
* IEEE 1394-1995
* section 8.3.2
* IEEE P1394A Draft 3.0
* sections 10.32,10.33
*/
static int
hci1394_s1394if_csr_write(void *hal_private, uint_t offset, uint32_t data)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
switch (offset) {
case CSR_STATE_CLEAR:
hci1394_csr_state_bclr(soft_state->csr, data);
status = DDI_SUCCESS;
break;
case CSR_STATE_SET:
hci1394_csr_state_bset(soft_state->csr, data);
status = DDI_SUCCESS;
break;
case CSR_NODE_IDS:
hci1394_ohci_nodeid_set(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_RESET_START:
/* Not supported */
status = DDI_FAILURE;
break;
/*
* there is a race condition when updating the split timeout
* due to the nature of the interface. (i.e. having a separate
* hi an lo register)
*/
case CSR_SPLIT_TIMEOUT_HI:
hci1394_csr_split_timeout_hi_set(soft_state->csr, data);
/*
* update the pending list timeout value. The split timeout
* is stored in 1394 bus cycles and the timeout is specified in
* nS. Therefore, we need to convert the split timeout into nS.
*/
hci1394_async_pending_timeout_update(soft_state->async,
OHCI_BUS_CYCLE_TO_nS(hci1394_csr_split_timeout_get(
soft_state->csr)));
status = DDI_SUCCESS;
break;
case CSR_SPLIT_TIMEOUT_LO:
hci1394_csr_split_timeout_lo_set(soft_state->csr, data);
/*
* update the pending list timeout value. The split timeout
* is stored in 1394 bus cycles and the timeout is specified in
* nS. Therefore, we need to convert the split timeout into nS.
*/
hci1394_async_pending_timeout_update(soft_state->async,
OHCI_BUS_CYCLE_TO_nS(hci1394_csr_split_timeout_get(
soft_state->csr)));
status = DDI_SUCCESS;
break;
case CSR_CYCLE_TIME:
hci1394_ohci_cycletime_set(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_BUS_TIME:
hci1394_ohci_bustime_set(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_BUSY_TIMEOUT:
hci1394_ohci_atreq_retries_set(soft_state->ohci, data);
status = DDI_SUCCESS;
break;
case CSR_BUS_MANAGER_ID:
/* Invalid access, only read/cswap32 allowed */
status = DDI_FAILURE;
break;
case CSR_BANDWIDTH_AVAILABLE:
/* Invalid access, only read/cswap32 allowed */
status = DDI_FAILURE;
break;
case CSR_CHANNELS_AVAILABLE_HI:
/* Invalid access, only read/cswap32 allowed */
status = DDI_FAILURE;
break;
case CSR_CHANNELS_AVAILABLE_LO:
/* Invalid access, only read/cswap32 allowed */
status = DDI_FAILURE;
break;
default:
status = DDI_FAILURE;
break;
}
return (status);
}
/*
* hci1394_s1394if_csr_cswap32()
* CSR register cswap32 interface
* For more information on CSR registers, see
* IEEE 1212
* IEEE 1394-1995
* section 8.3.2
* IEEE P1394A Draft 3.0
* sections 10.32,10.33
*/
static int
hci1394_s1394if_csr_cswap32(void *hal_private, uint_t generation, uint_t offset,
uint32_t compare, uint32_t swap, uint32_t *old)
{
hci1394_state_t *soft_state;
int status;
ASSERT(hal_private != NULL);
ASSERT(old != NULL);
soft_state = (hci1394_state_t *)hal_private;
/* make sure we are not shutdown */
if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN) {
return (DDI_FAILURE);
}
switch (offset) {
case CSR_STATE_CLEAR:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_STATE_SET:
/* Invalid access, only write allowed */
status = DDI_FAILURE;
break;
case CSR_NODE_IDS:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_RESET_START:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_SPLIT_TIMEOUT_HI:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_SPLIT_TIMEOUT_LO:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_CYCLE_TIME:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_BUS_TIME:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_BUSY_TIMEOUT:
/* Invalid access, only read/write allowed */
status = DDI_FAILURE;
break;
case CSR_BUS_MANAGER_ID:
/* BUS_MANAGER_ID is implemented in HW */
status = hci1394_ohci_csr_cswap(soft_state->ohci, generation,
OHCI_CSR_SEL_BUS_MGR_ID, compare, swap, old);
break;
case CSR_BANDWIDTH_AVAILABLE:
/* BANDWIDTH_AVAILABLE is implemented in HW */
status = hci1394_ohci_csr_cswap(soft_state->ohci, generation,
OHCI_CSR_SEL_BANDWIDTH_AVAIL, compare, swap, old);
break;
case CSR_CHANNELS_AVAILABLE_HI:
/* CHANNELS_AVAILABLE_HI is implemented in HW */
status = hci1394_ohci_csr_cswap(soft_state->ohci, generation,
OHCI_CSR_SEL_CHANS_AVAIL_HI, compare, swap, old);
break;
case CSR_CHANNELS_AVAILABLE_LO:
/* CHANNELS_AVAILABLE_LO is implemented in HW */
status = hci1394_ohci_csr_cswap(soft_state->ohci, generation,
OHCI_CSR_SEL_CHANS_AVAIL_LO, compare, swap, old);
break;
default:
status = DDI_FAILURE;
break;
}
return (status);
}
/*
* hci1394_s1394if_power_state_change()
* Signals that a change in the bus topology has taken place which may affect
* power management.
*/
/*ARGSUSED*/
static void
hci1394_s1394if_power_state_change(void *hal_private,
h1394_node_pwr_flags_t nodeflags)
{
/* not implemented */
}
|