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