Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014-2015 Broadcom Corporation |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation version 2. |
| 7 | * |
| 8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any |
| 9 | * kind, whether express or implied; without even the implied warranty |
| 10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #ifndef _PCIE_IPROC_H |
| 15 | #define _PCIE_IPROC_H |
| 16 | |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 17 | /** |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 18 | * iProc PCIe interface type |
| 19 | * |
| 20 | * PAXB is the wrapper used in root complex that can be connected to an |
| 21 | * external endpoint device. |
| 22 | * |
| 23 | * PAXC is the wrapper used in root complex dedicated for internal emulated |
| 24 | * endpoint devices. |
| 25 | */ |
| 26 | enum iproc_pcie_type { |
Ray Jui | 404349c | 2016-10-31 17:38:32 -0700 | [diff] [blame] | 27 | IPROC_PCIE_PAXB_BCMA = 0, |
| 28 | IPROC_PCIE_PAXB, |
Ray Jui | c7c4452 | 2016-10-31 17:38:41 -0700 | [diff] [blame] | 29 | IPROC_PCIE_PAXB_V2, |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 30 | IPROC_PCIE_PAXC, |
Ray Jui | 787b3c4 | 2016-10-31 17:38:35 -0700 | [diff] [blame] | 31 | IPROC_PCIE_PAXC_V2, |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | /** |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 35 | * iProc PCIe outbound mapping |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 36 | * @axi_offset: offset from the AXI address to the internal address used by |
| 37 | * the iProc PCIe core |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 38 | * @nr_windows: total number of supported outbound mapping windows |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 39 | */ |
| 40 | struct iproc_pcie_ob { |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 41 | resource_size_t axi_offset; |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 42 | unsigned int nr_windows; |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 43 | }; |
| 44 | |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 45 | /** |
| 46 | * iProc PCIe inbound mapping |
| 47 | * @nr_regions: total number of supported inbound mapping regions |
| 48 | */ |
| 49 | struct iproc_pcie_ib { |
| 50 | unsigned int nr_regions; |
| 51 | }; |
| 52 | |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 53 | struct iproc_pcie_ob_map; |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 54 | struct iproc_pcie_ib_map; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 55 | struct iproc_msi; |
| 56 | |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 57 | /** |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 58 | * iProc PCIe device |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 59 | * |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 60 | * @dev: pointer to device data structure |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 61 | * @type: iProc PCIe interface type |
| 62 | * @reg_offsets: register offsets |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 63 | * @base: PCIe host controller I/O register base |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 64 | * @base_addr: PCIe host controller register base physical address |
Ray Jui | 8d9bfe3 | 2015-07-21 18:29:40 -0700 | [diff] [blame] | 65 | * @sysdata: Per PCI controller data (ARM-specific) |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 66 | * @root_bus: pointer to root bus |
| 67 | * @phy: optional PHY device that controls the Serdes |
Ray Jui | 5d92f41 | 2015-09-15 17:39:15 -0700 | [diff] [blame] | 68 | * @map_irq: function callback to map interrupts |
Ray Jui | 06324ed | 2016-10-31 17:38:30 -0700 | [diff] [blame] | 69 | * @ep_is_internal: indicates an internal emulated endpoint device is connected |
Ray Jui | 538928f | 2016-10-31 17:38:33 -0700 | [diff] [blame] | 70 | * @has_apb_err_disable: indicates the controller can be configured to prevent |
| 71 | * unsupported request from being forwarded as an APB bus error |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 72 | * |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 73 | * @need_ob_cfg: indicates SW needs to configure the outbound mapping window |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 74 | * @ob: outbound mapping related parameters |
| 75 | * @ob_map: outbound mapping related parameters specific to the controller |
| 76 | * |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 77 | * @ib: inbound mapping related parameters |
| 78 | * @ib_map: outbound mapping region related parameters |
| 79 | * |
Ray Jui | 787b3c4 | 2016-10-31 17:38:35 -0700 | [diff] [blame] | 80 | * @need_msi_steer: indicates additional configuration of the iProc PCIe |
| 81 | * controller is required to steer MSI writes to external interrupt controller |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 82 | * @msi: MSI data |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 83 | */ |
| 84 | struct iproc_pcie { |
| 85 | struct device *dev; |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 86 | enum iproc_pcie_type type; |
Ray Jui | 06324ed | 2016-10-31 17:38:30 -0700 | [diff] [blame] | 87 | u16 *reg_offsets; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 88 | void __iomem *base; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 89 | phys_addr_t base_addr; |
Ray Jui | 8d9bfe3 | 2015-07-21 18:29:40 -0700 | [diff] [blame] | 90 | #ifdef CONFIG_ARM |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 91 | struct pci_sys_data sysdata; |
Ray Jui | 8d9bfe3 | 2015-07-21 18:29:40 -0700 | [diff] [blame] | 92 | #endif |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 93 | struct pci_bus *root_bus; |
| 94 | struct phy *phy; |
Hauke Mehrtens | c1e02ce | 2015-05-12 23:23:00 +0200 | [diff] [blame] | 95 | int (*map_irq)(const struct pci_dev *, u8, u8); |
Ray Jui | 06324ed | 2016-10-31 17:38:30 -0700 | [diff] [blame] | 96 | bool ep_is_internal; |
Ray Jui | 538928f | 2016-10-31 17:38:33 -0700 | [diff] [blame] | 97 | bool has_apb_err_disable; |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 98 | |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 99 | bool need_ob_cfg; |
| 100 | struct iproc_pcie_ob ob; |
Ray Jui | 4213e15 | 2016-10-31 17:38:37 -0700 | [diff] [blame] | 101 | const struct iproc_pcie_ob_map *ob_map; |
| 102 | |
Ray Jui | dd9d4e7 | 2016-10-31 17:38:39 -0700 | [diff] [blame] | 103 | struct iproc_pcie_ib ib; |
| 104 | const struct iproc_pcie_ib_map *ib_map; |
| 105 | |
Ray Jui | 787b3c4 | 2016-10-31 17:38:35 -0700 | [diff] [blame] | 106 | bool need_msi_steer; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 107 | struct iproc_msi *msi; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
Hauke Mehrtens | 18c4342 | 2015-05-24 22:37:02 +0200 | [diff] [blame] | 110 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res); |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 111 | int iproc_pcie_remove(struct iproc_pcie *pcie); |
| 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 */ |