[BACK]Return to pci_up1000.c CVS log [TXT][DIR] Up to [local] / sys / arch / alpha / pci

Annotation of sys/arch/alpha/pci/pci_up1000.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: pci_up1000.c,v 1.12 2007/05/02 21:50:14 martin Exp $  */
                      2: /* $NetBSD: pci_up1000.c,v 1.6 2000/12/28 22:59:07 sommerfeld Exp $ */
                      3:
                      4: /*-
                      5:  * Copyright (c) 2000 The NetBSD Foundation, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code is derived from software contributed to The NetBSD Foundation
                      9:  * by Jason R. Thorpe.
                     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/time.h>
                     43: #include <sys/systm.h>
                     44: #include <sys/errno.h>
                     45: #include <sys/device.h>
                     46:
                     47: #include <uvm/uvm_extern.h>
                     48:
                     49: #include <machine/autoconf.h>
                     50: #include <machine/bus.h>
                     51: #include <machine/intr.h>
                     52:
                     53: #include <dev/isa/isavar.h>
                     54:
                     55: #include <dev/pci/pcireg.h>
                     56: #include <dev/pci/pcivar.h>
                     57: #include <dev/pci/pciidereg.h>
                     58: #include <dev/pci/pciidevar.h>
                     59:
                     60: #include <alpha/pci/irongatevar.h>
                     61:
                     62: #include <alpha/pci/pci_up1000.h>
                     63: #include <alpha/pci/siovar.h>
                     64: #include <alpha/pci/sioreg.h>
                     65:
                     66: #include "sio.h"
                     67:
                     68: int     api_up1000_intr_map(void *, pcitag_t, int, int, pci_intr_handle_t *);
                     69: const char *api_up1000_intr_string(void *, pci_intr_handle_t);
                     70: int    api_up1000_intr_line(void *, pci_intr_handle_t);
                     71: void    *api_up1000_intr_establish(void *, pci_intr_handle_t,
                     72:            int, int (*func)(void *), void *, char *);
                     73: void    api_up1000_intr_disestablish(void *, void *);
                     74:
                     75: void   *api_up1000_pciide_compat_intr_establish(void *, struct device *,
                     76:            struct pci_attach_args *, int, int (*)(void *), void *);
                     77: void    api_up1000_pciide_compat_intr_disestablish(void *, void *);
                     78:
                     79: void
                     80: pci_up1000_pickintr(struct irongate_config *icp)
                     81: {
                     82:        bus_space_tag_t iot = &icp->ic_iot;
                     83:        pci_chipset_tag_t pc = &icp->ic_pc;
                     84:
                     85:        pc->pc_intr_v = icp;
                     86:        pc->pc_intr_map = api_up1000_intr_map;
                     87:        pc->pc_intr_string = api_up1000_intr_string;
                     88:        pc->pc_intr_line = api_up1000_intr_line;
                     89:        pc->pc_intr_establish = api_up1000_intr_establish;
                     90:        pc->pc_intr_disestablish = api_up1000_intr_disestablish;
                     91:
                     92:        pc->pc_pciide_compat_intr_establish =
                     93:            api_up1000_pciide_compat_intr_establish;
                     94:        pc->pc_pciide_compat_intr_disestablish =
                     95:            api_up1000_pciide_compat_intr_disestablish;
                     96:
                     97: #if NSIO
                     98:        sio_intr_setup(pc, iot);
                     99: #else
                    100:        panic("pci_up1000_pickintr: no I/O interrupt handler (no sio)");
                    101: #endif
                    102: }
                    103:
                    104: int
                    105: api_up1000_intr_map(void *icv, pcitag_t bustag, int buspin, int line, pci_intr_handle_t *ihp)
                    106: {
                    107:        struct irongate_config *icc = icv;
                    108:        pci_chipset_tag_t pc = &icc->ic_pc;
                    109:        int bus, device, function;
                    110:
                    111:        if (buspin == 0) {
                    112:                /* No IRQ used. */
                    113:                return 1;
                    114:        }
                    115:        if (buspin > 4) {
                    116:                printf("api_up1000_intr_map: bad interrupt pin %d\n",
                    117:                    buspin);
                    118:                return 1;
                    119:        }
                    120:
                    121:        pci_decompose_tag(pc, bustag, &bus, &device, &function);
                    122:
                    123:        /*
                    124:         * The console places the interrupt mapping in the "line" value.
                    125:         * A value of (char)-1 indicates there is no mapping.
                    126:         */
                    127:        if (line == 0xff) {
                    128:                printf("api_up1000_intr_map: no mapping for %d/%d/%d\n",
                    129:                    bus, device, function);
                    130:                return (1);
                    131:        }
                    132:
                    133:        /* XXX Check for 0? */
                    134:        if (line > 15) {
                    135: #ifdef DIAGNOSTIC
                    136:                printf("api_up1000_intr_map: ISA IRQ too large (%d)\n",
                    137:                    line);
                    138: #endif
                    139:                return (1);
                    140:        }
                    141:        if (line == 2) {
                    142: #ifdef DIAGNOSTIC
                    143:                printf("api_up1000_intr_map: changed IRQ 2 to IRQ 9\n");
                    144: #endif
                    145:                line = 9;
                    146:        }
                    147:
                    148:        *ihp = line;
                    149:        return (0);
                    150: }
                    151:
                    152: const char *
                    153: api_up1000_intr_string(void *icv, pci_intr_handle_t ih)
                    154: {
                    155: #if 0
                    156:        struct irongate_config *icp = icv;
                    157: #endif
                    158:
                    159:        return sio_intr_string(NULL /*XXX*/, ih);
                    160: }
                    161:
                    162: int
                    163: api_up1000_intr_line(void *icv, pci_intr_handle_t ih)
                    164: {
                    165:        return sio_intr_line(NULL /*XXX*/, ih);
                    166: }
                    167:
                    168: void *
                    169: api_up1000_intr_establish(void *icv, pci_intr_handle_t ih, int level,
                    170:     int (*func)(void *), void *arg, char *name)
                    171: {
                    172: #if 0
                    173:        struct irongate_config *icp = icv;
                    174: #endif
                    175:
                    176:        return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
                    177:            arg, name);
                    178: }
                    179:
                    180: void
                    181: api_up1000_intr_disestablish(void *icv, void *cookie)
                    182: {
                    183: #if 0
                    184:        struct irongate_config *icp = icv;
                    185: #endif
                    186:
                    187:        sio_intr_disestablish(NULL /*XXX*/, cookie);
                    188: }
                    189:
                    190: void *
                    191: api_up1000_pciide_compat_intr_establish(void *icv, struct device *dev,
                    192:     struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
                    193: {
                    194:        pci_chipset_tag_t pc = pa->pa_pc;
                    195:        void *cookie = NULL;
                    196:        int bus, irq;
                    197:
                    198:        pci_decompose_tag(pc, pa->pa_tag, &bus, NULL, NULL);
                    199:
                    200:        /*
                    201:         * If this isn't PCI bus #0, all bets are off.
                    202:         */
                    203:        if (bus != 0)
                    204:                return (NULL);
                    205:
                    206:        irq = PCIIDE_COMPAT_IRQ(chan);
                    207: #if NSIO
                    208:        cookie = sio_intr_establish(NULL /*XXX*/, irq, IST_EDGE, IPL_BIO,
                    209:            func, arg, dev->dv_xname);
                    210:        if (cookie == NULL)
                    211:                return (NULL);
                    212: #endif
                    213:        return (cookie);
                    214: }
                    215:
                    216: void
                    217: api_up1000_pciide_compat_intr_disestablish(void *v, void *cookie)
                    218: {
                    219:        sio_intr_disestablish(NULL, cookie);
                    220: }

CVSweb