Lines Matching +full:bus +full:- +full:addr

5  * Copyright 2005 - 2011, Broadcom Corporation
7 * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
19 /* Probe a 32bit value on the bus and catch bus exceptions.
20 * Returns nonzero on a bus exception.
22 #define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr))) argument
24 /* Assume one-hot slot wiring */
30 struct bcma_bus *bus = pc->core->bus; in bcma_core_pci_is_in_hostmode() local
34 chipid_top = (bus->chipinfo.id & 0xFF00); in bcma_core_pci_is_in_hostmode()
39 bcma_core_enable(pc->core, 0); in bcma_core_pci_is_in_hostmode()
41 return !mips_busprobe32(tmp, pc->core->io_addr); in bcma_core_pci_is_in_hostmode()
62 u32 addr = 0; in bcma_get_cfgspace_addr() local
75 addr = pc->host_controller->host_cfg_addr; in bcma_get_cfgspace_addr()
76 addr |= (dev << BCMA_CORE_PCI_CFG_SLOT_SHIFT); in bcma_get_cfgspace_addr()
77 addr |= (func << BCMA_CORE_PCI_CFG_FUN_SHIFT); in bcma_get_cfgspace_addr()
78 addr |= (off & ~3); in bcma_get_cfgspace_addr()
81 return addr; in bcma_get_cfgspace_addr()
88 int err = -EINVAL; in bcma_extpci_read_config()
89 u32 addr, val; in bcma_extpci_read_config() local
92 WARN_ON(!pc->hostmode); in bcma_extpci_read_config()
104 addr = (func << 12); in bcma_extpci_read_config()
105 addr |= (off & 0x0FFC); in bcma_extpci_read_config()
106 val = bcma_pcie_read_config(pc, addr); in bcma_extpci_read_config()
108 addr = BCMA_CORE_PCI_PCICFG0; in bcma_extpci_read_config()
109 addr |= (func << 8); in bcma_extpci_read_config()
110 addr |= (off & 0xFC); in bcma_extpci_read_config()
111 val = pcicore_read32(pc, addr); in bcma_extpci_read_config()
114 addr = bcma_get_cfgspace_addr(pc, dev, func, off); in bcma_extpci_read_config()
115 if (unlikely(!addr)) in bcma_extpci_read_config()
117 err = -ENOMEM; in bcma_extpci_read_config()
118 mmio = ioremap(addr, sizeof(val)); in bcma_extpci_read_config()
152 int err = -EINVAL; in bcma_extpci_write_config()
153 u32 addr, val; in bcma_extpci_write_config() local
155 u16 chipid = pc->core->bus->chipinfo.id; in bcma_extpci_write_config()
157 WARN_ON(!pc->hostmode); in bcma_extpci_write_config()
169 addr = (func << 12); in bcma_extpci_write_config()
170 addr |= (off & 0x0FFC); in bcma_extpci_write_config()
171 val = bcma_pcie_read_config(pc, addr); in bcma_extpci_write_config()
173 addr = BCMA_CORE_PCI_PCICFG0; in bcma_extpci_write_config()
174 addr |= (func << 8); in bcma_extpci_write_config()
175 addr |= (off & 0xFC); in bcma_extpci_write_config()
176 val = pcicore_read32(pc, addr); in bcma_extpci_write_config()
179 addr = bcma_get_cfgspace_addr(pc, dev, func, off); in bcma_extpci_write_config()
180 if (unlikely(!addr)) in bcma_extpci_write_config()
182 err = -ENOMEM; in bcma_extpci_write_config()
183 mmio = ioremap(addr, sizeof(val)); in bcma_extpci_write_config()
211 bcma_pcie_write_config(pc, addr, val); in bcma_extpci_write_config()
213 pcicore_write32(pc, addr, val); in bcma_extpci_write_config()
230 static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus, in bcma_core_pci_hostmode_read_config() argument
239 pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops); in bcma_core_pci_hostmode_read_config()
240 pc = pc_host->pdev; in bcma_core_pci_hostmode_read_config()
242 spin_lock_irqsave(&pc_host->cfgspace_lock, flags); in bcma_core_pci_hostmode_read_config()
245 spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags); in bcma_core_pci_hostmode_read_config()
250 static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus, in bcma_core_pci_hostmode_write_config() argument
259 pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops); in bcma_core_pci_hostmode_write_config()
260 pc = pc_host->pdev; in bcma_core_pci_hostmode_write_config()
262 spin_lock_irqsave(&pc_host->cfgspace_lock, flags); in bcma_core_pci_hostmode_write_config()
265 spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags); in bcma_core_pci_hostmode_write_config()
323 bufsize = PCI_CONFIG_SPACE_SIZE - cap_data; in bcma_find_pci_capability()
325 while (bufsize--) { in bcma_find_pci_capability()
342 struct bcma_bus *bus = pc->core->bus; in bcma_core_pci_enable_crs() local
365 * a read-data value of 0001h for the Vendor ID field and in bcma_core_pci_enable_crs()
381 bcma_err(bus, "PCI: Broken device in slot %d\n", in bcma_core_pci_enable_crs()
389 struct bcma_bus *bus = pc->core->bus; in bcma_core_pci_hostmode_init() local
395 bcma_info(bus, "PCIEcore in host mode found\n"); in bcma_core_pci_hostmode_init()
397 if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) { in bcma_core_pci_hostmode_init()
398 bcma_info(bus, "This PCIE core is disabled and not working\n"); in bcma_core_pci_hostmode_init()
404 bcma_err(bus, "can not allocate memory"); in bcma_core_pci_hostmode_init()
408 spin_lock_init(&pc_host->cfgspace_lock); in bcma_core_pci_hostmode_init()
410 pc->host_controller = pc_host; in bcma_core_pci_hostmode_init()
411 pc_host->pci_controller.io_resource = &pc_host->io_resource; in bcma_core_pci_hostmode_init()
412 pc_host->pci_controller.mem_resource = &pc_host->mem_resource; in bcma_core_pci_hostmode_init()
413 pc_host->pci_controller.pci_ops = &pc_host->pci_ops; in bcma_core_pci_hostmode_init()
414 pc_host->pdev = pc; in bcma_core_pci_hostmode_init()
417 pc_host->host_cfg_addr = BCMA_SOC_PCI_CFG; in bcma_core_pci_hostmode_init()
419 pc_host->pci_ops.read = bcma_core_pci_hostmode_read_config; in bcma_core_pci_hostmode_init()
420 pc_host->pci_ops.write = bcma_core_pci_hostmode_write_config; in bcma_core_pci_hostmode_init()
422 pc_host->mem_resource.name = "BCMA PCIcore external memory"; in bcma_core_pci_hostmode_init()
423 pc_host->mem_resource.start = BCMA_SOC_PCI_DMA; in bcma_core_pci_hostmode_init()
424 pc_host->mem_resource.end = BCMA_SOC_PCI_DMA + BCMA_SOC_PCI_DMA_SZ - 1; in bcma_core_pci_hostmode_init()
425 pc_host->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED; in bcma_core_pci_hostmode_init()
427 pc_host->io_resource.name = "BCMA PCIcore external I/O"; in bcma_core_pci_hostmode_init()
428 pc_host->io_resource.start = 0x100; in bcma_core_pci_hostmode_init()
429 pc_host->io_resource.end = 0x7FF; in bcma_core_pci_hostmode_init()
430 pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED; in bcma_core_pci_hostmode_init()
442 * as mips can't generate 64-bit address on the in bcma_core_pci_hostmode_init()
445 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4716 || in bcma_core_pci_hostmode_init()
446 bus->chipinfo.id == BCMA_CHIP_ID_BCM4748) { in bcma_core_pci_hostmode_init()
447 pc_host->mem_resource.start = BCMA_SOC_PCI_MEM; in bcma_core_pci_hostmode_init()
448 pc_host->mem_resource.end = BCMA_SOC_PCI_MEM + in bcma_core_pci_hostmode_init()
449 BCMA_SOC_PCI_MEM_SZ - 1; in bcma_core_pci_hostmode_init()
452 } else if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) { in bcma_core_pci_hostmode_init()
456 if (pc->core->core_unit == 0) { in bcma_core_pci_hostmode_init()
457 pc_host->mem_resource.start = BCMA_SOC_PCI_MEM; in bcma_core_pci_hostmode_init()
458 pc_host->mem_resource.end = BCMA_SOC_PCI_MEM + in bcma_core_pci_hostmode_init()
459 BCMA_SOC_PCI_MEM_SZ - 1; in bcma_core_pci_hostmode_init()
460 pc_host->io_resource.start = 0x100; in bcma_core_pci_hostmode_init()
461 pc_host->io_resource.end = 0x47F; in bcma_core_pci_hostmode_init()
465 } else if (pc->core->core_unit == 1) { in bcma_core_pci_hostmode_init()
466 pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM; in bcma_core_pci_hostmode_init()
467 pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM + in bcma_core_pci_hostmode_init()
468 BCMA_SOC_PCI_MEM_SZ - 1; in bcma_core_pci_hostmode_init()
469 pc_host->io_resource.start = 0x480; in bcma_core_pci_hostmode_init()
470 pc_host->io_resource.end = 0x7FF; in bcma_core_pci_hostmode_init()
472 pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG; in bcma_core_pci_hostmode_init()
497 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 || in bcma_core_pci_hostmode_init()
498 bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) { in bcma_core_pci_hostmode_init()
517 * to non-MIPS platform. */ in bcma_core_pci_hostmode_init()
518 io_map_base = (unsigned long)ioremap(pc_host->mem_resource.start, in bcma_core_pci_hostmode_init()
519 resource_size(&pc_host->mem_resource)); in bcma_core_pci_hostmode_init()
520 pc_host->pci_controller.io_map_base = io_map_base; in bcma_core_pci_hostmode_init()
521 set_io_port_base(pc_host->pci_controller.io_map_base); in bcma_core_pci_hostmode_init()
525 register_pci_controller(&pc_host->pci_controller); in bcma_core_pci_hostmode_init()
529 /* Early PCI fixup for a device on the PCI-core bridge. */
532 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { in bcma_core_pci_fixup_pcibridge()
533 /* This is not a device on the PCI-core bridge. */ in bcma_core_pci_fixup_pcibridge()
536 if (PCI_SLOT(dev->devfn) != 0) in bcma_core_pci_fixup_pcibridge()
541 /* Enable PCI bridge bus mastering and memory space */ in bcma_core_pci_fixup_pcibridge()
553 /* Early PCI fixup for all PCI-cores to set the correct memory address. */
559 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { in bcma_core_pci_fixup_addresses()
560 /* This is not a device on the PCI-core bridge. */ in bcma_core_pci_fixup_addresses()
563 if (PCI_SLOT(dev->devfn) == 0) in bcma_core_pci_fixup_addresses()
569 res = &dev->resource[pos]; in bcma_core_pci_fixup_addresses()
570 if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) { in bcma_core_pci_fixup_addresses()
581 * We must first check if the device is a device on the PCI-core bridge. */
587 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { in bcma_core_pci_plat_dev_init()
588 /* This is not a device on the PCI-core bridge. */ in bcma_core_pci_plat_dev_init()
589 return -ENODEV; in bcma_core_pci_plat_dev_init()
591 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host, in bcma_core_pci_plat_dev_init()
597 dev->irq = bcma_core_irq(pc_host->pdev->core, 0); in bcma_core_pci_plat_dev_init()
598 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); in bcma_core_pci_plat_dev_init()
614 if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { in bcma_core_pci_pcibios_map_irq()
615 /* This is not a device on the PCI-core bridge. */ in bcma_core_pci_pcibios_map_irq()
616 return -ENODEV; in bcma_core_pci_pcibios_map_irq()
619 pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host, in bcma_core_pci_pcibios_map_irq()
621 return bcma_core_irq(pc_host->pdev->core, 0); in bcma_core_pci_pcibios_map_irq()