aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/et131x/et1310_phy.h
blob: 080656c6142c18135f08788c19a2196360607b06 (plain) (blame)
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
/*
 * Agere Systems Inc.
 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
 *
 * Copyright © 2005 Agere Systems Inc.
 * All rights reserved.
 *   http://www.agere.com
 *
 *------------------------------------------------------------------------------
 *
 * et1310_phy.h - Defines, structs, enums, prototypes, etc. pertaining to the
 *                PHY.
 *
 *------------------------------------------------------------------------------
 *
 * SOFTWARE LICENSE
 *
 * This software is provided subject to the following terms and conditions,
 * which you should read carefully before using the software.  Using this
 * software indicates your acceptance of these terms and conditions.  If you do
 * not agree with these terms and conditions, do not use the software.
 *
 * Copyright © 2005 Agere Systems Inc.
 * All rights reserved.
 *
 * Redistribution and use in source or binary forms, with or without
 * modifications, are permitted provided that the following conditions are met:
 *
 * . Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following Disclaimer as comments in the code as
 *    well as in the documentation and/or other materials provided with the
 *    distribution.
 *
 * . Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following Disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * . Neither the name of Agere Systems Inc. nor the names of the contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * Disclaimer
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 */

#ifndef _ET1310_PHY_H_
#define _ET1310_PHY_H_

#include "et1310_address_map.h"

#define TRUEPHY_SUCCESS 0
#define TRUEPHY_FAILURE 1

/* MI Register Addresses */
#define MI_CONTROL_REG                      0
#define MI_STATUS_REG                       1
#define MI_PHY_IDENTIFIER_1_REG             2
#define MI_PHY_IDENTIFIER_2_REG             3
#define MI_AUTONEG_ADVERTISEMENT_REG        4
#define MI_AUTONEG_LINK_PARTNER_ABILITY_REG 5
#define MI_AUTONEG_EXPANSION_REG            6
#define MI_AUTONEG_NEXT_PAGE_TRANSMIT_REG   7
#define MI_LINK_PARTNER_NEXT_PAGE_REG       8
#define MI_1000BASET_CONTROL_REG            9
#define MI_1000BASET_STATUS_REG             10
#define MI_RESERVED11_REG                   11
#define MI_RESERVED12_REG                   12
#define MI_RESERVED13_REG                   13
#define MI_RESERVED14_REG                   14
#define MI_EXTENDED_STATUS_REG              15

/* VMI Register Addresses */
#define VMI_RESERVED16_REG                  16
#define VMI_RESERVED17_REG                  17
#define VMI_RESERVED18_REG                  18
#define VMI_LOOPBACK_CONTROL_REG            19
#define VMI_RESERVED20_REG                  20
#define VMI_MI_CONTROL_REG                  21
#define VMI_PHY_CONFIGURATION_REG           22
#define VMI_PHY_CONTROL_REG                 23
#define VMI_INTERRUPT_MASK_REG              24
#define VMI_INTERRUPT_STATUS_REG            25
#define VMI_PHY_STATUS_REG                  26
#define VMI_LED_CONTROL_1_REG               27
#define VMI_LED_CONTROL_2_REG               28
#define VMI_RESERVED29_REG                  29
#define VMI_RESERVED30_REG                  30
#define VMI_RESERVED31_REG                  31

/* PHY Register Mapping(MI) Management Interface Regs */
typedef struct _MI_REGS_t {
	u8 bmcr;	/* Basic mode control reg(Reg 0x00) */
	u8 bmsr;	/* Basic mode status reg(Reg 0x01) */
	u8 idr1;	/* Phy identifier reg 1(Reg 0x02) */
	u8 idr2;	/* Phy identifier reg 2(Reg 0x03) */
	u8 anar;	/* Auto-Negotiation advertisement(Reg 0x04) */
	u8 anlpar;	/* Auto-Negotiation link Partner Ability(Reg 0x05) */
	u8 aner;	/* Auto-Negotiation expansion reg(Reg 0x06) */
	u8 annptr;	/* Auto-Negotiation next page transmit reg(Reg 0x07) */
	u8 lpnpr;	/* link partner next page reg(Reg 0x08) */
	u8 gcr;		/* Gigabit basic mode control reg(Reg 0x09) */
	u8 gsr;		/* Gigabit basic mode status reg(Reg 0x0A) */
	u8 mi_res1[4];	/* Future use by MI working group(Reg 0x0B - 0x0E) */
	u8 esr;		/* Extended status reg(Reg 0x0F) */
	u8 mi_res2[3];	/* Future use by MI working group(Reg 0x10 - 0x12) */
	u8 loop_ctl;	/* Loopback Control Reg(Reg 0x13) */
	u8 mi_res3;	/* Future use by MI working group(Reg 0x14) */
	u8 mcr;		/* MI Control Reg(Reg 0x15) */
	u8 pcr;		/* Configuration Reg(Reg 0x16) */
	u8 phy_ctl;	/* PHY Control Reg(Reg 0x17) */
	u8 imr;		/* Interrupt Mask Reg(Reg 0x18) */
	u8 isr;		/* Interrupt Status Reg(Reg 0x19) */
	u8 psr;		/* PHY Status Reg(Reg 0x1A) */
	u8 lcr1;		/* LED Control 1 Reg(Reg 0x1B) */
	u8 lcr2;		/* LED Control 2 Reg(Reg 0x1C) */
	u8 mi_res4[3];	/* Future use by MI working group(Reg 0x1D - 0x1F) */
} MI_REGS_t, *PMI_REGS_t;

