示例#1
0
int __init
init_nm256(void)
{
    struct pci_dev *pcidev = NULL;
    int count = 0;

    if(! pci_present())
	return -ENODEV;

    while((pcidev = pci_find_device(PCI_VENDOR_ID_NEOMAGIC,
				    PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO,
				    pcidev)) != NULL) {
	count += nm256_install(pcidev, REV_NM256AV, "256AV");
    }

    while((pcidev = pci_find_device(PCI_VENDOR_ID_NEOMAGIC,
				    PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO,
				    pcidev)) != NULL) {
	count += nm256_install(pcidev, REV_NM256ZX, "256ZX");
    }

    if (count == 0)
	return -ENODEV;

    printk (KERN_INFO "Done installing NM256 audio driver.\n");
    return 0;
}
示例#2
0
/* Locate SiS bridge and correct base address for SIS5595 */
int sis5595_find_sis(int *address)
{
	u16 val;
	int *i;

	if (!pci_present())
		return -ENODEV;

	if (!(s_bridge =
	      pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503,
			     NULL)))
		return -ENODEV;

	/* Look for imposters */
	for(i = blacklist; *i != 0; i++) {
		if (pci_find_device(PCI_VENDOR_ID_SI, *i, NULL)) {
			printk("sis5595.o: Error: Looked for SIS5595 but found unsupported device %.4X\n", *i);
			return -ENODEV;
		}
	}

	if (PCIBIOS_SUCCESSFUL !=
	    pci_read_config_word(s_bridge, SIS5595_BASE_REG, &val))
		return -ENODEV;

	*address = val & ~(SIS5595_EXTENT - 1);
	if (*address == 0 && force_addr == 0) {
		printk("sis5595.o: base address not set - upgrade BIOS or use force_addr=0xaddr\n");
		return -ENODEV;
	}
	if (force_addr)
		*address = force_addr;	/* so detect will get called */

	return 0;
}
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_find_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_find_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_find_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_find_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);
	}
}
示例#4
0
文件: pcibios.c 项目: anchowee/linino
void __init
pcibios_fixup_bus(struct pci_bus *b)
{
	struct list_head *ln;
	struct pci_dev *d;
	struct resource *res;
	int pos, size;
	u32 *base;
	u8 irq;

	printk("PCI: Fixing up bus %d\n", b->number);

	/* Fix up SB */
	if (b->number == 0) {
		for (ln = b->devices.next; ln != &b->devices; ln = ln->next) {
			d = pci_dev_b(ln);
			/* Fix up interrupt lines */
			pci_read_config_byte(d, PCI_INTERRUPT_LINE, &irq);
			d->irq = irq + 2;
			pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
		}
	}

	/* Fix up external PCI */
	else {
		for (ln = b->devices.next; ln != &b->devices; ln = ln->next) {
			d = pci_dev_b(ln);
			/* Fix up resource bases */
			for (pos = 0; pos < 6; pos++) {
				res = &d->resource[pos];
				base = (res->flags & IORESOURCE_IO) ? &pci_iobase : ((b->number == 2) ? &pcmcia_membase : &pci_membase);
				if (res->end) {
					size = res->end - res->start + 1;
					if (*base & (size - 1))
						*base = (*base + size) & ~(size - 1);
					res->start = *base;
					res->end = res->start + size - 1;
					*base += size;
					pci_write_config_dword(d,
						PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
				}
				/* Fix up PCI bridge BAR0 only */
				if (b->number == 1 && PCI_SLOT(d->devfn) == 0)
					break;
			}
			/* Fix up interrupt lines */
			if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
				d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
			pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
		}
	}
}
示例#5
0
static void bcm947xx_fixup(struct pci_dev *d)
{
	struct pci_bus *b;
	struct list_head *ln;
	struct resource *res;
	int pos, size;
	u32 *base;

	b = d->bus;

	/* Fix up external PCI */
	if (b->number != 0) {
		for (ln = b->devices.next; ln != &b->devices;
		     ln = ln->next) {
			d = pci_dev_b(ln);
			/* Fix up resource bases */
			for (pos = 0; pos < 4; pos++) {
				res = &d->resource[pos];
				base =
				    (res->
				     flags & IORESOURCE_IO) ? &pci_iobase :
				    &pci_membase;
				if (res->end) {
					size = res->end - res->start + 1;
					if (*base & (size - 1))
						*base =
						    (*base +
						     size) & ~(size - 1);
					res->start = *base;
					res->end = res->start + size - 1;
					*base += size;
					pci_write_config_dword(d,
							       PCI_BASE_ADDRESS_0
							       +
							       (pos << 2),
							       res->start);
				}
				/* Fix up PCI bridge BAR0 only */
				if (b->number == 1
				    && PCI_SLOT(d->devfn) == 0)
					break;
			}
			/* Fix up interrupt lines */
			if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
				d->irq =
				    (pci_find_device
				     (VENDOR_BROADCOM, SB_PCI, NULL))->irq;
			pci_write_config_byte(d, PCI_INTERRUPT_LINE,
					      d->irq);
		}
	}
}
示例#6
0
static void __init prpmc750_pcibios_fixup(void)
{
	struct pci_dev *dev;
	unsigned short wtmp;

	/*
	 * Kludge to clean up after PPC6BUG which doesn't
	 * configure the CL5446 VGA card.  Also the
	 * resource subsystem doesn't fixup the
	 * PCI mem resources on the CL5446.
	 */
	if ((dev = pci_find_device(PCI_VENDOR_ID_CIRRUS,
				   PCI_DEVICE_ID_CIRRUS_5446, 0))) {
		dev->resource[0].start += PRPMC750_PCI_PHY_MEM_OFFSET;
		dev->resource[0].end += PRPMC750_PCI_PHY_MEM_OFFSET;
		pci_read_config_word(dev, PCI_COMMAND, &wtmp);
		pci_write_config_word(dev, PCI_COMMAND, wtmp | 3);
		/* Enable Color mode in MISC reg */
		outb(0x03, 0x3c2);
		/* Select DRAM config reg */
		outb(0x0f, 0x3c4);
		/* Set proper DRAM config */
		outb(0xdf, 0x3c5);
	}
}
示例#7
0
int get_pci_addr(unsigned int vendor, unsigned int device, unsigned int addr_mat[])
{
struct pci_dev *pdev=NULL;
unsigned int base_pci, base_status, base_adc, base_dio, base_dac;

  pdev=pci_find_device(vendor,device,pdev);
  if(pdev) {
    pci_read_config_dword(pdev,PCI_BASE_ADDRESS_0, &base_pci);
    pci_read_config_dword(pdev,PCI_BASE_ADDRESS_1, &base_status);
    pci_read_config_dword(pdev,PCI_BASE_ADDRESS_2, &base_adc);
    pci_read_config_dword(pdev,PCI_BASE_ADDRESS_3, &base_dio);
    pci_read_config_dword(pdev,PCI_BASE_ADDRESS_4, &base_dac);
                                           
    base_pci    &= PCI_BASE_ADDRESS_IO_MASK;
    base_status &= PCI_BASE_ADDRESS_IO_MASK;
    base_adc    &= PCI_BASE_ADDRESS_IO_MASK;
    base_dio    &= PCI_BASE_ADDRESS_IO_MASK;
    base_dac    &= PCI_BASE_ADDRESS_IO_MASK;

    addr_mat[0]=base_pci;
    addr_mat[1]=base_status;
    addr_mat[2]=base_adc;
    addr_mat[3]=base_dio;
    addr_mat[4]=base_dac;
  }
  return 0;
}
示例#8
0
文件: smm.c 项目: 3a9LL/panda
// This code is hardcoded for PIIX4 Power Management device.
static void piix4_apmc_smm_init(struct pci_device *pci, void *arg)
{
    struct pci_device *i440_pci = pci_find_device(PCI_VENDOR_ID_INTEL
                                                  , PCI_DEVICE_ID_INTEL_82441);
    if (!i440_pci)
        return;

    /* check if SMM init is already done */
    u32 value = pci_config_readl(pci->bdf, PIIX_DEVACTB);
    if (value & PIIX_APMC_EN)
        return;

    /* enable the SMM memory window */
    pci_config_writeb(i440_pci->bdf, I440FX_SMRAM, 0x02 | 0x48);

    smm_save_and_copy();

    /* enable SMI generation when writing to the APMC register */
    pci_config_writel(pci->bdf, PIIX_DEVACTB, value | PIIX_APMC_EN);

    smm_relocate_and_restore();

    /* close the SMM memory window and enable normal SMM */
    pci_config_writeb(i440_pci->bdf, I440FX_SMRAM, 0x02 | 0x08);
}
示例#9
0
int ide_preinit (void)
{
	int status;
	pci_dev_t devbusfn;
	int l;

	status = 1;
	for (l = 0; l < CFG_IDE_MAXBUS; l++) {
		ide_bus_offset[l] = -ATA_STATUS;
	}
	devbusfn = pci_find_device (0x1103, 0x0004, 0);
	if (devbusfn != -1) {
		status = 0;

		pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0,
				       (u32 *) & ide_bus_offset[0]);
		ide_bus_offset[0] &= 0xfffffffe;
		ide_bus_offset[0] += CFG_PCI0_IO_SPACE;
		pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_2,
				       (u32 *) & ide_bus_offset[1]);
		ide_bus_offset[1] &= 0xfffffffe;
		ide_bus_offset[1] += CFG_PCI0_IO_SPACE;
	}
	return (status);
}
示例#10
0
/* a helper function to get a PCIDevice for a given mmconfig address */
static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s,
                                                     uint32_t mmcfg_addr)
{
    return pci_find_device(s, PCIE_MMCFG_BUS(mmcfg_addr),
                           PCI_SLOT(PCIE_MMCFG_DEVFN(mmcfg_addr)),
                           PCI_FUNC(PCIE_MMCFG_DEVFN(mmcfg_addr)));
}
示例#11
0
static void
ehci_pci_ati_quirk(device_t self, uint8_t is_sb700)
{
	device_t smbdev;
	uint32_t val;

	if (is_sb700) {
		/* Lookup SMBUS PCI device */
		smbdev = pci_find_device(PCI_EHCI_VENDORID_ATI, 0x4385);
		if (smbdev == NULL)
			return;
		val = pci_get_revid(smbdev);
		if (val != 0x3a && val != 0x3b)
			return;
	}

	/*
	 * Note: this bit is described as reserved in SB700
	 * Register Reference Guide.
	 */
	val = pci_read_config(self, 0x53, 1);
	if (!(val & 0x8)) {
		val |= 0x8;
		pci_write_config(self, 0x53, val, 1);
		device_printf(self, "AMD SB600/700 quirk applied\n");
	}
}
示例#12
0
文件: scx200.c 项目: sarnobat/knoppix
int __init scx200_init(void)
{
	struct pci_dev *bridge;
	int bank;
	unsigned base;

	printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");

	if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, 
				      PCI_DEVICE_ID_NS_SCx200_BRIDGE,
				      NULL)) == NULL)
		return -ENODEV;

	base = pci_resource_start(bridge, 0);
	printk(KERN_INFO NAME ": GPIO base 0x%x\n", base);

	if (request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO") == 0) {
		printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n");
		return -EBUSY;
	}

	scx200_gpio_base = base;

	/* read the current values driven on the GPIO signals */
	for (bank = 0; bank < 2; ++bank)
		scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);

	return 0;
}
示例#13
0
void spi_init_address( void )
{
	pcidev_t lpc_isa_dev;
	int status;

	/* Find the spi controller base address */
	status = pci_find_device(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SB700_LPC, &lpc_isa_dev);
	if (!status)
		status = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_ATI_SB900_LPC, &lpc_isa_dev);
	if (!status) {
		printf("ERROR: Unable to find LPC bridge. Halting!\n");
		halt();
	}
	spi_base = pci_read_config32( lpc_isa_dev, SPI_CNTRL_BASE_ADDR_REG );
	spi_base &= 0xFFFFFFE0;
}
示例#14
0
int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
                      DriveInfo *dinfo, int type)
{
    int dom, pci_bus;
    unsigned slot;
    PCIDevice *dev;
    const char *pci_addr = qdict_get_str(qdict, "pci_addr");

    switch (type) {
    case IF_SCSI:
        if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
            goto err;
        }
        dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
                              PCI_DEVFN(slot, 0));
        if (!dev) {
            monitor_printf(mon, "no pci device with address %s\n", pci_addr);
            goto err;
        }
        if (scsi_hot_add(mon, &dev->qdev, dinfo, 1) != 0) {
            goto err;
        }
        break;
    default:
        monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
        goto err;
    }

    return 0;
