Browse Source

Hand-finished

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
28590d718b
1 changed files with 27 additions and 30 deletions
  1. 27
    30
      src/drivers/net/rtl8139.c

+ 27
- 30
src/drivers/net/rtl8139.c View File

@@ -180,30 +180,25 @@ static void rtl_transmit(struct nic *nic, const char *destaddr,
180 180
 static int rtl_poll(struct nic *nic, int retrieve);
181 181
 static void rtl_disable(struct nic *nic);
182 182
 static void rtl_irq(struct nic *nic, irq_action_t action);
183
-
183
+static struct nic_operations rtl_operations;
184
+static struct pci_driver rtl8139_driver;
184 185
 
185 186
 static int rtl8139_probe ( struct dev *dev ) {
186
-
187 187
 	struct nic *nic = nic_device ( dev );
188
-
189 188
 	struct pci_device *pci = pci_device ( dev );
190 189
 	int i;
191 190
 	int speed10, fullduplex;
192 191
 	int addr_len;
193 192
 	unsigned short *ap = (unsigned short*)nic->node_addr;
194 193
 
195
-	/* There are enough "RTL8139" strings on the console already, so
196
-	 * be brief and concentrate on the interesting pieces of info... */
197
-	printf(" - ");
198
-
199
-	/* Mask the bit that says "this is an io addr" */
200
-	nic->ioaddr = pci->ioaddr & ~3;
194
+	/* Look for PCI device */
195
+	if ( ! find_pci_device ( pci, &rtl8139_driver ) )
196
+		return 0;
201 197
 
202
-	/* Copy IRQ from PCI information */
198
+	/* Copy ioaddr and IRQ from PCI information */
199
+	nic->ioaddr = pci->ioaddr;
203 200
 	nic->irqno = pci->irq;
204 201
 
205
-	adjust_pci_device(pci);
206
-
207 202
 	/* Bring the chip out of low-power mode. */
208 203
 	outb(0x00, nic->ioaddr + Config1);
209 204
 
@@ -211,28 +206,14 @@ static int rtl8139_probe ( struct dev *dev ) {
211 206
 	for (i = 0; i < 3; i++)
212 207
 	  *ap++ = read_eeprom(nic,i + 7,addr_len);
213 208
 
209
+	rtl_reset(nic);
210
+
214 211
 	speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10;
212
+	nic->mbps = speed10 ? 10 : 100;
215 213
 	fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex;
216
-	printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr,
217
-	       nic->irqno, nic->node_addr,  speed10 ? "10" : "100",
218
-	       fullduplex ? "full" : "half");
214
+	nic->duplex = fullduplex ? FULL_DUPLEX : HALF_DUPLEX;
219 215
 
220
-	rtl_reset(nic);
221
-
222
-	if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) {
223
-		printf("Cable not connected or other link failure\n");
224
-		return(0);
225
-	}
226
-static struct nic_operations rtl_operations;
227
-static struct nic_operations rtl_operations = {
228
-	.connect	= dummy_connect,
229
-	.poll		= rtl_poll,
230
-	.transmit	= rtl_transmit,
231
-	.irq		= rtl_irq,
232
-	.disable	= rtl_disable,
233
-};
234 216
 	nic->nic_op	= &rtl_operations;
235
-
236 217
 	return 1;
237 218
 }
238 219
 
@@ -312,6 +293,14 @@ static void set_rx_mode(struct nic *nic) {
312 293
 	outl(mc_filter[0], nic->ioaddr + MAR0 + 0);
313 294
 	outl(mc_filter[1], nic->ioaddr + MAR0 + 4);
314 295
 }
296
+
297
+static int rtl_connect ( struct nic *nic ) {
298
+	if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) {
299
+		printf("Cable not connected or other link failure\n");
300
+		return 0;
301
+	}
302
+	return 1;
303
+}
315 304
 	
316 305
 static void rtl_reset(struct nic* nic)
317 306
 {
@@ -528,6 +517,14 @@ static void rtl_disable ( struct nic *nic ) {
528 517
 		/* wait */;
529 518
 }
530 519
 
520
+static struct nic_operations rtl_operations = {
521
+	.connect	= rtl_connect,
522
+	.poll		= rtl_poll,
523
+	.transmit	= rtl_transmit,
524
+	.irq		= rtl_irq,
525
+	.disable	= rtl_disable,
526
+};
527
+
531 528
 static struct pci_id rtl8139_nics[] = {
532 529
 PCI_ROM(0x10ec, 0x8129, "rtl8129",       "Realtek 8129"),
533 530
 PCI_ROM(0x10ec, 0x8139, "rtl8139",       "Realtek 8139"),

Loading…
Cancel
Save