Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2014-2015 Broadcom Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef _PCIE_IPROC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define _PCIE_IPROC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * iProc PCIe interface type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * PAXB is the wrapper used in root complex that can be connected to an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * external endpoint device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * PAXC is the wrapper used in root complex dedicated for internal emulated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * endpoint devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) enum iproc_pcie_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	IPROC_PCIE_PAXB_BCMA = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	IPROC_PCIE_PAXB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	IPROC_PCIE_PAXB_V2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	IPROC_PCIE_PAXC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	IPROC_PCIE_PAXC_V2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * iProc PCIe outbound mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * @axi_offset: offset from the AXI address to the internal address used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * the iProc PCIe core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * @nr_windows: total number of supported outbound mapping windows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct iproc_pcie_ob {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	resource_size_t axi_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	unsigned int nr_windows;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * iProc PCIe inbound mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * @nr_regions: total number of supported inbound mapping regions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) struct iproc_pcie_ib {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	unsigned int nr_regions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct iproc_pcie_ob_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) struct iproc_pcie_ib_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) struct iproc_msi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * iProc PCIe device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * @dev: pointer to device data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * @type: iProc PCIe interface type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * @reg_offsets: register offsets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * @base: PCIe host controller I/O register base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * @base_addr: PCIe host controller register base physical address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * @phy: optional PHY device that controls the Serdes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * @map_irq: function callback to map interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * @ep_is_internal: indicates an internal emulated endpoint device is connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * @iproc_cfg_read: indicates the iProc config read function should be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * @rej_unconfig_pf: indicates the root complex needs to detect and reject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * enumeration against unconfigured physical functions emulated in the ASIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * @has_apb_err_disable: indicates the controller can be configured to prevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * unsupported request from being forwarded as an APB bus error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * @fix_paxc_cap: indicates the controller has corrupted capability list in its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * config space registers and requires SW based fixup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * @ob: outbound mapping related parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @ob_map: outbound mapping related parameters specific to the controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @ib: inbound mapping related parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * @ib_map: outbound mapping region related parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * @need_msi_steer: indicates additional configuration of the iProc PCIe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * controller is required to steer MSI writes to external interrupt controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * @msi: MSI data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) struct iproc_pcie {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	enum iproc_pcie_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	u16 *reg_offsets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	phys_addr_t base_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct resource mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int (*map_irq)(const struct pci_dev *, u8, u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	bool ep_is_internal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	bool iproc_cfg_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	bool rej_unconfig_pf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	bool has_apb_err_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	bool fix_paxc_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	bool need_ob_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct iproc_pcie_ob ob;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	const struct iproc_pcie_ob_map *ob_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	bool need_ib_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct iproc_pcie_ib ib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	const struct iproc_pcie_ib_map *ib_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	bool need_msi_steer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct iproc_msi *msi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int iproc_pcie_remove(struct iproc_pcie *pcie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int iproc_pcie_shutdown(struct iproc_pcie *pcie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #ifdef CONFIG_PCIE_IPROC_MSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void iproc_msi_exit(struct iproc_pcie *pcie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline int iproc_msi_init(struct iproc_pcie *pcie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 				 struct device_node *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static inline void iproc_msi_exit(struct iproc_pcie *pcie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #endif /* _PCIE_IPROC_H */