From 5a904e5637cff1d708dc67098004f83ba9e84c54 Mon Sep 17 00:00:00 2001
From: Sergei Poselenov <sposelenov@emcraft.com>
Date: Tue, 27 May 2008 11:35:02 +0200
Subject: [PATCH] USB: add new configuration variable CONFIG_PCI_OHCI_DEVNO

In case of several PCI USB controllers on a board this variable
specifys which controller to use.
See doc/README.generic_usb_ohci for details.

Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>
---
 doc/README.generic_usb_ohci | 6 ++++++
 drivers/usb/usb_ohci.c      | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/README.generic_usb_ohci b/doc/README.generic_usb_ohci
index c44c501474..147ea514ae 100644
--- a/doc/README.generic_usb_ohci
+++ b/doc/README.generic_usb_ohci
@@ -51,6 +51,12 @@ You'll need to define
 
 	CONFIG_PCI_OHCI
 
+If you have several USB PCI controllers, define
+
+	CONFIG_PCI_OHCI_DEVNO: number of the OHCI device in PCI list
+
+If undefined, the first instance found in PCI space will be used.
+
 PCI Controllers need to do byte swapping on register accesses, so they
 should to define:
 
diff --git a/drivers/usb/usb_ohci.c b/drivers/usb/usb_ohci.c
index ee0f2e45b1..318478afa4 100644
--- a/drivers/usb/usb_ohci.c
+++ b/drivers/usb/usb_ohci.c
@@ -53,6 +53,9 @@
 
 #if defined(CONFIG_PCI_OHCI)
 # include <pci.h>
+#if !defined(CONFIG_PCI_OHCI_DEVNO)
+#define CONFIG_PCI_OHCI_DEVNO	0
+#endif
 #endif
 
 #include <malloc.h>
@@ -1818,7 +1821,7 @@ int usb_lowlevel_init(void)
 	gohci.sleeping = 0;
 	gohci.irq = -1;
 #ifdef CONFIG_PCI_OHCI
-	pdev = pci_find_devices(ohci_pci_ids, 0);
+	pdev = pci_find_devices(ohci_pci_ids, CONFIG_PCI_OHCI_DEVNO);
 
 	if (pdev != -1) {
 		u16 vid, did;
-- 
2.39.5