/* MI Register 0: Basic mode control register */
typedef union _MI_BMCR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 reset:1;		/* bit 15 */
		u16 loopback:1;		/* bit 14 */
		u16 speed_sel:1;		/* bit 13 */
		u16 enable_autoneg:1;	/* bit 12 */
		u16 power_down:1;		/* bit 11 */
		u16 isolate:1;		/* bit 10 */
		u16 restart_autoneg:1;	/* bit 9 */
		u16 duplex_mode:1;		/* bit 8 */
		u16 col_test:1;		/* bit 7 */
		u16 speed_1000_sel:1;	/* bit 6 */
		u16 res1:6;		/* bits 0-5 */
#else
		u16 res1:6;		/* bits 0-5 */
		u16 speed_1000_sel:1;	/* bit 6 */
		u16 col_test:1;		/* bit 7 */
		u16 duplex_mode:1;		/* bit 8 */
		u16 restart_autoneg:1;	/* bit 9 */
		u16 isolate:1;		/* bit 10 */
		u16 power_down:1;		/* bit 11 */
		u16 enable_autoneg:1;	/* bit 12 */
		u16 speed_sel:1;		/* bit 13 */
		u16 loopback:1;		/* bit 14 */
		u16 reset:1;		/* bit 15 */
#endif
	} bits;
} MI_BMCR_t, *PMI_BMCR_t;

/* MI Register 1:  Basic mode status register */
typedef union _MI_BMSR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 link_100T4:1;		/* bit 15 */
		u16 link_100fdx:1;		/* bit 14 */
		u16 link_100hdx:1;		/* bit 13 */
		u16 link_10fdx:1;		/* bit 12 */
		u16 link_10hdx:1;		/* bit 11 */
		u16 link_100T2fdx:1;	/* bit 10 */
		u16 link_100T2hdx:1;	/* bit 9 */
		u16 extend_status:1;	/* bit 8 */
		u16 res1:1;		/* bit 7 */
		u16 preamble_supress:1;	/* bit 6 */
		u16 auto_neg_complete:1;	/* bit 5 */
		u16 remote_fault:1;	/* bit 4 */
		u16 auto_neg_able:1;	/* bit 3 */
		u16 link_status:1;		/* bit 2 */
		u16 jabber_detect:1;	/* bit 1 */
		u16 ext_cap:1;		/* bit 0 */
#else
		u16 ext_cap:1;		/* bit 0 */
		u16 jabber_detect:1;	/* bit 1 */
		u16 link_status:1;		/* bit 2 */
		u16 auto_neg_able:1;	/* bit 3 */
		u16 remote_fault:1;	/* bit 4 */
		u16 auto_neg_complete:1;	/* bit 5 */
		u16 preamble_supress:1;	/* bit 6 */
		u16 res1:1;		/* bit 7 */
		u16 extend_status:1;	/* bit 8 */
		u16 link_100T2hdx:1;	/* bit 9 */
		u16 link_100T2fdx:1;	/* bit 10 */
		u16 link_10hdx:1;		/* bit 11 */
		u16 link_10fdx:1;		/* bit 12 */
		u16 link_100hdx:1;		/* bit 13 */
		u16 link_100fdx:1;		/* bit 14 */
		u16 link_100T4:1;		/* bit 15 */
#endif
	} bits;
} MI_BMSR_t, *PMI_BMSR_t;

/* MI Register 2: Physical Identifier 1 */
typedef union _MI_IDR1_t {
	u16 value;
	struct {
		u16 ieee_address:16;	/* 0x0282 default(bits 0-15) */
	} bits;
} MI_IDR1_t, *PMI_IDR1_t;

/* MI Register 3: Physical Identifier 2 */
typedef union _MI_IDR2_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 ieee_address:6;	/* 111100 default(bits 10-15) */
		u16 model_no:6;		/* 000001 default(bits 4-9) */
		u16 rev_no:4;		/* 0010   default(bits 0-3) */
#else
		u16 rev_no:4;		/* 0010   default(bits 0-3) */
		u16 model_no:6;		/* 000001 default(bits 4-9) */
		u16 ieee_address:6;	/* 111100 default(bits 10-15) */
#endif
	} bits;
} MI_IDR2_t, *PMI_IDR2_t;

