This source file includes following definitions.
- adw_pci_match
- adw_pci_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 #include <sys/types.h>
52 #include <sys/param.h>
53 #include <sys/systm.h>
54 #include <sys/malloc.h>
55 #include <sys/kernel.h>
56 #include <sys/queue.h>
57 #include <sys/device.h>
58 #include <sys/timeout.h>
59
60 #include <machine/bus.h>
61 #include <machine/intr.h>
62
63 #include <scsi/scsi_all.h>
64 #include <scsi/scsiconf.h>
65
66 #include <dev/pci/pcireg.h>
67 #include <dev/pci/pcivar.h>
68 #include <dev/pci/pcidevs.h>
69
70 #include <dev/ic/adwlib.h>
71 #include <dev/microcode/adw/adwmcode.h>
72 #include <dev/ic/adw.h>
73
74
75
76 #define PCI_BASEADR_IO 0x10
77
78
79
80 int adw_pci_match(struct device *, void *, void *);
81 void adw_pci_attach(struct device *, struct device *, void *);
82
83 struct cfattach adw_pci_ca =
84 {
85 sizeof(ADW_SOFTC), adw_pci_match, adw_pci_attach
86 };
87
88 const struct pci_matchid adw_pci_devices[] = {
89 { PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_WIDE },
90 { PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_U2W },
91 { PCI_VENDOR_ADVSYS, PCI_PRODUCT_ADVSYS_U3W },
92 };
93
94
95
96
97
98
99
100 int
101 adw_pci_match(parent, match, aux)
102 struct device *parent;
103 void *match;
104 void *aux;
105 {
106 return (pci_matchbyid((struct pci_attach_args *)aux, adw_pci_devices,
107 sizeof(adw_pci_devices)/sizeof(adw_pci_devices[0])));
108 }
109
110
111 void
112 adw_pci_attach(parent, self, aux)
113 struct device *parent, *self;
114 void *aux;
115 {
116 struct pci_attach_args *pa = aux;
117 ADW_SOFTC *sc = (void *) self;
118 bus_space_tag_t iot;
119 bus_space_handle_t ioh;
120 pci_intr_handle_t ih;
121 pci_chipset_tag_t pc = pa->pa_pc;
122 pcireg_t command;
123 const char *intrstr;
124
125
126
127
128 switch (PCI_PRODUCT(pa->pa_id)) {
129 case PCI_PRODUCT_ADVSYS_WIDE:
130 sc->chip_type = ADW_CHIP_ASC3550;
131 break;
132
133 case PCI_PRODUCT_ADVSYS_U2W:
134 sc->chip_type = ADW_CHIP_ASC38C0800;
135 break;
136
137 case PCI_PRODUCT_ADVSYS_U3W:
138 sc->chip_type = ADW_CHIP_ASC38C1600;
139 break;
140
141 default:
142 printf("\n%s: unknown model: %d\n", sc->sc_dev.dv_xname,
143 PCI_PRODUCT(pa->pa_id));
144 return;
145 }
146
147 command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
148 if ( (command & PCI_COMMAND_PARITY_ENABLE) == 0)
149 sc->cfg.control_flag |= CONTROL_FLAG_IGNORE_PERR;
150
151
152
153
154 if (pci_mapreg_map(pa, PCI_BASEADR_IO, PCI_MAPREG_TYPE_IO, 0,
155 &iot, &ioh, NULL, NULL, 0)) {
156 printf("\n%s: unable to map device registers\n",
157 sc->sc_dev.dv_xname);
158 return;
159 }
160 sc->sc_iot = iot;
161 sc->sc_ioh = ioh;
162 sc->sc_dmat = pa->pa_dmat;
163
164
165
166
167 if (adw_init(sc)) {
168 printf("%s: adw_init failed", sc->sc_dev.dv_xname);
169 return;
170 }
171
172
173
174
175 if (pci_intr_map(pa, &ih)) {
176 printf("\n%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
177 return;
178 }
179 intrstr = pci_intr_string(pc, ih);
180
181
182
183
184 sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, adw_intr, sc,
185 sc->sc_dev.dv_xname);
186 if (sc->sc_ih == NULL) {
187 printf("\n%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
188 if (intrstr != NULL)
189 printf(" at %s", intrstr);
190 printf("\n");
191 return;
192 }
193 printf(": %s\n", intrstr);
194
195
196
197
198 adw_attach(sc);
199 }
200