err:
    return -1;
}
示例#15
0
/* called by config.c */
int __devinit
setup_enternow_pci(struct IsdnCard *card)
{
	int ret;
	struct IsdnCardState *cs = card->cs;
	char tmp[64];

#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif

        strcpy(tmp, enternow_pci_rev);
	printk(KERN_INFO "HiSax: Formula-n Europe AG enter:now ISDN PCI driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ != ISDN_CTYPE_ENTERNOW)
		return(0);
	test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);

	for ( ;; )
	{
		if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
			PCI_DEVICE_ID_TIGERJET_300,  dev_netjet))) {
			ret = en_pci_probe(dev_netjet, cs);
			if (!ret)
				return(0);
		} else {
                        printk(KERN_WARNING "enter:now PCI: No PCI card found\n");
			return(0);
		}

		en_cs_init(card, cs);
		break;
	}

        return en_cs_init_rest(card, cs);
}
示例#16
0
static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
{
    PCIBus *root = pci_find_primary_bus();
    PCIDevice *d;
    int bus;
    unsigned slot;
    Error *local_err = NULL;

    if (!root) {
        monitor_printf(mon, "no primary PCI bus (if there are multiple"
                       " PCI roots, you must use device_del instead)");
        return -1;
    }

    if (pci_read_devaddr(mon, pci_addr, &bus, &slot)) {
        return -1;
    }

    d = pci_find_device(root, bus, PCI_DEVFN(slot, 0));
    if (!d) {
        monitor_printf(mon, "slot %d empty\n", slot);
        return -1;
    }

    qdev_unplug(&d->qdev, &local_err);
    if (error_is_set(&local_err)) {
        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
        error_free(local_err);
        return -1;
    }

    return 0;
}
示例#17
0
/**
 * Determine if the device really is AGP or not.
 *
 * In addition to the usual tests performed by \c drm_device_is_agp, this
 * function detects PCI G450 cards that appear to the system exactly like
 * AGP G450 cards.
 *
 * \param dev   The device to be tested.
 *
 * \returns
 * If the device is a PCI G450, zero is returned.  Otherwise non-zero is
 * returned.
 *
 * \bug
 * This function needs to be filled in!  The implementation in
 * linux-core/mga_drv.c shows what needs to be done.
 */
