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_CAPS 0x00100000U
254#define PCIE_CONF_CLASSREV 2U
256#define PCIE_CONF_CLASSREV_CLASS(w) (((w) >> 24) & 0xFFU)
257#define PCIE_CONF_CLASSREV_SUBCLASS(w) (((w) >> 16) & 0xFFU)
258#define PCIE_CONF_CLASSREV_PROGIF(w) (((w) >> 8) & 0xFFU)
259#define PCIE_CONF_CLASSREV_REV(w) ((w) & 0xFFU)
267#define PCIE_CONF_TYPE 3U
269#define PCIE_CONF_MULTIFUNCTION(w) (((w) & 0x00800000U) != 0U)
270#define PCIE_CONF_TYPE_BRIDGE(w) (((w) & 0x007F0000U) != 0U)
278#define PCIE_CONF_BAR0 4U
279#define PCIE_CONF_BAR1 5U
280#define PCIE_CONF_BAR2 6U
281#define PCIE_CONF_BAR3 7U
282#define PCIE_CONF_BAR4 8U
283#define PCIE_CONF_BAR5 9U
285#define PCIE_CONF_BAR_IO(w) (((w) & 0x00000001U) == 0x00000001U)
286#define PCIE_CONF_BAR_MEM(w) (((w) & 0x00000001U) != 0x00000001U)
287#define PCIE_CONF_BAR_64(w) (((w) & 0x00000006U) == 0x00000004U)
288#define PCIE_CONF_BAR_ADDR(w) ((w) & ~0xfUL)
289#define PCIE_CONF_BAR_IO_ADDR(w) ((w) & ~0x3UL)
290#define PCIE_CONF_BAR_FLAGS(w) ((w) & 0xfUL)
291#define PCIE_CONF_BAR_NONE 0U
293#define PCIE_CONF_BAR_INVAL 0xFFFFFFF0U
294#define PCIE_CONF_BAR_INVAL64 0xFFFFFFFFFFFFFFF0UL
296#define PCIE_CONF_BAR_INVAL_FLAGS(w) \
297 ((((w) & 0x00000006U) == 0x00000006U) || \
298 (((w) & 0x00000006U) == 0x00000002U))
303#define PCIE_BUS_NUMBER 6U
305#define PCIE_BUS_PRIMARY_NUMBER(w) ((w) & 0xffUL)
306#define PCIE_BUS_SECONDARY_NUMBER(w) (((w) >> 8) & 0xffUL)
307#define PCIE_BUS_SUBORDINATE_NUMBER(w) (((w) >> 16) & 0xffUL)
308#define PCIE_SECONDARY_LATENCY_TIMER(w) (((w) >> 24) & 0xffUL)
310#define PCIE_BUS_NUMBER_VAL(prim, sec, sub, lat) \
311 (((prim) & 0xffUL) | \
312 (((sec) & 0xffUL) << 8) | \
313 (((sub) & 0xffUL) << 16) | \
314 (((lat) & 0xffUL) << 24))
319#define PCIE_IO_SEC_STATUS 7U
321#define PCIE_IO_BASE(w) ((w) & 0xffUL)
322#define PCIE_IO_LIMIT(w) (((w) >> 8) & 0xffUL)
323#define PCIE_SEC_STATUS(w) (((w) >> 16) & 0xffffUL)
325#define PCIE_IO_SEC_STATUS_VAL(iob, iol, sec_status) \
326 (((iob) & 0xffUL) | \
327 (((iol) & 0xffUL) << 8) | \
328 (((sec_status) & 0xffffUL) << 16))
330#define PCIE_MEM_BASE_LIMIT 8U
332#define PCIE_MEM_BASE(w) ((w) & 0xffffUL)
333#define PCIE_MEM_LIMIT(w) (((w) >> 16) & 0xffffUL)
335#define PCIE_MEM_BASE_LIMIT_VAL(memb, meml) \
336 (((memb) & 0xffffUL) | \
337 (((meml) & 0xffffUL) << 16))
339#define PCIE_PREFETCH_BASE_LIMIT 9U
341#define PCIE_PREFETCH_BASE(w) ((w) & 0xffffUL)
342#define PCIE_PREFETCH_LIMIT(w) (((w) >> 16) & 0xffffUL)
344#define PCIE_PREFETCH_BASE_LIMIT_VAL(pmemb, pmeml) \
345 (((pmemb) & 0xffffUL) | \
346 (((pmeml) & 0xffffUL) << 16))
348#define PCIE_PREFETCH_BASE_UPPER 10U
350#define PCIE_PREFETCH_LIMIT_UPPER 11U
352#define PCIE_IO_BASE_LIMIT_UPPER 12U
354#define PCIE_IO_BASE_UPPER(w) ((w) & 0xffffUL)
355#define PCIE_IO_LIMIT_UPPER(w) (((w) >> 16) & 0xffffUL)
357#define PCIE_IO_BASE_LIMIT_UPPER_VAL(iobu, iolu) \
358 (((iobu) & 0xffffUL) | \
359 (((iolu) & 0xffffUL) << 16))
368#define PCIE_CONF_INTR 15U
370#define PCIE_CONF_INTR_IRQ(w) ((w) & 0xFFU)
371#define PCIE_CONF_INTR_IRQ_NONE 0xFFU
373#define PCIE_MAX_BUS (0xFFFFFFFF & PCIE_BDF_BUS_MASK)
374#define PCIE_MAX_DEV (0xFFFFFFFF & PCIE_BDF_DEV_MASK)
375#define PCIE_MAX_FUNC (0xFFFFFFFF & PCIE_BDF_FUNC_MASK)
391#define PCIE_IRQ_CONNECT(bdf_p, irq_p, priority_p, \
392 isr_p, isr_param_p, flags_p) \
393 ARCH_PCIE_IRQ_CONNECT(bdf_p, irq_p, priority_p, \
394 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