Bjorn Helgaas | 8cfab3c | 2018-01-26 12:50:27 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014-2015 Broadcom Corporation |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _PCIE_IPROC_H |
| 7 | #define _PCIE_IPROC_H |
| 8 | |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 9 | /** |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 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 | */ |
| 18 | enum iproc_pcie_type { |
Ray Jui | 404349c | 2016-10-31 17:38:32 -0700 | [diff] [blame] | 19 | IPROC_PCIE_PAXB_BCMA = 0, |
| 20 | IPROC_PCIE_PAXB, |
Ray Jui | c7c4452 | 2016-10-31 17:38:41 -0700 | [diff] [blame] | 21 | IPROC_PCIE_PAXB_V2, |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 22 | IPROC_PCIE_PAXC, |
Ray Jui | 787b3c4 | 2016-10-31 17:38:35 -0700 | [diff] [blame] | 23 | IPROC_PCIE_PAXC_V2, |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | /** |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 27 | * iProc PCIe outbound mapping |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 28 | * @axi_offset: offset from the AXI address to the internal address used by |
| 29 | * the iProc PCIe core |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 30 | * @nr_windows: total number of supported outbound mapping windows |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 31 | */ |
| 32 | struct iproc_pcie_ob { |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 33 | resource_size_t axi_offset; |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 34 | unsigned int nr_windows; |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 35 | }; |
| 36 | |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 37 | /** |
| 38 | * iProc PCIe inbound mapping |
| 39 | * @nr_regions: total number of supported inbound mapping regions |
| 40 | */ |
| 41 | struct iproc_pcie_ib { |
| 42 | unsigned int nr_regions; |
| 43 | }; |
| 44 | |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 45 | struct iproc_pcie_ob_map; |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 46 | struct iproc_pcie_ib_map; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 47 | struct iproc_msi; |
| 48 | |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 49 | /** |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 50 | * iProc PCIe device |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 51 | * |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 52 | * @dev: pointer to device data structure |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 53 | * @type: iProc PCIe interface type |
| 54 | * @reg_offsets: register offsets |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 55 | * @base: PCIe host controller I/O register base |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 56 | * @base_addr: PCIe host controller register base physical address |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 57 | * @root_bus: pointer to root bus |
| 58 | * @phy: optional PHY device that controls the Serdes |
Ray Jui | 5d92f41 | 2015-09-15 17:39:15 -0700 | [diff] [blame] | 59 | * @map_irq: function callback to map interrupts |
Ray Jui | 06324ed | 2016-10-31 17:38:30 -0700 | [diff] [blame] | 60 | * @ep_is_internal: indicates an internal emulated endpoint device is connected |
Ray Jui | f78e60a | 2018-06-11 17:21:06 -0700 | [diff] [blame] | 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 |
Ray Jui | 538928f | 2016-10-31 17:38:33 -0700 | [diff] [blame] | 64 | * @has_apb_err_disable: indicates the controller can be configured to prevent |
| 65 | * unsupported request from being forwarded as an APB bus error |
Ray Jui | 3bc7082 | 2018-06-11 17:21:04 -0700 | [diff] [blame] | 66 | * @fix_paxc_cap: indicates the controller has corrupted capability list in its |
| 67 | * config space registers and requires SW based fixup |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 68 | * |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 69 | * @need_ob_cfg: indicates SW needs to configure the outbound mapping window |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 70 | * @ob: outbound mapping related parameters |
| 71 | * @ob_map: outbound mapping related parameters specific to the controller |
| 72 | * |
Ray Jui | 3b65ca5 | 2018-01-11 12:36:16 -0800 | [diff] [blame] | 73 | * @need_ib_cfg: indicates SW needs to configure the inbound mapping window |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 74 | * @ib: inbound mapping related parameters |
| 75 | * @ib_map: outbound mapping region related parameters |
| 76 | * |
Ray Jui | 787b3c4 | 2016-10-31 17:38:35 -0700 | [diff] [blame] | 77 | * @need_msi_steer: indicates additional configuration of the iProc PCIe |
| 78 | * controller is required to steer MSI writes to external interrupt controller |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 79 | * @msi: MSI data |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 80 | */ |
| 81 | struct iproc_pcie { |
| 82 | struct device *dev; |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 83 | enum iproc_pcie_type type; |
Ray Jui | 06324ed | 2016-10-31 17:38:30 -0700 | [diff] [blame] | 84 | u16 *reg_offsets; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 85 | void __iomem *base; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 86 | phys_addr_t base_addr; |
Bjorn Helgaas | 6e347b5 | 2017-03-09 11:27:07 -0600 | [diff] [blame] | 87 | struct resource mem; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 88 | struct pci_bus *root_bus; |
| 89 | struct phy *phy; |
Hauke Mehrtens | c1e02ce | 2015-05-12 23:23:00 +0200 | [diff] [blame] | 90 | int (*map_irq)(const struct pci_dev *, u8, u8); |
Ray Jui | 06324ed | 2016-10-31 17:38:30 -0700 | [diff] [blame] | 91 | bool ep_is_internal; |
Ray Jui | f78e60a | 2018-06-11 17:21:06 -0700 | [diff] [blame] | 92 | bool iproc_cfg_read; |
| 93 | bool rej_unconfig_pf; |
Ray Jui | 538928f | 2016-10-31 17:38:33 -0700 | [diff] [blame] | 94 | bool has_apb_err_disable; |
Ray Jui | 3bc7082 | 2018-06-11 17:21:04 -0700 | [diff] [blame] | 95 | bool fix_paxc_cap; |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 96 | |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 97 | bool need_ob_cfg; |
| 98 | struct iproc_pcie_ob ob; |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 99 | const struct iproc_pcie_ob_map *ob_map; |
| 100 | |
Ray Jui | 3b65ca5 | 2018-01-11 12:36:16 -0800 | [diff] [blame] | 101 | bool need_ib_cfg; |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 102 | struct iproc_pcie_ib ib; |
| 103 | const struct iproc_pcie_ib_map *ib_map; |
| 104 | |
Ray Jui | 787b3c4 | 2016-10-31 17:38:35 -0700 | [diff] [blame] | 105 | bool need_msi_steer; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 106 | struct iproc_msi *msi; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
Hauke Mehrtens | 18c4342 | 2015-05-24 22:37:02 +0200 | [diff] [blame] | 109 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res); |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 110 | int iproc_pcie_remove(struct iproc_pcie *pcie); |
Oza Pawandeep | b91c26c | 2017-08-28 16:43:35 -0500 | [diff] [blame] | 111 | int iproc_pcie_shutdown(struct iproc_pcie *pcie); |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 112 | |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 113 | #ifdef CONFIG_PCIE_IPROC_MSI |
| 114 | int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node); |
| 115 | void iproc_msi_exit(struct iproc_pcie *pcie); |
| 116 | #else |
| 117 | static inline int iproc_msi_init(struct iproc_pcie *pcie, |
| 118 | struct device_node *node) |
| 119 | { |
| 120 | return -ENODEV; |
| 121 | } |
| 122 | static inline void iproc_msi_exit(struct iproc_pcie *pcie) |
| 123 | { |
| 124 | } |
| 125 | #endif |
| 126 | |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 127 | #endif /* _PCIE_IPROC_H */ |