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