1/* $NetBSD: ixm1200_pci.c,v 1.13 2018/11/16 15:06:23 jmcneill Exp $ */ 2#define PCI_DEBUG 3/* 4 * Copyright (c) 2002, 2003 5 * Ichiro FUKUHARA <ichiro@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 * 17 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> 31__KERNEL_RCSID(0, "$NetBSD: ixm1200_pci.c,v 1.13 2018/11/16 15:06:23 jmcneill Exp $"); 32 33/* 34 * IXM1200 PCI interrupt support. 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/device.h> 40 41#include <machine/autoconf.h> 42#include <sys/bus.h> 43 44#include <evbarm/ixm1200/ixm1200reg.h> 45#include <evbarm/ixm1200/ixm1200var.h> 46 47#include <arm/ixp12x0/ixp12x0reg.h> 48#include <arm/ixp12x0/ixp12x0var.h> 49 50#include <arm/ixp12x0/ixp12x0_pcireg.h> 51 52#include <dev/pci/pcidevs.h> 53#include <dev/pci/ppbreg.h> 54 55int ixm1200_pci_intr_map(const struct pci_attach_args *, pci_intr_handle_t *); 56const char *ixm1200_pci_intr_string(void *, pci_intr_handle_t, char *, size_t); 57const struct evcnt *ixm1200_pci_intr_evcnt(void *, pci_intr_handle_t); 58void *ixm1200_pci_intr_establish(void *, pci_intr_handle_t, int, 59 int (*func)(void *), void *, const char *); 60void ixm1200_pci_intr_disestablish(void *, void *); 61 62void 63ixm1200_pci_init(pci_chipset_tag_t pc, void *cookie) 64{ 65 pc->pc_intr_v = cookie; 66 pc->pc_intr_map = ixm1200_pci_intr_map; 67 pc->pc_intr_string = ixm1200_pci_intr_string; 68 pc->pc_intr_evcnt = ixm1200_pci_intr_evcnt; 69 pc->pc_intr_establish = ixm1200_pci_intr_establish; 70 pc->pc_intr_disestablish = ixm1200_pci_intr_disestablish; 71} 72 73int 74ixm1200_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp) 75{ 76#ifdef PCI_DEBUG 77 void *v = pa->pa_pc; 78 int pin = pa->pa_intrpin; 79 int line = pa->pa_intrline; 80 int dev=pa->pa_device; 81 pcitag_t intrtag = pa->pa_intrtag; 82 83 printf("ixm1200_pci_intr_map: v=%p, tag=%08lx intrpin=%d line=%d dev=%d\n", 84 v, intrtag, pin, line, dev); 85#endif 86 87 /* ixp12x0 has only one interrupt line for PCI */ 88 *ihp = IXPPCI_INTR_PIL; 89 return (0); 90} 91 92const char * 93ixm1200_pci_intr_string(void *v, pci_intr_handle_t ih, char *buf, size_t len) 94{ 95 snprintf(buf, len, "IXM1200 irq %" PRIu64, ih); 96 return buf; 97} 98 99const struct evcnt * 100ixm1200_pci_intr_evcnt(void *v, pci_intr_handle_t ih) 101{ 102 return (NULL); 103} 104 105void * 106ixm1200_pci_intr_establish(void *v, pci_intr_handle_t ih, int ipl, int (*func)(void *), 107 void *arg, const char *xname) 108{ 109#ifdef PCI_DEBUG 110 printf("ixm1200_pci_intr_establish(v=%p, irq=%d, ipl=%d, func=%p, arg=%p, xname=%s)\n", 111 v, (int) ih, ipl, func, arg, xname); 112#endif 113 114 return (ixp12x0_intr_establish(ih, ipl, func, arg)); 115} 116 117void 118ixm1200_pci_intr_disestablish(void *v, void *cookie) 119{ 120#ifdef PCI_DEBUG 121 printf("ixm1200_pci_intr_disestablish(v=%p, cookie=%p)\n", 122 v, cookie); 123#endif 124 125 ixp12x0_intr_disestablish(cookie); 126} 127