This source file includes following definitions.
- pcic_pci_match
- pcic_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 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/device.h>
42
43 #include <dev/ic/i82365reg.h>
44 #include <dev/ic/i82365var.h>
45
46 #include <dev/pci/pcivar.h>
47 #include <dev/pci/pcireg.h>
48 #include <dev/pci/pcidevs.h>
49 #include <dev/pci/i82365_pcivar.h>
50
51 #include <dev/isa/isavar.h>
52 #include <dev/isa/i82365_isavar.h>
53
54
55
56
57
58 #define PCI_CBIO 0x10
59
60 int pcic_pci_match(struct device *, void *, void *);
61 void pcic_pci_attach(struct device *, struct device *, void *);
62
63 struct cfattach pcic_pci_ca = {
64 sizeof(struct pcic_pci_softc), pcic_pci_match, pcic_pci_attach
65 };
66
67 static struct pcmcia_chip_functions pcic_pci_functions = {
68 pcic_chip_mem_alloc,
69 pcic_chip_mem_free,
70 pcic_chip_mem_map,
71 pcic_chip_mem_unmap,
72
73 pcic_chip_io_alloc,
74 pcic_chip_io_free,
75 pcic_chip_io_map,
76 pcic_chip_io_unmap,
77
78
79 pcic_isa_chip_intr_establish,
80 pcic_isa_chip_intr_disestablish,
81 pcic_isa_chip_intr_string,
82
83 pcic_chip_socket_enable,
84 pcic_chip_socket_disable,
85 };
86
87 int
88 pcic_pci_match(parent, match, aux)
89 struct device *parent;
90 void *match;
91 void *aux;
92 {
93 struct pci_attach_args *pa = (struct pci_attach_args *) aux;
94
95 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CIRRUS &&
96 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CIRRUS_CL_PD6729)
97 return (1);
98 return (0);
99 }
100
101 void pcic_isa_config_interrupts(struct device *);
102
103 void
104 pcic_pci_attach(parent, self, aux)
105 struct device *parent, *self;
106 void *aux;
107 {
108 struct pcic_softc *sc = (void *) self;
109 struct pcic_pci_softc *psc = (void *) self;
110 struct pcic_handle *h;
111 struct pci_attach_args *pa = aux;
112 pci_chipset_tag_t pc = pa->pa_pc;
113 bus_space_tag_t memt = pa->pa_memt;
114 bus_space_handle_t memh;
115 bus_size_t size;
116 int irq, i;
117
118 if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
119 &sc->iot, &sc->ioh, NULL, &size, 0)) {
120 printf(": can't map i/o space\n");
121 return;
122 }
123
124
125
126
127
128
129
130
131
132
133
134
135 if (bus_space_map(memt, 0xd0000, 0x10000, 0, &memh)) {
136 printf(": can't map mem space");
137 bus_space_unmap(sc->iot, sc->ioh, size);
138 return;
139 }
140
141 sc->membase = 0xd0000;
142 sc->subregionmask = (1 << (0x10000 / PCIC_MEM_PAGESIZE)) - 1;
143
144
145
146 sc->iobase = 0x400;
147 sc->iosize = 0xbff;
148
149
150
151 sc->pct = (pcmcia_chipset_tag_t) & pcic_pci_functions;
152
153 sc->memt = memt;
154 sc->memh = memh;
155
156 printf("\n");
157 pcic_attach(sc);
158 pcic_attach_sockets(sc);
159
160
161
162
163
164
165
166 pcic_write(&sc->handle[0], PCIC_CIRRUS_EXTENDED_INDEX,
167 PCIC_CIRRUS_EXT_CONTROL_1);
168 if ((pcic_read(&sc->handle[0], PCIC_CIRRUS_EXTENDED_DATA) &
169 PCIC_CIRRUS_EXT_CONTROL_1_PCI_INTR_MASK)) {
170 printf("%s: PCI interrupts not supported\n",
171 sc->dev.dv_xname);
172 return;
173 }
174
175 psc->intr_est = pcic_pci_machdep_intr_est(pc);
176
177 irq = pcic_intr_find(sc, IST_EDGE);
178
179
180 if (irq) {
181 sc->ih = pcic_pci_machdep_pcic_intr_establish(sc, pcic_intr);
182 if (sc->ih == NULL) {
183 printf("%s: couldnt map interrupt\n", sc->dev.dv_xname);
184 bus_space_unmap(memt, memh, 0x10000);
185 bus_space_unmap(sc->iot, sc->ioh, size);
186 return;
187 }
188 }
189 sc->irq = irq;
190
191 if (irq) {
192 printf("%s: irq %d, ", sc->dev.dv_xname, irq);
193
194
195 for (i = 0; i < PCIC_NSLOTS; i++) {
196 h = &sc->handle[i];
197 if (h->flags & PCIC_FLAG_SOCKETP) {
198 pcic_write(h, PCIC_CSC_INTR,
199 (sc->irq << PCIC_CSC_INTR_IRQ_SHIFT) |
200 PCIC_CSC_INTR_CD_ENABLE);
201 powerhook_establish(pcic_power, h);
202 }
203 }
204 } else
205 printf("%s: no irq, ", sc->dev.dv_xname);
206
207 printf("polling enabled\n");
208 if (sc->poll_established == 0) {
209 timeout_set(&sc->poll_timeout, pcic_poll_intr, sc);
210 timeout_add(&sc->poll_timeout, hz / 2);
211 sc->poll_established = 1;
212 }
213 }