/* MI Register 4: Auto-negotiation advertisement register */
typedef union _MI_ANAR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 np_indication:1;	/* bit 15 */
		u16 res2:1;		/* bit 14 */
		u16 remote_fault:1;	/* bit 13 */
		u16 res1:1;		/* bit 12 */
		u16 cap_asmpause:1;	/* bit 11 */
		u16 cap_pause:1;		/* bit 10 */
		u16 cap_100T4:1;		/* bit 9 */
		u16 cap_100fdx:1;		/* bit 8 */
		u16 cap_100hdx:1;		/* bit 7 */
		u16 cap_10fdx:1;		/* bit 6 */
		u16 cap_10hdx:1;		/* bit 5 */
		u16 selector:5;		/* bits 0-4 */
#else
		u16 selector:5;		/* bits 0-4 */
		u16 cap_10hdx:1;		/* bit 5 */
		u16 cap_10fdx:1;		/* bit 6 */
		u16 cap_100hdx:1;		/* bit 7 */
		u16 cap_100fdx:1;		/* bit 8 */
		u16 cap_100T4:1;		/* bit 9 */
		u16 cap_pause:1;		/* bit 10 */
		u16 cap_asmpause:1;	/* bit 11 */
		u16 res1:1;		/* bit 12 */
		u16 remote_fault:1;	/* bit 13 */
		u16 res2:1;		/* bit 14 */
		u16 np_indication:1;	/* bit 15 */
#endif
	} bits;
} MI_ANAR_t, *PMI_ANAR_t;

/* MI Register 5: Auto-negotiation link partner advertisement register */
typedef struct _MI_ANLPAR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 np_indication:1;	/* bit 15 */
		u16 acknowledge:1;		/* bit 14 */
		u16 remote_fault:1;	/* bit 13 */
		u16 res1:1;		/* bit 12 */
		u16 cap_asmpause:1;	/* bit 11 */
		u16 cap_pause:1;		/* bit 10 */
		u16 cap_100T4:1;		/* bit 9 */
		u16 cap_100fdx:1;		/* bit 8 */
		u16 cap_100hdx:1;		/* bit 7 */
		u16 cap_10fdx:1;		/* bit 6 */
		u16 cap_10hdx:1;		/* bit 5 */
		u16 selector:5;		/* bits 0-4 */
#else
		u16 selector:5;		/* bits 0-4 */
		u16 cap_10hdx:1;		/* bit 5 */
		u16 cap_10fdx:1;		/* bit 6 */
		u16 cap_100hdx:1;		/* bit 7 */
		u16 cap_100fdx:1;		/* bit 8 */
		u16 cap_100T4:1;		/* bit 9 */
		u16 cap_pause:1;		/* bit 10 */
		u16 cap_asmpause:1;	/* bit 11 */
		u16 res1:1;		/* bit 12 */
		u16 remote_fault:1;	/* bit 13 */
		u16 acknowledge:1;		/* bit 14 */
		u16 np_indication:1;	/* bit 15 */
#endif
	} bits;
} MI_ANLPAR_t, *PMI_ANLPAR_t;

/* MI Register 6: Auto-negotiation expansion register */
typedef union _MI_ANER_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res:11;	/* bits 5-15 */
		u16 pdf:1;		/* bit 4 */
		u16 lp_np_able:1;	/* bit 3 */
		u16 np_able:1;	/* bit 2 */
		u16 page_rx:1;	/* bit 1 */
		u16 lp_an_able:1;	/* bit 0 */
#else
		u16 lp_an_able:1;	/* bit 0 */
		u16 page_rx:1;	/* bit 1 */
		u16 np_able:1;	/* bit 2 */
		u16 lp_np_able:1;	/* bit 3 */
		u16 pdf:1;		/* bit 4 */
		u16 res:11;	/* bits 5-15 */
#endif
	} bits;
} MI_ANER_t, *PMI_ANER_t;

/* MI Register 7: Auto-negotiation next page transmit reg(0x07) */
typedef union _MI_ANNPTR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 np:1;		/* bit 15 */
		u16 res1:1;	/* bit 14 */
		u16 msg_page:1;	/* bit 13 */
		u16 ack2:1;	/* bit 12 */
		u16 toggle:1;	/* bit 11 */
		u16 msg:11;	/* bits 0-10 */
#else
		u16 msg:11;	/* bits 0-10 */
		u16 toggle:1;	/* bit 11 */
		u16 ack2:1;	/* bit 12 */
		u16 msg_page:1;	/* bit 13 */
		u16 res1:1;	/* bit 14 */
		u16 np:1;		/* bit 15 */
#endif
	} bits;
} MI_ANNPTR_t, *PMI_ANNPTR_t;

/* MI Register 8: Link Partner Next Page Reg(0x08) */
typedef union _MI_LPNPR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 np:1;		/* bit 15 */
		u16 ack:1;		/* bit 14 */
		u16 msg_page:1;	/* bit 13 */
		u16 ack2:1;	/* bit 12 */
		u16 toggle:1;	/* bit 11 */
		u16 msg:11;	/* bits 0-10 */
