Commit 18ac51ae authored by Hans Zhang's avatar Hans Zhang Committed by Bjorn Helgaas
Browse files

PCI: cadence: Implement capability search using PCI core APIs



The PCI core now provides generic PCI_FIND_NEXT_CAP() and
PCI_FIND_NEXT_EXT_CAP() macros to search for PCI capabilities, using
config accessors we supply.

Use them in the CDNS driver to add cdns_pcie_find_capability() and
cdns_pcie_find_ext_capability() interfaces.

Signed-off-by: default avatarHans Zhang <18255117159@163.com>
[bhelgaas: commit log]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250813144529.303548-6-18255117159@163.com
parent 3a33020d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -8,6 +8,20 @@
#include <linux/of.h>

#include "pcie-cadence.h"
#include "../../pci.h"

u8 cdns_pcie_find_capability(struct cdns_pcie *pcie, u8 cap)
{
	return PCI_FIND_NEXT_CAP(cdns_pcie_read_cfg, PCI_CAPABILITY_LIST,
				 cap, pcie);
}
EXPORT_SYMBOL_GPL(cdns_pcie_find_capability);

u16 cdns_pcie_find_ext_capability(struct cdns_pcie *pcie, u8 cap)
{
	return PCI_FIND_NEXT_EXT_CAP(cdns_pcie_read_cfg, 0, cap, pcie);
}
EXPORT_SYMBOL_GPL(cdns_pcie_find_ext_capability);

void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie)
{
+34 −0
Original line number Diff line number Diff line
@@ -367,6 +367,37 @@ static inline u32 cdns_pcie_readl(struct cdns_pcie *pcie, u32 reg)
	return readl(pcie->reg_base + reg);
}

static inline u16 cdns_pcie_readw(struct cdns_pcie *pcie, u32 reg)
{
	return readw(pcie->reg_base + reg);
}

static inline u8 cdns_pcie_readb(struct cdns_pcie *pcie, u32 reg)
{
	return readb(pcie->reg_base + reg);
}

static inline int cdns_pcie_read_cfg_byte(struct cdns_pcie *pcie, int where,
					  u8 *val)
{
	*val = cdns_pcie_readb(pcie, where);
	return PCIBIOS_SUCCESSFUL;
}

static inline int cdns_pcie_read_cfg_word(struct cdns_pcie *pcie, int where,
					  u16 *val)
{
	*val = cdns_pcie_readw(pcie, where);
	return PCIBIOS_SUCCESSFUL;
}

static inline int cdns_pcie_read_cfg_dword(struct cdns_pcie *pcie, int where,
					   u32 *val)
{
	*val = cdns_pcie_readl(pcie, where);
	return PCIBIOS_SUCCESSFUL;
}

static inline u32 cdns_pcie_read_sz(void __iomem *addr, int size)
{
	void __iomem *aligned_addr = PTR_ALIGN_DOWN(addr, 0x4);
@@ -536,6 +567,9 @@ static inline void cdns_pcie_ep_disable(struct cdns_pcie_ep *ep)
}
#endif

u8 cdns_pcie_find_capability(struct cdns_pcie *pcie, u8 cap);
u16 cdns_pcie_find_ext_capability(struct cdns_pcie *pcie, u8 cap);

void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie);

void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn,