BCM2708: Add hooks to support both Mini- and PL011 UARTs.

This commit is contained in:
Gregory Nutt 2017-10-18 08:09:24 -06:00
parent 8dd1bb03b2
commit 3316103efd
6 changed files with 216 additions and 43 deletions

View File

@ -72,7 +72,7 @@ endif
# BCM2708-specific source files.
CHIP_CSRCS = bcm_boot.c bcm_memorymap.c bcm_clockconfig.c bcm_irq.c
CHIP_CSRCS += bcm_tickless.c bcm_gpio.c bcm_aux.c bcm_lowputc.c
CHIP_CSRCS += bcm_tickless.c bcm_gpio.c bcm_aux.c bcm_lowputc.c bcm_serial.c
ifeq ($(CONFIG_BCM2708_GPIO_IRQ),y)
CHIP_CSRCS += bcm_gpioint.c

View File

@ -119,9 +119,16 @@ void bcm_aux_irqinitialize(void)
{
/* Disable all AUX interrupt sources (Also disables all peripheral
* register accesses).
*
* Keep the Mini-UART enabled if we are using it for the system console
* (since it was initialized earlier in the boot-up sequence).
*/
#ifdef CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE
putreg32(BCM_AUX_ENB_MU, BCM_AUX_ENB);
#else
putreg32(0, BCM_AUX_ENB);
#endif
/* Attach and enable the AUX interrupt */

View File

@ -57,13 +57,11 @@
#ifdef BCM_HAVE_UART_CONSOLE
# if defined(CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE)
# define BCM_CONSOLE_VBASE BCM_AUX_OFFSET
# define BCM_CONSOLE_BAUD CONFIG_BCM2708_MINI_UART_BAUD
# define BCM_CONSOLE_BITS CONFIG_BCM2708_MINI_UART_BITS
# define BCM_CONSOLE_PARITY CONFIG_BCM2708_MINI_UART_PARITY
# define BCM_CONSOLE_2STOP CONFIG_BCM2708_MINI_UART_2STOP
# elif defined(CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE)
# define BCM_CONSOLE_VBASE BCM_PL011_VBASE
# define BCM_CONSOLE_BAUD CONFIG_BCM2708_PL011_UART_BAUD
# define BCM_CONSOLE_BITS CONFIG_BCM2708_PL011_UART_BITS
# define BCM_CONSOLE_PARITY CONFIG_BCM2708_PL011_UART_PARITY
@ -123,24 +121,32 @@ void bcm_lowsetup(void)
# warning Missing logic
#endif
#ifdef BCM_HAVE_UART_CONSOLE
/* Configure the serial console for initial, non-interrupt driver mode */
#if defined(CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE)
/* Configure the mini-uart serial console for initial, non-interrupt
* driven mode.
*/
(void)bcm_uart_configure(BCM_CONSOLE_VBASE, &g_console_config);
(void)bcm_miniuart_configure(&g_console_config);
#elif defined(CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE)
/* Configure the pl011-uart serial console for initial, non-interrupt
* driven mode.
*/
(void)bcm_pl011uart_configure(&g_console_config);
#endif
#endif /* CONFIG_SUPPRESS_UART_CONFIG */
}
/************************************************************************************
* Name: bcm_uart_configure
/****************************************************************************
* Name: bcm_[mini|pl011]uart_configure
*
* Description:
* Configure a UART for non-interrupt driven operation
* Configure the Mini- or PL011 UART for non-interrupt driven operation
*
************************************************************************************/
****************************************************************************/
#ifdef BCM_HAVE_UART
int bcm_uart_configure(uint32_t base, FAR const struct uart_config_s *config)
#ifdef CONFIG_BCM2708_MINI_UART
int bcm_miniuart_configure(FAR const struct uart_config_s *config)
{
#ifndef CONFIG_SUPPRESS_UART_CONFIG
# warning Missing logic
@ -148,17 +154,28 @@ int bcm_uart_configure(uint32_t base, FAR const struct uart_config_s *config)
return OK;
}
#endif /* BCM_HAVE_UART */
#endif
/************************************************************************************
#ifdef CONFIG_BCM2708_PL011_UART
int bcm_pl011uart_configure(FAR const struct uart_config_s *config)
{
#ifndef CONFIG_SUPPRESS_UART_CONFIG
# warning Missing logic
#endif
return OK;
}
#endif
/****************************************************************************
* Name: bcm_lowputc
*
* Description:
* Output a byte with as few system dependencies as possible. This will even work
* BEFORE the console is initialized if we are booting from U-Boot (and the same
* UART is used for the console, of course.)
* Output a byte with as few system dependencies as possible. This will
* even work BEFORE the console is initialized if we are booting from
* U-Boot (and the same UART is used for the console, of course.)
*
************************************************************************************/
****************************************************************************/
#if defined(BCM_HAVE_UART) && defined(CONFIG_DEBUG_FEATURES)
void bcm_lowputc(int ch)

View File