#else
		u16 msg:11;	/* bits 0-10 */
		u16 toggle:1;	/* bit 11 */
		u16 ack2:1;	/* bit 12 */
		u16 msg_page:1;	/* bit 13 */
		u16 ack:1;		/* bit 14 */
		u16 np:1;		/* bit 15 */
#endif
	} bits;
} MI_LPNPR_t, *PMI_LPNPR_t;

/* MI Register 9: 1000BaseT Control Reg(0x09) */
typedef union _MI_GCR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 test_mode:3;		/* bits 13-15 */
		u16 ms_config_en:1;	/* bit 12 */
		u16 ms_value:1;		/* bit 11 */
		u16 port_type:1;		/* bit 10 */
		u16 link_1000fdx:1;	/* bit 9 */
		u16 link_1000hdx:1;	/* bit 8 */
		u16 res:8;			/* bit 0-7 */
#else
		u16 res:8;			/* bit 0-7 */
		u16 link_1000hdx:1;	/* bit 8 */
		u16 link_1000fdx:1;	/* bit 9 */
		u16 port_type:1;		/* bit 10 */
		u16 ms_value:1;		/* bit 11 */
		u16 ms_config_en:1;	/* bit 12 */
		u16 test_mode:3;		/* bits 13-15 */
#endif
	} bits;
} MI_GCR_t, *PMI_GCR_t;

/* MI Register 10: 1000BaseT Status Reg(0x0A) */
typedef union _MI_GSR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 ms_config_fault:1;	/* bit 15 */
		u16 ms_resolve:1;		/* bit 14 */
		u16 local_rx_status:1;	/* bit 13 */
		u16 remote_rx_status:1;	/* bit 12 */
		u16 link_1000fdx:1;	/* bit 11 */
		u16 link_1000hdx:1;	/* bit 10 */
		u16 res:2;			/* bits 8-9 */
		u16 idle_err_cnt:8;	/* bits 0-7 */
#else
		u16 idle_err_cnt:8;	/* bits 0-7 */
		u16 res:2;			/* bits 8-9 */
		u16 link_1000hdx:1;	/* bit 10 */
		u16 link_1000fdx:1;	/* bit 11 */
		u16 remote_rx_status:1;	/* bit 12 */
		u16 local_rx_status:1;	/* bit 13 */
		u16 ms_resolve:1;		/* bit 14 */
		u16 ms_config_fault:1;	/* bit 15 */
#endif
	} bits;
} MI_GSR_t, *PMI_GSR_t;

/* MI Register 11 - 14: Reserved Regs(0x0B - 0x0E) */
typedef union _MI_RES_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res15:1;	/* bit 15 */
		u16 res14:1;	/* bit 14 */
		u16 res13:1;	/* bit 13 */
		u16 res12:1;	/* bit 12 */
		u16 res11:1;	/* bit 11 */
		u16 res10:1;	/* bit 10 */
		u16 res9:1;	/* bit 9 */
		u16 res8:1;	/* bit 8 */
		u16 res7:1;	/* bit 7 */
		u16 res6:1;	/* bit 6 */
		u16 res5:1;	/* bit 5 */
		u16 res4:1;	/* bit 4 */
		u16 res3:1;	/* bit 3 */
		u16 res2:1;	/* bit 2 */
		u16 res1:1;	/* bit 1 */
		u16 res0:1;	/* bit 0 */
#else
		u16 res0:1;	/* bit 0 */
		u16 res1:1;	/* bit 1 */
		u16 res2:1;	/* bit 2 */
		u16 res3:1;	/* bit 3 */
		u16 res4:1;	/* bit 4 */
		u16 res5:1;	/* bit 5 */
		u16 res6:1;	/* bit 6 */
		u16 res7:1;	/* bit 7 */
		u16 res8:1;	/* bit 8 */
		u16 res9:1;	/* bit 9 */
		u16 res10:1;	/* bit 10 */
		u16 res11:1;	/* bit 11 */
		u16 res12:1;	/* bit 12 */
		u16 res13:1;	/* bit 13 */
		u16 res14:1;	/* bit 14 */
		u16 res15:1;	/* bit 15 */
#endif
	} bits;
} MI_RES_t, *PMI_RES_t;

/* MI Register 15: Extended status Reg(0x0F) */
typedef union _MI_ESR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 link_1000Xfdx:1;	/* bit 15 */
		u16 link_1000Xhdx:1;	/* bit 14 */
		u16 link_1000fdx:1;	/* bit 13 */
		u16 link_1000hdx:1;	/* bit 12 */
		u16 res:12;		/* bit 0-11 */
#else
		u16 res:12;		/* bit 0-11 */
		u16 link_1000hdx:1;	/* bit 12 */
		u16 link_1000fdx:1;	/* bit 13 */
		u16 link_1000Xhdx:1;	/* bit 14 */
		u16 link_1000Xfdx:1;	/* bit 15 */
#endif
	} bits;
} MI_ESR_t, *PMI_ESR_t;

/* MI Register 16 - 18: Reserved Reg(0x10-0x12) */

