fdc_pnpbios.c revision 1.1 1 /* $NetBSD: fdc_pnpbios.c,v 1.1 2000/04/23 17:50:00 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * PNPBIOS attachment for the PC Floppy Controller driver.
41 */
42
43 #include "rnd.h"
44
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/callout.h>
48 #include <sys/device.h>
49 #include <sys/buf.h>
50 #include <sys/queue.h>
51 #if NRND > 0
52 #include <sys/rnd.h>
53 #endif
54
55 #include <machine/bus.h>
56 #include <machine/intr.h>
57
58 #include <dev/isa/isavar.h>
59 #include <dev/isa/isadmavar.h>
60
61 #include <dev/isa/fdcvar.h>
62
63 #include <i386/pnpbios/pnpbiosvar.h>
64
65 int fdc_pnpbios_match(struct device *, struct cfdata *, void *);
66 void fdc_pnpbios_attach(struct device *, struct device *, void *);
67
68 struct cfattach fdc_pnpbios_ca = {
69 sizeof(struct fdc_softc), fdc_pnpbios_match,
70 fdc_pnpbios_attach,
71 };
72
73 int
74 fdc_pnpbios_match(struct device *parent,
75 struct cfdata *match,
76 void *aux)
77 {
78 struct pnpbiosdev_attach_args *aa = aux;
79
80 if (strcmp(aa->idstr, "PNP0700") == 0)
81 return (1);
82
83 return (0);
84 }
85
86 void
87 fdc_pnpbios_attach(struct device *parent,
88 struct device *self,
89 void *aux)
90 {
91 struct fdc_softc *fdc = (void *) self;
92 struct pnpbiosdev_attach_args *aa = aux;
93
94 printf("\n");
95
96 fdc->sc_ic = aa->ic;
97
98 if (pnpbios_io_map(aa->pbt, aa->resc, 0, &fdc->sc_iot, &fdc->sc_ioh)) {
99 printf("%s: unable to map I/O space\n", fdc->sc_dev.dv_xname);
100 return;
101 }
102
103 if (pnpbios_io_map(aa->pbt, aa->resc, 1, &fdc->sc_iot,
104 &fdc->sc_fdctlioh)) {
105 printf("%s: unable to map CTL I/O space\n",
106 fdc->sc_dev.dv_xname);
107 return;
108 }
109
110 if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &fdc->sc_drq)) {
111 printf("%s: unable to get DMA channel\n",
112 fdc->sc_dev.dv_xname);
113 return;
114 }
115
116 pnpbios_print_devres(self, aa);
117
118 fdc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_BIO,
119 fdcintr, fdc);
120
121 fdcattach(fdc);
122 }
123