7#ifndef ZEPHYR_INCLUDE_DRIVERS_PCIE_PCIE_H_
8#define ZEPHYR_INCLUDE_DRIVERS_PCIE_PCIE_H_
98 unsigned int bar_index,
127#ifndef CONFIG_PCIE_CONTROLLER
197 unsigned int priority,
198 void (*routine)(
const void *parameter),
199 const void *parameter,
206#define PCIE_CONF_CAPPTR 13U
207#define PCIE_CONF_CAPPTR_FIRST(w) (((w) >> 2) & 0x3FU)
214#define PCIE_CONF_CAP_ID(w) ((w) & 0xFFU)
215#define PCIE_CONF_CAP_NEXT(w) (((w) >> 10) & 0x3FU)
221#define PCIE_CONF_EXT_CAPPTR 64U
228#define PCIE_CONF_EXT_CAP_ID(w) ((w) & 0xFFFFU)
229#define PCIE_CONF_EXT_CAP_VER(w) (((w) >> 16) & 0xFU)
230#define PCIE_CONF_EXT_CAP_NEXT(w) (((w) >> 20) & 0xFFFU)
236#define PCIE_CONF_ID 0U
242#define PCIE_CONF_CMDSTAT 1U
244#define PCIE_CONF_CMDSTAT_IO 0x00000001U
245#define PCIE_CONF_CMDSTAT_MEM 0x00000002U
246#define PCIE_CONF_CMDSTAT_MASTER 0x00000004U
247#define PCIE_CONF_CMDSTAT_INTERRUPT 0x00080000U
248#define PCIE_CONF_CMDSTAT_CAPS 0x00100000U
255#define PCIE_CONF_CLASSREV 2U
257#define PCIE_CONF_CLASSREV_CLASS(w) (((w) >> 24) & 0xFFU)
258#define PCIE_CONF_CLASSREV_SUBCLASS(w) (((w) >> 16) & 0xFFU)
259#define PCIE_CONF_CLASSREV_PROGIF(w) (((w) >> 8) & 0xFFU)
260#define PCIE_CONF_CLASSREV_REV(w) ((w) & 0xFFU)
268#define PCIE_CONF_TYPE 3U
270#define PCIE_CONF_MULTIFUNCTION(w) (((w) & 0x00800000U) != 0U)
271#define PCIE_CONF_TYPE_BRIDGE(w) (((w) & 0x007F0000U) != 0U)
279#define PCIE_CONF_BAR0 4U
280#define PCIE_CONF_BAR1 5U
281#define PCIE_CONF_BAR2 6U
282#define PCIE_CONF_BAR3 7U
283#define PCIE_CONF_BAR4 8U
284#define PCIE_CONF_BAR5 9U
286#define PCIE_CONF_BAR_IO(w) (((w) & 0x00000001U) == 0x00000001U)
287#define PCIE_CONF_BAR_MEM(w) (((w) & 0x00000001U) != 0x00000001U)
288#define PCIE_CONF_BAR_64(w) (((w) & 0x00000006U) == 0x00000004U)
289#define PCIE_CONF_BAR_ADDR(w) ((w) & ~0xfUL)
290#define PCIE_CONF_BAR_IO_ADDR(w) ((w) & ~0x3UL)
291#define PCIE_CONF_BAR_FLAGS(w) ((w) & 0xfUL)
292#define PCIE_CONF_BAR_NONE 0U
294#define PCIE_CONF_BAR_INVAL 0xFFFFFFF0U
295#define PCIE_CONF_BAR_INVAL64 0xFFFFFFFFFFFFFFF0UL
297#define PCIE_CONF_BAR_INVAL_FLAGS(w) \
298 ((((w) & 0x00000006U) == 0x00000006U) || \
299 (((w) & 0x00000006U) == 0x00000002U))
304#define PCIE_BUS_NUMBER 6U
306#define PCIE_BUS_PRIMARY_NUMBER(w) ((w) & 0xffUL)
307#define PCIE_BUS_SECONDARY_NUMBER(w) (((w) >> 8) & 0xffUL)
308#define PCIE_BUS_SUBORDINATE_NUMBER(w) (((w) >> 16) & 0xffUL)
309#define PCIE_SECONDARY_LATENCY_TIMER(w) (((w) >> 24) & 0xffUL)
311#define PCIE_BUS_NUMBER_VAL(prim, sec, sub, lat) \
312 (((prim) & 0xffUL) | \
313 (((sec) & 0xffUL) << 8) | \
314 (((sub) & 0xffUL) << 16) | \
315 (((lat) & 0xffUL) << 24))
320#define PCIE_IO_SEC_STATUS 7U
322#define PCIE_IO_BASE(w) ((w) & 0xffUL)
323#define PCIE_IO_LIMIT(w) (((w) >> 8) & 0xffUL)
324#define PCIE_SEC_STATUS(w) (((w) >> 16) & 0xffffUL)
326#define PCIE_IO_SEC_STATUS_VAL(iob, iol, sec_status) \
327 (((iob) & 0xffUL) | \
328 (((iol) & 0xffUL) << 8) | \
329 (((sec_status) & 0xffffUL) << 16))
331#define PCIE_MEM_BASE_LIMIT 8U
333#define PCIE_MEM_BASE(w) ((w) & 0xffffUL)
334#define PCIE_MEM_LIMIT(w) (((w) >> 16) & 0xffffUL)
336#define PCIE_MEM_BASE_LIMIT_VAL(memb, meml) \
337 (((memb) & 0xffffUL) | \
338 (((meml) & 0xffffUL) << 16))
340#define PCIE_PREFETCH_BASE_LIMIT 9U
342#define PCIE_PREFETCH_BASE(w) ((w) & 0xffffUL)
343#define PCIE_PREFETCH_LIMIT(w) (((w) >> 16) & 0xffffUL)
345#define PCIE_PREFETCH_BASE_LIMIT_VAL(pmemb, pmeml) \
346 (((pmemb) & 0xffffUL) | \
347 (((pmeml) & 0xffffUL) << 16))
349#define PCIE_PREFETCH_BASE_UPPER 10U
351#define PCIE_PREFETCH_LIMIT_UPPER 11U
353#define PCIE_IO_BASE_LIMIT_UPPER 12U
355#define PCIE_IO_BASE_UPPER(w) ((w) & 0xffffUL)
356#define PCIE_IO_LIMIT_UPPER(w) (((w) >> 16) & 0xffffUL)
358#define PCIE_IO_BASE_LIMIT_UPPER_VAL(iobu, iolu) \
359 (((iobu) & 0xffffUL) | \
360 (((iolu) & 0xffffUL) << 16))
369#define PCIE_CONF_INTR 15U
371#define PCIE_CONF_INTR_IRQ(w) ((w) & 0xFFU)
372#define PCIE_CONF_INTR_IRQ_NONE 0xFFU
374#define PCIE_MAX_BUS (0xFFFFFFFFU & PCIE_BDF_BUS_MASK)
375#define PCIE_MAX_DEV (0xFFFFFFFFU & PCIE_BDF_DEV_MASK)
376#define PCIE_MAX_FUNC (0xFFFFFFFFU & PCIE_BDF_FUNC_MASK)
392#define PCIE_IRQ_CONNECT(bdf_p, irq_p, priority_p, \
393 isr_p, isr_param_p, flags_p) \
394 ARCH_PCIE_IRQ_CONNECT(bdf_p, irq_p, priority_p, \
395 isr_p, isr_param_p, flags_p)
ZTEST_BMEM int index[(3)]
Definition: main.c:32
uint32_t pcie_conf_read(pcie_bdf_t bdf, unsigned int reg)
Read a 32-bit word from an endpoint's configuration space.
bool pcie_connect_dynamic_irq(pcie_bdf_t bdf, unsigned int irq, unsigned int priority, void(*routine)(const void *parameter), const void *parameter, uint32_t flags)
Dynamically connect a PCIe endpoint IRQ to an ISR handler.
void pcie_set_cmd(pcie_bdf_t bdf, uint32_t bits, bool on)
Set or reset bits in the endpoint command/status register.
bool pcie_probe(pcie_bdf_t bdf, pcie_id_t id)
Probe for the presence of a PCI(e) endpoint.
uint32_t pcie_id_t
A unique PCI(e) identifier (vendor ID, device ID).
Definition: pcie.h:37
bool pcie_get_mbar(pcie_bdf_t bdf, unsigned int bar_index, struct pcie_mbar *mbar)
Get the MBAR at a specific BAR index.
void pcie_conf_write(pcie_bdf_t bdf, unsigned int reg, uint32_t data)
Write a 32-bit word to an endpoint's configuration space.
uint32_t pcie_get_cap(pcie_bdf_t bdf, uint32_t cap_id)
Find a PCI(e) capability in an endpoint's configuration space.
uint32_t pcie_get_ext_cap(pcie_bdf_t bdf, uint32_t cap_id)
Find an Extended PCI(e) capability in an endpoint's configuration space.
uint32_t pcie_bdf_t
A unique PCI(e) endpoint (bus, device, function).
Definition: pcie.h:27
pcie_bdf_t pcie_bdf_lookup(pcie_id_t id)
Look up the BDF based on PCI(e) vendor & device ID.
unsigned int pcie_alloc_irq(pcie_bdf_t bdf)
Allocate an IRQ for an endpoint.
bool pcie_probe_mbar(pcie_bdf_t bdf, unsigned int index, struct pcie_mbar *mbar)
Probe the nth MMIO address assigned to an endpoint.
unsigned int pcie_get_irq(pcie_bdf_t bdf)
Return the IRQ assigned by the firmware/board to an endpoint.
void pcie_irq_enable(pcie_bdf_t bdf, unsigned int irq)
Enable the PCI(e) endpoint to generate the specified IRQ.
flags
Definition: http_parser.h:131
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
size_t size
Definition: pcie.h:41
uintptr_t phys_addr
Definition: pcie.h:40
static fdata_t data[2]
Definition: test_fifo_contexts.c:15