wdc_ts.c revision 1.3 1 1.3 bouyer /* $NetBSD: wdc_ts.c,v 1.3 2006/01/16 20:30:19 bouyer Exp $ */
2 1.1 joff
3 1.1 joff /*-
4 1.1 joff * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
5 1.1 joff * All rights reserved.
6 1.1 joff *
7 1.1 joff * This code is derived from software contributed to The NetBSD Foundation
8 1.1 joff * by Charles M. Hannum and by Onno van der Linden.
9 1.1 joff *
10 1.1 joff * Redistribution and use in source and binary forms, with or without
11 1.1 joff * modification, are permitted provided that the following conditions
12 1.1 joff * are met:
13 1.1 joff * 1. Redistributions of source code must retain the above copyright
14 1.1 joff * notice, this list of conditions and the following disclaimer.
15 1.1 joff * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 joff * notice, this list of conditions and the following disclaimer in the
17 1.1 joff * documentation and/or other materials provided with the distribution.
18 1.1 joff * 3. All advertising materials mentioning features or use of this software
19 1.1 joff * must display the following acknowledgement:
20 1.1 joff * This product includes software developed by the NetBSD
21 1.1 joff * Foundation, Inc. and its contributors.
22 1.1 joff * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 joff * contributors may be used to endorse or promote products derived
24 1.1 joff * from this software without specific prior written permission.
25 1.1 joff *
26 1.1 joff * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 joff * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 joff * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 joff * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 joff * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 joff * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 joff * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 joff * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 joff * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 joff * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 joff * POSSIBILITY OF SUCH DAMAGE.
37 1.1 joff */
38 1.1 joff
39 1.1 joff #include <sys/cdefs.h>
40 1.3 bouyer __KERNEL_RCSID(0, "$NetBSD: wdc_ts.c,v 1.3 2006/01/16 20:30:19 bouyer Exp $");
41 1.1 joff
42 1.1 joff #include <sys/param.h>
43 1.1 joff #include <sys/systm.h>
44 1.1 joff #include <sys/device.h>
45 1.1 joff #include <sys/malloc.h>
46 1.1 joff
47 1.1 joff #include <machine/bus.h>
48 1.1 joff #include <machine/intr.h>
49 1.1 joff
50 1.1 joff #include <arm/ep93xx/ep93xxvar.h>
51 1.1 joff
52 1.1 joff #include <dev/ic/wdcreg.h>
53 1.1 joff #include <dev/ata/atavar.h>
54 1.1 joff #include <dev/ic/wdcvar.h>
55 1.1 joff #include <evbarm/tsarm/tspldvar.h>
56 1.1 joff
57 1.1 joff struct wdc_ts_softc {
58 1.1 joff struct wdc_softc sc_wdcdev;
59 1.1 joff struct ata_channel *wdc_chanlist[1];
60 1.1 joff struct ata_channel ata_channel;
61 1.1 joff struct ata_queue wdc_chqueue;
62 1.1 joff struct wdc_regs wdc_regs;
63 1.1 joff void *sc_ih;
64 1.1 joff };
65 1.1 joff
66 1.1 joff static int wdc_ts_probe(struct device *, struct cfdata *, void *);
67 1.1 joff static void wdc_ts_attach(struct device *, struct device *, void *);
68 1.1 joff
69 1.1 joff CFATTACH_DECL(wdc_ts, sizeof(struct wdc_ts_softc),
70 1.1 joff wdc_ts_probe, wdc_ts_attach, NULL, NULL);
71 1.1 joff
72 1.1 joff static int
73 1.1 joff wdc_ts_probe(struct device *parent, struct cfdata *match, void *aux)
74 1.1 joff {
75 1.1 joff return 1;
76 1.1 joff }
77 1.1 joff
78 1.1 joff static void
79 1.1 joff wdc_ts_attach(struct device *parent, struct device *self, void *aux)
80 1.1 joff {
81 1.1 joff struct wdc_ts_softc *sc = (void *)self;
82 1.1 joff struct wdc_regs *wdr;
83 1.1 joff struct tspld_attach_args *ta = aux;
84 1.1 joff int i;
85 1.1 joff
86 1.1 joff sc->sc_wdcdev.regs = wdr = &sc->wdc_regs;
87 1.1 joff wdr->cmd_iot = ta->ta_iot;
88 1.1 joff wdr->ctl_iot = ta->ta_iot;
89 1.1 joff if (bus_space_map(wdr->cmd_iot, 0x11000000, 8, 0, &wdr->cmd_baseioh) ||
90 1.1 joff bus_space_map(wdr->ctl_iot, 0x10400006, 1, 0, &wdr->ctl_ioh)) {
91 1.1 joff printf(": couldn't map registers\n");
92 1.1 joff return;
93 1.1 joff }
94 1.1 joff
95 1.1 joff for (i = 0; i < 8; i++) {
96 1.1 joff if (bus_space_subregion(wdr->cmd_iot,
97 1.1 joff wdr->cmd_baseioh, i, 1, &wdr->cmd_iohs[i]) != 0) {
98 1.1 joff printf(": couldn't subregion registers\n");
99 1.1 joff return;
100 1.1 joff }
101 1.1 joff }
102 1.1 joff
103 1.1 joff
104 1.1 joff if (bus_space_map(wdr->cmd_iot, 0x21000000, 2, 0, &wdr->cmd_iohs[0])) {
105 1.1 joff printf(": couldn't map registers\n");
106 1.1 joff return;
107 1.1 joff }
108 1.1 joff
109 1.1 joff sc->sc_wdcdev.cap |= WDC_CAPABILITY_PREATA;
110 1.1 joff sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
111 1.1 joff
112 1.1 joff sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
113 1.1 joff sc->wdc_chanlist[0] = &sc->ata_channel;
114 1.1 joff sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanlist;
115 1.1 joff sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
116 1.1 joff sc->ata_channel.ch_channel = 0;
117 1.1 joff sc->ata_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
118 1.1 joff sc->ata_channel.ch_queue = &sc->wdc_chqueue;
119 1.3 bouyer sc->ata_channel.ch_ndrive = 2;
120 1.1 joff wdc_init_shadow_regs(&sc->ata_channel);
121 1.1 joff
122 1.1 joff printf("\n");
123 1.1 joff
124 1.1 joff sc->sc_ih = ep93xx_intr_establish(32, IPL_BIO, wdcintr, &sc->ata_channel);
125 1.1 joff
126 1.1 joff wdcattach(&sc->ata_channel);
127 1.1 joff }
128