This source file includes following definitions.
- ac3200_probe
- ac_probe1
- ac_open
- ac_reset_8390
- ac_block_input
- ac_block_output
- ac_close_card
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 static char *version =
18 "ac3200.c:v1.01 7/1/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
19
20 #include <linux/kernel.h>
21 #include <linux/sched.h>
22 #include <linux/errno.h>
23 #include <linux/string.h>
24 #include <asm/system.h>
25 #include <asm/io.h>
26
27 #include <linux/netdevice.h>
28 #include "8390.h"
29
30
31 #define AC_NIC_BASE 0x00
32 #define AC_SA_PROM 0x16
33 #define AC_ADDR0 0x00
34 #define AC_ADDR1 0x40
35 #define AC_ADDR2 0x90
36 #define AC_ID_PORT 0xC80
37 #define AC_EISA_ID 0x0110d305
38 #define AC_RESET_PORT 0xC84
39 #define AC_RESET 0x00
40 #define AC_ENABLE 0x01
41 #define AC_CONFIG 0xC90
42
43
44 static unsigned char config2irqmap[8] = {15, 12, 11, 10, 9, 7, 5, 3};
45 static int addrmap[8] =
46 {0xFF0000, 0xFE0000, 0xFD0000, 0xFFF0000, 0xFFE0000, 0xFFC0000, 0xD0000, 0 };
47 static char *port_name[4] = { "10baseT", "invalid", "AUI", "10base2"};
48
49 #define config2irq(configval) config2irqmap[((configval) >> 3) & 7]
50 #define config2mem(configval) addrmap[(configval) & 7]
51 #define config2name(configval) port_name[((configval) >> 6) & 3]
52
53
54 #define AC_START_PG 0x00
55 #define AC_STOP_PG 0x80
56
57 int ac3200_probe(struct device *dev);
58 static int ac_probe1(int ioaddr, struct device *dev);
59
60 static int ac_open(struct device *dev);
61 static void ac_reset_8390(struct device *dev);
62 static int ac_block_input(struct device *dev, int count,
63 char *buf, int ring_offset);
64 static void ac_block_output(struct device *dev, const int count,
65 const unsigned char *buf, const int start_page);
66 static int ac_close_card(struct device *dev);
67
68
69
70
71
72
73
74
75 int ac3200_probe(struct device *dev)
76 {
77 unsigned short ioaddr = dev->base_addr;
78
79 if (ioaddr > 0x1ff)
80 return ac_probe1(ioaddr, dev);
81 else if (ioaddr > 0)
82 return ENXIO;
83
84
85 if ( ! EISA_bus)
86 return ENXIO;
87
88 for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000)
89 if (ac_probe1(ioaddr, dev) == 0)
90 return 0;
91
92 return ENODEV;
93 }
94
95 static int ac_probe1(int ioaddr, struct device *dev)
96 {
97 int i;
98
99 #ifndef final_version
100 printk("AC3200 ethercard probe at %#3x:", ioaddr);
101
102 for(i = 0; i < 6; i++)
103 printk(" %02x", inb(ioaddr + AC_SA_PROM + i));
104 #endif
105
106
107
108 if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
109 || inb(ioaddr + AC_SA_PROM + 1) != AC_ADDR1
110 || inb(ioaddr + AC_SA_PROM + 2) != AC_ADDR2 ) {
111 #ifndef final_version
112 printk(" not found (invalid prefix).\n");
113 #endif
114 return ENODEV;
115 }
116
117
118 for (i = 0; i < 4; i++)
119 if (inl(ioaddr + AC_ID_PORT) != AC_EISA_ID) {
120 printk("EISA ID mismatch, %8x vs %8x.\n",
121 inl(ioaddr + AC_EISA_ID), AC_EISA_ID);
122 return ENODEV;
123 }
124
125 for(i = 0; i < ETHER_ADDR_LEN; i++)
126 dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i);
127
128 #ifndef final_version
129 printk("\nAC3200 ethercard configuration register is %#02x,"
130 " EISA ID %02x %02x %02x %02x.\n", inb(ioaddr + AC_CONFIG),
131 inb(ioaddr + AC_ID_PORT + 0), inb(ioaddr + AC_ID_PORT + 1),
132 inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3));
133 #endif
134
135
136 if (dev->irq == 0)
137 dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
138 else if (dev->irq == 2)
139 dev->irq = 9;
140
141 if (request_irq(dev->irq, ei_interrupt, 0, "ac3200")) {
142 printk (" unable to get IRQ %d.\n", dev->irq);
143 return 0;
144 }
145
146 dev->base_addr = ioaddr;
147
148 #ifdef notyet
149 if (dev->mem_start) {
150 for (i = 0; i < 7; i++)
151 if (addrmap[i] == dev->mem_start)
152 break;
153 if (i >= 7)
154 i = 0;
155 outb((inb(ioaddr + AC_CONFIG) & ~7) | i, ioaddr + AC_CONFIG);
156 }
157 #endif
158
159 dev->if_port = inb(ioaddr + AC_CONFIG) >> 6;
160 dev->mem_start = config2mem(inb(ioaddr + AC_CONFIG));
161 dev->rmem_start = dev->mem_start + TX_PAGES*256;
162 dev->mem_end = dev->rmem_end = dev->mem_start
163 + (AC_STOP_PG - AC_START_PG)*256;
164
165 ethdev_init(dev);
166
167 ei_status.name = "AC3200";
168 ei_status.tx_start_page = AC_START_PG;
169 ei_status.rx_start_page = AC_START_PG + TX_PAGES;
170 ei_status.stop_page = AC_STOP_PG;
171 ei_status.word16 = 1;
172
173 printk("\n%s: AC3200 at %#x, IRQ %d, %s port, shared memory %#lx-%#lx.\n",
174 dev->name, ioaddr, dev->irq, port_name[dev->if_port],
175 dev->mem_start, dev->mem_end-1);
176
177 if (ei_debug > 0)
178 printk(version);
179
180 ei_status.reset_8390 = &ac_reset_8390;
181 ei_status.block_input = &ac_block_input;
182 ei_status.block_output = &ac_block_output;
183
184 dev->open = &ac_open;
185 dev->stop = &ac_close_card;
186 NS8390_init(dev, 0);
187 return 0;
188 }
189
190 static int ac_open(struct device *dev)
191 {
192 #ifdef notyet
193
194 int ioaddr = dev->base_addr;
195
196 if (request_irq(dev->irq, ei_interrupt, 0, "ac3200"))
197 return -EAGAIN;
198 #endif
199
200 return ei_open(dev);
201 }
202
203 static void ac_reset_8390(struct device *dev)
204 {
205 ushort ioaddr = dev->base_addr;
206
207 outb(AC_RESET, ioaddr + AC_RESET_PORT);
208 if (ei_debug > 1) printk("resetting AC3200, t=%ld...", jiffies);
209
210 ei_status.txing = 0;
211 outb(AC_ENABLE, ioaddr + AC_RESET_PORT);
212 if (ei_debug > 1) printk("reset done\n");
213
214 return;
215 }
216
217
218
219
220 static int ac_block_input(struct device *dev, int count, char *buf,
221 int ring_offset)
222 {
223 long xfer_start = dev->mem_start + ring_offset - (AC_START_PG<<8);
224
225 if (xfer_start + count > dev->rmem_end) {
226
227 int semi_count = dev->rmem_end - xfer_start;
228 memcpy(buf, (char*)xfer_start, semi_count);
229 count -= semi_count;
230 memcpy(buf + semi_count, (char *)dev->rmem_start, count);
231 return dev->rmem_start + count;
232 }
233 memcpy(buf, (char*)xfer_start, count);
234
235 return ring_offset + count;
236 }
237
238 static void ac_block_output(struct device *dev, int count,
239 const unsigned char *buf, int start_page)
240 {
241 long shmem = dev->mem_start + ((start_page - AC_START_PG)<<8);
242
243 memcpy((unsigned char *)shmem, buf, count);
244 }
245
246 static int ac_close_card(struct device *dev)
247 {
248 dev->start = 0;
249 dev->tbusy = 1;
250
251 if (ei_debug > 1)
252 printk("%s: Shutting down ethercard.\n", dev->name);
253
254 #ifdef notyet
255
256 outb(0x00, ioaddr + 6);
257 free_irq(dev->irq);
258 irq2dev_map[dev->irq] = 0;
259 #endif
260
261 NS8390_init(dev, 0);
262
263 return 0;
264 }
265
266
267
268
269
270
271
272
273
274