📄 prep_pci.c
字号:
/* * $Id: prep_pci.c,v 1.40 1999/09/17 17:23:05 cort Exp $ * PReP pci functions. * Originally by Gary Thomas * rewritten and updated by Cort Dougan (cort@cs.nmt.edu) * * The motherboard routes/maps will disappear shortly. -- Cort */#include <linux/types.h>#include <linux/pci.h>#include <linux/kernel.h>#include <linux/init.h>#include <linux/openpic.h>#include <asm/init.h>#include <asm/byteorder.h>#include <asm/io.h>#include <asm/ptrace.h>#include <asm/prom.h>#include <asm/pci-bridge.h>#include <asm/residual.h>#include <asm/processor.h>#include <asm/irq.h>#include <asm/machdep.h>#include "pci.h"#define MAX_DEVNR 22/* Which PCI interrupt line does a given device [slot] use? *//* Note: This really should be two dimensional based in slot/pin used */unsigned char *Motherboard_map;unsigned char *Motherboard_map_name;/* How is the 82378 PIRQ mapping setup? */unsigned char *Motherboard_routes;/* Used for Motorola to store system config register */static unsigned long *ProcInfo;extern int chrp_get_irq(struct pt_regs *);extern void chrp_post_irq(struct pt_regs* regs, int);/* Tables for known hardware */ /* Motorola PowerStackII - Utah */static char Utah_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 5, /* Slot 2 - SCSI - NCR825A */ 0, /* Slot 3 - unused */ 1, /* Slot 4 - Ethernet - DEC2114x */ 0, /* Slot 5 - unused */ 3, /* Slot 6 - PCI Card slot #1 */ 4, /* Slot 7 - PCI Card slot #2 */ 5, /* Slot 8 - PCI Card slot #3 */ 5, /* Slot 9 - PCI Bridge */ /* added here in case we ever support PCI bridges */ /* Secondary PCI bus cards are at slot-9,6 & slot-9,7 */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 5, /* Slot 12 - SCSI - NCR825A */ 0, /* Slot 13 - unused */ 3, /* Slot 14 - enet */ 0, /* Slot 15 - unused */ 2, /* Slot 16 - unused */ 3, /* Slot 17 - unused */ 5, /* Slot 18 - unused */ 0, /* Slot 19 - unused */ 0, /* Slot 20 - unused */ 0, /* Slot 21 - unused */ 0, /* Slot 22 - unused */};static char Utah_pci_IRQ_routes[] __prepdata ={ 0, /* Line 0 - Unused */ 9, /* Line 1 */ 10, /* Line 2 */ 11, /* Line 3 */ 14, /* Line 4 */ 15, /* Line 5 */};/* Motorola PowerStackII - Omaha *//* no integrated SCSI or ethernet */static char Omaha_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 3, /* Slot 2 - Winbond EIDE */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 1, /* Slot 6 - PCI slot 1 */ 2, /* Slot 7 - PCI slot 2 */ 3, /* Slot 8 - PCI slot 3 */ 4, /* Slot 9 - PCI slot 4 */ /* needs indirect access */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 0, /* Slot 12 - unused */ 0, /* Slot 13 - unused */ 0, /* Slot 14 - unused */ 0, /* Slot 15 - unused */ 1, /* Slot 16 - PCI slot 1 */ 2, /* Slot 17 - PCI slot 2 */ 3, /* Slot 18 - PCI slot 3 */ 4, /* Slot 19 - PCI slot 4 */ /* needs indirect access */ 0, 0, 0,};static char Omaha_pci_IRQ_routes[] __prepdata ={ 0, /* Line 0 - Unused */ 9, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */};/* Motorola PowerStack */static char Blackhawk_pci_IRQ_map[19] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ 1, /* Slot P7 */ 2, /* Slot P6 */ 3, /* Slot P5 */};static char Blackhawk_pci_IRQ_routes[] __prepdata ={ 0, /* Line 0 - Unused */ 9, /* Line 1 */ 11, /* Line 2 */ 15, /* Line 3 */ 15 /* Line 4 */}; /* Motorola Mesquite */static char Mesquite_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unxued */ 0, /* Slot 11 - unused */ 0, /* Slot 12 - unused */ 0, /* Slot 13 - unused */ 2, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ 3, /* Slot 16 - PMC */ 0, /* Slot 17 - unused */ 0, /* Slot 18 - unused */ 0, /* Slot 19 - unused */ 0, /* Slot 20 - unused */ 0, /* Slot 21 - unused */ 0, /* Slot 22 - unused */};/* Motorola Sitka */static char Sitka_pci_IRQ_map[21] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unxued */ 0, /* Slot 11 - unused */ 0, /* Slot 12 - unused */ 0, /* Slot 13 - unused */ 2, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ 9, /* Slot 16 - PMC 1 */ 12, /* Slot 17 - PMC 2 */ 0, /* Slot 18 - unused */ 0, /* Slot 19 - unused */ 4, /* Slot 20 - NT P2P bridge */};/* Motorola MTX */static char MTX_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 2, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ 9, /* Slot 16 - PCI/PMC slot 1 */ 10, /* Slot 17 - PCI/PMC slot 2 */ 11, /* Slot 18 - PCI slot 3 */ 0, /* Slot 19 - unused */ 0, /* Slot 20 - unused */ 0, /* Slot 21 - unused */ 0, /* Slot 22 - unused */};/* Motorola MTX Plus *//* Secondary bus interrupt routing is not supported yet */static char MTXplus_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 2, /* Slot 14 - Ethernet 1 */ 0, /* Slot 15 - unused */ 9, /* Slot 16 - PCI slot 1P */ 10, /* Slot 17 - PCI slot 2P */ 11, /* Slot 18 - PCI slot 3P */ 10, /* Slot 19 - Ethernet 2 */ 0, /* Slot 20 - P2P Bridge */ 0, /* Slot 21 - unused */ 0, /* Slot 22 - unused */};static char Raven_pci_IRQ_routes[] __prepdata ={ 0, /* This is a dummy structure */}; /* Motorola MVME16xx */static char Genesis_pci_IRQ_map[16] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */};static char Genesis_pci_IRQ_routes[] __prepdata ={ 0, /* Line 0 - Unused */ 10, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */}; static char Genesis2_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - Ethernet */ 0, /* Slot 11 - Universe PCI - VME Bridge */ 3, /* Slot 12 - unused */ 0, /* Slot 13 - unused */ 2, /* Slot 14 - SCSI */ 0, /* Slot 15 - graphics on 3600 */ 9, /* Slot 16 - PMC */ 12, /* Slot 17 - pci */ 11, /* Slot 18 - pci */ 10, /* Slot 19 - pci */ 0, /* Slot 20 - pci */ 0, /* Slot 21 - unused */ 0, /* Slot 22 - unused */};/* Motorola Series-E */static char Comet_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet */ 0, /* Slot 15 - unused */ 1, /* Slot 16 - PCI slot 1 */ 2, /* Slot 17 - PCI slot 2 */ 3, /* Slot 18 - PCI slot 3 */ 4, /* Slot 19 - PCI bridge */ 0, 0, 0,};static char Comet_pci_IRQ_routes[] __prepdata ={ 0, /* Line 0 - Unused */ 10, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15 /* Line 4 */};/* Motorola Series-EX */static char Comet2_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 3, /* Slot 2 - SCSI - NCR825A */ 0, /* Slot 3 - unused */ 1, /* Slot 4 - Ethernet - DEC2104X */ 0, /* Slot 5 - unused */ 1, /* Slot 6 - PCI slot 1 */ 2, /* Slot 7 - PCI slot 2 */ 3, /* Slot 8 - PCI slot 3 */ 4, /* Slot 9 - PCI bridge */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI - NCR825A */ 0, /* Slot 13 - unused */ 1, /* Slot 14 - Ethernet - DEC2104X */ 0, /* Slot 15 - unused */ 1, /* Slot 16 - PCI slot 1 */ 2, /* Slot 17 - PCI slot 2 */ 3, /* Slot 18 - PCI slot 3 */ 4, /* Slot 19 - PCI bridge */ 0, 0, 0,};static char Comet2_pci_IRQ_routes[] __prepdata ={ 0, /* Line 0 - Unused */ 10, /* Line 1 */ 11, /* Line 2 */ 14, /* Line 3 */ 15, /* Line 4 */};/* * ibm 830 (and 850?). * This is actually based on the Carolina motherboard * -- Cort */static char ibm8xx_pci_IRQ_map[23] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - FireCoral */ 4, /* Slot 12 - Ethernet PCIINTD# */ 2, /* Slot 13 - PCI Slot #2 */ 2, /* Slot 14 - S3 Video PCIINTD# */ 0, /* Slot 15 - onboard SCSI (INDI) [1] */ 3, /* Slot 16 - NCR58C810 RS6000 Only PCIINTC# */ 0, /* Slot 17 - unused */ 2, /* Slot 18 - PCI Slot 2 PCIINTx# (See below) */ 0, /* Slot 19 - unused */ 0, /* Slot 20 - unused */ 0, /* Slot 21 - unused */ 2, /* Slot 22 - PCI slot 1 PCIINTx# (See below) */};static char ibm8xx_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - unused */ 13, /* Line 1 */ 10, /* Line 2 */ 15, /* Line 3 */ 15, /* Line 4 */};/* * a 6015 ibm board * -- Cort */static char ibm6015_pci_IRQ_map[23] __prepdata = { 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - */ 1, /* Slot 12 - SCSI */ 2, /* Slot 13 - */ 2, /* Slot 14 - */ 1, /* Slot 15 - */ 1, /* Slot 16 - */ 0, /* Slot 17 - */ 2, /* Slot 18 - */ 0, /* Slot 19 - */ 0, /* Slot 20 - */ 0, /* Slot 21 - */ 2, /* Slot 22 - */};static char ibm6015_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - unused */ 13, /* Line 1 */ 10, /* Line 2 */ 15, /* Line 3 */ 15, /* Line 4 */};/* IBM Nobis and 850 */static char Nobis_pci_IRQ_map[23] __prepdata ={ 0, /* Slot 0 - unused */ 0, /* Slot 1 - unused */ 0, /* Slot 2 - unused */ 0, /* Slot 3 - unused */ 0, /* Slot 4 - unused */ 0, /* Slot 5 - unused */ 0, /* Slot 6 - unused */ 0, /* Slot 7 - unused */ 0, /* Slot 8 - unused */ 0, /* Slot 9 - unused */ 0, /* Slot 10 - unused */ 0, /* Slot 11 - unused */ 3, /* Slot 12 - SCSI */ 0, /* Slot 13 - unused */ 0, /* Slot 14 - unused */ 0, /* Slot 15 - unused */};static char Nobis_pci_IRQ_routes[] __prepdata = { 0, /* Line 0 - Unused */ 13, /* Line 1 */ 13, /* Line 2 */ 13, /* Line 3 */ 13 /* Line 4 */};/* We have to turn on LEVEL mode for changed IRQ's *//* All PCI IRQ's need to be level mode, so this should be something * other than hard-coded as well... IRQ's are individually mappable * to either edge or level. */#define CAROLINA_IRQ_EDGE_MASK_LO 0x00 /* IRQ's 0-7 */#define CAROLINA_IRQ_EDGE_MASK_HI 0xA4 /* IRQ's 8-15 [10,13,15] *//* * 8259 edge/level control definitions */#define ISA8259_M_ELCR 0x4d0#define ISA8259_S_ELCR 0x4d1#define ELCRS_INT15_LVL 0x80#define ELCRS_INT14_LVL 0x40#define ELCRS_INT12_LVL 0x10#define ELCRS_INT11_LVL 0x08#define ELCRS_INT10_LVL 0x04#define ELCRS_INT9_LVL 0x02#define ELCRS_INT8_LVL 0x01#define ELCRM_INT7_LVL 0x80#define ELCRM_INT5_LVL 0x20#define CFGPTR(dev) (0x80800000 | (1<<(dev>>3)) | ((dev&7)<<8) | offset)#define DEVNO(dev) (dev>>3) __prepintprep_pcibios_read_config_dword (unsigned char bus, unsigned char dev, unsigned char offset, unsigned int *val){ unsigned long _val; unsigned long *ptr; if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { *val = 0xFFFFFFFF;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -