FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/wdc_upc.c
1 /* $NetBSD: wdc_upc.c,v 1.15 2004/01/03 22:56:53 thorpej Exp $ */
2 /*-
3 * Copyright (c) 2000 Ben Harris
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 /* This file is part of NetBSD/arm26 -- a port of NetBSD to ARM2/3 machines. */
29
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: wdc_upc.c,v 1.15 2004/01/03 22:56:53 thorpej Exp $");
32
33 #include <sys/param.h>
34 #include <sys/device.h>
35 #include <sys/malloc.h>
36 #include <sys/systm.h>
37
38 #include <machine/bus.h>
39 #include <machine/intr.h>
40
41 #include <dev/ata/atavar.h> /* XXX needed by wdcvar.h */
42
43 #include <dev/ic/upcvar.h>
44 #include <dev/ic/wdcreg.h>
45 #include <dev/ic/wdcvar.h>
46
47 static int wdc_upc_match(struct device *, struct cfdata *, void *);
48 static void wdc_upc_attach(struct device *, struct device *, void *);
49
50 struct wdc_upc_softc {
51 struct wdc_softc sc_wdc;
52 struct wdc_channel *sc_chanlist[1];
53 struct wdc_channel sc_channel;
54 struct ata_queue sc_chqueue;
55 };
56
57 CFATTACH_DECL(wdc_upc, sizeof(struct wdc_upc_softc),
58 wdc_upc_match, wdc_upc_attach, NULL, NULL);
59
60 static int
61 wdc_upc_match(struct device *parent, struct cfdata *cf, void *aux)
62 {
63
64 /* upc_submatch does it all anyway */
65 return 1;
66 }
67
68 static void
69 wdc_upc_attach(struct device *parent, struct device *self, void *aux)
70 {
71 struct wdc_upc_softc *sc = (struct wdc_upc_softc *)self;
72 struct upc_attach_args *ua = aux;
73 int i;
74
75 sc->sc_wdc.cap = WDC_CAPABILITY_DATA16;
76 sc->sc_wdc.PIO_cap = 1; /* XXX ??? */
77 sc->sc_wdc.DMA_cap = 0;
78 sc->sc_wdc.UDMA_cap = 0;
79 sc->sc_wdc.nchannels = 1;
80 sc->sc_chanlist[0] = &sc->sc_channel;
81 sc->sc_wdc.channels = sc->sc_chanlist;
82 sc->sc_channel.cmd_iot = ua->ua_iot;
83 sc->sc_channel.cmd_baseioh = ua->ua_ioh;
84 sc->sc_channel.ctl_iot = ua->ua_iot;
85 sc->sc_channel.ctl_ioh = ua->ua_ioh2;
86 sc->sc_channel.ch_channel = 0;
87 sc->sc_channel.ch_wdc = &sc->sc_wdc;
88 sc->sc_channel.ch_queue = &sc->sc_chqueue;
89 for (i = 0; i < WDC_NREG; i++) {
90 if (bus_space_subregion(ua->ua_iot, ua->ua_ioh, i,
91 i == 0 ? 4 : 1, &sc->sc_channel.cmd_iohs[i]) != 0) {
92 aprint_error("%s: can't subregion I/O space\n",
93 sc->sc_wdc.sc_dev.dv_xname);
94 return;
95 }
96 }
97
98 upc_intr_establish(ua->ua_irqhandle, IPL_BIO, wdcintr,
99 &sc->sc_channel);
100
101 aprint_normal("\n");
102 aprint_naive("\n");
103
104 wdcattach(&sc->sc_channel);
105 }
Cache object: 95d4bb34ccfeb7698a9e8b5481065bd8
|