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

📄 pci_v3.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	*val = v;	return PCIBIOS_SUCCESSFUL;}static int v3_write_config(struct pci_bus *bus, unsigned int devfn, int where,			   int size, u32 val){	unsigned long addr;	unsigned long flags;	spin_lock_irqsave(&v3_lock, flags);	addr = v3_open_config_window(bus, devfn, where);	switch (size) {	case 1:		__raw_writeb((u8)val, addr);		__raw_readb(addr);		break;	case 2:		__raw_writew((u16)val, addr);		__raw_readw(addr);		break;	case 4:		__raw_writel(val, addr);		__raw_readl(addr);		break;	}	v3_close_config_window();	spin_unlock_irqrestore(&v3_lock, flags);	return PCIBIOS_SUCCESSFUL;}static struct pci_ops pci_v3_ops = {	.read	= v3_read_config,	.write	= v3_write_config,};static struct resource non_mem = {	.name	= "PCI non-prefetchable",	.start	= PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START,	.end	= PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START + PCI_BUS_NONMEM_SIZE - 1,	.flags	= IORESOURCE_MEM,};static struct resource pre_mem = {	.name	= "PCI prefetchable",	.start	= PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START,	.end	= PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START + PCI_BUS_PREMEM_SIZE - 1,	.flags	= IORESOURCE_MEM | IORESOURCE_PREFETCH,};static int __init pci_v3_setup_resources(struct resource **resource){	if (request_resource(&iomem_resource, &non_mem)) {		printk(KERN_ERR "PCI: unable to allocate non-prefetchable "		       "memory region\n");		return -EBUSY;	}	if (request_resource(&iomem_resource, &pre_mem)) {		release_resource(&non_mem);		printk(KERN_ERR "PCI: unable to allocate prefetchable "		       "memory region\n");		return -EBUSY;	}	/*	 * bus->resource[0] is the IO resource for this bus	 * bus->resource[1] is the mem resource for this bus	 * bus->resource[2] is the prefetch mem resource for this bus	 */	resource[0] = &ioport_resource;	resource[1] = &non_mem;	resource[2] = &pre_mem;	return 1;}/* * These don't seem to be implemented on the Integrator I have, which * means I can't get additional information on the reason for the pm2fb * problems.  I suppose I'll just have to mind-meld with the machine. ;) */#define SC_PCI     (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_PCIENABLE_OFFSET)#define SC_LBFADDR (IO_ADDRESS(INTEGRATOR_SC_BASE) + 0x20)#define SC_LBFCODE (IO_ADDRESS(INTEGRATOR_SC_BASE) + 0x24)static intv3_pci_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs){	unsigned long pc = instruction_pointer(regs);	unsigned long instr = *(unsigned long *)pc;#if 0	char buf[128];	sprintf(buf, "V3 fault: addr 0x%08lx, FSR 0x%03x, PC 0x%08lx [%08lx] LBFADDR=%08x LBFCODE=%02x ISTAT=%02x\n",		addr, fsr, pc, instr, __raw_readl(SC_LBFADDR), __raw_readl(SC_LBFCODE) & 255,		v3_readb(V3_LB_ISTAT));	printk(KERN_DEBUG "%s", buf);	printascii(buf);#endif	v3_writeb(V3_LB_ISTAT, 0);	__raw_writel(3, SC_PCI);	/*	 * If the instruction being executed was a read,	 * make it look like it read all-ones.	 */	if ((instr & 0x0c100000) == 0x04100000) {		int reg = (instr >> 12) & 15;		unsigned long val;		if (instr & 0x00400000)			val = 255;		else			val = -1;		regs->uregs[reg] = val;		regs->ARM_pc += 4;		return 0;	}	if ((instr & 0x0e100090) == 0x00100090) {		int reg = (instr >> 12) & 15;		regs->uregs[reg] = -1;		regs->ARM_pc += 4;		return 0;	}	return 1;}static irqreturn_t v3_irq(int irq, void *devid){#ifdef CONFIG_DEBUG_LL	struct pt_regs *regs = get_irq_regs();	unsigned long pc = instruction_pointer(regs);	unsigned long instr = *(unsigned long *)pc;	char buf[128];	sprintf(buf, "V3 int %d: pc=0x%08lx [%08lx] LBFADDR=%08x LBFCODE=%02x ISTAT=%02x\n", irq,		pc, instr, __raw_readl(SC_LBFADDR), __raw_readl(SC_LBFCODE) & 255,		v3_readb(V3_LB_ISTAT));	printascii(buf);#endif	v3_writew(V3_PCI_STAT, 0xf000);	v3_writeb(V3_LB_ISTAT, 0);	__raw_writel(3, SC_PCI);#ifdef CONFIG_DEBUG_LL	/*	 * If the instruction being executed was a read,	 * make it look like it read all-ones.	 */	if ((instr & 0x0c100000) == 0x04100000) {		int reg = (instr >> 16) & 15;		sprintf(buf, "   reg%d = %08lx\n", reg, regs->uregs[reg]);		printascii(buf);	}#endif	return IRQ_HANDLED;}int __init pci_v3_setup(int nr, struct pci_sys_data *sys){	int ret = 0;	if (nr == 0) {		sys->mem_offset = PHYS_PCI_MEM_BASE;		ret = pci_v3_setup_resources(sys->resource);	}	return ret;}struct pci_bus *pci_v3_scan_bus(int nr, struct pci_sys_data *sys){	return pci_scan_bus(sys->busnr, &pci_v3_ops, sys);}/* * V3_LB_BASE? - local bus address * V3_LB_MAP?  - pci bus address */void __init pci_v3_preinit(void){	unsigned long flags;	unsigned int temp;	int ret;	/*	 * Hook in our fault handler for PCI errors	 */	hook_fault_code(4, v3_pci_fault, SIGBUS, "external abort on linefetch");	hook_fault_code(6, v3_pci_fault, SIGBUS, "external abort on linefetch");	hook_fault_code(8, v3_pci_fault, SIGBUS, "external abort on non-linefetch");	hook_fault_code(10, v3_pci_fault, SIGBUS, "external abort on non-linefetch");	spin_lock_irqsave(&v3_lock, flags);	/*	 * Unlock V3 registers, but only if they were previously locked.	 */	if (v3_readw(V3_SYSTEM) & V3_SYSTEM_M_LOCK)		v3_writew(V3_SYSTEM, 0xa05f);	/*	 * Setup window 0 - PCI non-prefetchable memory	 *  Local: 0x40000000 Bus: 0x00000000 Size: 256MB	 */	v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |			V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE);	v3_writew(V3_LB_MAP0, v3_addr_to_lb_map(PCI_BUS_NONMEM_START) |			V3_LB_MAP_TYPE_MEM);	/*	 * Setup window 1 - PCI prefetchable memory	 *  Local: 0x50000000 Bus: 0x10000000 Size: 256MB	 */	v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE + SZ_256M) |			V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |			V3_LB_BASE_ENABLE);	v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |			V3_LB_MAP_TYPE_MEM_MULTIPLE);	/*	 * Setup window 2 - PCI IO	 */	v3_writel(V3_LB_BASE2, v3_addr_to_lb_base2(PHYS_PCI_IO_BASE) |			V3_LB_BASE_ENABLE);	v3_writew(V3_LB_MAP2, v3_addr_to_lb_map2(0));	/*	 * Disable PCI to host IO cycles	 */	temp = v3_readw(V3_PCI_CFG) & ~V3_PCI_CFG_M_I2O_EN;	temp |= V3_PCI_CFG_M_IO_REG_DIS | V3_PCI_CFG_M_IO_DIS;	v3_writew(V3_PCI_CFG, temp);	printk(KERN_DEBUG "FIFO_CFG: %04x  FIFO_PRIO: %04x\n",		v3_readw(V3_FIFO_CFG), v3_readw(V3_FIFO_PRIORITY));	/*	 * Set the V3 FIFO such that writes have higher priority than	 * reads, and local bus write causes local bus read fifo flush.	 * Same for PCI.	 */	v3_writew(V3_FIFO_PRIORITY, 0x0a0a);	/*	 * Re-lock the system register.	 */	temp = v3_readw(V3_SYSTEM) | V3_SYSTEM_M_LOCK;	v3_writew(V3_SYSTEM, temp);	/*	 * Clear any error conditions, and enable write errors.	 */	v3_writeb(V3_LB_ISTAT, 0);	v3_writew(V3_LB_CFG, v3_readw(V3_LB_CFG) | (1 << 10));	v3_writeb(V3_LB_IMASK, 0x28);	__raw_writel(3, SC_PCI);	/*	 * Grab the PCI error interrupt.	 */	ret = request_irq(IRQ_AP_V3INT, v3_irq, 0, "V3", NULL);	if (ret)		printk(KERN_ERR "PCI: unable to grab PCI error "		       "interrupt: %d\n", ret);	spin_unlock_irqrestore(&v3_lock, flags);}void __init pci_v3_postinit(void){	unsigned int pci_cmd;	pci_cmd = PCI_COMMAND_MEMORY |		  PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE;	v3_writew(V3_PCI_CMD, pci_cmd);	v3_writeb(V3_LB_ISTAT, ~0x40);	v3_writeb(V3_LB_IMASK, 0x68);#if 0	ret = request_irq(IRQ_AP_LBUSTIMEOUT, lb_timeout, 0, "bus timeout", NULL);	if (ret)		printk(KERN_ERR "PCI: unable to grab local bus timeout "		       "interrupt: %d\n", ret);#endif	register_isa_ports(PHYS_PCI_MEM_BASE, PHYS_PCI_IO_BASE, 0);}

⌨️ 快捷键说明

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