Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH v2]: MIPS: PCI: Add pre_enable hook, minor readability fixes
@ 2015-05-25 18:17 Joshua Kinard
  0 siblings, 0 replies; only message in thread
From: Joshua Kinard @ 2015-05-25 18:17 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Linux MIPS List

From: Joshua Kinard <kumba@gentoo.org>

This patch adds a hook "pre_enable", to the core MIPS PCI code.  It is
used by the IP30 Port to setup the PCI resources prior to probing the
BRIDGE and detecting available PCI devices.  It also adds some minor
whitespace to improve readability.

Signed-off-by: Joshua Kinard <kumba@gentoo.org>
---
 arch/mips/sgi-ip27/ip27-xtalk.c |   87 +++++++++++++++++++++---------
 1 file changed, 61 insertions(+), 26 deletions(-)

This version corrects several issues detected by checkpatch.pl.

linux-mips-pci-pre_enable.patch
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index d969299..b51ccbd 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -43,6 +43,9 @@ struct pci_controller {
 	   and XFree86. Eventually will be removed. */
 	unsigned int need_domain_info;
 
+	/* called in pcibios_enable_resources */
+	int (*pre_enable)(struct pci_controller *, struct pci_dev *, int);
+
 	int iommu;
 
 	/* Optional access methods for reading/writing the bus number
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index b8a0bf5..57031e2 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -261,14 +261,19 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 	u16 cmd, old_cmd;
 	int idx;
 	struct resource *r;
+	struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
 
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
 	old_cmd = cmd;
-	for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
+	for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
 		/* Only set up the requested stuff */
-		if (!(mask & (1<<idx)))
+		if (!(mask & (1 << idx)))
 			continue;
 
+		if (hose->pre_enable)
+			if (hose->pre_enable(hose, dev, idx) < 0)
+				return -EINVAL;
+
 		r = &dev->resource[idx];
 		if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
 			continue;
@@ -291,6 +296,7 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 		       pci_name(dev), old_cmd, cmd);
 		pci_write_config_word(dev, PCI_COMMAND, cmd);
 	}
+
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-25 18:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-25 18:17 [PATCH v2]: MIPS: PCI: Add pre_enable hook, minor readability fixes Joshua Kinard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox