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