Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
pcie_ep.h
Go to the documentation of this file.
1
7/*
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Copyright 2020 Broadcom
11 *
12 */
13#ifndef ZEPHYR_INCLUDE_DRIVERS_PCIE_EP_H_
14#define ZEPHYR_INCLUDE_DRIVERS_PCIE_EP_H_
15
16#include <device.h>
17#include <init.h>
18#include <kernel.h>
19#include <stdint.h>
20
25};
26
31};
32
36};
37
43};
44
57typedef void (*pcie_ep_reset_callback_t)(void *arg);
58
60 int (*conf_read)(const struct device *dev, uint32_t offset,
61 uint32_t *data);
62 void (*conf_write)(const struct device *dev, uint32_t offset,
64 int (*map_addr)(const struct device *dev, uint64_t pcie_addr,
65 uint64_t *mapped_addr, uint32_t size,
66 enum pcie_ob_mem_type ob_mem_type);
67 void (*unmap_addr)(const struct device *dev, uint64_t mapped_addr);
68 int (*raise_irq)(const struct device *dev,
69 enum pci_ep_irq_type irq_type,
70 uint32_t irq_num);
71 int (*register_reset_cb)(const struct device *dev,
72 enum pcie_reset reset,
73 pcie_ep_reset_callback_t cb, void *arg);
74 int (*dma_xfer)(const struct device *dev, uint64_t mapped_addr,
75 uintptr_t local_addr, uint32_t size,
76 enum xfer_direction dir);
77};
78
91static inline int pcie_ep_conf_read(const struct device *dev,
92 uint32_t offset, uint32_t *data)
93{
94 const struct pcie_ep_driver_api *api =
95 (const struct pcie_ep_driver_api *)dev->api;
96
97 return api->conf_read(dev, offset, data);
98}
99
112static inline void pcie_ep_conf_write(const struct device *dev,
113 uint32_t offset, uint32_t data)
114{
115 const struct pcie_ep_driver_api *api =
116 (const struct pcie_ep_driver_api *)dev->api;
117
118 api->conf_write(dev, offset, data);
119}
120
146static inline int pcie_ep_map_addr(const struct device *dev,
147 uint64_t pcie_addr,
148 uint64_t *mapped_addr, uint32_t size,
149 enum pcie_ob_mem_type ob_mem_type)
150{
151 const struct pcie_ep_driver_api *api =
152 (const struct pcie_ep_driver_api *)dev->api;
153
154 return api->map_addr(dev, pcie_addr, mapped_addr, size, ob_mem_type);
155}
156
170static inline void pcie_ep_unmap_addr(const struct device *dev,
171 uint64_t mapped_addr)
172{
173 const struct pcie_ep_driver_api *api =
174 (const struct pcie_ep_driver_api *)dev->api;
175
176 api->unmap_addr(dev, mapped_addr);
177}
178
191static inline int pcie_ep_raise_irq(const struct device *dev,
192 enum pci_ep_irq_type irq_type,
193 uint32_t irq_num)
194{
195 const struct pcie_ep_driver_api *api =
196 (const struct pcie_ep_driver_api *)dev->api;
197 return api->raise_irq(dev, irq_type, irq_num);
198}
199
215static inline int pcie_ep_register_reset_cb(const struct device *dev,
216 enum pcie_reset reset,
218 void *arg)
219{
220 const struct pcie_ep_driver_api *api =
221 (const struct pcie_ep_driver_api *)dev->api;
222
223 if (api->register_reset_cb) {
224 return api->register_reset_cb(dev, reset, cb, arg);
225 }
226
227 return -ENOTSUP;
228}
229
250static inline int pcie_ep_dma_xfer(const struct device *dev,
251 uint64_t mapped_addr,
252 uintptr_t local_addr, uint32_t size,
253 const enum xfer_direction dir)
254{
255 const struct pcie_ep_driver_api *api =
256 (const struct pcie_ep_driver_api *)dev->api;
257
258 if (api->dma_xfer) {
259 return api->dma_xfer(dev, mapped_addr, local_addr, size, dir);
260 }
261
262 return -ENOTSUP;
263}
264
283int pcie_ep_xfer_data_memcpy(const struct device *dev, uint64_t pcie_addr,
284 uintptr_t *local_addr, uint32_t size,
285 enum pcie_ob_mem_type ob_mem_type,
286 enum xfer_direction dir);
287
305int pcie_ep_xfer_data_dma(const struct device *dev, uint64_t pcie_addr,
306 uintptr_t *local_addr, uint32_t size,
307 enum pcie_ob_mem_type ob_mem_type,
308 enum xfer_direction dir);
309
310#endif /* ZEPHYR_INCLUDE_DRIVERS_PCIE_EP_H_ */
void
Definition: eswifi_shell.c:15
#define ENOTSUP
Definition: errno.h:115
static void pcie_ep_unmap_addr(const struct device *dev, uint64_t mapped_addr)
Remove mapping to PCIe outbound region.
Definition: pcie_ep.h:170
static int pcie_ep_register_reset_cb(const struct device *dev, enum pcie_reset reset, pcie_ep_reset_callback_t cb, void *arg)
Register callback function for reset interrupts.
Definition: pcie_ep.h:215
pcie_reset
Definition: pcie_ep.h:38
@ PCIE_RESET_MAX
Definition: pcie_ep.h:42
@ PCIE_PERST
Definition: pcie_ep.h:39
@ PCIE_FLR
Definition: pcie_ep.h:41
@ PCIE_PERST_INB
Definition: pcie_ep.h:40
static int pcie_ep_map_addr(const struct device *dev, uint64_t pcie_addr, uint64_t *mapped_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type)
Map a host memory buffer to PCIe outbound region.
Definition: pcie_ep.h:146
static int pcie_ep_dma_xfer(const struct device *dev, uint64_t mapped_addr, uintptr_t local_addr, uint32_t size, const enum xfer_direction dir)
Data transfer between mapped Host memory and device memory with "System DMA". The term "System DMA" i...
Definition: pcie_ep.h:250
static void pcie_ep_conf_write(const struct device *dev, uint32_t offset, uint32_t data)
Write PCIe EP configuration space.
Definition: pcie_ep.h:112
pcie_ob_mem_type
Definition: pcie_ep.h:21
@ PCIE_OB_HIGHMEM
Definition: pcie_ep.h:24
@ PCIE_OB_ANYMEM
Definition: pcie_ep.h:22
@ PCIE_OB_LOWMEM
Definition: pcie_ep.h:23
pci_ep_irq_type
Definition: pcie_ep.h:27
@ PCIE_EP_IRQ_MSI
Definition: pcie_ep.h:29
@ PCIE_EP_IRQ_MSIX
Definition: pcie_ep.h:30
@ PCIE_EP_IRQ_LEGACY
Definition: pcie_ep.h:28
int pcie_ep_xfer_data_memcpy(const struct device *dev, uint64_t pcie_addr, uintptr_t *local_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type, enum xfer_direction dir)
Data transfer using memcpy.
xfer_direction
Definition: pcie_ep.h:33
@ DEVICE_TO_HOST
Definition: pcie_ep.h:35
@ HOST_TO_DEVICE
Definition: pcie_ep.h:34
int pcie_ep_xfer_data_dma(const struct device *dev, uint64_t pcie_addr, uintptr_t *local_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type, enum xfer_direction dir)
Data transfer using system DMA.
static int pcie_ep_conf_read(const struct device *dev, uint32_t offset, uint32_t *data)
Read PCIe EP configuration space.
Definition: pcie_ep.h:91
static int pcie_ep_raise_irq(const struct device *dev, enum pci_ep_irq_type irq_type, uint32_t irq_num)
Raise interrupt to Host.
Definition: pcie_ep.h:191
void(* pcie_ep_reset_callback_t)(void *arg)
Callback API for PCIe reset interrupts.
Definition: pcie_ep.h:57
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:75
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
Definition: pcie_ep.h:59
int(* map_addr)(const struct device *dev, uint64_t pcie_addr, uint64_t *mapped_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type)
Definition: pcie_ep.h:64
void(* unmap_addr)(const struct device *dev, uint64_t mapped_addr)
Definition: pcie_ep.h:67
int(* raise_irq)(const struct device *dev, enum pci_ep_irq_type irq_type, uint32_t irq_num)
Definition: pcie_ep.h:68
int(* conf_read)(const struct device *dev, uint32_t offset, uint32_t *data)
Definition: pcie_ep.h:60
int(* dma_xfer)(const struct device *dev, uint64_t mapped_addr, uintptr_t local_addr, uint32_t size, enum xfer_direction dir)
Definition: pcie_ep.h:74
void(* conf_write)(const struct device *dev, uint32_t offset, uint32_t data)
Definition: pcie_ep.h:62
int(* register_reset_cb)(const struct device *dev, enum pcie_reset reset, pcie_ep_reset_callback_t cb, void *arg)
Definition: pcie_ep.h:71
static fdata_t data[2]
Definition: test_fifo_contexts.c:15