/* MI Register 19: Loopback Control Reg(0x13) */
typedef union _MI_LCR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 mii_en:1;		/* bit 15 */
		u16 pcs_en:1;		/* bit 14 */
		u16 pmd_en:1;		/* bit 13 */
		u16 all_digital_en:1;	/* bit 12 */
		u16 replica_en:1;		/* bit 11 */
		u16 line_driver_en:1;	/* bit 10 */
		u16 res:10;		/* bit 0-9 */
#else
		u16 res:10;		/* bit 0-9 */
		u16 line_driver_en:1;	/* bit 10 */
		u16 replica_en:1;		/* bit 11 */
		u16 all_digital_en:1;	/* bit 12 */
		u16 pmd_en:1;		/* bit 13 */
		u16 pcs_en:1;		/* bit 14 */
		u16 mii_en:1;		/* bit 15 */
#endif
	} bits;
} MI_LCR_t, *PMI_LCR_t;

/* MI Register 20: Reserved Reg(0x14) */

/* MI Register 21: Management Interface Control Reg(0x15) */
typedef union _MI_MICR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res1:5;		/* bits 11-15 */
		u16 mi_error_count:7;	/* bits 4-10 */
		u16 res2:1;		/* bit 3 */
		u16 ignore_10g_fr:1;	/* bit 2 */
		u16 res3:1;		/* bit 1 */
		u16 preamble_supress_en:1;	/* bit 0 */
#else
		u16 preamble_supress_en:1;	/* bit 0 */
		u16 res3:1;		/* bit 1 */
		u16 ignore_10g_fr:1;	/* bit 2 */
		u16 res2:1;		/* bit 3 */
		u16 mi_error_count:7;	/* bits 4-10 */
		u16 res1:5;		/* bits 11-15 */
#endif
	} bits;
} MI_MICR_t, *PMI_MICR_t;

/* MI Register 22: PHY Configuration Reg(0x16) */
typedef union _MI_PHY_CONFIG_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 crs_tx_en:1;		/* bit 15 */
		u16 res1:1;		/* bit 14 */
		u16 tx_fifo_depth:2;	/* bits 12-13 */
		u16 speed_downshift:2;	/* bits 10-11 */
		u16 pbi_detect:1;		/* bit 9 */
		u16 tbi_rate:1;		/* bit 8 */
		u16 alternate_np:1;	/* bit 7 */
		u16 group_mdio_en:1;	/* bit 6 */
		u16 tx_clock_en:1;		/* bit 5 */
		u16 sys_clock_en:1;	/* bit 4 */
		u16 res2:1;		/* bit 3 */
		u16 mac_if_mode:3;		/* bits 0-2 */
#else
		u16 mac_if_mode:3;		/* bits 0-2 */
		u16 res2:1;		/* bit 3 */
		u16 sys_clock_en:1;	/* bit 4 */
		u16 tx_clock_en:1;		/* bit 5 */
		u16 group_mdio_en:1;	/* bit 6 */
		u16 alternate_np:1;	/* bit 7 */
		u16 tbi_rate:1;		/* bit 8 */
		u16 pbi_detect:1;		/* bit 9 */
		u16 speed_downshift:2;	/* bits 10-11 */
		u16 tx_fifo_depth:2;	/* bits 12-13 */
		u16 res1:1;		/* bit 14 */
		u16 crs_tx_en:1;		/* bit 15 */
#endif
	} bits;
} MI_PHY_CONFIG_t, *PMI_PHY_CONFIG_t;

/* MI Register 23: PHY CONTROL Reg(0x17) */
typedef union _MI_PHY_CONTROL_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res1:1;		/* bit 15 */
		u16 tdr_en:1;		/* bit 14 */
		u16 res2:1;		/* bit 13 */
		u16 downshift_attempts:2;	/* bits 11-12 */
		u16 res3:5;		/* bit 6-10 */
		u16 jabber_10baseT:1;	/* bit 5 */
		u16 sqe_10baseT:1;		/* bit 4 */
		u16 tp_loopback_10baseT:1;	/* bit 3 */
		u16 preamble_gen_en:1;	/* bit 2 */
		u16 res4:1;		/* bit 1 */
		u16 force_int:1;		/* bit 0 */
#else
		u16 force_int:1;		/* bit 0 */
		u16 res4:1;		/* bit 1 */
		u16 preamble_gen_en:1;	/* bit 2 */
		u16 tp_loopback_10baseT:1;	/* bit 3 */
		u16 sqe_10baseT:1;		/* bit 4 */
		u16 jabber_10baseT:1;	/* bit 5 */
		u16 res3:5;		/* bit 6-10 */
		u16 downshift_attempts:2;	/* bits 11-12 */
		u16 res2:1;		/* bit 13 */
		u16 tdr_en:1;		/* bit 14 */
		u16 res1:1;		/* bit 15 */
#endif
	} bits;
} MI_PHY_CONTROL_t, *PMI_PHY_CONTROL_t;

