static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { unsigned base; if (pdev->device == PCI_DEVICE_ID_NS_SCx200_BRIDGE || pdev->device == PCI_DEVICE_ID_NS_SC1100_BRIDGE) { base = pci_resource_start(pdev, 0); printk(KERN_INFO NAME ": GPIO base 0x%x\n", base); if (!request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO")) { printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n"); return -EBUSY; } scx200_gpio_base = base; scx200_init_shadow(); } else { /* find the base of the Configuration Block */ if (scx200_cb_probe(SCx200_CB_BASE_FIXED)) { scx200_cb_base = SCx200_CB_BASE_FIXED; } else { pci_read_config_dword(pdev, SCx200_CBA_SCRATCH, &base); if (scx200_cb_probe(base)) { scx200_cb_base = base; } else { printk(KERN_WARNING NAME ": Configuration Block not found\n"); return -ENODEV; } } printk(KERN_INFO NAME ": Configuration Block base 0x%x\n", scx200_cb_base); } return 0; }
int __init init_scx200_docflash(void) { unsigned u; unsigned base; unsigned ctrl; unsigned pmr; struct pci_dev *bridge; printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE, NULL)) == NULL) return -ENODEV; if (!scx200_cb_probe(SCx200_CB_BASE)) { printk(KERN_WARNING NAME ": no configuration block found\n"); return -ENODEV; } if (probe) { /* Try to use the present flash mapping if any */ pci_read_config_dword(bridge, SCx200_DOCCS_BASE, &base); pci_read_config_dword(bridge, SCx200_DOCCS_CTRL, &ctrl); pmr = inl(SCx200_CB_BASE + SCx200_PMR); if (base == 0 || (ctrl & 0x07000000) != 0x07000000 || (ctrl & 0x0007ffff) == 0) return -ENODEV; size = ((ctrl&0x1fff)<<13) + (1<<13); for (u = size; u > 1; u >>= 1) ; if (u != 1) return -ENODEV; if (pmr & (1<<6)) width = 16; else width = 8; docmem.start = base; docmem.end = base + size; if (request_resource(&iomem_resource, &docmem)) { printk(KERN_ERR NAME ": unable to allocate memory for flash mapping\n"); return -ENOMEM; } } else { for (u = size; u > 1; u >>= 1)