xref: /netbsd-src/sys/dev/mii/makphyreg.h (revision 8167a3efd2050237ed4f5255435ed106d2d32b71)
1 /*	$NetBSD: makphyreg.h,v 1.12 2024/02/26 20:20:01 andvar Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _DEV_MII_MAKPHYREG_H_
33 #define	_DEV_MII_MAKPHYREG_H_
34 
35 /*
36  * Marvell 88E1000 ``Alaska'' 10/100/1000 PHY registers.
37  */
38 
39 #define	MAKPHY_PSCR		0x10	/* PHY specific control register */
40 #define	PSCR_DIS_JABBER		(1U << 0)   /* disable jabber */
41 #define	PSCR_POL_REV		(1U << 1)   /* polarity reversal */
42 #define	PSCR_SQE_TEST		(1U << 2)   /* SQE test */
43 #define	PSCR_MBO		(1U << 3)   /* must be one */
44 #define	PSCR_DIS_125CLK		(1U << 4)   /* 125CLK low */
45 #define	PSCR_MDI_XOVER_MODE(x)	((x) << 5)  /* crossover mode */
46 #define	PSCR_LOW_10T_THRESH	(1U << 7)   /* lower 10BASE-T Rx threshold */
47 #define	PSCR_EN_DETECT(x)	((x) << 8)  /* Energy Detect */
48 #define	PSCR_FORCE_LINK_GOOD	(1U << 10)  /* force link good */
49 #define	PSCR_CRS_ON_TX		(1U << 11)  /* assert CRS on transmit */
50 #define	PSCR_RX_FIFO(x)		((x) << 12) /* Rx FIFO depth */
51 #define	PSCR_TX_FIFO(x)		((x) << 14) /* Tx FIFO depth */
52 
53 #define	XOVER_MODE_MDI		0
54 #define	XOVER_MODE_MDIX		1
55 #define	XOVER_MODE_AUTO		2
56 
57 /* 88E3016 */
58 /* bit 2 and 3 are reserved */
59 #define	E3016_PSCR_MDI_XOVER_MODE(x) ((x) << 4)  /* crossover mode */
60 #define	E3016_PSCR_SIGDET_POLARITY (1U << 6)  /* 0: Active H, 1: Active L */
61 #define	E3016_PSCR_EXTDIST	(1U << 7)  /* Enable Extended Distance */
62 #define	E3016_PSCR_FEFI_DIS	(1U << 8)  /* Disable FEFI */
63 #define	E3016_PSCR_SCRAMBLE_DIS	(1U << 9)  /* Disable Scrambler */
64 /* bit 10 is reserved */
65 #define	E3016_PSCR_NLPGEN_DIS	(1U << 11)  /* Disable Linkpulse Generation */
66 #define	E3016_PSCR_REG8NXTPG	(1U << 12)  /* En. Link Partner Next Page R */
67 #define	E3016_PSCR_NLPCHK_DIS	(1U << 13)  /* Disable NLP check */
68 #define	E3016_PSCR_EN_DETECT	(1U << 14)  /* Energy Detect */
69 /* bit 15 is reserved */
70 
71 /* 88E1112 page 1 */
72 #define	MAKPHY_FSCR		0x10	/* Fiber specific control register */
73 #define	FSCR_XMITTER_DIS	0x0008	/* Transmitter Disable */
74 
75 /* 88E1112 page 2 */
76 #define	MAKPHY_MSCR		0x10	/* MAC specific control register */
77 #define	MSCR_TX_FIFODEPTH	0xc000	/* Transmit FIFO Depth */
78 #define	MSCR_RX_FIFODEPTH	0x3000	/* Receive FIFO Depth */
79 #define	MSCR_AUTOPREF_MASK	0x0c00	/* Autoselect preferred media mask */
80 #define	MSCR_AUTOPREF_NO	0x0000	/*  No preference */
81 #define	MSCR_AUTOPREF_FIBER	0x0400	/*  Preferred Fiber */
82 #define	MSCR_AUTOPREF_COPPER	0x0800	/*  Preferred Copper */
83 #define	MSCR_MODE_MASK		0x0380	/* Mode select mask */
84 #define	MSCR_M_100FX		0x0000	/*  100BASE-FX */
85 #define	MSCR_M_COOPER_GBIC	0x0080	/*  Copper GBIC */
86 #define	MSCR_M_AUTO_COPPER_SGMII 0x0100	/*  Auto Copper/SGMII */
87 #define	MSCR_M_AUTO_COPPER_1000X 0x0180	/*  Auto Copper/1000BASE-X */
88 #define	MSCR_M_COPPER		0x0280	/*  Copper only */
89 #define	MSCR_M_SGMII		0x0300	/*  SGMII only */
90 #define	MSCR_M_1000X		0x0380	/*  1000BASE-X only */
91 #define	MSCR_SGMII_PDOWN	0x0008	/* SGMII MAC Interface Power Down */
92 #define	MSCR_ENHANCED_SGMII	0x0004	/* Enhanced SGMII */
93 
94 #define	MAKPHY_PSSR		0x11	/* PHY specific status register */
95 #define	MAKPHY_PSSR_JABBER	(1U << 0)   /* jabber indication */
96 #define	MAKPHY_PSSR_POLARITY	(1U << 1)   /* polarity indiciation */
97 #define	MAKPHY_PSSR_MDIX	(1U << 6)   /* 1 = MIDX, 0 = MDI */
98 #define	MAKPHY_PSSR_CABLE_LENGTH_get(x) (((x) >> 7) & 0x3)
99 #define	MAKPHY_PSSR_LINK	(1U << 10)  /* link indication */
100 #define	MAKPHY_PSSR_RESOLVED	(1U << 11)  /* speed and duplex resolved */
101 #define	MAKPHY_PSSR_PAGE_RECEIVED (1U << 12)  /* page received */
102 #define	MAKPHY_PSSR_DUPLEX	(1U << 13)  /* 1 = FDX */
103 #define	MAKPHY_PSSR_SPEED_get(x) (((x) >> 14) & 0x3)
104 
105 #define	SPEED_10		0
106 #define	SPEED_100		1
107 #define	SPEED_1000		2
108 #define	SPEED_reserved		3
109 
110 /* For 88E1112 */
111 #define	MAKPHY_PSSR_RESOLUTION_FIBER (1U << 7) /*
112 						* Fiber/Copper resolution
113 						* 1 = Fiber, 0 = Copper
114 						*/
115 
116 #define	MAKPHY_IE		0x12	/* Interrupt enable */
117 #define	IE_JABBER		(1U << 0)   /* jabber indication */
118 #define	IE_POL_CHANGED		(1U << 1)   /* polarity changed */
119 #define	IE_MDI_XOVER_CHANGED	(1U << 6)   /* MDI/MDIX changed */
120 #define	IE_FIFO_OVER_UNDER	(1U << 7)   /* FIFO over/underflow */
121 #define	IE_FALSE_CARRIER	(1U << 8)   /* false carrier detected */
122 #define	IE_SYMBOL_ERROR		(1U << 9)   /* symbol error occurred */
123 #define	IE_LINK_CHANGED		(1U << 10)  /* link status changed */
124 #define	IE_ANEG_COMPLETE	(1U << 11)  /* autonegotiation completed */
125 #define	IE_PAGE_RECEIVED	(1U << 12)  /* page received */
126 #define	IE_DUPLEX_CHANGED	(1U << 13)  /* duplex changed */
127 #define	IE_SPEED_CHANGED	(1U << 14)  /* speed changed */
128 #define	IE_ANEG_ERROR		(1U << 15)  /* autonegotiation error occurred */
129 
130 #define	MAKPHY_IS		0x13	/* Interrupt status */
131 	/* See Interrupt enable bits */
132 
133 #define	MAKPHY_EPSC		0x14	/* extended PHY specific control */
134 #define	EPSC_TX_CLK(x)		((x) << 4)  /* transmit clock */
135 #define	EPSC_TBI_RCLK_DIS	(1U << 12)  /* TBI RCLK disable */
136 #define	EPSC_TBI_RX_CLK125_EN	(1U << 13)  /* TBI RX_CLK125 enable */
137 #define	EPSC_LINK_DOWN_NO_IDLES	(1U << 15)  /* 1 = lost lock detect */
138 
139 #define	MAKPHY_REC		0x15	/* receive error counter */
140 
141 #define	MAKPHY_EADR		0x16	/* extended address register */
142 
143 #define	MAKPHY_LEDCTRL	0x18	/* LED control */
144 #define	LEDCTRL_LED_TX		(1U << 0)   /* 1 = activ/link, 0 = xmit */
145 #define	LEDCTRL_LED_RX		(1U << 1)   /* 1 = activ/link, 1 = recv */
146 #define	LEDCTRL_LED_DUPLEX	(1U << 2)   /* 1 = duplex, 0 = dup/coll */
147 #define	LEDCTRL_LED_LINK	(1U << 3)   /* 1 = spd/link, 0 = link */
148 #define	LEDCTRL_BLINK_RATE(x)	((x) << 8)
149 #define	LEDCTRL_PULSE_STRCH(x)	((x) << 12)
150 #define	LEDCTRL_DISABLE		(1U << 15)  /* disable LED */
151 
152 /* For 88E1011, 88E1111 */
153 #define MAKPHY_ESSR		0x1b    /* Extended PHY specific status */
154 #define ESSR_AUTOSEL_DISABLE	0x8000	/* Fiber/Copper autoselect disable */
155 #define ESSR_FIBER_LINK		0x2000	/* Fiber/Copper resolution */
156 #define ESSR_SER_ANEG_BYPASS	0x1000	/* Serial Iface Aneg bypass enable */
157 #define ESSR_SER_ANEG_BYPASS_ST	0x0800	/* Serial Iface Aneg bypass status */
158 #define ESSR_INTR_POLARITY	0x0400	/* Interrupt Polarity */
159 #define ESSR_AUTO_MEDIAREG_SEL	0x0200	/* Auto Medium Register Selection */
160 #define ESSR_DTE_DROP_HYST	0x01e0	/* DTE detect status drop hysteresis */
161 #define ESSR_DTE_POWER		0x0010
162 #define ESSR_HWCFG_MODE		0x000f
163 #define ESSR_SGMII_WC_COPPER	 0x0000 /* SGMII w/ Clock w/ SGMII AN Copper */
164 #define ESSR_RTBI_FIBER		 0x0001 /* RTBI to Fiber */
165 #define ESSR_RGMII_FIBER	 0x0003 /* RGMII to Fiber */
166 #define ESSR_SGMII_WOC_COPPER	 0x0004 /* SGMII w/o Clock w/ SGMII AN Copp. */
167 #define ESSR_TBI_FIBER		 0x0005 /* TBI to Fiber */
168 #define ESSR_RGMII_SGMII	 0x0006 /* RGMII to SGMII */
169 #define ESSR_GMII_FIBER		 0x0007 /* GMII to Fiber */
170 #define ESSR_SERIAL_WAN		 0x0008 /* 88E1011: Serial w 1000KX AN */
171 #define ESSR_GBIC		 0x0008 /* 88E1111: GBIC */
172 #define ESSR_RTBI_COPPER	 0x0009 /* RTBI to Copper */
173 #define ESSR_RGMII_COPPER	 0x000b /* RGMII to Copper */
174 #define ESSR_RGMII_AUTOSEL	 0x000b /* RGMII with Auto-Selection */
175 #define ESSR_SERIAL_WOAN	 0x000c /* 88E1011: Serial w/o 1000KX AN */
176 #define ESSR_1000X_WOAN		 0x000c /* 88E1111: 1000X w/o AN Copper */
177 #define ESSR_TBI_COPPER		 0x000d /* TBI to Copper */
178 #define ESSR_GMII_SGMII		 0x000e /* GMII to SGMII */
179 #define ESSR_GMII_COPPER	 0x000f /* GMII to Copper */
180 #define ESSR_GMII_AUTOSEL	 0x000f /* GMII with Auto-Selection */
181 
182 #endif /* _DEV_MII_MAKPHYREG_H_ */
183