wdc_ts.c revision 1.1 1 /* $NetBSD: wdc_ts.c,v 1.1 2004/12/23 04:30:50 joff Exp $ */
2
3 /*-
4 * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum and by Onno van der Linden.
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 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: wdc_ts.c,v 1.1 2004/12/23 04:30:50 joff Exp $");
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
45 #include <sys/malloc.h>
46
47 #include <machine/bus.h>
48 #include <machine/intr.h>
49
50 #include <arm/ep93xx/ep93xxvar.h>
51
52 #include <dev/ic/wdcreg.h>
53 #include <dev/ata/atavar.h>
54 #include <dev/ic/wdcvar.h>
55 #include <evbarm/tsarm/tspldvar.h>
56
57 struct wdc_ts_softc {
58 struct wdc_softc sc_wdcdev;
59 struct ata_channel *wdc_chanlist[1];
60 struct ata_channel ata_channel;
61 struct ata_queue wdc_chqueue;
62 struct wdc_regs wdc_regs;
63 void *sc_ih;
64 };
65
66 static int wdc_ts_probe(struct device *, struct cfdata *, void *);
67 static void wdc_ts_attach(struct device *, struct device *, void *);
68
69 CFATTACH_DECL(wdc_ts, sizeof(struct wdc_ts_softc),
70 wdc_ts_probe, wdc_ts_attach, NULL, NULL);
71
72 static int
73 wdc_ts_probe(struct device *parent, struct cfdata *match, void *aux)
74 {
75 return 1;
76 }
77
78 static void
79 wdc_ts_attach(struct device *parent, struct device *self, void *aux)
80 {
81 struct wdc_ts_softc *sc = (void *)self;
82 struct wdc_regs *wdr;
83 struct tspld_attach_args *ta = aux;
84 int i;
85
86 sc->sc_wdcdev.regs = wdr = &sc->wdc_regs;
87 wdr->cmd_iot = ta->ta_iot;
88 wdr->ctl_iot = ta->ta_iot;
89 if (bus_space_map(wdr->cmd_iot, 0x11000000, 8, 0, &wdr->cmd_baseioh) ||
90 bus_space_map(wdr->ctl_iot, 0x10400006, 1, 0, &wdr->ctl_ioh)) {
91 printf(": couldn't map registers\n");
92 return;
93 }
94
95 for (i = 0; i < 8; i++) {
96 if (bus_space_subregion(wdr->cmd_iot,
97 wdr->cmd_baseioh, i, 1, &wdr->cmd_iohs[i]) != 0) {
98 printf(": couldn't subregion registers\n");
99 return;
100 }
101 }
102
103
104 if (bus_space_map(wdr->cmd_iot, 0x21000000, 2, 0, &wdr->cmd_iohs[0])) {
105 printf(": couldn't map registers\n");
106 return;
107 }
108
109 sc->sc_wdcdev.cap |= WDC_CAPABILITY_PREATA;
110 sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
111
112 sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
113 sc->wdc_chanlist[0] = &sc->ata_channel;
114 sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanlist;
115 sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
116 sc->ata_channel.ch_channel = 0;
117 sc->ata_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
118 sc->ata_channel.ch_queue = &sc->wdc_chqueue;
119 wdc_init_shadow_regs(&sc->ata_channel);
120
121 printf("\n");
122
123 sc->sc_ih = ep93xx_intr_establish(32, IPL_BIO, wdcintr, &sc->ata_channel);
124
125 wdcattach(&sc->ata_channel);
126 }
127