]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/pci/if_ar_p.c
This commit was generated by cvs2svn to compensate for changes in r53809,
[FreeBSD/FreeBSD.git] / sys / pci / if_ar_p.c
1 /*
2  * Copyright (c) 1999 John Hay.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the author nor the names of any co-contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31
32 #include "ar.h"
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/malloc.h>
38
39 #include <pci/pcivar.h>
40
41 /*
42  * The must match with the real functions in if_ar.c
43  */
44 extern void *arattach_pci(int unit, vm_offset_t mem_vaddr);
45 extern void arintr_hc(void *hc);
46
47 static const char *ar_pci_probe(pcici_t tag, pcidi_t type);
48 static void ar_pci_attach(pcici_t config_id, int unit);
49
50 static u_long arc_count = NAR;
51
52 static struct pci_device ar_pci_driver =
53 {
54         "ar",
55         ar_pci_probe,
56         ar_pci_attach,
57         &arc_count,
58         NULL
59 };
60
61 COMPAT_PCI_DRIVER (ar_pci, ar_pci_driver);
62
63 static const char *
64 ar_pci_probe(pcici_t tag, pcidi_t type)
65 {
66         switch(type) {
67         case 0x5012114f:
68                 return ("Digi SYNC/570i-PCI 2 port");
69                 break;
70         case 0x5010114f:
71                 printf("Digi SYNC/570i-PCI 2 port (mapped below 1M)\n");
72                 printf("Please change the jumper to select linear mode.\n");
73                 break;
74         case 0x5013114f:
75                 return ("Digi SYNC/570i-PCI 4 port");
76                 break;
77         case 0x5011114f:
78                 printf("Digi SYNC/570i-PCI 4 port (mapped below 1M)\n");
79                 printf("Please change the jumper to select linear mode.\n");
80                 break;
81         default:
82                 break;
83         }
84         return (0);
85 }
86
87 static void
88 ar_pci_attach(pcici_t config_id, int unit)
89 {
90         u_char *inten;
91         void *hc;
92         vm_offset_t mem_vaddr, mem_paddr;
93         vm_offset_t plx_vaddr, plx_paddr;
94
95         if(!pci_map_mem(config_id, 0x10, &plx_vaddr, &plx_paddr)) {
96                 printf("arp: map failed.\n");
97                 return;
98         }
99
100         if(!pci_map_mem(config_id, 0x18, &mem_vaddr, &mem_paddr)) {
101                 printf("arp: map failed.\n");
102                 return;
103         }
104
105         hc = arattach_pci(unit, mem_vaddr);
106         if(!hc)
107                 return;
108
109         /* Magic to enable the card to generate interrupts. */
110         inten = (u_char *)plx_vaddr;
111         inten[0x69] = 0x09;
112
113         if(!pci_map_int(config_id, arintr_hc, (void *)hc, &net_imask)) {
114                 free(hc, M_DEVBUF);
115                 return;
116         }
117 }