static int mga_driver_device_is_agp(struct drm_device * dev)
{
	/* There are PCI versions of the G450.  These cards have the
	 * same PCI ID as the AGP G450, but have an additional PCI-to-PCI
	 * bridge chip.  We detect these cards, which are not currently
	 * supported by this driver, by looking at the device ID of the
	 * bus the "card" is on.  If vendor is 0x3388 (Hint Corp) and the
	 * device is 0x0021 (HB6 Universal PCI-PCI bridge), we reject the
	 * device.
	 */
#if defined(__FreeBSD__)
	device_t bus;

#if __FreeBSD_version >= 700010
	bus = device_get_parent(device_get_parent(dev->device));
#else
	bus = device_get_parent(dev->device);
#endif
	if (pci_get_device(dev->device) == 0x0525 &&
	    pci_get_vendor(bus) == 0x3388 &&
	    pci_get_device(bus) == 0x0021)
#else
	struct pci_attach_args pa;

	if (PCI_PRODUCT(dev->pa.pa_id) == PCI_PRODUCT_MATROX_G400_AGP &&
	    pci_find_device(&pa, mgadev_match))
#endif
		return DRM_IS_NOT_AGP;
	else
		return DRM_MIGHT_BE_AGP;
}
示例#18
0
int zuma_mbox_init(void)
{
  unsigned int iobase;
  memset(&zuma_mbox_dev, 0, sizeof(struct _zuma_mbox_dev));

  zuma_mbox_dev.dev = pci_find_device(VENDOR_ID_ZUMA, DEVICE_ID_ZUMA_PBB, 0);

  if(zuma_mbox_dev.dev == -1) {
    printf("no zuma pbb\n");
    return -1;
  }

  pci_read_config_dword(zuma_mbox_dev.dev, PCI_BASE_ADDRESS_0, &iobase);

  zuma_mbox_dev.sip = (PBB_DMA_REG_MAP *) (iobase & PCI_BASE_ADDRESS_MEM_MASK);

  zuma_mbox_dev.sip->int_mask.word=0;

  printf("pbb @ %p v%d.%d, timestamp %08x\n", zuma_mbox_dev.sip,
	 zuma_mbox_dev.sip->version.pci_bits.rev_major,
	 zuma_mbox_dev.sip->version.pci_bits.rev_minor,
	 zuma_mbox_dev.sip->timestamp);

  if (zuma_mbox_do_all_mailbox() == -1) {
	  printf("mailbox failed.. no ACC?\n");
	  return -1;
  }

  zuma_mbox_dump();

  zuma_mbox_setenv();

  return 0;
}
示例#19
0
static void __devinit init_setup_pdc20270(struct pci_dev *dev, ide_pci_device_t *d)
{
	struct pci_dev *findev = NULL;

	if ((dev->bus->self &&
	     dev->bus->self->vendor == PCI_VENDOR_ID_DEC) &&
	    (dev->bus->self->device == PCI_DEVICE_ID_DEC_21150)) {
		if (PCI_SLOT(dev->devfn) & 2) {
			return;
		}
		d->extra = 0;
		while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) {
			if ((findev->vendor == dev->vendor) &&
			    (findev->device == dev->device) &&
			    (PCI_SLOT(findev->devfn) & 2)) {
				if (findev->irq != dev->irq) {
					findev->irq = dev->irq;
				}
				ide_setup_pci_devices(dev, findev, d);
				return;
			}
		}
	}
	ide_setup_pci_device(dev, d);
}
示例#20
0
int __devinit
setup_bkm_a4t(struct IsdnCard *card)
{
	struct IsdnCardState *cs = card->cs;
	char tmp[64];
	u_int pci_memaddr = 0, found = 0;
	int ret;

	strcpy(tmp, bkm_a4t_revision);
	printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
	if (cs->typ == ISDN_CTYPE_BKM_A4T) {
		cs->subtyp = BKM_A4T;
	} else
		return (0);

	while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN,
		PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) {
		ret = a4t_pci_probe(dev_a4t, cs, &found, &pci_memaddr);
		if (!ret)
			return (0);
		if (ret > 0)
			break;
	}
	if (!found) {
		printk(KERN_WARNING "HiSax: Telekom A4T: Card not found\n");
		return (0);
	}
	if (!pci_memaddr) {
		printk(KERN_WARNING "HiSax: Telekom A4T: "
		       "No Memory base address\n");
		return (0);
	}

	return a4t_cs_init(card, cs, pci_memaddr);
}
示例#21
0
void zuma_init_pbb (void)
{
	unsigned int iobase;
	pci_dev_t dev =
			pci_find_device (VENDOR_ID_ZUMA, DEVICE_ID_ZUMA_PBB, 0);

	if (dev == -1) {
		printf ("no zuma pbb\n");
		return;
	}

	pci_read_config_dword (dev, PCI_BASE_ADDRESS_0, &iobase);

	zuma_pbb_reg =
			(PBB_DMA_REG_MAP *) (iobase & PCI_BASE_ADDRESS_MEM_MASK);

	if (!zuma_pbb_reg) {
		printf ("zuma pbb bar none! (hah hah, get it?)\n");
		return;
	}

	zuma_pbb_reg->int_mask.word = 0;

	printf ("pbb @ %p v%d.%d, timestamp %08x\n", zuma_pbb_reg,
			zuma_pbb_reg->version.pci_bits.rev_major,
			zuma_pbb_reg->version.pci_bits.rev_minor,
			zuma_pbb_reg->timestamp);

}
示例#22
0
static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
{
    PCIDevice *d;
    int dom, bus;
    unsigned slot;
    Error *local_err = NULL;

    if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
        return -1;
    }

    d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0));
    if (!d) {
        monitor_printf(mon, "slot %d empty\n", slot);
        return -1;
    }

    qdev_unplug(&d->qdev, &local_err);
    if (error_is_set(&local_err)) {
        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
        error_free(local_err);
        return -1;
    }

    return 0;
}
void __init
pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
	       int (*map_irq)(struct pci_dev *, u8, u8))
{
	struct pci_dev *dev = NULL;
	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
		pdev_fixup_irq(dev, swizzle, map_irq);
	}
}
示例#24
0
static void
search_cards(void)
{
	struct pci_dev *akt_pcidev = NULL;
	hysdn_card *card, *card_last;
	int i;

	card_root = NULL;
	card_last = NULL;
	while ((akt_pcidev = pci_find_device(PCI_VENDOR_ID_HYPERCOPE, PCI_DEVICE_ID_HYPERCOPE_PLX,
					     akt_pcidev)) != NULL) {
		if (pci_enable_device(akt_pcidev))
			continue;

		if (!(card = kmalloc(sizeof(hysdn_card), GFP_KERNEL))) {
			printk(KERN_ERR "HYSDN: unable to alloc device mem \n");
			return;
		}
		memset(card, 0, sizeof(hysdn_card));
		card->myid = cardmax;	/* set own id */
		card->bus = akt_pcidev->bus->number;
		card->devfn = akt_pcidev->devfn;	/* slot + function */
		card->subsysid = akt_pcidev->subsystem_device;
		card->irq = akt_pcidev->irq;
		card->iobase = pci_resource_start(akt_pcidev, PCI_REG_PLX_IO_BASE);
		card->plxbase = pci_resource_start(akt_pcidev, PCI_REG_PLX_MEM_BASE);
		card->membase = pci_resource_start(akt_pcidev, PCI_REG_MEMORY_BASE);
		card->brdtype = BD_NONE;	/* unknown */
		card->debug_flags = DEF_DEB_FLAGS;	/* set default debug */
		card->faxchans = 0;	/* default no fax channels */
		card->bchans = 2;	/* and 2 b-channels */
		for (i = 0; pci_subid_map[i].subid; i++)
			if (pci_subid_map[i].subid == card->subsysid) {
				card->brdtype = pci_subid_map[i].cardtyp;
				break;
			}
		if (card->brdtype != BD_NONE) {
			if (ergo_inithardware(card)) {
				printk(KERN_WARNING "HYSDN: card at io 0x%04x already in use\n", card->iobase);
				kfree(card);
				continue;
			}
		} else {
			printk(KERN_WARNING "HYSDN: unknown card id 0x%04x\n", card->subsysid);
			kfree(card);	/* release mem */
			continue;
		}
		cardmax++;
		card->next = NULL;	/*end of chain */
		if (card_last)
			card_last->next = card;		/* pointer to next card */
		else
			card_root = card;
		card_last = card;	/* new chain end */
	}			/* device found */
}				/* search_cards */
示例#25
0
文件: cif_main.c 项目: 376473984/pvb
/*
 * Scan Compact-PCI-bus / detect CIF80 boards 
 */
