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

📄 pplus.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * arch/ppc/platforms/pplus.c * * Board and PCI setup routines for MCG PowerPlus * * Author: Randy Vinson <rvinson@mvista.com> * * Derived from original PowerPlus PReP work by * Cort Dougan, Johnnie Peters, Matt Porter, and * Troy Benjegerdes. * * 2001-2004 (c) MontaVista, Software, Inc.  This file is licensed under * the terms of the GNU General Public License version 2.  This program * is licensed "as is" without any warranty of any kind, whether express * or implied. */#include <linux/config.h>#include <linux/kernel.h>#include <linux/interrupt.h>#include <linux/init.h>#include <linux/ioport.h>#include <linux/console.h>#include <linux/pci.h>#include <linux/ide.h>#include <linux/seq_file.h>#include <linux/root_dev.h>#include <asm/system.h>#include <asm/io.h>#include <asm/pgtable.h>#include <asm/dma.h>#include <asm/machdep.h>#include <asm/prep_nvram.h>#include <asm/vga.h>#include <asm/i8259.h>#include <asm/open_pic.h>#include <asm/hawk.h>#include <asm/todc.h>#include <asm/bootinfo.h>#include <asm/kgdb.h>#include <asm/reg.h>#include "pplus.h"#undef DUMP_DBATSTODC_ALLOC();extern void pplus_setup_hose(void);extern void pplus_set_VIA_IDE_native(void);extern unsigned long loops_per_jiffy;unsigned char *Motherboard_map_name;/* Tables for known hardware *//* Motorola Mesquite */static inline intmesquite_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){	static char pci_irq_table[][4] =	    /*	     *      MPIC interrupts for various IDSEL values (MPIC IRQ0 =	     *      Linux IRQ16 (to leave room for ISA IRQs at 0-15).	     *      PCI IDSEL/INTPIN->INTLINE	     *         A   B   C   D	     */	{		{18,  0,  0,  0},	/* IDSEL 14 - Enet 0 */		{ 0,  0,  0,  0},	/* IDSEL 15 - unused */		{19, 19, 19, 19},	/* IDSEL 16 - PMC Slot 1 */		{ 0,  0,  0,  0},	/* IDSEL 17 - unused */		{ 0,  0,  0,  0},	/* IDSEL 18 - unused */		{ 0,  0,  0,  0},	/* IDSEL 19 - unused */		{24, 25, 26, 27},	/* IDSEL 20 - P2P bridge (to cPCI 1) */		{ 0,  0,  0,  0},	/* IDSEL 21 - unused */		{28, 29, 30, 31}	/* IDSEL 22 - P2P bridge (to cPCI 2) */	};	const long min_idsel = 14, max_idsel = 22, irqs_per_slot = 4;	return PCI_IRQ_TABLE_LOOKUP;}/* Motorola Sitka */static inline intsitka_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){	static char pci_irq_table[][4] =	    /*	     *      MPIC interrupts for various IDSEL values (MPIC IRQ0 =	     *      Linux IRQ16 (to leave room for ISA IRQs at 0-15).	     *      PCI IDSEL/INTPIN->INTLINE	     *         A   B   C   D	     */	{		{18,  0,  0,  0},	/* IDSEL 14 - Enet 0 */		{ 0,  0,  0,  0},	/* IDSEL 15 - unused */		{25, 26, 27, 28},	/* IDSEL 16 - PMC Slot 1 */		{28, 25, 26, 27},	/* IDSEL 17 - PMC Slot 2 */		{ 0,  0,  0,  0},	/* IDSEL 18 - unused */		{ 0,  0,  0,  0},	/* IDSEL 19 - unused */		{20,  0,  0,  0}	/* IDSEL 20 - P2P bridge (to cPCI) */	};	const long min_idsel = 14, max_idsel = 20, irqs_per_slot = 4;	return PCI_IRQ_TABLE_LOOKUP;}/* Motorola MTX */static inline intMTX_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){	static char pci_irq_table[][4] =	    /*	     *      MPIC interrupts for various IDSEL values (MPIC IRQ0 =	     *      Linux IRQ16 (to leave room for ISA IRQs at 0-15).	     *      PCI IDSEL/INTPIN->INTLINE	     *         A   B   C   D	     */	{		{19,  0,  0,  0},	/* IDSEL 12 - SCSI   */		{ 0,  0,  0,  0},	/* IDSEL 13 - unused */		{18,  0,  0,  0},	/* IDSEL 14 - Enet   */		{ 0,  0,  0,  0},	/* IDSEL 15 - unused */		{25, 26, 27, 28},	/* IDSEL 16 - PMC Slot 1 */		{26, 27, 28, 25},	/* IDSEL 17 - PMC Slot 2 */		{27, 28, 25, 26}	/* IDSEL 18 - PCI Slot 3 */	};	const long min_idsel = 12, max_idsel = 18, irqs_per_slot = 4;	return PCI_IRQ_TABLE_LOOKUP;}/* Motorola MTX Plus *//* Secondary bus interrupt routing is not supported yet */static inline intMTXplus_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){	static char pci_irq_table[][4] =	    /*	     *      MPIC interrupts for various IDSEL values (MPIC IRQ0 =	     *      Linux IRQ16 (to leave room for ISA IRQs at 0-15).	     *      PCI IDSEL/INTPIN->INTLINE	     *         A   B   C   D	     */	{		{19,  0,  0,  0},	/* IDSEL 12 - SCSI   */		{ 0,  0,  0,  0},	/* IDSEL 13 - unused */		{18,  0,  0,  0},	/* IDSEL 14 - Enet 1 */		{ 0,  0,  0,  0},	/* IDSEL 15 - unused */		{25, 26, 27, 28},	/* IDSEL 16 - PCI Slot 1P */		{26, 27, 28, 25},	/* IDSEL 17 - PCI Slot 2P */		{27, 28, 25, 26},	/* IDSEL 18 - PCI Slot 3P */		{26,  0,  0,  0},	/* IDSEL 19 - Enet 2 */		{ 0,  0,  0,  0}	/* IDSEL 20 - P2P Bridge */	};	const long min_idsel = 12, max_idsel = 20, irqs_per_slot = 4;	return PCI_IRQ_TABLE_LOOKUP;}static inline intGenesis2_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){	/* 2600	 * Raven 31	 * ISA   11	 * SCSI  12 - IRQ3	 * Univ  13	 * eth   14 - IRQ2	 * VGA   15 - IRQ4	 * PMC1  16 - IRQ9,10,11,12 = PMC1 A-D	 * PMC2  17 - IRQ12,9,10,11 = A-D	 * SCSI2 18 - IRQ11	 * eth2  19 - IRQ10	 * PCIX  20 - IRQ9,10,11,12 = PCI A-D	 */	/* 2400	 * Hawk 31	 * ISA  11	 * Univ 13	 * eth  14 - IRQ2	 * PMC1 16 - IRQ9,10,11,12 = PMC A-D	 * PMC2 17 - IRQ12,9,10,11 = PMC A-D	 * PCIX 20 - IRQ9,10,11,12 = PMC A-D	 */	/* 2300	 * Raven 31	 * ISA   11	 * Univ  13	 * eth   14 - IRQ2	 * PMC1  16 - 9,10,11,12 = A-D	 * PMC2  17 - 9,10,11,12 = B,C,D,A	 */	static char pci_irq_table[][4] =	    /*	     *      MPIC interrupts for various IDSEL values (MPIC IRQ0 =	     *      Linux IRQ16 (to leave room for ISA IRQs at 0-15).	     *      PCI IDSEL/INTPIN->INTLINE	     *         A   B   C   D	     */	{		{19,  0,  0,  0},	/* IDSEL 12 - SCSI   */		{ 0,  0,  0,  0},	/* IDSEL 13 - Universe PCI - VME */		{18,  0,  0,  0},	/* IDSEL 14 - Enet 1 */		{ 0,  0,  0,  0},	/* IDSEL 15 - unused */		{25, 26, 27, 28},	/* IDSEL 16 - PCI/PMC Slot 1P */		{28, 25, 26, 27},	/* IDSEL 17 - PCI/PMC Slot 2P */		{27, 28, 25, 26},	/* IDSEL 18 - PCI Slot 3P */		{26,  0,  0,  0},	/* IDSEL 19 - Enet 2 */		{25, 26, 27, 28}	/* IDSEL 20 - P2P Bridge */	};	const long min_idsel = 12, max_idsel = 20, irqs_per_slot = 4;	return PCI_IRQ_TABLE_LOOKUP;}#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 pplus_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 */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),};int mot_entry = -1;int prep_keybd_present = 1;int mot_multi = 0;struct brd_info {	/* 0x100 mask assumes for Raven and Hawk boards that the level/edge	 * are set */	int cpu_type;	/* 0x200 if this board has a Hawk chip. */	int base_type;	/* or'ed with 0x80 if this board should be checked for multi CPU */	int max_cpu;	const char *name;	int (*map_irq) (struct pci_dev *, unsigned char, unsigned char);};struct brd_info mot_info[] = {	{0x300, 0x00, 0x00, "MVME 2400", Genesis2_map_irq},	{0x1E0, 0xE0, 0x00, "Mesquite cPCI (MCP750)", mesquite_map_irq},	{0x1E0, 0xE1, 0x00, "Sitka cPCI (MCPN750)", sitka_map_irq},	{0x1E0, 0xE2, 0x00, "Mesquite cPCI (MCP750) w/ HAC", mesquite_map_irq},	{0x1E0, 0xF6, 0x80, "MTX Plus", MTXplus_map_irq},	{0x1E0, 0xF6, 0x81, "Dual MTX Plus", MTXplus_map_irq},	{0x1E0, 0xF7, 0x80, "MTX wo/ Parallel Port", MTX_map_irq},	{0x1E0, 0xF7, 0x81, "Dual MTX wo/ Parallel Port", MTX_map_irq},	{0x1E0, 0xF8, 0x80, "MTX w/ Parallel Port", MTX_map_irq},	{0x1E0, 0xF8, 0x81, "Dual MTX w/ Parallel Port", MTX_map_irq},	{0x1E0, 0xF9, 0x00, "MVME 2300", Genesis2_map_irq},	{0x1E0, 0xFA, 0x00, "MVME 2300SC/2600", Genesis2_map_irq},	{0x1E0, 0xFB, 0x00, "MVME 2600 with MVME712M", Genesis2_map_irq},	{0x1E0, 0xFC, 0x00, "MVME 2600/2700 with MVME761", Genesis2_map_irq},	{0x1E0, 0xFD, 0x80, "MVME 3600 with MVME712M", Genesis2_map_irq},	{0x1E0, 0xFD, 0x81, "MVME 4600 with MVME712M", Genesis2_map_irq},	{0x1E0, 0xFE, 0x80, "MVME 3600 with MVME761", Genesis2_map_irq},	{0x1E0, 0xFE, 0x81, "MVME 4600 with MVME761", Genesis2_map_irq},	{0x000, 0x00, 0x00, "", NULL}};void __init pplus_set_board_type(void){	unsigned char cpu_type;	unsigned char base_mod;	int entry;	unsigned short devid;	unsigned long *ProcInfo = NULL;	cpu_type = inb(MOTOROLA_CPUTYPE_REG) & 0xF0;	base_mod = inb(MOTOROLA_BASETYPE_REG);	early_read_config_word(0, 0, 0, PCI_VENDOR_ID, &devid);	for (entry = 0; mot_info[entry].cpu_type != 0; entry++) {		/* Check for Hawk chip */		if (mot_info[entry].cpu_type & 0x200) {			if (devid != PCI_DEVICE_ID_MOTOROLA_HAWK)				continue;		} else {			/* store the system config register for later use. */			ProcInfo =			    (unsigned long *)ioremap(PPLUS_SYS_CONFIG_REG, 4);			/* Check non hawk boards */			if ((mot_info[entry].cpu_type & 0xff) != cpu_type)				continue;			if (mot_info[entry].base_type == 0) {				mot_entry = entry;				break;			}			if (mot_info[entry].base_type != base_mod)				continue;		}		if (!(mot_info[entry].max_cpu & 0x80)) {			mot_entry = entry;			break;		}		/* processor 1 not present and max processor zero indicated */		if ((*ProcInfo & MOT_PROC2_BIT)		    && !(mot_info[entry].max_cpu & 0x7f)) {			mot_entry = entry;			break;		}		/* processor 1 present and max processor zero indicated */		if (!(*ProcInfo & MOT_PROC2_BIT)		    && (mot_info[entry].max_cpu & 0x7f)) {			mot_entry = entry;			break;		}		/* Indicate to system if this is a multiprocessor board */		if (!(*ProcInfo & MOT_PROC2_BIT))			mot_multi = 1;	}	if (mot_entry == -1)		/* No particular cpu type found - assume Mesquite (MCP750) */		mot_entry = 1;	Motherboard_map_name = (unsigned char *)mot_info[mot_entry].name;	ppc_md.pci_map_irq = mot_info[mot_entry].map_irq;}void __init pplus_pib_init(void){	unsigned char reg;	unsigned short short_reg;	struct pci_dev *dev = NULL;	/*	 * Perform specific configuration for the Via Tech or	 * or Winbond PCI-ISA-Bridge part.	 */	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,				   PCI_DEVICE_ID_VIA_82C586_1, dev))) {		/*		 * PPCBUG does not set the enable bits		 * for the IDE device. Force them on here.		 */		pci_read_config_byte(dev, 0x40, &reg);		reg |= 0x03;	/* IDE: Chip Enable Bits */		pci_write_config_byte(dev, 0x40, reg);	}	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,				   PCI_DEVICE_ID_VIA_82C586_2,				   dev)) && (dev->devfn = 0x5a)) {		/* Force correct USB interrupt */		dev->irq = 11;		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);	}	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,				   PCI_DEVICE_ID_WINBOND_83C553, dev))) {		/* Clear PCI Interrupt Routing Control Register. */		short_reg = 0x0000;		pci_write_config_word(dev, 0x44, short_reg);		/* Route IDE interrupts to IRQ 14 */		reg = 0xEE;		pci_write_config_byte(dev, 0x43, reg);	}	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,				   PCI_DEVICE_ID_WINBOND_82C105, dev))) {		/*		 * Disable LEGIRQ mode so PCI INTS are routed		 * directly to the 8259 and enable both channels		 */		pci_write_config_dword(dev, 0x40, 0x10ff0033);		/* Force correct IDE interrupt */		dev->irq = 14;		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);	}	pci_dev_put(dev);}void __init pplus_set_VIA_IDE_legacy(void){	unsigned short vend, dev;	early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_VENDOR_ID, &vend);	early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_DEVICE_ID, &dev);	if ((vend == PCI_VENDOR_ID_VIA) &&			(dev == PCI_DEVICE_ID_VIA_82C586_1)) {		unsigned char temp;		/* put back original "standard" port base addresses */		early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),					 PCI_BASE_ADDRESS_0, 0x1f1);		early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),					 PCI_BASE_ADDRESS_1, 0x3f5);		early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),					 PCI_BASE_ADDRESS_2, 0x171);		early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),					 PCI_BASE_ADDRESS_3, 0x375);		early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),					 PCI_BASE_ADDRESS_4, 0xcc01);		/* put into legacy mode */		early_read_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,				       &temp);		temp &= ~0x05;		early_write_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,					temp);	}}void pplus_set_VIA_IDE_native(void){	unsigned short vend, dev;	early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_VENDOR_ID, &vend);	early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_DEVICE_ID, &dev);	if ((vend == PCI_VENDOR_ID_VIA) &&			(dev == PCI_DEVICE_ID_VIA_82C586_1)) {		unsigned char temp;		/* put into native mode */		early_read_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,				       &temp);		temp |= 0x05;		early_write_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,

⌨️ 快捷键说明

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