Commit graph zephyr/drivers/pcie
Author SHA1 Message Date
Khadem Ullah
ff31d01d16 pcie: host: shell: add irq affinity probe
Introduce an interactive multi-vector steering redirection table
probe subcommand to the common PCIe host shell driver layer.

The IRQ subsystem extracts MSI-X registers using pcie_get_cap()
offsets, decoding allocated vector pools and exposing steering
offsets via standard Base Address Register (BAR) bitmasks.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
68945726d4 pcie: host: shell: add hardware offload probe
Introduce a dynamic hardware capability offload telemetry probe
command to the common PCIe host shell subsystem layer.

The capability subsystem automatically resolves and decodes the
Device Capabilities 2 (DEVCAP2) register map via the native
pcie_get_cap() engine. It evaluates bitmasks for Alternative
Routing-ID (ARI) and Single-Root I/O Virtualization (SR-IOV).

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
f4d8fec058 pcie: host: shell: add link capability tracker
Implement the 'pcie link speed <bus:dev.func>' shell subcommand to allow
runtime discovery, interrogation, and bitfield decoding of the PCI Express
Link Capabilities and Link Status capability registers (Cap ID 0x10).

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
c8a42b64c0 pcie: host: shell: add device power gating tool
Implement the 'pcie device state <bus:dev.func> up|down' shell
subcommand to allow runtime interrogation, status tracking, and
bit-level state mutation of the standard PCI Power Management
Capability block (Cap ID 0x01).

The command scans the traditional capability linked list within
traditional configuration space to locate the power block base offset.
It utilizes a read-modify-write routine targeting the Power Management
Control/Status Register (PMCSR) to transition the underlying hardware
transceiver between the D0 Fully Operational state (00b) and the
D3hot Low Energy Suspend state (11b).

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
6a208fe12a pcie: host: shell: add link margining tracker
Implement the 'pcie link margin <bus:dev.func>' shell subcommand to
allow runtime discovery, interrogation, and bitfield decoding of the
PCI Express Lane Margining at Receiver extended capability structures
(Extended Cap ID 0x001A).

The command dynamically traverses the PCIe Extended Configuration Space
(offsets >= 0x100) to isolate the margining block base. It reads the
underlying hardware registers and unpacks the 16-bit Port Capabilities
and Control fields to report maximum voltage/timing steps, total link
widths, and independent per-lane software execution controls. It also
polls active receiver signal status flags and bounds tracking limit
thresholds.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
a6ed0b27d5 pcie: host: shell: add aer telemetry command
Implement the 'pcie aer status <bus:dev.func>' shell subcommand to allow
runtime interrogation and decoding of the PCI Express Advanced Error
Reporting (AER) capability registers.

The command handles hardware traversal across the PCIe Extended Capability
Space (offsets >= 0x100) to dynamically isolate the AER capability block
and read configuration space registers. It decodes uncorrectable fatal
and non-fatal register flags—including Link Training errors, Data Link
Protocol errors, Poisoned TLPs, and Flow Control Protocol breakdown states—
as well as correctable signal layer degradation deviations.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
b13273fb88 pcie: host: shell: add irq status probe
This patch introduces a `pcie irq status` sub-command to the common
PCIe host shell subsystem layer.

The utility decodes legacy INTx pin and line metrics, structures real-time
traversals across standard device capabilities loops, and maps standard
MSI (Cap ID 0x05) and MSI-X (Cap ID 0x11) status parameters. The resulting
trace logs track active configuration states, vector capabilities, target
message address fields, and MSI-X table sizing dimensions to simplify
embedded hardware interrupt triage tasks.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
463c798a22 pcie: host: shell: add speed retraining tool
This patch introduces a `pcie link set_speed` sub-command utility
to the PCIe host shell subsystem layer.

The tool locates the native PCI Express Capability structure (Cap ID
0x10), updates the Target Link Speed bitfield inside the Link Control
2 register, and issues a Retrain Link command override to the physical
layer. This enables developers to interactively scale bus power and
performance profiles directly from the command line window.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
a02b7aea0d pcie: host: shell: add resource decoder tool
This patch introduces a standalone root-level shell command utility
named `pcie_resource` to decode and evaluate PCIe Base Address Register
(BAR) spaces dynamically from the serial console interface.

