Home | History | Annotate | Line # | Download | only in pci
pci_machdep.c revision 1.16
      1  1.16  kiyohara /*	$NetBSD: pci_machdep.c,v 1.16 2008/02/17 03:54:21 kiyohara Exp $	*/
      2   1.1  sakamoto 
      3   1.1  sakamoto /*
      4   1.1  sakamoto  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      5   1.4   mycroft  * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
      6   1.1  sakamoto  *
      7   1.1  sakamoto  * Redistribution and use in source and binary forms, with or without
      8   1.1  sakamoto  * modification, are permitted provided that the following conditions
      9   1.1  sakamoto  * are met:
     10   1.1  sakamoto  * 1. Redistributions of source code must retain the above copyright
     11   1.1  sakamoto  *    notice, this list of conditions and the following disclaimer.
     12   1.1  sakamoto  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1  sakamoto  *    notice, this list of conditions and the following disclaimer in the
     14   1.1  sakamoto  *    documentation and/or other materials provided with the distribution.
     15   1.1  sakamoto  * 3. All advertising materials mentioning features or use of this software
     16   1.1  sakamoto  *    must display the following acknowledgement:
     17   1.4   mycroft  *	This product includes software developed by Charles M. Hannum.
     18   1.1  sakamoto  * 4. The name of the author may not be used to endorse or promote products
     19   1.1  sakamoto  *    derived from this software without specific prior written permission.
     20   1.1  sakamoto  *
     21   1.1  sakamoto  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1  sakamoto  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1  sakamoto  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1  sakamoto  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1  sakamoto  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1  sakamoto  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1  sakamoto  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1  sakamoto  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1  sakamoto  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1  sakamoto  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1  sakamoto  */
     32   1.1  sakamoto 
     33   1.1  sakamoto /*
     34   1.1  sakamoto  * Machine-specific functions for PCI autoconfiguration.
     35   1.1  sakamoto  *
     36   1.1  sakamoto  * On PCs, there are two methods of generating PCI configuration cycles.
     37   1.1  sakamoto  * We try to detect the appropriate mechanism for this machine and set
     38   1.1  sakamoto  * up a few function pointers to access the correct method directly.
     39   1.1  sakamoto  */
     40  1.13     lukem 
     41  1.13     lukem #include <sys/cdefs.h>
     42  1.16  kiyohara __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.16 2008/02/17 03:54:21 kiyohara Exp $");
     43   1.1  sakamoto 
     44   1.1  sakamoto #include <sys/types.h>
     45   1.1  sakamoto #include <sys/param.h>
     46   1.1  sakamoto #include <sys/time.h>
     47   1.1  sakamoto #include <sys/systm.h>
     48   1.1  sakamoto #include <sys/errno.h>
     49   1.1  sakamoto #include <sys/device.h>
     50   1.1  sakamoto 
     51   1.7       mrg #include <uvm/uvm_extern.h>
     52   1.1  sakamoto 
     53  1.10      matt #define _POWERPC_BUS_DMA_PRIVATE
     54   1.2  sakamoto #include <machine/bus.h>
     55   1.1  sakamoto #include <machine/intr.h>
     56   1.1  sakamoto 
     57  1.15   garbled #include <powerpc/pio.h>
     58  1.15   garbled 
     59   1.1  sakamoto #include <dev/isa/isavar.h>
     60   1.1  sakamoto #include <dev/pci/pcivar.h>
     61   1.1  sakamoto #include <dev/pci/pcireg.h>
     62  1.15   garbled #include <dev/pci/pcidevs.h>
     63   1.1  sakamoto 
     64  1.15   garbled #include <machine/pci_machdep.h>
     65   1.1  sakamoto 
     66  1.15   garbled extern struct genppc_pci_chipset *genppc_pct;
     67   1.1  sakamoto 
     68  1.15   garbled #define	PCI_MODE1_ADDRESS_REG	(PREP_BUS_SPACE_IO + 0xcf8)
     69  1.15   garbled #define	PCI_MODE1_DATA_REG	(PREP_BUS_SPACE_IO + 0xcfc)
     70   1.1  sakamoto 
     71  1.15   garbled void pci_intr_fixup(int, int, int *);
     72   1.1  sakamoto 
     73   1.1  sakamoto void
     74  1.15   garbled bebox_pci_get_chipset_tag(pci_chipset_tag_t pc)
     75   1.1  sakamoto {
     76  1.15   garbled 	pc->pc_conf_v = (void *)pc;
     77   1.1  sakamoto 
     78  1.15   garbled 	pc->pc_attach_hook = genppc_pci_indirect_attach_hook;
     79  1.15   garbled 	pc->pc_bus_maxdevs = genppc_pci_bus_maxdevs;
     80  1.15   garbled 	pc->pc_make_tag = genppc_pci_indirect_make_tag;
     81  1.15   garbled 	pc->pc_conf_read = genppc_pci_indirect_conf_read;
     82  1.15   garbled 	pc->pc_conf_write = genppc_pci_indirect_conf_write;
     83  1.15   garbled 
     84  1.15   garbled 	pc->pc_intr_v = (void *)pc;
     85  1.15   garbled 
     86  1.15   garbled 	pc->pc_intr_map = genppc_pci_intr_map;
     87  1.15   garbled 	pc->pc_intr_string = genppc_pci_intr_string;
     88  1.15   garbled 	pc->pc_intr_evcnt = genppc_pci_intr_evcnt;
     89  1.15   garbled 	pc->pc_intr_establish = genppc_pci_intr_establish;
     90  1.15   garbled 	pc->pc_intr_disestablish = genppc_pci_intr_disestablish;
     91  1.15   garbled 
     92  1.15   garbled 	pc->pc_conf_interrupt = bebox_pci_conf_interrupt;
     93  1.15   garbled 	pc->pc_decompose_tag = genppc_pci_indirect_decompose_tag;
     94  1.15   garbled 	pc->pc_conf_hook = genppc_pci_conf_hook;
     95  1.15   garbled 
     96  1.15   garbled 	pc->pc_addr = mapiodev(PCI_MODE1_ADDRESS_REG, 4);
     97  1.15   garbled 	pc->pc_data = mapiodev(PCI_MODE1_DATA_REG, 4);
     98  1.15   garbled 	pc->pc_bus = 0;
     99  1.15   garbled 	pc->pc_node = 0;
    100  1.15   garbled 	pc->pc_memt = 0;
    101  1.15   garbled 	pc->pc_iot = 0;
    102   1.9    briggs }
    103   1.9    briggs 
    104   1.9    briggs void
    105  1.15   garbled bebox_pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int pin,
    106   1.9    briggs     int swiz, int *iline)
    107   1.9    briggs {
    108  1.16  kiyohara 
    109  1.16  kiyohara 	if (bus == 0) {
    110  1.16  kiyohara 		switch (dev) {
    111  1.16  kiyohara 		case 12: /*       SCSI is bit 10, mapped to IRQ 26 */
    112  1.16  kiyohara 		case 13: /* PCI slot 1 is bit 11, mapped to IRQ 27 */
    113  1.16  kiyohara 		case 14: /* PCI slot 2 is bit 12, mapped to IRQ 28 */
    114  1.16  kiyohara 		case 15: /* PCI slot 3 is bit 13, mapped to IRQ 29 */
    115  1.16  kiyohara #define  BEBOX_PCIBUS0_DEV2LINE(d)	((d) + 14)
    116  1.16  kiyohara 			*iline = BEBOX_PCIBUS0_DEV2LINE(dev);
    117  1.16  kiyohara 		}
    118  1.16  kiyohara 	} else
    119  1.16  kiyohara #define  BEBOX_PCIBUS_DEV2LINE(d, s)	((((d) + (s) + 1) & 0x3) + 26)
    120  1.16  kiyohara 		*iline = BEBOX_PCIBUS_DEV2LINE(dev, swiz);
    121   1.1  sakamoto }
    122