drivers/pci/controller/pcie-rcar.c
Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-rcar.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/controller/pcie-rcar.c- Extension
.c- Size
- 2890 bytes
- Lines
- 121
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/pci.hpcie-rcar.h
Detected Declarations
function Copyrightfunction rcar_pci_read_regfunction rcar_rmw32function rcar_pcie_wait_for_phyrdyfunction rcar_pcie_wait_for_dlfunction rcar_pcie_set_outboundfunction rcar_pcie_set_inbound
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* PCIe driver for Renesas R-Car SoCs
* Copyright (C) 2014-2020 Renesas Electronics Europe Ltd
*
* Author: Phil Edworthy <phil.edworthy@renesas.com>
*/
#include <linux/delay.h>
#include <linux/pci.h>
#include "pcie-rcar.h"
void rcar_pci_write_reg(struct rcar_pcie *pcie, u32 val, unsigned int reg)
{
writel(val, pcie->base + reg);
}
u32 rcar_pci_read_reg(struct rcar_pcie *pcie, unsigned int reg)
{
return readl(pcie->base + reg);
}
void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
{
unsigned int shift = BITS_PER_BYTE * (where & 3);
u32 val = rcar_pci_read_reg(pcie, where & ~3);
val &= ~(mask << shift);
val |= data << shift;
rcar_pci_write_reg(pcie, val, where & ~3);
}
int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie)
{
unsigned int timeout = 10;
while (timeout--) {
if (rcar_pci_read_reg(pcie, PCIEPHYSR) & PHYRDY)
return 0;
msleep(5);
}
return -ETIMEDOUT;
}
int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
{
unsigned int timeout = 10000;
while (timeout--) {
if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
return 0;
udelay(5);
cpu_relax();
}
return -ETIMEDOUT;
}
void rcar_pcie_set_outbound(struct rcar_pcie *pcie, int win,
struct resource_entry *window)
{
/* Setup PCIe address space mappings for each resource */
struct resource *res = window->res;
resource_size_t res_start;
resource_size_t size;
u32 mask;
rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
/*
* The PAMR mask is calculated in units of 128Bytes, which
* keeps things pretty simple.
*/
size = resource_size(res);
if (size > 128)
mask = (roundup_pow_of_two(size) / SZ_128) - 1;
else
mask = 0x0;
rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
if (res->flags & IORESOURCE_IO)
res_start = pci_pio_to_address(res->start) - window->offset;
else
res_start = res->start - window->offset;
rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
Annotation
- Immediate include surface: `linux/delay.h`, `linux/pci.h`, `pcie-rcar.h`.
- Detected declarations: `function Copyright`, `function rcar_pci_read_reg`, `function rcar_rmw32`, `function rcar_pcie_wait_for_phyrdy`, `function rcar_pcie_wait_for_dl`, `function rcar_pcie_set_outbound`, `function rcar_pcie_set_inbound`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- 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.