cp3100_pci.c revision 1.1
11.1Sscw/* $NetBSD: cp3100_pci.c,v 1.1 2006/11/08 23:49:02 scw Exp $ */ 21.1Sscw 31.1Sscw/* 41.1Sscw * Copyright 2006 Wasabi Systems, Inc. 51.1Sscw * All rights reserved. 61.1Sscw * 71.1Sscw * Written by Steve C. Woodford for Wasabi Systems, Inc. 81.1Sscw * 91.1Sscw * Redistribution and use in source and binary forms, with or without 101.1Sscw * modification, are permitted provided that the following conditions 111.1Sscw * are met: 121.1Sscw * 1. Redistributions of source code must retain the above copyright 131.1Sscw * notice, this list of conditions and the following disclaimer. 141.1Sscw * 2. Redistributions in binary form must reproduce the above copyright 151.1Sscw * notice, this list of conditions and the following disclaimer in the 161.1Sscw * documentation and/or other materials provided with the distribution. 171.1Sscw * 3. All advertising materials mentioning features or use of this software 181.1Sscw * must display the following acknowledgement: 191.1Sscw * This product includes software developed for the NetBSD Project by 201.1Sscw * Wasabi Systems, Inc. 211.1Sscw * 4. The name of Wasabi Systems, Inc. may not be used to endorse 221.1Sscw * or promote products derived from this software without specific prior 231.1Sscw * written permission. 241.1Sscw * 251.1Sscw * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 261.1Sscw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.1Sscw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.1Sscw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 291.1Sscw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.1Sscw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.1Sscw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.1Sscw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.1Sscw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.1Sscw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.1Sscw * POSSIBILITY OF SUCH DAMAGE. 361.1Sscw */ 371.1Sscw 381.1Sscw/* 391.1Sscw * CP3100 PCI interrupt support. 401.1Sscw */ 411.1Sscw 421.1Sscw#include <sys/cdefs.h> 431.1Sscw__KERNEL_RCSID(0, "$NetBSD: cp3100_pci.c,v 1.1 2006/11/08 23:49:02 scw Exp $"); 441.1Sscw 451.1Sscw#include <sys/param.h> 461.1Sscw#include <sys/systm.h> 471.1Sscw#include <sys/device.h> 481.1Sscw 491.1Sscw#include <machine/autoconf.h> 501.1Sscw#include <machine/bus.h> 511.1Sscw 521.1Sscw#include <evbarm/iq80321/iq80321reg.h> 531.1Sscw#include <evbarm/iq80321/iq80321var.h> 541.1Sscw 551.1Sscw#include <arm/xscale/i80321reg.h> 561.1Sscw#include <arm/xscale/i80321var.h> 571.1Sscw 581.1Sscw#include <dev/pci/pcidevs.h> 591.1Sscw#include <dev/pci/ppbreg.h> 601.1Sscw 611.1Sscwint iq80321_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *); 621.1Sscwconst char *iq80321_pci_intr_string(void *, pci_intr_handle_t); 631.1Sscwconst struct evcnt *iq80321_pci_intr_evcnt(void *, pci_intr_handle_t); 641.1Sscwvoid *iq80321_pci_intr_establish(void *, pci_intr_handle_t, 651.1Sscw int, int (*func)(void *), void *); 661.1Sscwvoid iq80321_pci_intr_disestablish(void *, void *); 671.1Sscw 681.1Sscwvoid 691.1Sscwiq80321_pci_init(pci_chipset_tag_t pc, void *cookie) 701.1Sscw{ 711.1Sscw 721.1Sscw pc->pc_intr_v = cookie; /* the i80321 softc */ 731.1Sscw pc->pc_intr_map = iq80321_pci_intr_map; 741.1Sscw pc->pc_intr_string = iq80321_pci_intr_string; 751.1Sscw pc->pc_intr_evcnt = iq80321_pci_intr_evcnt; 761.1Sscw pc->pc_intr_establish = iq80321_pci_intr_establish; 771.1Sscw pc->pc_intr_disestablish = iq80321_pci_intr_disestablish; 781.1Sscw} 791.1Sscw 801.1Sscwint 811.1Sscwiq80321_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) 821.1Sscw{ 831.1Sscw struct i80321_softc *sc = pa->pa_pc->pc_intr_v; 841.1Sscw int b, d, f; 851.1Sscw uint32_t busno; 861.1Sscw 871.1Sscw busno = bus_space_read_4(sc->sc_st, sc->sc_atu_sh, ATU_PCIXSR); 881.1Sscw busno = PCIXSR_BUSNO(busno); 891.1Sscw if (busno == 0xff) 901.1Sscw busno = 0; 911.1Sscw 921.1Sscw pci_decompose_tag(pa->pa_pc, pa->pa_intrtag, &b, &d, &f); 931.1Sscw 941.1Sscw /* No mappings for devices not on our bus. */ 951.1Sscw if (b != busno) 961.1Sscw goto no_mapping; 971.1Sscw 981.1Sscw switch (d) { 991.1Sscw case 0: /* i82546EB Dual GigE */ 1001.1Sscw /* 1011.1Sscw * This is a dual-function chip which uses INTA and INTB, 1021.1Sscw * connected to XINT0 and XINT1 respectively. 1031.1Sscw */ 1041.1Sscw if (f != 0 && f != 1) 1051.1Sscw goto no_mapping; 1061.1Sscw *ihp = ICU_INT_XINT(f); 1071.1Sscw return (0); 1081.1Sscw 1091.1Sscw case 1: /* i31244 S-ATA Interface */ 1101.1Sscw *ihp = ICU_INT_XINT(2); 1111.1Sscw return (0); 1121.1Sscw 1131.1Sscw case 2: /* Symbios Logic 53c1010 SCSI Controllers */ 1141.1Sscw case 3: 1151.1Sscw /* 1161.1Sscw * Both controllers share a single pin 1171.1Sscw */ 1181.1Sscw *ihp = ICU_INT_XINT(3); 1191.1Sscw return (0); 1201.1Sscw 1211.1Sscw default: 1221.1Sscw no_mapping: 1231.1Sscw printf("iq80321_pci_intr_map: no mapping for %d/%d/%d/%c\n", 1241.1Sscw pa->pa_bus, pa->pa_device, pa->pa_function, 1251.1Sscw '@' + pa->pa_intrpin); 1261.1Sscw return (1); 1271.1Sscw } 1281.1Sscw 1291.1Sscw return (0); 1301.1Sscw} 1311.1Sscw 1321.1Sscwconst char * 1331.1Sscwiq80321_pci_intr_string(void *v, pci_intr_handle_t ih) 1341.1Sscw{ 1351.1Sscw 1361.1Sscw return (i80321_irqnames[ih]); 1371.1Sscw} 1381.1Sscw 1391.1Sscwconst struct evcnt * 1401.1Sscwiq80321_pci_intr_evcnt(void *v, pci_intr_handle_t ih) 1411.1Sscw{ 1421.1Sscw 1431.1Sscw /* XXX For now. */ 1441.1Sscw return (NULL); 1451.1Sscw} 1461.1Sscw 1471.1Sscwvoid * 1481.1Sscwiq80321_pci_intr_establish(void *v, pci_intr_handle_t ih, int ipl, 1491.1Sscw int (*func)(void *), void *arg) 1501.1Sscw{ 1511.1Sscw 1521.1Sscw return (i80321_intr_establish(ih, ipl, func, arg)); 1531.1Sscw} 1541.1Sscw 1551.1Sscwvoid 1561.1Sscwiq80321_pci_intr_disestablish(void *v, void *cookie) 1571.1Sscw{ 1581.1Sscw 1591.1Sscw i80321_intr_disestablish(cookie); 1601.1Sscw} 161