int __init bcma_host_soc_register(struct bcma_soc *soc) { struct bcma_bus *bus = &soc->bus; /* iomap only first core. We have to read some register on this core * to scan the bus. */ bus->mmio = ioremap_nocache(BCMA_ADDR_BASE, BCMA_CORE_SIZE * 1); if (!bus->mmio) return -ENOMEM; /* Host specific */ bus->hosttype = BCMA_HOSTTYPE_SOC; bus->ops = &bcma_host_soc_ops; bus->host_pdev = NULL; /* Initialize struct, detect chip */ bcma_init_bus(bus); return 0; }
static int bcma_host_soc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct bcma_bus *bus; int err; /* Alloc */ bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL); if (!bus) return -ENOMEM; /* Map MMIO */ bus->mmio = of_iomap(np, 0); if (!bus->mmio) return -ENOMEM; /* Host specific */ bus->hosttype = BCMA_HOSTTYPE_SOC; bus->ops = &bcma_host_soc_ops; bus->host_pdev = pdev; /* Initialize struct, detect chip */ bcma_init_bus(bus); /* Register */ err = bcma_bus_register(bus); if (err) goto err_unmap_mmio; platform_set_drvdata(pdev, bus); return err; err_unmap_mmio: iounmap(bus->mmio); return err; }
static int bcma_host_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { struct bcma_bus *bus; int err = -ENOMEM; const char *name; u32 val; /* Alloc */ bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (!bus) goto out; /* Basic PCI configuration */ err = pci_enable_device(dev); if (err) goto err_kfree_bus; name = dev_name(&dev->dev); if (dev->driver && dev->driver->name) name = dev->driver->name; err = pci_request_regions(dev, name); if (err) goto err_pci_disable; pci_set_master(dev); /* Disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ pci_read_config_dword(dev, 0x40, &val); if ((val & 0x0000ff00) != 0) pci_write_config_dword(dev, 0x40, val & 0xffff00ff); /* SSB needed additional powering up, do we have any AMBA PCI cards? */ if (!pci_is_pcie(dev)) { bcma_err(bus, "PCI card detected, they are not supported.\n"); err = -ENXIO; goto err_pci_release_regions; } /* Map MMIO */ err = -ENOMEM; bus->mmio = pci_iomap(dev, 0, ~0UL); if (!bus->mmio) goto err_pci_release_regions; /* Host specific */ bus->host_pci = dev; bus->hosttype = BCMA_HOSTTYPE_PCI; bus->ops = &bcma_host_pci_ops; bus->boardinfo.vendor = bus->host_pci->subsystem_vendor; bus->boardinfo.type = bus->host_pci->subsystem_device; /* Initialize struct, detect chip */ bcma_init_bus(bus); /* Scan bus to find out generation of PCIe core */ err = bcma_bus_scan(bus); if (err) goto err_pci_unmap_mmio; if (bcma_find_core(bus, BCMA_CORE_PCIE2)) bus->host_is_pcie2 = true; /* Register */ err = bcma_bus_register(bus); if (err) goto err_unregister_cores; pci_set_drvdata(dev, bus); out: return err; err_unregister_cores: bcma_unregister_cores(bus); err_pci_unmap_mmio: pci_iounmap(dev, bus->mmio); err_pci_release_regions: pci_release_regions(dev); err_pci_disable: pci_disable_device(dev); err_kfree_bus: kfree(bus); return err; }