1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright (C) 2014-2015 Broadcom Corporation
4*4882a593Smuzhiyun */
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun #ifndef _PCIE_IPROC_H
7*4882a593Smuzhiyun #define _PCIE_IPROC_H
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun /**
10*4882a593Smuzhiyun * iProc PCIe interface type
11*4882a593Smuzhiyun *
12*4882a593Smuzhiyun * PAXB is the wrapper used in root complex that can be connected to an
13*4882a593Smuzhiyun * external endpoint device.
14*4882a593Smuzhiyun *
15*4882a593Smuzhiyun * PAXC is the wrapper used in root complex dedicated for internal emulated
16*4882a593Smuzhiyun * endpoint devices.
17*4882a593Smuzhiyun */
18*4882a593Smuzhiyun enum iproc_pcie_type {
19*4882a593Smuzhiyun IPROC_PCIE_PAXB_BCMA = 0,
20*4882a593Smuzhiyun IPROC_PCIE_PAXB,
21*4882a593Smuzhiyun IPROC_PCIE_PAXB_V2,
22*4882a593Smuzhiyun IPROC_PCIE_PAXC,
23*4882a593Smuzhiyun IPROC_PCIE_PAXC_V2,
24*4882a593Smuzhiyun };
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun /**
27*4882a593Smuzhiyun * iProc PCIe outbound mapping
28*4882a593Smuzhiyun * @axi_offset: offset from the AXI address to the internal address used by
29*4882a593Smuzhiyun * the iProc PCIe core
30*4882a593Smuzhiyun * @nr_windows: total number of supported outbound mapping windows
31*4882a593Smuzhiyun */
32*4882a593Smuzhiyun struct iproc_pcie_ob {
33*4882a593Smuzhiyun resource_size_t axi_offset;
34*4882a593Smuzhiyun unsigned int nr_windows;
35*4882a593Smuzhiyun };
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun /**
38*4882a593Smuzhiyun * iProc PCIe inbound mapping
39*4882a593Smuzhiyun * @nr_regions: total number of supported inbound mapping regions
40*4882a593Smuzhiyun */
41*4882a593Smuzhiyun struct iproc_pcie_ib {
42*4882a593Smuzhiyun unsigned int nr_regions;
43*4882a593Smuzhiyun };
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun struct iproc_pcie_ob_map;
46*4882a593Smuzhiyun struct iproc_pcie_ib_map;
47*4882a593Smuzhiyun struct iproc_msi;
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun /**
50*4882a593Smuzhiyun * iProc PCIe device
51*4882a593Smuzhiyun *
52*4882a593Smuzhiyun * @dev: pointer to device data structure
53*4882a593Smuzhiyun * @type: iProc PCIe interface type
54*4882a593Smuzhiyun * @reg_offsets: register offsets
55*4882a593Smuzhiyun * @base: PCIe host controller I/O register base
56*4882a593Smuzhiyun * @base_addr: PCIe host controller register base physical address
57*4882a593Smuzhiyun * @phy: optional PHY device that controls the Serdes
58*4882a593Smuzhiyun * @map_irq: function callback to map interrupts
59*4882a593Smuzhiyun * @ep_is_internal: indicates an internal emulated endpoint device is connected
60*4882a593Smuzhiyun * @iproc_cfg_read: indicates the iProc config read function should be used
61*4882a593Smuzhiyun * @rej_unconfig_pf: indicates the root complex needs to detect and reject
62*4882a593Smuzhiyun * enumeration against unconfigured physical functions emulated in the ASIC
63*4882a593Smuzhiyun * @has_apb_err_disable: indicates the controller can be configured to prevent
64*4882a593Smuzhiyun * unsupported request from being forwarded as an APB bus error
65*4882a593Smuzhiyun * @fix_paxc_cap: indicates the controller has corrupted capability list in its
66*4882a593Smuzhiyun * config space registers and requires SW based fixup
67*4882a593Smuzhiyun *
68*4882a593Smuzhiyun * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
69*4882a593Smuzhiyun * @ob: outbound mapping related parameters
70*4882a593Smuzhiyun * @ob_map: outbound mapping related parameters specific to the controller
71*4882a593Smuzhiyun *
72*4882a593Smuzhiyun * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
73*4882a593Smuzhiyun * @ib: inbound mapping related parameters
74*4882a593Smuzhiyun * @ib_map: outbound mapping region related parameters
75*4882a593Smuzhiyun *
76*4882a593Smuzhiyun * @need_msi_steer: indicates additional configuration of the iProc PCIe
77*4882a593Smuzhiyun * controller is required to steer MSI writes to external interrupt controller
78*4882a593Smuzhiyun * @msi: MSI data
79*4882a593Smuzhiyun */
80*4882a593Smuzhiyun struct iproc_pcie {
81*4882a593Smuzhiyun struct device *dev;
82*4882a593Smuzhiyun enum iproc_pcie_type type;
83*4882a593Smuzhiyun u16 *reg_offsets;
84*4882a593Smuzhiyun void __iomem *base;
85*4882a593Smuzhiyun phys_addr_t base_addr;
86*4882a593Smuzhiyun struct resource mem;
87*4882a593Smuzhiyun struct phy *phy;
88*4882a593Smuzhiyun int (*map_irq)(const struct pci_dev *, u8, u8);
89*4882a593Smuzhiyun bool ep_is_internal;
90*4882a593Smuzhiyun bool iproc_cfg_read;
91*4882a593Smuzhiyun bool rej_unconfig_pf;
92*4882a593Smuzhiyun bool has_apb_err_disable;
93*4882a593Smuzhiyun bool fix_paxc_cap;
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun bool need_ob_cfg;
96*4882a593Smuzhiyun struct iproc_pcie_ob ob;
97*4882a593Smuzhiyun const struct iproc_pcie_ob_map *ob_map;
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun bool need_ib_cfg;
100*4882a593Smuzhiyun struct iproc_pcie_ib ib;
101*4882a593Smuzhiyun const struct iproc_pcie_ib_map *ib_map;
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun bool need_msi_steer;
104*4882a593Smuzhiyun struct iproc_msi *msi;
105*4882a593Smuzhiyun };
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
108*4882a593Smuzhiyun int iproc_pcie_remove(struct iproc_pcie *pcie);
109*4882a593Smuzhiyun int iproc_pcie_shutdown(struct iproc_pcie *pcie);
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun #ifdef CONFIG_PCIE_IPROC_MSI
112*4882a593Smuzhiyun int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
113*4882a593Smuzhiyun void iproc_msi_exit(struct iproc_pcie *pcie);
114*4882a593Smuzhiyun #else
iproc_msi_init(struct iproc_pcie * pcie,struct device_node * node)115*4882a593Smuzhiyun static inline int iproc_msi_init(struct iproc_pcie *pcie,
116*4882a593Smuzhiyun struct device_node *node)
117*4882a593Smuzhiyun {
118*4882a593Smuzhiyun return -ENODEV;
119*4882a593Smuzhiyun }
iproc_msi_exit(struct iproc_pcie * pcie)120*4882a593Smuzhiyun static inline void iproc_msi_exit(struct iproc_pcie *pcie)
121*4882a593Smuzhiyun {
122*4882a593Smuzhiyun }
123*4882a593Smuzhiyun #endif
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun #endif /* _PCIE_IPROC_H */
126