The command operates within its own dedicated top-level namespace to
prevent redefinition conflicts with existing shell subsystem tables. It
iterates through standard configuration offsets (BAR0 to BAR5), executes
the standard PCI write-all-1s probing algorithm to calculate resource
footprints, and decodes aperture characteristics natively. The output
provides human-readable size geometry metrics, 32-bit vs. 64-bit bounds,
prefetchable memory attributes, and I/O port address space layouts.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
6744ef90a9 pcie: host: shell: add scan masking engine
Introduce a dynamic software-based masking registry table to
the common PCIe host subsystem layer via the shell.

The masking subsystem features an explicit hook callback pointer that can
be runtime-registered via dynamic terminal command invocations. When
active, the core `scan_dev` device bus enumerator intercepts the BDF
coordinate before running the physical hardware registers discovery
sweeps. If a target slot matches a registered ignore block, it is
gracefully bypassed.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Khadem Ullah
508f80e7e5 drivers: pcie: host: add configuration space write utility to shell
This patch introduces an interactive `pcie write` sub-command to
the native PCIe kernel shell subsystem layer.

The utility accepts string arguments from the terminal prompt,
checks for link responsiveness via PCIE_CONF_ID to prevent
unmapped interconnect bus lockups, and invokes the low-level
`pcie_conf_write` function directly over the target configuration
space index parameters. An immediate read-back verification
check is executed to confirm latch status stability.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-08-30 16:42:29 -04:00
Li Wan
606778871a drivers: pcie: host: add Type-1 prefetch/MEM64 bridge windows
Type-1 enumeration left prefetchable memory as TODO, so 64-bit BARs
behind a PCI-to-PCI bridge were not forwarded. Program prefetch
base/limit (and upper 32 bits) like the existing non-prefetch MEM
window.

Also advance the ECAM allocation offset when region_get_allocate_base()
aligns a Type-1 window, so subsequent BAR allocations start at the
aligned base instead of overlapping the unaligned remainder.

Signed-off-by: Li Wan <wanli@kylinos.cn>
2026-08-23 14:42:50 -04:00
Khadem Ullah
ed0133f776 drivers: pcie: controller: ecam: validate raw BDF token boundaries
This patch introduces strict __ASSERT parameter validation gates to
the primary configuration read and write handlers within the ECAM
host bridge controller driver.

On platforms mapping multi-bus topologies, passing an out-of-bounds
bus index variable can cause a bit-field overflow and boundary
spillage, shifting overflow bits into upper address coordinates. The
driver then executes memory transactions over unallocated regions
inside the ECAM window, causing the hardware to return dummy data
blocks (0xFFFFFFFF) or leak address spaces silently.

Checking the raw bits before any bitwise shifts or extraction macros
are applied halts out-of-bounds parameter execution at the lowest
hardware choke point without interfering with multi-bus hierarchies
conforming to the PCI Express Specification.

Signed-off-by: Khadem Ullah <khadem.systems@gmail.com>
2026-07-27 09:21:22 +02:00
TOKITA Hiroshi
b071110a8a drivers: pcie: Format iProc endpoint driver
Formatting with clang-format.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2026-07-09 18:02:38 -04:00
TOKITA Hiroshi
4f14a7e119 drivers: pcie: Enable iProc endpoint from devicetree
Enable the iProc endpoint driver by default when the corresponding
devicetree node is present.

Drop the now-redundant board defconfig selections from the bcm958402m2
variants.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2026-07-09 18:02:38 -04:00
TOKITA Hiroshi
4f69eb584b dts: pcie: epdpoint: Add brcm,iproc-pcie-ep-v2
ADd `brcm,iproc-pcie-ep-v2` to represent the version difference
with `brcm,iproc-pcie-ep`.

This property can replace the CONFIG_PCIE_EP_IPROC_V2.
So, we removed it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2026-07-09 18:02:38 -04:00
Bindu S
9f72d59f24 drivers: pcie: add support for scanning additional PCIe buses
Add support for scanning PCIe buses beyond bus 0 using a devicetree
property. Some platforms have PCIe devices on
non-zero buses that are not reachable through bridge
enumeration from bus 0.

