xref: /reactos/drivers/network/dd/dc21x4/eeprom.h (revision 4514e91d)
1 /*
2  * PROJECT:     ReactOS DC21x4 Driver
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     EEPROM specific definitions
5  * COPYRIGHT:   Copyright 2023 Dmitry Borisov <di.sean@protonmail.com>
6  */
7 
8 #pragma once
9 
10 #include <pshpack1.h>
11 typedef struct _DC_SROM_COMPACT_BLOCK
12 {
13     USHORT SelectedConnectionType;
14     UCHAR GpioDirection; /* 21140 only */
15     UCHAR BlockCount;
16 } DC_SROM_COMPACT_BLOCK, *PDC_SROM_COMPACT_BLOCK;
17 #include <poppack.h>
18 
19 typedef struct _DC_SROM_REPAIR_ENTRY
20 {
21 #if DBG
22     PCSTR Name;
23 #endif
24     PUCHAR InfoLeaf;
25     ULONG Length;
26 } DC_SROM_REPAIR_ENTRY, *PDC_SROM_REPAIR_ENTRY;
27 
28 typedef struct _DC_SROM_ENTRY
29 {
30     LIST_ENTRY ListEntry;
31     ULONG BusNumber;
32     DC_CHIP_TYPE ChipType;
33     UCHAR DeviceNumber;
34     ULONG InterruptLevel;
35     ULONG InterruptVector;
36     ULONG DeviceBitmap;
37     UCHAR SRomImage[ANYSIZE_ARRAY];
38 } DC_SROM_ENTRY, *PDC_SROM_ENTRY;
39 
40 #define SRomIsBlockExtended(Byte)           ((Byte) & 0x80)
41 #define SRomGetExtendedBlockLength(Byte)    (((Byte) & 0x7F) + 1)
42 #define SRomGetMediaCode(Byte)              ((Byte) & 0x3F)
43 #define SRomBlockHasExtendedData(Byte)      ((Byte) & 0x40)
44 #define SRomIsDefaultMedia(Word)            ((Word) & 0x4000)
45 #define SRomMediaHasActivityIndicator(Word) (((Word) & 0x8000) == 0)
46 #define SRomMediaActivityIsActiveLow(Word)  ((Word) & 0x80)
47 #define SRomMediaGetSenseMask(Word)         (1 << (((Word) & 0x0E) >> 1))
48 #define SRomCommandToOpMode(Word)           (((Word) & 0x71) << 18)
49 #define SRomMediaAutoSense(Media)           ((Media) & 0x800)
50 #define SRomMediaToMediaNumber(Word)        ((Word) & 0x1F)
51 #define SRomHmrRegAddress(Byte)             ((Byte) & 0x1F)
52 
53 #define SROM_OPMODE_MASK \
54     (DC_OPMODE_PORT_SELECT | \
55      DC_OPMODE_PORT_XMIT_10 | \
56      DC_OPMODE_PORT_PCS | \
57      DC_OPMODE_PORT_SCRAMBLER)
58 
59 #define EE_SIZE     128
60 #define EAR_SIZE    32
61 
62 #define EAR_TEST_PATTERN    0xAA5500FFAA5500FFULL
63 
64 #define EEPROM_CMD_WRITE    5
65 #define EEPROM_CMD_READ     6
66 #define EEPROM_CMD_ERASE    7
67 
68 #define EEPROM_CMD_LENGTH   3
69 
70 /*
71  * Various offsets in the SROM
72  */
73 #define SROM_VERSION                18
74 #define SROM_CONTROLLER_COUNT       19
75 #define SROM_MAC_ADDRESS            20
76 #define SROM_DEVICE_NUMBER(n)       (26 + ((n) * 3))
77 #define SROM_LEAF_OFFSET(n)         (27 + ((n) * 3))
78 #define SROM_CHECKSUM_V1            126
79 #define SROM_CHECKSUM_V2            94
80 
81 /*
82  * SROM compact and extended format types
83  */
84 #define SROM_BLOCK_TYPE_GPR             0
85 #define SROM_BLOCK_TYPE_MII_1           1
86 #define SROM_BLOCK_TYPE_SIA             2
87 #define SROM_BLOCK_TYPE_MII_2           3
88 #define SROM_BLOCK_TYPE_SYM             4
89 #define SROM_BLOCK_TYPE_RESET           5
90 #define SROM_BLOCK_TYPE_PHY_SHUTDOWN    6
91 #define SROM_BLOCK_TYPE_HOMERUN         7
92 
93 #define SROM_MAX_STREAM_REGS    6
94 
95 /*
96  * SROM media codes
97  */
98 #define SROM_MEDIA_10T          0
99 #define SROM_MEDIA_BNC          1
100 #define SROM_MEDIA_AUI          2
101 #define SROM_MEDIA_100T_HD      3
102 #define SROM_MEDIA_10T_FD       4
103 #define SROM_MEDIA_100TX_FD     5
104 #define SROM_MEDIA_100T4        6
105 #define SROM_MEDIA_100FX_HD     7
106 #define SROM_MEDIA_100FX_FD     8
107 #define SROM_MEDIA_MAX          8
108 #define SROM_MEDIA_HMR          18
109