2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1996 NeXT Software, Inc.
26 * - Intel 82557 eeprom access object
30 * 6-Mar-96 Dieter Siegmund (dieter) at NeXT
34 #ifndef _I82557EEPROM_H
35 #define _I82557EEPROM_H
37 #include "i82557Inline.h"
40 #define BITS_IN_SHORT 16
41 #define MIN_SK_HIGH 20
43 #define NUM_EEPROM_WORDS 0x40
44 #define EEPROM_CHECKSUM_VALUE 0xbaba
46 //-------------------------------------------------------------------------
47 // Compatibility Byte 0
48 // 8-bit, word 0x3, low byte
49 //-------------------------------------------------------------------------
50 #define EEPROM_C0_MC_100 BIT(1)
51 #define EEPROM_C0_MC_10 BIT(0)
53 //-------------------------------------------------------------------------
54 // Compatibility Byte 1
55 // 8-bit, word 0x3, high byte
56 //-------------------------------------------------------------------------
57 #define EEPROM_C1_OEM BIT(0)
59 //-------------------------------------------------------------------------
61 // 8-bit, word 0x5, high byte
62 //-------------------------------------------------------------------------
63 #define EEPROM_TYPE_82558 2
64 #define EEPROM_TYPE_82557 1
66 //-------------------------------------------------------------------------
68 // 8-bit, word 0x5, low byte
69 //-------------------------------------------------------------------------
70 #define EEPROM_CON_MII BIT(3)
71 #define EEPROM_CON_AUI BIT(2)
72 #define EEPROM_CON_BNC BIT(1)
73 #define EEPROM_CON_RJ45 BIT(0)
75 //-------------------------------------------------------------------------
77 // 16-bit, Primary word 0x6, Secondary word 0x7.
78 //-------------------------------------------------------------------------
79 #define EEPROM_PHY_10 BIT(15)
80 #define EEPROM_PHY_VSCR BIT(14)
81 #define EEPROM_PHY_DEVICE_SHIFT 8
82 #define EEPROM_PHY_DEVICE_MASK CSR_MASK(EEPROM_PHY_DEVICE, 0x3f)
83 #define EEPROM_PHY_ADDRESS_SHIFT 0
84 #define EEPROM_PHY_ADDRESS_MASK CSR_MASK(EEPROM_PHY_ADDRESS, 0xff)
88 PHYDevice_Intel82553_A_B_step_e
,
89 PHYDevice_Intel82553_C_step_e
,
90 PHYDevice_Intel82503_e
,
91 PHYDevice_NationalDP83840_TX_C_step_e
,
92 PHYDevice_Seeq80C240_T4_e
,
93 PHYDevice_Seeq80C24_e
,
94 PHYDevice_Intel82555_e
,
95 PHYDevice_MicroLinear_e
,
96 PHYDevice_Level_One_e
,
97 PHYDevice_NationalDP82840A_e
,
103 PHYDeviceNames(unsigned int i
)
106 "No PHY device installed",
107 "Intel 82553 (PHY 100) A or B step",
108 "Intel 82553 (PHY 100) C step",
110 "National DP83840 C step 100Base-TX",
111 "Seeq 80C240 100Base-T4",
113 "Intel 82555 10/100Base-TX PHY",
114 "MicroLinear 10Mbps",
120 if (i
> PHYDevice_Last_e
)
121 i
= PHYDevice_Last_e
;
126 #define PRIMARY_PHY 0
127 #define SECONDARY_PHY 1
131 IOEthernetAddress addr
;
132 UInt8 compatibility_0
;
133 UInt8 compatibility_1
;
136 UInt8 controllerType
;
137 #define I82557_CONTROLLER_TYPE 1
138 #define I82558_CONTROLLER_TYPE 2
139 UInt16 phys
[NUM_PHYS
];
140 UInt8 PWANumber
[NPWA_BYTES
];
148 void EEPROMWriteBit(volatile eeprom_control_t
* ee_p
, bool bit
)
151 OSSetLE16(ee_p
, EEPROM_CONTROL_EEDI
);
153 OSClearLE16(ee_p
, EEPROM_CONTROL_EEDI
);
155 OSSetLE16(ee_p
, EEPROM_CONTROL_EESK
);
156 IODelay(MIN_SK_HIGH
);
157 OSClearLE16(ee_p
, EEPROM_CONTROL_EESK
);
162 bool EEPROMReadBit(volatile eeprom_control_t
* ee_p
)
166 OSSetLE16(ee_p
, EEPROM_CONTROL_EESK
);
167 IODelay(MIN_SK_HIGH
);
168 bit
= (OSReadLE16(ee_p
) & EEPROM_CONTROL_EEDO
) ? 1 : 0;
169 OSClearLE16(ee_p
, EEPROM_CONTROL_EESK
);
175 void EEPROMEnable(volatile eeprom_control_t
* ee_p
)
177 OSSetLE16(ee_p
, EEPROM_CONTROL_EECS
);
182 void EEPROMDisable(volatile eeprom_control_t
* ee_p
)
184 OSClearLE16(ee_p
, EEPROM_CONTROL_EECS
);
188 class i82557eeprom
: public OSObject
190 OSDeclareDefaultStructors(i82557eeprom
)
193 volatile eeprom_control_t
* ee_p
;
196 UInt16 words
[NUM_EEPROM_WORDS
];
200 static i82557eeprom
* withAddress(volatile eeprom_control_t
* p
);
202 bool initWithAddress(volatile eeprom_control_t
* p
);
204 UInt16
readWord(int offset
);
206 EEPROM_t
* getContents();
211 #endif /* !_I82557EEPROM_H */