162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci// Copyright (c) 2017 Cadence
362306a36Sopenharmony_ci// Cadence PCIe controller driver.
462306a36Sopenharmony_ci// Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com>
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef _PCIE_CADENCE_H
762306a36Sopenharmony_ci#define _PCIE_CADENCE_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/kernel.h>
1062306a36Sopenharmony_ci#include <linux/pci.h>
1162306a36Sopenharmony_ci#include <linux/pci-epf.h>
1262306a36Sopenharmony_ci#include <linux/phy/phy.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* Parameters for the waiting for link up routine */
1562306a36Sopenharmony_ci#define LINK_WAIT_MAX_RETRIES	10
1662306a36Sopenharmony_ci#define LINK_WAIT_USLEEP_MIN	90000
1762306a36Sopenharmony_ci#define LINK_WAIT_USLEEP_MAX	100000
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*
2062306a36Sopenharmony_ci * Local Management Registers
2162306a36Sopenharmony_ci */
2262306a36Sopenharmony_ci#define CDNS_PCIE_LM_BASE	0x00100000
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* Vendor ID Register */
2562306a36Sopenharmony_ci#define CDNS_PCIE_LM_ID		(CDNS_PCIE_LM_BASE + 0x0044)
2662306a36Sopenharmony_ci#define  CDNS_PCIE_LM_ID_VENDOR_MASK	GENMASK(15, 0)
2762306a36Sopenharmony_ci#define  CDNS_PCIE_LM_ID_VENDOR_SHIFT	0
2862306a36Sopenharmony_ci#define  CDNS_PCIE_LM_ID_VENDOR(vid) \
2962306a36Sopenharmony_ci	(((vid) << CDNS_PCIE_LM_ID_VENDOR_SHIFT) & CDNS_PCIE_LM_ID_VENDOR_MASK)
3062306a36Sopenharmony_ci#define  CDNS_PCIE_LM_ID_SUBSYS_MASK	GENMASK(31, 16)
3162306a36Sopenharmony_ci#define  CDNS_PCIE_LM_ID_SUBSYS_SHIFT	16
3262306a36Sopenharmony_ci#define  CDNS_PCIE_LM_ID_SUBSYS(sub) \
3362306a36Sopenharmony_ci	(((sub) << CDNS_PCIE_LM_ID_SUBSYS_SHIFT) & CDNS_PCIE_LM_ID_SUBSYS_MASK)
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* Root Port Requester ID Register */
3662306a36Sopenharmony_ci#define CDNS_PCIE_LM_RP_RID	(CDNS_PCIE_LM_BASE + 0x0228)
3762306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RP_RID_MASK	GENMASK(15, 0)
3862306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RP_RID_SHIFT	0
3962306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RP_RID_(rid) \
4062306a36Sopenharmony_ci	(((rid) << CDNS_PCIE_LM_RP_RID_SHIFT) & CDNS_PCIE_LM_RP_RID_MASK)
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/* Endpoint Bus and Device Number Register */
4362306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_ID	(CDNS_PCIE_LM_BASE + 0x022c)
4462306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_ID_DEV_MASK	GENMASK(4, 0)
4562306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_ID_DEV_SHIFT	0
4662306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_ID_BUS_MASK	GENMASK(15, 8)
4762306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_ID_BUS_SHIFT	8
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* Endpoint Function f BAR b Configuration Registers */
5062306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_FUNC_BAR_CFG(bar, fn) \
5162306a36Sopenharmony_ci	(((bar) < BAR_4) ? CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) : CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn))
5262306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) \
5362306a36Sopenharmony_ci	(CDNS_PCIE_LM_BASE + 0x0240 + (fn) * 0x0008)
5462306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn) \
5562306a36Sopenharmony_ci	(CDNS_PCIE_LM_BASE + 0x0244 + (fn) * 0x0008)
5662306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_VFUNC_BAR_CFG(bar, fn) \
5762306a36Sopenharmony_ci	(((bar) < BAR_4) ? CDNS_PCIE_LM_EP_VFUNC_BAR_CFG0(fn) : CDNS_PCIE_LM_EP_VFUNC_BAR_CFG1(fn))
5862306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_VFUNC_BAR_CFG0(fn) \
5962306a36Sopenharmony_ci	(CDNS_PCIE_LM_BASE + 0x0280 + (fn) * 0x0008)
6062306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_VFUNC_BAR_CFG1(fn) \
6162306a36Sopenharmony_ci	(CDNS_PCIE_LM_BASE + 0x0284 + (fn) * 0x0008)
6262306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b) \
6362306a36Sopenharmony_ci	(GENMASK(4, 0) << ((b) * 8))
6462306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE(b, a) \
6562306a36Sopenharmony_ci	(((a) << ((b) * 8)) & CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b))
6662306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b) \
6762306a36Sopenharmony_ci	(GENMASK(7, 5) << ((b) * 8))
6862306a36Sopenharmony_ci#define  CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL(b, c) \
6962306a36Sopenharmony_ci	(((c) << ((b) * 8 + 5)) & CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b))
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/* Endpoint Function Configuration Register */
7262306a36Sopenharmony_ci#define CDNS_PCIE_LM_EP_FUNC_CFG	(CDNS_PCIE_LM_BASE + 0x02c0)
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/* Root Complex BAR Configuration Register */
7562306a36Sopenharmony_ci#define CDNS_PCIE_LM_RC_BAR_CFG	(CDNS_PCIE_LM_BASE + 0x0300)
7662306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK	GENMASK(5, 0)
7762306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE(a) \
7862306a36Sopenharmony_ci	(((a) << 0) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK)
7962306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK		GENMASK(8, 6)
8062306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL(c) \
8162306a36Sopenharmony_ci	(((c) << 6) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK)
8262306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK	GENMASK(13, 9)
8362306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE(a) \
8462306a36Sopenharmony_ci	(((a) << 9) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK)
8562306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK		GENMASK(16, 14)
8662306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL(c) \
8762306a36Sopenharmony_ci	(((c) << 14) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK)
8862306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE	BIT(17)
8962306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_32BITS	0
9062306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS	BIT(18)
9162306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE		BIT(19)
9262306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_IO_16BITS		0
9362306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS		BIT(20)
9462306a36Sopenharmony_ci#define  CDNS_PCIE_LM_RC_BAR_CFG_CHECK_ENABLE		BIT(31)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci/* BAR control values applicable to both Endpoint Function and Root Complex */
9762306a36Sopenharmony_ci#define  CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED		0x0
9862306a36Sopenharmony_ci#define  CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS		0x1
9962306a36Sopenharmony_ci#define  CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS		0x4
10062306a36Sopenharmony_ci#define  CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS	0x5
10162306a36Sopenharmony_ci#define  CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS		0x6
10262306a36Sopenharmony_ci#define  CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS	0x7
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define LM_RC_BAR_CFG_CTRL_DISABLED(bar)		\
10562306a36Sopenharmony_ci		(CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED << (((bar) * 8) + 6))
10662306a36Sopenharmony_ci#define LM_RC_BAR_CFG_CTRL_IO_32BITS(bar)		\
10762306a36Sopenharmony_ci		(CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS << (((bar) * 8) + 6))
10862306a36Sopenharmony_ci#define LM_RC_BAR_CFG_CTRL_MEM_32BITS(bar)		\
10962306a36Sopenharmony_ci		(CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS << (((bar) * 8) + 6))
11062306a36Sopenharmony_ci#define LM_RC_BAR_CFG_CTRL_PREF_MEM_32BITS(bar)	\
11162306a36Sopenharmony_ci	(CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS << (((bar) * 8) + 6))
11262306a36Sopenharmony_ci#define LM_RC_BAR_CFG_CTRL_MEM_64BITS(bar)		\
11362306a36Sopenharmony_ci		(CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS << (((bar) * 8) + 6))
11462306a36Sopenharmony_ci#define LM_RC_BAR_CFG_CTRL_PREF_MEM_64BITS(bar)	\
11562306a36Sopenharmony_ci	(CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS << (((bar) * 8) + 6))
11662306a36Sopenharmony_ci#define LM_RC_BAR_CFG_APERTURE(bar, aperture)		\
11762306a36Sopenharmony_ci					(((aperture) - 2) << ((bar) * 8))
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci/* PTM Control Register */
12062306a36Sopenharmony_ci#define CDNS_PCIE_LM_PTM_CTRL 	(CDNS_PCIE_LM_BASE + 0x0da8)
12162306a36Sopenharmony_ci#define CDNS_PCIE_LM_TPM_CTRL_PTMRSEN 	BIT(17)
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/*
12462306a36Sopenharmony_ci * Endpoint Function Registers (PCI configuration space for endpoint functions)
12562306a36Sopenharmony_ci */
12662306a36Sopenharmony_ci#define CDNS_PCIE_EP_FUNC_BASE(fn)	(((fn) << 12) & GENMASK(19, 12))
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#define CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET	0x90
12962306a36Sopenharmony_ci#define CDNS_PCIE_EP_FUNC_MSIX_CAP_OFFSET	0xb0
13062306a36Sopenharmony_ci#define CDNS_PCIE_EP_FUNC_DEV_CAP_OFFSET	0xc0
13162306a36Sopenharmony_ci#define CDNS_PCIE_EP_FUNC_SRIOV_CAP_OFFSET	0x200
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci/*
13462306a36Sopenharmony_ci * Root Port Registers (PCI configuration space for the root port function)
13562306a36Sopenharmony_ci */
13662306a36Sopenharmony_ci#define CDNS_PCIE_RP_BASE	0x00200000
13762306a36Sopenharmony_ci#define CDNS_PCIE_RP_CAP_OFFSET 0xc0
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci/*
14062306a36Sopenharmony_ci * Address Translation Registers
14162306a36Sopenharmony_ci */
14262306a36Sopenharmony_ci#define CDNS_PCIE_AT_BASE	0x00400000
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/* Region r Outbound AXI to PCIe Address Translation Register 0 */
14562306a36Sopenharmony_ci#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r) \
14662306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0000 + ((r) & 0x1f) * 0x0020)
14762306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK	GENMASK(5, 0)
14862306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS(nbits) \
14962306a36Sopenharmony_ci	(((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK)
15062306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK	GENMASK(19, 12)
15162306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN(devfn) \
15262306a36Sopenharmony_ci	(((devfn) << 12) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK)
15362306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK	GENMASK(27, 20)
15462306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS(bus) \
15562306a36Sopenharmony_ci	(((bus) << 20) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK)
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci/* Region r Outbound AXI to PCIe Address Translation Register 1 */
15862306a36Sopenharmony_ci#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r) \
15962306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0004 + ((r) & 0x1f) * 0x0020)
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci/* Region r Outbound PCIe Descriptor Register 0 */
16262306a36Sopenharmony_ci#define CDNS_PCIE_AT_OB_REGION_DESC0(r) \
16362306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0008 + ((r) & 0x1f) * 0x0020)
16462306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MASK		GENMASK(3, 0)
16562306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MEM		0x2
16662306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_IO		0x6
16762306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0	0xa
16862306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1	0xb
16962306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_NORMAL_MSG	0xc
17062306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_VENDOR_MSG	0xd
17162306a36Sopenharmony_ci/* Bit 23 MUST be set in RC mode. */
17262306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID	BIT(23)
17362306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK	GENMASK(31, 24)
17462306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(devfn) \
17562306a36Sopenharmony_ci	(((devfn) << 24) & CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK)
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci/* Region r Outbound PCIe Descriptor Register 1 */
17862306a36Sopenharmony_ci#define CDNS_PCIE_AT_OB_REGION_DESC1(r)	\
17962306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x000c + ((r) & 0x1f) * 0x0020)
18062306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK	GENMASK(7, 0)
18162306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_DESC1_BUS(bus) \
18262306a36Sopenharmony_ci	((bus) & CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK)
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci/* Region r AXI Region Base Address Register 0 */
18562306a36Sopenharmony_ci#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r) \
18662306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0018 + ((r) & 0x1f) * 0x0020)
18762306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK	GENMASK(5, 0)
18862306a36Sopenharmony_ci#define  CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) \
18962306a36Sopenharmony_ci	(((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK)
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci/* Region r AXI Region Base Address Register 1 */
19262306a36Sopenharmony_ci#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r) \
19362306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x001c + ((r) & 0x1f) * 0x0020)
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/* Root Port BAR Inbound PCIe to AXI Address Translation Register */
19662306a36Sopenharmony_ci#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0(bar) \
19762306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0800 + (bar) * 0x0008)
19862306a36Sopenharmony_ci#define  CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK	GENMASK(5, 0)
19962306a36Sopenharmony_ci#define  CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS(nbits) \
20062306a36Sopenharmony_ci	(((nbits) - 1) & CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK)
20162306a36Sopenharmony_ci#define CDNS_PCIE_AT_IB_RP_BAR_ADDR1(bar) \
20262306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0804 + (bar) * 0x0008)
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci/* AXI link down register */
20562306a36Sopenharmony_ci#define CDNS_PCIE_AT_LINKDOWN (CDNS_PCIE_AT_BASE + 0x0824)
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci/* LTSSM Capabilities register */
20862306a36Sopenharmony_ci#define CDNS_PCIE_LTSSM_CONTROL_CAP             (CDNS_PCIE_LM_BASE + 0x0054)
20962306a36Sopenharmony_ci#define  CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK  GENMASK(2, 1)
21062306a36Sopenharmony_ci#define  CDNS_PCIE_DETECT_QUIET_MIN_DELAY_SHIFT 1
21162306a36Sopenharmony_ci#define  CDNS_PCIE_DETECT_QUIET_MIN_DELAY(delay) \
21262306a36Sopenharmony_ci	 (((delay) << CDNS_PCIE_DETECT_QUIET_MIN_DELAY_SHIFT) & \
21362306a36Sopenharmony_ci	 CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK)
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_cienum cdns_pcie_rp_bar {
21662306a36Sopenharmony_ci	RP_BAR_UNDEFINED = -1,
21762306a36Sopenharmony_ci	RP_BAR0,
21862306a36Sopenharmony_ci	RP_BAR1,
21962306a36Sopenharmony_ci	RP_NO_BAR
22062306a36Sopenharmony_ci};
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci#define CDNS_PCIE_RP_MAX_IB	0x3
22362306a36Sopenharmony_ci#define CDNS_PCIE_MAX_OB	32
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_cistruct cdns_pcie_rp_ib_bar {
22662306a36Sopenharmony_ci	u64 size;
22762306a36Sopenharmony_ci	bool free;
22862306a36Sopenharmony_ci};
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* Endpoint Function BAR Inbound PCIe to AXI Address Translation Register */
23162306a36Sopenharmony_ci#define CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR0(fn, bar) \
23262306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0840 + (fn) * 0x0040 + (bar) * 0x0008)
23362306a36Sopenharmony_ci#define CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR1(fn, bar) \
23462306a36Sopenharmony_ci	(CDNS_PCIE_AT_BASE + 0x0844 + (fn) * 0x0040 + (bar) * 0x0008)
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci/* Normal/Vendor specific message access: offset inside some outbound region */
23762306a36Sopenharmony_ci#define CDNS_PCIE_NORMAL_MSG_ROUTING_MASK	GENMASK(7, 5)
23862306a36Sopenharmony_ci#define CDNS_PCIE_NORMAL_MSG_ROUTING(route) \
23962306a36Sopenharmony_ci	(((route) << 5) & CDNS_PCIE_NORMAL_MSG_ROUTING_MASK)
24062306a36Sopenharmony_ci#define CDNS_PCIE_NORMAL_MSG_CODE_MASK		GENMASK(15, 8)
24162306a36Sopenharmony_ci#define CDNS_PCIE_NORMAL_MSG_CODE(code) \
24262306a36Sopenharmony_ci	(((code) << 8) & CDNS_PCIE_NORMAL_MSG_CODE_MASK)
24362306a36Sopenharmony_ci#define CDNS_PCIE_MSG_NO_DATA			BIT(16)
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_cistruct cdns_pcie;
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_cienum cdns_pcie_msg_code {
24862306a36Sopenharmony_ci	MSG_CODE_ASSERT_INTA	= 0x20,
24962306a36Sopenharmony_ci	MSG_CODE_ASSERT_INTB	= 0x21,
25062306a36Sopenharmony_ci	MSG_CODE_ASSERT_INTC	= 0x22,
25162306a36Sopenharmony_ci	MSG_CODE_ASSERT_INTD	= 0x23,
25262306a36Sopenharmony_ci	MSG_CODE_DEASSERT_INTA	= 0x24,
25362306a36Sopenharmony_ci	MSG_CODE_DEASSERT_INTB	= 0x25,
25462306a36Sopenharmony_ci	MSG_CODE_DEASSERT_INTC	= 0x26,
25562306a36Sopenharmony_ci	MSG_CODE_DEASSERT_INTD	= 0x27,
25662306a36Sopenharmony_ci};
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_cienum cdns_pcie_msg_routing {
25962306a36Sopenharmony_ci	/* Route to Root Complex */
26062306a36Sopenharmony_ci	MSG_ROUTING_TO_RC,
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	/* Use Address Routing */
26362306a36Sopenharmony_ci	MSG_ROUTING_BY_ADDR,
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci	/* Use ID Routing */
26662306a36Sopenharmony_ci	MSG_ROUTING_BY_ID,
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci	/* Route as Broadcast Message from Root Complex */
26962306a36Sopenharmony_ci	MSG_ROUTING_BCAST,
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci	/* Local message; terminate at receiver (INTx messages) */
27262306a36Sopenharmony_ci	MSG_ROUTING_LOCAL,
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_ci	/* Gather & route to Root Complex (PME_TO_Ack message) */
27562306a36Sopenharmony_ci	MSG_ROUTING_GATHER,
27662306a36Sopenharmony_ci};
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_cistruct cdns_pcie_ops {
27962306a36Sopenharmony_ci	int	(*start_link)(struct cdns_pcie *pcie);
28062306a36Sopenharmony_ci	void	(*stop_link)(struct cdns_pcie *pcie);
28162306a36Sopenharmony_ci	bool	(*link_up)(struct cdns_pcie *pcie);
28262306a36Sopenharmony_ci	u64     (*cpu_addr_fixup)(struct cdns_pcie *pcie, u64 cpu_addr);
28362306a36Sopenharmony_ci};
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci/**
28662306a36Sopenharmony_ci * struct cdns_pcie - private data for Cadence PCIe controller drivers
28762306a36Sopenharmony_ci * @reg_base: IO mapped register base
28862306a36Sopenharmony_ci * @mem_res: start/end offsets in the physical system memory to map PCI accesses
28962306a36Sopenharmony_ci * @dev: PCIe controller
29062306a36Sopenharmony_ci * @is_rc: tell whether the PCIe controller mode is Root Complex or Endpoint.
29162306a36Sopenharmony_ci * @phy_count: number of supported PHY devices
29262306a36Sopenharmony_ci * @phy: list of pointers to specific PHY control blocks
29362306a36Sopenharmony_ci * @link: list of pointers to corresponding device link representations
29462306a36Sopenharmony_ci * @ops: Platform-specific ops to control various inputs from Cadence PCIe
29562306a36Sopenharmony_ci *       wrapper
29662306a36Sopenharmony_ci */
29762306a36Sopenharmony_cistruct cdns_pcie {
29862306a36Sopenharmony_ci	void __iomem		*reg_base;
29962306a36Sopenharmony_ci	struct resource		*mem_res;
30062306a36Sopenharmony_ci	struct device		*dev;
30162306a36Sopenharmony_ci	bool			is_rc;
30262306a36Sopenharmony_ci	int			phy_count;
30362306a36Sopenharmony_ci	struct phy		**phy;
30462306a36Sopenharmony_ci	struct device_link	**link;
30562306a36Sopenharmony_ci	const struct cdns_pcie_ops *ops;
30662306a36Sopenharmony_ci};
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci/**
30962306a36Sopenharmony_ci * struct cdns_pcie_rc - private data for this PCIe Root Complex driver
31062306a36Sopenharmony_ci * @pcie: Cadence PCIe controller
31162306a36Sopenharmony_ci * @dev: pointer to PCIe device
31262306a36Sopenharmony_ci * @cfg_res: start/end offsets in the physical system memory to map PCI
31362306a36Sopenharmony_ci *           configuration space accesses
31462306a36Sopenharmony_ci * @cfg_base: IO mapped window to access the PCI configuration space of a
31562306a36Sopenharmony_ci *            single function at a time
31662306a36Sopenharmony_ci * @vendor_id: PCI vendor ID
31762306a36Sopenharmony_ci * @device_id: PCI device ID
31862306a36Sopenharmony_ci * @avail_ib_bar: Status of RP_BAR0, RP_BAR1 and RP_NO_BAR if it's free or
31962306a36Sopenharmony_ci *                available
32062306a36Sopenharmony_ci * @quirk_retrain_flag: Retrain link as quirk for PCIe Gen2
32162306a36Sopenharmony_ci * @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk
32262306a36Sopenharmony_ci */
32362306a36Sopenharmony_cistruct cdns_pcie_rc {
32462306a36Sopenharmony_ci	struct cdns_pcie	pcie;
32562306a36Sopenharmony_ci	struct resource		*cfg_res;
32662306a36Sopenharmony_ci	void __iomem		*cfg_base;
32762306a36Sopenharmony_ci	u32			vendor_id;
32862306a36Sopenharmony_ci	u32			device_id;
32962306a36Sopenharmony_ci	bool			avail_ib_bar[CDNS_PCIE_RP_MAX_IB];
33062306a36Sopenharmony_ci	unsigned int		quirk_retrain_flag:1;
33162306a36Sopenharmony_ci	unsigned int		quirk_detect_quiet_flag:1;
33262306a36Sopenharmony_ci};
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci/**
33562306a36Sopenharmony_ci * struct cdns_pcie_epf - Structure to hold info about endpoint function
33662306a36Sopenharmony_ci * @epf: Info about virtual functions attached to the physical function
33762306a36Sopenharmony_ci * @epf_bar: reference to the pci_epf_bar for the six Base Address Registers
33862306a36Sopenharmony_ci */
33962306a36Sopenharmony_cistruct cdns_pcie_epf {
34062306a36Sopenharmony_ci	struct cdns_pcie_epf *epf;
34162306a36Sopenharmony_ci	struct pci_epf_bar *epf_bar[PCI_STD_NUM_BARS];
34262306a36Sopenharmony_ci};
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci/**
34562306a36Sopenharmony_ci * struct cdns_pcie_ep - private data for this PCIe endpoint controller driver
34662306a36Sopenharmony_ci * @pcie: Cadence PCIe controller
34762306a36Sopenharmony_ci * @max_regions: maximum number of regions supported by hardware
34862306a36Sopenharmony_ci * @ob_region_map: bitmask of mapped outbound regions
34962306a36Sopenharmony_ci * @ob_addr: base addresses in the AXI bus where the outbound regions start
35062306a36Sopenharmony_ci * @irq_phys_addr: base address on the AXI bus where the MSI/legacy IRQ
35162306a36Sopenharmony_ci *		   dedicated outbound regions is mapped.
35262306a36Sopenharmony_ci * @irq_cpu_addr: base address in the CPU space where a write access triggers
35362306a36Sopenharmony_ci *		  the sending of a memory write (MSI) / normal message (legacy
35462306a36Sopenharmony_ci *		  IRQ) TLP through the PCIe bus.
35562306a36Sopenharmony_ci * @irq_pci_addr: used to save the current mapping of the MSI/legacy IRQ
35662306a36Sopenharmony_ci *		  dedicated outbound region.
35762306a36Sopenharmony_ci * @irq_pci_fn: the latest PCI function that has updated the mapping of
35862306a36Sopenharmony_ci *		the MSI/legacy IRQ dedicated outbound region.
35962306a36Sopenharmony_ci * @irq_pending: bitmask of asserted legacy IRQs.
36062306a36Sopenharmony_ci * @lock: spin lock to disable interrupts while modifying PCIe controller
36162306a36Sopenharmony_ci *        registers fields (RMW) accessible by both remote RC and EP to
36262306a36Sopenharmony_ci *        minimize time between read and write
36362306a36Sopenharmony_ci * @epf: Structure to hold info about endpoint function
36462306a36Sopenharmony_ci * @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk
36562306a36Sopenharmony_ci * @quirk_disable_flr: Disable FLR (Function Level Reset) quirk flag
36662306a36Sopenharmony_ci */
36762306a36Sopenharmony_cistruct cdns_pcie_ep {
36862306a36Sopenharmony_ci	struct cdns_pcie	pcie;
36962306a36Sopenharmony_ci	u32			max_regions;
37062306a36Sopenharmony_ci	unsigned long		ob_region_map;
37162306a36Sopenharmony_ci	phys_addr_t		*ob_addr;
37262306a36Sopenharmony_ci	phys_addr_t		irq_phys_addr;
37362306a36Sopenharmony_ci	void __iomem		*irq_cpu_addr;
37462306a36Sopenharmony_ci	u64			irq_pci_addr;
37562306a36Sopenharmony_ci	u8			irq_pci_fn;
37662306a36Sopenharmony_ci	u8			irq_pending;
37762306a36Sopenharmony_ci	/* protect writing to PCI_STATUS while raising legacy interrupts */
37862306a36Sopenharmony_ci	spinlock_t		lock;
37962306a36Sopenharmony_ci	struct cdns_pcie_epf	*epf;
38062306a36Sopenharmony_ci	unsigned int		quirk_detect_quiet_flag:1;
38162306a36Sopenharmony_ci	unsigned int		quirk_disable_flr:1;
38262306a36Sopenharmony_ci};
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_ci/* Register access */
38662306a36Sopenharmony_cistatic inline void cdns_pcie_writel(struct cdns_pcie *pcie, u32 reg, u32 value)
38762306a36Sopenharmony_ci{
38862306a36Sopenharmony_ci	writel(value, pcie->reg_base + reg);
38962306a36Sopenharmony_ci}
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_cistatic inline u32 cdns_pcie_readl(struct cdns_pcie *pcie, u32 reg)
39262306a36Sopenharmony_ci{
39362306a36Sopenharmony_ci	return readl(pcie->reg_base + reg);
39462306a36Sopenharmony_ci}
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_cistatic inline u32 cdns_pcie_read_sz(void __iomem *addr, int size)
39762306a36Sopenharmony_ci{
39862306a36Sopenharmony_ci	void __iomem *aligned_addr = PTR_ALIGN_DOWN(addr, 0x4);
39962306a36Sopenharmony_ci	unsigned int offset = (unsigned long)addr & 0x3;
40062306a36Sopenharmony_ci	u32 val = readl(aligned_addr);
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ci	if (!IS_ALIGNED((uintptr_t)addr, size)) {
40362306a36Sopenharmony_ci		pr_warn("Address %p and size %d are not aligned\n", addr, size);
40462306a36Sopenharmony_ci		return 0;
40562306a36Sopenharmony_ci	}
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_ci	if (size > 2)
40862306a36Sopenharmony_ci		return val;
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_ci	return (val >> (8 * offset)) & ((1 << (size * 8)) - 1);
41162306a36Sopenharmony_ci}
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_cistatic inline void cdns_pcie_write_sz(void __iomem *addr, int size, u32 value)
41462306a36Sopenharmony_ci{
41562306a36Sopenharmony_ci	void __iomem *aligned_addr = PTR_ALIGN_DOWN(addr, 0x4);
41662306a36Sopenharmony_ci	unsigned int offset = (unsigned long)addr & 0x3;
41762306a36Sopenharmony_ci	u32 mask;
41862306a36Sopenharmony_ci	u32 val;
41962306a36Sopenharmony_ci
42062306a36Sopenharmony_ci	if (!IS_ALIGNED((uintptr_t)addr, size)) {
42162306a36Sopenharmony_ci		pr_warn("Address %p and size %d are not aligned\n", addr, size);
42262306a36Sopenharmony_ci		return;
42362306a36Sopenharmony_ci	}
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci	if (size > 2) {
42662306a36Sopenharmony_ci		writel(value, addr);
42762306a36Sopenharmony_ci		return;
42862306a36Sopenharmony_ci	}
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci	mask = ~(((1 << (size * 8)) - 1) << (offset * 8));
43162306a36Sopenharmony_ci	val = readl(aligned_addr) & mask;
43262306a36Sopenharmony_ci	val |= value << (offset * 8);
43362306a36Sopenharmony_ci	writel(val, aligned_addr);
43462306a36Sopenharmony_ci}
43562306a36Sopenharmony_ci
43662306a36Sopenharmony_ci/* Root Port register access */
43762306a36Sopenharmony_cistatic inline void cdns_pcie_rp_writeb(struct cdns_pcie *pcie,
43862306a36Sopenharmony_ci				       u32 reg, u8 value)
43962306a36Sopenharmony_ci{
44062306a36Sopenharmony_ci	void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci	cdns_pcie_write_sz(addr, 0x1, value);
44362306a36Sopenharmony_ci}
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_cistatic inline void cdns_pcie_rp_writew(struct cdns_pcie *pcie,
44662306a36Sopenharmony_ci				       u32 reg, u16 value)
44762306a36Sopenharmony_ci{
44862306a36Sopenharmony_ci	void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci	cdns_pcie_write_sz(addr, 0x2, value);
45162306a36Sopenharmony_ci}
45262306a36Sopenharmony_ci
45362306a36Sopenharmony_cistatic inline u16 cdns_pcie_rp_readw(struct cdns_pcie *pcie, u32 reg)
45462306a36Sopenharmony_ci{
45562306a36Sopenharmony_ci	void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
45662306a36Sopenharmony_ci
45762306a36Sopenharmony_ci	return cdns_pcie_read_sz(addr, 0x2);
45862306a36Sopenharmony_ci}
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_ci/* Endpoint Function register access */
46162306a36Sopenharmony_cistatic inline void cdns_pcie_ep_fn_writeb(struct cdns_pcie *pcie, u8 fn,
46262306a36Sopenharmony_ci					  u32 reg, u8 value)
46362306a36Sopenharmony_ci{
46462306a36Sopenharmony_ci	void __iomem *addr = pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg;
46562306a36Sopenharmony_ci
46662306a36Sopenharmony_ci	cdns_pcie_write_sz(addr, 0x1, value);
46762306a36Sopenharmony_ci}
46862306a36Sopenharmony_ci
46962306a36Sopenharmony_cistatic inline void cdns_pcie_ep_fn_writew(struct cdns_pcie *pcie, u8 fn,
47062306a36Sopenharmony_ci					  u32 reg, u16 value)
47162306a36Sopenharmony_ci{
47262306a36Sopenharmony_ci	void __iomem *addr = pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg;
47362306a36Sopenharmony_ci
47462306a36Sopenharmony_ci	cdns_pcie_write_sz(addr, 0x2, value);
47562306a36Sopenharmony_ci}
47662306a36Sopenharmony_ci
47762306a36Sopenharmony_cistatic inline void cdns_pcie_ep_fn_writel(struct cdns_pcie *pcie, u8 fn,
47862306a36Sopenharmony_ci					  u32 reg, u32 value)
47962306a36Sopenharmony_ci{
48062306a36Sopenharmony_ci	writel(value, pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg);
48162306a36Sopenharmony_ci}
48262306a36Sopenharmony_ci
48362306a36Sopenharmony_cistatic inline u16 cdns_pcie_ep_fn_readw(struct cdns_pcie *pcie, u8 fn, u32 reg)
48462306a36Sopenharmony_ci{
48562306a36Sopenharmony_ci	void __iomem *addr = pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg;
48662306a36Sopenharmony_ci
48762306a36Sopenharmony_ci	return cdns_pcie_read_sz(addr, 0x2);
48862306a36Sopenharmony_ci}
48962306a36Sopenharmony_ci
49062306a36Sopenharmony_cistatic inline u32 cdns_pcie_ep_fn_readl(struct cdns_pcie *pcie, u8 fn, u32 reg)
49162306a36Sopenharmony_ci{
49262306a36Sopenharmony_ci	return readl(pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg);
49362306a36Sopenharmony_ci}
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_cistatic inline int cdns_pcie_start_link(struct cdns_pcie *pcie)
49662306a36Sopenharmony_ci{
49762306a36Sopenharmony_ci	if (pcie->ops->start_link)
49862306a36Sopenharmony_ci		return pcie->ops->start_link(pcie);
49962306a36Sopenharmony_ci
50062306a36Sopenharmony_ci	return 0;
50162306a36Sopenharmony_ci}
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_cistatic inline void cdns_pcie_stop_link(struct cdns_pcie *pcie)
50462306a36Sopenharmony_ci{
50562306a36Sopenharmony_ci	if (pcie->ops->stop_link)
50662306a36Sopenharmony_ci		pcie->ops->stop_link(pcie);
50762306a36Sopenharmony_ci}
50862306a36Sopenharmony_ci
50962306a36Sopenharmony_cistatic inline bool cdns_pcie_link_up(struct cdns_pcie *pcie)
51062306a36Sopenharmony_ci{
51162306a36Sopenharmony_ci	if (pcie->ops->link_up)
51262306a36Sopenharmony_ci		return pcie->ops->link_up(pcie);
51362306a36Sopenharmony_ci
51462306a36Sopenharmony_ci	return true;
51562306a36Sopenharmony_ci}
51662306a36Sopenharmony_ci
51762306a36Sopenharmony_ci#ifdef CONFIG_PCIE_CADENCE_HOST
51862306a36Sopenharmony_ciint cdns_pcie_host_setup(struct cdns_pcie_rc *rc);
51962306a36Sopenharmony_civoid __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
52062306a36Sopenharmony_ci			       int where);
52162306a36Sopenharmony_ci#else
52262306a36Sopenharmony_cistatic inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
52362306a36Sopenharmony_ci{
52462306a36Sopenharmony_ci	return 0;
52562306a36Sopenharmony_ci}
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_cistatic inline void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
52862306a36Sopenharmony_ci					     int where)
52962306a36Sopenharmony_ci{
53062306a36Sopenharmony_ci	return NULL;
53162306a36Sopenharmony_ci}
53262306a36Sopenharmony_ci#endif
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_ci#ifdef CONFIG_PCIE_CADENCE_EP
53562306a36Sopenharmony_ciint cdns_pcie_ep_setup(struct cdns_pcie_ep *ep);
53662306a36Sopenharmony_ci#else
53762306a36Sopenharmony_cistatic inline int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)
53862306a36Sopenharmony_ci{
53962306a36Sopenharmony_ci	return 0;
54062306a36Sopenharmony_ci}
54162306a36Sopenharmony_ci#endif
54262306a36Sopenharmony_ci
54362306a36Sopenharmony_civoid cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie);
54462306a36Sopenharmony_ci
54562306a36Sopenharmony_civoid cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn,
54662306a36Sopenharmony_ci				   u32 r, bool is_io,
54762306a36Sopenharmony_ci				   u64 cpu_addr, u64 pci_addr, size_t size);
54862306a36Sopenharmony_ci
54962306a36Sopenharmony_civoid cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie,
55062306a36Sopenharmony_ci						  u8 busnr, u8 fn,
55162306a36Sopenharmony_ci						  u32 r, u64 cpu_addr);
55262306a36Sopenharmony_ci
55362306a36Sopenharmony_civoid cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r);
55462306a36Sopenharmony_civoid cdns_pcie_disable_phy(struct cdns_pcie *pcie);
55562306a36Sopenharmony_ciint cdns_pcie_enable_phy(struct cdns_pcie *pcie);
55662306a36Sopenharmony_ciint cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie);
55762306a36Sopenharmony_ciextern const struct dev_pm_ops cdns_pcie_pm_ops;
55862306a36Sopenharmony_ci
55962306a36Sopenharmony_ci#endif /* _PCIE_CADENCE_H */
560