本文整理汇总了C++中pci_find_device函数的典型用法代码示例。如果您正苦于以下问题:C++ pci_find_device函数的具体用法?C++ pci_find_device怎么用?C++ pci_find_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pci_find_device函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_nm256
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: pplus_pib_init
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 |= 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);
}
}
示例3: pcibios_fixup_bus
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);
}
}
}
示例4: bcm947xx_fixup
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);
}
}
}
示例5: prpmc750_pcibios_fixup
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);
}
}
示例6: get_pci_addr
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;
}
示例7: piix4_apmc_smm_init
// 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);
}
示例8: ide_preinit
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);
}
示例9: pci_find_device
/* 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)));
}
示例10: ehci_pci_ati_quirk
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");
}
}
示例11: scx200_init
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;
}
示例12: spi_init_address
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;
}
示例13: pci_drive_hot_add
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;
}
示例14: setup_enternow_pci
/* 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);
}
示例15: pci_device_hot_remove
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;
}