arch/mips/pci/pcie-octeon.c
Source file repositories/reference/linux-study-clean/arch/mips/pci/pcie-octeon.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/pci/pcie-octeon.c- Extension
.c- Size
- 68395 bytes
- Lines
- 2095
- 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/kernel.hlinux/init.hlinux/pci.hlinux/interrupt.hlinux/time.hlinux/delay.hlinux/moduleparam.hasm/octeon/octeon.hasm/octeon/cvmx-npei-defs.hasm/octeon/cvmx-pciercx-defs.hasm/octeon/cvmx-pescx-defs.hasm/octeon/cvmx-pexp-defs.hasm/octeon/cvmx-pemx-defs.hasm/octeon/cvmx-dpi-defs.hasm/octeon/cvmx-sli-defs.hasm/octeon/cvmx-sriox-defs.hasm/octeon/cvmx-helper-errata.hasm/octeon/pci-octeon.h
Detected Declarations
function cvmx_pcie_get_io_base_addressfunction cvmx_pcie_get_io_base_addressfunction cvmx_pcie_get_mem_base_addressfunction cvmx_pcie_get_mem_base_addressfunction cvmx_pcie_cfgx_readfunction cvmx_pcie_cfgx_writefunction __cvmx_pcie_build_config_addrfunction cvmx_pcie_config_read8function cvmx_pcie_config_read16function cvmx_pcie_config_read32function cvmx_pcie_config_write8function cvmx_pcie_config_write16function cvmx_pcie_config_write32function __cvmx_pcie_rc_initialize_config_spacefunction __cvmx_pcie_rc_initialize_link_gen1function __cvmx_increment_bafunction hostfunction Orderingfunction OCTEON_IS_MODELfunction __cvmx_pcie_rc_initialize_link_gen2function hostfunction hostfunction octeon_pcie_pcibios_map_irqfunction set_cfg_read_retryfunction disable_cfg_read_retryfunction is_cfg_retryfunction octeon_pcie_read_configfunction OCTEON_IS_MODELfunction octeon_pcie0_read_configfunction octeon_pcie1_read_configfunction octeon_dummy_read_configfunction octeon_pcie_write_configfunction octeon_pcie0_write_configfunction octeon_pcie1_write_configfunction octeon_dummy_write_configfunction device_needs_bus_num_warfunction octeon_pcie_setupfunction OCTEON_IS_MODEL
Annotated Snippet
if (cvmx_get_cycle() - start_cycle > 2 * octeon_get_clock_rate()) {
cvmx_dprintf("PCIe: Port %d link timeout\n", pcie_port);
return -1;
}
__delay(10000);
pciercx_cfg032.u32 = cvmx_pcie_cfgx_read(pcie_port, CVMX_PCIERCX_CFG032(pcie_port));
} while (pciercx_cfg032.s.dlla == 0);
/* Clear all pending errors */
cvmx_write_csr(CVMX_PEXP_NPEI_INT_SUM, cvmx_read_csr(CVMX_PEXP_NPEI_INT_SUM));
/*
* Update the Replay Time Limit. Empirically, some PCIe
* devices take a little longer to respond than expected under
* load. As a workaround for this we configure the Replay Time
* Limit to the value expected for a 512 byte MPS instead of
* our actual 256 byte MPS. The numbers below are directly
* from the PCIe spec table 3-4.
*/
pciercx_cfg448.u32 = cvmx_pcie_cfgx_read(pcie_port, CVMX_PCIERCX_CFG448(pcie_port));
switch (pciercx_cfg032.s.nlw) {
case 1: /* 1 lane */
pciercx_cfg448.s.rtl = 1677;
break;
case 2: /* 2 lanes */
pciercx_cfg448.s.rtl = 867;
break;
case 4: /* 4 lanes */
pciercx_cfg448.s.rtl = 462;
break;
case 8: /* 8 lanes */
pciercx_cfg448.s.rtl = 258;
break;
}
cvmx_pcie_cfgx_write(pcie_port, CVMX_PCIERCX_CFG448(pcie_port), pciercx_cfg448.u32);
return 0;
}
static void __cvmx_increment_ba(union cvmx_sli_mem_access_subidx *pmas)
{
if (OCTEON_IS_MODEL(OCTEON_CN68XX))
pmas->cn68xx.ba++;
else
pmas->s.ba++;
}
/**
* Initialize a PCIe gen 1 port for use in host(RC) mode. It doesn't
* enumerate the bus.
*
* @pcie_port: PCIe port to initialize
*
* Returns Zero on success
*/
static int __cvmx_pcie_rc_initialize_gen1(int pcie_port)
{
int i;
int base;
u64 addr_swizzle;
union cvmx_ciu_soft_prst ciu_soft_prst;
union cvmx_pescx_bist_status pescx_bist_status;
union cvmx_pescx_bist_status2 pescx_bist_status2;
union cvmx_npei_ctl_status npei_ctl_status;
union cvmx_npei_mem_access_ctl npei_mem_access_ctl;
union cvmx_npei_mem_access_subidx mem_access_subid;
union cvmx_npei_dbg_data npei_dbg_data;
union cvmx_pescx_ctl_status2 pescx_ctl_status2;
union cvmx_pciercx_cfg032 pciercx_cfg032;
union cvmx_npei_bar1_indexx bar1_index;
retry:
/*
* Make sure we aren't trying to setup a target mode interface
* in host mode.
*/
npei_ctl_status.u64 = cvmx_read_csr(CVMX_PEXP_NPEI_CTL_STATUS);
if ((pcie_port == 0) && !npei_ctl_status.s.host_mode) {
cvmx_dprintf("PCIe: Port %d in endpoint mode\n", pcie_port);
return -1;
}
/*
* Make sure a CN52XX isn't trying to bring up port 1 when it
* is disabled.
*/
if (OCTEON_IS_MODEL(OCTEON_CN52XX)) {
npei_dbg_data.u64 = cvmx_read_csr(CVMX_PEXP_NPEI_DBG_DATA);
if ((pcie_port == 1) && npei_dbg_data.cn52xx.qlm0_link_width) {
cvmx_dprintf("PCIe: ERROR: cvmx_pcie_rc_initialize() called on port1, but port1 is disabled\n");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/pci.h`, `linux/interrupt.h`, `linux/time.h`, `linux/delay.h`, `linux/moduleparam.h`, `asm/octeon/octeon.h`.
- Detected declarations: `function cvmx_pcie_get_io_base_address`, `function cvmx_pcie_get_io_base_address`, `function cvmx_pcie_get_mem_base_address`, `function cvmx_pcie_get_mem_base_address`, `function cvmx_pcie_cfgx_read`, `function cvmx_pcie_cfgx_write`, `function __cvmx_pcie_build_config_addr`, `function cvmx_pcie_config_read8`, `function cvmx_pcie_config_read16`, `function cvmx_pcie_config_read32`.
- 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.