root/dev/isa/wdc_isapnp.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. wdc_isapnp_match
  2. wdc_isapnp_attach
  3. wdc_isapnp_dma_setup
  4. wdc_isapnp_dma_start
  5. wdc_isapnp_dma_finish

    1 /*      $OpenBSD: wdc_isapnp.c,v 1.7 2002/03/14 01:26:56 millert Exp $  */
    2 /*      $NetBSD: wdc_isapnp.c,v 1.13 1999/03/22 10:00:12 mycroft Exp $  */
    3 
    4 /*-
    5  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Charles M. Hannum and by Onno van der Linden.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *        This product includes software developed by the NetBSD
   22  *        Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 #include <sys/types.h>
   41 #include <sys/param.h>
   42 #include <sys/systm.h>
   43 #include <sys/device.h>
   44 #include <sys/malloc.h>
   45 
   46 #include <machine/bus.h>
   47 #include <machine/intr.h>
   48 
   49 #include <dev/isa/isavar.h>
   50 #include <dev/isa/isadmavar.h>
   51 
   52 #include <dev/ata/atavar.h>
   53 #include <dev/ic/wdcreg.h>
   54 #include <dev/ic/wdcvar.h>
   55 
   56 struct wdc_isapnp_softc {
   57         struct  wdc_softc sc_wdcdev;
   58         struct  channel_softc *wdc_chanptr;
   59         struct  channel_softc wdc_channel;
   60         isa_chipset_tag_t sc_ic;
   61         void    *sc_ih;
   62         int     sc_drq;
   63 };
   64 
   65 int     wdc_isapnp_match(struct device *, void *, void *);
   66 void    wdc_isapnp_attach(struct device *, struct device *, void *);
   67 
   68 struct cfattach wdc_isapnp_ca = {
   69         sizeof(struct wdc_isapnp_softc), wdc_isapnp_match, wdc_isapnp_attach
   70 };
   71 
   72 #ifdef notyet
   73 static void     wdc_isapnp_dma_setup(struct wdc_isapnp_softc *);
   74 static void     wdc_isapnp_dma_start(void *, void *, size_t, int);
   75 static void     wdc_isapnp_dma_finish(void *);
   76 #endif
   77 
   78 int
   79 wdc_isapnp_match(parent, match, aux)
   80         struct device *parent;
   81         void *match;
   82         void *aux;
   83 {
   84         struct isa_attach_args *ipa = aux;
   85 
   86         if (ipa->ipa_nio != 2 ||
   87             ipa->ipa_nmem != 0 ||
   88             ipa->ipa_nmem32 != 0 ||
   89             ipa->ipa_nirq != 1 ||
   90             ipa->ipa_ndrq > 1)
   91                 return 0;
   92 
   93         return (1);
   94 }
   95 
   96 void
   97 wdc_isapnp_attach(parent, self, aux)
   98         struct device *parent, *self;
   99         void *aux;
  100 {
  101         struct wdc_isapnp_softc *sc = (void *)self;
  102         struct isa_attach_args *ipa = aux;
  103 
  104 
  105         sc->wdc_channel.cmd_iot = ipa->ia_iot;
  106         sc->wdc_channel.ctl_iot = ipa->ia_iot;
  107 
  108         /*
  109          * An IDE controller can feed us the regions in any order. Pass
  110          * them along with the 8-byte region in sc_ad.ioh, and the other
  111          * (2 byte) region in auxioh.
  112          */
  113         if (ipa->ipa_io[0].length == 8) {
  114                 sc->wdc_channel.cmd_ioh = ipa->ipa_io[0].h;
  115                 sc->wdc_channel.ctl_ioh = ipa->ipa_io[1].h;
  116         } else {
  117                 sc->wdc_channel.cmd_ioh = ipa->ipa_io[1].h;
  118                 sc->wdc_channel.ctl_ioh = ipa->ipa_io[0].h;
  119         }
  120         sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot;
  121         sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh;
  122 
  123         sc->sc_ic = ipa->ia_ic;
  124         sc->sc_ih = isa_intr_establish(ipa->ia_ic, ipa->ipa_irq[0].num,
  125             ipa->ipa_irq[0].type, IPL_BIO, wdcintr, &sc->wdc_channel,
  126             sc->sc_wdcdev.sc_dev.dv_xname);
  127 
  128 #ifdef notyet
  129         if (ipa->ipa_ndrq > 0) {
  130                 sc->sc_drq = ipa->ipa_drq[0].num;
  131 
  132                 sc->sc_ad.cap |= WDC_CAPABILITY_DMA;
  133                 sc->sc_ad.dma_start = &wdc_isapnp_dma_start;
  134                 sc->sc_ad.dma_finish = &wdc_isapnp_dma_finish;
  135                 wdc_isapnp_dma_setup(sc);
  136         }
  137 #endif
  138         sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
  139         sc->sc_wdcdev.PIO_cap = 0;
  140         sc->wdc_chanptr = &sc->wdc_channel;
  141         sc->sc_wdcdev.channels = &sc->wdc_chanptr;
  142         sc->sc_wdcdev.nchannels = 1;
  143         sc->wdc_channel.channel = 0;
  144         sc->wdc_channel.wdc = &sc->sc_wdcdev;
  145         sc->wdc_channel.ch_queue = malloc(sizeof(struct channel_queue),
  146             M_DEVBUF, M_NOWAIT);
  147         if (sc->wdc_channel.ch_queue == NULL) {
  148                 printf(": can't allocate memory for command queue\n");
  149                 return;
  150         }
  151 
  152         printf("\n");
  153         wdcattach(&sc->wdc_channel);
  154         wdc_print_current_modes(&sc->wdc_channel);
  155 }
  156 
  157 #ifdef notyet
  158 static void
  159 wdc_isapnp_dma_setup(sc)
  160         struct wdc_isapnp_softc *sc;
  161 {
  162 
  163         if (isa_dmamap_create(sc->sc_ic, sc->sc_drq,
  164             MAXPHYS, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
  165                 printf("%s: can't create map for drq %d\n",
  166                     sc->sc_wdcdev.sc_dev.dv_xname, sc->sc_drq);
  167                 sc->sc_wdcdev.cap &= ~WDC_CAPABILITY_DMA;
  168         }
  169 }
  170 
  171 static void
  172 wdc_isapnp_dma_start(scv, buf, size, read)
  173         void *scv, *buf;
  174         size_t size;
  175         int read;
  176 {
  177         struct wdc_isapnp_softc *sc = scv;
  178 
  179         isa_dmastart(sc->sc_ic, sc->sc_drq, buf, size, NULL,
  180             (read ? DMAMODE_READ : DMAMODE_WRITE) | DMAMODE_DEMAND,
  181             BUS_DMA_NOWAIT);
  182 }
  183 
  184 static void
  185 wdc_isapnp_dma_finish(scv)
  186         void *scv;
  187 {
  188         struct wdc_isapnp_softc *sc = scv;
  189 
  190         isa_dmadone(sc->sc_ic, sc->sc_drq);
  191 }
  192 #endif

/* [<][>][^][v][top][bottom][index][help] */