drivers/bcma/driver_pci_host.c
Source file repositories/reference/linux-study-clean/drivers/bcma/driver_pci_host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bcma/driver_pci_host.c- Extension
.c- Size
- 17878 bytes
- Lines
- 624
- Domain
- Driver Families
- Bucket
- drivers/bcma
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
bcma_private.hlinux/pci.hlinux/slab.hlinux/export.hlinux/bcma/bcma.hasm/paccess.h
Detected Declarations
function bcma_core_pci_is_in_hostmodefunction bcma_pcie_read_configfunction bcma_pcie_write_configfunction bcma_get_cfgspace_addrfunction bcma_extpci_read_configfunction bcma_extpci_write_configfunction bcma_core_pci_hostmode_read_configfunction bcma_core_pci_hostmode_write_configfunction bcma_find_pci_capabilityfunction Statusfunction bcma_core_pci_hostmode_initfunction bcma_core_pci_fixup_pcibridgefunction bcma_core_pci_fixup_addressesfunction bcma_core_pci_plat_dev_initfunction bcma_core_pci_pcibios_map_irqexport bcma_core_pci_plat_dev_initexport bcma_core_pci_pcibios_map_irq
Annotated Snippet
if (off >= PCI_CONFIG_SPACE_SIZE) {
addr = (func << 12);
addr |= (off & 0x0FFC);
val = bcma_pcie_read_config(pc, addr);
} else {
addr = BCMA_CORE_PCI_PCICFG0;
addr |= (func << 8);
addr |= (off & 0xFC);
val = pcicore_read32(pc, addr);
}
} else {
addr = bcma_get_cfgspace_addr(pc, dev, func, off);
if (unlikely(!addr))
goto out;
err = -ENOMEM;
mmio = ioremap(addr, sizeof(val));
if (!mmio)
goto out;
if (mips_busprobe32(val, mmio)) {
val = 0xFFFFFFFF;
goto unmap;
}
}
val >>= (8 * (off & 3));
switch (len) {
case 1:
*((u8 *)buf) = (u8)val;
break;
case 2:
*((u16 *)buf) = (u16)val;
break;
case 4:
*((u32 *)buf) = (u32)val;
break;
}
err = 0;
unmap:
if (mmio)
iounmap(mmio);
out:
return err;
}
static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
unsigned int func, unsigned int off,
const void *buf, int len)
{
int err = -EINVAL;
u32 addr, val;
void __iomem *mmio = 0;
u16 chipid = pc->core->bus->chipinfo.id;
WARN_ON(!pc->hostmode);
if (unlikely(len != 1 && len != 2 && len != 4))
goto out;
if (dev == 0) {
/* we support only two functions on device 0 */
if (func > 1)
goto out;
/* accesses to config registers with offsets >= 256
* requires indirect access.
*/
if (off >= PCI_CONFIG_SPACE_SIZE) {
addr = (func << 12);
addr |= (off & 0x0FFC);
val = bcma_pcie_read_config(pc, addr);
} else {
addr = BCMA_CORE_PCI_PCICFG0;
addr |= (func << 8);
addr |= (off & 0xFC);
val = pcicore_read32(pc, addr);
}
} else {
addr = bcma_get_cfgspace_addr(pc, dev, func, off);
if (unlikely(!addr))
goto out;
err = -ENOMEM;
mmio = ioremap(addr, sizeof(val));
if (!mmio)
goto out;
if (mips_busprobe32(val, mmio)) {
val = 0xFFFFFFFF;
goto unmap;
}
}
Annotation
- Immediate include surface: `bcma_private.h`, `linux/pci.h`, `linux/slab.h`, `linux/export.h`, `linux/bcma/bcma.h`, `asm/paccess.h`.
- Detected declarations: `function bcma_core_pci_is_in_hostmode`, `function bcma_pcie_read_config`, `function bcma_pcie_write_config`, `function bcma_get_cfgspace_addr`, `function bcma_extpci_read_config`, `function bcma_extpci_write_config`, `function bcma_core_pci_hostmode_read_config`, `function bcma_core_pci_hostmode_write_config`, `function bcma_find_pci_capability`, `function Status`.
- Atlas domain: Driver Families / drivers/bcma.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.