30
30
#include <linux/reset.h>
31
31
#include <linux/sys_soc.h>
32
32
33
+ #include "../pci.h"
34
+
33
35
/* MediaTek-specific configuration registers */
34
36
#define PCIE_FTS_NUM 0x70c
35
37
#define PCIE_FTS_NUM_MASK GENMASK(15, 8)
@@ -120,19 +122,12 @@ static inline void pcie_port_write(struct mt7621_pcie_port *port,
120
122
writel_relaxed (val , port -> base + reg );
121
123
}
122
124
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
-
130
125
static void __iomem * mt7621_pcie_map_bus (struct pci_bus * bus ,
131
126
unsigned int devfn , int where )
132
127
{
133
128
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 );
136
131
137
132
writel_relaxed (address , pcie -> base + RALINK_PCI_CONFIG_ADDR );
138
133
@@ -147,7 +142,7 @@ static struct pci_ops mt7621_pcie_ops = {
147
142
148
143
static u32 read_config (struct mt7621_pcie * pcie , unsigned int dev , u32 reg )
149
144
{
150
- u32 address = mt7621_pcie_get_cfgaddr (0 , dev , 0 , reg );
145
+ u32 address = PCI_CONF1_EXT_ADDRESS (0 , dev , 0 , reg );
151
146
152
147
pcie_write (pcie , address , RALINK_PCI_CONFIG_ADDR );
153
148
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)
156
151
static void write_config (struct mt7621_pcie * pcie , unsigned int dev ,
157
152
u32 reg , u32 val )
158
153
{
159
- u32 address = mt7621_pcie_get_cfgaddr (0 , dev , 0 , reg );
154
+ u32 address = PCI_CONF1_EXT_ADDRESS (0 , dev , 0 , reg );
160
155
161
156
pcie_write (pcie , address , RALINK_PCI_CONFIG_ADDR );
162
157
pcie_write (pcie , val , RALINK_PCI_CONFIG_DATA );
0 commit comments