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 { |
| 27 | IPROC_PCIE_PAXB = 0, |
| 28 | IPROC_PCIE_PAXC, |
| 29 | }; |
| 30 | |
| 31 | /** |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 32 | * iProc PCIe outbound mapping |
| 33 | * @set_oarr_size: indicates the OARR size bit needs to be set |
| 34 | * @axi_offset: offset from the AXI address to the internal address used by |
| 35 | * the iProc PCIe core |
| 36 | * @window_size: outbound window size |
| 37 | */ |
| 38 | struct iproc_pcie_ob { |
| 39 | bool set_oarr_size; |
| 40 | resource_size_t axi_offset; |
| 41 | resource_size_t window_size; |
| 42 | }; |
| 43 | |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 44 | struct iproc_msi; |
| 45 | |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 46 | /** |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 47 | * iProc PCIe device |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 48 | * |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 49 | * @dev: pointer to device data structure |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 50 | * @type: iProc PCIe interface type |
| 51 | * @reg_offsets: register offsets |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 52 | * @base: PCIe host controller I/O register base |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 53 | * @base_addr: PCIe host controller register base physical address |
Ray Jui | 8d9bfe3 | 2015-07-21 18:29:40 -0700 | [diff] [blame] | 54 | * @sysdata: Per PCI controller data (ARM-specific) |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 55 | * @root_bus: pointer to root bus |
| 56 | * @phy: optional PHY device that controls the Serdes |
Ray Jui | 5d92f41 | 2015-09-15 17:39:15 -0700 | [diff] [blame] | 57 | * @map_irq: function callback to map interrupts |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 58 | * @need_ob_cfg: indicates SW needs to configure the outbound mapping window |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 59 | * @ob: outbound mapping parameters |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 60 | * @msi: MSI data |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 61 | */ |
| 62 | struct iproc_pcie { |
| 63 | struct device *dev; |
Ray Jui | 943ebae | 2015-12-04 09:34:59 -0800 | [diff] [blame] | 64 | enum iproc_pcie_type type; |
| 65 | const u16 *reg_offsets; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 66 | void __iomem *base; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 67 | phys_addr_t base_addr; |
Ray Jui | 8d9bfe3 | 2015-07-21 18:29:40 -0700 | [diff] [blame] | 68 | #ifdef CONFIG_ARM |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 69 | struct pci_sys_data sysdata; |
Ray Jui | 8d9bfe3 | 2015-07-21 18:29:40 -0700 | [diff] [blame] | 70 | #endif |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 71 | struct pci_bus *root_bus; |
| 72 | struct phy *phy; |
Hauke Mehrtens | c1e02ce | 2015-05-12 23:23:00 +0200 | [diff] [blame] | 73 | int (*map_irq)(const struct pci_dev *, u8, u8); |
Ray Jui | e99a187 | 2015-10-16 08:18:24 -0500 | [diff] [blame] | 74 | bool need_ob_cfg; |
| 75 | struct iproc_pcie_ob ob; |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 76 | struct iproc_msi *msi; |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
Hauke Mehrtens | 18c4342 | 2015-05-24 22:37:02 +0200 | [diff] [blame] | 79 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res); |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 80 | int iproc_pcie_remove(struct iproc_pcie *pcie); |
| 81 | |
Ray Jui | 3bc2b23 | 2016-01-06 18:04:35 -0600 | [diff] [blame] | 82 | #ifdef CONFIG_PCIE_IPROC_MSI |
| 83 | int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node); |
| 84 | void iproc_msi_exit(struct iproc_pcie *pcie); |
| 85 | #else |
| 86 | static inline int iproc_msi_init(struct iproc_pcie *pcie, |
| 87 | struct device_node *node) |
| 88 | { |
| 89 | return -ENODEV; |
| 90 | } |
| 91 | static inline void iproc_msi_exit(struct iproc_pcie *pcie) |
| 92 | { |
| 93 | } |
| 94 | #endif |
| 95 | |
Ray Jui | 1fb37a8 | 2015-04-08 11:21:35 -0700 | [diff] [blame] | 96 | #endif /* _PCIE_IPROC_H */ |