Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2014-2015 Broadcom Corporation
0004  */
0005 
0006 #ifndef _PCIE_IPROC_H
0007 #define _PCIE_IPROC_H
0008 
0009 /**
0010  * enum iproc_pcie_type - iProc PCIe interface type
0011  * @IPROC_PCIE_PAXB_BCMA: BCMA-based host controllers
0012  * @IPROC_PCIE_PAXB:      PAXB-based host controllers for
0013  *            NS, NSP, Cygnus, NS2, and Pegasus SOCs
0014  * @IPROC_PCIE_PAXB_V2:   PAXB-based host controllers for Stingray SoCs
0015  * @IPROC_PCIE_PAXC:      PAXC-based host controllers
0016  * @IPROC_PCIE_PAXC_V2:   PAXC-based host controllers (second generation)
0017  *
0018  * PAXB is the wrapper used in root complex that can be connected to an
0019  * external endpoint device.
0020  *
0021  * PAXC is the wrapper used in root complex dedicated for internal emulated
0022  * endpoint devices.
0023  */
0024 enum iproc_pcie_type {
0025     IPROC_PCIE_PAXB_BCMA = 0,
0026     IPROC_PCIE_PAXB,
0027     IPROC_PCIE_PAXB_V2,
0028     IPROC_PCIE_PAXC,
0029     IPROC_PCIE_PAXC_V2,
0030 };
0031 
0032 /**
0033  * struct iproc_pcie_ob - iProc PCIe outbound mapping
0034  * @axi_offset: offset from the AXI address to the internal address used by
0035  * the iProc PCIe core
0036  * @nr_windows: total number of supported outbound mapping windows
0037  */
0038 struct iproc_pcie_ob {
0039     resource_size_t axi_offset;
0040     unsigned int nr_windows;
0041 };
0042 
0043 /**
0044  * struct iproc_pcie_ib - iProc PCIe inbound mapping
0045  * @nr_regions: total number of supported inbound mapping regions
0046  */
0047 struct iproc_pcie_ib {
0048     unsigned int nr_regions;
0049 };
0050 
0051 struct iproc_pcie_ob_map;
0052 struct iproc_pcie_ib_map;
0053 struct iproc_msi;
0054 
0055 /**
0056  * struct iproc_pcie - iProc PCIe device
0057  * @dev: pointer to device data structure
0058  * @type: iProc PCIe interface type
0059  * @reg_offsets: register offsets
0060  * @base: PCIe host controller I/O register base
0061  * @base_addr: PCIe host controller register base physical address
0062  * @mem: host bridge memory window resource
0063  * @phy: optional PHY device that controls the Serdes
0064  * @map_irq: function callback to map interrupts
0065  * @ep_is_internal: indicates an internal emulated endpoint device is connected
0066  * @iproc_cfg_read: indicates the iProc config read function should be used
0067  * @rej_unconfig_pf: indicates the root complex needs to detect and reject
0068  * enumeration against unconfigured physical functions emulated in the ASIC
0069  * @has_apb_err_disable: indicates the controller can be configured to prevent
0070  * unsupported request from being forwarded as an APB bus error
0071  * @fix_paxc_cap: indicates the controller has corrupted capability list in its
0072  * config space registers and requires SW based fixup
0073  *
0074  * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
0075  * @ob: outbound mapping related parameters
0076  * @ob_map: outbound mapping related parameters specific to the controller
0077  *
0078  * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
0079  * @ib: inbound mapping related parameters
0080  * @ib_map: outbound mapping region related parameters
0081  *
0082  * @need_msi_steer: indicates additional configuration of the iProc PCIe
0083  * controller is required to steer MSI writes to external interrupt controller
0084  * @msi: MSI data
0085  */
0086 struct iproc_pcie {
0087     struct device *dev;
0088     enum iproc_pcie_type type;
0089     u16 *reg_offsets;
0090     void __iomem *base;
0091     phys_addr_t base_addr;
0092     struct resource mem;
0093     struct phy *phy;
0094     int (*map_irq)(const struct pci_dev *, u8, u8);
0095     bool ep_is_internal;
0096     bool iproc_cfg_read;
0097     bool rej_unconfig_pf;
0098     bool has_apb_err_disable;
0099     bool fix_paxc_cap;
0100 
0101     bool need_ob_cfg;
0102     struct iproc_pcie_ob ob;
0103     const struct iproc_pcie_ob_map *ob_map;
0104 
0105     bool need_ib_cfg;
0106     struct iproc_pcie_ib ib;
0107     const struct iproc_pcie_ib_map *ib_map;
0108 
0109     bool need_msi_steer;
0110     struct iproc_msi *msi;
0111 };
0112 
0113 int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
0114 int iproc_pcie_remove(struct iproc_pcie *pcie);
0115 int iproc_pcie_shutdown(struct iproc_pcie *pcie);
0116 
0117 #ifdef CONFIG_PCIE_IPROC_MSI
0118 int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
0119 void iproc_msi_exit(struct iproc_pcie *pcie);
0120 #else
0121 static inline int iproc_msi_init(struct iproc_pcie *pcie,
0122                  struct device_node *node)
0123 {
0124     return -ENODEV;
0125 }
0126 static inline void iproc_msi_exit(struct iproc_pcie *pcie)
0127 {
0128 }
0129 #endif
0130 
0131 #endif /* _PCIE_IPROC_H */