/* MI Register 24: Interrupt Mask Reg(0x18) */
typedef union _MI_IMR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res1:6;		/* bits 10-15 */
		u16 mdio_sync_lost:1;	/* bit 9 */
		u16 autoneg_status:1;	/* bit 8 */
		u16 hi_bit_err:1;		/* bit 7 */
		u16 np_rx:1;		/* bit 6 */
		u16 err_counter_full:1;	/* bit 5 */
		u16 fifo_over_underflow:1;	/* bit 4 */
		u16 rx_status:1;		/* bit 3 */
		u16 link_status:1;		/* bit 2 */
		u16 automatic_speed:1;	/* bit 1 */
		u16 int_en:1;		/* bit 0 */
#else
		u16 int_en:1;		/* bit 0 */
		u16 automatic_speed:1;	/* bit 1 */
		u16 link_status:1;		/* bit 2 */
		u16 rx_status:1;		/* bit 3 */
		u16 fifo_over_underflow:1;	/* bit 4 */
		u16 err_counter_full:1;	/* bit 5 */
		u16 np_rx:1;		/* bit 6 */
		u16 hi_bit_err:1;		/* bit 7 */
		u16 autoneg_status:1;	/* bit 8 */
		u16 mdio_sync_lost:1;	/* bit 9 */
		u16 res1:6;		/* bits 10-15 */
#endif
	} bits;
} MI_IMR_t, *PMI_IMR_t;

/* MI Register 25: Interrupt Status Reg(0x19) */
typedef union _MI_ISR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res1:6;		/* bits 10-15 */
		u16 mdio_sync_lost:1;	/* bit 9 */
		u16 autoneg_status:1;	/* bit 8 */
		u16 hi_bit_err:1;		/* bit 7 */
		u16 np_rx:1;		/* bit 6 */
		u16 err_counter_full:1;	/* bit 5 */
		u16 fifo_over_underflow:1;	/* bit 4 */
		u16 rx_status:1;		/* bit 3 */
		u16 link_status:1;		/* bit 2 */
		u16 automatic_speed:1;	/* bit 1 */
		u16 int_en:1;		/* bit 0 */
#else
		u16 int_en:1;		/* bit 0 */
		u16 automatic_speed:1;	/* bit 1 */
		u16 link_status:1;		/* bit 2 */
		u16 rx_status:1;		/* bit 3 */
		u16 fifo_over_underflow:1;	/* bit 4 */
		u16 err_counter_full:1;	/* bit 5 */
		u16 np_rx:1;		/* bit 6 */
		u16 hi_bit_err:1;		/* bit 7 */
		u16 autoneg_status:1;	/* bit 8 */
		u16 mdio_sync_lost:1;	/* bit 9 */
		u16 res1:6;		/* bits 10-15 */
#endif
	} bits;
} MI_ISR_t, *PMI_ISR_t;

/* MI Register 26: PHY Status Reg(0x1A) */
typedef union _MI_PSR_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res1:1;		/* bit 15 */
		u16 autoneg_fault:2;	/* bit 13-14 */
		u16 autoneg_status:1;	/* bit 12 */
		u16 mdi_x_status:1;	/* bit 11 */
		u16 polarity_status:1;	/* bit 10 */
		u16 speed_status:2;	/* bits 8-9 */
		u16 duplex_status:1;	/* bit 7 */
		u16 link_status:1;		/* bit 6 */
		u16 tx_status:1;		/* bit 5 */
		u16 rx_status:1;		/* bit 4 */
		u16 collision_status:1;	/* bit 3 */
		u16 autoneg_en:1;		/* bit 2 */
		u16 pause_en:1;		/* bit 1 */
		u16 asymmetric_dir:1;	/* bit 0 */
#else
		u16 asymmetric_dir:1;	/* bit 0 */
		u16 pause_en:1;		/* bit 1 */
		u16 autoneg_en:1;		/* bit 2 */
		u16 collision_status:1;	/* bit 3 */
		u16 rx_status:1;		/* bit 4 */
		u16 tx_status:1;		/* bit 5 */
		u16 link_status:1;		/* bit 6 */
		u16 duplex_status:1;	/* bit 7 */
		u16 speed_status:2;	/* bits 8-9 */
		u16 polarity_status:1;	/* bit 10 */
		u16 mdi_x_status:1;	/* bit 11 */
		u16 autoneg_status:1;	/* bit 12 */
		u16 autoneg_fault:2;	/* bit 13-14 */
		u16 res1:1;		/* bit 15 */
#endif
	} bits;
} MI_PSR_t, *PMI_PSR_t;

/* MI Register 27: LED Control Reg 1(0x1B) */
typedef union _MI_LCR1_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 res1:2;		/* bits 14-15 */
		u16 led_dup_indicate:2;	/* bits 12-13 */
		u16 led_10baseT:2;		/* bits 10-11 */
		u16 led_collision:2;	/* bits 8-9 */
		u16 res2:2;		/* bits 6-7 */
		u16 res3:2;		/* bits 4-5 */
		u16 pulse_dur:2;		/* bits 2-3 */
		u16 pulse_stretch1:1;	/* bit 1 */
		u16 pulse_stretch0:1;	/* bit 0 */