Signed-off-by: Bindu S <bindu.s@intel.com>
2026-07-02 12:58:15 +01:00
Fin Maaß
4ea5a11c63 pcie: move pcie ecam controller to controllers
move pcie ecam controller to controllers.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-21 17:43:51 +01:00
Fin Maaß
3b8d015b88 pcie: add missing copyright and license infos
add missing copyright and license infos.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-21 17:43:51 +01:00
Fin Maaß
f70515e69c pcie: fix type casting
Without this we will get a warning on 32 bit
platforms.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-17 15:56:48 +02:00
Fin Maaß
662f59c675 pcie: use z specifier when used on size_t
use z specifier when used on size_t,
otherwise we will get build warnings.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-17 15:56:48 +02:00
Fin Maaß
4247c8787a pcie: dependency for PCIE_CONTROLLER
When CONFIG_PCIE_CONTROLLER is enabled,
the chosen zephyr,pcie-controller also needs to
be enabled.

Also on platforms where this chosen is set the
pcie controller is needed for the pcie to work,
therefor enable it by default.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-17 12:37:16 +01:00
Fin Maaß
85917d8086 drivers: pcie: enable PCIE_ECAM based on dt
enable PCIE_ECAM based on dt.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-17 12:37:16 +01:00
Pisit Sawangvonganan
f5512a6907 drivers: fix typo in (mipi_dbi, misc, mm, mspi, pcie, ptp_clock, pwm)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/mipi_dbi`
- `drivers/misc`
- `drivers/mm`
- `drivers/mspi`
- `drivers/pcie`
- `drivers/ptp_clock`
- `drivers/pwm`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-03-27 20:21:24 -04:00
Josuah Demangeon
30950b888d style: drivers: sort Kconfig and CMake includes
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Christian Mauderer
144895dc8e pcie: controller: Use device for register accesses
Use the device in register accesses. This allows to use this code with
multiple controllers instead of only the "chosen" one.

Signed-off-by: Christian Mauderer <christian.mauderer@embedded-brains.de>
2025-08-14 10:44:11 +01:00
Benjamin Cabé
7a663fbf99 drivers: pcie: shell: add missing const qualifiers
Ensure string conversion tables end up in flash.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-17 07:24:52 +02:00
Junho Lee
5edfd02691 drivers: pcie: add brcmstb pcie controller driver
Add PCIe controller driver for brcmstb, required by Raspberry Pi 5.

Signed-off-by: Junho Lee <junho@tsnlab.com>
2025-01-08 21:03:03 +01:00
Pieter De Gendt
a7756f20d1 drivers: pcie: host: Place API into iterable section
Add wrapper DEVICE_API macro to all pcie_ctrl_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-03 13:06:31 +01:00
Pieter De Gendt
6cc18fc9c1 drivers: pcie: endpoint: Place API into iterable section
Add wrapper DEVICE_API macro to all bt_hci_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-03 13:06:21 +01:00
Daniel Leung
552e29790d kernel: mm: rename z_phys_un/map to k_mem_*_phys_bare
This renames z_phys_map() and z_phys_unmap() to
k_mem_map_phys_bare() and k_mem_unmap_phys_bare()
respectively. This is part of the series to move memory
management functions away from the z_ namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Flavio Ceolin
8cd1ab8896 drivers: pcie: Remove deprecated pcie_bdf_lookup
pcie_bdf_lookup() was deprecated before 3.3 release. Time to remove
it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-17 09:30:04 +02:00
Flavio Ceolin
f4aefc281b drivers: pcie: Remove deprecated pcie_probe
pcie_probe() was deprecated before 3.3 release. Time to remove it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-17 09:30:04 +02:00
Hess Nathan
958a4505bd coding guidelines: comply with MISRA Rule 12.1.
-added parentheses verifying lack of ambiguities

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-05-13 16:05:53 -04:00
Najumon B.A
34a2fbfba1 drivers: pci: update prt retrieve based on pnp id
update prt retrieve based on acpi pnp id instead of acpi device
path/name

Signed-off-by: Najumon B.A <najumon.ba@intel.com>
2024-01-31 15:03:06 +01:00
Andrei Emeltchenko
fc8b53bf10 drivers: pcie: Read register before actual usage
Move reading PCIE_CONF_CMDSTAT before actual usage. There are four
return branches before value is used.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-12-28 12:07:30 +00:00
Andrei Emeltchenko
4a17446636 drivers: pcie: Remove magic number
Use definitions instead of magic numbers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-12-28 12:07:30 +00:00
Najumon B.A
c146833fc8 drivers: pcie: fix for mmio size region calculation
I/O or memory decoding should be disabled via the command register
before sizing BAR for calculation MMIO size

Signed-off-by: Najumon B.A <najumon.ba@intel.com>
2023-12-22 09:52:40 +01:00
Henrik Brix Andersen
c0c8952739 shell: do not enable subsystem/driver shell modules by default
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.

The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.

This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-20 09:21:40 +01:00
Daniel Leung
c972ef1a0f kernel: mm: move kernel mm functions under kernel includes
This moves the k_* memory management functions from sys/ into
kernel/ includes, as there are kernel public APIs. The z_*
functions are further separated into the kernel internal
header directory.

Also made a quick change to doxygen to group sys_mem_* into
the OS Memory Management group so they will appear in doc.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-20 09:19:14 +01:00
Najumon B.A
e89b005368 drivers: pcie: add config for enable PRT
add config support for enable IRQ information retrieve via
ACPI PRT (PCI Routing Table)

Signed-off-by: Najumon B.A <najumon.ba@intel.com>
2023-10-06 10:40:14 +02:00
Gerard Marull-Paretas
1b361f9832 drivers: pcie: host: add missing init.h
File was using SYS_INIT from init.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 12:20:31 +01:00
Daniel Leung
80f079a2cd pcie: host: guard include of ACPICA header file
This puts a ifdef guard around the inclusion of ACPICA header
file. The ACPICA module is not active unless CONFIG_ACPI is
also enabled so we should not be using that header without
CONFIG_ACPI also being enabled.

This was discovered by Coverity.

Fixes #60484

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-24 09:07:45 +00:00
Fabio Baltieri
5ea3f9a24e drivers: pcie: initialize after interrupt controllers
PCIe devices refer to interrupt nodes, but are initialized with the same
priority, making the sequence depending on the linking order. Add a new
symbol and set it to one unit after intc to ensure that the
initialization sequence is stable.

Found with:

west build -p -b qemu_cortex_a53 \
	samples/drivers/virtualization/ivshmem/doorbell \
	-DCONFIG_CHECK_INIT_PRIORITIES=y
...
ERROR: /soc/pcie@4010000000 PRE_KERNEL_1 40 <
	/soc/interrupt-controller@8000000/its@8080000 POST_KERNEL 40

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-12 09:25:35 +02:00
Najumon Ba
a72271f27f drivers: pcie: add prt support for pci legacy interrupt
add support for obtain irq number from pci irq routing table

Signed-off-by: Najumon Ba <najumon.ba@intel.com>
2023-06-30 17:53:01 +03:00
Tomasz Bursztyka
257deba9c2 drivers/pcie: Fix copyright year
Trivial update that was missed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-06-21 13:57:01 -04:00
Tomasz Bursztyka
0c9e762cee drivers/pcie: Add VC/TC mapping and VC enablement
Note that only the the hardware round robin port arbitration capability
is being used.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-06-20 14:01:43 -04:00
Tomasz Bursztyka
6a1e19cf86 drivers/pcie: Add virtual channel details output to shell module
Helps to see how many VCs are supported and the related ressources.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-06-20 14:01:43 -04:00
Tomasz Bursztyka
5e4e6bc486 drivers/pcie: Add Virtual Channel configuration support
Basic support of VC capability, where a driver can enable VC and map its
traffic classes.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-06-20 14:01:43 -04:00
Tomasz Bursztyka
d39645a206 drivers/pcie: Add capabilities output to shell module
This help to decipher PCIe capabilities supported by each listed device.
Shown only on a selected device and not on the general list.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2023-06-17 07:58:41 -04:00