ReactOS 0.4.15-dev-8408-g466a198
media.c File Reference
#include "dc21x4.h"
#include <debug.h>
Include dependency graph for media.c:

Go to the source code of this file.

Functions

VOID MediaIndicateConnect (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN LinkUp)
 
static ULONG MediaMiiNextMedia (_In_ PDC21X4_ADAPTER Adapter)
 
static VOID MediaMiiSetSpeedAndDuplex (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN FullDuplex, _In_ BOOLEAN Speed100)
 
static VOID MediaMiiGetSpeedAndDuplex (_In_ PDC21X4_ADAPTER Adapter, _Out_ PBOOLEAN FullDuplex, _Out_ PBOOLEAN Speed100)
 
BOOLEAN MediaMiiCheckLink (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaMiiSelect (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaSelectMiiPort (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN ResetPhy)
 
VOID MediaSiaSelect (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaGprSelect (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaInitDefaultMedia (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG MediaNumber)
 
static VOID MediaInitOpMode2114x (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaInitMediaList (_In_ PDC21X4_ADAPTER Adapter)
 

Function Documentation

◆ MediaGprSelect()

VOID MediaGprSelect ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 303 of file media.c.

305{
306 ULONG OpMode;
307 PDC_MEDIA Media;
308
309 INFO("Selected media %s\n", MediaNumber2Str(Adapter, Adapter->MediaNumber));
310
311 Media = &Adapter->Media[Adapter->MediaNumber];
312
313 DC_WRITE(Adapter, DcCsr12_Gpio, Media->GpioData);
314
315 OpMode = Adapter->OpMode;
316 OpMode &= ~DC_OPMODE_MEDIA_MASK;
317 OpMode |= Media->OpMode;
318 Adapter->OpMode = OpMode;
319
320 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
321}
#define DC_WRITE(Adapter, Register, Value)
Definition: dc21x4.h:272
@ DcCsr6_OpMode
Definition: dc21x4hw.h:180
@ DcCsr12_Gpio
Definition: dc21x4hw.h:187
#define MediaNumber2Str
Definition: debug.h:93
#define INFO
Definition: debug.h:89
ULONG OpMode
Definition: media.h:12
USHORT GpioData
Definition: media.h:15
uint32_t ULONG
Definition: typedefs.h:59

Referenced by DcSetupAdapter(), and MediaMonitor21140Dpc().

◆ MediaIndicateConnect()

VOID MediaIndicateConnect ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  LinkUp 
)

Definition at line 17 of file media.c.

20{
21 /* Nothing to do */
22 if (Adapter->LinkUp == LinkUp)
23 return;
24
25 Adapter->LinkUp = LinkUp;
26
27 INFO_VERB("Link %sconnected, media is %s\n",
28 LinkUp ? "" : "dis",
29 MediaNumber2Str(Adapter, Adapter->MediaNumber));
30
31 NdisDprReleaseSpinLock(&Adapter->ModeLock);
32
33 NdisMIndicateStatus(Adapter->AdapterHandle,
35 NULL,
36 0);
37 NdisMIndicateStatusComplete(Adapter->AdapterHandle);
38
39 NdisDprAcquireSpinLock(&Adapter->ModeLock);
40}
#define NULL
Definition: types.h:112
#define INFO_VERB
Definition: debug.h:90
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
#define NdisMIndicateStatusComplete(MiniportAdapterHandle)
Definition: ndis.h:5580
#define NdisDprReleaseSpinLock(_SpinLock)
Definition: ndis.h:4133
#define NDIS_STATUS_MEDIA_DISCONNECT
Definition: ndis.h:362
#define NdisDprAcquireSpinLock(_SpinLock)
Definition: ndis.h:4124
#define NdisMIndicateStatus(MiniportAdapterHandle, GeneralStatus, StatusBuffer, StatusBufferSize)
Definition: ndis.h:5570
@ LinkUp
Definition: srb.h:741

Referenced by Media143Handle100LinkChange(), Media143Handle10LinkFail(), Media143Handle10LinkPass(), Media143SelectNextMedia(), MediaLinkStateChange21040(), MediaLinkStateChange21041(), MediaMonitor143(), MediaMonitor21040Dpc(), MediaMonitor21041Dpc(), MediaMonitor21140Dpc(), and MediaMonitor21143Dpc().

◆ MediaInitDefaultMedia()

VOID MediaInitDefaultMedia ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  MediaNumber 
)

Definition at line 325 of file media.c.

328{
329 ULONG Csr14, i;
330 BOOLEAN UseMii;
331
332 PAGED_CODE();
333
334 /* Media auto-detection */
335 if (MediaNumber == MEDIA_AUTO)
336 {
337 Adapter->Flags |= DC_AUTOSENSE;
338
339 /* Initial value for all boards */
340 Adapter->DefaultMedia = MEDIA_10T;
341
342 Adapter->MiiAdvertising = Adapter->MiiMedia.Advertising;
343 Adapter->MiiControl = MII_CR_AUTONEG | MII_CR_AUTONEG_RESTART;
344
345 switch (Adapter->ChipType)
346 {
347 case DC21041:
348 {
349 /* Errata: don't enable auto-negotiation */
350 if (Adapter->RevisionId < 0x20)
351 break;
352
353 /* Advertise 10T HD and 10T FD. The chip chooses the 10T FD mode automatically */
354 Adapter->Media[MEDIA_10T].Csr14 |= DC_SIA_TXRX_AUTONEG | DC_SIA_TXRX_ADV_10T_HD;
355 Adapter->Media[MEDIA_10T].OpMode |= DC_OPMODE_FULL_DUPLEX;
356 break;
357 }
358
359 case DC21140:
360 {
361 /* Pick the default media */
362 if (Adapter->Features & DC_HAS_MII)
363 {
364 Adapter->DefaultMedia = MEDIA_MII;
365 break;
366 }
367
368 /* The final entry in the media list should be checked first */
369 _BitScanReverse(&Adapter->DefaultMedia, Adapter->MediaBitmap);
370
371 /*
372 * Select the first half-duplex media.
373 * If you want to be able to use 21140 boards without MII in full-duplex mode,
374 * you have to manually select the media.
375 */
376 for (i = Adapter->DefaultMedia; i > 0; --i)
377 {
378 if ((Adapter->MediaBitmap & (1 << i)) && !MEDIA_IS_FD(i))
379 break;
380 }
381 Adapter->DefaultMedia = i;
382 break;
383 }
384
385 case DC21143:
386 case DC21145:
387 {
388 /* Pick the default media */
389 if (Adapter->Features & DC_HAS_MII)
390 {
391 Adapter->DefaultMedia = MEDIA_MII;
392 }
393 else if (Adapter->MediaBitmap & (1 << MEDIA_10T))
394 {
395 /* Start at 10mbps to do internal auto-negotiation */
396 Adapter->DefaultMedia = MEDIA_10T;
397 }
398 else
399 {
400 /* The final entry in the media list should be checked first */
401 _BitScanReverse(&Adapter->DefaultMedia, Adapter->MediaBitmap);
402 }
403
404 /* Enable the PCS function to do 100mbps parallel detection */
405 if (Adapter->SymAdvertising & MII_ADV_100)
406 {
407 Adapter->Media[MEDIA_10T].OpMode |= DC_OPMODE_PORT_PCS;
408 Adapter->Media[MEDIA_10T_FD].OpMode |= DC_OPMODE_PORT_PCS;
409 Adapter->Media[MEDIA_AUI].OpMode |= DC_OPMODE_PORT_PCS;
410 Adapter->Media[MEDIA_BNC].OpMode |= DC_OPMODE_PORT_PCS;
411 Adapter->Media[MEDIA_HMR].OpMode |= DC_OPMODE_PORT_PCS;
412 }
413
414 Csr14 = DC_SIA_TXRX_AUTONEG;
415
416 if (Adapter->SymAdvertising & MII_ADV_10T_HD)
417 Csr14 |= DC_SIA_TXRX_ADV_10T_HD;
418
419 /* When NWay is turned on, the FDX bit advertises 10T FD */
420 if (Adapter->SymAdvertising & MII_ADV_10T_FD)
421 Adapter->Media[MEDIA_10T].OpMode |= DC_OPMODE_FULL_DUPLEX;
422
423 if (Adapter->SymAdvertising & MII_ADV_100T_HD)
425
426 if (Adapter->SymAdvertising & MII_ADV_100T_FD)
428
429 if (Adapter->SymAdvertising & MII_ADV_100T4)
430 Csr14 |= DC_SIA_TXRX_ADV_100T4;
431
432 /* Advertise the PHY capability */
433 Adapter->Media[MEDIA_10T].Csr14 |= Csr14;
434
435 /* This media may use GPIO data different from the 10T HD */
436 Adapter->Media[MEDIA_10T_FD].Csr14 |= Csr14;
437 break;
438 }
439
440 default:
441 break;
442 }
443 }
444 else /* Forced speed and duplex */
445 {
446 UseMii = FALSE;
447
448 if (Adapter->Features & DC_HAS_MII)
449 {
450 if (!MEDIA_MII_OVERRIDE(MediaNumber))
451 {
452 UseMii = TRUE;
453 }
454 }
455
456 if (!UseMii)
457 {
458 Adapter->DefaultMedia = MediaNumber;
459
460 if (MEDIA_IS_10T(MediaNumber))
461 {
462 Adapter->InterruptMask &= ~DC_IRQ_LINK_CHANGED;
463 Adapter->LinkStateChangeMask &= ~DC_IRQ_LINK_CHANGED;
464 }
465
466 if (MEDIA_IS_100(MediaNumber))
467 {
468 Adapter->InterruptMask &= ~(DC_IRQ_LINK_FAIL | DC_IRQ_LINK_PASS);
469 Adapter->LinkStateChangeMask &= ~(DC_IRQ_LINK_FAIL | DC_IRQ_LINK_PASS);
470 }
471 }
472 else
473 {
474 ULONG MiiAdvertising, MiiControl;
475 Adapter->DefaultMedia = MEDIA_MII;
476
477 switch (MediaNumber)
478 {
479 case MEDIA_10T:
480 MiiAdvertising = MII_ADV_10T_HD;
481 MiiControl = 0;
482 break;
483 case MEDIA_10T_FD:
484 MiiAdvertising = MII_ADV_10T_FD;
485 MiiControl = MII_CR_FULL_DUPLEX;
486 break;
487 case MEDIA_100TX_HD:
488 MiiAdvertising = MII_ADV_100T_HD;
489 MiiControl = MII_CR_SPEED_SELECTION;
490 break;
491 case MEDIA_100TX_FD:
492 MiiAdvertising = MII_ADV_100T_FD;
494 break;
495 case MEDIA_100T4:
496 MiiAdvertising = MII_ADV_100T4;
497 MiiControl = MII_CR_SPEED_SELECTION;
498 break;
499 default:
500 MiiAdvertising = 0;
501 MiiControl = 0;
502 break;
503 }
504
505 if (MiiControl & MII_CR_SPEED_SELECTION)
506 Adapter->LinkSpeedMbps = 100;
507 else
508 Adapter->LinkSpeedMbps = 10;
509
510 Adapter->MiiAdvertising = MiiAdvertising;
511 Adapter->MiiControl = MiiControl;
512 }
513 }
514
515 INFO("Default media is %s\n", MediaNumber2Str(Adapter, Adapter->DefaultMedia));
516}
#define PAGED_CODE()
unsigned char BOOLEAN
#define DC_HAS_MII
Definition: dc21x4.h:113
#define DC_AUTOSENSE
Definition: dc21x4.h:124
#define MII_ADV_10T_FD
Definition: dc21x4hw.h:574
#define DC_SIA_TXRX_ADV_100TX_FD
Definition: dc21x4hw.h:471
#define DC_SIA_TXRX_ADV_10T_HD
Definition: dc21x4hw.h:460
#define DC_OPMODE_FULL_DUPLEX
Definition: dc21x4hw.h:327
#define MII_ADV_100T4
Definition: dc21x4hw.h:577
@ DC21145
Definition: dc21x4hw.h:16
@ DC21140
Definition: dc21x4hw.h:14
@ DC21041
Definition: dc21x4hw.h:13
@ DC21143
Definition: dc21x4hw.h:15
#define DC_SIA_TXRX_ADV_100TX_HD
Definition: dc21x4hw.h:470
#define MII_CR_FULL_DUPLEX
Definition: dc21x4hw.h:558
#define MII_CR_AUTONEG
Definition: dc21x4hw.h:562
#define MII_ADV_100
Definition: dc21x4hw.h:596
#define MII_CR_AUTONEG_RESTART
Definition: dc21x4hw.h:559
#define DC_OPMODE_PORT_PCS
Definition: dc21x4hw.h:338
#define DC_SIA_TXRX_AUTONEG
Definition: dc21x4hw.h:461
#define DC_SIA_TXRX_ADV_100T4
Definition: dc21x4hw.h:472
#define DC_IRQ_LINK_PASS
Definition: dc21x4hw.h:271
#define MII_ADV_100T_HD
Definition: dc21x4hw.h:575
#define MII_ADV_100T_FD
Definition: dc21x4hw.h:576
#define MII_ADV_10T_HD
Definition: dc21x4hw.h:573
#define DC_IRQ_LINK_FAIL
Definition: dc21x4hw.h:281
#define MII_CR_SPEED_SELECTION
Definition: dc21x4hw.h:563
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:180
#define MEDIA_AUI
Definition: media.h:48
#define MEDIA_MII
Definition: media.h:67
#define MEDIA_100TX_FD
Definition: media.h:52
#define MEDIA_IS_10T(MediaNumber)
Definition: media.h:114
#define MEDIA_IS_100(MediaNumber)
Definition: media.h:118
#define MEDIA_AUTO
Definition: media.h:62
#define MEDIA_IS_FD(MediaNumber)
Definition: media.h:106
#define MEDIA_MII_OVERRIDE(MediaNumber)
Definition: media.h:102
#define MEDIA_10T_FD
Definition: media.h:51
#define MEDIA_10T
Definition: media.h:46
#define MEDIA_HMR
Definition: media.h:56
#define MEDIA_100T4
Definition: media.h:53
#define MEDIA_BNC
Definition: media.h:47
#define MEDIA_100TX_HD
Definition: media.h:49

Referenced by DcInitialize().

◆ MediaInitMediaList()

VOID MediaInitMediaList ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 547 of file media.c.

549{
550 PAGED_CODE();
551
552 /*
553 * Set the default internal values for the SIA/SYM operating modes.
554 * The SROM parsing code may later overwrite them.
555 */
556 switch (Adapter->ChipType)
557 {
558 case DC21040:
559 {
560 Adapter->Media[MEDIA_10T].Csr13 = 0x8F01;
561 Adapter->Media[MEDIA_10T].Csr14 = 0xFFFF;
562 Adapter->Media[MEDIA_10T].Csr15 = 0x0000;
563
564 Adapter->Media[MEDIA_BNC].Csr13 = 0x8F09;
565 Adapter->Media[MEDIA_BNC].Csr14 = 0x0705;
566 Adapter->Media[MEDIA_BNC].Csr15 = 0x0006;
567
568 Adapter->Media[MEDIA_10T_FD].Csr13 = 0x8F01;
569 Adapter->Media[MEDIA_10T_FD].Csr14 = 0xFFFD;
570 Adapter->Media[MEDIA_10T_FD].Csr15 = 0x0000;
571 Adapter->Media[MEDIA_10T_FD].OpMode = DC_OPMODE_FULL_DUPLEX;
572 break;
573 }
574
575 case DC21041:
576 {
577 Adapter->Media[MEDIA_10T].Csr13 = 0xEF01;
578 Adapter->Media[MEDIA_10T].Csr14 = 0xFF3F;
579 Adapter->Media[MEDIA_10T].Csr15 = 0x0008;
580
581 Adapter->Media[MEDIA_BNC].Csr13 = 0xEF09;
582 Adapter->Media[MEDIA_BNC].Csr14 = 0xF7FD;
583 Adapter->Media[MEDIA_BNC].Csr15 = 0x0006;
584
585 Adapter->Media[MEDIA_AUI].Csr13 = 0xEF09;
586 Adapter->Media[MEDIA_AUI].Csr14 = 0xF7FD;
587 Adapter->Media[MEDIA_AUI].Csr15 = 0x000E;
588
589 Adapter->Media[MEDIA_10T_HD].Csr13 = 0xEF01;
590 Adapter->Media[MEDIA_10T_HD].Csr14 = 0x7F3F;
591 Adapter->Media[MEDIA_10T_HD].Csr15 = 0x0008;
592
593 Adapter->Media[MEDIA_10T_FD].Csr13 = 0xEF01;
594 Adapter->Media[MEDIA_10T_FD].Csr14 = 0x7F3D;
595 Adapter->Media[MEDIA_10T_FD].Csr15 = 0x0008;
596 Adapter->Media[MEDIA_10T_FD].OpMode = DC_OPMODE_FULL_DUPLEX;
597 break;
598 }
599
600 case DC21140:
601 {
602 MediaInitOpMode2114x(Adapter);
603 break;
604 }
605
606 case DC21143:
607 case DC21145:
608 {
609 Adapter->Media[MEDIA_10T].Csr13 = 0x0001;
610 Adapter->Media[MEDIA_10T].Csr14 = 0x7F3F;
611 Adapter->Media[MEDIA_10T].Csr15 = 0x0008;
612
613 Adapter->Media[MEDIA_BNC].Csr13 = 0x0009;
614 Adapter->Media[MEDIA_BNC].Csr14 = 0x0705;
615 Adapter->Media[MEDIA_BNC].Csr15 = 0x0006;
616
617 Adapter->Media[MEDIA_AUI].Csr13 = 0x0009;
618 Adapter->Media[MEDIA_AUI].Csr14 = 0x0705;
619 Adapter->Media[MEDIA_AUI].Csr15 = 0x000E;
620
621 Adapter->Media[MEDIA_10T_FD].Csr13 = 0x0001;
622 Adapter->Media[MEDIA_10T_FD].Csr14 = 0x7F3D;
623 Adapter->Media[MEDIA_10T_FD].Csr15 = 0x0008;
624
625 Adapter->Media[MEDIA_HMR].Csr13 = 0x0009;
626 Adapter->Media[MEDIA_HMR].Csr14 = 0x0505;
627 Adapter->Media[MEDIA_HMR].Csr15 = 0x0010;
628
629 MediaInitOpMode2114x(Adapter);
630 break;
631 }
632
633 default:
634 break;
635 }
636}
@ DC21040
Definition: dc21x4hw.h:12
static VOID MediaInitOpMode2114x(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:521
#define MEDIA_10T_HD
Definition: media.h:50

Referenced by DcInitialize().

◆ MediaInitOpMode2114x()

static VOID MediaInitOpMode2114x ( _In_ PDC21X4_ADAPTER  Adapter)
static

Definition at line 521 of file media.c.

523{
524 PAGED_CODE();
525
526 Adapter->Media[MEDIA_10T ].OpMode = 0;
527 Adapter->Media[MEDIA_BNC ].OpMode = 0;
528 Adapter->Media[MEDIA_AUI ].OpMode = 0;
529 Adapter->Media[MEDIA_100TX_HD].OpMode = DC_OPMODE_PORT_SELECT |
531 Adapter->Media[MEDIA_10T_FD ].OpMode = DC_OPMODE_FULL_DUPLEX;
534 Adapter->Media[MEDIA_100T4 ].OpMode = DC_OPMODE_PORT_SELECT |
536 Adapter->Media[MEDIA_100FX_HD].OpMode = DC_OPMODE_PORT_SELECT |
542 Adapter->Media[MEDIA_HMR ].OpMode = DC_OPMODE_PORT_HEARTBEAT_DISABLE;
543}
#define DC_OPMODE_PORT_HEARTBEAT_DISABLE
Definition: dc21x4hw.h:335
#define DC_OPMODE_PORT_SELECT
Definition: dc21x4hw.h:334
#define MEDIA_100FX_FD
Definition: media.h:55
#define MEDIA_100FX_HD
Definition: media.h:54

Referenced by MediaInitMediaList().

◆ MediaMiiCheckLink()

BOOLEAN MediaMiiCheckLink ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 141 of file media.c.

143{
144 ULONG MiiStatus;
145 BOOLEAN FullDuplex, Speed100;
146
147 /* The link status is a latched-low bit, read it twice */
148 if (!MiiRead(Adapter, Adapter->PhyAddress, MII_STATUS, &MiiStatus))
149 {
150 goto NoLink;
151 }
152 if (!(MiiStatus & MII_SR_LINK_STATUS))
153 {
154 MiiRead(Adapter, Adapter->PhyAddress, MII_STATUS, &MiiStatus);
155 }
156 TRACE("MII Status %04lx\n", MiiStatus);
157
158 /* Check the link status */
159 if (!(MiiStatus & MII_SR_LINK_STATUS))
160 {
161NoLink:
162 /* No link detected, check the other port */
163 if (Adapter->MediaBitmap & ((1 << MEDIA_HMR) | (1 << MEDIA_AUI) | (1 << MEDIA_BNC)))
164 {
165 if ((Adapter->Features & DC_MII_AUTOSENSE) && !MEDIA_IS_FIXED(Adapter))
166 {
167 Adapter->MediaNumber = MediaMiiNextMedia(Adapter);
168 MediaSiaSelect(Adapter);
169 }
170 }
171
172 return FALSE;
173 }
174
175 /* If we are forcing speed and duplex */
176 if (MEDIA_IS_FIXED(Adapter))
177 {
178 FullDuplex = !!(Adapter->MiiControl & MII_CR_FULL_DUPLEX);
179 Speed100 = !!(Adapter->MiiControl & MII_CR_SPEED_SELECTION);
180 }
181 else
182 {
183 /* Check auto-negotiation is complete */
184 if (!(MiiStatus & MII_SR_AUTONEG_COMPLETE))
185 return FALSE;
186
187 MediaMiiGetSpeedAndDuplex(Adapter, &FullDuplex, &Speed100);
188 }
189
190 /* Set the link speed and duplex */
191 MediaMiiSetSpeedAndDuplex(Adapter, FullDuplex, Speed100);
192
193 return TRUE;
194}
#define DC_MII_AUTOSENSE
Definition: dc21x4.h:116
BOOLEAN MiiRead(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _Out_ PULONG Data)
Definition: phy.c:101
#define MII_STATUS
Definition: dc21x4hw.h:566
#define MII_SR_AUTONEG_COMPLETE
Definition: dc21x4hw.h:568
#define MII_SR_LINK_STATUS
Definition: dc21x4hw.h:567
static VOID MediaMiiGetSpeedAndDuplex(_In_ PDC21X4_ADAPTER Adapter, _Out_ PBOOLEAN FullDuplex, _Out_ PBOOLEAN Speed100)
Definition: media.c:101
static VOID MediaMiiSetSpeedAndDuplex(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN FullDuplex, _In_ BOOLEAN Speed100)
Definition: media.c:64
VOID MediaSiaSelect(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:268
static ULONG MediaMiiNextMedia(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:44
#define MEDIA_IS_FIXED(Adapter)
Definition: media.h:126
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by MediaMonitor21140Dpc(), and MediaMonitor21143Dpc().

◆ MediaMiiGetSpeedAndDuplex()

static VOID MediaMiiGetSpeedAndDuplex ( _In_ PDC21X4_ADAPTER  Adapter,
_Out_ PBOOLEAN  FullDuplex,
_Out_ PBOOLEAN  Speed100 
)
static

Definition at line 101 of file media.c.

105{
106 ULONG MiiLinkPartnerAbility, AdvLpa;
107
108 MiiRead(Adapter, Adapter->PhyAddress, MII_AUTONEG_LINK_PARTNER, &MiiLinkPartnerAbility);
109
110 TRACE("MII LPA %04lx\n", MiiLinkPartnerAbility);
111
112 AdvLpa = Adapter->MiiMedia.Advertising & MiiLinkPartnerAbility;
113 if (AdvLpa & MII_LP_100T_FD)
114 {
115 *FullDuplex = TRUE;
116 *Speed100 = TRUE;
117 }
118 else if (AdvLpa & MII_LP_100T4)
119 {
120 *FullDuplex = FALSE;
121 *Speed100 = TRUE;
122 }
123 else if (AdvLpa & MII_LP_100T_HD)
124 {
125 *FullDuplex = FALSE;
126 *Speed100 = TRUE;
127 }
128 else if (AdvLpa & MII_LP_10T_FD)
129 {
130 *FullDuplex = TRUE;
131 *Speed100 = FALSE;
132 }
133 else
134 {
135 *FullDuplex = FALSE;
136 *Speed100 = FALSE;
137 }
138}
#define MII_LP_100T_HD
Definition: dc21x4hw.h:583
#define MII_LP_10T_FD
Definition: dc21x4hw.h:582
#define MII_LP_100T_FD
Definition: dc21x4hw.h:584
#define MII_LP_100T4
Definition: dc21x4hw.h:585
#define MII_AUTONEG_LINK_PARTNER
Definition: dc21x4hw.h:580

Referenced by MediaMiiCheckLink().

◆ MediaMiiNextMedia()

static ULONG MediaMiiNextMedia ( _In_ PDC21X4_ADAPTER  Adapter)
static

Definition at line 44 of file media.c.

46{
48 Adapter->LastReceiveActivity = (ULONG)Adapter->Statistics.ReceiveOk;
49
50 /*
51 * In MII mode, we don't know exactly which port is active.
52 * Switch to the media with a higher priority.
53 */
54 if (Adapter->MediaBitmap & (1 << MEDIA_HMR))
55 return MEDIA_HMR;
56 else if (Adapter->MediaBitmap & (1 << MEDIA_AUI))
57 return MEDIA_AUI;
58 else
59 return MEDIA_BNC;
60}
#define DC_MODE_AUI_FAILED
Definition: dc21x4.h:166
#define DC_MODE_BNC_FAILED
Definition: dc21x4.h:167
#define DC_MODE_TEST_PACKET
Definition: dc21x4.h:165
if(dx< 0)
Definition: linetemp.h:194

Referenced by MediaMiiCheckLink().

◆ MediaMiiSelect()

VOID MediaMiiSelect ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 197 of file media.c.

199{
200 ULONG MiiControl, MiiAdvertise;
201
202 MiiRead(Adapter, Adapter->PhyAddress, MII_CONTROL, &MiiControl);
205 MiiWrite(Adapter, Adapter->PhyAddress, MII_CONTROL, MiiControl);
206
207 MiiControl |= Adapter->MiiControl;
208 MiiAdvertise = Adapter->MiiAdvertising;
209
210 MiiWrite(Adapter, Adapter->PhyAddress, MII_AUTONEG_ADVERTISE, MiiAdvertise | MII_ADV_CSMA);
211 MiiWrite(Adapter, Adapter->PhyAddress, MII_CONTROL, MiiControl);
212}
BOOLEAN MiiWrite(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _In_ ULONG Data)
Definition: phy.c:78
#define MII_ADV_CSMA
Definition: dc21x4hw.h:572
#define MII_AUTONEG_ADVERTISE
Definition: dc21x4hw.h:571
#define MII_CR_POWER_DOWN
Definition: dc21x4hw.h:561
#define MII_CR_RESET
Definition: dc21x4hw.h:565
#define MII_CR_ISOLATE
Definition: dc21x4hw.h:560
#define MII_CONTROL
Definition: dc21x4hw.h:556

Referenced by DcSetupAdapter(), and Media143SelectNextSerialMedia().

◆ MediaMiiSetSpeedAndDuplex()

static VOID MediaMiiSetSpeedAndDuplex ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  FullDuplex,
_In_ BOOLEAN  Speed100 
)
static

Definition at line 64 of file media.c.

68{
69 ULONG OpMode = Adapter->OpMode;
70
71 if (FullDuplex)
72 OpMode |= DC_OPMODE_FULL_DUPLEX;
73 else
74 OpMode &= ~DC_OPMODE_FULL_DUPLEX;
75
76 if (Speed100)
77 OpMode &= ~DC_OPMODE_PORT_XMIT_10;
78 else
79 OpMode |= DC_OPMODE_PORT_XMIT_10;
80
81 /* Nothing to do */
82 if (OpMode == Adapter->OpMode)
83 return;
84
85 INFO_VERB("Configuring MAC from %u %s-duplex to %u %s-duplex\n",
86 Adapter->LinkSpeedMbps,
87 (Adapter->OpMode & DC_OPMODE_FULL_DUPLEX) ? "full" : "half",
88 Speed100 ? 100 : 10,
89 FullDuplex ? "full" : "half");
90
91 Adapter->LinkSpeedMbps = Speed100 ? 100 : 10;
92
93 DcStopTxRxProcess(Adapter);
94
95 Adapter->OpMode = OpMode;
96 DC_WRITE(Adapter, DcCsr6_OpMode, Adapter->OpMode);
97}
VOID DcStopTxRxProcess(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:38
#define DC_OPMODE_PORT_XMIT_10
Definition: dc21x4hw.h:337

Referenced by MediaMiiCheckLink().

◆ MediaSelectMiiPort()

VOID MediaSelectMiiPort ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  ResetPhy 
)

Definition at line 215 of file media.c.

218{
219 ULONG OpMode, i;
220
221 if (Adapter->ChipType != DC21140)
222 {
223 DcWriteSia(Adapter, 0, 0, 0);
224 }
225
226 OpMode = Adapter->OpMode;
227 OpMode &= ~DC_OPMODE_MEDIA_MASK;
229 Adapter->OpMode = OpMode;
230
231 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
232
234
235 if (ResetPhy)
236 {
238
239 /* Execute the GPIO reset sequence */
240 if (Adapter->MiiMedia.ResetStreamLength)
241 {
242 /* Set the GPIO direction */
243 DcWriteGpio(Adapter, Adapter->MiiMedia.SetupStream[0]);
244
245 for (i = 0; i < Adapter->MiiMedia.ResetStreamLength; ++i)
246 {
247 NdisMSleep(100);
248 DcWriteGpio(Adapter, Adapter->MiiMedia.ResetStream[i]);
249 }
250
251 /* Give the PHY some time to reset */
252 NdisMSleep(5000);
253 }
254 }
255
256 /* Set the GPIO direction */
257 DcWriteGpio(Adapter, Adapter->MiiMedia.SetupStream[0]);
258
259 /* Execute the GPIO setup sequence */
260 for (i = 1; i < Adapter->MiiMedia.SetupStreamLength; ++i)
261 {
263 DcWriteGpio(Adapter, Adapter->MiiMedia.SetupStream[i]);
264 }
265}
VOID DcWriteGpio(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Value)
Definition: hardware.c:64
VOID DcWriteSia(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Csr13, _In_ ULONG Csr14, _In_ ULONG Csr15)
Definition: hardware.c:89
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define ASSERT(a)
Definition: mode.c:44
#define NdisStallExecution
Definition: ndis.h:4453
VOID EXPORT NdisMSleep(IN ULONG MicrosecondsToSleep)
Definition: miniport.c:2928

Referenced by DcInitialize(), DcSetupAdapter(), and Media143SelectNextSerialMedia().

◆ MediaSiaSelect()

VOID MediaSiaSelect ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 268 of file media.c.

270{
271 ULONG OpMode;
272 PDC_MEDIA Media;
273
274 INFO_VERB("Selected media %s\n",
275 MediaNumber2Str(Adapter, Adapter->MediaNumber));
276
277 Media = &Adapter->Media[Adapter->MediaNumber];
278
279 DcStopTxRxProcess(Adapter);
280
281 if (Adapter->ChipType != DC21041)
282 {
283 /* Make sure the reset pulse is wide enough */
285 DcWriteGpio(Adapter, Media->GpioCtrl);
287 DcWriteGpio(Adapter, Media->GpioData);
288 }
289
290 DcWriteSia(Adapter, Media->Csr13, Media->Csr14, Media->Csr15);
291
293
294 OpMode = Adapter->OpMode;
295 OpMode &= ~DC_OPMODE_MEDIA_MASK;
296 OpMode |= Media->OpMode;
297 Adapter->OpMode = OpMode;
298
299 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
300}
ULONG Csr14
Definition: media.h:22
USHORT GpioCtrl
Definition: media.h:14
ULONG Csr13
Definition: media.h:21
ULONG Csr15
Definition: media.h:23

Referenced by DcSetupAdapter(), Media041SelectNextMedia(), Media143Handle10LinkPass(), Media143HandleNWayComplete(), Media143SelectNextMedia(), Media143SelectNextSerialMedia(), MediaLinkStateChange21041(), MediaMiiCheckLink(), and MediaMonitor21041Dpc().