Home | History | Annotate | Line # | Download | only in ixm1200
ixm1200_pci.c revision 1.2.2.2
      1 /*      $NetBSD: ixm1200_pci.c,v 1.2.2.2 2002/09/06 08:34:11 jdolecek Exp $ */
      2 /*
      3  * Copyright (c) 2002
      4  *      Ichiro FUKUHARA <ichiro (at) ichiro.org>.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Ichiro FUKUHARA.
     18  * 4. The name of the company nor the name of the author may be used to
     19  *    endorse or promote products derived from this software without specific
     20  *    prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     26  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  */
     34 
     35 /*
     36  * IXM1200 PCI interrupt support.
     37  */
     38 
     39 #include <sys/param.h>
     40 #include <sys/systm.h>
     41 #include <sys/device.h>
     42 
     43 #include <machine/autoconf.h>
     44 #include <machine/bus.h>
     45 
     46 #include <evbarm/ixm1200/ixm1200reg.h>
     47 #include <evbarm/ixm1200/ixm1200var.h>
     48 
     49 #include <arm/ixp12x0/ixp12x0reg.h>
     50 #include <arm/ixp12x0/ixp12x0var.h>
     51 
     52 #include <arm/ixp12x0/ixp12x0_pcireg.h>
     53 
     54 #include <dev/pci/pcidevs.h>
     55 #include <dev/pci/ppbreg.h>
     56 
     57 int ixm1200_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
     58 const char *ixm1200_pci_intr_string(void *, pci_intr_handle_t);
     59 const struct evcnt *ixm1200_pci_intr_evcnt(void *, pci_intr_handle_t);
     60 void *ixm1200_pci_intr_establish(void *, pci_intr_handle_t, int,
     61 	int (*func)(void *), void *);
     62 void ixm1200_pci_intr_disestablish(void *, void *);
     63 
     64 #ifdef PCI_DEBUG
     65 extern void ixp12x0_pci_decompose_tag();
     66 #endif
     67 
     68 void
     69 ixm1200_pci_init(pc, cookie)
     70 	pci_chipset_tag_t pc;
     71 	void *cookie;
     72 {
     73 	pc->pc_intr_v = cookie;
     74 	pc->pc_intr_map = ixm1200_pci_intr_map;
     75 	pc->pc_intr_string = ixm1200_pci_intr_string;
     76 	pc->pc_intr_evcnt = ixm1200_pci_intr_evcnt;
     77 	pc->pc_intr_establish = ixm1200_pci_intr_establish;
     78 	pc->pc_intr_disestablish = ixm1200_pci_intr_disestablish;
     79 }
     80 
     81 int
     82 ixm1200_pci_intr_map(pa, ihp)
     83 	struct pci_attach_args *pa;
     84 	pci_intr_handle_t *ihp;
     85 {
     86 	int pin = pa->pa_intrpin, line = pa->pa_intrline;
     87 
     88 #ifdef PCI_DEBUG
     89 	void *v = pa->pa_pc;
     90 	pcitag_t intrtag = pa->pa_intrtag;
     91 	int bus, device, function;
     92 
     93 	ixp12x0_pci_decompose_tag(v, intrtag, &bus, &device, &function);
     94 	printf("ixm1200_pci_intr_map: v=%p, tag=%08lx intrpin=%d line=%d dev=%d\n",
     95 		v, intrtag, pin, line, device);
     96 #else
     97 	printf("pin = %d, line = %d\n", pin, line);
     98 #endif
     99 
    100 	*ihp = IXPPCI_INTR_PIL;
    101 	return (0);
    102 }
    103 
    104 const char *
    105 ixm1200_pci_intr_string(v, ih)
    106 	void *v;
    107 	pci_intr_handle_t ih;
    108 {
    109 	static char irqstr[IRQNAMESIZE];
    110 
    111 	sprintf(irqstr, "IXM1200 irq %ld", ih);
    112 	return (irqstr);
    113 }
    114 
    115 const struct evcnt *
    116 ixm1200_pci_intr_evcnt(v, ih)
    117 	void *v;
    118 	pci_intr_handle_t ih;
    119 {
    120 	return (NULL);
    121 }
    122 
    123 void *
    124 ixm1200_pci_intr_establish(v, ih, ipl, func, arg)
    125 	void *v;
    126 	pci_intr_handle_t ih;
    127 	int ipl;
    128 	int (*func)(void *);
    129 	void *arg;
    130 {
    131 	return (ixp12x0_intr_establish(ih, ipl, func, arg));
    132 }
    133 
    134 void
    135 ixm1200_pci_intr_disestablish(void *v, void *cookie)
    136 {
    137 	ixp12x0_intr_disestablish(cookie);
    138 }
    139