int cif_scan_cpci (void)
{
  unsigned short usSubVendor, usSubSystem;

#ifdef CONFIG_PCI
    int i = 0;
    u32  curr, mask, ulDPMByteSize = 0x0UL;
    unsigned short index = 0;
    struct pci_dev *pDev = NULL;
      DBG_PRN ("scanning for cif80 Boards . . .\n");
    while ( (pDev = pci_find_device(VENDOR_ID, CPCI_DEVICE_ID, pDev)) != NULL ) {
      // PLX-Chip found, look for Hilscher one!
      pci_read_config_word(pDev, PCI_SUB_VENDOR_ID, &usSubVendor);
      pci_read_config_word(pDev, PCI_SUB_SYSTEM_ID, &usSubSystem);
      DBG_PRN("subSystem = %X, subVendor = %X\n", usSubSystem, usSubVendor); 

      if( SUBVENDOR_ID == usSubVendor && CPCI_SUBSYSTEM_ID == usSubSystem && index < 4) {
 	ulDPMByteSize = 0x0UL;

   	DBG_PRN("BAR[]=%x,%x,%x,%x IRQ=%x\n",
		(unsigned short)pci_resource_start(pDev, 0), (unsigned short)pci_resource_start(pDev, 1),
		(unsigned short)pci_resource_start(pDev, 2), (unsigned short)pci_resource_start(pDev, 3), pDev->irq);
 	for(i=0; addresses[i]; i++) {
 	  pci_read_config_dword(pDev, addresses[i],&curr);
	  DBG_PRN("addresses[%d] = %d, curr = %d\n", i, addresses[i], curr);
 	  local_irq_disable(); // cli();
 	  if(i == 2) ulRegisterSave = pci_resource_start (pDev, 2);
 	  else if(i == 1) cif_base = (unsigned short)(pci_resource_start (pDev, 1) & 0xFFFFFFFE);
 	  else if(i == 0) ulIrqCtrlRegSave = pci_resource_start (pDev, 0);
 	  pci_write_config_dword(pDev, addresses[i], ~0);
 	  pci_read_config_dword (pDev, addresses[i], &mask);
 	  pci_write_config_dword(pDev, addresses[i], curr);
 	  local_irq_enable(); // sti();
 	  if(i == 2) ulDPMByteSize = ~(mask & PCI_BASE_ADDRESS_IO_MASK) +1;
 	}
 	DBG_PRN ("PLX-CHIP local Reg. Add. : %x\n", cif_base);
 	if(( IrqCtrlRegAddr = (unsigned char *)ioremap(ulIrqCtrlRegSave, 0x50)) != NULL) { 
 	  bData = readb( IrqCtrlRegAddr + PCI_INTCTRLSTS_REG);
 	}
 	DBG_PRN ("Interrupt-ctrl-state read: %x\n", bData);
 	bData = (unsigned char)(bData | HW_INTERRUPT_ENABLE);//(bData & ~HW_INTERRUPT_ENABLE); // Desable Interrupt
 	if( cif_init_dev_pci (pDev, index, ulDPMByteSize) != 0) {
 	  DBG_PRN ("Cannot alloc memory for Board : %x\n", index);
 	  break; // -ENOMEM
 	}
 	else
 	  index++;
       }
    }
    if(index == 0) {
      DBG_PRN ("cif80: no Boards found:\n");
      return -ENODEV;
    }
#endif
    return -ENODEV;
}
示例#26
0
static void p5064_enable_ide(void)
{
#if CFG_PCI
    pcitag_t tag;

    if (pci_find_device(0x8086,0x7010,0,&tag) == 0) {
	pci_conf_write16(tag,0x40,0x8000);
	}
#endif
}
示例#27
0
文件: scsi.c 项目: frawang/u-boot
void scsi_init(void)
{
	int busdevfunc = -1;
	int i;
	/*
	 * Find a device from the list, this driver will support a single
	 * controller.
	 */
	for (i = 0; i < ARRAY_SIZE(scsi_device_list); i++) {
		/* get PCI Device ID */
#ifdef CONFIG_DM_PCI
		struct udevice *dev;
		int ret;

		ret = dm_pci_find_device(scsi_device_list[i].vendor,
					 scsi_device_list[i].device, 0, &dev);
		if (!ret) {
			busdevfunc = dm_pci_get_bdf(dev);
			break;
		}
#else
		busdevfunc = pci_find_device(scsi_device_list[i].vendor,
					     scsi_device_list[i].device,
					     0);
#endif
		if (busdevfunc != -1)
			break;
	}

	if (busdevfunc == -1) {
		printf("Error: SCSI Controller(s) ");
		for (i = 0; i < ARRAY_SIZE(scsi_device_list); i++) {
			printf("%04X:%04X ",
			       scsi_device_list[i].vendor,
			       scsi_device_list[i].device);
		}
		printf("not found\n");
		return;
	}
#ifdef DEBUG
	else {
		printf("SCSI Controller (%04X,%04X) found (%d:%d:%d)\n",
		       scsi_device_list[i].vendor,
		       scsi_device_list[i].device,
		       (busdevfunc >> 16) & 0xFF,
		       (busdevfunc >> 11) & 0x1F,
		       (busdevfunc >> 8) & 0x7);
	}
#endif
	bootstage_start(BOOTSTAGE_ID_ACCUM_SCSI, "ahci");
	scsi_low_level_init(busdevfunc);
	scsi_scan(true);
	bootstage_accum(BOOTSTAGE_ID_ACCUM_SCSI);
}
示例#28
0
static int
getAMDRamSpeed(void)
{
    struct pci_device *pci = pci_find_device(PCI_VENDOR_ID_AMD
                                             , PCI_DEVICE_ID_AMD_K8_NB_MEMCTL);
    if (!pci)
        return -1;

    /* mem clk 0 = DDR2 400 */
    return (pci_config_readb(pci->bdf, 0x94) & 0x7) + 6;
}
示例#29
0
/* Detect chip and initialize it. */
static int savage4_setup(void)
{
	struct pci_dev *dev;
	int s4_num;

	s4_num = 0;

	dev = NULL;
	do {
		if ((dev = pci_find_device(PCI_VENDOR_ID_S3,
					   PCI_CHIP_SAVAGE4,
					   dev))) {
			if (!s4_num)
				config_s4(dev);
			s4_num++;
		}
	} while (dev);

	dev = NULL;
	do {
		if ((dev = pci_find_device(PCI_VENDOR_ID_S3,
					   PCI_CHIP_SAVAGE2000,
					   dev))) {
			if (!s4_num)
				config_s4(dev);
			s4_num++;
		}
	} while (dev);

	if (s4_num > 0) {
		if(!mem)
			return -ENOMEM;
		printk("i2c-savage4: %d Savage4 found.\n", s4_num);
		if (s4_num > 1)
			printk("i2c-savage4: warning: only 1 supported.\n");
		return 0;
	} else {
		printk("i2c-savage4: No Savage4 found.\n");
		return -ENODEV;
	}
}
示例#30
0
/* scans possible addresses for vti cards */
static int vti_autodetect()
{
    dev = pci_find_device(VENDOR, DEVICE, dev);
    if (dev) {
	rtapi_print_msg(RTAPI_MSG_INFO,
	    "VTI: Card detected in slot: %2x\n", PCI_SLOT(dev->devfn));
	return (0);
    } else {
	rtapi_print_msg(RTAPI_MSG_INFO, "VTI: Exiting with auto detect failed\n");
	return (-ENODEV);
    }
}