arch/mips/pci/pci-mt7620.c
Source file repositories/reference/linux-study-clean/arch/mips/pci/pci-mt7620.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/pci/pci-mt7620.c- Extension
.c- Size
- 10703 bytes
- Lines
- 445
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/pci.hlinux/io.hlinux/init.hlinux/delay.hlinux/interrupt.hlinux/of.hlinux/of_irq.hlinux/of_pci.hlinux/reset.hlinux/platform_device.hasm/mach-ralink/ralink_regs.hasm/mach-ralink/mt7620.h
Detected Declarations
function bridge_w32function bridge_r32function bridge_m32function pcie_w32function pcie_r32function pcie_m32function pcie_phyctrl_setfunction wait_pciephy_busyfunction pcie_phyfunction pci_config_readfunction pci_config_writefunction mt7620_pci_hw_initfunction mt7628_pci_hw_initfunction mt7620_pci_probefunction pcibios_map_irqfunction pcibios_plat_dev_initfunction mt7620_pci_init
Annotated Snippet
if (retry++ > WAITRETRY_MAX) {
pr_warn("PCIE-PHY retry failed.\n");
return -1;
}
}
return 0;
}
static void pcie_phy(unsigned long addr, unsigned long val)
{
wait_pciephy_busy();
pcie_w32(WRITE_MODE | (val << DATA_SHIFT) | (addr << ADDR_SHIFT),
PCIEPHY0_CFG);
mdelay(1);
wait_pciephy_busy();
}
static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *val)
{
unsigned int slot = PCI_SLOT(devfn);
u8 func = PCI_FUNC(devfn);
u32 address;
u32 data;
u32 num = 0;
if (bus)
num = bus->number;
address = (((where & 0xF00) >> 8) << 24) | (num << 16) | (slot << 11) |
(func << 8) | (where & 0xfc) | 0x80000000;
bridge_w32(address, RALINK_PCI_CONFIG_ADDR);
data = bridge_r32(RALINK_PCI_CONFIG_DATA_VIRT_REG);
switch (size) {
case 1:
*val = (data >> ((where & 3) << 3)) & 0xff;
break;
case 2:
*val = (data >> ((where & 3) << 3)) & 0xffff;
break;
case 4:
*val = data;
break;
}
return PCIBIOS_SUCCESSFUL;
}
static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 val)
{
unsigned int slot = PCI_SLOT(devfn);
u8 func = PCI_FUNC(devfn);
u32 address;
u32 data;
u32 num = 0;
if (bus)
num = bus->number;
address = (((where & 0xF00) >> 8) << 24) | (num << 16) | (slot << 11) |
(func << 8) | (where & 0xfc) | 0x80000000;
bridge_w32(address, RALINK_PCI_CONFIG_ADDR);
data = bridge_r32(RALINK_PCI_CONFIG_DATA_VIRT_REG);
switch (size) {
case 1:
data = (data & ~(0xff << ((where & 3) << 3))) |
(val << ((where & 3) << 3));
break;
case 2:
data = (data & ~(0xffff << ((where & 3) << 3))) |
(val << ((where & 3) << 3));
break;
case 4:
data = val;
break;
}
bridge_w32(data, RALINK_PCI_CONFIG_DATA_VIRT_REG);
return PCIBIOS_SUCCESSFUL;
}
struct pci_ops mt7620_pci_ops = {
.read = pci_config_read,
.write = pci_config_write,
};
Annotation
- Immediate include surface: `linux/types.h`, `linux/pci.h`, `linux/io.h`, `linux/init.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/of.h`, `linux/of_irq.h`.
- Detected declarations: `function bridge_w32`, `function bridge_r32`, `function bridge_m32`, `function pcie_w32`, `function pcie_r32`, `function pcie_m32`, `function pcie_phyctrl_set`, `function wait_pciephy_busy`, `function pcie_phy`, `function pci_config_read`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: source implementation candidate.
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.