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