[coreboot-gerrit] New patch to review for coreboot: 43eaae5 usbdebug: Move EHCI BAR relocation code

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Mon Jul 8 08:47:06 CEST 2013


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3626

-gerrit

commit 43eaae5bbd29be73e0e49758818f7dd9426a4bc4
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sat Jul 6 11:57:00 2013 +0300

    usbdebug: Move EHCI BAR relocation code
    
    There are other uses for EHCI debug port besides console, so move
    EHCI relocation code from console to lib.
    
    Change-Id: I95cddd31be529351d9ec68f14782cc3cbe08c617
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/console/usbdebug_console.c | 59 ------------------------------------------
 src/lib/usbdebug.c             | 59 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/src/console/usbdebug_console.c b/src/console/usbdebug_console.c
index 80d7bfc..0e69f87 100644
--- a/src/console/usbdebug_console.c
+++ b/src/console/usbdebug_console.c
@@ -21,65 +21,6 @@
 #include <string.h>
 #include <console/console.h>
 #include <usbdebug.h>
-#include <device/pci.h>
-#include <pc80/mc146818rtc.h>
-
-static struct device_operations *ehci_drv_ops;
-static struct device_operations ehci_dbg_ops;
-
-static void usbdebug_re_enable(unsigned ehci_base)
-{
-	struct ehci_debug_info *dbg_info = dbgp_ehci_info();
-	unsigned diff;
-
-	if (!dbg_info->ehci_debug)
-		return;
-
-	diff = (unsigned)dbg_info.ehci_caps - ehci_base;
-	dbg_info->ehci_regs -= diff;
-	dbg_info->ehci_debug -= diff;
-	dbg_info->ehci_caps = (void*)ehci_base;
-	dbg_info->ehci_info = dbg_info;
-}
-
-static void usbdebug_disable(void)
-{
-	struct ehci_debug_info *dbg_info = dbgp_ehci_info();
-	dbg_info->ehci_info = NULL;
-}
-
-static void pci_ehci_set_resources(struct device *dev)
-{
-	struct resource *res;
-
-	printk(BIOS_DEBUG, "%s EHCI Debug Port hook triggered\n", dev_path(dev));
-	usbdebug_disable();
-
-	if (ehci_drv_ops->set_resources)
-		ehci_drv_ops->set_resources(dev);
-	res = find_resource(dev, EHCI_BAR_INDEX);
-	if (!res)
-		return;
-
-	usbdebug_re_enable((u32)res->base);
-	report_resource_stored(dev, res, "");
-	printk(BIOS_DEBUG, "%s EHCI Debug Port relocated\n", dev_path(dev));
-}
-
-void pci_ehci_read_resources(struct device *dev)
-{
-	if (!ehci_drv_ops) {
-		memcpy(&ehci_dbg_ops, dev->ops, sizeof(ehci_dbg_ops));
-		ehci_drv_ops = dev->ops;
-		ehci_dbg_ops.set_resources = pci_ehci_set_resources;
-		dev->ops = &ehci_dbg_ops;
-		printk(BIOS_DEBUG, "%s EHCI BAR hook registered\n", dev_path(dev));
-	} else {
-		printk(BIOS_DEBUG, "More than one caller of %s from %s\n", __func__, dev_path(dev));
-	}
-
-	pci_dev_read_resources(dev);
-}
 
 static void dbgp_init(void)
 {
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index 97d083b..0fea9c6 100644
--- a/src/lib/usbdebug.c
+++ b/src/lib/usbdebug.c
@@ -21,6 +21,7 @@
 #include <stddef.h>
 #include <console/console.h>
 #include <arch/io.h>
+#include <device/pci.h>
 #include <arch/byteorder.h>
 
 #include <usb_ch9.h>
@@ -88,6 +89,8 @@
 
 #if !defined(__PRE_RAM__) && !defined(__SMM__)
 static struct ehci_debug_info glob_dbg_info;
+static struct device_operations *ehci_drv_ops;
+static struct device_operations ehci_dbg_ops;
 #endif
 
 static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
@@ -597,6 +600,62 @@ void usbdebug_tx_flush(struct ehci_debug_info *dbg_info)
 	}
 }
 
+#if !defined(__PRE_RAM__) && !defined(__SMM__)
+static void usbdebug_re_enable(unsigned ehci_base)
+{
+	struct ehci_debug_info *dbg_info = dbgp_ehci_info();
+	unsigned diff;
+
+	if (!dbg_info->ehci_debug)
+		return;
+
+	diff = (u32)dbg_info->ehci_caps - ehci_base;
+	dbg_info->ehci_regs -= diff;
+	dbg_info->ehci_debug -= diff;
+	dbg_info->ehci_caps = (void*)ehci_base;
+	dbg_info->ehci_info = dbg_info;
+}
+
+static void usbdebug_disable(void)
+{
+	struct ehci_debug_info *dbg_info = dbgp_ehci_info();
+	dbg_info->ehci_info = NULL;
+}
+
+static void pci_ehci_set_resources(struct device *dev)
+{
+	struct resource *res;
+
+	printk(BIOS_DEBUG, "%s EHCI Debug Port hook triggered\n", dev_path(dev));
+	usbdebug_disable();
+
+	if (ehci_drv_ops->set_resources)
+		ehci_drv_ops->set_resources(dev);
+	res = find_resource(dev, EHCI_BAR_INDEX);
+	if (!res)
+		return;
+
+	usbdebug_re_enable((u32)res->base);
+	report_resource_stored(dev, res, "");
+	printk(BIOS_DEBUG, "%s EHCI Debug Port relocated\n", dev_path(dev));
+}
+
+void pci_ehci_read_resources(struct device *dev)
+{
+	if (!ehci_drv_ops) {
+		memcpy(&ehci_dbg_ops, dev->ops, sizeof(ehci_dbg_ops));
+		ehci_drv_ops = dev->ops;
+		ehci_dbg_ops.set_resources = pci_ehci_set_resources;
+		dev->ops = &ehci_dbg_ops;
+		printk(BIOS_DEBUG, "%s EHCI BAR hook registered\n", dev_path(dev));
+	} else {
+		printk(BIOS_DEBUG, "More than one caller of %s from %s\n", __func__, dev_path(dev));
+	}
+
+	pci_dev_read_resources(dev);
+}
+#endif
+
 struct ehci_debug_info *dbgp_ehci_info(void)
 {
 #if __PRE_RAM__



More information about the coreboot-gerrit mailing list