blob: 04fed8e907f12b602b5fb1f11ff59971ebd0b87f [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 {
Ray Jui404349c2016-10-31 17:38:32 -070027 IPROC_PCIE_PAXB_BCMA = 0,
28 IPROC_PCIE_PAXB,
Ray Juic7c44522016-10-31 17:38:41 -070029 IPROC_PCIE_PAXB_V2,
Ray Jui943ebae2015-12-04 09:34:59 -080030 IPROC_PCIE_PAXC,
Ray Jui787b3c42016-10-31 17:38:35 -070031 IPROC_PCIE_PAXC_V2,
Ray Jui943ebae2015-12-04 09:34:59 -080032};
33
34/**
Ray Juie99a1872015-10-16 08:18:24 -050035 * iProc PCIe outbound mapping
Ray Juie99a1872015-10-16 08:18:24 -050036 * @axi_offset: offset from the AXI address to the internal address used by
37 * the iProc PCIe core
Ray Jui4213e152016-10-31 17:38:37 -070038 * @nr_windows: total number of supported outbound mapping windows
Ray Juie99a1872015-10-16 08:18:24 -050039 */
40struct iproc_pcie_ob {
Ray Juie99a1872015-10-16 08:18:24 -050041 resource_size_t axi_offset;
Ray Jui4213e152016-10-31 17:38:37 -070042 unsigned int nr_windows;
Ray Juie99a1872015-10-16 08:18:24 -050043};
44
Ray Juidd9d4e72016-10-31 17:38:39 -070045/**
46 * iProc PCIe inbound mapping
47 * @nr_regions: total number of supported inbound mapping regions
48 */
49struct iproc_pcie_ib {
50 unsigned int nr_regions;
51};
52
Ray Jui4213e152016-10-31 17:38:37 -070053struct iproc_pcie_ob_map;
Ray Juidd9d4e72016-10-31 17:38:39 -070054struct iproc_pcie_ib_map;
Ray Jui3bc2b232016-01-06 18:04:35 -060055struct iproc_msi;
56
Ray Juie99a1872015-10-16 08:18:24 -050057/**
Ray Jui1fb37a82015-04-08 11:21:35 -070058 * iProc PCIe device
Ray Jui943ebae2015-12-04 09:34:59 -080059 *
Ray Jui1fb37a82015-04-08 11:21:35 -070060 * @dev: pointer to device data structure
Ray Jui943ebae2015-12-04 09:34:59 -080061 * @type: iProc PCIe interface type
62 * @reg_offsets: register offsets
Ray Jui1fb37a82015-04-08 11:21:35 -070063 * @base: PCIe host controller I/O register base
Ray Jui3bc2b232016-01-06 18:04:35 -060064 * @base_addr: PCIe host controller register base physical address
Ray Jui8d9bfe32015-07-21 18:29:40 -070065 * @sysdata: Per PCI controller data (ARM-specific)
Ray Jui1fb37a82015-04-08 11:21:35 -070066 * @root_bus: pointer to root bus
67 * @phy: optional PHY device that controls the Serdes
Ray Jui5d92f412015-09-15 17:39:15 -070068 * @map_irq: function callback to map interrupts
Ray Jui06324ed2016-10-31 17:38:30 -070069 * @ep_is_internal: indicates an internal emulated endpoint device is connected
Ray Jui538928f2016-10-31 17:38:33 -070070 * @has_apb_err_disable: indicates the controller can be configured to prevent
71 * unsupported request from being forwarded as an APB bus error
Ray Jui4213e152016-10-31 17:38:37 -070072 *
Ray Jui3bc2b232016-01-06 18:04:35 -060073 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
Ray Jui4213e152016-10-31 17:38:37 -070074 * @ob: outbound mapping related parameters
75 * @ob_map: outbound mapping related parameters specific to the controller
76 *
Ray Juidd9d4e72016-10-31 17:38:39 -070077 * @ib: inbound mapping related parameters
78 * @ib_map: outbound mapping region related parameters
79 *
Ray Jui787b3c42016-10-31 17:38:35 -070080 * @need_msi_steer: indicates additional configuration of the iProc PCIe
81 * controller is required to steer MSI writes to external interrupt controller
Ray Jui3bc2b232016-01-06 18:04:35 -060082 * @msi: MSI data
Ray Jui1fb37a82015-04-08 11:21:35 -070083 */
84struct iproc_pcie {
85 struct device *dev;
Ray Jui943ebae2015-12-04 09:34:59 -080086 enum iproc_pcie_type type;
Ray Jui06324ed2016-10-31 17:38:30 -070087 u16 *reg_offsets;
Ray Jui1fb37a82015-04-08 11:21:35 -070088 void __iomem *base;
Ray Jui3bc2b232016-01-06 18:04:35 -060089 phys_addr_t base_addr;
Ray Jui8d9bfe32015-07-21 18:29:40 -070090#ifdef CONFIG_ARM
Ray Jui1fb37a82015-04-08 11:21:35 -070091 struct pci_sys_data sysdata;
Ray Jui8d9bfe32015-07-21 18:29:40 -070092#endif
Ray Jui1fb37a82015-04-08 11:21:35 -070093 struct pci_bus *root_bus;
94 struct phy *phy;
Hauke Mehrtensc1e02ce2015-05-12 23:23:00 +020095 int (*map_irq)(const struct pci_dev *, u8, u8);
Ray Jui06324ed2016-10-31 17:38:30 -070096 bool ep_is_internal;
Ray Jui538928f2016-10-31 17:38:33 -070097 bool has_apb_err_disable;
Ray Jui4213e152016-10-31 17:38:37 -070098
Ray Juie99a1872015-10-16 08:18:24 -050099 bool need_ob_cfg;
100 struct iproc_pcie_ob ob;
Ray Jui4213e152016-10-31 17:38:37 -0700101 const struct iproc_pcie_ob_map *ob_map;
102
Ray Juidd9d4e72016-10-31 17:38:39 -0700103 struct iproc_pcie_ib ib;
104 const struct iproc_pcie_ib_map *ib_map;
105
Ray Jui787b3c42016-10-31 17:38:35 -0700106 bool need_msi_steer;
Ray Jui3bc2b232016-01-06 18:04:35 -0600107 struct iproc_msi *msi;
Ray Jui1fb37a82015-04-08 11:21:35 -0700108};
109
Hauke Mehrtens18c43422015-05-24 22:37:02 +0200110int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
Ray Jui1fb37a82015-04-08 11:21:35 -0700111int iproc_pcie_remove(struct iproc_pcie *pcie);
112
Ray Jui3bc2b232016-01-06 18:04:35 -0600113#ifdef CONFIG_PCIE_IPROC_MSI
114int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
115void iproc_msi_exit(struct iproc_pcie *pcie);
116#else
117static inline int iproc_msi_init(struct iproc_pcie *pcie,
118 struct device_node *node)
119{
120 return -ENODEV;
121}
122static inline void iproc_msi_exit(struct iproc_pcie *pcie)
123{
124}
125#endif
126
Ray Jui1fb37a82015-04-08 11:21:35 -0700127#endif /* _PCIE_IPROC_H */