Subversion Repositories Kolibri OS

Rev

Rev 3545 | Rev 5073 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4467 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2010-2014. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;  mii.inc - Media Independent Interface routines for KolibriOS   ;;
7
;;                                                                 ;;
8
;;          GNU GENERAL PUBLIC LICENSE                             ;;
9
;;             Version 2, June 1991                                ;;
10
;;                                                                 ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
 
13
 
3545 hidnplayr 14
; Generic MII registers.
15
 
16
        MII_BMCR                = 0x00          ; Basic mode control register
17
        MII_BMSR                = 0x01          ; Basic mode status register
18
        MII_PHYSID1             = 0x02          ; PHYS ID 1
19
        MII_PHYSID2             = 0x03          ; PHYS ID 2
20
        MII_ADVERTISE           = 0x04          ; Advertisement control reg
21
        MII_LPA                 = 0x05          ; Link partner ability reg
22
        MII_EXPANSION           = 0x06          ; Expansion register
23
        MII_CTRL1000            = 0x09          ; 1000BASE-T control
24
        MII_STAT1000            = 0x0a          ; 1000BASE-T status
25
        MII_ESTATUS             = 0x0f          ; Extended Status
26
        MII_DCOUNTER            = 0x12          ; Disconnect counter
27
        MII_FCSCOUNTER          = 0x13          ; False carrier counter
28
        MII_NWAYTEST            = 0x14          ; N-way auto-neg test reg
29
        MII_RERRCOUNTER         = 0x15          ; Receive error counter
30
        MII_SREVISION           = 0x16          ; Silicon revision
31
        MII_RESV1               = 0x17          ; Reserved...
32
        MII_LBRERROR            = 0x18          ; Lpback, rx, bypass error
33
        MII_PHYADDR             = 0x19          ; PHY address
34
        MII_RESV2               = 0x1a          ; Reserved...
35
        MII_TPISTATUS           = 0x1b          ; TPI status for 10mbps
36
        MII_NCONFIG             = 0x1c          ; Network interface config
37
 
38
; Basic mode control register.
39
 
40
        BMCR_RESV               = 0x003f        ; Unused...
41
        BMCR_SPEED1000          = 0x0040        ; MSB of Speed (1000)
42
        BMCR_CTST               = 0x0080        ; Collision test
43
        BMCR_FULLDPLX           = 0x0100        ; Full duplex
44
        BMCR_ANRESTART          = 0x0200        ; Auto negotiation restart
45
        BMCR_ISOLATE            = 0x0400        ; Disconnect DP83840 from MII
46
        BMCR_PDOWN              = 0x0800        ; Powerdown the DP83840
47
        BMCR_ANENABLE           = 0x1000        ; Enable auto negotiation
48
        BMCR_SPEED100           = 0x2000        ; Select 100Mbps
49
        BMCR_LOOPBACK           = 0x4000        ; TXD loopback bits
50
        BMCR_RESET              = 0x8000        ; Reset the DP83840
51
 
52
; Basic mode status register.
53
 
54
        BMSR_ERCAP              = 0x0001        ; Ext-reg capability
55
        BMSR_JCD                = 0x0002        ; Jabber detected
56
        BMSR_LSTATUS            = 0x0004        ; Link status
57
        BMSR_ANEGCAPABLE        = 0x0008        ; Able to do auto-negotiation
58
        BMSR_RFAULT             = 0x0010        ; Remote fault detected
59
        BMSR_ANEGCOMPLETE       = 0x0020        ; Auto-negotiation complete
60
        BMSR_RESV               = 0x00c0        ; Unused...
61
        BMSR_ESTATEN            = 0x0100        ; Extended Status in R15
62
        BMSR_100HALF2           = 0x0200        ; Can do 100BASE-T2 HDX
63
        BMSR_100FULL2           = 0x0400        ; Can do 100BASE-T2 FDX
64
        BMSR_10HALF             = 0x0800        ; Can do 10mbps, half-duplex
65
        BMSR_10FULL             = 0x1000        ; Can do 10mbps, full-duplex
66
        BMSR_100HALF            = 0x2000        ; Can do 100mbps, half-duplex
67
        BMSR_100FULL            = 0x4000        ; Can do 100mbps, full-duplex
68
        BMSR_100BASE4           = 0x8000        ; Can do 100mbps, 4k packets
69
 
70
; Advertisement control register.
71
 
72
        ADVERTISE_SLCT          = 0x001f        ; Selector bits
73
        ADVERTISE_CSMA          = 0x0001        ; Only selector supported
74
        ADVERTISE_10HALF        = 0x0020        ; Try for 10mbps half-duplex
75
        ADVERTISE_1000XFULL     = 0x0020        ; Try for 1000BASE-X full-duplex
76
        ADVERTISE_10FULL        = 0x0040        ; Try for 10mbps full-duplex
77
        ADVERTISE_1000XHALF     = 0x0040        ; Try for 1000BASE-X half-duplex
78
        ADVERTISE_100HALF       = 0x0080        ; Try for 100mbps half-duplex
79
        ADVERTISE_1000XPAUSE    = 0x0080        ; Try for 1000BASE-X pause
80
        ADVERTISE_100FULL       = 0x0100        ; Try for 100mbps full-duplex
