__P!= wanted
[dragonfly.git] / sys / dev / netif / lnc_p / if_lnc_p.c
1 /*
2  *
3  * Copyright (c) 1996 Stefan Esser <se@freebsd.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice immediately at the beginning of the file, without modification,
11  *    this list of conditions, and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Absolutely no warranty of function or purpose is made by the author
16  *    Stefan Esser.
17  * 4. Modifications may be freely made to this file if the above conditions
18  *    are met.
19  *
20  * $FreeBSD: src/sys/pci/if_lnc_p.c,v 1.13 1999/08/28 00:50:51 peter Exp $
21  * $DragonFly: src/sys/dev/netif/lnc_p/Attic/if_lnc_p.c,v 1.4 2003/08/27 09:38:31 rob Exp $
22  */
23
24 #include "use_lnc.h"
25
26 #include <sys/param.h>
27 #include <sys/systm.h>
28 #include <sys/malloc.h>
29 #include <sys/kernel.h>
30 #include <bus/pci/pcireg.h>
31 #include <bus/pci/pcivar.h>
32
33 #define PCI_DEVICE_ID_PCNet_PCI 0x20001022
34 #define PCI_DEVICE_ID_PCHome_PCI 0x20011022
35
36 extern void *lnc_attach_ne2100_pci (int unit, unsigned iobase);
37
38 static const char* lnc_pci_probe (pcici_t tag, pcidi_t type);
39 static void lnc_pci_attach (pcici_t config_id, int unit);
40
41 static u_long lnc_pci_count = NLNC;
42
43 static struct pci_device lnc_pci_driver = {
44         "lnc",
45         lnc_pci_probe,
46         lnc_pci_attach,
47         &lnc_pci_count,
48         NULL
49 };
50
51 COMPAT_PCI_DRIVER (lnc_pci, lnc_pci_driver);
52
53 static const char*
54 lnc_pci_probe (pcici_t tag, pcidi_t type)
55 {
56         switch(type) {
57         case PCI_DEVICE_ID_PCNet_PCI:
58                 return ("PCNet/PCI Ethernet adapter");
59                 break;
60         case PCI_DEVICE_ID_PCHome_PCI:
61                 return ("PCHome/PCI Ethernet adapter");
62                 break;
63         default:
64                 break;
65         }
66         return (0);
67 }
68
69 void lncintr_sc (void*);
70
71 static void
72 lnc_pci_attach(config_id, unit)
73         pcici_t config_id;
74         int     unit;
75 {
76         unsigned iobase;
77         unsigned data;  /* scratch to make this device a bus master*/
78         void *lnc; /* device specific data for interrupt handler ... */
79
80         if ( !pci_map_port(config_id,PCI_MAP_REG_START,(u_short *)&iobase) )
81             printf("lnc%d: pci_port_map_attach failed?!\n",unit);
82
83
84         /* Make this device a bus master.  This was implictly done by 
85            pci_map_port under 2.2.x -- tvf */
86
87         data = pci_cfgread(config_id, PCIR_COMMAND, 4);
88         data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
89         pci_cfgwrite(config_id, PCIR_COMMAND, data, 4);
90
91         lnc = lnc_attach_ne2100_pci(unit, iobase);
92
93         if (!lnc)
94                 return;
95         if(!(pci_map_int(config_id, lncintr_sc, (void *)lnc, &net_imask))) {
96                 free (lnc, M_DEVBUF);
97                 return;
98         }
99
100         return;
101 }