Esempio n. 1
0
/**
 * pci_enable_rom - enable ROM decoding for a PCI device
 * @pdev: PCI device to enable
 *
 * Enable ROM decoding on @dev.  This involves simply turning on the last
 * bit of the PCI ROM BAR.  Note that some cards may share address decoders
 * between the ROM and other resources, so enabling it may disable access
 * to MMIO registers or other card memory.
 */
static int pci_enable_rom(struct pci_dev *pdev)
{
	struct resource *res = pdev->resource + PCI_ROM_RESOURCE;
	struct pci_bus_region region;
	u32 rom_addr;

	if (!res->flags)
		return -1;

	pcibios_resource_to_bus(pdev, &region, res);
	pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
	rom_addr &= ~PCI_ROM_ADDRESS_MASK;
	rom_addr |= region.start | PCI_ROM_ADDRESS_ENABLE;
	pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
	return 0;
}
static void gapspci_fixup_resources(struct pci_dev *dev)
{
	struct pci_channel *p = dev->sysdata;
	struct resource res;
	struct pci_bus_region region;

	printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));

	switch (dev->device) {
	case PCI_DEVICE_ID_SEGA_BBA:
		/*
		 * We also assume that dev->devfn == 0
		 */
		dev->resource[1].start	= p->resources[0].start  + 0x100;
		dev->resource[1].end	= dev->resource[1].start + 0x200 - 1;

		/*
		 * This is not a normal BAR, prevent any attempts to move
		 * the BAR, as this will result in a bus lock.
		 */
		dev->resource[1].flags |= IORESOURCE_PCI_FIXED;

		/*
		 * Redirect dma memory allocations to special memory window.
		 *
		 * If this GAPSPCI region were mapped by a BAR, the CPU
		 * phys_addr_t would be pci_resource_start(), and the bus
		 * address would be pci_bus_address(pci_resource_start()).
		 * But apparently there's no BAR mapping it, so we just
		 * "know" its CPU address is GAPSPCI_DMA_BASE.
		 */
		res.start = GAPSPCI_DMA_BASE;
		res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
		res.flags = IORESOURCE_MEM;
		pcibios_resource_to_bus(dev->bus, &region, &res);
		BUG_ON(dma_declare_coherent_memory(&dev->dev,
						res.start,
						region.start,
						resource_size(&res)));
		break;
	default:
		printk("PCI: Failed resource fixup\n");
	}
}