2803bdf8c6888cfb55fcc0515e1a65a0a2425005
[firefly-linux-kernel-4.4.55.git] / drivers / staging / et131x / et1310_phy.h
1 /*
2  * Agere Systems Inc.
3  * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4  *
5  * Copyright © 2005 Agere Systems Inc.
6  * All rights reserved.
7  *   http://www.agere.com
8  *
9  * Copyright (c) 2011 Mark Einon <mark.einon@gmail.com>
10  *
11  *------------------------------------------------------------------------------
12  *
13  * et1310_phy.h - Defines, structs, enums, prototypes, etc. pertaining to the
14  *                PHY.
15  *
16  *------------------------------------------------------------------------------
17  *
18  * SOFTWARE LICENSE
19  *
20  * This software is provided subject to the following terms and conditions,
21  * which you should read carefully before using the software.  Using this
22  * software indicates your acceptance of these terms and conditions.  If you do
23  * not agree with these terms and conditions, do not use the software.
24  *
25  * Copyright © 2005 Agere Systems Inc.
26  * All rights reserved.
27  *
28  * Redistribution and use in source or binary forms, with or without
29  * modifications, are permitted provided that the following conditions are met:
30  *
31  * . Redistributions of source code must retain the above copyright notice, this
32  *    list of conditions and the following Disclaimer as comments in the code as
33  *    well as in the documentation and/or other materials provided with the
34  *    distribution.
35  *
36  * . Redistributions in binary form must reproduce the above copyright notice,
37  *    this list of conditions and the following Disclaimer in the documentation
38  *    and/or other materials provided with the distribution.
39  *
40  * . Neither the name of Agere Systems Inc. nor the names of the contributors
41  *    may be used to endorse or promote products derived from this software
42  *    without specific prior written permission.
43  *
44  * Disclaimer
45  *
46  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
47  * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
48  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
49  * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
50  * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
51  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54  * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
57  * DAMAGE.
58  *
59  */
60
61 #ifndef _ET1310_PHY_H_
62 #define _ET1310_PHY_H_
63
64 #include "et1310_address_map.h"
65
66 /*
67  * Defines for generic MII registers 0x00 -> 0x0F can be found in
68  * include/linux/mii.h
69  */
70
71 /* some defines for modem registers that seem to be 'reserved' */
72 #define PHY_INDEX_REG              0x10
73 #define PHY_DATA_REG               0x11
74 #define PHY_MPHY_CONTROL_REG       0x12
75
76 /* defines for specified registers */
77 #define PHY_LOOPBACK_CONTROL       0x13 /* TRU_VMI_LOOPBACK_CONTROL_1_REG 19 */
78                                         /* TRU_VMI_LOOPBACK_CONTROL_2_REG 20 */
79 #define PHY_REGISTER_MGMT_CONTROL  0x15 /* TRU_VMI_MI_SEQ_CONTROL_REG     21 */
80 #define PHY_CONFIG                 0x16 /* TRU_VMI_CONFIGURATION_REG      22 */
81 #define PHY_PHY_CONTROL            0x17 /* TRU_VMI_PHY_CONTROL_REG        23 */
82 #define PHY_INTERRUPT_MASK         0x18 /* TRU_VMI_INTERRUPT_MASK_REG     24 */
83 #define PHY_INTERRUPT_STATUS       0x19 /* TRU_VMI_INTERRUPT_STATUS_REG   25 */
84 #define PHY_PHY_STATUS             0x1A /* TRU_VMI_PHY_STATUS_REG         26 */
85 #define PHY_LED_1                  0x1B /* TRU_VMI_LED_CONTROL_1_REG      27 */
86 #define PHY_LED_2                  0x1C /* TRU_VMI_LED_CONTROL_2_REG      28 */
87                                         /* TRU_VMI_LINK_CONTROL_REG       29 */
88                                         /* TRU_VMI_TIMING_CONTROL_REG        */
89
90 /* MI Register 10: Gigabit basic mode status reg(Reg 0x0A) */
91 #define ET_1000BT_MSTR_SLV 0x4000
92
93 /* MI Register 16 - 18: Reserved Reg(0x10-0x12) */
94
95 /* MI Register 19: Loopback Control Reg(0x13)
96  *      15:     mii_en
97  *      14:     pcs_en
98  *      13:     pmd_en
99  *      12:     all_digital_en
100  *      11:     replica_en
101  *      10:     line_driver_en
102  *      9-0:    reserved
103  */
104
105 /* MI Register 20: Reserved Reg(0x14) */
106
107 /* MI Register 21: Management Interface Control Reg(0x15)
108  *      15-11:  reserved
109  *      10-4:   mi_error_count
110  *      3:      reserved
111  *      2:      ignore_10g_fr
112  *      1:      reserved
113  *      0:      preamble_supress_en
114  */
115
116 /* MI Register 22: PHY Configuration Reg(0x16)
117  *      15:     crs_tx_en
118  *      14:     reserved
119  *      13-12:  tx_fifo_depth
120  *      11-10:  speed_downshift
121  *      9:      pbi_detect
122  *      8:      tbi_rate
123  *      7:      alternate_np
124  *      6:      group_mdio_en
125  *      5:      tx_clock_en
126  *      4:      sys_clock_en
127  *      3:      reserved
128  *      2-0:    mac_if_mode
129  */
130
131 #define ET_PHY_CONFIG_TX_FIFO_DEPTH     0x3000
132
133 #define ET_PHY_CONFIG_FIFO_DEPTH_8      0x0000
134 #define ET_PHY_CONFIG_FIFO_DEPTH_16     0x1000
135 #define ET_PHY_CONFIG_FIFO_DEPTH_32     0x2000
136 #define ET_PHY_CONFIG_FIFO_DEPTH_64     0x3000
137
138 /* MI Register 23: PHY CONTROL Reg(0x17)
139  *      15:     reserved
140  *      14:     tdr_en
141  *      13:     reserved
142  *      12-11:  downshift_attempts
143  *      10-6:   reserved
144  *      5:      jabber_10baseT
145  *      4:      sqe_10baseT
146  *      3:      tp_loopback_10baseT
147  *      2:      preamble_gen_en
148  *      1:      reserved
149  *      0:      force_int
150  */
151
152 /* MI Register 24: Interrupt Mask Reg(0x18)
153  *      15-10:  reserved
154  *      9:      mdio_sync_lost
155  *      8:      autoneg_status
156  *      7:      hi_bit_err
157  *      6:      np_rx
158  *      5:      err_counter_full
159  *      4:      fifo_over_underflow
160  *      3:      rx_status
161  *      2:      link_status
162  *      1:      automatic_speed
163  *      0:      int_en
164  */
165
166 #define ET_PHY_INT_MASK_AUTONEGSTAT     0x0100
167 #define ET_PHY_INT_MASK_LINKSTAT        0x0004
168 #define ET_PHY_INT_MASK_ENABLE          0x0001
169
170 /* MI Register 25: Interrupt Status Reg(0x19)
171  *      15-10:  reserved
172  *      9:      mdio_sync_lost
173  *      8:      autoneg_status
174  *      7:      hi_bit_err
175  *      6:      np_rx
176  *      5:      err_counter_full
177  *      4:      fifo_over_underflow
178  *      3:      rx_status
179  *      2:      link_status
180  *      1:      automatic_speed
181  *      0:      int_en
182  */
183
184 /* MI Register 26: PHY Status Reg(0x1A)
185  *      15:     reserved
186  *      14-13:  autoneg_fault
187  *      12:     autoneg_status
188  *      11:     mdi_x_status
189  *      10:     polarity_status
190  *      9-8:    speed_status
191  *      7:      duplex_status
192  *      6:      link_status
193  *      5:      tx_status
194  *      4:      rx_status
195  *      3:      collision_status
196  *      2:      autoneg_en
197  *      1:      pause_en
198  *      0:      asymmetric_dir
199  */
200 #define ET_PHY_AUTONEG_STATUS   0x1000
201 #define ET_PHY_POLARITY_STATUS  0x0400
202 #define ET_PHY_SPEED_STATUS     0x0300
203 #define ET_PHY_DUPLEX_STATUS    0x0080
204 #define ET_PHY_LSTATUS          0x0040
205 #define ET_PHY_AUTONEG_ENABLE   0x0020
206
207 /* MI Register 27: LED Control Reg 1(0x1B)
208  *      15-14:  reserved
209  *      13-12:  led_dup_indicate
210  *      11-10:  led_10baseT
211  *      9-8:    led_collision
212  *      7-4:    reserved
213  *      3-2:    pulse_dur
214  *      1:      pulse_stretch1
215  *      0:      pulse_stretch0
216  */
217
218 /* MI Register 28: LED Control Reg 2(0x1C)
219  *      15-12:  led_link
220  *      11-8:   led_tx_rx
221  *      7-4:    led_100BaseTX
222  *      3-0:    led_1000BaseT
223  */
224 #define ET_LED2_LED_LINK        0xF000
225 #define ET_LED2_LED_TXRX        0x0F00
226 #define ET_LED2_LED_100TX       0x00F0
227 #define ET_LED2_LED_1000T       0x000F
228
229 /* defines for LED control reg 2 values */
230 #define LED_VAL_1000BT                  0x0
231 #define LED_VAL_100BTX                  0x1
232 #define LED_VAL_10BT                    0x2
233 #define LED_VAL_1000BT_100BTX           0x3 /* 1000BT on, 100BTX blink */
234 #define LED_VAL_LINKON                  0x4
235 #define LED_VAL_TX                      0x5
236 #define LED_VAL_RX                      0x6
237 #define LED_VAL_TXRX                    0x7 /* TX or RX */
238 #define LED_VAL_DUPLEXFULL              0x8
239 #define LED_VAL_COLLISION               0x9
240 #define LED_VAL_LINKON_ACTIVE           0xA /* Link on, activity blink */
241 #define LED_VAL_LINKON_RECV             0xB /* Link on, receive blink */
242 #define LED_VAL_DUPLEXFULL_COLLISION    0xC /* Duplex on, collision blink */
243 #define LED_VAL_BLINK                   0xD
244 #define LED_VAL_ON                      0xE
245 #define LED_VAL_OFF                     0xF
246
247 #define LED_LINK_SHIFT                  12
248 #define LED_TXRX_SHIFT                  8
249 #define LED_100TX_SHIFT                 4
250
251 /* MI Register 29 - 31: Reserved Reg(0x1D - 0x1E) */
252
253 /* Defines for PHY access routines */
254
255 /* Define bit operation flags */
256 #define TRUEPHY_BIT_CLEAR               0
257 #define TRUEPHY_BIT_SET                 1
258 #define TRUEPHY_BIT_READ                2
259
260 /* Define read/write operation flags */
261 #ifndef TRUEPHY_READ
262 #define TRUEPHY_READ                    0
263 #define TRUEPHY_WRITE                   1
264 #define TRUEPHY_MASK                    2
265 #endif
266
267 /* Define master/slave configuration values */
268 #define TRUEPHY_CFG_SLAVE               0
269 #define TRUEPHY_CFG_MASTER              1
270
271 /* Define MDI/MDI-X settings */
272 #define TRUEPHY_MDI                     0
273 #define TRUEPHY_MDIX                    1
274 #define TRUEPHY_AUTO_MDI_MDIX           2
275
276 /* Define 10Base-T link polarities */
277 #define TRUEPHY_POLARITY_NORMAL         0
278 #define TRUEPHY_POLARITY_INVERTED       1
279
280 /* Define auto-negotiation results */
281 #define TRUEPHY_ANEG_NOT_COMPLETE       0
282 #define TRUEPHY_ANEG_COMPLETE           1
283 #define TRUEPHY_ANEG_DISABLED           2
284
285 /* Define duplex advertisement flags */
286 #define TRUEPHY_ADV_DUPLEX_NONE         0x00
287 #define TRUEPHY_ADV_DUPLEX_FULL         0x01
288 #define TRUEPHY_ADV_DUPLEX_HALF         0x02
289 #define TRUEPHY_ADV_DUPLEX_BOTH     \
290         (TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF)
291
292 #endif /* _ET1310_PHY_H_ */