@ -84,15 +84,19 @@ struct uart_config_s
void bcm_lowsetup(void);
/****************************************************************************
* Name: bcm_uart_configure
* Name: bcm_[mini|pl011]uart_configure
*
* Description:
* Configure a UART for non-interrupt driven operation
* Configure the Mini- or PL011 UART for non-interrupt driven operation
*
****************************************************************************/
#ifdef BCM_HAVE_UART
int bcm_uart_configure(uint32_t base, FAR const struct uart_config_s *config);
#ifdef CONFIG_BCM2708_MINI_UART
int bcm_miniuart_configure(FAR const struct uart_config_s *config);
#endif
#ifdef CONFIG_BCM2708_PL011_UART
int bcm_pl011uart_configure(FAR const struct uart_config_s *config);
#endif
/************************************************************************************

View File

@ -0,0 +1,115 @@
/****************************************************************************
* arch/arm/src/bcm/bcm_serialinit.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include "bcm_config.h"
#include "bcm_serial.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if !defined(HAVE_UART_DEVICE) && !defined(HAVE_LPUART_DEVICE)
# undef CONFIG_KINETS_LPUART_LOWEST
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: bcm_earlyserialinit
*
* Description:
* Performs the low level UART initialization early in debug so that the
* serial console will be available during bootup. This must be called
* before up_serialinit.
*
****************************************************************************/
#ifdef USE_EARLYSERIALINIT
void bcm_earlyserialinit(void)
{
#ifdef CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE
/* Initialize the Mini-UART console */
bcm_miniuart_earlyserialinit();
#endif
#ifdef CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE
/* Initialize the PL011-UART console */
bcm_pl011uart_earlyserialinit();
#endif
}
#endif
/****************************************************************************
* Name: up_serialinit
*
* Description:
* Register all the serial console and serial ports. This assumes
* that bcm_earlyserialinit was called previously.
*
****************************************************************************/
#ifdef USE_SERIALDRIVER
void up_serialinit(void)
{
#ifdef CONFIG_BCM2708_MINI_UART
/* Register the Mini-UART serial console and serial ports. This function
* will be called by uart_serialinit() if the Mini-UART is enabled.
*/
bcm_miniuart_serialinit();
#endif
#ifdef CONFIG_BCM2708_PL011_UART
/* Register the PL011-UART serial console and serial ports. This function
* will be called by uart_serialinit() if the Mini-UART is enabled.
*/
bcm_pl011uart_serialinit();
#endif
}
#endif /* USE_SERIALDRIVER */

View File

@ -46,23 +46,11 @@
#include "bcm_config.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Inline Functions
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
@ -88,22 +76,38 @@ extern "C"
#ifdef USE_EARLYSERIALINIT
void bcm_earlyserialinit(void);
#endif
/****************************************************************************
* Name: uart_earlyserialinit
* Name: bcm_miniuart_earlyserialinit
*
* Description:
* Performs the low level UART initialization early in debug so that the
* serial console will be available during bootup. This must be called
* before up_serialinit.
* Performs the low level Mini-UART initialization early in debug so that
* the Mini-UART serial console will be available during bootup. This
* function will be called by bcm_earlyserialinit() if the Mini-UART is
* selected for the serial console.
*
****************************************************************************/
#if defined(USE_EARLYSERIALINIT) && defined(BCM6_HAVE_UART)
void uart_earlyserialinit(void);
#ifdef CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE
void bcm_miniuart_earlyserialinit(void);
#endif
/****************************************************************************
* Name: bcm_pl011uart_earlyserialinit
*
* Description:
* Performs the low level PL011-UART initialization early in debug so that
* the PL011-UART serial console will be available during bootup. This
* function will be called by bcm_earlyserialinit() if the PL011-UART is
* selected for the serial console.
*
****************************************************************************/
#ifdef CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE
void bcm_pl011uart_earlyserialinit(void);
#endif
#endif /* USE_EARLYSERIALINIT */
/****************************************************************************
* Name: uart_serialinit
*
@ -113,10 +117,36 @@ void uart_earlyserialinit(void);
*
****************************************************************************/
#ifdef BCM6_HAVE_UART
#ifdef USE_SERIALDRIVER
void uart_serialinit(void);
/****************************************************************************
* Name: bcm_miniuart_serialinit
*
* Description:
* Register the Mini-UART serial console and serial ports. This function
* will be called by uart_serialinit() if the Mini-UART is enabled.
*
****************************************************************************/
#ifdef CONFIG_BCM2708_MINI_UART
void bcm_miniuart_serialinit(void);
#endif
/****************************************************************************
* Name: bcm_pl011uart_serialinit
*
* Description:
* Register the PL011-UART serial console and serial ports. This function
* will be called by uart_serialinit() if the Mini-UART is enabled.
*
****************************************************************************/
#ifdef CONFIG_BCM2708_PL011_UART
void bcm_pl011uart_serialinit(void);
#endif
#endif /* USE_SERIALDRIVER */
#undef EXTERN
#if defined(__cplusplus)
}