Skip to content

Commit 18ac51a

Browse files
Hans Zhangbjorn-helgaas
authored andcommitted
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: Hans Zhang <[email protected]> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 3a33020 commit 18ac51a

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

drivers/pci/controller/cadence/pcie-cadence.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
#include <linux/of.h>
99

1010
#include "pcie-cadence.h"
11+
#include "../../pci.h"
12+
13+
u8 cdns_pcie_find_capability(struct cdns_pcie *pcie, u8 cap)
14+
{
15+
return PCI_FIND_NEXT_CAP(cdns_pcie_read_cfg, PCI_CAPABILITY_LIST,
16+
cap, pcie);
17+
}
18+
EXPORT_SYMBOL_GPL(cdns_pcie_find_capability);
19+
20+
u16 cdns_pcie_find_ext_capability(struct cdns_pcie *pcie, u8 cap)
21+
{
22+
return PCI_FIND_NEXT_EXT_CAP(cdns_pcie_read_cfg, 0, cap, pcie);
23+
}
24+
EXPORT_SYMBOL_GPL(cdns_pcie_find_ext_capability);
1125

1226
void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie)
1327
{

drivers/pci/controller/cadence/pcie-cadence.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,37 @@ static inline u32 cdns_pcie_readl(struct cdns_pcie *pcie, u32 reg)
367367
return readl(pcie->reg_base + reg);
368368
}
369369

370+
static inline u16 cdns_pcie_readw(struct cdns_pcie *pcie, u32 reg)
371+
{
372+
return readw(pcie->reg_base + reg);
373+
}
374+
375+
static inline u8 cdns_pcie_readb(struct cdns_pcie *pcie, u32 reg)
376+
{
377+
return readb(pcie->reg_base + reg);
378+
}
379+
380+
static inline int cdns_pcie_read_cfg_byte(struct cdns_pcie *pcie, int where,
381+
u8 *val)
382+
{
383+
*val = cdns_pcie_readb(pcie, where);
384+
return PCIBIOS_SUCCESSFUL;
385+
}
386+
387+
static inline int cdns_pcie_read_cfg_word(struct cdns_pcie *pcie, int where,
388+
u16 *val)
389+
{
390+
*val = cdns_pcie_readw(pcie, where);
391+
return PCIBIOS_SUCCESSFUL;
392+
}
393+
394+
static inline int cdns_pcie_read_cfg_dword(struct cdns_pcie *pcie, int where,
395+
u32 *val)
396+
{
397+
*val = cdns_pcie_readl(pcie, where);
398+
return PCIBIOS_SUCCESSFUL;
399+
}
400+
370401
static inline u32 cdns_pcie_read_sz(void __iomem *addr, int size)
371402
{
372403
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)
536567
}
537568
#endif
538569

570+
u8 cdns_pcie_find_capability(struct cdns_pcie *pcie, u8 cap);
571+
u16 cdns_pcie_find_ext_capability(struct cdns_pcie *pcie, u8 cap);
572+
539573
void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie);
540574

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

0 commit comments

Comments
 (0)