RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
pci.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2022, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2022-08-25 GuEe-GUI first version
9 */
10
11#ifndef __PCI_H__
12#define __PCI_H__
13
14#include <rtdef.h>
15#include <bitmap.h>
16#include <ioremap.h>
17#include <drivers/ofw.h>
18#include <drivers/pic.h>
19#include <drivers/core/dm.h>
20#include <drivers/core/driver.h>
21
22#include "../../pci/pci_ids.h"
23#include "../../pci/pci_regs.h"
24
25#define RT_PCI_INTX_PIN_MAX 4
26#define RT_PCI_BAR_NR_MAX 6
27#define RT_PCI_DEVICE_MAX 32
28#define RT_PCI_FUNCTION_MAX 8
29
30#define RT_PCI_FIND_CAP_TTL 48
31
32/*
33 * The PCI interface treats multi-function devices as independent
34 * devices. The slot/function address of each device is encoded
35 * in a single byte as follows:
36 *
37 * 7:3 = slot
38 * 2:0 = function
39 */
40#define RT_PCI_DEVID(bus, devfn) ((((rt_uint16_t)(bus)) << 8) | (devfn))
41#define RT_PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
42#define RT_PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
43#define RT_PCI_FUNC(devfn) ((devfn) & 0x07)
44
45#define PCIE_LINK_STATE_L0S RT_BIT(0)
46#define PCIE_LINK_STATE_L1 RT_BIT(1)
47#define PCIE_LINK_STATE_CLKPM RT_BIT(2)
48#define PCIE_LINK_STATE_L1_1 RT_BIT(3)
49#define PCIE_LINK_STATE_L1_2 RT_BIT(4)
50#define PCIE_LINK_STATE_L1_1_PCIPM RT_BIT(5)
51#define PCIE_LINK_STATE_L1_2_PCIPM RT_BIT(6)
52#define PCIE_LINK_STATE_ALL \
53( \
54 PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | \
55 PCIE_LINK_STATE_CLKPM | \
56 PCIE_LINK_STATE_L1_1 | PCIE_LINK_STATE_L1_2 | \
57 PCIE_LINK_STATE_L1_1_PCIPM | PCIE_LINK_STATE_L1_2_PCIPM \
58)
59
61{
65
67
68#define PCI_BUS_REGION_F_NONE 0xffffffff /* PCI no memory */
69#define PCI_BUS_REGION_F_MEM 0x00000000 /* PCI memory space */
70#define PCI_BUS_REGION_F_IO 0x00000001 /* PCI IO space */
71#define PCI_BUS_REGION_F_PREFETCH 0x00000008 /* Prefetchable PCI memory */
73};
74
82
83/*
84 * PCI topology:
85 *
86 * +-----+-----+ +-------------+ PCI Bus 0 +------------+ PCI Bus 1
87 * | RAM | CPU |---------| Host Bridge |--------+-----| PCI Bridge |-----+
88 * +-----+-----+ +-------------+ | +------------+ | +-------------+
89 * | +----| End Point 2 |
90 * +-------------+ +-------------+ | +-------------+ | +-------------+
91 * | End Point 5 |----+ | End Point 0 |-------+ | End Point 3 |----+
92 * +-------------+ | +-------------+ | +-------------+ |
93 * | | |
94 * +-------------+ | +-------------+ | +-------------+ | +-------------+
95 * | End Point 6 |----+----| ISA Bridge |-------+-----| End Point 1 | +----| End Point 4 |
96 * +-------------+ +-------------+ | +-------------+ +-------------+
97 * |
98 * +------+ +----------------+ |
99 * | Port |---------| CardBus Bridge |----+
100 * +------+ +----------------+
101 */
102
103struct rt_pci_bus;
104
106{
107#define PCI_ANY_ID (~0)
108#define RT_PCI_DEVICE_ID(vend, dev) \
109 .vendor = (vend), \
110 .device = (dev), \
111 .subsystem_vendor = PCI_ANY_ID, \
112 .subsystem_device = PCI_ANY_ID
113
114#define RT_PCI_DEVICE_CLASS(dev_class, dev_class_mask) \
115 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
116 .subsystem_vendor = PCI_ANY_ID, \
117 .subsystem_device = PCI_ANY_ID, \
118 .class = (dev_class), .class_mask = (dev_class_mask),
119
120 rt_uint32_t vendor, device; /* Vendor and device ID or PCI_ANY_ID */
121 rt_uint32_t subsystem_vendor; /* Subsystem ID's or PCI_ANY_ID */
122 rt_uint32_t subsystem_device; /* Subsystem ID's or PCI_ANY_ID */
123 rt_uint32_t class, class_mask; /* (class, subclass, prog-if) triplet */
124
125 const void *data;
126};
127
129{
131 const char *name;
132
135 struct rt_pci_bus *subbus; /* In PCI-to-PCI bridge, 'End Point' or 'Port' is NULL */
136
137 const struct rt_pci_device_id *id;
138
139 rt_uint32_t devfn; /* Encoded device & function index */
144 rt_uint32_t class; /* 3 bytes: (base, sub, prog-if) */
153
154 void *sysdata;
155
156 int irq;
159
161
166
167 rt_uint8_t busmaster:1; /* Is the bus master */
168 rt_uint8_t multi_function:1; /* Multi-function device */
169 rt_uint8_t ari_enabled:1; /* Alternative Routing-ID Interpretation */
170 rt_uint8_t no_msi:1; /* May not use MSI */
171 rt_uint8_t no_64bit_msi:1; /* May only use 32-bit MSIs */
172 rt_uint8_t msi_enabled:1; /* MSI enable */
173 rt_uint8_t msix_enabled:1; /* MSIx enable */
174 rt_uint8_t broken_intx_masking:1; /* INTx masking can't be used */
175 rt_uint8_t pme_support:5; /* Bitmask of states from which PME# can be generated */
176
177#ifdef RT_PCI_MSI
178 void *msix_base;
179 struct rt_pic *msi_pic;
180 rt_list_t msi_desc_nodes;
181 struct rt_spinlock msi_lock;
182#endif
183};
184
207#define rt_device_to_pci_host_bridge(dev) rt_container_of(dev, struct rt_pci_host_bridge, parent)
208
210{
211 rt_err_t (*add)(struct rt_pci_bus *bus);
212 rt_err_t (*remove)(struct rt_pci_bus *bus);
213
214 void *(*map)(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg);
215
216 rt_err_t (*read)(struct rt_pci_bus *bus,
217 rt_uint32_t devfn, int reg, int width, rt_uint32_t *value);
218 rt_err_t (*write)(struct rt_pci_bus *bus,
219 rt_uint32_t devfn, int reg, int width, rt_uint32_t value);
220};
221
223{
228
229 union
230 {
231 /* In PCI-to-PCI bridge, parent is not NULL */
233 /* In Host bridge, this is Root bus ('PCI Bus 0') */
235 };
236
237 const struct rt_pci_ops *ops;
238
239 char name[48];
240 char number;
242
243 void *sysdata;
244};
245
247{
248 struct rt_driver parent;
249
250 const char *name;
251 const struct rt_pci_device_id *ids;
252
253 rt_err_t (*probe)(struct rt_pci_device *pdev);
254 rt_err_t (*remove)(struct rt_pci_device *pdev);
256};
257
259{
260 int irq;
261 int index;
262};
263
274
276void rt_pci_pme_active(struct rt_pci_device *pdev, rt_bool_t enable);
278 enum rt_pci_power state, rt_bool_t enable);
280 enum rt_pci_power state)
281{
282 if (!pdev->pme_cap)
283 {
284 return RT_FALSE;
285 }
286
287 return !!(pdev->pme_support & (1 << state));
288}
289
292
295
300
307
310
314
316
320
323
326
328{
329 return RT_PCI_DEVID(pdev->bus->number, pdev->devfn);
330}
331
333{
334 return bus->parent ? RT_FALSE : RT_TRUE;
335}
336
338{
339 return pdev->hdr_type == PCIM_HDRTYPE_BRIDGE ||
340 pdev->hdr_type == PCIM_HDRTYPE_CARDBUS;
341}
342
344{
345 return !!pdev->pcie_cap;
346}
347
348#define rt_pci_foreach_bridge(pdev, bus) \
349 rt_list_for_each_entry(pdev, &bus->devices_nodes, list) \
350 if (rt_pci_is_bridge(pdev))
351
353 rt_uint32_t devfn, int pos, rt_uint8_t *value);
355 rt_uint32_t devfn, int pos, rt_uint16_t *value);
357 rt_uint32_t devfn, int pos, rt_uint32_t *value);
358
360 rt_uint32_t devfn, int reg, rt_uint8_t value);
362 rt_uint32_t devfn, int reg, rt_uint16_t value);
364 rt_uint32_t devfn, int reg, rt_uint32_t value);
365
367 rt_uint32_t devfn, int reg, int width, rt_uint32_t *value);
369 rt_uint32_t devfn, int reg, int width, rt_uint32_t value);
370
372 rt_uint32_t devfn, int reg, int width, rt_uint32_t *value);
374 rt_uint32_t devfn, int reg, int width, rt_uint32_t value);
375
376rt_inline rt_err_t rt_pci_read_config_u8(const struct rt_pci_device *pdev,
377 int reg, rt_uint8_t *value)
378{
379 return rt_pci_bus_read_config_u8(pdev->bus, pdev->devfn, reg, value);
380}
381
382rt_inline rt_err_t rt_pci_read_config_u16(const struct rt_pci_device *pdev,
383 int reg, rt_uint16_t *value)
384{
385 return rt_pci_bus_read_config_u16(pdev->bus, pdev->devfn, reg, value);
386}
387
388rt_inline rt_err_t rt_pci_read_config_u32(const struct rt_pci_device *pdev,
389 int reg, rt_uint32_t *value)
390{
391 return rt_pci_bus_read_config_u32(pdev->bus, pdev->devfn, reg, value);
392}
393
394rt_inline rt_err_t rt_pci_write_config_u8(const struct rt_pci_device *pdev,
395 int reg, rt_uint8_t value)
396{
397 return rt_pci_bus_write_config_u8(pdev->bus, pdev->devfn, reg, value);
398}
399
400rt_inline rt_err_t rt_pci_write_config_u16(const struct rt_pci_device *pdev,
401 int reg, rt_uint16_t value)
402{
403 return rt_pci_bus_write_config_u16(pdev->bus, pdev->devfn, reg, value);
404}
405
406rt_inline rt_err_t rt_pci_write_config_u32(const struct rt_pci_device *pdev,
407 int reg, rt_uint32_t value)
408{
409 return rt_pci_bus_write_config_u32(pdev->bus, pdev->devfn, reg, value);
410}
411
412#ifdef RT_USING_OFW
414 rt_uint8_t slot, rt_uint8_t pin);
415
417 struct rt_pci_host_bridge *host_bridge);
418
420 struct rt_pci_host_bridge *host_bridge);
421
426#else
428 struct rt_pci_host_bridge *host_bridge)
429{
430 return RT_EOK;
431}
433{
434 return RT_EOK;
435}
437{
438 return RT_EOK;
439}
441{
442 return RT_EOK;
443}
445{
446 return RT_EOK;
447}
449 rt_uint8_t slot, rt_uint8_t pin)
450{
451 return -1;
452}
454 struct rt_pci_host_bridge *host_bridge)
455{
456 return -RT_ENOSYS;
457}
458#endif /* RT_USING_OFW */
459
460rt_inline void *rt_pci_iomap(struct rt_pci_device *pdev, int bar_idx)
461{
462 struct rt_pci_bus_resource *res = &pdev->resource[bar_idx];
463
464 RT_ASSERT(bar_idx < RT_ARRAY_SIZE(pdev->resource));
465
466 return rt_ioremap((void *)res->base, res->size);
467}
468
471
473
474void rt_pci_intx(struct rt_pci_device *pdev, rt_bool_t enable);
477
480
481#define RT_PCI_IRQ_F_LEGACY RT_BIT(0) /* Allow legacy interrupts */
482#define RT_PCI_IRQ_F_MSI RT_BIT(1) /* Allow MSI interrupts */
483#define RT_PCI_IRQ_F_MSIX RT_BIT(2) /* Allow MSI-X interrupts */
484#define RT_PCI_IRQ_F_AFFINITY RT_BIT(3) /* Auto-assign affinity */
485#define RT_PCI_IRQ_F_ALL_TYPES (RT_PCI_IRQ_F_LEGACY | RT_PCI_IRQ_F_MSI | RT_PCI_IRQ_F_MSIX)
486
487#ifdef RT_PCI_MSI
488rt_ssize_t rt_pci_alloc_vector(struct rt_pci_device *pdev, int min, int max,
490void rt_pci_free_vector(struct rt_pci_device *pdev);
491
495 int min, int max, RT_IRQ_AFFINITY_DECLARE((*affinities)));
496
500 struct rt_pci_msix_entry *entries, int min, int max,
501 RT_IRQ_AFFINITY_DECLARE((*affinities)));
502#else
503rt_inline rt_ssize_t rt_pci_alloc_vector(struct rt_pci_device *pdev, int min, int max,
505{
506 return -RT_ENOSYS;
507}
508
509rt_inline void rt_pci_free_vector(struct rt_pci_device *pdev)
510{
511 return;
512}
513
515{
516 return 0;
517}
518
520{
521 return RT_EOK;
522}
523
525 int min, int max, RT_IRQ_AFFINITY_DECLARE((*affinities)))
526{
527 return -RT_ENOSYS;
528}
529
531{
532 return 0;
533}
534
536{
537 return RT_EOK;
538}
539
541 struct rt_pci_msix_entry *entries, int min, int max,
542 RT_IRQ_AFFINITY_DECLARE((*affinities)))
543{
544 return -RT_ENOSYS;
545}
546#endif /* RT_PCI_MSI */
547
549 rt_size_t nvectors)
550{
551 for (int i = 0; i < nvectors; ++i)
552 {
553 entries[i].index = i;
554 }
555}
556
558 int min, int max)
559{
560 return rt_pci_msi_enable_range_affinity(pdev, min, max, RT_NULL);
561}
562
564{
565 rt_ssize_t res = rt_pci_msi_enable_range(pdev, 1, 1);
566 return res == 1 ? res : RT_EOK;
567}
568
570 struct rt_pci_msix_entry *entries, int min, int max)
571{
572 return rt_pci_msix_enable_range_affinity(pdev, entries, min, max, RT_NULL);
573}
574
576 struct rt_pci_msix_entry *entries, int count)
577{
578 return rt_pci_msix_enable_range(pdev, entries, count, count);
579}
580
583 void **out_addr, rt_size_t size, rt_ubase_t flags, rt_bool_t mem64);
584
586 struct rt_pci_device *pdev);
587
589 rt_bool_t (callback(struct rt_pci_device *, void *)), void *data);
590
592 const struct rt_pci_device_id *id);
593
595 const struct rt_pci_device_id *ids);
596
600#define RT_PCI_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, pci, BUILIN)
601
602extern struct rt_spinlock rt_pci_lock;
603
604#endif /* __PCI_H__ */
#define RT_ASSERT(EX)
#define RT_ARRAY_SIZE(arr)
定义 misc.h:59
rt_err_t rt_pci_host_bridge_probe(struct rt_pci_host_bridge *host_bridge)
rt_err_t rt_pci_device_register(struct rt_pci_device *pdev)
rt_err_t rt_pci_device_alloc_resource(struct rt_pci_host_bridge *host_bridge, struct rt_pci_device *pdev)
rt_err_t rt_pci_host_bridge_remove(struct rt_pci_host_bridge *host_bridge)
rt_bool_t rt_pci_check_and_mask_intx(struct rt_pci_device *pdev)
struct rt_pci_bus_resource * rt_pci_find_bar(struct rt_pci_device *pdev, rt_ubase_t flags, int index)
struct rt_pci_host_bridge * rt_pci_host_bridge_alloc(rt_size_t priv_size)
rt_err_t rt_pci_bus_read_config_u8(struct rt_pci_bus *bus, rt_uint32_t devfn, int pos, rt_uint8_t *value)
rt_err_t rt_pci_bus_read_config_u32(struct rt_pci_bus *bus, rt_uint32_t devfn, int pos, rt_uint32_t *value)
rt_inline rt_ssize_t rt_pci_msi_enable_range(struct rt_pci_device *pdev, int min, int max)
定义 pci.h:557
rt_inline rt_ssize_t rt_pci_alloc_vector(struct rt_pci_device *pdev, int min, int max, rt_uint32_t flags, RT_IRQ_AFFINITY_DECLARE((*affinities)))
定义 pci.h:503
rt_inline rt_ssize_t rt_pci_msix_enable_range(struct rt_pci_device *pdev, struct rt_pci_msix_entry *entries, int min, int max)
定义 pci.h:569
void rt_pci_intx(struct rt_pci_device *pdev, rt_bool_t enable)
rt_inline rt_ssize_t rt_pci_msix_vector_count(struct rt_pci_device *pdev)
定义 pci.h:530
rt_err_t rt_pci_setup_device(struct rt_pci_device *pdev)
rt_inline rt_err_t rt_pci_ofw_host_bridge_init(struct rt_ofw_node *dev_np, struct rt_pci_host_bridge *host_bridge)
定义 pci.h:427
rt_err_t rt_pci_bus_write_config_u8(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, rt_uint8_t value)
rt_inline rt_err_t rt_pci_ofw_bus_init(struct rt_pci_bus *bus)
定义 pci.h:432
rt_err_t rt_pci_host_bridge_init(struct rt_pci_host_bridge *host_bridge)
rt_inline rt_bool_t rt_pci_pme_capable(struct rt_pci_device *pdev, enum rt_pci_power state)
定义 pci.h:279
rt_inline rt_ssize_t rt_pci_msi_vector_count(struct rt_pci_device *pdev)
定义 pci.h:514
rt_inline rt_bool_t rt_pci_is_pcie(struct rt_pci_device *pdev)
定义 pci.h:343
rt_err_t rt_pci_bus_read_config_generic_u32(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, int width, rt_uint32_t *value)
rt_err_t rt_pci_scan_root_bus_bridge(struct rt_pci_host_bridge *host_bridge)
rt_uint8_t rt_pci_bus_find_capability(struct rt_pci_bus *bus, rt_uint32_t devfn, int cap)
rt_err_t rt_pci_bus_read_config_u16(struct rt_pci_bus *bus, rt_uint32_t devfn, int pos, rt_uint16_t *value)
rt_inline rt_ssize_t rt_pci_msix_enable(struct rt_pci_device *pdev, struct rt_pci_msix_entry *entries, int count)
定义 pci.h:575
rt_inline rt_ssize_t rt_pci_msix_enable_range_affinity(struct rt_pci_device *pdev, struct rt_pci_msix_entry *entries, int min, int max, RT_IRQ_AFFINITY_DECLARE((*affinities)))
定义 pci.h:540
rt_err_t rt_pci_driver_register(struct rt_pci_driver *pdrv)
rt_err_t rt_pci_bus_read_config_uxx(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, int width, rt_uint32_t *value)
struct rt_pci_device * rt_pci_alloc_device(struct rt_pci_bus *bus)
rt_err_t rt_pci_device_remove(struct rt_pci_device *pdev)
rt_inline void rt_pci_free_vector(struct rt_pci_device *pdev)
定义 pci.h:509
rt_size_t rt_pci_scan_slot(struct rt_pci_bus *bus, rt_uint32_t devfn)
void rt_pci_enum_device(struct rt_pci_bus *bus, rt_bool_t(callback(struct rt_pci_device *, void *)), void *data)
rt_inline rt_err_t rt_pci_read_config_u16(const struct rt_pci_device *pdev, int reg, rt_uint16_t *value)
定义 pci.h:382
struct rt_pci_host_bridge * rt_pci_find_host_bridge(struct rt_pci_bus *bus)
rt_pci_power
定义 pci.h:265
@ RT_PCI_D1
定义 pci.h:267
@ RT_PCI_D0
定义 pci.h:266
@ RT_PCI_D3HOT
定义 pci.h:269
@ RT_PCI_PME_MAX
定义 pci.h:272
@ RT_PCI_D3COLD
定义 pci.h:270
@ RT_PCI_D2
定义 pci.h:268
rt_err_t rt_pci_bus_write_config_u32(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, rt_uint32_t value)
void rt_pci_irq_mask(struct rt_pci_device *pdev)
#define RT_PCI_DEVID(bus, devfn)
定义 pci.h:40
rt_err_t rt_pci_enable_wake(struct rt_pci_device *pci_dev, enum rt_pci_power state, rt_bool_t enable)
rt_uint16_t rt_pci_find_ext_next_capability(struct rt_pci_device *pdev, rt_uint16_t pos, int cap)
rt_inline rt_err_t rt_pci_write_config_u32(const struct rt_pci_device *pdev, int reg, rt_uint32_t value)
定义 pci.h:406
rt_bool_t rt_pci_check_and_unmask_intx(struct rt_pci_device *pdev)
rt_inline rt_err_t rt_pci_msi_enable(struct rt_pci_device *pdev)
定义 pci.h:563
void rt_pci_pme_active(struct rt_pci_device *pdev, rt_bool_t enable)
rt_inline rt_bool_t rt_pci_is_bridge(struct rt_pci_device *pdev)
定义 pci.h:337
void rt_pci_msix_init(struct rt_pci_device *pdev)
rt_inline void * rt_pci_iomap(struct rt_pci_device *pdev, int bar_idx)
定义 pci.h:460
rt_inline rt_err_t rt_pci_write_config_u16(const struct rt_pci_device *pdev, int reg, rt_uint16_t value)
定义 pci.h:400
rt_inline void rt_pci_msix_entry_index_linear(struct rt_pci_msix_entry *entries, rt_size_t nvectors)
定义 pci.h:548
rt_err_t rt_pci_bus_write_config_generic_u32(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, int width, rt_uint32_t value)
rt_inline rt_err_t rt_pci_read_config_u8(const struct rt_pci_device *pdev, int reg, rt_uint8_t *value)
定义 pci.h:376
rt_uint8_t rt_pci_irq_slot(struct rt_pci_device *pdev, rt_uint8_t *pinp)
rt_err_t rt_pci_host_bridge_register(struct rt_pci_host_bridge *host_bridge)
rt_uint16_t rt_pci_find_ext_capability(struct rt_pci_device *pdev, int cap)
rt_uint32_t rt_pci_domain(struct rt_pci_device *pdev)
struct rt_spinlock rt_pci_lock
rt_uint32_t rt_pci_scan_child_buses(struct rt_pci_bus *bus, rt_size_t buses)
rt_inline rt_err_t rt_pci_ofw_bus_free(struct rt_pci_bus *bus)
定义 pci.h:436
rt_err_t rt_pci_bus_write_config_uxx(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, int width, rt_uint32_t value)
rt_inline rt_err_t rt_pci_write_config_u8(const struct rt_pci_device *pdev, int reg, rt_uint8_t value)
定义 pci.h:394
rt_err_t rt_pci_region_setup(struct rt_pci_host_bridge *host_bridge)
rt_uint32_t rt_pci_scan_child_bus(struct rt_pci_bus *bus)
void rt_pci_clear_master(struct rt_pci_device *pdev)
void rt_pci_pme_init(struct rt_pci_device *pdev)
rt_uint8_t rt_pci_find_next_capability(struct rt_pci_device *pdev, rt_uint8_t pos, int cap)
void rt_pci_assign_irq(struct rt_pci_device *pdev)
rt_inline rt_err_t rt_pci_ofw_device_init(struct rt_pci_device *pdev)
定义 pci.h:440
rt_inline int rt_pci_ofw_irq_parse_and_map(struct rt_pci_device *pdev, rt_uint8_t slot, rt_uint8_t pin)
定义 pci.h:448
rt_err_t rt_pci_bus_remove(struct rt_pci_bus *bus)
rt_err_t rt_pci_host_bridge_free(struct rt_pci_host_bridge *)
rt_inline rt_err_t rt_pci_read_config_u32(const struct rt_pci_device *pdev, int reg, rt_uint32_t *value)
定义 pci.h:388
rt_err_t rt_pci_bus_write_config_u16(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, rt_uint16_t value)
rt_uint8_t rt_pci_find_capability(struct rt_pci_device *pdev, int cap)
struct rt_pci_bus_region * rt_pci_region_alloc(struct rt_pci_host_bridge *host_bridge, void **out_addr, rt_size_t size, rt_ubase_t flags, rt_bool_t mem64)
void rt_pci_msi_init(struct rt_pci_device *pdev)
rt_inline rt_err_t rt_pci_msi_disable(struct rt_pci_device *pdev)
定义 pci.h:519
void rt_pci_set_master(struct rt_pci_device *pdev)
rt_inline rt_err_t rt_pci_ofw_parse_ranges(struct rt_ofw_node *dev_np, struct rt_pci_host_bridge *host_bridge)
定义 pci.h:453
struct rt_pci_bus * rt_pci_find_root_bus(struct rt_pci_bus *bus)
rt_inline rt_uint16_t rt_pci_dev_id(struct rt_pci_device *pdev)
定义 pci.h:327
rt_uint8_t rt_pci_irq_intx(struct rt_pci_device *pdev, rt_uint8_t pin)
rt_inline rt_err_t rt_pci_msix_disable(struct rt_pci_device *pdev)
定义 pci.h:535
void rt_pci_irq_unmask(struct rt_pci_device *pdev)
rt_inline rt_err_t rt_pci_ofw_device_free(struct rt_pci_device *pdev)
定义 pci.h:444
rt_inline rt_bool_t rt_pci_is_root_bus(struct rt_pci_bus *bus)
定义 pci.h:332
struct rt_pci_device * rt_pci_scan_single_device(struct rt_pci_bus *bus, rt_uint32_t devfn)
rt_inline rt_ssize_t rt_pci_msi_enable_range_affinity(struct rt_pci_device *pdev, int min, int max, RT_IRQ_AFFINITY_DECLARE((*affinities)))
定义 pci.h:524
#define RT_PCI_BAR_NR_MAX
定义 pci.h:26
const struct rt_pci_device_id * rt_pci_match_ids(struct rt_pci_device *pdev, const struct rt_pci_device_id *ids)
const struct rt_pci_device_id * rt_pci_match_id(struct rt_pci_device *pdev, const struct rt_pci_device_id *id)
#define RT_IRQ_AFFINITY_DECLARE(name)
定义 pic.h:100
rt_base_t rt_ssize_t
int rt_bool_t
rt_base_t rt_err_t
unsigned char rt_uint8_t
unsigned short rt_uint16_t
#define RT_TRUE
rt_ubase_t rt_size_t
struct rt_list_node rt_list_t
unsigned int rt_uint32_t
#define RT_FALSE
rt_uint32_t rt_ubase_t
#define RT_NULL
unsigned long long rt_uint64_t
rt_ubase_t flags
定义 pci.h:72
rt_uint64_t size
定义 pci.h:64
rt_uint64_t phy_addr
定义 pci.h:62
rt_uint64_t cpu_addr
定义 pci.h:63
rt_uint64_t bus_start
定义 pci.h:66
rt_ubase_t flags
定义 pci.h:80
rt_ubase_t base
定义 pci.h:77
struct rt_spinlock lock
定义 pci.h:241
struct rt_pci_bus * parent
定义 pci.h:227
struct rt_pci_device * self
定义 pci.h:232
char number
定义 pci.h:240
void * sysdata
定义 pci.h:243
struct rt_pci_host_bridge * host_bridge
定义 pci.h:234
rt_list_t devices_nodes
定义 pci.h:226
rt_list_t list
定义 pci.h:224
char name[48]
定义 pci.h:239
const struct rt_pci_ops * ops
定义 pci.h:237
rt_list_t children_nodes
定义 pci.h:225
rt_uint32_t class_mask
定义 pci.h:123
rt_uint32_t subsystem_device
定义 pci.h:122
rt_uint32_t subsystem_vendor
定义 pci.h:121
rt_uint32_t vendor
定义 pci.h:120
const void * data
定义 pci.h:125
rt_uint32_t device
定义 pci.h:120
rt_uint8_t broken_intx_masking
定义 pci.h:174
rt_uint16_t subsystem_device
定义 pci.h:143
rt_uint16_t subsystem_vendor
定义 pci.h:142
rt_uint32_t cfg_size
定义 pci.h:152
struct rt_pci_bus * subbus
定义 pci.h:135
rt_uint8_t pme_support
定义 pci.h:175
struct rt_pic * intx_pic
定义 pci.h:158
const char * name
定义 pci.h:131
rt_uint16_t vendor
定义 pci.h:140
struct rt_pci_bus * bus
定义 pci.h:134
rt_uint8_t int_line
定义 pci.h:150
rt_uint8_t int_pin
定义 pci.h:149
rt_uint8_t revision
定义 pci.h:145
rt_uint8_t pin
定义 pci.h:157
struct rt_device parent
定义 pci.h:130
rt_uint8_t max_latency
定义 pci.h:147
rt_uint8_t msix_enabled
定义 pci.h:173
rt_uint8_t pme_cap
定义 pci.h:162
rt_uint32_t devfn
定义 pci.h:139
rt_uint8_t msi_enabled
定义 pci.h:172
rt_uint8_t msi_cap
定义 pci.h:163
const struct rt_pci_device_id * id
定义 pci.h:137
rt_uint8_t min_grantl
定义 pci.h:148
rt_uint8_t ari_enabled
定义 pci.h:169
void * sysdata
定义 pci.h:154
rt_uint16_t exp_flags
定义 pci.h:151
rt_list_t list
定义 pci.h:133
rt_uint8_t msix_cap
定义 pci.h:164
struct rt_pci_bus_resource resource[RT_PCI_BAR_NR_MAX]
定义 pci.h:160
rt_uint8_t no_msi
定义 pci.h:170
rt_uint8_t multi_function
定义 pci.h:168
rt_uint16_t device
定义 pci.h:141
rt_uint8_t busmaster
定义 pci.h:167
rt_uint8_t pcie_cap
定义 pci.h:165
rt_uint8_t no_64bit_msi
定义 pci.h:171
rt_uint8_t hdr_type
定义 pci.h:146
const struct rt_pci_device_id * ids
定义 pci.h:251
const char * name
定义 pci.h:250
rt_err_t(* shutdown)(struct rt_pci_device *pdev)
定义 pci.h:255
rt_err_t(* remove)(struct rt_pci_device *pdev)
定义 pci.h:254
rt_err_t(* probe)(struct rt_pci_device *pdev)
定义 pci.h:253
struct rt_driver parent
定义 pci.h:248
rt_size_t dma_regions_nr
定义 pci.h:198
int(* irq_map)(struct rt_pci_device *pdev, rt_uint8_t slot, rt_uint8_t pin)
定义 pci.h:202
struct rt_pci_bus_region * bus_regions
定义 pci.h:197
rt_uint8_t priv[0]
定义 pci.h:205
struct rt_device parent
定义 pci.h:187
struct rt_pci_bus * root_bus
定义 pci.h:191
const struct rt_pci_ops * ops
定义 pci.h:192
rt_uint8_t(* irq_slot)(struct rt_pci_device *pdev, rt_uint8_t *pinp)
定义 pci.h:201
rt_size_t bus_regions_nr
定义 pci.h:196
struct rt_pci_bus_region * dma_regions
定义 pci.h:199
rt_uint32_t domain
定义 pci.h:189
rt_uint32_t bus_range[2]
定义 pci.h:195
const struct rt_pci_ops * child_ops
定义 pci.h:193
定义 pci.h:259
int index
定义 pci.h:261
int irq
定义 pci.h:260
rt_err_t(* remove)(struct rt_pci_bus *bus)
定义 pci.h:212
rt_err_t(* write)(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, int width, rt_uint32_t value)
定义 pci.h:218
rt_err_t(* add)(struct rt_pci_bus *bus)
定义 pci.h:211
rt_err_t(* read)(struct rt_pci_bus *bus, rt_uint32_t devfn, int reg, int width, rt_uint32_t *value)
定义 pci.h:216