3 * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __LAN9118_DXE_UTIL_H__
16 #define __LAN9118_DXE_UTIL_H__
18 // Most common CRC32 Polynomial for little endian machines
19 #define CRC_POLYNOMIAL 0xEDB88320
22 This internal function reverses bits for 32bit data.
24 @param Value The data to be reversed.
26 @return Data reversed.
34 // Create an Ethernet CRC
37 IN EFI_MAC_ADDRESS
*Mac
,
46 #define Lan9118MmioRead32(a) \
47 Lan9118RawMmioRead32(a, a ## _RD_DELAY)
50 Lan9118RawMmioWrite32(
55 #define Lan9118MmioWrite32(a, v) \
56 Lan9118RawMmioWrite32(a, v, a ## _WR_DELAY)
58 /* ------------------ MAC CSR Access ------------------- */
60 // Read from MAC indirect registers
67 // Write to indirect registers
75 /* --------------- PHY Registers Access ---------------- */
77 // Read from MII register (PHY Access)
84 // Write to the MII register (PHY Access)
91 /* ---------------- EEPROM Operations ------------------ */
93 // Read from EEPROM memory
95 IndirectEEPROMRead32 (
99 // Write to EEPROM memory
101 IndirectEEPROMWrite32 (
106 /* ---------------- General Operations ----------------- */
109 Lan9118SetMacAddress (
110 EFI_MAC_ADDRESS
*Mac
,
111 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
114 // Initialise the LAN9118
117 IN EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
120 // Flags for software reset
121 #define SOFT_RESET_CHECK_MAC_ADDR_LOAD BIT0
122 #define SOFT_RESET_CLEAR_INT BIT1
123 #define SOFT_RESET_SELF_TEST BIT2
125 // Perform software reset on the LAN9118
129 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
132 // Flags for PHY reset
133 #define PHY_RESET_PMT BIT0
134 #define PHY_RESET_BCR BIT1
135 #define PHY_SOFT_RESET_CLEAR_INT BIT2
137 // Perform PHY software reset
141 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
144 // Flags for Hardware configuration
145 #define HW_CONF_USE_LEDS BIT0
147 // Configure hardware for LAN9118
151 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
154 // Configure flow control
161 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
164 // Flags for auto negotiation
165 #define AUTO_NEGOTIATE_COLLISION_TEST BIT0
166 #define AUTO_NEGOTIATE_ADVERTISE_ALL BIT1
168 // Do auto-negotiation
172 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
175 // Check the Link Status and take appropriate action
179 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
182 // Stop transmitter flags
183 #define STOP_TX_MAC BIT0
184 #define STOP_TX_CFG BIT1
185 #define STOP_TX_CLEAR BIT2
187 // Stop the transmitter
191 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
194 // Stop receiver flags
195 #define STOP_RX_CLEAR BIT0
201 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
204 // Start transmitter flags
205 #define START_TX_MAC BIT0
206 #define START_TX_CFG BIT1
207 #define START_TX_CLEAR BIT2
209 // Start the transmitter
213 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
216 // Stop receiver flags
217 #define START_RX_CLEAR BIT0
219 // Start the receiver
223 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
226 // Check Tx Data available space
230 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
233 // Check Tx Status used space
237 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
240 // Check Rx Data used space
244 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
247 // Check Rx Status used space
251 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
255 // Flags for FIFO allocation
256 #define ALLOC_USE_DEFAULT BIT0
257 #define ALLOC_USE_FIFOS BIT1
258 #define ALLOC_USE_DMA BIT2
260 // FIFO min and max sizes
261 #define TX_FIFO_MIN_SIZE 0x00000600
262 #define TX_FIFO_MAX_SIZE 0x00003600
263 //#define RX_FIFO_MIN_SIZE
264 //#define RX_FIFO_MAX_SIZE
266 // Change the allocation of FIFOs
268 ChangeFifoAllocation (
270 IN OUT UINTN
*TxDataSize OPTIONAL
,
271 IN OUT UINTN
*RxDataSize OPTIONAL
,
272 IN OUT UINT32
*TxStatusSize OPTIONAL
,
273 IN OUT UINT32
*RxStatusSize OPTIONAL
,
274 IN OUT EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
278 Lan9118ReadMacAddress (
279 OUT EFI_MAC_ADDRESS
*Mac
282 #endif // __LAN9118_DXE_UTIL_H__