xref: /onnv-gate/usr/src/uts/common/io/chxge/com/pm3393.c (revision 3833:45d8d0ee8613)
1*3833Sxw161283 /*
2*3833Sxw161283  * CDDL HEADER START
3*3833Sxw161283  *
4*3833Sxw161283  * The contents of this file are subject to the terms of the
5*3833Sxw161283  * Common Development and Distribution License (the "License").
6*3833Sxw161283  * You may not use this file except in compliance with the License.
7*3833Sxw161283  *
8*3833Sxw161283  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*3833Sxw161283  * or http://www.opensolaris.org/os/licensing.
10*3833Sxw161283  * See the License for the specific language governing permissions
11*3833Sxw161283  * and limitations under the License.
12*3833Sxw161283  *
13*3833Sxw161283  * When distributing Covered Code, include this CDDL HEADER in each
14*3833Sxw161283  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*3833Sxw161283  * If applicable, add the following below this CDDL HEADER, with the
16*3833Sxw161283  * fields enclosed by brackets "[]" replaced with your own identifying
17*3833Sxw161283  * information: Portions Copyright [yyyy] [name of copyright owner]
18*3833Sxw161283  *
19*3833Sxw161283  * CDDL HEADER END
20*3833Sxw161283  */
21*3833Sxw161283 
22*3833Sxw161283 /*
23*3833Sxw161283  * Copyright (C) 2003-2005 Chelsio Communications.  All rights reserved.
24*3833Sxw161283  */
25*3833Sxw161283 
26*3833Sxw161283 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* pm3393.c */
27*3833Sxw161283 
28*3833Sxw161283 #include "common.h"
29*3833Sxw161283 #include "regs.h"
30*3833Sxw161283 #include "gmac.h"
31*3833Sxw161283 #include "elmer0.h"
32*3833Sxw161283 #include "suni1x10gexp_regs.h"
33*3833Sxw161283 
34*3833Sxw161283 /* 802.3ae 10Gb/s MDIO Manageable Device(MMD)
35*3833Sxw161283  */
36*3833Sxw161283 #define MMD_RESERVED        0
37*3833Sxw161283 #define MMD_PMAPMD          1
38*3833Sxw161283 #define MMD_WIS             2
39*3833Sxw161283 #define MMD_PCS             3
40*3833Sxw161283 #define MMD_PHY_XGXS        4	/* XGMII Extender Sublayer */
41*3833Sxw161283 #define MMD_DTE_XGXS        5
42*3833Sxw161283 
43*3833Sxw161283 #define PHY_XGXS_CTRL_1     0
44*3833Sxw161283 #define PHY_XGXS_STATUS_1   1
45*3833Sxw161283 
46*3833Sxw161283 #define OFFSET(REG_ADDR)    (REG_ADDR << 2)
47*3833Sxw161283 
48*3833Sxw161283 /* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
49*3833Sxw161283 #define MAX_FRAME_SIZE  9600
50*3833Sxw161283 
51*3833Sxw161283 #define IPG 12
52*3833Sxw161283 #define TXXG_CONF1_VAL ((IPG << SUNI1x10GEXP_BITOFF_TXXG_IPGT) | \
53*3833Sxw161283     SUNI1x10GEXP_BITMSK_TXXG_32BIT_ALIGN | SUNI1x10GEXP_BITMSK_TXXG_CRCEN | \
54*3833Sxw161283     SUNI1x10GEXP_BITMSK_TXXG_PADEN)
55*3833Sxw161283 #define RXXG_CONF1_VAL (SUNI1x10GEXP_BITMSK_RXXG_PUREP | 0x14 | \
56*3833Sxw161283     SUNI1x10GEXP_BITMSK_RXXG_FLCHK | SUNI1x10GEXP_BITMSK_RXXG_CRC_STRIP)
57*3833Sxw161283 
58*3833Sxw161283 /* Update statistics every 15 minutes */
59*3833Sxw161283 #define STATS_TICK_SECS (15 * 60)
60*3833Sxw161283 
61*3833Sxw161283 enum {                     /* RMON registers */
62*3833Sxw161283 	RxOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW,
63*3833Sxw161283 	RxUnicastFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_4_LOW,
64*3833Sxw161283 	RxMulticastFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_5_LOW,
65*3833Sxw161283 	RxBroadcastFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_6_LOW,
66*3833Sxw161283 	RxPAUSEMACCtrlFramesReceived = SUNI1x10GEXP_REG_MSTAT_COUNTER_8_LOW,
67*3833Sxw161283 	RxFrameCheckSequenceErrors = SUNI1x10GEXP_REG_MSTAT_COUNTER_10_LOW,
68*3833Sxw161283 	RxFramesLostDueToInternalMACErrors = SUNI1x10GEXP_REG_MSTAT_COUNTER_11_LOW,
69*3833Sxw161283 	RxSymbolErrors = SUNI1x10GEXP_REG_MSTAT_COUNTER_12_LOW,
70*3833Sxw161283 	RxInRangeLengthErrors = SUNI1x10GEXP_REG_MSTAT_COUNTER_13_LOW,
71*3833Sxw161283 	RxFramesTooLongErrors = SUNI1x10GEXP_REG_MSTAT_COUNTER_15_LOW,
72*3833Sxw161283 	RxJabbers = SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW,
73*3833Sxw161283 	RxFragments = SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW,
74*3833Sxw161283 	RxUndersizedFrames =  SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW,
75*3833Sxw161283 	RxJumboFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_25_LOW,
76*3833Sxw161283 	RxJumboOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_26_LOW,
77*3833Sxw161283 
78*3833Sxw161283 	TxOctetsTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW,
79*3833Sxw161283 	TxFramesLostDueToInternalMACTransmissionError = SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW,
80*3833Sxw161283 	TxTransmitSystemError = SUNI1x10GEXP_REG_MSTAT_COUNTER_36_LOW,
81*3833Sxw161283 	TxUnicastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW,
82*3833Sxw161283 	TxMulticastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW,
83*3833Sxw161283 	TxBroadcastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW,
84*3833Sxw161283 	TxPAUSEMACCtrlFramesTransmitted = SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW,
85*3833Sxw161283 	TxJumboFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_51_LOW,
86*3833Sxw161283 	TxJumboOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_52_LOW
87*3833Sxw161283 };
88*3833Sxw161283 
89*3833Sxw161283 struct _cmac_instance {
90*3833Sxw161283 	u8 enabled;
91*3833Sxw161283 	u8 fc;
92*3833Sxw161283 	u8 mac_addr[6];
93*3833Sxw161283 };
94*3833Sxw161283 
pmread(struct cmac * cmac,u32 reg,u32 * data32)95*3833Sxw161283 static int pmread(struct cmac *cmac, u32 reg, u32 * data32)
96*3833Sxw161283 {
97*3833Sxw161283 	(void) t1_tpi_read(cmac->adapter, OFFSET(reg), data32);
98*3833Sxw161283 	return 0;
99*3833Sxw161283 }
100*3833Sxw161283 
pmwrite(struct cmac * cmac,u32 reg,u32 data32)101*3833Sxw161283 static int pmwrite(struct cmac *cmac, u32 reg, u32 data32)
102*3833Sxw161283 {
103*3833Sxw161283 	(void) t1_tpi_write(cmac->adapter, OFFSET(reg), data32);
104*3833Sxw161283 	return 0;
105*3833Sxw161283 }
106*3833Sxw161283 
107*3833Sxw161283 /* Port reset. */
108*3833Sxw161283 /* ARGSUSED */
pm3393_reset(struct cmac * cmac)109*3833Sxw161283 static int pm3393_reset(struct cmac *cmac)
110*3833Sxw161283 {
111*3833Sxw161283 	return 0;
112*3833Sxw161283 }
113*3833Sxw161283 
114*3833Sxw161283 /*
115*3833Sxw161283  * Enable interrupts for the PM3393
116*3833Sxw161283 
117*3833Sxw161283     1. Enable PM3393 BLOCK interrupts.
118*3833Sxw161283     2. Enable PM3393 Master Interrupt bit(INTE)
119*3833Sxw161283     3. Enable ELMER's PM3393 bit.
120*3833Sxw161283     4. Enable Terminator external interrupt.
121*3833Sxw161283 */
pm3393_interrupt_enable(struct cmac * cmac)122*3833Sxw161283 static int pm3393_interrupt_enable(struct cmac *cmac)
123*3833Sxw161283 {
124*3833Sxw161283 #if 0
125*3833Sxw161283 	u32 elmer;
126*3833Sxw161283 #endif
127*3833Sxw161283 	u32 pl_intr;
128*3833Sxw161283 
129*3833Sxw161283 	/* PM3393 - Enabling all hardware block interrupts.
130*3833Sxw161283 	 */
131*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_ENABLE, 0xffff);
132*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_XRF_INTERRUPT_ENABLE, 0xffff);
133*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_ENABLE, 0xffff);
134*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXOAM_INTERRUPT_ENABLE, 0xffff);
135*3833Sxw161283 
136*3833Sxw161283 	/* Don't interrupt on statistics overflow, we are polling */
137*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_0, 0);
138*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_1, 0);
139*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_2, 0);
140*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_3, 0);
141*3833Sxw161283 
142*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_ENABLE, 0xffff);
143*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_PL4ODP_INTERRUPT_MASK, 0xffff);
144*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_XTEF_INTERRUPT_ENABLE, 0xffff);
145*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXOAM_INTERRUPT_ENABLE, 0xffff);
146*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_CONFIG_3, 0xffff);
147*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_MASK, 0xffff);
148*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_CONFIG_3, 0xffff);
149*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_PL4IDU_INTERRUPT_MASK, 0xffff);
150*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_ENABLE, 0xffff);
151*3833Sxw161283 
152*3833Sxw161283 	/* PM3393 - Global interrupt enable
153*3833Sxw161283 	 */
154*3833Sxw161283 	/* TBD XXX Disable for now until we figure out why error interrupts keep asserting. */
155*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_GLOBAL_INTERRUPT_ENABLE,
156*3833Sxw161283 		0 /*SUNI1x10GEXP_BITMSK_TOP_INTE */ );
157*3833Sxw161283 
158*3833Sxw161283 #if 0
159*3833Sxw161283 	/* ELMER - External chip interrupts.
160*3833Sxw161283 	 */
161*3833Sxw161283 	(void) t1_tpi_read(cmac->adapter, A_ELMER0_INT_ENABLE, &elmer);
162*3833Sxw161283 	elmer |= ELMER0_GP_BIT1;
163*3833Sxw161283 	(void) t1_tpi_write(cmac->adapter, A_ELMER0_INT_ENABLE, elmer);
164*3833Sxw161283 #endif
165*3833Sxw161283 
166*3833Sxw161283 	/* TERMINATOR - PL_INTERUPTS_EXT */
167*3833Sxw161283 	pl_intr = t1_read_reg_4(cmac->adapter, A_PL_ENABLE);
168*3833Sxw161283 	pl_intr |= F_PL_INTR_EXT;
169*3833Sxw161283 	t1_write_reg_4(cmac->adapter, A_PL_ENABLE, pl_intr);
170*3833Sxw161283 	return 0;
171*3833Sxw161283 }
172*3833Sxw161283 
pm3393_interrupt_disable(struct cmac * cmac)173*3833Sxw161283 static int pm3393_interrupt_disable(struct cmac *cmac)
174*3833Sxw161283 {
175*3833Sxw161283 	u32 elmer;
176*3833Sxw161283 
177*3833Sxw161283 	/* PM3393 - Enabling HW interrupt blocks. */
178*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_ENABLE, 0);
179*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_XRF_INTERRUPT_ENABLE, 0);
180*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_ENABLE, 0);
181*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXOAM_INTERRUPT_ENABLE, 0);
182*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_0, 0);
183*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_1, 0);
184*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_2, 0);
185*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_3, 0);
186*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_ENABLE, 0);
187*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_PL4ODP_INTERRUPT_MASK, 0);
188*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_XTEF_INTERRUPT_ENABLE, 0);
189*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXOAM_INTERRUPT_ENABLE, 0);
190*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_CONFIG_3, 0);
191*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_MASK, 0);
192*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_CONFIG_3, 0);
193*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_PL4IDU_INTERRUPT_MASK, 0);
194*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_ENABLE, 0);
195*3833Sxw161283 
196*3833Sxw161283 	/* PM3393 - Global interrupt enable */
197*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_GLOBAL_INTERRUPT_ENABLE, 0);
198*3833Sxw161283 
199*3833Sxw161283 	/* ELMER - External chip interrupts. */
200*3833Sxw161283 	(void) t1_tpi_read(cmac->adapter, A_ELMER0_INT_ENABLE, &elmer);
201*3833Sxw161283 	elmer &= ~ELMER0_GP_BIT1;
202*3833Sxw161283 	(void) t1_tpi_write(cmac->adapter, A_ELMER0_INT_ENABLE, elmer);
203*3833Sxw161283 
204*3833Sxw161283 	/* TERMINATOR - PL_INTERUPTS_EXT */
205*3833Sxw161283 	/* DO NOT DISABLE TERMINATOR's EXTERNAL INTERRUPTS. ANOTHER CHIP
206*3833Sxw161283 	 * COULD WANT THEM ENABLED. We disable PM3393 at the ELMER level.
207*3833Sxw161283 	 */
208*3833Sxw161283 
209*3833Sxw161283 	return 0;
210*3833Sxw161283 }
211*3833Sxw161283 
pm3393_interrupt_clear(struct cmac * cmac)212*3833Sxw161283 static int pm3393_interrupt_clear(struct cmac *cmac)
213*3833Sxw161283 {
214*3833Sxw161283 	u32 elmer;
215*3833Sxw161283 	u32 pl_intr;
216*3833Sxw161283 	u32 val32;
217*3833Sxw161283 
218*3833Sxw161283 	/* PM3393 - Clearing HW interrupt blocks. Note, this assumes
219*3833Sxw161283 	 *          bit WCIMODE=0 for a clear-on-read.
220*3833Sxw161283 	 */
221*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_STATUS, &val32);
222*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_XRF_INTERRUPT_STATUS, &val32);
223*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_STATUS, &val32);
224*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_RXOAM_INTERRUPT_STATUS, &val32);
225*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_PL4ODP_INTERRUPT, &val32);
226*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_XTEF_INTERRUPT_STATUS, &val32);
227*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_INTERRUPT, &val32);
228*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_TXOAM_INTERRUPT_STATUS, &val32);
229*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_RXXG_INTERRUPT, &val32);
230*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_TXXG_INTERRUPT, &val32);
231*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_PL4IDU_INTERRUPT, &val32);
232*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_INDICATION,
233*3833Sxw161283 	       &val32);
234*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_STATUS, &val32);
235*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_CHANGE, &val32);
236*3833Sxw161283 
237*3833Sxw161283 	/* PM3393 - Global interrupt status
238*3833Sxw161283 	 */
239*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS, &val32);
240*3833Sxw161283 
241*3833Sxw161283 	/* ELMER - External chip interrupts.
242*3833Sxw161283 	 */
243*3833Sxw161283 	(void) t1_tpi_read(cmac->adapter, A_ELMER0_INT_CAUSE, &elmer);
244*3833Sxw161283 	elmer |= ELMER0_GP_BIT1;
245*3833Sxw161283 	(void) t1_tpi_write(cmac->adapter, A_ELMER0_INT_CAUSE, elmer);
246*3833Sxw161283 
247*3833Sxw161283 	/* TERMINATOR - PL_INTERUPTS_EXT
248*3833Sxw161283 	 */
249*3833Sxw161283 	pl_intr = t1_read_reg_4(cmac->adapter, A_PL_CAUSE);
250*3833Sxw161283 	pl_intr |= F_PL_INTR_EXT;
251*3833Sxw161283 	t1_write_reg_4(cmac->adapter, A_PL_CAUSE, pl_intr);
252*3833Sxw161283 
253*3833Sxw161283 	return 0;
254*3833Sxw161283 }
255*3833Sxw161283 
256*3833Sxw161283 /* Interrupt handler */
pm3393_interrupt_handler(struct cmac * cmac)257*3833Sxw161283 static int pm3393_interrupt_handler(struct cmac *cmac)
258*3833Sxw161283 {
259*3833Sxw161283 	u32 master_intr_status;
260*3833Sxw161283 /*
261*3833Sxw161283     1. Read master interrupt register.
262*3833Sxw161283     2. Read BLOCK's interrupt status registers.
263*3833Sxw161283     3. Handle BLOCK interrupts.
264*3833Sxw161283 */
265*3833Sxw161283 	/* Read the master interrupt status register. */
266*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS,
267*3833Sxw161283 	       &master_intr_status);
268*3833Sxw161283 	CH_DBG(cmac->adapter, INTR, "PM3393 intr cause 0x%x\n",
269*3833Sxw161283 	       master_intr_status);
270*3833Sxw161283 
271*3833Sxw161283 	/* Handle BLOCK's interrupts. */
272*3833Sxw161283 
273*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_PL4IO_INT & master_intr_status) {
274*3833Sxw161283 		/* EMPTY */
275*3833Sxw161283 	}
276*3833Sxw161283 
277*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_IRAM_INT & master_intr_status) {
278*3833Sxw161283 		/* EMPTY */
279*3833Sxw161283 	}
280*3833Sxw161283 
281*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_ERAM_INT & master_intr_status) {
282*3833Sxw161283 		/* EMPTY */
283*3833Sxw161283 	}
284*3833Sxw161283 
285*3833Sxw161283 	/* SERDES */
286*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_XAUI_INT & master_intr_status) {
287*3833Sxw161283 		/* EMPTY */
288*3833Sxw161283 	}
289*3833Sxw161283 
290*3833Sxw161283 	/* MSTAT */
291*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_MSTAT_INT & master_intr_status) {
292*3833Sxw161283 		/* EMPTY */
293*3833Sxw161283 	}
294*3833Sxw161283 
295*3833Sxw161283 	/* RXXG */
296*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_RXXG_INT & master_intr_status) {
297*3833Sxw161283 		/* EMPTY */
298*3833Sxw161283 	}
299*3833Sxw161283 
300*3833Sxw161283 	/* TXXG */
301*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_TXXG_INT & master_intr_status) {
302*3833Sxw161283 		/* EMPTY */
303*3833Sxw161283 	}
304*3833Sxw161283 
305*3833Sxw161283 	/* XRF */
306*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_XRF_INT & master_intr_status) {
307*3833Sxw161283 		/* EMPTY */
308*3833Sxw161283 	}
309*3833Sxw161283 
310*3833Sxw161283 	/* XTEF */
311*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_XTEF_INT & master_intr_status) {
312*3833Sxw161283 		/* EMPTY */
313*3833Sxw161283 	}
314*3833Sxw161283 
315*3833Sxw161283 	/* MDIO */
316*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_MDIO_BUSY_INT & master_intr_status) {
317*3833Sxw161283 		/* Not used. 8000 uses MDIO through Elmer. */
318*3833Sxw161283 		/* EMPTY */
319*3833Sxw161283 	}
320*3833Sxw161283 
321*3833Sxw161283 	/* RXOAM */
322*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_RXOAM_INT & master_intr_status) {
323*3833Sxw161283 		/* EMPTY */
324*3833Sxw161283 	}
325*3833Sxw161283 
326*3833Sxw161283 	/* TXOAM */
327*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_TXOAM_INT & master_intr_status) {
328*3833Sxw161283 		/* EMPTY */
329*3833Sxw161283 	}
330*3833Sxw161283 
331*3833Sxw161283 	/* IFLX */
332*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_IFLX_INT & master_intr_status) {
333*3833Sxw161283 		/* EMPTY */
334*3833Sxw161283 	}
335*3833Sxw161283 
336*3833Sxw161283 	/* EFLX */
337*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_EFLX_INT & master_intr_status) {
338*3833Sxw161283 		/* EMPTY */
339*3833Sxw161283 	}
340*3833Sxw161283 
341*3833Sxw161283 	/* PL4ODP */
342*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_PL4ODP_INT & master_intr_status) {
343*3833Sxw161283 		/* EMPTY */
344*3833Sxw161283 	}
345*3833Sxw161283 
346*3833Sxw161283 	/* PL4IDU */
347*3833Sxw161283 	if (SUNI1x10GEXP_BITMSK_TOP_PL4IDU_INT & master_intr_status) {
348*3833Sxw161283 		/* EMPTY */
349*3833Sxw161283 	}
350*3833Sxw161283 
351*3833Sxw161283 	/* TBD XXX Lets just clear everything for now */
352*3833Sxw161283 	(void) pm3393_interrupt_clear(cmac);
353*3833Sxw161283 
354*3833Sxw161283 	return 0;
355*3833Sxw161283 }
356*3833Sxw161283 
pm3393_enable(struct cmac * cmac,int which)357*3833Sxw161283 static int pm3393_enable(struct cmac *cmac, int which)
358*3833Sxw161283 {
359*3833Sxw161283 	if (which & MAC_DIRECTION_RX)
360*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_CONFIG_1,
361*3833Sxw161283 			(RXXG_CONF1_VAL | SUNI1x10GEXP_BITMSK_RXXG_RXEN));
362*3833Sxw161283 
363*3833Sxw161283 	if (which & MAC_DIRECTION_TX) {
364*3833Sxw161283 		u32 val = TXXG_CONF1_VAL | SUNI1x10GEXP_BITMSK_TXXG_TXEN0;
365*3833Sxw161283 
366*3833Sxw161283 		if (cmac->instance->fc & PAUSE_RX)
367*3833Sxw161283 			val |= SUNI1x10GEXP_BITMSK_TXXG_FCRX;
368*3833Sxw161283 		if (cmac->instance->fc & PAUSE_TX)
369*3833Sxw161283 			val |= SUNI1x10GEXP_BITMSK_TXXG_FCTX;
370*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_CONFIG_1, val);
371*3833Sxw161283 	}
372*3833Sxw161283 
373*3833Sxw161283 	cmac->instance->enabled |= which;
374*3833Sxw161283 	return 0;
375*3833Sxw161283 }
376*3833Sxw161283 
377*3833Sxw161283 /* ARGSUSED */
pm3393_enable_port(struct cmac * cmac,int which)378*3833Sxw161283 static int pm3393_enable_port(struct cmac *cmac, int which)
379*3833Sxw161283 {
380*3833Sxw161283 	/* Clear port statistics */
381*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_MSTAT_CONTROL,
382*3833Sxw161283 		SUNI1x10GEXP_BITMSK_MSTAT_CLEAR);
383*3833Sxw161283 	DELAY_US(2);
384*3833Sxw161283 	(void) memset(&cmac->stats, 0, sizeof(struct cmac_statistics));
385*3833Sxw161283 
386*3833Sxw161283 	(void) pm3393_enable(cmac, which);
387*3833Sxw161283 
388*3833Sxw161283 	/*
389*3833Sxw161283 	 * XXX This should be done by the PHY and preferrably not at all.
390*3833Sxw161283 	 * The PHY doesn't give us link status indication on its own so have
391*3833Sxw161283 	 * the link management code query it instead.
392*3833Sxw161283 	 */
393*3833Sxw161283 	{
394*3833Sxw161283 		extern void link_changed(adapter_t *adapter, int port_id);
395*3833Sxw161283 		link_changed(cmac->adapter, 0);
396*3833Sxw161283 	}
397*3833Sxw161283 	return 0;
398*3833Sxw161283 }
399*3833Sxw161283 
pm3393_disable(struct cmac * cmac,int which)400*3833Sxw161283 static int pm3393_disable(struct cmac *cmac, int which)
401*3833Sxw161283 {
402*3833Sxw161283 	if (which & MAC_DIRECTION_RX)
403*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_CONFIG_1, RXXG_CONF1_VAL);
404*3833Sxw161283 	if (which & MAC_DIRECTION_TX)
405*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_CONFIG_1, TXXG_CONF1_VAL);
406*3833Sxw161283 
407*3833Sxw161283 	/*
408*3833Sxw161283 	 * The disable is graceful. Give the PM3393 time.  Can't wait very
409*3833Sxw161283 	 * long here, we may be holding locks.
410*3833Sxw161283 	 */
411*3833Sxw161283 	DELAY_US(20);
412*3833Sxw161283 
413*3833Sxw161283 	cmac->instance->enabled &= ~which;
414*3833Sxw161283 	return 0;
415*3833Sxw161283 }
416*3833Sxw161283 
417*3833Sxw161283 /* ARGSUSED */
pm3393_loopback_enable(struct cmac * cmac)418*3833Sxw161283 static int pm3393_loopback_enable(struct cmac *cmac)
419*3833Sxw161283 {
420*3833Sxw161283 	return 0;
421*3833Sxw161283 }
422*3833Sxw161283 
423*3833Sxw161283 /* ARGSUSED */
pm3393_loopback_disable(struct cmac * cmac)424*3833Sxw161283 static int pm3393_loopback_disable(struct cmac *cmac)
425*3833Sxw161283 {
426*3833Sxw161283 	return 0;
427*3833Sxw161283 }
428*3833Sxw161283 
pm3393_set_mtu(struct cmac * cmac,int mtu)429*3833Sxw161283 static int pm3393_set_mtu(struct cmac *cmac, int mtu)
430*3833Sxw161283 {
431*3833Sxw161283 	int enabled = cmac->instance->enabled;
432*3833Sxw161283 
433*3833Sxw161283 	/* MAX_FRAME_SIZE includes header + FCS, mtu doesn't */
434*3833Sxw161283 	mtu += 14 + 4;
435*3833Sxw161283 	if (mtu > MAX_FRAME_SIZE)
436*3833Sxw161283 		return -EINVAL;
437*3833Sxw161283 
438*3833Sxw161283 	/* Disable Rx/Tx MAC before configuring it. */
439*3833Sxw161283 	if (enabled)
440*3833Sxw161283 		(void) pm3393_disable(cmac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
441*3833Sxw161283 
442*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MAX_FRAME_LENGTH, mtu);
443*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_MAX_FRAME_SIZE, mtu);
444*3833Sxw161283 
445*3833Sxw161283 	if (enabled)
446*3833Sxw161283 		(void) pm3393_enable(cmac, enabled);
447*3833Sxw161283 	return 0;
448*3833Sxw161283 }
449*3833Sxw161283 
calc_crc(u8 * b,int len)450*3833Sxw161283 static u32 calc_crc(u8 *b, int len)
451*3833Sxw161283 {
452*3833Sxw161283         int i;
453*3833Sxw161283 	u32 crc = (u32)~0;
454*3833Sxw161283 
455*3833Sxw161283 	/* calculate crc one bit at a time */
456*3833Sxw161283         while (len--) {
457*3833Sxw161283                 crc ^= *b++;
458*3833Sxw161283                 for (i = 0; i < 8; i++) {
459*3833Sxw161283 			if (crc & 0x1)
460*3833Sxw161283 				crc = (crc >> 1) ^ 0xedb88320;
461*3833Sxw161283 			else
462*3833Sxw161283 				crc = (crc >> 1);
463*3833Sxw161283 		}
464*3833Sxw161283         }
465*3833Sxw161283 
466*3833Sxw161283 	/* reverse bits */
467*3833Sxw161283         crc = ((crc >> 4) & 0x0f0f0f0f) | ((crc << 4) & 0xf0f0f0f0);
468*3833Sxw161283         crc = ((crc >> 2) & 0x33333333) | ((crc << 2) & 0xcccccccc);
469*3833Sxw161283         crc = ((crc >> 1) & 0x55555555) | ((crc << 1) & 0xaaaaaaaa);
470*3833Sxw161283 	/* swap bytes */
471*3833Sxw161283         crc = (crc >> 16) | (crc << 16);
472*3833Sxw161283         crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
473*3833Sxw161283 
474*3833Sxw161283         return crc;
475*3833Sxw161283 }
476*3833Sxw161283 
pm3393_set_rx_mode(struct cmac * cmac,struct t1_rx_mode * rm)477*3833Sxw161283 static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
478*3833Sxw161283 {
479*3833Sxw161283 	int enabled = cmac->instance->enabled & MAC_DIRECTION_RX;
480*3833Sxw161283 	u32 rx_mode;
481*3833Sxw161283 
482*3833Sxw161283 	/* Disable MAC RX before reconfiguring it */
483*3833Sxw161283 	if (enabled)
484*3833Sxw161283 		(void) pm3393_disable(cmac, MAC_DIRECTION_RX);
485*3833Sxw161283 
486*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2, &rx_mode);
487*3833Sxw161283 	rx_mode &= ~(SUNI1x10GEXP_BITMSK_RXXG_PMODE | SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN);
488*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2, (u16)rx_mode);
489*3833Sxw161283 
490*3833Sxw161283         if (t1_rx_mode_promisc(rm)) {
491*3833Sxw161283                 /* Promiscuous mode. */
492*3833Sxw161283 		rx_mode |= SUNI1x10GEXP_BITMSK_RXXG_PMODE;
493*3833Sxw161283         }
494*3833Sxw161283 	if (t1_rx_mode_allmulti(rm)) {
495*3833Sxw161283                 /* Accept all multicast. */
496*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, 0xffff);
497*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDLOW, 0xffff);
498*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDHIGH, 0xffff);
499*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_HIGH, 0xffff);
500*3833Sxw161283 		rx_mode |= SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN;
501*3833Sxw161283         } else if (t1_rx_mode_mc_cnt(rm)) {
502*3833Sxw161283                 /* Accept one or more multicast(s). */
503*3833Sxw161283 		u8 *addr;
504*3833Sxw161283 		int bit;
505*3833Sxw161283 		u16 mc_filter[4] = { 0, };
506*3833Sxw161283 
507*3833Sxw161283 		while ((addr = t1_get_next_mcaddr(rm))) {
508*3833Sxw161283 			bit = (calc_crc(addr, ETH_ALEN) >> 23) & 0x3f;	/* bit[23:28] */
509*3833Sxw161283 			mc_filter[bit >> 4] |= 1 << (bit & 0xf);
510*3833Sxw161283 		}
511*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]);
512*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDLOW, mc_filter[1]);
513*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDHIGH, mc_filter[2]);
514*3833Sxw161283 		(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_HIGH, mc_filter[3]);
515*3833Sxw161283 		rx_mode |= SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN;
516*3833Sxw161283         }
517*3833Sxw161283 
518*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2, (u16)rx_mode);
519*3833Sxw161283 
520*3833Sxw161283 	if (enabled)
521*3833Sxw161283 		(void) pm3393_enable(cmac, MAC_DIRECTION_RX);
522*3833Sxw161283 
523*3833Sxw161283 	return 0;
524*3833Sxw161283 }
525*3833Sxw161283 
pm3393_get_speed_duplex_fc(struct cmac * cmac,int * speed,int * duplex,int * fc)526*3833Sxw161283 static int pm3393_get_speed_duplex_fc(struct cmac *cmac, int *speed,
527*3833Sxw161283 				      int *duplex, int *fc)
528*3833Sxw161283 {
529*3833Sxw161283 	if (speed)
530*3833Sxw161283 		*speed = SPEED_10000;
531*3833Sxw161283 	if (duplex)
532*3833Sxw161283 		*duplex = DUPLEX_FULL;
533*3833Sxw161283 	if (fc)
534*3833Sxw161283 		*fc = cmac->instance->fc;
535*3833Sxw161283 	return 0;
536*3833Sxw161283 }
537*3833Sxw161283 
pm3393_set_speed_duplex_fc(struct cmac * cmac,int speed,int duplex,int fc)538*3833Sxw161283 static int pm3393_set_speed_duplex_fc(struct cmac *cmac, int speed, int duplex,
539*3833Sxw161283 				      int fc)
540*3833Sxw161283 {
541*3833Sxw161283 	if (speed >= 0 && speed != SPEED_10000)
542*3833Sxw161283 		return -1;
543*3833Sxw161283 	if (duplex >= 0 && duplex != DUPLEX_FULL)
544*3833Sxw161283 		return -1;
545*3833Sxw161283 	if (fc & ~(PAUSE_TX | PAUSE_RX))
546*3833Sxw161283 		return -1;
547*3833Sxw161283 
548*3833Sxw161283 	if (fc != cmac->instance->fc) {
549*3833Sxw161283 		cmac->instance->fc = (u8) fc;
550*3833Sxw161283 		if (cmac->instance->enabled & MAC_DIRECTION_TX)
551*3833Sxw161283 			(void) pm3393_enable(cmac, MAC_DIRECTION_TX);
552*3833Sxw161283 	}
553*3833Sxw161283 	return 0;
554*3833Sxw161283 }
555*3833Sxw161283 
556*3833Sxw161283 #define RMON_UPDATE(mac, name, stat_name) \
557*3833Sxw161283 	{ \
558*3833Sxw161283 		(void) t1_tpi_read((mac)->adapter, OFFSET(name), &val0);	\
559*3833Sxw161283 		(void) t1_tpi_read((mac)->adapter, OFFSET(((name)+1)), &val1); \
560*3833Sxw161283 		(void) t1_tpi_read((mac)->adapter, OFFSET(((name)+2)), &val2); \
561*3833Sxw161283 		(mac)->stats.stat_name = (u16)val0  | (((u16)val1) << 16) \
562*3833Sxw161283 						   | ((u64)((u8)val2) << 32) \
563*3833Sxw161283 						   | ((mac)->stats.stat_name & (~(u64)0 << 40)); \
564*3833Sxw161283 		if (ro & ((name -  SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)) \
565*3833Sxw161283 			(mac)->stats.stat_name += ((u64)1 << 40); \
566*3833Sxw161283 	}
567*3833Sxw161283 
568*3833Sxw161283 /* ARGSUSED */
pm3393_update_statistics(struct cmac * mac,int flag)569*3833Sxw161283 static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
570*3833Sxw161283 							      int flag)
571*3833Sxw161283 {
572*3833Sxw161283 	u64	ro;
573*3833Sxw161283 	u32	val0, val1, val2, val3;
574*3833Sxw161283 
575*3833Sxw161283 	/* Snap the counters */
576*3833Sxw161283 	(void) pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL,
577*3833Sxw161283 		SUNI1x10GEXP_BITMSK_MSTAT_SNAP);
578*3833Sxw161283 
579*3833Sxw161283 	/* Counter rollover, clear on read */
580*3833Sxw161283 	(void) pmread(mac, SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_0, &val0);
581*3833Sxw161283 	(void) pmread(mac, SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_1, &val1);
582*3833Sxw161283 	(void) pmread(mac, SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_2, &val2);
583*3833Sxw161283 	(void) pmread(mac, SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_3, &val3);
584*3833Sxw161283 	ro = (u16)val0 | (((u16)val1) << 16) | ((u64)((u16)val2) << 32)
585*3833Sxw161283 	     | ((u64)((u16)val3) << 48);
586*3833Sxw161283 
587*3833Sxw161283 	/* Rx stats */
588*3833Sxw161283 	RMON_UPDATE(mac, RxOctetsReceivedOK, RxOctetsOK);
589*3833Sxw161283 	RMON_UPDATE(mac, RxUnicastFramesReceivedOK, RxUnicastFramesOK);
590*3833Sxw161283 	RMON_UPDATE(mac, RxMulticastFramesReceivedOK, RxMulticastFramesOK);
591*3833Sxw161283 	RMON_UPDATE(mac, RxBroadcastFramesReceivedOK, RxBroadcastFramesOK);
592*3833Sxw161283 	RMON_UPDATE(mac, RxPAUSEMACCtrlFramesReceived, RxPauseFrames);
593*3833Sxw161283 	RMON_UPDATE(mac, RxFrameCheckSequenceErrors, RxFCSErrors);
594*3833Sxw161283 	RMON_UPDATE(mac, RxFramesLostDueToInternalMACErrors, RxInternalMACRcvError);
595*3833Sxw161283 	RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
596*3833Sxw161283 	RMON_UPDATE(mac, RxInRangeLengthErrors, RxInRangeLengthErrors);
597*3833Sxw161283 	RMON_UPDATE(mac, RxFramesTooLongErrors , RxFrameTooLongErrors);
598*3833Sxw161283 	RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
599*3833Sxw161283 	RMON_UPDATE(mac, RxFragments, RxRuntErrors);
600*3833Sxw161283 	RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
601*3833Sxw161283 
602*3833Sxw161283 	/* Tx stats */
603*3833Sxw161283 	RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
604*3833Sxw161283 	RMON_UPDATE(mac, TxFramesLostDueToInternalMACTransmissionError, TxInternalMACXmitError);
605*3833Sxw161283 	RMON_UPDATE(mac, TxTransmitSystemError, TxFCSErrors);
606*3833Sxw161283 	RMON_UPDATE(mac, TxUnicastFramesTransmittedOK, TxUnicastFramesOK);
607*3833Sxw161283 	RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
608*3833Sxw161283 	RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
609*3833Sxw161283 	RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
610*3833Sxw161283 
611*3833Sxw161283 	return &mac->stats;
612*3833Sxw161283 }
613*3833Sxw161283 
pm3393_macaddress_get(struct cmac * cmac,u8 mac_addr[6])614*3833Sxw161283 static int pm3393_macaddress_get(struct cmac *cmac, u8 mac_addr[6])
615*3833Sxw161283 {
616*3833Sxw161283 	memcpy(mac_addr, cmac->instance->mac_addr, 6);
617*3833Sxw161283 	return 0;
618*3833Sxw161283 }
619*3833Sxw161283 
pm3393_macaddress_set(struct cmac * cmac,u8 ma[6])620*3833Sxw161283 static int pm3393_macaddress_set(struct cmac *cmac, u8 ma[6])
621*3833Sxw161283 {
622*3833Sxw161283 	u32 val, lo, mid, hi, enabled = cmac->instance->enabled;
623*3833Sxw161283 
624*3833Sxw161283 	/*
625*3833Sxw161283 	 * MAC addr: 00:07:43:00:13:09
626*3833Sxw161283 	 *
627*3833Sxw161283 	 * ma[5] = 0x09
628*3833Sxw161283 	 * ma[4] = 0x13
629*3833Sxw161283 	 * ma[3] = 0x00
630*3833Sxw161283 	 * ma[2] = 0x43
631*3833Sxw161283 	 * ma[1] = 0x07
632*3833Sxw161283 	 * ma[0] = 0x00
633*3833Sxw161283 	 *
634*3833Sxw161283 	 * The PM3393 requires byte swapping and reverse order entry
635*3833Sxw161283 	 * when programming MAC addresses:
636*3833Sxw161283 	 *
637*3833Sxw161283 	 * low_bits[15:0]    = ma[1]:ma[0]
638*3833Sxw161283 	 * mid_bits[31:16]   = ma[3]:ma[2]
639*3833Sxw161283 	 * high_bits[47:32]  = ma[5]:ma[4]
640*3833Sxw161283 	 */
641*3833Sxw161283 
642*3833Sxw161283 	/* Store local copy */
643*3833Sxw161283 	memcpy(cmac->instance->mac_addr, ma, 6);
644*3833Sxw161283 
645*3833Sxw161283 	lo = ((u32) ma[1] << 8) | (u32) ma[0];
646*3833Sxw161283 	mid = ((u32) ma[3] << 8) | (u32) ma[2];
647*3833Sxw161283 	hi = ((u32) ma[5] << 8) | (u32) ma[4];
648*3833Sxw161283 
649*3833Sxw161283 	/* Disable Rx/Tx MAC before configuring it. */
650*3833Sxw161283 	if (enabled)
651*3833Sxw161283 		(void) pm3393_disable(cmac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
652*3833Sxw161283 
653*3833Sxw161283 	/* Set RXXG Station Address */
654*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_SA_15_0, lo);
655*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_SA_31_16, mid);
656*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_SA_47_32, hi);
657*3833Sxw161283 
658*3833Sxw161283 	/* Set TXXG Station Address */
659*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_SA_15_0, lo);
660*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_SA_31_16, mid);
661*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_TXXG_SA_47_32, hi);
662*3833Sxw161283 
663*3833Sxw161283 	/* Setup Exact Match Filter 1 with our MAC address
664*3833Sxw161283 	 *
665*3833Sxw161283 	 * Must disable exact match filter before configuring it.
666*3833Sxw161283 	 */
667*3833Sxw161283 	(void) pmread(cmac, SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0, &val);
668*3833Sxw161283 	val &= 0xff0f;
669*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0, val);
670*3833Sxw161283 
671*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_LOW, lo);
672*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_MID, mid);
673*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_HIGH, hi);
674*3833Sxw161283 
675*3833Sxw161283 	val |= 0x0090;
676*3833Sxw161283 	(void) pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0, val);
677*3833Sxw161283 
678*3833Sxw161283 	if (enabled)
679*3833Sxw161283 		(void) pm3393_enable(cmac, enabled);
680*3833Sxw161283 	return 0;
681*3833Sxw161283 }
682*3833Sxw161283 
pm3393_destroy(struct cmac * cmac)683*3833Sxw161283 static void pm3393_destroy(struct cmac *cmac)
684*3833Sxw161283 {
685*3833Sxw161283 	t1_os_free((void *)cmac, sizeof(*cmac) + sizeof(cmac_instance));
686*3833Sxw161283 }
687*3833Sxw161283 
688*3833Sxw161283 #ifdef C99_NOT_SUPPORTED
689*3833Sxw161283 static struct cmac_ops pm3393_ops = {
690*3833Sxw161283 	pm3393_destroy,
691*3833Sxw161283 	pm3393_reset,
692*3833Sxw161283 	pm3393_interrupt_enable,
693*3833Sxw161283 	pm3393_interrupt_disable,
694*3833Sxw161283 	pm3393_interrupt_clear,
695*3833Sxw161283 	pm3393_interrupt_handler,
696*3833Sxw161283 	pm3393_enable,
697*3833Sxw161283 	pm3393_disable,
698*3833Sxw161283 	pm3393_loopback_enable,
699*3833Sxw161283 	pm3393_loopback_disable,
700*3833Sxw161283 	pm3393_set_mtu,
701*3833Sxw161283 	pm3393_set_rx_mode,
702*3833Sxw161283 	pm3393_set_speed_duplex_fc,
703*3833Sxw161283 	pm3393_get_speed_duplex_fc,
704*3833Sxw161283 	pm3393_update_statistics,
705*3833Sxw161283 	pm3393_macaddress_get,
706*3833Sxw161283 	pm3393_macaddress_set
707*3833Sxw161283 };
708*3833Sxw161283 #else
709*3833Sxw161283 static struct cmac_ops pm3393_ops = {
710*3833Sxw161283 	.destroy                 = pm3393_destroy,
711*3833Sxw161283 	.reset                   = pm3393_reset,
712*3833Sxw161283 	.interrupt_enable        = pm3393_interrupt_enable,
713*3833Sxw161283 	.interrupt_disable       = pm3393_interrupt_disable,
714*3833Sxw161283 	.interrupt_clear         = pm3393_interrupt_clear,
715*3833Sxw161283 	.interrupt_handler       = pm3393_interrupt_handler,
716*3833Sxw161283 	.enable                  = pm3393_enable_port,
717*3833Sxw161283 	.disable                 = pm3393_disable,
718*3833Sxw161283 	.loopback_enable         = pm3393_loopback_enable,
719*3833Sxw161283 	.loopback_disable        = pm3393_loopback_disable,
720*3833Sxw161283 	.set_mtu                 = pm3393_set_mtu,
721*3833Sxw161283 	.set_rx_mode             = pm3393_set_rx_mode,
722*3833Sxw161283 	.get_speed_duplex_fc     = pm3393_get_speed_duplex_fc,
723*3833Sxw161283 	.set_speed_duplex_fc     = pm3393_set_speed_duplex_fc,
724*3833Sxw161283 	.statistics_update       = pm3393_update_statistics,
725*3833Sxw161283 	.macaddress_get          = pm3393_macaddress_get,
726*3833Sxw161283 	.macaddress_set          = pm3393_macaddress_set
727*3833Sxw161283 };
728*3833Sxw161283 #endif
729*3833Sxw161283 
730*3833Sxw161283 /* ARGSUSED */
pm3393_mac_create(adapter_t * adapter,int index)731*3833Sxw161283 static struct cmac *pm3393_mac_create(adapter_t *adapter, int index)
732*3833Sxw161283 {
733*3833Sxw161283 	struct cmac *cmac;
734*3833Sxw161283 
735*3833Sxw161283 	cmac = t1_os_malloc_wait_zero(sizeof(*cmac) + sizeof(cmac_instance));
736*3833Sxw161283 	if (!cmac)
737*3833Sxw161283 		return NULL;
738*3833Sxw161283 
739*3833Sxw161283 	cmac->ops = &pm3393_ops;
740*3833Sxw161283 	cmac->instance = (cmac_instance *) (cmac + 1);
741*3833Sxw161283 	cmac->adapter = adapter;
742*3833Sxw161283 	cmac->instance->fc = PAUSE_TX | PAUSE_RX;
743*3833Sxw161283 
744*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x0001), 0x00008000);
745*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x0001), 0x00000000);
746*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2308), 0x00009800);
747*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2305), 0x00001001);   /* PL4IO Enable */
748*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2320), 0x00008800);
749*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2321), 0x00008800);
750*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2322), 0x00008800);
751*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2323), 0x00008800);
752*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2324), 0x00008800);
753*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2325), 0x00008800);
754*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2326), 0x00008800);
755*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2327), 0x00008800);
756*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2328), 0x00008800);
757*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2329), 0x00008800);
758*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x232a), 0x00008800);
759*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x232b), 0x00008800);
760*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x232c), 0x00008800);
761*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x232d), 0x00008800);
762*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x232e), 0x00008800);
763*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x232f), 0x00008800);
764*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x230d), 0x00009c00);
765*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2304), 0x00000202);	/* PL4IO Calendar Repetitions */
766*3833Sxw161283 
767*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3200), 0x00008080);	/* EFLX Enable */
768*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3210), 0x00000000);	/* EFLX Channel Deprovision */
769*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3203), 0x00000000);	/* EFLX Low Limit */
770*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3204), 0x00000040);	/* EFLX High Limit */
771*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3205), 0x000002cc);	/* EFLX Almost Full */
772*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3206), 0x00000199);	/* EFLX Almost Empty */
773*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3207), 0x00000240);	/* EFLX Cut Through Threshold */
774*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3202), 0x00000000);	/* EFLX Indirect Register Update */
775*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3210), 0x00000001);	/* EFLX Channel Provision */
776*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3208), 0x0000ffff);	/* EFLX Undocumented */
777*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x320a), 0x0000ffff);	/* EFLX Undocumented */
778*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x320c), 0x0000ffff);	/* EFLX enable overflow interrupt The other bit are undocumented */
779*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x320e), 0x0000ffff);	/* EFLX Undocumented */
780*3833Sxw161283 
781*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2200), 0x0000c000);	/* IFLX Configuration - enable */
782*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2201), 0x00000000);	/* IFLX Channel Deprovision */
783*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x220e), 0x00000000);	/* IFLX Low Limit */
784*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x220f), 0x00000100);	/* IFLX High Limit */
785*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2210), 0x00000c00);	/* IFLX Almost Full Limit */
786*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2211), 0x00000599);	/* IFLX Almost Empty Limit */
787*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x220d), 0x00000000);	/* IFLX Indirect Register Update */
788*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2201), 0x00000001);	/* IFLX Channel Provision */
789*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2203), 0x0000ffff);	/* IFLX Undocumented */
790*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2205), 0x0000ffff);	/* IFLX Undocumented */
791*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2209), 0x0000ffff);	/* IFLX Enable overflow interrupt.  The other bit are undocumented */
792*3833Sxw161283 
793*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2241), 0xfffffffe);	/* PL4MOS Undocumented */
794*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2242), 0x0000ffff);	/* PL4MOS Undocumented */
795*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2243), 0x00000008);	/* PL4MOS Starving Burst Size */
796*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2244), 0x00000008);	/* PL4MOS Hungry Burst Size */
797*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2245), 0x00000008);	/* PL4MOS Transfer Size */
798*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2240), 0x00000005);	/* PL4MOS Disable */
799*3833Sxw161283 
800*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2280), 0x00002103);	/* PL4ODP Training Repeat and SOP rule */
801*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2284), 0x00000000);	/* PL4ODP MAX_T setting */
802*3833Sxw161283 
803*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3280), 0x00000087);	/* PL4IDU Enable data forward, port state machine. Set ALLOW_NON_ZERO_OLB */
804*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3282), 0x0000001f);	/* PL4IDU Enable Dip4 check error interrupts */
805*3833Sxw161283 
806*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x3040), 0x0c32);	/* # TXXG Config */
807*3833Sxw161283 	/* For T1 use timer based Mac flow control. */
808*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x304d), 0x8000);
809*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2040), 0x059c);	/* # RXXG Config */
810*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2049), 0x0001);	/* # RXXG Cut Through */
811*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x2070), 0x0000);	/* # Disable promiscuous mode */
812*3833Sxw161283 
813*3833Sxw161283 	/* Setup Exact Match Filter 0 to allow broadcast packets.
814*3833Sxw161283 	 */
815*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x206e), 0x0000);	/* # Disable Match Enable bit */
816*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x204a), 0xffff);	/* # low addr */
817*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x204b), 0xffff);	/* # mid addr */
818*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x204c), 0xffff);	/* # high addr */
819*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x206e), 0x0009);	/* # Enable Match Enable bit */
820*3833Sxw161283 
821*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x0003), 0x0000);	/* # NO SOP/ PAD_EN setup */
822*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x0100), 0x0ff0);	/* # RXEQB disabled */
823*3833Sxw161283 	(void) t1_tpi_write(adapter, OFFSET(0x0101), 0x0f0f);	/* # No Preemphasis */
824*3833Sxw161283 
825*3833Sxw161283 	return cmac;
826*3833Sxw161283 }
827*3833Sxw161283 
pm3393_mac_reset(adapter_t * adapter)828*3833Sxw161283 static int pm3393_mac_reset(adapter_t * adapter)
829*3833Sxw161283 {
830*3833Sxw161283 	u32 val;
831*3833Sxw161283 	u32 x;
832*3833Sxw161283 	u32 is_pl4_reset_finished;
833*3833Sxw161283 	u32 is_pl4_outof_lock;
834*3833Sxw161283 	u32 is_xaui_mabc_pll_locked;
835*3833Sxw161283 	u32 successful_reset;
836*3833Sxw161283 	int i;
837*3833Sxw161283 
838*3833Sxw161283 	/* The following steps are required to properly reset
839*3833Sxw161283 	 * the PM3393. This information is provided in the
840*3833Sxw161283 	 * PM3393 datasheet (Issue 2: November 2002)
841*3833Sxw161283 	 * section 13.1 -- Device Reset.
842*3833Sxw161283 	 *
843*3833Sxw161283 	 * The PM3393 has three types of components that are
844*3833Sxw161283 	 * individually reset:
845*3833Sxw161283 	 *
846*3833Sxw161283 	 * DRESETB      - Digital circuitry
847*3833Sxw161283 	 * PL4_ARESETB  - PL4 analog circuitry
848*3833Sxw161283 	 * XAUI_ARESETB - XAUI bus analog circuitry
849*3833Sxw161283 	 *
850*3833Sxw161283 	 * Steps to reset PM3393 using RSTB pin:
851*3833Sxw161283 	 *
852*3833Sxw161283 	 * 1. Assert RSTB pin low ( write 0 )
853*3833Sxw161283 	 * 2. Wait at least 1ms to initiate a complete initialization of device.
854*3833Sxw161283 	 * 3. Wait until all external clocks and REFSEL are stable.
855*3833Sxw161283 	 * 4. Wait minimum of 1ms. (after external clocks and REFEL are stable)
856*3833Sxw161283 	 * 5. De-assert RSTB ( write 1 )
857*3833Sxw161283 	 * 6. Wait until internal timers to expires after ~14ms.
858*3833Sxw161283 	 *    - Allows analog clock synthesizer(PL4CSU) to stabilize to
859*3833Sxw161283 	 *      selected reference frequency before allowing the digital
860*3833Sxw161283 	 *      portion of the device to operate.
861*3833Sxw161283 	 * 7. Wait at least 200us for XAUI interface to stabilize.
862*3833Sxw161283 	 * 8. Verify the PM3393 came out of reset successfully.
863*3833Sxw161283 	 *    Set successful reset flag if everything worked else try again
864*3833Sxw161283 	 *    a few more times.
865*3833Sxw161283 	 */
866*3833Sxw161283 
867*3833Sxw161283 	successful_reset = 0;
868*3833Sxw161283 	for (i = 0; i < 3 && !successful_reset; i++) {
869*3833Sxw161283 		/* 1 */
870*3833Sxw161283 		(void) t1_tpi_read(adapter, A_ELMER0_GPO, &val);
871*3833Sxw161283 		val &= ~1;
872*3833Sxw161283 		(void) t1_tpi_write(adapter, A_ELMER0_GPO, val);
873*3833Sxw161283 
874*3833Sxw161283 		/* 2 */
875*3833Sxw161283 		DELAY_MS(1);
876*3833Sxw161283 
877*3833Sxw161283 		/* 3 */
878*3833Sxw161283 		DELAY_MS(1);
879*3833Sxw161283 
880*3833Sxw161283 		/* 4 */
881*3833Sxw161283 		DELAY_MS(2 /*1 extra ms for safety */ );
882*3833Sxw161283 
883*3833Sxw161283 		/* 5 */
884*3833Sxw161283 		val |= 1;
885*3833Sxw161283 		(void) t1_tpi_write(adapter, A_ELMER0_GPO, val);
886*3833Sxw161283 
887*3833Sxw161283 		/* 6 */
888*3833Sxw161283 		DELAY_MS(15 /*1 extra ms for safety */ );
889*3833Sxw161283 
890*3833Sxw161283 		/* 7 */
891*3833Sxw161283 		DELAY_MS(1);
892*3833Sxw161283 
893*3833Sxw161283 		/* 8 */
894*3833Sxw161283 
895*3833Sxw161283 		/* Has PL4 analog block come out of reset correctly? */
896*3833Sxw161283 		(void) t1_tpi_read(adapter, OFFSET(SUNI1x10GEXP_REG_DEVICE_STATUS), &val);
897*3833Sxw161283 		is_pl4_reset_finished = (val & SUNI1x10GEXP_BITMSK_TOP_EXPIRED);
898*3833Sxw161283 
899*3833Sxw161283 		/* TBD XXX SUNI1x10GEXP_BITMSK_TOP_PL4_IS_DOOL gets locked later in the init sequence
900*3833Sxw161283 		 *         figure out why? */
901*3833Sxw161283 
902*3833Sxw161283 		/* Have all PL4 block clocks locked? */
903*3833Sxw161283 		x = (SUNI1x10GEXP_BITMSK_TOP_PL4_ID_DOOL
904*3833Sxw161283 		     /*| SUNI1x10GEXP_BITMSK_TOP_PL4_IS_DOOL */  |
905*3833Sxw161283 		     SUNI1x10GEXP_BITMSK_TOP_PL4_ID_ROOL |
906*3833Sxw161283 		     SUNI1x10GEXP_BITMSK_TOP_PL4_IS_ROOL |
907*3833Sxw161283 		     SUNI1x10GEXP_BITMSK_TOP_PL4_OUT_ROOL);
908*3833Sxw161283 		is_pl4_outof_lock = (val & x);
909*3833Sxw161283 
910*3833Sxw161283 		/* ??? If this fails, might be able to software reset the XAUI part
911*3833Sxw161283 		 *     and try to recover... thus saving us from doing another HW reset */
912*3833Sxw161283 		/* Has the XAUI MABC PLL circuitry stablized? */
913*3833Sxw161283 		is_xaui_mabc_pll_locked =
914*3833Sxw161283 		    (val & SUNI1x10GEXP_BITMSK_TOP_SXRA_EXPIRED);
915*3833Sxw161283 
916*3833Sxw161283 		successful_reset = (is_pl4_reset_finished && !is_pl4_outof_lock
917*3833Sxw161283 				    && is_xaui_mabc_pll_locked);
918*3833Sxw161283 
919*3833Sxw161283 		CH_DBG(adapter, HW,
920*3833Sxw161283 		       "PM3393 HW reset %d: pl4_reset 0x%x, val 0x%x, "
921*3833Sxw161283 		       "is_pl4_outof_lock 0x%x, xaui_locked 0x%x\n",
922*3833Sxw161283 		       i, is_pl4_reset_finished, val, is_pl4_outof_lock,
923*3833Sxw161283 		       is_xaui_mabc_pll_locked);
924*3833Sxw161283 	}
925*3833Sxw161283 	return successful_reset ? 0 : 1;
926*3833Sxw161283 }
927*3833Sxw161283 
928*3833Sxw161283 struct gmac t1_pm3393_ops = {
929*3833Sxw161283 	STATS_TICK_SECS,
930*3833Sxw161283 	pm3393_mac_create,
931*3833Sxw161283 	pm3393_mac_reset
932*3833Sxw161283 };
933