This source file includes following definitions.
- cy_pci_match
- cy_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 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/device.h>
43
44 #include <machine/bus.h>
45
46 #include <dev/pci/pcivar.h>
47 #include <dev/pci/pcireg.h>
48 #include <dev/pci/pcidevs.h>
49
50 #include <dev/ic/cd1400reg.h>
51 #include <dev/ic/cyreg.h>
52
53 int cy_pci_match(struct device *, void *, void *);
54 void cy_pci_attach(struct device *, struct device *, void *);
55
56 struct cy_pci_softc {
57 struct cy_softc sc_cy;
58
59 bus_space_tag_t sc_iot;
60 bus_space_handle_t sc_ioh;
61 };
62
63 struct cfattach cy_pci_ca = {
64 sizeof(struct cy_pci_softc), cy_pci_match, cy_pci_attach
65 };
66
67 #define CY_PLX_9050_ICS_IENABLE 0x040
68 #define CY_PLX_9050_ICS_LOCAL_IENABLE 0x001
69 #define CY_PLX_9050_ICS_LOCAL_IPOLARITY 0x002
70 #define CY_PLX_9060_ICS_IENABLE 0x100
71 #define CY_PLX_9060_ICS_LOCAL_IENABLE 0x800
72
73 const struct pci_matchid cy_pci_devices[] = {
74 { PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOMY_1 },
75 { PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOMY_2 },
76 { PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM4Y_1 },
77 { PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM4Y_2 },
78 { PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM8Y_1 },
79 { PCI_VENDOR_CYCLADES, PCI_PRODUCT_CYCLADES_CYCLOM8Y_2 },
80 };
81
82 int
83 cy_pci_match(parent, match, aux)
84 struct device *parent;
85 void *match, *aux;
86 {
87 return (pci_matchbyid((struct pci_attach_args *)aux, cy_pci_devices,
88 sizeof(cy_pci_devices)/sizeof(cy_pci_devices[0])));
89 }
90
91 void
92 cy_pci_attach(parent, self, aux)
93 struct device *parent, *self;
94 void *aux;
95 {
96 struct cy_pci_softc *psc = (struct cy_pci_softc *)self;
97 struct cy_softc *sc = (struct cy_softc *)self;
98 struct pci_attach_args *pa = aux;
99 const char *intrstr = NULL;
100 pci_intr_handle_t ih;
101 pcireg_t memtype;
102 int plx_ver;
103
104 sc->sc_bustype = CY_BUSTYPE_PCI;
105
106 switch (PCI_PRODUCT(pa->pa_id)) {
107 case PCI_PRODUCT_CYCLADES_CYCLOMY_1:
108 case PCI_PRODUCT_CYCLADES_CYCLOM4Y_1:
109 case PCI_PRODUCT_CYCLADES_CYCLOM8Y_1:
110 memtype = PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT_1M;
111 break;
112 case PCI_PRODUCT_CYCLADES_CYCLOMY_2:
113 case PCI_PRODUCT_CYCLADES_CYCLOM4Y_2:
114 case PCI_PRODUCT_CYCLADES_CYCLOM8Y_2:
115 memtype = PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT;
116 break;
117 }
118
119 if (pci_mapreg_map(pa, 0x14, PCI_MAPREG_TYPE_IO, 0,
120 &psc->sc_iot, &psc->sc_ioh, NULL, NULL, 0) != 0) {
121 printf(": unable to map PLX registers\n");
122 return;
123 }
124
125 if (pci_mapreg_map(pa, 0x18, memtype, 0, &sc->sc_memt,
126 &sc->sc_memh, NULL, NULL, 0) != 0) {
127 printf(": couldn't map device registers\n");
128 return;
129 }
130
131 if ((sc->sc_nr_cd1400s = cy_probe_common(sc->sc_memt, sc->sc_memh,
132 CY_BUSTYPE_PCI)) == 0) {
133 printf(": PCI Cyclom card with no CD1400s\n");
134 return;
135 }
136
137 if (pci_intr_map(pa, &ih) != 0) {
138 printf(": couldn't map interrupt\n");
139 return;
140 }
141
142 intrstr = pci_intr_string(pa->pa_pc, ih);
143 sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_TTY, cy_intr,
144 sc, sc->sc_dev.dv_xname);
145 if (sc->sc_ih == NULL) {
146 printf(": couldn't establish interrupt");
147 if (intrstr != NULL)
148 printf(" at %s", intrstr);
149 printf("\n");
150 return;
151 }
152 printf(": %s", intrstr);
153
154 cy_attach(parent, self);
155
156
157 plx_ver = bus_space_read_1(sc->sc_memt, sc->sc_memh, CY_PLX_VER) & 0x0f;
158
159
160 switch (plx_ver) {
161 case CY_PLX_9050:
162 bus_space_write_2(psc->sc_iot, psc->sc_ioh, CY_PCI_INTENA_9050,
163 CY_PLX_9050_ICS_IENABLE | CY_PLX_9050_ICS_LOCAL_IENABLE |
164 CY_PLX_9050_ICS_LOCAL_IPOLARITY);
165 break;
166
167 case CY_PLX_9060:
168 case CY_PLX_9080:
169 default:
170 bus_space_write_2(psc->sc_iot, psc->sc_ioh, CY_PCI_INTENA,
171 bus_space_read_2(psc->sc_iot, psc->sc_ioh,
172 CY_PCI_INTENA) | CY_PLX_9060_ICS_IENABLE |
173 CY_PLX_9060_ICS_LOCAL_IENABLE);
174 }
175 }