arch/powerpc/sysdev/fsl_pci.c
Source file repositories/reference/linux-study-clean/arch/powerpc/sysdev/fsl_pci.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/sysdev/fsl_pci.c- Extension
.c- Size
- 34947 bytes
- Lines
- 1372
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
linux/kernel.hlinux/pci.hlinux/delay.hlinux/string.hlinux/fsl/edac.hlinux/init.hlinux/interrupt.hlinux/memblock.hlinux/log2.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/slab.hlinux/suspend.hlinux/syscore_ops.hlinux/uaccess.hasm/io.hasm/pci-bridge.hasm/ppc-pci.hasm/machdep.hasm/mpc85xx.hasm/disassemble.hasm/ppc-opcode.hasm/swiotlb.hasm/setup.hsysdev/fsl_soc.hsysdev/fsl_pci.h
Detected Declarations
struct mpc83xx_pcie_privstruct pex_inbound_windowfunction quirk_fsl_pcie_earlyfunction fsl_pcie_check_linkfunction fsl_indirect_read_configfunction pci_dma_dev_setup_swiotlbfunction setup_swiotlb_opsfunction setup_swiotlb_opsfunction setup_one_atmufunction is_kdumpfunction setup_pci_atmufunction setup_pci_cmdfunction fsl_pcibios_fixup_busfunction fsl_add_bridgefunction PBFRfunction mpc83xx_pcie_exclude_devicefunction mpc83xx_pcie_write_configfunction mpc83xx_pcie_setupfunction mpc83xx_add_bridgefunction fsl_pci_immrbar_basefunction mcheck_handle_loadfunction is_in_pci_mem_spacefunction list_for_each_entryfunction fsl_pci_mcheck_exceptionfunction fsl_pci_assign_primaryfunction fsl_pci_pme_handlefunction fsl_pci_pme_probefunction send_pme_turnoff_messagefunction fsl_pci_syscore_do_suspendfunction fsl_pci_syscore_suspendfunction fsl_pci_syscore_do_resumefunction fsl_pci_syscore_resumefunction fsl_pcibios_fixup_phbfunction add_err_devfunction fsl_pci_probefunction fsl_pci_init
Annotated Snippet
struct mpc83xx_pcie_priv {
void __iomem *cfg_type0;
void __iomem *cfg_type1;
u32 dev_base;
};
struct pex_inbound_window {
u32 ar;
u32 tar;
u32 barl;
u32 barh;
};
/*
* With the convention of u-boot, the PCIE outbound window 0 serves
* as configuration transactions outbound.
*/
#define PEX_OUTWIN0_BAR 0xCA4
#define PEX_OUTWIN0_TAL 0xCA8
#define PEX_OUTWIN0_TAH 0xCAC
#define PEX_RC_INWIN_BASE 0xE60
#define PEX_RCIWARn_EN 0x1
static int mpc83xx_pcie_exclude_device(struct pci_bus *bus, unsigned int devfn)
{
struct pci_controller *hose = pci_bus_to_host(bus);
if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK)
return PCIBIOS_DEVICE_NOT_FOUND;
/*
* Workaround for the HW bug: for Type 0 configure transactions the
* PCI-E controller does not check the device number bits and just
* assumes that the device number bits are 0.
*/
if (bus->number == hose->first_busno ||
bus->primary == hose->first_busno) {
if (devfn & 0xf8)
return PCIBIOS_DEVICE_NOT_FOUND;
}
if (ppc_md.pci_exclude_device) {
if (ppc_md.pci_exclude_device(hose, bus->number, devfn))
return PCIBIOS_DEVICE_NOT_FOUND;
}
return PCIBIOS_SUCCESSFUL;
}
static void __iomem *mpc83xx_pcie_remap_cfg(struct pci_bus *bus,
unsigned int devfn, int offset)
{
struct pci_controller *hose = pci_bus_to_host(bus);
struct mpc83xx_pcie_priv *pcie = hose->dn->data;
u32 dev_base = bus->number << 24 | devfn << 16;
int ret;
ret = mpc83xx_pcie_exclude_device(bus, devfn);
if (ret)
return NULL;
offset &= 0xfff;
/* Type 0 */
if (bus->number == hose->first_busno)
return pcie->cfg_type0 + offset;
if (pcie->dev_base == dev_base)
goto mapped;
out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAL, dev_base);
pcie->dev_base = dev_base;
mapped:
return pcie->cfg_type1 + offset;
}
static int mpc83xx_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
int offset, int len, u32 val)
{
struct pci_controller *hose = pci_bus_to_host(bus);
/* PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS */
if (offset == PCI_PRIMARY_BUS && bus->number == hose->first_busno)
val &= 0xffffff00;
return pci_generic_config_write(bus, devfn, offset, len, val);
}
static struct pci_ops mpc83xx_pcie_ops = {
.map_bus = mpc83xx_pcie_remap_cfg,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/pci.h`, `linux/delay.h`, `linux/string.h`, `linux/fsl/edac.h`, `linux/init.h`, `linux/interrupt.h`, `linux/memblock.h`.
- Detected declarations: `struct mpc83xx_pcie_priv`, `struct pex_inbound_window`, `function quirk_fsl_pcie_early`, `function fsl_pcie_check_link`, `function fsl_indirect_read_config`, `function pci_dma_dev_setup_swiotlb`, `function setup_swiotlb_ops`, `function setup_swiotlb_ops`, `function setup_one_atmu`, `function is_kdump`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.