iPXE
axge.h
Go to the documentation of this file.
1 #ifndef _AXGE_H
2 #define _AXGE_H
3 
4 /** @file
5  *
6  * Asix 10/100/1000 USB Ethernet driver
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 #include <ipxe/usb.h>
14 #include <ipxe/usbnet.h>
15 
16 /** Read MAC register */
17 #define AXGE_READ_MAC_REGISTER \
18  ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
19  USB_REQUEST_TYPE ( 0x01 ) )
20 
21 /** Write MAC register */
22 #define AXGE_WRITE_MAC_REGISTER \
23  ( USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
24  USB_REQUEST_TYPE ( 0x01 ) )
25 
26 /** Physical Link Status Register */
27 #define AXGE_PLSR 0x02
28 #define AXGE_PLSR_EPHY_10 0x10 /**< Ethernet at 10Mbps */
29 #define AXGE_PLSR_EPHY_100 0x20 /**< Ethernet at 100Mbps */
30 #define AXGE_PLSR_EPHY_1000 0x40 /**< Ethernet at 1000Mbps */
31 #define AXGE_PLSR_EPHY_ANY \
32  ( AXGE_PLSR_EPHY_10 | \
33  AXGE_PLSR_EPHY_100 | \
34  AXGE_PLSR_EPHY_1000 )
35 
36 /** RX Control Register */
37 #define AXGE_RCR 0x0b
38 #define AXGE_RCR_PRO 0x0001 /**< Promiscuous mode */
39 #define AXGE_RCR_AMALL 0x0002 /**< Accept all multicasts */
40 #define AXGE_RCR_AB 0x0008 /**< Accept broadcasts */
41 #define AXGE_RCR_SO 0x0080 /**< Start operation */
42 
43 /** Node ID Register */
44 #define AXGE_NIDR 0x10
45 
46 /** Medium Status Register */
47 #define AXGE_MSR 0x22
48 #define AXGE_MSR_GM 0x0001 /**< Gigabit mode */
49 #define AXGE_MSR_FD 0x0002 /**< Full duplex */
50 #define AXGE_MSR_RFC 0x0010 /**< RX flow control enable */
51 #define AXGE_MSR_TFC 0x0020 /**< TX flow control enable */
52 #define AXGE_MSR_RE 0x0100 /**< Receive enable */
53 #define AXGE_MSR_PS 0x0200 /**< 100Mbps port speed */
54 
55 /** Ethernet PHY Power and Reset Control Register */
56 #define AXGE_EPPRCR 0x26
57 #define AXGE_EPPRCR_IPRL 0x0020 /**< Undocumented */
58 
59 /** Delay after initialising EPPRCR */
60 #define AXGE_EPPRCR_DELAY_MS 200
61 
62 /** Bulk IN Control Register (undocumented) */
63 #define AXGE_BICR 0x2e
64 
65 /** Bulk IN Control (undocumented) */
67  /** Control */
69  /** Timer */
71  /** Size */
73  /** Inter-frame gap */
75 } __attribute__ (( packed ));
76 
77 /** Clock Select Register (undocumented) */
78 #define AXGE_CSR 0x33
79 #define AXGE_CSR_BCS 0x01 /**< Undocumented */
80 #define AXGE_CSR_ACS 0x02 /**< Undocumented */
81 
82 /** Delay after initialising CSR */
83 #define AXGE_CSR_DELAY_MS 100
84 
85 /** Transmit packet header */
87  /** Packet length */
89  /** Answers on a postcard, please */
91 } __attribute__ (( packed ));
92 
93 /** Receive packet footer */
95  /** Packet count */
97  /** Header offset */
99 } __attribute__ (( packed ));
100 
101 /** Receive packet descriptor */
103  /** Checksum information */
105  /** Length and error flags */
107 } __attribute__ (( packed ));
108 
109 /** Receive packet length mask */
110 #define AXGE_RX_LEN_MASK 0x1fff
111 
112 /** Receive packet length alignment */
113 #define AXGE_RX_LEN_PAD_ALIGN 8
114 
115 /** Receive packet CRC error */
116 #define AXGE_RX_CRC_ERROR 0x2000
117 
118 /** Receive packet dropped error */
119 #define AXGE_RX_DROP_ERROR 0x8000
120 
121 /** Interrupt data */
123  /** Magic signature */
125  /** Link state */
127  /** PHY register MR01 */
129  /** PHY register MR05 */
131 } __attribute__ (( packed ));
132 
133 /** Interrupt magic signature */
134 #define AXGE_INTR_MAGIC 0x00a1
135 
136 /** Link is up */
137 #define AXGE_INTR_LINK_PPLS 0x0001
138 
139 /** An AXGE network device */
140 struct axge_device {
141  /** USB device */
142  struct usb_device *usb;
143  /** USB bus */
144  struct usb_bus *bus;
145  /** Network device */
147  /** USB network device */
149  /** Device configuration */
150  unsigned int config;
151  /** Link state has changed */
153 };
154 
155 /** Interrupt maximum fill level
156  *
157  * This is a policy decision.
158  */
159 #define AXGE_INTR_MAX_FILL 2
160 
161 /** Bulk IN maximum fill level
162  *
163  * This is a policy decision.
164  */
165 #define AXGE_IN_MAX_FILL 8
166 
167 /** Bulk IN buffer size
168  *
169  * This is a policy decision.
170  */
171 #define AXGE_IN_MTU 2048
172 
173 /** Amount of space to reserve at start of bulk IN buffers
174  *
175  * This is required to allow for protocols such as ARP which may reuse
176  * a received I/O buffer for transmission.
177  */
178 #define AXGE_IN_RESERVE sizeof ( struct axge_tx_header )
179 
180 #endif /* _AXGE_H */
FILE_SECBOOT(PERMITTED)
#define __attribute__(x)
Definition: compiler.h:10
unsigned short uint16_t
Definition: stdint.h:11
struct usb_device * usb
USB device.
Definition: axge.h:142
uint8_t ifg
Inter-frame gap.
Definition: axge.h:74
struct usb_bus * bus
USB bus.
Definition: axge.h:144
Interrupt data.
Definition: axge.h:122
uint16_t magic
Magic signature.
Definition: axge.h:124
uint16_t link
Link state.
Definition: axge.h:126
uint16_t mr01
PHY register MR01.
Definition: axge.h:128
uint16_t check
Checksum information.
Definition: axge.h:104
An AXGE network device.
Definition: axge.h:140
Transmit packet header.
Definition: axge.h:86
struct net_device * netdev
Network device.
Definition: axge.h:146
uint8_t size
Size.
Definition: axge.h:72
A USB device.
Definition: usb.h:723
int check_link
Link state has changed.
Definition: axge.h:152
Bulk IN Control (undocumented)
Definition: axge.h:66
A USB network device.
Definition: usbnet.h:16
A network device.
Definition: netdevice.h:353
unsigned char uint8_t
Definition: stdint.h:10
uint16_t mr05
PHY register MR05.
Definition: axge.h:130
uint16_t timer
Timer.
Definition: axge.h:70
uint16_t len_flags
Length and error flags.
Definition: axge.h:106
unsigned int uint32_t
Definition: stdint.h:12
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
USB network devices.
Universal Serial Bus (USB)
unsigned int config
Device configuration.
Definition: axge.h:150
uint8_t ctrl
Control.
Definition: axge.h:68
Receive packet descriptor.
Definition: axge.h:102
uint32_t wtf
Answers on a postcard, please.
Definition: axge.h:90
struct usbnet_device usbnet
USB network device.
Definition: axge.h:148
A USB bus.
Definition: usb.h:966
uint32_t len
Packet length.
Definition: axge.h:88