/*------------------------------------------------------------------------ * quark_irq_routing - Set IRQ indirection for devices *------------------------------------------------------------------------ */ int32 quark_irq_routing(void) { int pciinfo; /* PCI info for Legacy bridge */ uint32 rcba; /* Root Complex Base Address */ pciinfo = find_pci_device(INTEL_QUARK_LEGBR_PCI_DID, INTEL_QUARK_LEGBR_PCI_VID, 0); if(pciinfo == SYSERR) { return SYSERR; } /* Route PIRQ A-D to 8259 IRQ 2-5 respectively */ pci_write_config_dword(pciinfo, PABCDRC_OFFSET, PABCDRC_VALUE); /* Route PIRQ E-H to 8259 IRQ 6-9 respectively */ pci_write_config_dword(pciinfo, PEFGHRC_OFFSET, PEFGHRC_VALUE); /* Read the Root Complex Base Address */ pci_read_config_dword(pciinfo, RCBA_OFFSET, &rcba); rcba &= RCBA_MASK; /* Route PCI interrupts to PIRQA-H, refer to quark_irq.h file * for specific IRQ assignments */ *(uint16 *)(rcba + IRQAGENT0_OFFSET) = IRQAGENT0_VALUE; *(uint16 *)(rcba + IRQAGENT1_OFFSET) = IRQAGENT1_VALUE; *(uint16 *)(rcba + IRQAGENT2_OFFSET) = IRQAGENT2_VALUE; *(uint16 *)(rcba + IRQAGENT3_OFFSET) = IRQAGENT3_VALUE; outb(0x4d1, 0x1E); return OK; }
/*------------------------------------------------------------------ * platinit - platform specific initialization for Galileo *------------------------------------------------------------------ */ void platinit() { int32 pcidev; /* Initialize the PCI bus */ pci_init(); /* Initialize the console serial port */ console_init(); /* Remove Isolated Memory Region Protections */ remove_irm_protections(); /* Intel Quark Irq Routing */ quark_irq_routing(); /* Find the Ethernet device */ pcidev = find_pci_device(INTEL_ETH_QUARK_PCI_DID, INTEL_ETH_QUARK_PCI_VID, 0); if(pcidev != SYSERR) { /* Store the pcidev for future use */ ethertab[0].pcidev = pcidev; pci_get_dev_mmio_base_addr(pcidev, 0, &devtab[ETHER0].dvcsr); } }
/** * sb_probe * * @param dev: the PCI device matching * @param id: entry in the match table * @return 0 * * Callback from PCI layer when dev/vendor ids match. * Sets up necessary resources */ static int intel_cln_early_sb_probe(void) { int sb_dev; sb_dev = find_pci_device(PCI_DEVICE_ID_CLANTON_SB, PCI_VENDOR_ID_INTEL, 0); if (sb_dev < 0) { kprintf("%s(): error finding PCI device DID 0x%x\n", __FUNCTION__, PCI_DEVICE_ID_CLANTON_SB); // Reflect the error. return sb_dev; } //kprintf("%s(): found PCI device DID 0x%x sb_dev 0x%x\n", __FUNCTION__, PCI_DEVICE_ID_CLANTON_SB, sb_dev); return 0; }
/*------------------------------------------------------------------ * console_init - initialize the serial console. The serial console * is on the second memory-mapped 16550 UART device. *------------------------------------------------------------------ */ int console_init(void) { int status; int pciDev; pciDev = find_pci_device(INTEL_QUARK_UART_PCI_DID, INTEL_QUARK_UART_PCI_VID, QUARK_CONS_PORT); if (pciDev < 0) { /* Error finding console device */ return pciDev; } /* Store the console device CSR base address into the console device's device table entry. */ status = pci_get_dev_mmio_base_addr(pciDev, QUARK_CONS_BAR_INDEX, &devtab[CONSOLE].dvcsr); return status; }
int main(int argc, char *argv[]) { struct match *list, *match; struct pci_domain *pci_domain; openconsole(&dev_null_r, &dev_stdcon_w); pci_domain = pci_scan(); if (pci_domain) { list = parse_config(argc < 2 ? NULL : argv[1]); match = find_pci_device(pci_domain, list); if (match) syslinux_run_command(match->filename); } /* On error, return to the command line */ fputs("Error: no recognized network card found!\n", stderr); return 1; }
int i915_init(void) { static pci_dev_t device; const struct pci_device_id *ent; int err; ent = find_pci_device(&device, pciidlist); if( unlikely(ent == NULL) ) { dbgprintf("device not found\n"); return -ENODEV; }; drm_core_init(); DRM_INFO("device %x:%x\n", device.pci_dev.vendor, device.pci_dev.device); driver.driver_features |= DRIVER_MODESET; err = drm_get_pci_dev(&device.pci_dev, ent, &driver); return err; }
/*------------------------------------------------------------------------ * ethInit - Initialize Ethernet device structures *------------------------------------------------------------------------ */ devcall ethInit ( struct dentry *devptr ) { struct ether *ethptr; int32 dinfo; /* device information */ /* Initialize structure pointers */ ethptr = ðertab[devptr->dvminor]; memset(ethptr, '\0', sizeof(struct ether)); ethptr->dev = devptr; ethptr->csr = devptr->dvcsr; ethptr->state = ETH_STATE_DOWN; ethptr->mtu = ETH_MTU; ethptr->errors = 0; ethptr->addrLen = ETH_ADDR_LEN; ethptr->rxHead = ethptr->rxTail = 0; ethptr->txHead = ethptr->txTail = 0; if ((dinfo = find_pci_device(INTEL_82545EM_DEVICE_ID, INTEL_VENDOR_ID, 0)) != SYSERR) { kprintf("Found Intel 82545EM Ethernet NIC\n"); ethptr->type = NIC_TYPE_82545EM; ethptr->pcidev = dinfo; /* Initialize function pointers */ devtab[ETHER0].dvread = (void *)e1000Read; devtab[ETHER0].dvwrite = (void *)e1000Write; devtab[ETHER0].dvcntl = (void *)e1000Control; devtab[ETHER0].dvintr = (void *)e1000Dispatch; if (_82545EMInit(ethptr) == SYSERR) { kprintf("Failed to initialize Intel 82545EM NIC\n"); return SYSERR; } } else if ((dinfo = find_pci_device(INTEL_82567LM_DEVICE_ID, INTEL_VENDOR_ID, 0)) != SYSERR) { kprintf("Found Intel 82567LM Ethernet NIC\n"); ethptr->type = NIC_TYPE_82567LM; ethptr->pcidev = dinfo; /* Initialize function pointers */ devtab[ETHER0].dvread = (void *)e1000Read; devtab[ETHER0].dvwrite = (void *)e1000Write; devtab[ETHER0].dvcntl = (void *)e1000Control; devtab[ETHER0].dvintr = (void *)e1000Dispatch; if (_82567LMInit(ethptr) == SYSERR) { kprintf("Failed to initialize Intel 82567LM NIC\n"); return SYSERR; } } else { kprintf("No recognized PCI Ethernet NIC found\n"); return SYSERR; } /* Ethernet interface is active from here */ ethptr->state = ETH_STATE_UP; return OK; }
/*------------------------------------------------------------------------ * ttyinit - Initialize buffers and modes for a tty line *------------------------------------------------------------------------ */ devcall ttyinit( struct dentry *devptr /* Entry in device switch table */ ) { struct ttycblk *typtr; /* Pointer to ttytab entry */ struct uart_csreg *uptr; /* Address of UART's CSRs */ uint32 pcidev; /* Encoded PCI device */ typtr = &ttytab[ devptr->dvminor ]; /* Initialize values in the tty control block */ typtr->tyihead = typtr->tyitail = /* Set up input queue */ &typtr->tyibuff[0]; /* as empty */ typtr->tyisem = semcreate(0); /* Input semaphore */ typtr->tyohead = typtr->tyotail = /* Set up output queue */ &typtr->tyobuff[0]; /* as empty */ typtr->tyosem = semcreate(TY_OBUFLEN); /* Output semaphore */ typtr->tyehead = typtr->tyetail = /* Set up echo queue */ &typtr->tyebuff[0]; /* as empty */ typtr->tyimode = TY_IMCOOKED; /* Start in cooked mode */ typtr->tyiecho = TRUE; /* Echo console input */ typtr->tyieback = TRUE; /* Honor erasing bksp */ typtr->tyevis = TRUE; /* Visual control chars */ typtr->tyecrlf = TRUE; /* Echo CRLF for NEWLINE*/ typtr->tyicrlf = TRUE; /* Map CR to NEWLINE */ typtr->tyierase = TRUE; /* Do erasing backspace */ typtr->tyierasec = TY_BACKSP; /* Primary erase char */ typtr->tyierasec2= TY_BACKSP2; /* Alternate erase char */ typtr->tyeof = TRUE; /* Honor eof on input */ typtr->tyeofch = TY_EOFCH; /* End-of-file character*/ typtr->tyikill = TRUE; /* Allow line kill */ typtr->tyikillc = TY_KILLCH; /* Set line kill to ^U */ typtr->tyicursor = 0; /* Start of input line */ typtr->tyoflow = TRUE; /* Handle flow control */ typtr->tyoheld = FALSE; /* Output not held */ typtr->tyostop = TY_STOPCH; /* Stop char is ^S */ typtr->tyostart = TY_STRTCH; /* Start char is ^Q */ typtr->tyocrlf = TRUE; /* Send CRLF for NEWLINE*/ typtr->tyifullc = TY_FULLCH; /* Send ^G when buffer */ /* is full */ /* Get the encoded PCI for the UART device */ pcidev = find_pci_device(INTEL_QUARK_UART_PCI_DID, INTEL_QUARK_UART_PCI_VID, 1); /* Initialize the UART */ uptr = (struct uart_csreg *)devptr->dvcsr; /* Set baud rate */ uptr->lcr = UART_LCR_DLAB; uptr->dlm = 0x00; uptr->dll = 0x18; uptr->lcr = UART_LCR_8N1; /* 8 bit char, No Parity, 1 Stop*/ uptr->fcr = 0x00; /* Disable FIFO for now */ /* Register the interrupt handler for the tty device */ pci_set_ivec( pcidev, devptr->dvirq, devptr->dvintr, (int32)devptr ); /* Enable interrupts on the device: reset the transmit and */ /* receive FIFOS, and set the interrupt trigger level */ uptr->fcr = UART_FCR_EFIFO | UART_FCR_RRESET | UART_FCR_TRESET | UART_FCR_TRIG2; /* Start the device */ ttykickout(uptr); return OK; }