1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "nge.h"
#undef NGE_DBG
#define NGE_DBG NGE_DBG_MII /* debug flag for this code */
/*
* The arrays below can be indexed by the MODE bits from the mac2phy
* register to determine the current speed/duplex settings.
*/
static const int16_t nge_copper_link_speed[] = {
0, /* MII_AUX_STATUS_MODE_NONE */
10, /* MII_AUX_STAT0,US_MODE_10 */
100, /* MII_AUX_STAT0,US_MODE_100 */
1000, /* MII_AUX_STAT0,US_MODE_1000 */
};
static const int8_t nge_copper_link_duplex[] = {
LINK_DUPLEX_UNKNOWN, /* MII_DUPLEX_NONE */
LINK_DUPLEX_HALF, /* MII_DUPLEX_HALF */
LINK_DUPLEX_FULL, /* MII_DUPLEX_FULL */
};
static uint16_t nge_mii_access(nge_t *ngep, nge_regno_t regno,
uint16_t data, uint32_t cmd);
#pragma inline(nge_mii_access)
static uint16_t
nge_mii_access(nge_t *ngep, nge_regno_t regno, uint16_t data, uint32_t cmd)
{
uint16_t tries;
uint16_t mdio_data;
nge_mdio_adr mdio_adr;
nge_mintr_src intr_src;
NGE_TRACE(("nge_mii_access($%p, 0x%lx, 0x%x, 0x%x)",
(void *)ngep, regno, data, cmd));
/*
* Clear the privous interrupt event
*/
intr_src.src_val = nge_reg_get8(ngep, NGE_MINTR_SRC);
nge_reg_put8(ngep, NGE_MINTR_SRC, intr_src.src_val);
/*
* Check whether the current operation has been finished
*/
mdio_adr.adr_val = nge_reg_get16(ngep, NGE_MDIO_ADR);
for (tries = 0; tries < 30; tries ++) {
if (mdio_adr.adr_bits.mdio_clc == NGE_CLEAR)
break;
drv_usecwait(10);
mdio_adr.adr_val = nge_reg_get16(ngep, NGE_MDIO_ADR);
}
/*
* The current operation can not be finished successfully
* The driver should halt the current operation
*/
if (tries == 30) {
mdio_adr.adr_bits.mdio_clc = NGE_SET;
nge_reg_put16(ngep, NGE_MDIO_ADR, mdio_adr.adr_val);
drv_usecwait(100);
}
/*
* Assemble the operation cmd
*/
mdio_adr.adr_bits.phy_reg = (uint16_t)regno;
mdio_adr.adr_bits.phy_adr = ngep->phy_xmii_addr;
mdio_adr.adr_bits.mdio_rw = (cmd == NGE_MDIO_WRITE) ? 1 : 0;
if (cmd == NGE_MDIO_WRITE)
nge_reg_put16(ngep, NGE_MDIO_DATA, data);
nge_reg_put16(ngep, NGE_MDIO_ADR, mdio_adr.adr_val);
/*
* To check whether the read/write operation is finished
*/
for (tries = 0; tries < 300; tries ++) {
drv_usecwait(10);
mdio_adr.adr_val = nge_reg_get16(ngep, NGE_MDIO_ADR);
if (mdio_adr.adr_bits.mdio_clc == NGE_CLEAR)
break;
}
if (tries == 300)
return ((uint16_t)~0);
/*
* Read the data from MDIO data register
*/
if (cmd == NGE_MDIO_READ)
mdio_data = nge_reg_get16(ngep, NGE_MDIO_DATA);
/*
* To check whether the read/write operation is valid
*/
intr_src.src_val = nge_reg_get8(ngep, NGE_MINTR_SRC);
nge_reg_put8(ngep, NGE_MINTR_SRC, intr_src.src_val);
if (intr_src.src_bits.mrei == NGE_SET)
return ((uint16_t)~0);
return (mdio_data);
}
uint16_t nge_mii_get16(nge_t *ngep, nge_regno_t regno);
#pragma inline(nge_mii_get16)
uint16_t
nge_mii_get16(nge_t *ngep, nge_regno_t regno)
{
return (nge_mii_access(ngep, regno, 0, NGE_MDIO_READ));
}
void nge_mii_put16(nge_t *ngep, nge_regno_t regno, uint16_t data);
#pragma inline(nge_mii_put16)
void
nge_mii_put16(nge_t *ngep, nge_regno_t regno, uint16_t data)
{
(void) nge_mii_access(ngep, regno, data, NGE_MDIO_WRITE);
}
/*
* Basic low-level function to probe for a PHY
*
* Returns TRUE if the PHY responds with valid data, FALSE otherwise
*/
static boolean_t
nge_phy_probe(nge_t *ngep)
{
int i;
uint16_t phy_status;
uint16_t phyidh;
uint16_t phyidl;
NGE_TRACE(("nge_phy_probe($%p)", (void *)ngep));
/*
* Scan the phys to find the right address
* of the phy
*
* Probe maximum for 32 phy addresses
*/
for (i = 0; i < NGE_PHY_NUMBER; i++) {
ngep->phy_xmii_addr = i;
/*
* Read the MII_STATUS register twice, in
* order to clear any sticky bits (but they should
* have been cleared by the RESET, I think).
*/
phy_status = nge_mii_get16(ngep, MII_STATUS);
phy_status = nge_mii_get16(ngep, MII_STATUS);
if (phy_status != 0xffff) {
phyidh = nge_mii_get16(ngep, MII_PHYIDH);
phyidl = nge_mii_get16(ngep, MII_PHYIDL);
ngep->phy_id =
(((uint32_t)phyidh << 16) |(phyidl & MII_IDL_MASK));
NGE_DEBUG(("nge_phy_probe: status 0x%x, phy id 0x%x",
phy_status, ngep->phy_id));
return (B_TRUE);
}
}
return (B_FALSE);
}
/*
* Basic low-level function to powerup the phy and remove the isolation
*/
static boolean_t
nge_phy_recover(nge_t *ngep)
{
uint16_t control;
uint16_t count;
NGE_TRACE(("nge_phy_recover($%p)", (void *)ngep));
control = nge_mii_get16(ngep, MII_CONTROL);
control &= ~(MII_CONTROL_PWRDN | MII_CONTROL_ISOLATE);
nge_mii_put16(ngep, MII_CONTROL, control);
for (count = 0; ++count < 10; ) {
drv_usecwait(5);
control = nge_mii_get16(ngep, MII_CONTROL);
if (BIC(control, MII_CONTROL_PWRDN))
return (B_TRUE);
}
return (B_FALSE);
}
/*
* Basic low-level function to reset the PHY.
* Doesn't incorporate any special-case workarounds.
*
* Returns TRUE on success, FALSE if the RESET bit doesn't clear
*/
boolean_t
nge_phy_reset(nge_t *ngep)
{
uint16_t control;
uint_t count;
NGE_TRACE(("nge_phy_reset($%p)", (void *)ngep));
ASSERT(mutex_owned(ngep->genlock));
/*
* Set the PHY RESET bit, then wait up to 5 ms for it to self-clear
*/
control = nge_mii_get16(ngep, MII_CONTROL);
control |= MII_CONTROL_RESET;
nge_mii_put16(ngep, MII_CONTROL, control);
/* We should wait for 500ms. It's defined in the manual */
delay(drv_usectohz(500000));
for (count = 0; ++count < 10; ) {
drv_usecwait(5);
control = nge_mii_get16(ngep, MII_CONTROL);
if (BIC(control, MII_CONTROL_RESET))
return (B_TRUE);
}
NGE_DEBUG(("nge_phy_reset: FAILED, control now 0x%x", control));
return (B_FALSE);
}
static boolean_t
nge_phy_restart(nge_t *ngep)
{
uint16_t mii_reg;
if (!nge_phy_recover(ngep))
return (B_FALSE);
if (!nge_phy_reset(ngep))
return (B_FALSE);
if (MII_PHY_MFG(ngep->phy_id) == MII_ID_CICADA) {
if (ngep->phy_mode == RGMII_IN) {
mii_reg = nge_mii_get16(ngep,
MII_CICADA_EXT_CONTROL);
mii_reg &= ~(MII_CICADA_MODE_SELECT_BITS
| MII_CICADA_POWER_SUPPLY_BITS);
mii_reg |= (MII_CICADA_MODE_SELECT_RGMII
| MII_CICADA_POWER_SUPPLY_2_5V);
nge_mii_put16(ngep, MII_CICADA_EXT_CONTROL, mii_reg);
mii_reg = nge_mii_get16(ngep,
MII_CICADA_AUXCTRL_STATUS);
mii_reg |= MII_CICADA_PIN_PRORITY_SETTING;
nge_mii_put16(ngep, MII_CICADA_AUXCTRL_STATUS,
mii_reg);
} else {
mii_reg = nge_mii_get16(ngep,
MII_CICADA_10BASET_CONTROL);
mii_reg |= MII_CICADA_DISABLE_ECHO_MODE;
nge_mii_put16(ngep,
MII_CICADA_10BASET_CONTROL, mii_reg);
mii_reg = nge_mii_get16(ngep,
MII_CICADA_BYPASS_CONTROL);
mii_reg &= (~CICADA_125MHZ_CLOCK_ENABLE);
nge_mii_put16(ngep, MII_CICADA_BYPASS_CONTROL, mii_reg);
}
}
return (B_TRUE);
}
/*
* Synchronise the (copper) PHY's speed/duplex/autonegotiation capabilities
* and advertisements with the required settings as specified by the various
* param_* variables that can be poked via the NDD interface.
*
* We always reset the PHY and reprogram *all* the relevant registers,
* not just those changed. This should cause the link to go down, and then
* back up again once the link is stable and autonegotiation (if enabled)
* is complete. We should get a link state change interrupt somewhere along
* the way ...
*
* NOTE: <genlock> must already be held by the caller
*/
static void
nge_update_copper(nge_t *ngep)
{
uint16_t control;
uint16_t gigctrl;
uint16_t anar;
boolean_t adv_autoneg;
boolean_t adv_pause;
boolean_t adv_asym_pause;
boolean_t adv_1000fdx;
boolean_t adv_100fdx;
boolean_t adv_100hdx;
boolean_t adv_10fdx;
boolean_t adv_10hdx;
NGE_TRACE(("nge_update_copper($%p)", (void *)ngep));
ASSERT(mutex_owned(ngep->genlock));
NGE_DEBUG(("nge_update_copper: autoneg %d "
"pause %d asym_pause %d "
"1000fdx %d "
"100fdx %d 100hdx %d "
"10fdx %d 10hdx %d ",
ngep->param_adv_autoneg,
ngep->param_adv_pause, ngep->param_adv_asym_pause,
ngep->param_adv_1000fdx,
ngep->param_adv_100fdx, ngep->param_adv_100hdx,
ngep->param_adv_10fdx, ngep->param_adv_10hdx));
control = anar = gigctrl = 0;
/*
* PHY settings are normally based on the param_* variables,
* but if any loopback mode is in effect, that takes precedence.
*
* NGE supports MAC-internal loopback, PHY-internal loopback,
* and External loopback at a variety of speeds (with a special
* cable). In all cases, autoneg is turned OFF, full-duplex
* is turned ON, and the speed/mastership is forced.
*/
switch (ngep->param_loop_mode) {
case NGE_LOOP_NONE:
default:
adv_pause = ngep->param_adv_pause;
adv_autoneg = ngep->param_adv_autoneg;
adv_asym_pause = ngep->param_adv_asym_pause;
if (ngep->phy_mode == MII_IN) {
adv_1000fdx = ngep->param_adv_1000fdx = B_FALSE;
}
adv_1000fdx = ngep->param_adv_1000fdx;
adv_100fdx = ngep->param_adv_100fdx;
adv_100hdx = ngep->param_adv_100hdx;
adv_10fdx = ngep->param_adv_10fdx;
adv_10hdx = ngep->param_adv_10hdx;
break;
case NGE_LOOP_EXTERNAL_100:
case NGE_LOOP_EXTERNAL_10:
case NGE_LOOP_INTERNAL_PHY:
adv_autoneg = adv_pause = adv_asym_pause = B_FALSE;
adv_1000fdx = adv_100fdx = adv_10fdx = B_FALSE;
adv_100hdx = adv_10hdx = B_FALSE;
ngep->param_link_duplex = LINK_DUPLEX_FULL;
switch (ngep->param_loop_mode) {
case NGE_LOOP_EXTERNAL_100:
ngep->param_link_speed = 100;
adv_100fdx = B_TRUE;
break;
case NGE_LOOP_EXTERNAL_10:
ngep->param_link_speed = 10;
adv_10fdx = B_TRUE;
break;
case NGE_LOOP_INTERNAL_PHY:
ngep->param_link_speed = 1000;
adv_1000fdx = B_TRUE;
break;
}
}
NGE_DEBUG(("nge_update_copper: autoneg %d "
"pause %d asym_pause %d "
"1000fdx %d "
"100fdx %d 100hdx %d "
"10fdx %d 10hdx %d ",
adv_autoneg,
adv_pause, adv_asym_pause,
adv_1000fdx,
adv_100fdx, adv_100hdx,
adv_10fdx, adv_10hdx));
/*
* We should have at least one technology capability set;
* if not, we select a default of 10Mb/s half-duplex
*/
if (!adv_1000fdx && !adv_100fdx && !adv_10fdx &&
!adv_100hdx && !adv_10hdx)
adv_10hdx = B_TRUE;
/*
* Now transform the adv_* variables into the proper settings
* of the PHY registers ...
*
* If autonegotiation is (now) enabled, we want to trigger
* a new autonegotiation cycle once the PHY has been
* programmed with the capabilities to be advertised.
*/
if (adv_autoneg)
control |= MII_CONTROL_ANE|MII_CONTROL_RSAN;
if (adv_1000fdx)
control |= MII_CONTROL_1000MB|MII_CONTROL_FDUPLEX;
else if (adv_100fdx)
control |= MII_CONTROL_100MB|MII_CONTROL_FDUPLEX;
else if (adv_100hdx)
control |= MII_CONTROL_100MB;
else if (adv_10fdx)
control |= MII_CONTROL_FDUPLEX;
else if (adv_10hdx)
control |= 0;
else
{ _NOTE(EMPTY); } /* Can't get here anyway ... */
if (adv_1000fdx)
gigctrl |= MII_1000BT_CTL_ADV_FDX;
if (adv_100fdx)
anar |= MII_ABILITY_100BASE_TX_FD;
if (adv_100hdx)
anar |= MII_ABILITY_100BASE_TX;
if (adv_10fdx)
anar |= MII_ABILITY_10BASE_T_FD;
if (adv_10hdx)
anar |= MII_ABILITY_10BASE_T;
if (adv_pause)
anar |= MII_ABILITY_PAUSE;
if (adv_asym_pause)
anar |= MII_ABILITY_ASMPAUSE;
/*
* Munge in any other fixed bits we require ...
*/
anar |= MII_AN_SELECTOR_8023;
/*
* Restart the PHY and write the new values.
*/
nge_mii_put16(ngep, MII_AN_ADVERT, anar);
nge_mii_put16(ngep, MII_CONTROL, control);
nge_mii_put16(ngep, MII_1000BASE_T_CONTROL, gigctrl);
if (!nge_phy_restart(ngep))
nge_error(ngep, "nge_update_copper: failed to restart phy");
/*
* Loopback bit in control register is not reset sticky
* write it after PHY restart.
*/
if (ngep->param_loop_mode == NGE_LOOP_INTERNAL_PHY) {
control = nge_mii_get16(ngep, MII_CONTROL);
control |= MII_CONTROL_LOOPBACK;
nge_mii_put16(ngep, MII_CONTROL, control);
}
}
static boolean_t
nge_check_copper(nge_t *ngep)
{
uint16_t mii_status;
uint16_t mii_exstatus;
uint16_t mii_excontrol;
uint16_t anar;
uint16_t lpan;
uint_t speed;
uint_t duplex;
boolean_t linkup;
nge_mii_cs mii_cs;
nge_mintr_src mintr_src;
speed = UNKOWN_SPEED;
duplex = UNKOWN_DUPLEX;
/*
* Read the status from the PHY (which is self-clearing
* on read!); also read & clear the main (Ethernet) MAC status
* (the relevant bits of this are write-one-to-clear).
*/
mii_status = nge_mii_get16(ngep, MII_STATUS);
mii_cs.cs_val = nge_reg_get32(ngep, NGE_MII_CS);
mintr_src.src_val = nge_reg_get32(ngep, NGE_MINTR_SRC);
nge_reg_put32(ngep, NGE_MINTR_SRC, mintr_src.src_val);
NGE_DEBUG(("nge_check_copper: link %d/%s, MII status 0x%x "
"(was 0x%x)", ngep->link_state,
UPORDOWN(ngep->param_link_up), mii_status,
ngep->phy_gen_status));
do {
/*
* If the PHY status changed, record the time
*/
switch (ngep->phy_mode) {
default:
case RGMII_IN:
/*
* Judge the giga speed by reading control
* and status register
*/
mii_excontrol = nge_mii_get16(ngep,
MII_1000BASE_T_CONTROL);
mii_exstatus = nge_mii_get16(ngep,
MII_1000BASE_T_STATUS);
if ((mii_excontrol & MII_1000BT_CTL_ADV_FDX) &&
(mii_exstatus & MII_1000BT_STAT_LP_FDX_CAP)) {
speed = NGE_1000M;
duplex = NGE_FD;
} else {
anar = nge_mii_get16(ngep, MII_AN_ADVERT);
lpan = nge_mii_get16(ngep, MII_AN_LPABLE);
if (lpan != 0)
anar = (anar & lpan);
if (anar & MII_100BASET_FD) {
speed = NGE_100M;
duplex = NGE_FD;
} else if (anar & MII_100BASET_HD) {
speed = NGE_100M;
duplex = NGE_HD;
} else if (anar & MII_10BASET_FD) {
speed = NGE_10M;
duplex = NGE_FD;
} else if (anar & MII_10BASET_HD) {
speed = NGE_10M;
duplex = NGE_HD;
}
}
break;
case MII_IN:
anar = nge_mii_get16(ngep, MII_AN_ADVERT);
lpan = nge_mii_get16(ngep, MII_AN_LPABLE);
if (lpan != 0)
anar = (anar & lpan);
if (anar & MII_100BASET_FD) {
speed = NGE_100M;
duplex = NGE_FD;
} else if (anar & MII_100BASET_HD) {
speed = NGE_100M;
duplex = NGE_HD;
} else if (anar & MII_10BASET_FD) {
speed = NGE_10M;
duplex = NGE_FD;
} else if (anar & MII_10BASET_HD) {
speed = NGE_10M;
duplex = NGE_HD;
}
break;
}
/*
* We will only consider the link UP if all the readings
* are consistent and give meaningful results ...
*/
linkup = nge_copper_link_speed[speed] > 0;
linkup &= nge_copper_link_duplex[duplex] != LINK_DUPLEX_UNKNOWN;
linkup &= BIS(mii_status, MII_STATUS_LINKUP);
linkup &= BIS(mii_cs.cs_val, MII_STATUS_LINKUP);
/*
* Record current register values, then reread status
* register & loop until it stabilises ...
*/
ngep->phy_gen_status = mii_status;
mii_status = nge_mii_get16(ngep, MII_STATUS);
} while (mii_status != ngep->phy_gen_status);
/* Get the Link Partner Ability */
mii_exstatus = nge_mii_get16(ngep, MII_1000BASE_T_STATUS);
lpan = nge_mii_get16(ngep, MII_AN_LPABLE);
if (mii_exstatus & MII_1000BT_STAT_LP_FDX_CAP) {
ngep->param_lp_autoneg = B_TRUE;
ngep->param_link_autoneg = B_TRUE;
ngep->param_lp_1000fdx = B_TRUE;
}
if (mii_exstatus & MII_1000BT_STAT_LP_HDX_CAP) {
ngep->param_lp_autoneg = B_TRUE;
ngep->param_link_autoneg = B_TRUE;
ngep->param_lp_1000hdx = B_TRUE;
}
if (lpan & MII_100BASET_FD)
ngep->param_lp_100fdx = B_TRUE;
if (lpan & MII_100BASET_HD)
ngep->param_lp_100hdx = B_TRUE;
if (lpan & MII_10BASET_FD)
ngep->param_lp_10fdx = B_TRUE;
if (lpan & MII_10BASET_HD)
ngep->param_lp_10hdx = B_TRUE;
if (lpan & MII_LP_ASYM_PAUSE)
ngep->param_lp_asym_pause = B_TRUE;
if (lpan & MII_LP_PAUSE)
ngep->param_lp_pause = B_TRUE;
if (linkup) {
ngep->param_link_up = linkup;
ngep->param_link_speed = nge_copper_link_speed[speed];
ngep->param_link_duplex = nge_copper_link_duplex[duplex];
} else {
ngep->param_link_up = B_FALSE;
ngep->param_link_speed = 0;
ngep->param_link_duplex = LINK_DUPLEX_UNKNOWN;
}
NGE_DEBUG(("nge_check_copper: link now %s speed %d duplex %d",
UPORDOWN(ngep->param_link_up),
ngep->param_link_speed,
ngep->param_link_duplex));
return (B_FALSE);
}
/*
* Because the network chipset embedded in Ck8-04 bridge is only a mac chipset,
* the different vendor can use different media(serdes and copper).
* To make it easier to extend the driver to support more platforms with ck8-04,
* For example, one platform with serdes support,
* wrapper phy operation functions.
* But now, only supply copper phy operations.
*/
static const phys_ops_t copper_ops = {
nge_phy_restart,
nge_update_copper,
nge_check_copper
};
/*
* Here we have to determine which media we're using (copper or serdes).
* Once that's done, we can initialise the physical layer appropriately.
*/
void
nge_phys_init(nge_t *ngep)
{
nge_mac2phy m2p;
NGE_TRACE(("nge_phys_init($%p)", (void *)ngep));
/* Get the phy type from MAC2PHY register */
m2p.m2p_val = nge_reg_get32(ngep, NGE_MAC2PHY);
ngep->phy_mode = m2p.m2p_bits.in_type;
if ((ngep->phy_mode != RGMII_IN) && (ngep->phy_mode != MII_IN)) {
ngep->phy_mode = RGMII_IN;
m2p.m2p_bits.in_type = RGMII_IN;
nge_reg_put32(ngep, NGE_MAC2PHY, m2p.m2p_val);
}
/*
* Probe for the type of the PHY.
*/
ngep->phy_xmii_addr = 1;
(void) nge_phy_probe(ngep);
ngep->chipinfo.flags |= CHIP_FLAG_COPPER;
ngep->physops = &copper_ops;
(*(ngep->physops->phys_restart))(ngep);
}
|