132 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright (C) 2014-2015 Broadcom Corporation4 */5 6#ifndef _PCIE_IPROC_H7#define _PCIE_IPROC_H8 9/**10 * enum iproc_pcie_type - iProc PCIe interface type11 * @IPROC_PCIE_PAXB_BCMA: BCMA-based host controllers12 * @IPROC_PCIE_PAXB: PAXB-based host controllers for13 * NS, NSP, Cygnus, NS2, and Pegasus SOCs14 * @IPROC_PCIE_PAXB_V2: PAXB-based host controllers for Stingray SoCs15 * @IPROC_PCIE_PAXC: PAXC-based host controllers16 * @IPROC_PCIE_PAXC_V2: PAXC-based host controllers (second generation)17 *18 * PAXB is the wrapper used in root complex that can be connected to an19 * external endpoint device.20 *21 * PAXC is the wrapper used in root complex dedicated for internal emulated22 * endpoint devices.23 */24enum iproc_pcie_type {25 IPROC_PCIE_PAXB_BCMA = 0,26 IPROC_PCIE_PAXB,27 IPROC_PCIE_PAXB_V2,28 IPROC_PCIE_PAXC,29 IPROC_PCIE_PAXC_V2,30};31 32/**33 * struct iproc_pcie_ob - iProc PCIe outbound mapping34 * @axi_offset: offset from the AXI address to the internal address used by35 * the iProc PCIe core36 * @nr_windows: total number of supported outbound mapping windows37 */38struct iproc_pcie_ob {39 resource_size_t axi_offset;40 unsigned int nr_windows;41};42 43/**44 * struct iproc_pcie_ib - iProc PCIe inbound mapping45 * @nr_regions: total number of supported inbound mapping regions46 */47struct iproc_pcie_ib {48 unsigned int nr_regions;49};50 51struct iproc_pcie_ob_map;52struct iproc_pcie_ib_map;53struct iproc_msi;54 55/**56 * struct iproc_pcie - iProc PCIe device57 * @dev: pointer to device data structure58 * @type: iProc PCIe interface type59 * @reg_offsets: register offsets60 * @base: PCIe host controller I/O register base61 * @base_addr: PCIe host controller register base physical address62 * @mem: host bridge memory window resource63 * @phy: optional PHY device that controls the Serdes64 * @map_irq: function callback to map interrupts65 * @ep_is_internal: indicates an internal emulated endpoint device is connected66 * @iproc_cfg_read: indicates the iProc config read function should be used67 * @rej_unconfig_pf: indicates the root complex needs to detect and reject68 * enumeration against unconfigured physical functions emulated in the ASIC69 * @has_apb_err_disable: indicates the controller can be configured to prevent70 * unsupported request from being forwarded as an APB bus error71 * @fix_paxc_cap: indicates the controller has corrupted capability list in its72 * config space registers and requires SW based fixup73 *74 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window75 * @ob: outbound mapping related parameters76 * @ob_map: outbound mapping related parameters specific to the controller77 *78 * @need_ib_cfg: indicates SW needs to configure the inbound mapping window79 * @ib: inbound mapping related parameters80 * @ib_map: outbound mapping region related parameters81 *82 * @need_msi_steer: indicates additional configuration of the iProc PCIe83 * controller is required to steer MSI writes to external interrupt controller84 * @msi: MSI data85 */86struct iproc_pcie {87 struct device *dev;88 enum iproc_pcie_type type;89 u16 *reg_offsets;90 void __iomem *base;91 phys_addr_t base_addr;92 struct resource mem;93 struct phy *phy;94 int (*map_irq)(const struct pci_dev *, u8, u8);95 bool ep_is_internal;96 bool iproc_cfg_read;97 bool rej_unconfig_pf;98 bool has_apb_err_disable;99 bool fix_paxc_cap;100 101 bool need_ob_cfg;102 struct iproc_pcie_ob ob;103 const struct iproc_pcie_ob_map *ob_map;104 105 bool need_ib_cfg;106 struct iproc_pcie_ib ib;107 const struct iproc_pcie_ib_map *ib_map;108 109 bool need_msi_steer;110 struct iproc_msi *msi;111};112 113int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);114void iproc_pcie_remove(struct iproc_pcie *pcie);115int iproc_pcie_shutdown(struct iproc_pcie *pcie);116 117#ifdef CONFIG_PCIE_IPROC_MSI118int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);119void iproc_msi_exit(struct iproc_pcie *pcie);120#else121static 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#endif130 131#endif /* _PCIE_IPROC_H */132