FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/wdc_upc.c
1 /* $NetBSD: wdc_upc.c,v 1.23 2006/10/01 21:50:33 bjh21 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.23 2006/10/01 21:50:33 bjh21 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 ata_channel *sc_chanlist[1];
53 struct ata_channel sc_channel;
54 struct ata_queue sc_chqueue;
55 struct wdc_regs sc_wdc_regs;
56 };
57
58 CFATTACH_DECL(wdc_upc, sizeof(struct wdc_upc_softc),
59 wdc_upc_match, wdc_upc_attach, NULL, NULL);
60
61 static int
62 wdc_upc_match(struct device *parent, struct cfdata *cf, void *aux)
63 {
64
65 /* upc_submatch does it all anyway */
66 return 1;
67 }
68
69 static void
70 wdc_upc_attach(struct device *parent, struct device *self, void *aux)
71 {
72 struct wdc_upc_softc *sc = (struct wdc_upc_softc *)self;
73 struct wdc_regs *wdr;
74 struct upc_attach_args *ua = aux;
75 int i;
76
77 sc->sc_wdc.regs = wdr = &sc->sc_wdc_regs;
78
79 sc->sc_wdc.sc_atac.atac_cap = ATAC_CAP_DATA16;
80 sc->sc_wdc.sc_atac.atac_pio_cap = 1; /* XXX ??? */
81 sc->sc_wdc.sc_atac.atac_nchannels = 1;
82 sc->sc_chanlist[0] = &sc->sc_channel;
83 sc->sc_wdc.sc_atac.atac_channels = sc->sc_chanlist;
84 wdr->cmd_iot = ua->ua_iot;
85 wdr->cmd_baseioh = ua->ua_ioh;
86 wdr->ctl_iot = ua->ua_iot;
87 wdr->ctl_ioh = ua->ua_ioh2;
88 sc->sc_channel.ch_channel = 0;
89 sc->sc_channel.ch_atac = &sc->sc_wdc.sc_atac;
90 sc->sc_channel.ch_queue = &sc->sc_chqueue;
91 sc->sc_channel.ch_ndrive = 2;
92 for (i = 0; i < WDC_NREG; i++) {
93 if (bus_space_subregion(ua->ua_iot, ua->ua_ioh, i,
94 i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) {
95 aprint_error("%s: can't subregion I/O space\n",
96 sc->sc_wdc.sc_atac.atac_dev.dv_xname);
97 return;
98 }
99 }
100 wdc_init_shadow_regs(&sc->sc_channel);
101
102 upc_intr_establish(ua->ua_irqhandle, IPL_BIO, wdcintr,
103 &sc->sc_channel);
104
105 aprint_normal("\n");
106 aprint_naive("\n");
107
108 wdcattach(&sc->sc_channel);
109 }
Cache object: 2e2a18ca4e8476a774ae971b46bf7c5e
|