diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2013-07-05 21:38:54 +0300 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2013-07-10 23:22:36 +0200 |
commit | 4d409b5fc27e44f7c902f8402f661db56d62ac74 (patch) | |
tree | a8bdcd3bfa898c6fcdf32bc5ff6b4d22627dc1a9 /src/console | |
parent | d686acd1a358518e8f37452c0e826a3ac381cbe2 (diff) |
usbdebug: Refactor disable logic
Output to usbdebug console needs to be disabled until hardware is
initialized and while EHCI BAR is relocated. Add separate field
ehci_info to point to back to EHCI context when hardware is ready
to transfer data.
Change-Id: If7d441b561819ab8ae23ed9f3f320f7742ed231e
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/3624
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
Diffstat (limited to 'src/console')
-rw-r--r-- | src/console/usbdebug_console.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/console/usbdebug_console.c b/src/console/usbdebug_console.c index 9cfb45491a..d6747792fe 100644 --- a/src/console/usbdebug_console.c +++ b/src/console/usbdebug_console.c @@ -28,7 +28,7 @@ static struct ehci_debug_info dbg_info; static struct device_operations *ehci_drv_ops; static struct device_operations ehci_dbg_ops; -void set_ehci_base(unsigned ehci_base) +static void usbdebug_re_enable(unsigned ehci_base) { unsigned diff; @@ -39,36 +39,28 @@ void set_ehci_base(unsigned ehci_base) dbg_info.ehci_regs -= diff; dbg_info.ehci_debug -= diff; dbg_info.ehci_caps = (void*)ehci_base; + dbg_info.status |= DBGP_EP_ENABLED; } -void set_ehci_debug(unsigned ehci_debug) +static void usbdebug_disable(void) { - dbg_info.ehci_debug = (void*)ehci_debug; -} - -unsigned get_ehci_debug(void) -{ - return (unsigned)dbg_info.ehci_debug; + dbg_info.status &= ~DBGP_EP_ENABLED; } static void pci_ehci_set_resources(struct device *dev) { struct resource *res; - u32 base; - u32 usb_debug; printk(BIOS_DEBUG, "%s EHCI Debug Port hook triggered\n", dev_path(dev)); - usb_debug = get_ehci_debug(); - set_ehci_debug(0); + usbdebug_disable(); if (ehci_drv_ops->set_resources) ehci_drv_ops->set_resources(dev); - res = find_resource(dev, EHCI_BAR_INDEX); - set_ehci_debug(usb_debug); - if (!res) return; - base = res->base; - set_ehci_base(base); + 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)); } @@ -105,7 +97,7 @@ static unsigned char dbgp_rx_byte(void) { unsigned char data = 0xff; - if (dbg_info.ehci_debug) + if (dbgp_ep_is_active(&dbg_info)) dbgp_bulk_read_x(&dbg_info, &data, 1); return data; @@ -118,7 +110,7 @@ static void dbgp_tx_flush(void) static int dbgp_tst_byte(void) { - return (int)dbg_info.ehci_debug; + return dbgp_ep_is_active(&dbgp_info); } static const struct console_driver usbdebug_direct_console __console = { |