⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prep_pci.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
        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[] = {        0,      /* Line 0 - unused */        13,     /* Line 1 */        15,     /* Line 2 */        15,     /* Line 3 */        15,     /* Line 4 */};/* IBM Nobis and Thinkpad 850 */static char Nobis_pci_IRQ_map[23] ={        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[] = {        0, /* Line 0 - Unused */        13, /* Line 1 */        13, /* Line 2 */        13, /* Line 3 */        13      /* Line 4 */};/* * IBM RS/6000 43p/140  -- paulus * XXX we should get all this from the residual data */static char ibm43p_pci_IRQ_map[23] = {        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 ISA bridge */        6, /* Slot 12 - Ethernet  */        0, /* Slot 13 - openpic */        0, /* Slot 14 - unused */        0, /* Slot 15 - unused */        7, /* Slot 16 - NCR58C825a onboard scsi */        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 */        1, /* Slot 22 - PCI slot 1 PCIINTx# (See below) */};static char ibm43p_pci_IRQ_routes[] = {        0,      /* Line 0 - unused */        15,     /* Line 1 */        15,     /* Line 2 */        15,     /* Line 3 */        15,     /* Line 4 */};/* Motorola PowerPlus architecture PCI IRQ tables *//* Interrupt line values for INTA-D on primary/secondary MPIC inputs */struct powerplus_irq_list{	unsigned char primary[4];       /* INT A-D */	unsigned char secondary[4];     /* INT A-D */};/* * For standard PowerPlus boards, bus 0 PCI INTs A-D are routed to * OpenPIC inputs 9-12.  PCI INTs A-D from the on board P2P bridge * are routed to OpenPIC inputs 5-8.  These values are offset by * 16 in the table to reflect the Linux kernel interrupt value. */struct powerplus_irq_list Powerplus_pci_IRQ_list ={	{25, 26, 27, 28},	{21, 22, 23, 24}};/* * For the MCP750 (system slot board), cPCI INTs A-D are routed to * OpenPIC inputs 8-11 and the PMC INTs A-D are routed to OpenPIC * input 3.  On a hot swap MCP750, the companion card PCI INTs A-D * are routed to OpenPIC inputs 12-15. These values are offset by * 16 in the table to reflect the Linux kernel interrupt value. */struct powerplus_irq_list Mesquite_pci_IRQ_list ={	{24, 25, 26, 27},	{28, 29, 30, 31}};/* * This table represents the standard PCI swizzle defined in the * PCI bus specification. */static unsigned char prep_pci_intpins[4][4] ={	{ 1, 2, 3, 4},  /* Buses 0, 4, 8, ... */	{ 2, 3, 4, 1},  /* Buses 1, 5, 9, ... */	{ 3, 4, 1, 2},  /* Buses 2, 6, 10 ... */	{ 4, 1, 2, 3},  /* Buses 3, 7, 11 ... */};/* 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. *//* * 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#if 0/* * PCI config space access. */#define CFGADDR(dev)	((1<<(dev>>3)) | ((dev&7)<<8))#define DEVNO(dev)	(dev>>3)#define MIN_DEVNR	11#define MAX_DEVNR	22static intprep_read_config(struct pci_bus *bus, unsigned int devfn, int offset,		 int len, u32 *val){	struct pci_controller *hose = bus->sysdata;	volatile void __iomem *cfg_data;	if (bus->number != 0 || DEVNO(devfn) < MIN_DEVNR	    || DEVNO(devfn) > MAX_DEVNR)		return PCIBIOS_DEVICE_NOT_FOUND;	/*	 * Note: the caller has already checked that offset is	 * suitably aligned and that len is 1, 2 or 4.	 */	cfg_data = hose->cfg_data + CFGADDR(devfn) + offset;	switch (len) {	case 1:		*val = in_8(cfg_data);		break;	case 2:		*val = in_le16(cfg_data);		break;	default:		*val = in_le32(cfg_data);		break;	}	return PCIBIOS_SUCCESSFUL;}static intprep_write_config(struct pci_bus *bus, unsigned int devfn, int offset,		  int len, u32 val){	struct pci_controller *hose = bus->sysdata;	volatile void __iomem *cfg_data;	if (bus->number != 0 || DEVNO(devfn) < MIN_DEVNR	    || DEVNO(devfn) > MAX_DEVNR)		return PCIBIOS_DEVICE_NOT_FOUND;	/*	 * Note: the caller has already checked that offset is	 * suitably aligned and that len is 1, 2 or 4.	 */	cfg_data = hose->cfg_data + CFGADDR(devfn) + offset;	switch (len) {	case 1:		out_8(cfg_data, val);		break;	case 2:		out_le16(cfg_data, val);		break;	default:		out_le32(cfg_data, val);		break;	}	return PCIBIOS_SUCCESSFUL;}static struct pci_ops prep_pci_ops ={	prep_read_config,	prep_write_config};#endif#define MOTOROLA_CPUTYPE_REG	0x800#define MOTOROLA_BASETYPE_REG	0x803#define MPIC_RAVEN_ID		0x48010000#define	MPIC_HAWK_ID		0x48030000#define	MOT_PROC2_BIT		0x800static u_char prep_openpic_initsenses[] __initdata = {    (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* MVME2600_INT_SIO */    (IRQ_SENSE_EDGE  | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_FALCN_ECC_ERR */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_ETHERNET */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_SCSI */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_GRAPHICS */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME0 */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME1 */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME2 */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME3 */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTA */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTB */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTC */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTD */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_LM_SIG0 */    (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_LM_SIG1 */};#define MOT_RAVEN_PRESENT	0x1#define MOT_HAWK_PRESENT	0x2int mot_entry = -1;int prep_keybd_present = 1;int MotMPIC;int mot_multi;int __initraven_init(void){	unsigned int	devid;	unsigned int	pci_membase;	unsigned char	base_mod;	/* Check to see if the Raven chip exists. */	if ( _prep_type != _PREP_Motorola) {		OpenPIC_Addr = NULL;		return 0;	}	/* Check to see if this board is a type that might have a Raven. */	if ((inb(MOTOROLA_CPUTYPE_REG) & 0xF0) != 0xE0) {		OpenPIC_Addr = NULL;		return 0;	}	/* Check the first PCI device to see if it is a Raven. */	early_read_config_dword(NULL, 0, 0, PCI_VENDOR_ID, &devid);	switch (devid & 0xffff0000) {	case MPIC_RAVEN_ID:		MotMPIC = MOT_RAVEN_PRESENT;		break;	case MPIC_HAWK_ID:		MotMPIC = MOT_HAWK_PRESENT;		break;	default:		OpenPIC_Addr = NULL;		return 0;	}	/* Read the memory base register. */	early_read_config_dword(NULL, 0, 0, PCI_BASE_ADDRESS_1, &pci_membase);	if (pci_membase == 0) {		OpenPIC_Addr = NULL;		return 0;	}	/* Map the Raven MPIC registers to virtual memory. */	OpenPIC_Addr = ioremap(pci_membase+0xC0000000, 0x22000);	OpenPIC_InitSenses = prep_openpic_initsenses;	OpenPIC_NumInitSenses = sizeof(prep_openpic_initsenses);	ppc_md.get_irq = openpic_get_irq;	/* If raven is present on Motorola store the system config register	 * for later use.	 */	ProcInfo = (unsigned long *)ioremap(0xfef80400, 4);	/* Indicate to system if this is a multiprocessor board */	if (!(*ProcInfo & MOT_PROC2_BIT)) {		mot_multi = 1;	}	/* This is a hack.  If this is a 2300 or 2400 mot board then there is	 * no keyboard controller and we have to indicate that.	 */	base_mod = inb(MOTOROLA_BASETYPE_REG);	if ((MotMPIC == MOT_HAWK_PRESENT) || (base_mod == 0xF9) ||	    (base_mod == 0xFA) || (base_mod == 0xE1))		prep_keybd_present = 0;	return 1;}struct mot_info {	int		cpu_type;	/* 0x100 mask assumes for Raven and Hawk boards that the level/edge are set */					/* 0x200 if this board has a Hawk chip. */	int		base_type;	int		max_cpu;	/* ored with 0x80 if this board should be checked for multi CPU */	const char	*name;	unsigned char	*map;	unsigned char	*routes;	void            (*map_non0_bus)(struct pci_dev *);      /* For boards with more than bus 0 devices. */	struct powerplus_irq_list *pci_irq_list; /* List of PCI MPIC inputs */	unsigned char   secondary_bridge_devfn; /* devfn of secondary bus transparent bridge */} mot_info[] = {	{0x300, 0x00, 0x00, "MVME 2400",			Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x010, 0x00, 0x00, "Genesis",				Genesis_pci_IRQ_map,	Genesis_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},	{0x020, 0x00, 0x00, "Powerstack (Series E)",		Comet_pci_IRQ_map,	Comet_pci_IRQ_routes, NULL, NULL, 0x00},	{0x040, 0x00, 0x00, "Blackhawk (Powerstack)",		Blackhawk_pci_IRQ_map,	Blackhawk_pci_IRQ_routes, NULL, NULL, 0x00},	{0x050, 0x00, 0x00, "Omaha (PowerStack II Pro3000)",	Omaha_pci_IRQ_map,	Omaha_pci_IRQ_routes, NULL, NULL, 0x00},	{0x060, 0x00, 0x00, "Utah (Powerstack II Pro4000)",	Utah_pci_IRQ_map,	Utah_pci_IRQ_routes, NULL, NULL, 0x00},	{0x0A0, 0x00, 0x00, "Powerstack (Series EX)",		Comet2_pci_IRQ_map,	Comet2_pci_IRQ_routes, NULL, NULL, 0x00},	{0x1E0, 0xE0, 0x00, "Mesquite cPCI (MCP750)",		Mesquite_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Mesquite_pci_IRQ_list, 0xFF},	{0x1E0, 0xE1, 0x00, "Sitka cPCI (MCPN750)",		Sitka_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xE2, 0x00, "Mesquite cPCI (MCP750) w/ HAC",	Mesquite_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Mesquite_pci_IRQ_list, 0xC0},	{0x1E0, 0xF6, 0x80, "MTX Plus",				MTXplus_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xA0},	{0x1E0, 0xF6, 0x81, "Dual MTX Plus",			MTXplus_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xA0},	{0x1E0, 0xF7, 0x80, "MTX wo/ Parallel Port",		MTX_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},	{0x1E0, 0xF7, 0x81, "Dual MTX wo/ Parallel Port",	MTX_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},	{0x1E0, 0xF8, 0x80, "MTX w/ Parallel Port",		MTX_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},	{0x1E0, 0xF8, 0x81, "Dual MTX w/ Parallel Port",	MTX_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},	{0x1E0, 0xF9, 0x00, "MVME 2300",			Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFA, 0x00, "MVME 2300SC/2600",			Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFB, 0x00, "MVME 2600 with MVME712M",		Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFC, 0x00, "MVME 2600/2700 with MVME761",	Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFD, 0x80, "MVME 3600 with MVME712M",		Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},	{0x1E0, 0xFD, 0x81, "MVME 4600 with MVME712M",		Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFE, 0x80, "MVME 3600 with MVME761",		Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFE, 0x81, "MVME 4600 with MVME761",		Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x1E0, 0xFF, 0x00, "MVME 1600-001 or 1600-011",	Genesis2_pci_IRQ_map,	Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},	{0x000, 0x00, 0x00, "",					NULL,			NULL, NULL, NULL, 0x00}};void __initibm_prep_init(void){	if (have_residual_data) {		u32 addr, real_addr, len, offset;		PPC_DEVICE *mpic;		PnP_TAG_PACKET *pkt;		/* Use the PReP residual data to determine if an OpenPIC is		 * present.  If so, get the large vendor packet which will		 * tell us the base address and length in memory.		 * If we are successful, ioremap the memory area and set		 * OpenPIC_Addr (this indicates that the OpenPIC was found).		 */		mpic = residual_find_device(-1, NULL, SystemPeripheral,				    ProgrammableInterruptController, MPIC, 0);		if (!mpic)			return;		pkt = PnP_find_large_vendor_packet(res->DevicePnPHeap +				mpic->AllocatedOffset, 9, 0);		if (!pkt)			return;#define p pkt->L4_Pack.L4_Data.L4_PPCPack	 	if (p.PPCData[1] == 32) {			switch (p.PPCData[0]) {				case 1:  offset = PREP_ISA_IO_BASE;  break;				case 2:  offset = PREP_ISA_MEM_BASE; break;				default: return; /* Not I/O or memory?? */			}		}		else			return; /* Not a 32-bit address */		real_addr = ld_le32((unsigned int *) (p.PPCData + 4));		if (real_addr == 0xffffffff)			return;		/* Adjust address to be as seen by CPU */		addr = real_addr + offset;		len = ld_le32((unsigned int *) (p.PPCData + 12));		if (!len)			return;#undef p		OpenPIC_Addr = ioremap(addr, len);		ppc_md.get_irq = openpic_get_irq;		OpenPIC_InitSenses = prep_openpic_initsenses;		OpenPIC_NumInitSenses = sizeof(prep_openpic_initsenses);		printk(KERN_INFO "MPIC at 0x%08x (0x%08x), length 0x%08x "		       "mapped to 0x%p\n", addr, real_addr, len, OpenPIC_Addr);	}}static void __initibm43p_pci_map_non0(struct pci_dev *dev){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -