Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / evbarm / tsarm / wdc_ts.c
blob917b7f4f35ef5b88014b5eabbcf20bd520bae51c
1 /* $NetBSD: wdc_ts.c,v 1.4 2008/03/18 20:46:35 cube Exp $ */
3 /*-
4 * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum and by Onno van der Linden.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: wdc_ts.c,v 1.4 2008/03/18 20:46:35 cube Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
38 #include <sys/malloc.h>
40 #include <machine/bus.h>
41 #include <machine/intr.h>
43 #include <arm/ep93xx/ep93xxvar.h>
45 #include <dev/ic/wdcreg.h>
46 #include <dev/ata/atavar.h>
47 #include <dev/ic/wdcvar.h>
48 #include <evbarm/tsarm/tspldvar.h>
50 struct wdc_ts_softc {
51 struct wdc_softc sc_wdcdev;
52 struct ata_channel *wdc_chanlist[1];
53 struct ata_channel ata_channel;
54 struct ata_queue wdc_chqueue;
55 struct wdc_regs wdc_regs;
56 void *sc_ih;
59 static int wdc_ts_probe(device_t, cfdata_t, void *);
60 static void wdc_ts_attach(device_t, device_t, void *);
62 CFATTACH_DECL_NEW(wdc_ts, sizeof(struct wdc_ts_softc),
63 wdc_ts_probe, wdc_ts_attach, NULL, NULL);
65 static int
66 wdc_ts_probe(device_t parent, cfdata_t match, void *aux)
68 return 1;
71 static void
72 wdc_ts_attach(device_t parent, device_t self, void *aux)
74 struct wdc_ts_softc *sc = device_private(self);
75 struct wdc_regs *wdr;
76 struct tspld_attach_args *ta = aux;
77 int i;
79 sc->sc_wdcdev.sc_atac.atac_dev = self;
80 sc->sc_wdcdev.regs = wdr = &sc->wdc_regs;
81 wdr->cmd_iot = ta->ta_iot;
82 wdr->ctl_iot = ta->ta_iot;
83 if (bus_space_map(wdr->cmd_iot, 0x11000000, 8, 0, &wdr->cmd_baseioh) ||
84 bus_space_map(wdr->ctl_iot, 0x10400006, 1, 0, &wdr->ctl_ioh)) {
85 aprint_error(": couldn't map registers\n");
86 return;
89 for (i = 0; i < 8; i++) {
90 if (bus_space_subregion(wdr->cmd_iot,
91 wdr->cmd_baseioh, i, 1, &wdr->cmd_iohs[i]) != 0) {
92 aprint_error(": couldn't subregion registers\n");
93 return;
98 if (bus_space_map(wdr->cmd_iot, 0x21000000, 2, 0, &wdr->cmd_iohs[0])) {
99 aprint_error(": couldn't map registers\n");
100 return;
103 sc->sc_wdcdev.cap |= WDC_CAPABILITY_PREATA;
104 sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
106 sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
107 sc->wdc_chanlist[0] = &sc->ata_channel;
108 sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanlist;
109 sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
110 sc->ata_channel.ch_channel = 0;
111 sc->ata_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
112 sc->ata_channel.ch_queue = &sc->wdc_chqueue;
113 sc->ata_channel.ch_ndrive = 2;
114 wdc_init_shadow_regs(&sc->ata_channel);
116 aprint_normal("\n");
118 sc->sc_ih = ep93xx_intr_establish(32, IPL_BIO, wdcintr, &sc->ata_channel);
120 wdcattach(&sc->ata_channel);