[U-Boot] [PATCH v2 2/5] debug_uart: Support board-specific UART initialisation

Bin Meng bmeng.cn at gmail.com
Mon Oct 19 05:17:49 CEST 2015


On Mon, Oct 19, 2015 at 9:51 AM, Simon Glass <sjg at chromium.org> wrote:
> Some boards need to set things up before the debug UART can be used. On
> these boards a call to debug_uart_init() is insufficient. When this option
> is enabled, the function board_debug_uart_init() will be called when
> debug_uart_init() is called. You can put any code here that is needed to
> set up the UART ready for use, such as set pin multiplexing or enable
> clocks.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2: None
>
>  drivers/serial/Kconfig | 11 +++++++++++
>  include/debug_uart.h   | 14 ++++++++++++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index ddb725d..39f6500 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -109,6 +109,17 @@ config DEBUG_UART_SHIFT
>           value. Use this value to specify the shift to use, where 0=byte
>           registers, 2=32-bit word registers, etc.
>
> +config DEBUG_UART_BOARD_INIT
> +       bool "Enable board-specific debug UART init"
> +       depends on DEBUG_UART
> +       help
> +         Some boards need to set things up before the debug UART can be used.
> +         On these boards a call to debug_uart_init() is insufficient. When
> +         this option is enabled, the function board_debug_uart_init() will
> +         be called when debug_uart_init() is called. You can put any code
> +         here that is needed to set up the UART ready for use, such as set
> +         pin multiplexing or enable clocks.
> +
>  config ROCKCHIP_SERIAL
>         bool "Rockchip on-chip UART support"
>         depends on ARCH_ROCKCHIP && DM_SERIAL
> diff --git a/include/debug_uart.h b/include/debug_uart.h
> index 257ba00..a6b7ce8 100644
> --- a/include/debug_uart.h
> +++ b/include/debug_uart.h
> @@ -42,6 +42,11 @@
>   * - Define _debug_uart_putc() as static inline (avoiding stack usage)
>   * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the
>   *     functionality (printch(), etc.)
> + *
> + * If your board needs additional init for the UART to work, enable
> + * CONFIG_DEBUG_UART_BOARD_INIT and write a function called
> + * board_debug_uart_init() to perform that init. When debug_uart_init() is
> + * called, the init will happen automatically.
>   */
>
>  /**
> @@ -57,6 +62,14 @@
>   */
>  void debug_uart_init(void);
>
> +#ifdef CONFIG_DEBUG_UART_BOARD_INIT
> +void board_debug_uart_init(void);
> +#else
> +static inline void board_debug_uart_init(void)
> +{
> +}
> +#endif
> +
>  /**
>   * printch() - Output a character to the debug UART
>   *
> @@ -136,6 +149,7 @@ void printhex8(uint value);
>  \
>         void debug_uart_init(void) \
>         { \
> +               board_debug_uart_init(); \
>                 _debug_uart_init(); \
>         } \
>
> --

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>


More information about the U-Boot mailing list