• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /********************************************************************************
2 Copyright (C) 2016 Marvell International Ltd.
3 
4 Marvell BSD License Option
5 
6 If you received this File from Marvell, you may opt to use, redistribute and/or
7 modify this File under the following licensing terms.
8 Redistribution and use in source and binary forms, with or without modification,
9 are permitted provided that the following conditions are met:
10 
11   * Redistributions of source code must retain the above copyright notice,
12     this list of conditions and the following disclaimer.
13 
14   * Redistributions in binary form must reproduce the above copyright
15     notice, this list of conditions and the following disclaimer in the
16     documentation and/or other materials provided with the distribution.
17 
18   * Neither the name of Marvell nor the names of its contributors may be
19     used to endorse or promote products derived from this software without
20     specific prior written permission.
21 
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 *******************************************************************************/
34 #ifndef __MV_PHY_DXE_H__
35 #define __MV_PHY_DXE_H__
36 
37 #define MII_BMCR      0x00  /* Basic mode control Register */
38 #define MII_BMSR      0x01  /* Basic mode status Register  */
39 #define MII_PHYSID1      0x02  /* PHYS ID 1           */
40 #define MII_PHYSID2      0x03  /* PHYS ID 2           */
41 #define MII_ADVERTISE      0x04  /* Advertisement control Reg   */
42 #define MII_LPA        0x05  /* Link partner ability Reg    */
43 #define MII_EXPANSION      0x06  /* Expansion Register         */
44 #define MII_CTRL1000      0x09  /* 1000BASE-T control         */
45 #define MII_STAT1000      0x0a  /* 1000BASE-T status         */
46 #define MII_ESTATUS      0x0f  /* Extended Status */
47 #define MII_DCOUNTER      0x12  /* Disconnect counter         */
48 #define MII_FCSCOUNTER      0x13  /* False carrier counter       */
49 #define MII_NWAYTEST      0x14  /* N-way auto-neg test Reg     */
50 #define MII_RERRCOUNTER     0x15  /* Receive error counter       */
51 #define MII_SREVISION      0x16  /* Silicon revision         */
52 #define MII_RESV1      0x17  /* Reserved...           */
53 #define MII_LBRERROR      0x18  /* Lpback, rx, bypass error    */
54 #define MII_PHYADDR      0x19  /* PHY address           */
55 #define MII_RESV2      0x1a  /* Reserved...           */
56 #define MII_TPISTATUS      0x1b  /* TPI status for 10mbps       */
57 #define MII_NCONFIG      0x1c  /* Network interface config    */
58 
59 /* Basic mode control Register. */
60 #define BMCR_RESV    0x003f  /* Unused...           */
61 #define BMCR_SPEED1000    0x0040  /* MSB of Speed (1000)         */
62 #define BMCR_CTST    0x0080  /* Collision test         */
63 #define BMCR_FULLDPLX    0x0100  /* Full duplex           */
64 #define BMCR_ANRESTART    0x0200  /* Auto negotiation restart    */
65 #define BMCR_ISOLATE    0x0400  /* Disconnect DP83840 from MII */
66 #define BMCR_PDOWN    0x0800  /* Powerdown the DP83840       */
67 #define BMCR_ANENABLE    0x1000  /* Enable auto negotiation     */
68 #define BMCR_SPEED100    0x2000  /* Select 100Mbps         */
69 #define BMCR_LOOPBACK    0x4000  /* TXD loopback bits         */
70 #define BMCR_RESET    0x8000  /* Reset the DP83840         */
71 
72 /* Basic mode status Register. */
73 #define BMSR_ERCAP    0x0001  /* Ext-Reg capability         */
74 #define BMSR_JCD    0x0002  /* Jabber detected         */
75 #define BMSR_LSTATUS    0x0004  /* Link status           */
76 #define BMSR_ANEGCAPABLE  0x0008  /* Able to do auto-negotiation */
77 #define BMSR_RFAULT    0x0010  /* Remote fault detected       */
78 #define BMSR_ANEGCOMPLETE  0x0020  /* Auto-negotiation complete   */
79 #define BMSR_RESV    0x00c0  /* Unused...           */
80 #define BMSR_ESTATEN    0x0100  /* Extended Status in R15 */
81 #define BMSR_100HALF2    0x0200  /* Can do 100BASE-T2 HDX */
82 #define BMSR_100FULL2    0x0400  /* Can do 100BASE-T2 FDX */
83 #define BMSR_10HALF    0x0800  /* Can do 10mbps, half-duplex  */
84 #define BMSR_10FULL    0x1000  /* Can do 10mbps, full-duplex  */
85 #define BMSR_100HALF    0x2000  /* Can do 100mbps, half-duplex */
86 #define BMSR_100FULL    0x4000  /* Can do 100mbps, full-duplex */
87 #define BMSR_100BASE4    0x8000  /* Can do 100mbps, 4k packets  */
88 
89 #define PHY_ANEG_TIMEOUT 4000
90 
91 #define PHY_INTERFACE_MODE_RGMII 0
92 #define PHY_INTERFACE_MODE_RGMII_ID 1
93 #define PHY_INTERFACE_MODE_RGMII_RXID 2
94 #define PHY_INTERFACE_MODE_RGMII_TXID 3
95 #define PHY_INTERFACE_MODE_SGMII 4
96 #define PHY_INTERFACE_MODE_RTBI 5
97 
98 #define PHY_AUTONEGOTIATE_TIMEOUT 5000
99 
100 /* 88E1011 PHY Status Register */
101 #define MIIM_88E1xxx_PHY_STATUS    0x11
102 #define MIIM_88E1xxx_PHYSTAT_SPEED  0xc000
103 #define MIIM_88E1xxx_PHYSTAT_GBIT  0x8000
104 #define MIIM_88E1xxx_PHYSTAT_100  0x4000
105 #define MIIM_88E1xxx_PHYSTAT_DUPLEX  0x2000
106 #define MIIM_88E1xxx_PHYSTAT_SPDDONE  0x0800
107 #define MIIM_88E1xxx_PHYSTAT_LINK  0x0400
108 
109 #define MIIM_88E1xxx_PHY_SCR    0x10
110 #define MIIM_88E1xxx_PHY_MDI_X_AUTO  0x0060
111 
112 /* 88E1111 PHY LED Control Register */
113 #define MIIM_88E1111_PHY_LED_CONTROL  24
114 #define MIIM_88E1111_PHY_LED_DIRECT  0x4100
115 #define MIIM_88E1111_PHY_LED_COMBINE  0x411C
116 
117 /* 88E1111 Extended PHY Specific Control Register */
118 #define MIIM_88E1111_PHY_EXT_CR    0x14
119 #define MIIM_88E1111_RX_DELAY    0x80
120 #define MIIM_88E1111_TX_DELAY    0x2
121 
122 /* 88E1111 Extended PHY Specific Status Register */
123 #define MIIM_88E1111_PHY_EXT_SR    0x1b
124 #define MIIM_88E1111_HWCFG_MODE_MASK    0xf
125 #define MIIM_88E1111_HWCFG_MODE_COPPER_RGMII  0xb
126 #define MIIM_88E1111_HWCFG_MODE_FIBER_RGMII  0x3
127 #define MIIM_88E1111_HWCFG_MODE_SGMII_NO_CLK  0x4
128 #define MIIM_88E1111_HWCFG_MODE_COPPER_RTBI  0x9
129 #define MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO  0x8000
130 #define MIIM_88E1111_HWCFG_FIBER_COPPER_RES  0x2000
131 
132 #define MIIM_88E1111_COPPER    0
133 #define MIIM_88E1111_FIBER    1
134 
135 /* 88E1118 PHY defines */
136 #define MIIM_88E1118_PHY_PAGE    22
137 #define MIIM_88E1118_PHY_LED_PAGE  3
138 
139 /* 88E1121 PHY LED Control Register */
140 #define MIIM_88E1121_PHY_LED_CTRL  16
141 #define MIIM_88E1121_PHY_LED_PAGE  3
142 #define MIIM_88E1121_PHY_LED_DEF  0x0030
143 
144 /* 88E1121 PHY IRQ Enable/Status Register */
145 #define MIIM_88E1121_PHY_IRQ_EN    18
146 #define MIIM_88E1121_PHY_IRQ_STATUS  19
147 
148 #define MIIM_88E1121_PHY_PAGE    22
149 
150 /* 88E1145 Extended PHY Specific Control Register */
151 #define MIIM_88E1145_PHY_EXT_CR 20
152 #define MIIM_M88E1145_RGMII_RX_DELAY  0x0080
153 #define MIIM_M88E1145_RGMII_TX_DELAY  0x0002
154 
155 #define MIIM_88E1145_PHY_LED_CONTROL  24
156 #define MIIM_88E1145_PHY_LED_DIRECT  0x4100
157 
158 #define MIIM_88E1145_PHY_PAGE  29
159 #define MIIM_88E1145_PHY_CAL_OV 30
160 
161 #define MIIM_88E1149_PHY_PAGE  29
162 
163 /* 88E1310 PHY defines */
164 #define MIIM_88E1310_PHY_LED_CTRL  16
165 #define MIIM_88E1310_PHY_IRQ_EN    18
166 #define MIIM_88E1310_PHY_RGMII_CTRL  21
167 #define MIIM_88E1310_PHY_PAGE    22
168 
169 typedef enum {
170   MV_PHY_DEVICE_1512
171 } MV_PHY_DEVICE_ID;
172 
173 typedef
174 EFI_STATUS
175 (*MV_PHY_DEVICE_INIT) (
176     IN CONST MARVELL_PHY_PROTOCOL *Snp,
177     IN UINT32 PhyAddr,
178     IN OUT PHY_DEVICE *PhyDev
179     );
180 
181 typedef struct {
182   MV_PHY_DEVICE_ID DevId;
183   MV_PHY_DEVICE_INIT DevInit;
184 } MV_PHY_DEVICE;
185 
186 STATIC
187 EFI_STATUS
188 MvPhyInit1512 (
189     IN CONST MARVELL_PHY_PROTOCOL *Snp,
190     IN UINT32 PhyAddr,
191     IN OUT PHY_DEVICE *PhyDev
192     );
193 
194 #endif
195