It was originally designed such that if usbdebug_init() was called before cbmem_initialize(), it would fetch the already-initialized state from CBMEM. This changed when cbmem_find() behaviour changed to require cbmem_initialize() to be called first. As a result, ramstage had to reinitialize all of the EHCI controller and USB endpoints on entry. This was slow, specially with AMD hardware where one can scan USB ports to probe for the debug dongle. For postcar and ramstage, move usbdebug entry such that it is triggered from CBMEM_INIT_HOOK instead of console_init(). Side-effect of this is usbdebug console shows 'coreboot-xxx ... starting...' line only for romstage. Initialisation for usbdebug is never done in postcar. If you have USBDEBUG_IN_ROMSTAGE=n, postcar will not have console output on usb either. While at it, fix also some other __PRE_RAM__ cases to ENV_ROMSTAGE and alike. Change-Id: If8ab973321a801abc5529f3ff68c5dccae9512ad Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/21443 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
/*
|
|
* This file is part of the coreboot project.
|
|
*
|
|
* Copyright (C) 2007 AMD
|
|
* Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef _CONSOLE_USB_H_
|
|
#define _CONSOLE_USB_H_
|
|
|
|
#include <rules.h>
|
|
#include <stdint.h>
|
|
|
|
void usbdebug_init(void);
|
|
|
|
void usb_tx_byte(int idx, unsigned char data);
|
|
void usb_tx_flush(int idx);
|
|
unsigned char usb_rx_byte(int idx);
|
|
int usb_can_rx_byte(int idx);
|
|
|
|
#define __CONSOLE_USB_ENABLE__ (IS_ENABLED(CONFIG_CONSOLE_USB) && \
|
|
((ENV_ROMSTAGE && IS_ENABLED(CONFIG_USBDEBUG_IN_ROMSTAGE)) || \
|
|
(ENV_POSTCAR && IS_ENABLED(CONFIG_USBDEBUG_IN_ROMSTAGE)) || \
|
|
ENV_RAMSTAGE))
|
|
|
|
#define USB_PIPE_FOR_CONSOLE 0
|
|
#define USB_PIPE_FOR_GDB 0
|
|
|
|
#if __CONSOLE_USB_ENABLE__
|
|
static inline void __usbdebug_init(void) { usbdebug_init(); }
|
|
static inline void __usb_tx_byte(u8 data)
|
|
{
|
|
usb_tx_byte(USB_PIPE_FOR_CONSOLE, data);
|
|
}
|
|
static inline void __usb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_CONSOLE); }
|
|
#else
|
|
static inline void __usbdebug_init(void) {}
|
|
static inline void __usb_tx_byte(u8 data) {}
|
|
static inline void __usb_tx_flush(void) {}
|
|
#endif
|
|
|
|
/* */
|
|
#if 0 && IS_ENABLED(CONFIG_GDB_STUB) && \
|
|
((ENV_ROMSTAGE && IS_ENABLED(CONFIG_USBDEBUG_IN_ROMSTAGE)) \
|
|
|| ENV_RAMSTAGE)
|
|
static inline void __gdb_hw_init(void) { usbdebug_init(); }
|
|
static inline void __gdb_tx_byte(u8 data)
|
|
{
|
|
usb_tx_byte(USB_PIPE_FOR_GDB, data);
|
|
}
|
|
static inline void __gdb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_GDB); }
|
|
static inline u8 __gdb_rx_byte(void)
|
|
{
|
|
return usb_rx_byte(USB_PIPE_FOR_GDB);
|
|
}
|
|
#endif
|
|
|
|
#endif /* _CONSOLE_USB_H_ */
|