Skip to content

Commit 2301a3e

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: mt7621: Use PCI_CONF1_EXT_ADDRESS() macro
Simplify pcie-mt7621.c driver code and use new PCI_CONF1_EXT_ADDRESS() macro for accessing PCIe config space. Link: https://lore.kernel.org/r/20220924092404.31776-4-pali@kernel.org Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Acked-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
1 parent f75a27d commit 2301a3e

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

drivers/pci/controller/pcie-mt7621.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <linux/reset.h>
3131
#include <linux/sys_soc.h>
3232

33+
#include "../pci.h"
34+
3335
/* MediaTek-specific configuration registers */
3436
#define PCIE_FTS_NUM 0x70c
3537
#define PCIE_FTS_NUM_MASK GENMASK(15, 8)
@@ -120,19 +122,12 @@ static inline void pcie_port_write(struct mt7621_pcie_port *port,
120122
writel_relaxed(val, port->base + reg);
121123
}
122124

123-
static inline u32 mt7621_pcie_get_cfgaddr(unsigned int bus, unsigned int slot,
124-
unsigned int func, unsigned int where)
125-
{
126-
return (((where & 0xf00) >> 8) << 24) | (bus << 16) | (slot << 11) |
127-
(func << 8) | (where & 0xfc) | 0x80000000;
128-
}
129-
130125
static void __iomem *mt7621_pcie_map_bus(struct pci_bus *bus,
131126
unsigned int devfn, int where)
132127
{
133128
struct mt7621_pcie *pcie = bus->sysdata;
134-
u32 address = mt7621_pcie_get_cfgaddr(bus->number, PCI_SLOT(devfn),
135-
PCI_FUNC(devfn), where);
129+
u32 address = PCI_CONF1_EXT_ADDRESS(bus->number, PCI_SLOT(devfn),
130+
PCI_FUNC(devfn), where);
136131

137132
writel_relaxed(address, pcie->base + RALINK_PCI_CONFIG_ADDR);
138133

@@ -147,7 +142,7 @@ static struct pci_ops mt7621_pcie_ops = {
147142

148143
static u32 read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg)
149144
{
150-
u32 address = mt7621_pcie_get_cfgaddr(0, dev, 0, reg);
145+
u32 address = PCI_CONF1_EXT_ADDRESS(0, dev, 0, reg);
151146

152147
pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
153148
return pcie_read(pcie, RALINK_PCI_CONFIG_DATA);
@@ -156,7 +151,7 @@ static u32 read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg)
156151
static void write_config(struct mt7621_pcie *pcie, unsigned int dev,
157152
u32 reg, u32 val)
158153
{
159-
u32 address = mt7621_pcie_get_cfgaddr(0, dev, 0, reg);
154+
u32 address = PCI_CONF1_EXT_ADDRESS(0, dev, 0, reg);
160155

161156
pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
162157
pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA);

0 commit comments

Comments
 (0)