81
        ADVERTISE_1000XPSE_ASYM = 0x0100        ; Try for 1000BASE-X asym pause
82
        ADVERTISE_100BASE4      = 0x0200        ; Try for 100mbps 4k packets
83
        ADVERTISE_PAUSE_CAP     = 0x0400        ; Try for pause
84
        ADVERTISE_PAUSE_ASYM    = 0x0800        ; Try for asymetric pause
85
        ADVERTISE_RESV          = 0x1000        ; Unused...
86
        ADVERTISE_RFAULT        = 0x2000        ; Say we can detect faults
87
        ADVERTISE_LPACK         = 0x4000        ; Ack link partners response
88
        ADVERTISE_NPAGE         = 0x8000        ; Next page bit
89
 
90
        ADVERTISE_FULL          = (ADVERTISE_100FULL or ADVERTISE_10FULL or ADVERTISE_CSMA)
91
        ADVERTISE_ALL           = (ADVERTISE_10HALF or ADVERTISE_10FULL or ADVERTISE_100HALF or ADVERTISE_100FULL)
92
 
93
; Link partner ability register.
94
 
95
        LPA_SLCT                = 0x001f        ; Same as advertise selector
96
        LPA_10HALF              = 0x0020        ; Can do 10mbps half-duplex
97
        LPA_1000XFULL           = 0x0020        ; Can do 1000BASE-X full-duplex
98
        LPA_10FULL              = 0x0040        ; Can do 10mbps full-duplex
99
        LPA_1000XHALF           = 0x0040        ; Can do 1000BASE-X half-duplex
100
        LPA_100HALF             = 0x0080        ; Can do 100mbps half-duplex
101
        LPA_1000XPAUSE          = 0x0080        ; Can do 1000BASE-X pause
102
        LPA_100FULL             = 0x0100        ; Can do 100mbps full-duplex
103
        LPA_1000XPAUSE_ASYM     = 0x0100        ; Can do 1000BASE-X pause asym
104
        LPA_100BASE4            = 0x0200        ; Can do 100mbps 4k packets
105
        LPA_PAUSE_CAP           = 0x0400        ; Can pause
106
        LPA_PAUSE_ASYM          = 0x0800        ; Can pause asymetrically
107
        LPA_RESV                = 0x1000        ; Unused...
108
        LPA_RFAULT              = 0x2000        ; Link partner faulted
109
        LPA_LPACK               = 0x4000        ; Link partner acked us
110
        LPA_NPAGE               = 0x8000        ; Next page bit
111
 
112
        LPA_DUPLEX              = (LPA_10FULL or LPA_100FULL)
113
        LPA_100                 = (LPA_100FULL or LPA_100HALF or LPA_100BASE4)
114
 
115
; Expansion register for auto-negotiation.
116
 
117
        EXPANSION_NWAY          = 0x0001        ; Can do N-way auto-nego
118
        EXPANSION_LCWP          = 0x0002        ; Got new RX page code word
119
        EXPANSION_ENABLENPAGE   = 0x0004        ; This enables npage words
120
        EXPANSION_NPCAPABLE     = 0x0008        ; Link partner supports npage
121
        EXPANSION_MFAULTS       = 0x0010        ; Multiple faults detected
122
        EXPANSION_RESV          = 0xffe0        ; Unused...
123
 
124
        ESTATUS_1000_TFULL      = 0x2000        ; Can do 1000BT Full
125
        ESTATUS_1000_THALF      = 0x1000        ; Can do 1000BT Half
126
 
127
; N-way test register.
128
 
129
        NWAYTEST_RESV1          = 0x00ff        ; Unused...
130
        NWAYTEST_LOOPBACK       = 0x0100        ; Enable loopback for N-way
131
        NWAYTEST_RESV2          = 0xfe00        ; Unused...
132
 
133
; 1000BASE-T Control register
134
 
135
        ADVERTISE_1000FULL      = 0x0200        ; Advertise 1000BASE-T full duplex
136
        ADVERTISE_1000HALF      = 0x0100        ; Advertise 1000BASE-T half duplex
137
 
138
; 1000BASE-T Status register
139
 
140
        LPA_1000LOCALRXOK       = 0x2000        ; Link partner local receiver status
141
        LPA_1000REMRXOK         = 0x1000        ; Link partner remote receiver status
142
        LPA_1000FULL            = 0x0800        ; Link partner 1000BASE-T full duplex
143
        LPA_1000HALF            = 0x0400        ; Link partner 1000BASE-T half duplex
144
 
145
; Flow control flags
146
 
147
        FLOW_CTRL_TX            = 0x01
148
        FLOW_CTRL_RX            = 0x02
149
 
150
 
151
 
152
if used mii_link_ok
153
 
154
align 4
155
mii_link_ok:
156
 
157
        DEBUGF  1, "mii_link_ok\n"
158
 
159
; First do a dummy read to latch some MII phys
160
 
161
        mov     ecx, MII_BMSR
162
        call    mdio_read
163
 
164
        mov     ecx, MII_BMSR
165
        call    mdio_read
166
 
167
        and     ax, BMSR_LSTATUS
168
 
169
        DEBUGF  1, "link status=0x%x\n", ax
170
 
171
        ret
172
 
173
end if