#else
		u16 pulse_stretch0:1;	/* bit 0 */
		u16 pulse_stretch1:1;	/* bit 1 */
		u16 pulse_dur:2;		/* bits 2-3 */
		u16 res3:2;		/* bits 4-5 */
		u16 res2:2;		/* bits 6-7 */
		u16 led_collision:2;	/* bits 8-9 */
		u16 led_10baseT:2;		/* bits 10-11 */
		u16 led_dup_indicate:2;	/* bits 12-13 */
		u16 res1:2;		/* bits 14-15 */
#endif
	} bits;
} MI_LCR1_t, *PMI_LCR1_t;

/* MI Register 28: LED Control Reg 2(0x1C) */
typedef union _MI_LCR2_t {
	u16 value;
	struct {
#ifdef _BIT_FIELDS_HTOL
		u16 led_link:4;		/* bits 12-15 */
		u16 led_tx_rx:4;		/* bits 8-11 */
		u16 led_100BaseTX:4;	/* bits 4-7 */
		u16 led_1000BaseT:4;	/* bits 0-3 */
#else
		u16 led_1000BaseT:4;	/* bits 0-3 */
		u16 led_100BaseTX:4;	/* bits 4-7 */
		u16 led_tx_rx:4;		/* bits 8-11 */
		u16 led_link:4;		/* bits 12-15 */
#endif
	} bits;
} MI_LCR2_t, *PMI_LCR2_t;

/* MI Register 29 - 31: Reserved Reg(0x1D - 0x1E) */

/* Forward declaration of the private adapter structure */
struct et131x_adapter;

/* OS Specific Functions*/
void TPAL_SetPhy10HalfDuplex(struct et131x_adapter *adapter);
void TPAL_SetPhy10FullDuplex(struct et131x_adapter *adapter);
void TPAL_SetPhy10Force(struct et131x_adapter *pAdapter);
void TPAL_SetPhy100HalfDuplex(struct et131x_adapter *adapter);
void TPAL_SetPhy100FullDuplex(struct et131x_adapter *adapter);
void TPAL_SetPhy100Force(struct et131x_adapter *pAdapter);
void TPAL_SetPhy1000FullDuplex(struct et131x_adapter *adapter);
void TPAL_SetPhyAutoNeg(struct et131x_adapter *adapter);

/* Prototypes for ET1310_phy.c */
int et131x_xcvr_find(struct et131x_adapter *adapter);
int et131x_setphy_normal(struct et131x_adapter *adapter);
int32_t PhyMiRead(struct et131x_adapter *adapter,
	       u8 xcvrAddr, u8 xcvrReg, u16 *value);

/* static inline function does not work because et131x_adapter is not always
 * defined
 */
#define MiRead(adapter, xcvrReg, value) \
	PhyMiRead((adapter), (adapter)->Stats.xcvr_addr, (xcvrReg), (value))

int32_t MiWrite(struct et131x_adapter *adapter,
		u8 xcvReg, u16 value);
void et131x_Mii_check(struct et131x_adapter *pAdapter,
		      MI_BMSR_t bmsr, MI_BMSR_t bmsr_ints);

/* This last is not strictly required (the driver could call the TPAL
 * version instead), but this sets the adapter up correctly, and calls the
 * access routine indirectly.  This protects the driver from changes in TPAL.
 */
void SetPhy_10BaseTHalfDuplex(struct et131x_adapter *adapter);

/* Defines for PHY access routines */

/* Define bit operation flags */
#define TRUEPHY_BIT_CLEAR               0
#define TRUEPHY_BIT_SET                 1
#define TRUEPHY_BIT_READ                2

/* Define read/write operation flags */
#ifndef TRUEPHY_READ
#define TRUEPHY_READ                    0
#define TRUEPHY_WRITE                   1
#define TRUEPHY_MASK                    2
#endif

/* Define speeds */
#define TRUEPHY_SPEED_10MBPS            0
#define TRUEPHY_SPEED_100MBPS           1
#define TRUEPHY_SPEED_1000MBPS          2

/* Define duplex modes */
#define TRUEPHY_DUPLEX_HALF             0
#define TRUEPHY_DUPLEX_FULL             1

/* Define master/slave configuration values */
#define TRUEPHY_CFG_SLAVE               0
#define TRUEPHY_CFG_MASTER              1

/* Define MDI/MDI-X settings */
#define TRUEPHY_MDI                     0
#define TRUEPHY_MDIX                    1
#define TRUEPHY_AUTO_MDI_MDIX           2

/* Define 10Base-T link polarities */
#define TRUEPHY_POLARITY_NORMAL         0
#define TRUEPHY_POLARITY_INVERTED       1

/* Define auto-negotiation results */
#define TRUEPHY_ANEG_NOT_COMPLETE       0
#define TRUEPHY_ANEG_COMPLETE           1
#define TRUEPHY_ANEG_DISABLED           2

