This source file includes following definitions.
- wdc_isapnp_match
- wdc_isapnp_attach
- wdc_isapnp_dma_setup
- wdc_isapnp_dma_start
- wdc_isapnp_dma_finish
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/types.h>
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/device.h>
44 #include <sys/malloc.h>
45
46 #include <machine/bus.h>
47 #include <machine/intr.h>
48
49 #include <dev/isa/isavar.h>
50 #include <dev/isa/isadmavar.h>
51
52 #include <dev/ata/atavar.h>
53 #include <dev/ic/wdcreg.h>
54 #include <dev/ic/wdcvar.h>
55
56 struct wdc_isapnp_softc {
57 struct wdc_softc sc_wdcdev;
58 struct channel_softc *wdc_chanptr;
59 struct channel_softc wdc_channel;
60 isa_chipset_tag_t sc_ic;
61 void *sc_ih;
62 int sc_drq;
63 };
64
65 int wdc_isapnp_match(struct device *, void *, void *);
66 void wdc_isapnp_attach(struct device *, struct device *, void *);
67
68 struct cfattach wdc_isapnp_ca = {
69 sizeof(struct wdc_isapnp_softc), wdc_isapnp_match, wdc_isapnp_attach
70 };
71
72 #ifdef notyet
73 static void wdc_isapnp_dma_setup(struct wdc_isapnp_softc *);
74 static void wdc_isapnp_dma_start(void *, void *, size_t, int);
75 static void wdc_isapnp_dma_finish(void *);
76 #endif
77
78 int
79 wdc_isapnp_match(parent, match, aux)
80 struct device *parent;
81 void *match;
82 void *aux;
83 {
84 struct isa_attach_args *ipa = aux;
85
86 if (ipa->ipa_nio != 2 ||
87 ipa->ipa_nmem != 0 ||
88 ipa->ipa_nmem32 != 0 ||
89 ipa->ipa_nirq != 1 ||
90 ipa->ipa_ndrq > 1)
91 return 0;
92
93 return (1);
94 }
95
96 void
97 wdc_isapnp_attach(parent, self, aux)
98 struct device *parent, *self;
99 void *aux;
100 {
101 struct wdc_isapnp_softc *sc = (void *)self;
102 struct isa_attach_args *ipa = aux;
103
104
105 sc->wdc_channel.cmd_iot = ipa->ia_iot;
106 sc->wdc_channel.ctl_iot = ipa->ia_iot;
107
108
109
110
111
112
113 if (ipa->ipa_io[0].length == 8) {
114 sc->wdc_channel.cmd_ioh = ipa->ipa_io[0].h;
115 sc->wdc_channel.ctl_ioh = ipa->ipa_io[1].h;
116 } else {
117 sc->wdc_channel.cmd_ioh = ipa->ipa_io[1].h;
118 sc->wdc_channel.ctl_ioh = ipa->ipa_io[0].h;
119 }
120 sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot;
121 sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh;
122
123 sc->sc_ic = ipa->ia_ic;
124 sc->sc_ih = isa_intr_establish(ipa->ia_ic, ipa->ipa_irq[0].num,
125 ipa->ipa_irq[0].type, IPL_BIO, wdcintr, &sc->wdc_channel,
126 sc->sc_wdcdev.sc_dev.dv_xname);
127
128 #ifdef notyet
129 if (ipa->ipa_ndrq > 0) {
130 sc->sc_drq = ipa->ipa_drq[0].num;
131
132 sc->sc_ad.cap |= WDC_CAPABILITY_DMA;
133 sc->sc_ad.dma_start = &wdc_isapnp_dma_start;
134 sc->sc_ad.dma_finish = &wdc_isapnp_dma_finish;
135 wdc_isapnp_dma_setup(sc);
136 }
137 #endif
138 sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
139 sc->sc_wdcdev.PIO_cap = 0;
140 sc->wdc_chanptr = &sc->wdc_channel;
141 sc->sc_wdcdev.channels = &sc->wdc_chanptr;
142 sc->sc_wdcdev.nchannels = 1;
143 sc->wdc_channel.channel = 0;
144 sc->wdc_channel.wdc = &sc->sc_wdcdev;
145 sc->wdc_channel.ch_queue = malloc(sizeof(struct channel_queue),
146 M_DEVBUF, M_NOWAIT);
147 if (sc->wdc_channel.ch_queue == NULL) {
148 printf(": can't allocate memory for command queue\n");
149 return;
150 }
151
152 printf("\n");
153 wdcattach(&sc->wdc_channel);
154 wdc_print_current_modes(&sc->wdc_channel);
155 }
156
157 #ifdef notyet
158 static void
159 wdc_isapnp_dma_setup(sc)
160 struct wdc_isapnp_softc *sc;
161 {
162
163 if (isa_dmamap_create(sc->sc_ic, sc->sc_drq,
164 MAXPHYS, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
165 printf("%s: can't create map for drq %d\n",
166 sc->sc_wdcdev.sc_dev.dv_xname, sc->sc_drq);
167 sc->sc_wdcdev.cap &= ~WDC_CAPABILITY_DMA;
168 }
169 }
170
171 static void
172 wdc_isapnp_dma_start(scv, buf, size, read)
173 void *scv, *buf;
174 size_t size;
175 int read;
176 {
177 struct wdc_isapnp_softc *sc = scv;
178
179 isa_dmastart(sc->sc_ic, sc->sc_drq, buf, size, NULL,
180 (read ? DMAMODE_READ : DMAMODE_WRITE) | DMAMODE_DEMAND,
181 BUS_DMA_NOWAIT);
182 }
183
184 static void
185 wdc_isapnp_dma_finish(scv)
186 void *scv;
187 {
188 struct wdc_isapnp_softc *sc = scv;
189
190 isa_dmadone(sc->sc_ic, sc->sc_drq);
191 }
192 #endif