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