xref: /minix/minix/drivers/net/vt6105/vt6105.h (revision 9f81acbc)
1 #ifndef _NDR_H
2 #define _NDR_H
3 
4 /* ======= General Parameter ======= */
5 /* Global configure */
6 
7 #include <minix/drivers.h>
8 
9 #define DRIVER_NAME		"VT6105"
10 
11 /* Rx/Tx buffer parameter */
12 #define RX_BUF_SIZE		1536
13 #define TX_BUF_SIZE		1536
14 #define RX_BUFFER_NUM	64
15 #define TX_BUFFER_NUM	64
16 
17 /* Interrupt status */
18 #define INTR_STS_LINK	0x4000
19 #define INTR_STS_RX		0x0001
20 #define INTR_STS_TX		0x0002
21 
22 /* Link status */
23 #define LINK_UP			1
24 #define LINK_DOWN		0
25 #define LINK_UNKNOWN	-1
26 
27 /* Interrupt control */
28 #define INTR_ENABLE		1
29 #define INTR_DISABLE	0
30 
31 /* Rx status */
32 #define RX_ERROR		1
33 #define RX_OK			0
34 #define RX_SUSPEND		-1
35 
36 /* Tx status */
37 #define TX_ERROR		1
38 #define TX_OK			0
39 #define TX_SUSPEND		-1
40 
41 /* Rx/Tx control */
42 #define RX_TX_ENABLE	1
43 #define RX_TX_DISABLE	0
44 
45 /* ======= Self-defined Parameter ======= */
46 #define DESC_OWN			0x80000000
47 #define DESC_FIRST			0x00000200
48 #define DESC_LAST			0x00000100
49 #define DESC_RX_LENMASK		0x7fff0000
50 #define DESC_RX_ERROR		0x000000bf
51 #define DESC_RX_NORMAL		(DESC_FIRST | DESC_LAST)
52 #define DESC_TX_ERROR		0x00008f10
53 
54 #define REG_ADDR			0x00
55 #define REG_RCR				0x06
56 #define REG_TCR				0x07
57 #define REG_CR				0x08
58 #define REG_IMR				0x0e
59 #define REG_ISR				0x0c
60 #define REG_RX_DESC_BASE	0x18
61 #define REG_TX_DESC_BASE	0x1c
62 #define REG_MII_PHY			0x6c
63 #define REG_BCR				0x6e
64 #define REG_MII_CR			0x70
65 #define REG_MII_REG			0x71
66 #define REG_MII_DATA		0x72
67 #define REG_MCR				0x81
68 #define REG_STICK			0x83
69 
70 #define CMD_START			0x0002
71 #define CMD_STOP			0x0004
72 #define CMD_RX_ON			0x0008
73 #define CMD_TX_ON			0x0010
74 #define CMD_TX_DEMAND		0x0020
75 #define CMD_RX_DEMAND		0x0040
76 #define CMD_FDUPLEX			0x0400
77 #define CMD_NO_POLL			0x0800
78 #define CMD_RESET			0x8000
79 #define CMD_INTR_ENABLE		0xfeff
80 #define CMD_RCR_UNICAST		0x10
81 #define CMD_RCR_MULTICAST	0x04
82 #define CMD_RCR_BROADCAST	0x08
83 #define INTR_STS_CLEAR		0xbfbf
84 #define LINK_STATUS			0x0004
85 
86 /* ======= Data Descriptor ======= */
87 typedef struct NDR_desc {
88 	u32_t status;
89 	u32_t length;
90 	u32_t addr;
91 	u32_t next;
92 } NDR_desc;
93 
94 /* Driver Data Structure */
95 typedef struct NDR_driver {
96 	char *dev_name;			/* Device name */
97 	u16_t vid, did;			/* Vendor and device ID */
98 	u32_t devind;			/* Device index */
99 	u32_t base[6];			/* Base address */
100 	char irq;				/* IRQ number */
101 	char revision;			/* Revision ID */
102 
103 	int mode;
104 	int link;				/* Whether link-up */
105 	int recv_flag;			/* Receive flag */
106 	int send_flag;			/* Send flag */
107 	int tx_busy;			/* Whether Tx is busy */
108 
109 	/* Buffer */
110 	size_t buf_size;
111 	char *buf;
112 
113 	/* Rx data */
114 	int rx_head;
115 	struct {
116 		phys_bytes buf_dma;
117 		char *buf;
118 	} rx[RX_BUFFER_NUM];
119 
120 	/* Tx data */
121 	int tx_head;
122 	int tx_tail;
123 	struct {
124 		int busy;
125 		phys_bytes buf_dma;
126 		char *buf;
127 	} tx[TX_BUFFER_NUM];
128 	int tx_busy_num;			/* Number of busy Tx buffer */
129 
130 	NDR_desc *rx_desc;			/* Rx descriptor buffer */
131 	phys_bytes rx_desc_dma;		/* Rx descriptor DMA buffer */
132 	NDR_desc *tx_desc;			/* Tx descriptor buffer */
133 	phys_bytes tx_desc_dma;		/* Tx descriptor DMA buffer */
134 
135 	int hook;			/* IRQ hook id at kernel */
136 } NDR_driver;
137 
138 #endif
139