/* Define duplex advertisment flags */
#define TRUEPHY_ADV_DUPLEX_NONE         0x00
#define TRUEPHY_ADV_DUPLEX_FULL         0x01
#define TRUEPHY_ADV_DUPLEX_HALF         0x02
#define TRUEPHY_ADV_DUPLEX_BOTH     \
    (TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF)

#define PHY_CONTROL                0x00	/* #define TRU_MI_CONTROL_REGISTER                 0 */
#define PHY_STATUS                 0x01	/* #define TRU_MI_STATUS_REGISTER                  1 */
#define PHY_ID_1                   0x02	/* #define TRU_MI_PHY_IDENTIFIER_1_REGISTER        2 */
#define PHY_ID_2                   0x03	/* #define TRU_MI_PHY_IDENTIFIER_2_REGISTER        3 */
#define PHY_AUTO_ADVERTISEMENT     0x04	/* #define TRU_MI_ADVERTISEMENT_REGISTER           4 */
#define PHY_AUTO_LINK_PARTNER      0x05	/* #define TRU_MI_LINK_PARTNER_ABILITY_REGISTER    5 */
#define PHY_AUTO_EXPANSION         0x06	/* #define TRU_MI_EXPANSION_REGISTER               6 */
#define PHY_AUTO_NEXT_PAGE_TX      0x07	/* #define TRU_MI_NEXT_PAGE_TRANSMIT_REGISTER      7 */
#define PHY_LINK_PARTNER_NEXT_PAGE 0x08	/* #define TRU_MI_LINK_PARTNER_NEXT_PAGE_REGISTER  8 */
#define PHY_1000_CONTROL           0x09	/* #define TRU_MI_1000BASET_CONTROL_REGISTER       9 */
#define PHY_1000_STATUS            0x0A	/* #define TRU_MI_1000BASET_STATUS_REGISTER        10 */

#define PHY_EXTENDED_STATUS        0x0F	/* #define TRU_MI_EXTENDED_STATUS_REGISTER         15 */

/* some defines for modem registers that seem to be 'reserved' */
#define PHY_INDEX_REG              0x10
#define PHY_DATA_REG               0x11

#define PHY_MPHY_CONTROL_REG       0x12	/* #define TRU_VMI_MPHY_CONTROL_REGISTER           18 */

#define PHY_LOOPBACK_CONTROL       0x13	/* #define TRU_VMI_LOOPBACK_CONTROL_1_REGISTER     19 */
					/* #define TRU_VMI_LOOPBACK_CONTROL_2_REGISTER     20 */
#define PHY_REGISTER_MGMT_CONTROL  0x15	/* #define TRU_VMI_MI_SEQ_CONTROL_REGISTER         21 */
#define PHY_CONFIG                 0x16	/* #define TRU_VMI_CONFIGURATION_REGISTER          22 */
#define PHY_PHY_CONTROL            0x17	/* #define TRU_VMI_PHY_CONTROL_REGISTER            23 */
#define PHY_INTERRUPT_MASK         0x18	/* #define TRU_VMI_INTERRUPT_MASK_REGISTER         24 */
#define PHY_INTERRUPT_STATUS       0x19	/* #define TRU_VMI_INTERRUPT_STATUS_REGISTER       25 */
#define PHY_PHY_STATUS             0x1A	/* #define TRU_VMI_PHY_STATUS_REGISTER             26 */
#define PHY_LED_1                  0x1B	/* #define TRU_VMI_LED_CONTROL_1_REGISTER          27 */
#define PHY_LED_2                  0x1C	/* #define TRU_VMI_LED_CONTROL_2_REGISTER          28 */
					/* #define TRU_VMI_LINK_CONTROL_REGISTER           29 */
					/* #define TRU_VMI_TIMING_CONTROL_REGISTER */

/* Prototypes for PHY access routines */
void ET1310_PhyInit(struct et131x_adapter *adapter);
void ET1310_PhyReset(struct et131x_adapter *adapter);
void ET1310_PhyPowerDown(struct et131x_adapter *adapter, bool down);
void ET1310_PhyAutoNeg(struct et131x_adapter *adapter, bool enable);
void ET1310_PhyDuplexMode(struct et131x_adapter *adapter, u16 duplex);
void ET1310_PhySpeedSelect(struct et131x_adapter *adapter, u16 speed);
void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *adapter,
				  u16 duplex);
void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *adapter,
				 u16 duplex);
void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *adapter,
				u16 duplex);
void ET1310_PhyLinkStatus(struct et131x_adapter *adapter,
			  u8 *Link_status,
			  u32 *autoneg,
			  u32 *linkspeed,
			  u32 *duplex_mode,
			  u32 *mdi_mdix,
			  u32 *masterslave, u32 *polarity);
void ET1310_PhyAndOrReg(struct et131x_adapter *adapter,
			u16 regnum, u16 andMask, u16 orMask);
void ET1310_PhyAccessMiBit(struct et131x_adapter *adapter,
			   u16 action,
			   u16 regnum, u16 bitnum, u8 *value);

#endif /* _ET1310_PHY_H_ */