blob: 3020ee22c837f56124ef397297c3bfaf370c0a28 [file] [log] [blame]
Cornelia Huck9f0ae302021-06-09 16:37:07 +02001#ifndef _PCI_HOST_GENERIC_H_
2#define _PCI_HOST_GENERIC_H_
Alexander Gordeev33d78b02016-11-07 11:14:42 +01003/*
4 * PCI host bridge supporting structures and constants
5 *
6 * Copyright (C) 2016, Red Hat Inc, Alexander Gordeev <agordeev@redhat.com>
7 *
8 * This work is licensed under the terms of the GNU LGPL, version 2.
9 */
10#include "libcflat.h"
11
12struct pci_addr_space {
13 phys_addr_t pci_start;
14 phys_addr_t start;
15 phys_addr_t size;
16 phys_addr_t allocated;
17 int type;
18};
19
20struct pci_host_bridge {
Andrew Jones340cf7d2020-11-03 21:47:08 +010021 void __iomem *start;
22 size_t size;
Alexander Gordeev33d78b02016-11-07 11:14:42 +010023 int bus;
24 int bus_max;
25 int nr_addr_spaces;
26 struct pci_addr_space addr_space[];
27};
28
29/*
30 * The following constants are derived from Linux, see this source:
31 *
32 * drivers/pci/host/pci-host-generic.c
33 * struct gen_pci_cfg_bus_ops::bus_shift
34 * int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
35 *
36 * Documentation/devicetree/bindings/pci/host-generic-pci.txt describes
37 * ECAM Configuration Space is be memory-mapped by concatenating the various
38 * components to form an offset:
39 *
40 * cfg_offset(bus, device, function, register) =
41 * bus << 20 | device << 15 | function << 12 | register
42 */
43#define PCI_ECAM_BUS_SHIFT 20
44#define PCI_ECAM_DEVFN_SHIFT 12
45
46#endif