blob: e84d93c53c7b59ee5cf75a002f95860f1ee2fba9 [file] [log] [blame]
Ray Jui1fb37a82015-04-08 11:21:35 -07001/*
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 Jui1fb37a82015-04-08 11:21:35 -070017/**
Ray Jui943ebae2015-12-04 09:34:59 -080018 * 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 */
26enum iproc_pcie_type {
27 IPROC_PCIE_PAXB = 0,
28 IPROC_PCIE_PAXC,
29};
30
31/**
Ray Juie99a1872015-10-16 08:18:24 -050032 * 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 */
38struct iproc_pcie_ob {
39 bool set_oarr_size;
40 resource_size_t axi_offset;
41 resource_size_t window_size;
42};
43
Ray Jui3bc2b232016-01-06 18:04:35 -060044struct iproc_msi;
45
Ray Juie99a1872015-10-16 08:18:24 -050046/**
Ray Jui1fb37a82015-04-08 11:21:35 -070047 * iProc PCIe device
Ray Jui943ebae2015-12-04 09:34:59 -080048 *
Ray Jui1fb37a82015-04-08 11:21:35 -070049 * @dev: pointer to device data structure
Ray Jui943ebae2015-12-04 09:34:59 -080050 * @type: iProc PCIe interface type
51 * @reg_offsets: register offsets
Ray Jui1fb37a82015-04-08 11:21:35 -070052 * @base: PCIe host controller I/O register base
Ray Jui3bc2b232016-01-06 18:04:35 -060053 * @base_addr: PCIe host controller register base physical address
Ray Jui8d9bfe32015-07-21 18:29:40 -070054 * @sysdata: Per PCI controller data (ARM-specific)
Ray Jui1fb37a82015-04-08 11:21:35 -070055 * @root_bus: pointer to root bus
56 * @phy: optional PHY device that controls the Serdes
Ray Jui5d92f412015-09-15 17:39:15 -070057 * @map_irq: function callback to map interrupts
Ray Jui3bc2b232016-01-06 18:04:35 -060058 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
Ray Juie99a1872015-10-16 08:18:24 -050059 * @ob: outbound mapping parameters
Ray Jui3bc2b232016-01-06 18:04:35 -060060 * @msi: MSI data
Ray Jui1fb37a82015-04-08 11:21:35 -070061 */
62struct iproc_pcie {
63 struct device *dev;
Ray Jui943ebae2015-12-04 09:34:59 -080064 enum iproc_pcie_type type;
65 const u16 *reg_offsets;
Ray Jui1fb37a82015-04-08 11:21:35 -070066 void __iomem *base;
Ray Jui3bc2b232016-01-06 18:04:35 -060067 phys_addr_t base_addr;
Ray Jui8d9bfe32015-07-21 18:29:40 -070068#ifdef CONFIG_ARM
Ray Jui1fb37a82015-04-08 11:21:35 -070069 struct pci_sys_data sysdata;
Ray Jui8d9bfe32015-07-21 18:29:40 -070070#endif
Ray Jui1fb37a82015-04-08 11:21:35 -070071 struct pci_bus *root_bus;
72 struct phy *phy;
Hauke Mehrtensc1e02ce2015-05-12 23:23:00 +020073 int (*map_irq)(const struct pci_dev *, u8, u8);
Ray Juie99a1872015-10-16 08:18:24 -050074 bool need_ob_cfg;
75 struct iproc_pcie_ob ob;
Ray Jui3bc2b232016-01-06 18:04:35 -060076 struct iproc_msi *msi;
Ray Jui1fb37a82015-04-08 11:21:35 -070077};
78
Hauke Mehrtens18c43422015-05-24 22:37:02 +020079int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
Ray Jui1fb37a82015-04-08 11:21:35 -070080int iproc_pcie_remove(struct iproc_pcie *pcie);
81
Ray Jui3bc2b232016-01-06 18:04:35 -060082#ifdef CONFIG_PCIE_IPROC_MSI
83int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
84void iproc_msi_exit(struct iproc_pcie *pcie);
85#else
86static inline int iproc_msi_init(struct iproc_pcie *pcie,
87 struct device_node *node)
88{
89 return -ENODEV;
90}
91static inline void iproc_msi_exit(struct iproc_pcie *pcie)
92{
93}
94#endif
95
Ray Jui1fb37a82015-04-08 11:21:35 -070096#endif /* _PCIE_IPROC_H */