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

📄 pci_bus_cvlink.c

📁 microwindows移植到S3C44B0的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif	/*	 * Set the root start and end for Mem Resource.	 */	iomem_resource.start = 0;	iomem_resource.end = 0xffffffffffffffff;	/*	 * Initialize the device vertex in the pci_dev struct.	 */	pci_for_each_dev(device_dev) {		unsigned int irq;		int idx;		u16 cmd;		devfs_handle_t vhdl;		unsigned long size;		extern int bit_pos_to_irq(int);		if (device_dev->vendor == PCI_VENDOR_ID_SGI &&				device_dev->device == PCI_DEVICE_ID_SGI_IOC3) {			extern void pci_fixup_ioc3(struct pci_dev *d);			pci_fixup_ioc3(device_dev);		}		/* Set the device vertex */		device_sysdata = kmalloc(sizeof(struct sn_device_sysdata),					GFP_KERNEL);		device_sysdata->vhdl = devfn_to_vertex(device_dev->bus->number, device_dev->devfn);		device_sysdata->isa64 = 0;		/*		 * Set the xbridge Device(X) Write Buffer Flush and Xbow Flush 		 * register addresses.		 */		(void) set_flush_addresses(device_dev, device_sysdata);		device_dev->sysdata = (void *) device_sysdata;		set_sn_pci64(device_dev);		pci_read_config_word(device_dev, PCI_COMMAND, &cmd);		/*		 * Set the resources address correctly.  The assumption here 		 * is that the addresses in the resource structure has been		 * read from the card and it was set in the card by our		 * Infrastructure ..		 */		vhdl = device_sysdata->vhdl;		for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {			size = 0;			size = device_dev->resource[idx].end -				device_dev->resource[idx].start;			if (size) {				device_dev->resource[idx].start = (unsigned long)pciio_pio_addr(vhdl, 0, PCIIO_SPACE_WIN(idx), 0, size, 0, PCIIO_BYTE_STREAM);				device_dev->resource[idx].start |= __IA64_UNCACHED_OFFSET;			}			else				continue;			device_dev->resource[idx].end = 				device_dev->resource[idx].start + size;#ifdef CONFIG_IA64_SGI_SN1			/*			 * Adjust the addresses to go to the SWIZZLE ..			 */			device_dev->resource[idx].start = 				device_dev->resource[idx].start & 0xfffff7ffffffffff;			device_dev->resource[idx].end = 				device_dev->resource[idx].end & 0xfffff7ffffffffff;#endif			if (device_dev->resource[idx].flags & IORESOURCE_IO) {				cmd |= PCI_COMMAND_IO;#ifdef SN_IOPORTS				ioport = sn_allocate_ioports(device_dev->resource[idx].start);				if (ioport < 0) {					printk("sn_pci_fixup: PCI Device 0x%x on PCI Bus %d not mapped to IO PORTs .. IO PORTs exhausted\n", device_dev->devfn, device_dev->bus->number);					continue;				}				pciio_config_set(vhdl, (unsigned) PCI_BASE_ADDRESS_0 + (idx * 4), 4, (res + (ioport & 0xfff)));printk("sn_pci_fixup: ioport number %d mapped to pci address 0x%lx\n", ioport, (res + (ioport & 0xfff)));				device_dev->resource[idx].start = ioport;				device_dev->resource[idx].end = ioport + SN_IOPORTS_UNIT;#endif			}			if (device_dev->resource[idx].flags & IORESOURCE_MEM)				cmd |= PCI_COMMAND_MEMORY;		}		/*		 * Now handle the ROM resource ..		 */		size = device_dev->resource[PCI_ROM_RESOURCE].end -			device_dev->resource[PCI_ROM_RESOURCE].start;		if (size) {			device_dev->resource[PCI_ROM_RESOURCE].start =			(unsigned long) pciio_pio_addr(vhdl, 0, PCIIO_SPACE_ROM, 0, 				size, 0, PCIIO_BYTE_STREAM);			device_dev->resource[PCI_ROM_RESOURCE].start |= __IA64_UNCACHED_OFFSET;			device_dev->resource[PCI_ROM_RESOURCE].end =			device_dev->resource[PCI_ROM_RESOURCE].start + size;#ifdef CONFIG_IA64_SGI_SN1                	/*                 	 * go through synergy swizzled space                 	 */			device_dev->resource[PCI_ROM_RESOURCE].start &= 0xfffff7ffffffffffUL;			device_dev->resource[PCI_ROM_RESOURCE].end   &= 0xfffff7ffffffffffUL;#endif		}		/*		 * Update the Command Word on the Card.		 */		cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */					   /* bit gets dropped .. no harm */		pci_write_config_word(device_dev, PCI_COMMAND, cmd);		pci_read_config_byte(device_dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines);		if (device_dev->vendor == PCI_VENDOR_ID_SGI &&			device_dev->device == PCI_DEVICE_ID_SGI_IOC3 ) {				lines = 1;		} 		device_sysdata = (struct sn_device_sysdata *)device_dev->sysdata;		device_vertex = device_sysdata->vhdl; 		intr_handle = pciio_intr_alloc(device_vertex, NULL, lines, device_vertex);		bit = intr_handle->pi_irq;		cpuid = intr_handle->pi_cpu;#ifdef CONFIG_IA64_SGI_SN1		irq = bit_pos_to_irq(bit);#else /* SN2 */		irq = bit;#endif		irq = irq + (cpuid << 8);		pciio_intr_connect(intr_handle);		device_dev->irq = irq;#ifdef ajmtestintr		{			int slot = PCI_SLOT(device_dev->devfn);			static int timer_set = 0;			pcibr_intr_t	pcibr_intr = (pcibr_intr_t)intr_handle;			pcibr_soft_t	pcibr_soft = pcibr_intr->bi_soft;			extern void intr_test_handle_intr(int, void*, struct pt_regs *);			if (!timer_set) {				intr_test_set_timer();				timer_set = 1;			}			intr_test_register_irq(irq, pcibr_soft, slot);			request_irq(irq, intr_test_handle_intr,0,NULL, NULL);		}#endif	}#if 0{        devfs_handle_t  bridge_vhdl = pci_bus_to_vertex(0);        pcibr_soft_t    pcibr_soft = (pcibr_soft_t) hwgraph_fastinfo_get(bridge_vhdl);        bridge_t        *bridge = pcibr_soft->bs_base;        printk("pci_fixup_ioc3: Before devreg fixup\n");        printk("pci_fixup_ioc3: Devreg 0 0x%x\n", bridge->b_device[0].reg);        printk("pci_fixup_ioc3: Devreg 1 0x%x\n", bridge->b_device[1].reg);        printk("pci_fixup_ioc3: Devreg 2 0x%x\n", bridge->b_device[2].reg);        printk("pci_fixup_ioc3: Devreg 3 0x%x\n", bridge->b_device[3].reg);        printk("pci_fixup_ioc3: Devreg 4 0x%x\n", bridge->b_device[4].reg);        printk("pci_fixup_ioc3: Devreg 5 0x%x\n", bridge->b_device[5].reg);        printk("pci_fixup_ioc3: Devreg 6 0x%x\n", bridge->b_device[6].reg);        printk("pci_fixup_ioc3: Devreg 7 0x%x\n", bridge->b_device[7].reg);}printk("testing Big Window: 0xC0000200c0000000 %p\n", *( (volatile uint64_t *)0xc0000200a0000000));printk("testing Big Window: 0xC0000200c0000008 %p\n", *( (volatile uint64_t *)0xc0000200a0000008));#endif}/* * pci_bus_map_create() - Called by pci_bus_to_hcl_cvlink() to finish the job. * *	Linux PCI Bus numbers are assigned from lowest module_id numbers *	(rack/slot etc.) starting from HUB_WIDGET_ID_MAX down to  *	HUB_WIDGET_ID_MIN: *		widgetnum 15 gets lower Bus Number than widgetnum 14 etc. * *	Given 2 modules 001c01 and 001c02 we get the following mappings: *		001c01, widgetnum 15 = Bus number 0 *		001c01, widgetnum 14 = Bus number 1 *		001c02, widgetnum 15 = Bus number 3 *		001c02, widgetnum 14 = Bus number 4 *		etc. * * The rational for starting Bus Number 0 with Widget number 15 is because  * the system boot disks are always connected via Widget 15 Slot 0 of the  * I-brick.  Linux creates /dev/sd* devices(naming) strating from Bus Number 0  * Therefore, /dev/sda1 will be the first disk, on Widget 15 of the lowest  * module id(Master Cnode) of the system. *	 */static int pci_bus_map_create(devfs_handle_t xtalk){	devfs_handle_t master_node_vertex = NULL;	devfs_handle_t xwidget = NULL;	devfs_handle_t pci_bus = NULL;	hubinfo_t hubinfo = NULL;	xwidgetnum_t widgetnum;	char pathname[128];	graph_error_t rv;	/*	 * Loop throught this vertex and get the Xwidgets ..	 */	for (widgetnum = HUB_WIDGET_ID_MAX; widgetnum >= HUB_WIDGET_ID_MIN; widgetnum--) {#if 0        {                int pos;                char dname[256];                pos = devfs_generate_path(xtalk, dname, 256);                printk("%s : path= %s\n", __FUNCTION__, &dname[pos]);        }#endif		sprintf(pathname, "%d", widgetnum);		xwidget = NULL;				/*		 * Example - /hw/module/001c16/Pbrick/xtalk/8 is the xwidget		 *	     /hw/module/001c16/Pbrick/xtalk/8/pci/1 is device		 */		rv = hwgraph_traverse(xtalk, pathname, &xwidget);		if ( (rv != GRAPH_SUCCESS) ) {			if (!xwidget)				continue;		}		sprintf(pathname, "%d/"EDGE_LBL_PCI, widgetnum);		pci_bus = NULL;		if (hwgraph_traverse(xtalk, pathname, &pci_bus) != GRAPH_SUCCESS)			if (!pci_bus)				continue;		/*		 * Assign the correct bus number and also the nasid of this 		 * pci Xwidget.		 * 		 * Should not be any race here ...		 */		num_bridges++;		busnum_to_pcibr_vhdl[num_bridges - 1] = pci_bus;		/*		 * Get the master node and from there get the NASID.		 */		master_node_vertex = device_master_get(xwidget);		if (!master_node_vertex) {			printk("WARNING: pci_bus_map_create: Unable to get .master for vertex 0x%p\n", (void *)xwidget);		}			hubinfo_get(master_node_vertex, &hubinfo);		if (!hubinfo) {			printk("WARNING: pci_bus_map_create: Unable to get hubinfo for master node vertex 0x%p\n", (void *)master_node_vertex);			return(1);		} else {			busnum_to_nid[num_bridges - 1] = hubinfo->h_nasid;		}		/*		 * Pre assign DMA maps needed for 32 Bits Page Map DMA.		 */		busnum_to_atedmamaps[num_bridges - 1] = (void *) kmalloc(			sizeof(struct sn_dma_maps_s) * MAX_ATE_MAPS, GFP_KERNEL);		if (!busnum_to_atedmamaps[num_bridges - 1])			printk("WARNING: pci_bus_map_create: Unable to precreate ATE DMA Maps for busnum %d vertex 0x%p\n", num_bridges - 1, (void *)xwidget);		memset(busnum_to_atedmamaps[num_bridges - 1], 0x0, 			sizeof(struct sn_dma_maps_s) * MAX_ATE_MAPS);	}        return(0);}/* * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure    *      initialization has completed to set up the mappings between Xbridge *      and logical pci bus numbers.  We also set up the NASID for each of these *      xbridges. * *      Must be called before pci_init() is invoked. */intpci_bus_to_hcl_cvlink(void) {	devfs_handle_t devfs_hdl = NULL;	devfs_handle_t xtalk = NULL;	int rv = 0;	char name[256];	int master_iobrick;	int i;	/*	 * Iterate throught each xtalk links in the system ..	 * /hw/module/001c01/node/xtalk/ 8|9|10|11|12|13|14|15 	 *	 * /hw/module/001c01/node/xtalk/15 -> /hw/module/001c01/Ibrick/xtalk/15	 *	 * What if it is not pci?	 */	devfs_hdl = hwgraph_path_to_vertex("/dev/hw/module");	/*	 * To provide consistent(not persistent) device naming, we need to start 	 * bus number allocation from the C-Brick with the lowest module id e.g. 001c01 	 * with an attached I-Brick.  Find the master_iobrick.	 */	master_iobrick = -1;	for (i = 0; i < nummodules; i++) {		moduleid_t iobrick_id; 		iobrick_id = iobrick_module_get(&modules[i]->elsc);		if (iobrick_id > 0) { /* Valid module id */			if (MODULE_GET_BTYPE(iobrick_id) == MODULE_IBRICK) {				master_iobrick = i;				break;			}		}	}	/*	 * The master_iobrick gets bus 0 and 1.	 */	if (master_iobrick >= 0) {		memset(name, 0, 256);		format_module_id(name, modules[master_iobrick]->id, MODULE_FORMAT_BRIEF);		strcat(name, "/node/xtalk");		xtalk = NULL;		rv = hwgraph_edge_get(devfs_hdl, name, &xtalk);		pci_bus_map_create(xtalk);	}			/*	 * Now go do the rest of the modules, starting from the C-Brick with the lowest 	 * module id, remembering to skip the master_iobrick, which was done above.	 */	for (i = 0; i < nummodules; i++) {		if (i == master_iobrick) {			continue; /* Did the master_iobrick already. */		}		memset(name, 0, 256);		format_module_id(name, modules[i]->id, MODULE_FORMAT_BRIEF);		strcat(name, "/node/xtalk");		xtalk = NULL;		rv = hwgraph_edge_get(devfs_hdl, name, &xtalk);		pci_bus_map_create(xtalk);	}	return(0);}

⌨️ 快捷键说明

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