2008-03-18 23:46:35 +03:00
|
|
|
/* $NetBSD: dtide.c,v 1.25 2008/03/18 20:46:37 cube Exp $ */
|
2000-05-10 01:55:44 +04:00
|
|
|
|
|
|
|
/*-
|
2001-06-13 22:29:40 +04:00
|
|
|
* Copyright (c) 2000, 2001 Ben Harris
|
2000-05-10 01:55:44 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
2005-02-27 03:26:58 +03:00
|
|
|
*
|
2000-05-10 01:55:44 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* dtide.c - Driver for the D.T. Software IDE interface.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:23:15 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-03-18 23:46:35 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: dtide.c,v 1.25 2008/03/18 20:46:37 cube Exp $");
|
2000-05-10 01:55:44 +04:00
|
|
|
|
2001-11-13 10:23:15 +03:00
|
|
|
#include <sys/param.h>
|
2000-05-10 01:55:44 +04:00
|
|
|
|
|
|
|
#include <sys/device.h>
|
2001-06-13 22:29:40 +04:00
|
|
|
#include <sys/malloc.h>
|
2000-05-10 01:55:44 +04:00
|
|
|
#include <sys/systm.h>
|
2001-06-13 22:29:40 +04:00
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
2000-05-10 01:55:44 +04:00
|
|
|
|
2001-04-19 17:47:07 +04:00
|
|
|
#include <dev/podulebus/podulebus.h>
|
2001-03-17 23:34:43 +03:00
|
|
|
#include <dev/podulebus/podules.h>
|
2001-06-09 00:13:24 +04:00
|
|
|
#include <dev/podulebus/dtidereg.h>
|
2000-05-10 01:55:44 +04:00
|
|
|
|
2003-11-29 23:30:27 +03:00
|
|
|
#include <dev/ic/wdcreg.h>
|
2000-05-10 01:55:44 +04:00
|
|
|
#include <dev/ata/atavar.h>
|
|
|
|
#include <dev/ic/wdcvar.h>
|
|
|
|
|
|
|
|
struct dtide_softc {
|
|
|
|
struct wdc_softc sc_wdc;
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *sc_chp[DTIDE_NCHANNELS];/* pointers to sc_chan */
|
|
|
|
struct ata_channel sc_chan[DTIDE_NCHANNELS];
|
2004-01-01 20:18:53 +03:00
|
|
|
struct ata_queue sc_chq[DTIDE_NCHANNELS];
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs sc_wdc_regs[DTIDE_NCHANNELS];
|
2000-05-10 01:55:44 +04:00
|
|
|
bus_space_tag_t sc_magict;
|
|
|
|
bus_space_handle_t sc_magich;
|
|
|
|
};
|
|
|
|
|
2008-03-18 23:46:35 +03:00
|
|
|
static int dtide_match(device_t, cfdata_t, void *);
|
|
|
|
static void dtide_attach(device_t, device_t, void *);
|
2000-05-10 01:55:44 +04:00
|
|
|
|
2008-03-18 23:46:35 +03:00
|
|
|
CFATTACH_DECL_NEW(dtide, sizeof(struct dtide_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
dtide_match, dtide_attach, NULL, NULL);
|
2000-05-10 01:55:44 +04:00
|
|
|
|
2001-06-13 22:29:40 +04:00
|
|
|
static const int dtide_cmdoffsets[] = { DTIDE_CMDBASE0, DTIDE_CMDBASE1 };
|
|
|
|
static const int dtide_ctloffsets[] = { DTIDE_CTLBASE0, DTIDE_CTLBASE1 };
|
2001-06-09 00:13:24 +04:00
|
|
|
|
2000-05-10 01:55:44 +04:00
|
|
|
static int
|
2008-03-18 23:46:35 +03:00
|
|
|
dtide_match(device_t parent, cfdata_t cf, void *aux)
|
2000-05-10 01:55:44 +04:00
|
|
|
{
|
|
|
|
struct podulebus_attach_args *pa = aux;
|
|
|
|
|
2001-06-09 00:13:24 +04:00
|
|
|
return pa->pa_product == PODULE_DTSOFT_IDE;
|
2000-05-10 01:55:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-18 23:46:35 +03:00
|
|
|
dtide_attach(device_t parent, device_t self, void *aux)
|
2000-05-10 01:55:44 +04:00
|
|
|
{
|
|
|
|
struct podulebus_attach_args *pa = aux;
|
2006-03-29 10:51:47 +04:00
|
|
|
struct dtide_softc *sc = device_private(self);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr;
|
|
|
|
struct ata_channel *ch;
|
2003-11-29 23:30:27 +03:00
|
|
|
int i, j;
|
2000-05-10 01:55:44 +04:00
|
|
|
bus_space_tag_t bst;
|
|
|
|
|
2008-03-18 23:46:35 +03:00
|
|
|
sc->sc_wdc.sc_atac.atac_dev = self;
|
2004-08-14 19:08:04 +04:00
|
|
|
sc->sc_wdc.regs = sc->sc_wdc_regs;
|
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
sc->sc_wdc.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_NOIRQ;
|
|
|
|
sc->sc_wdc.sc_atac.atac_pio_cap = 0; /* XXX correct? */
|
|
|
|
sc->sc_wdc.sc_atac.atac_nchannels = DTIDE_NCHANNELS;
|
|
|
|
sc->sc_wdc.sc_atac.atac_channels = sc->sc_chp;
|
2000-05-10 01:55:44 +04:00
|
|
|
sc->sc_magict = pa->pa_fast_t;
|
2001-06-09 00:13:24 +04:00
|
|
|
bus_space_map(pa->pa_fast_t, pa->pa_fast_base + DTIDE_MAGICBASE, 0, 1,
|
|
|
|
&sc->sc_magich);
|
|
|
|
podulebus_shift_tag(pa->pa_fast_t, DTIDE_REGSHIFT, &bst);
|
2008-03-18 23:46:35 +03:00
|
|
|
aprint_normal("\n");
|
2001-06-13 22:29:40 +04:00
|
|
|
for (i = 0; i < DTIDE_NCHANNELS; i++) {
|
2003-11-29 23:30:27 +03:00
|
|
|
ch = sc->sc_chp[i] = &sc->sc_chan[i];
|
2004-08-14 19:08:04 +04:00
|
|
|
wdr = &sc->sc_wdc_regs[i];
|
2004-01-04 01:56:52 +03:00
|
|
|
ch->ch_channel = i;
|
2004-08-20 10:39:37 +04:00
|
|
|
ch->ch_atac = &sc->sc_wdc.sc_atac;
|
2004-08-14 19:08:04 +04:00
|
|
|
wdr->cmd_iot = bst;
|
|
|
|
wdr->ctl_iot = bst;
|
2003-11-29 23:30:27 +03:00
|
|
|
ch->ch_queue = &sc->sc_chq[i];
|
2006-01-16 23:30:18 +03:00
|
|
|
ch->ch_ndrive = 2;
|
2001-06-13 22:29:40 +04:00
|
|
|
bus_space_map(pa->pa_fast_t,
|
|
|
|
pa->pa_fast_base + dtide_cmdoffsets[i], 0, 8,
|
2004-08-14 19:08:04 +04:00
|
|
|
&wdr->cmd_baseioh);
|
2003-11-29 23:30:27 +03:00
|
|
|
for (j = 0; j < WDC_NREG; j++)
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
|
|
|
|
j, j == 0 ? 4 : 1, &wdr->cmd_iohs[j]);
|
2004-05-26 00:42:40 +04:00
|
|
|
wdc_init_shadow_regs(ch);
|
2001-06-13 22:29:40 +04:00
|
|
|
bus_space_map(pa->pa_fast_t,
|
|
|
|
pa->pa_fast_base + dtide_ctloffsets[i], 0, 8,
|
2004-08-14 19:08:04 +04:00
|
|
|
&wdr->ctl_ioh);
|
2003-11-29 23:30:27 +03:00
|
|
|
wdcattach(ch);
|
2001-06-09 00:13:24 +04:00
|
|
|
}
|
2000-05-10 01:55:44 +04:00
|
|
|
}
|