Skip to content

Commit fc10f9d

Browse files
committed
Merge branch 'pci/host/mt7621'
- Declare mt7621_pci_ops static (Sergio Paracuellos) - Give pcibios_root_bridge_prepare() access to host bridge windows (Sergio Paracuellos) - Move MIPS I/O coherency unit setup from driver to pcibios_root_bridge_prepare() (Sergio Paracuellos) - Add missing MODULE_LICENSE() (Sergio Paracuellos) - Allow COMPILE_TEST for all arches (Sergio Paracuellos) * pci/host/mt7621: PCI: mt7621: Allow COMPILE_TEST for all arches PCI: mt7621: Add missing MODULE_LICENSE() PCI: mt7621: Move MIPS setup to pcibios_root_bridge_prepare() PCI: Let pcibios_root_bridge_prepare() access bridge->windows PCI: mt7621: Declare mt7621_pci_ops static
2 parents 96fe579 + 44ddb79 commit fc10f9d

File tree

4 files changed

+37
-41
lines changed

4 files changed

+37
-41
lines changed

arch/mips/ralink/mt7621.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <linux/slab.h>
1111
#include <linux/sys_soc.h>
1212
#include <linux/memblock.h>
13+
#include <linux/pci.h>
14+
#include <linux/bug.h>
1315

1416
#include <asm/bootinfo.h>
1517
#include <asm/mipsregs.h>
@@ -22,6 +24,35 @@
2224

2325
static void *detect_magic __initdata = detect_memory_region;
2426

27+
int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
28+
{
29+
struct resource_entry *entry;
30+
resource_size_t mask;
31+
32+
entry = resource_list_first_type(&bridge->windows, IORESOURCE_MEM);
33+
if (!entry) {
34+
pr_err("Cannot get memory resource\n");
35+
return -EINVAL;
36+
}
37+
38+
if (mips_cps_numiocu(0)) {
39+
/*
40+
* Hardware doesn't accept mask values with 1s after
41+
* 0s (e.g. 0xffef), so warn if that's happen
42+
*/
43+
mask = ~(entry->res->end - entry->res->start) & CM_GCR_REGn_MASK_ADDRMASK;
44+
WARN_ON(mask && BIT(ffz(~mask)) - 1 != ~mask);
45+
46+
write_gcr_reg1_base(entry->res->start);
47+
write_gcr_reg1_mask(mask | CM_GCR_REGn_MASK_CMTGT_IOCU0);
48+
pr_info("PCI coherence region base: 0x%08llx, mask/settings: 0x%08llx\n",
49+
(unsigned long long)read_gcr_reg1_base(),
50+
(unsigned long long)read_gcr_reg1_mask());
51+
}
52+
53+
return 0;
54+
}
55+
2556
phys_addr_t mips_cpc_default_phys_base(void)
2657
{
2758
panic("Cannot detect cpc address");

drivers/pci/controller/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ config PCIE_APPLE
333333

334334
config PCIE_MT7621
335335
tristate "MediaTek MT7621 PCIe Controller"
336-
depends on (RALINK && SOC_MT7621) || (MIPS && COMPILE_TEST)
336+
depends on SOC_MT7621 || COMPILE_TEST
337337
select PHY_MT7621_PCI
338338
default SOC_MT7621
339339
help

drivers/pci/controller/pcie-mt7621.c

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void __iomem *mt7621_pcie_map_bus(struct pci_bus *bus,
148148
return pcie->base + RALINK_PCI_CONFIG_DATA + (where & 3);
149149
}
150150

151-
struct pci_ops mt7621_pci_ops = {
151+
static struct pci_ops mt7621_pci_ops = {
152152
.map_bus = mt7621_pcie_map_bus,
153153
.read = pci_generic_config_read,
154154
.write = pci_generic_config_write,
@@ -208,37 +208,6 @@ static inline void mt7621_control_deassert(struct mt7621_pcie_port *port)
208208
reset_control_assert(port->pcie_rst);
209209
}
210210

211-
static int setup_cm_memory_region(struct pci_host_bridge *host)
212-
{
213-
struct mt7621_pcie *pcie = pci_host_bridge_priv(host);
214-
struct device *dev = pcie->dev;
215-
struct resource_entry *entry;
216-
resource_size_t mask;
217-
218-
entry = resource_list_first_type(&host->windows, IORESOURCE_MEM);
219-
if (!entry) {
220-
dev_err(dev, "cannot get memory resource\n");
221-
return -EINVAL;
222-
}
223-
224-
if (mips_cps_numiocu(0)) {
225-
/*
226-
* FIXME: hardware doesn't accept mask values with 1s after
227-
* 0s (e.g. 0xffef), so it would be great to warn if that's
228-
* about to happen
229-
*/
230-
mask = ~(entry->res->end - entry->res->start);
231-
232-
write_gcr_reg1_base(entry->res->start);
233-
write_gcr_reg1_mask(mask | CM_GCR_REGn_MASK_CMTGT_IOCU0);
234-
dev_info(dev, "PCI coherence region base: 0x%08llx, mask/settings: 0x%08llx\n",
235-
(unsigned long long)read_gcr_reg1_base(),
236-
(unsigned long long)read_gcr_reg1_mask());
237-
}
238-
239-
return 0;
240-
}
241-
242211
static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
243212
struct device_node *node,
244213
int slot)
@@ -557,12 +526,6 @@ static int mt7621_pci_probe(struct platform_device *pdev)
557526
goto remove_resets;
558527
}
559528

560-
err = setup_cm_memory_region(bridge);
561-
if (err) {
562-
dev_err(dev, "error setting up iocu mem regions\n");
563-
goto remove_resets;
564-
}
565-
566529
return mt7621_pcie_register_host(bridge);
567530

568531
remove_resets:
@@ -598,3 +561,5 @@ static struct platform_driver mt7621_pci_driver = {
598561
},
599562
};
600563
builtin_platform_driver(mt7621_pci_driver);
564+
565+
MODULE_LICENSE("GPL v2");

drivers/pci/probe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,6 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
898898

899899
bridge->bus = bus;
900900

901-
/* Temporarily move resources off the list */
902-
list_splice_init(&bridge->windows, &resources);
903901
bus->sysdata = bridge->sysdata;
904902
bus->ops = bridge->ops;
905903
bus->number = bus->busn_res.start = bridge->busnr;
@@ -925,6 +923,8 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
925923
if (err)
926924
goto free;
927925

926+
/* Temporarily move resources off the list */
927+
list_splice_init(&bridge->windows, &resources);
928928
err = device_add(&bridge->dev);
929929
if (err) {
930930
put_device(&bridge->dev);

0 commit comments

Comments
 (0)