blob: dcca315897c8ef83658652095ae3a39da36aab84 [file] [log] [blame]
Bjorn Helgaas8cfab3c2018-01-26 12:50:27 -06001/* SPDX-License-Identifier: GPL-2.0 */
Ray Jui1fb37a82015-04-08 11:21:35 -07002/*
3 * Copyright (C) 2014-2015 Broadcom Corporation
Ray Jui1fb37a82015-04-08 11:21:35 -07004 */
5
6#ifndef _PCIE_IPROC_H
7#define _PCIE_IPROC_H
8
Ray Jui1fb37a82015-04-08 11:21:35 -07009/**
Krzysztof Wilczyński347269c2021-07-03 15:13:02 +000010 * enum iproc_pcie_type - iProc PCIe interface type
11 * @IPROC_PCIE_PAXB_BCMA: BCMA-based host controllers
12 * @IPROC_PCIE_PAXB: PAXB-based host controllers for
13 * NS, NSP, Cygnus, NS2, and Pegasus SOCs
14 * @IPROC_PCIE_PAXB_V2: PAXB-based host controllers for Stingray SoCs
15 * @IPROC_PCIE_PAXC: PAXC-based host controllers
16 * @IPROC_PCIE_PAXC_V2: PAXC-based host controllers (second generation)
Ray Jui943ebae2015-12-04 09:34:59 -080017 *
18 * PAXB is the wrapper used in root complex that can be connected to an
19 * external endpoint device.
20 *
21 * PAXC is the wrapper used in root complex dedicated for internal emulated
22 * endpoint devices.
23 */
24enum iproc_pcie_type {
Ray Jui404349c2016-10-31 17:38:32 -070025 IPROC_PCIE_PAXB_BCMA = 0,
26 IPROC_PCIE_PAXB,
Ray Juic7c44522016-10-31 17:38:41 -070027 IPROC_PCIE_PAXB_V2,
Ray Jui943ebae2015-12-04 09:34:59 -080028 IPROC_PCIE_PAXC,
Ray Jui787b3c42016-10-31 17:38:35 -070029 IPROC_PCIE_PAXC_V2,
Ray Jui943ebae2015-12-04 09:34:59 -080030};
31
32/**
Krzysztof Wilczyński347269c2021-07-03 15:13:02 +000033 * struct iproc_pcie_ob - iProc PCIe outbound mapping
Ray Juie99a1872015-10-16 08:18:24 -050034 * @axi_offset: offset from the AXI address to the internal address used by
35 * the iProc PCIe core
Ray Jui4213e152016-10-31 17:38:37 -070036 * @nr_windows: total number of supported outbound mapping windows
Ray Juie99a1872015-10-16 08:18:24 -050037 */
38struct iproc_pcie_ob {
Ray Juie99a1872015-10-16 08:18:24 -050039 resource_size_t axi_offset;
Ray Jui4213e152016-10-31 17:38:37 -070040 unsigned int nr_windows;
Ray Juie99a1872015-10-16 08:18:24 -050041};
42
Ray Juidd9d4e72016-10-31 17:38:39 -070043/**
Krzysztof Wilczyński347269c2021-07-03 15:13:02 +000044 * struct iproc_pcie_ib - iProc PCIe inbound mapping
Ray Juidd9d4e72016-10-31 17:38:39 -070045 * @nr_regions: total number of supported inbound mapping regions
46 */
47struct iproc_pcie_ib {
48 unsigned int nr_regions;
49};
50
Ray Jui4213e152016-10-31 17:38:37 -070051struct iproc_pcie_ob_map;
Ray Juidd9d4e72016-10-31 17:38:39 -070052struct iproc_pcie_ib_map;
Ray Jui3bc2b232016-01-06 18:04:35 -060053struct iproc_msi;
54
Ray Juie99a1872015-10-16 08:18:24 -050055/**
Krzysztof Wilczyński347269c2021-07-03 15:13:02 +000056 * struct iproc_pcie - iProc PCIe device
Ray Jui1fb37a82015-04-08 11:21:35 -070057 * @dev: pointer to device data structure
Ray Jui943ebae2015-12-04 09:34:59 -080058 * @type: iProc PCIe interface type
59 * @reg_offsets: register offsets
Ray Jui1fb37a82015-04-08 11:21:35 -070060 * @base: PCIe host controller I/O register base
Ray Jui3bc2b232016-01-06 18:04:35 -060061 * @base_addr: PCIe host controller register base physical address
Krzysztof Wilczyński347269c2021-07-03 15:13:02 +000062 * @mem: host bridge memory window resource
Ray Jui1fb37a82015-04-08 11:21:35 -070063 * @phy: optional PHY device that controls the Serdes
Ray Jui5d92f412015-09-15 17:39:15 -070064 * @map_irq: function callback to map interrupts
Ray Jui06324ed2016-10-31 17:38:30 -070065 * @ep_is_internal: indicates an internal emulated endpoint device is connected
Ray Juif78e60a2018-06-11 17:21:06 -070066 * @iproc_cfg_read: indicates the iProc config read function should be used
67 * @rej_unconfig_pf: indicates the root complex needs to detect and reject
68 * enumeration against unconfigured physical functions emulated in the ASIC
Ray Jui538928f2016-10-31 17:38:33 -070069 * @has_apb_err_disable: indicates the controller can be configured to prevent
70 * unsupported request from being forwarded as an APB bus error
Ray Jui3bc70822018-06-11 17:21:04 -070071 * @fix_paxc_cap: indicates the controller has corrupted capability list in its
72 * config space registers and requires SW based fixup
Ray Jui4213e152016-10-31 17:38:37 -070073 *
Ray Jui3bc2b232016-01-06 18:04:35 -060074 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
Ray Jui4213e152016-10-31 17:38:37 -070075 * @ob: outbound mapping related parameters
76 * @ob_map: outbound mapping related parameters specific to the controller
77 *
Ray Jui3b65ca52018-01-11 12:36:16 -080078 * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
Ray Juidd9d4e72016-10-31 17:38:39 -070079 * @ib: inbound mapping related parameters
80 * @ib_map: outbound mapping region related parameters
81 *
Ray Jui787b3c42016-10-31 17:38:35 -070082 * @need_msi_steer: indicates additional configuration of the iProc PCIe
83 * controller is required to steer MSI writes to external interrupt controller
Ray Jui3bc2b232016-01-06 18:04:35 -060084 * @msi: MSI data
Ray Jui1fb37a82015-04-08 11:21:35 -070085 */
86struct iproc_pcie {
87 struct device *dev;
Ray Jui943ebae2015-12-04 09:34:59 -080088 enum iproc_pcie_type type;
Ray Jui06324ed2016-10-31 17:38:30 -070089 u16 *reg_offsets;
Ray Jui1fb37a82015-04-08 11:21:35 -070090 void __iomem *base;
Ray Jui3bc2b232016-01-06 18:04:35 -060091 phys_addr_t base_addr;
Bjorn Helgaas6e347b52017-03-09 11:27:07 -060092 struct resource mem;
Ray Jui1fb37a82015-04-08 11:21:35 -070093 struct phy *phy;
Hauke Mehrtensc1e02ce2015-05-12 23:23:00 +020094 int (*map_irq)(const struct pci_dev *, u8, u8);
Ray Jui06324ed2016-10-31 17:38:30 -070095 bool ep_is_internal;
Ray Juif78e60a2018-06-11 17:21:06 -070096 bool iproc_cfg_read;
97 bool rej_unconfig_pf;
Ray Jui538928f2016-10-31 17:38:33 -070098 bool has_apb_err_disable;
Ray Jui3bc70822018-06-11 17:21:04 -070099 bool fix_paxc_cap;
Ray Jui4213e152016-10-31 17:38:37 -0700100
Ray Juie99a1872015-10-16 08:18:24 -0500101 bool need_ob_cfg;
102 struct iproc_pcie_ob ob;
Ray Jui4213e152016-10-31 17:38:37 -0700103 const struct iproc_pcie_ob_map *ob_map;
104
Ray Jui3b65ca52018-01-11 12:36:16 -0800105 bool need_ib_cfg;
Ray Juidd9d4e72016-10-31 17:38:39 -0700106 struct iproc_pcie_ib ib;
107 const struct iproc_pcie_ib_map *ib_map;
108
Ray Jui787b3c42016-10-31 17:38:35 -0700109 bool need_msi_steer;
Ray Jui3bc2b232016-01-06 18:04:35 -0600110 struct iproc_msi *msi;
Ray Jui1fb37a82015-04-08 11:21:35 -0700111};
112
Hauke Mehrtens18c43422015-05-24 22:37:02 +0200113int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
Ray Jui1fb37a82015-04-08 11:21:35 -0700114int iproc_pcie_remove(struct iproc_pcie *pcie);
Oza Pawandeepb91c26c2017-08-28 16:43:35 -0500115int iproc_pcie_shutdown(struct iproc_pcie *pcie);
Ray Jui1fb37a82015-04-08 11:21:35 -0700116
Ray Jui3bc2b232016-01-06 18:04:35 -0600117#ifdef CONFIG_PCIE_IPROC_MSI
118int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
119void iproc_msi_exit(struct iproc_pcie *pcie);
120#else
121static inline int iproc_msi_init(struct iproc_pcie *pcie,
122 struct device_node *node)
123{
124 return -ENODEV;
125}
126static inline void iproc_msi_exit(struct iproc_pcie *pcie)
127{
128}
129#endif
130
Ray Jui1fb37a82015-04-08 11:21:35 -0700131#endif /* _PCIE_IPROC_H */