BCM2708: Add some build configuration and support logic for low-level serial otput (unfinished)

This commit is contained in:
Gregory Nutt 2017-10-17 16:26:52 -06:00
parent 851fa7ba85
commit d160ae8a32
9 changed files with 367 additions and 17 deletions

View File

@ -16,7 +16,163 @@ config ARCH_CHIP_BCM2835
endchoice # BCM2708 Configuration Option
menuconfig BCM2708_GPIO_IRQ
menu "BCM2708 Peripheral Selections"
config BCM2708_MINI_UART
bool "Mini-UART"
config BCM2708_PL011_UART
bool "PL011UART"
endmenu # BCM2708 Peripheral Selections
menu "BCM2708 UART Configuration"
depends on BCM2708_MINI_UART || BCM2708_PL011_UART
menu "BCM2708 Mini-UART Configuration"
depends on BCM2708_MINI_UART
config BCM2708_MINI_UART_RXBUFSIZE
int "Receive buffer size"
default 256
---help---
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config BCM2708_MINI_UART_TXBUFSIZE
int "Transmit buffer size"
default 256
---help---
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config BCM2708_MINI_UART_BAUD
int "BAUD rate"
default 115200
---help---
The configured BAUD of the UART.
config BCM2708_MINI_UART_BITS
int "Character size"
default 8
---help---
The number of bits. Must be either 7 or 8.
config BCM2708_MINI_UART_PARITY
int "Parity setting"
range 0 2
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config BCM2708_MINI_UART_2STOP
int "use 2 stop bits"
default 0
---help---
1=Two stop bits
config BCM2708_MINI_UART_IFLOWCONTROL
bool "Mini-UART RTS flow control"
default n
select SERIAL_IFLOWCONTROL
---help---
Enable BCM2708_MINI_UART RTS flow control
config BCM2708_MINI_UART_OFLOWCONTROL
bool "Mini-UART CTS flow control"
default n
select SERIAL_OFLOWCONTROL
---help---
Enable BCM2708_MINI_UART CTS flow control
endmenu # BCM2708 Mini-UART Configuration
menu "BCM2708 PL011 UART Configuration"
depends on BCM2708_PL011_UART
config BCM2708_PL011_UART_RXBUFSIZE
int "Receive buffer size"
default 256
---help---
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config BCM2708_PL011_UART_TXBUFSIZE
int "Transmit buffer size"
default 256
---help---
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config BCM2708_PL011_UART_BAUD
int "BAUD rate"
default 115200
---help---
The configured BAUD of the UART.
config BCM2708_PL011_UART_BITS
int "Character size"
default 8
---help---
The number of bits. Must be either 7 or 8.
config BCM2708_PL011_UART_PARITY
int "Parity setting"
range 0 2
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config BCM2708_PL011_UART_2STOP
int "use 2 stop bits"
default 0
---help---
1=Two stop bits
config BCM2708_PL011_UART_IFLOWCONTROL
bool "UART RTS flow control"
default n
select SERIAL_IFLOWCONTROL
---help---
Enable UART RTS flow control. CD, DSR, DTR, and RI are not supported.
config BCM2708_PL011_UART_OFLOWCONTROL
bool "UART CTS flow control"
default n
select SERIAL_OFLOWCONTROL
---help---
Enable UART CTS flow control. CD, DSR, DTR, and RI are not supported.
endmenu # BCM2708 PL011 UART Configuration
choice
prompt "BCM2708 Serial Console"
default BCM2708_NO_SERIAL_CONSOLE
depends on DEV_CONSOLE
config BCM2708_MINI_UART_SERIAL_CONSOLE
bool "Use Mini-UART as the serial console"
depends on BCM2708_MINI_UART
select OTHER_SERIAL_CONSOLE
---help---
Use the Mini-UART as the serial console
config BCM2708_PL011_UART_SERIAL_CONSOLE
bool "Use PO011 UART as the serial console"
depends on BCM2708_PL011_UART
select OTHER_SERIAL_CONSOLE
---help---
Use the PO011 UART as the serial console
config BCM2708_NO_SERIAL_CONSOLE
bool "No serial console"
---help---
No serial based console
endchoice # BCM2708 Serial Console
endmenu # BCM2708 UART Configuration
config BCM2708_GPIO_IRQ
bool "GPIO pin interrupts"
---help---
Enable support for interrupting GPIO pins

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
CHIP_CSRCS += bcm_tickless.c bcm_gpio.c bcm_lowputc.c
ifeq ($(CONFIG_BCM2708_GPIO_IRQ),y)
CHIP_CSRCS += bcm_gpioint.c

View File

@ -46,10 +46,34 @@
* Pre-processor Definitions
****************************************************************************/
/* Configuration **********************************************************/
/* Configuration ************************************************************/
/* Is there a UART enabled? */
/* Is there a UART enabled? The BCM2835 device has two UARTS. On mini UART
* and and PL011 UART.
*/
/* Is there a serial console? */
#if defined(CONFIG_BCM2708_MINI_UART) || defined(CONFIG_BCM2708_PL011_UART)
# define BCM_HAVE_UART
#endif
#undef SUPPRESS_CONSOLE_CONFIG
#ifdef CONFIG_SUPPRESS_UART_CONFIG
# define SUPPRESS_CONSOLE_CONFIG 1
#endif
/* Is there a serial console? It could be on UART1-5 */
#if defined(CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE) && defined(CONFIG_BCM2708_MINI_UART)
# undef CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE
# define BCM_HAVE_UART_CONSOLE 1
#elif defined(CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE) && defined(CONFIG_BCM2708_PL011_UART)
# undef CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE
# define BCM_HAVE_UART_CONSOLE 1
#else
# warning "No valid serial console Setting"
# undef CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE
# undef CONFIG_BCM2708_PL011_UART_SERIAL_CONSOLE
# undef BCM_HAVE_UART_CONSOLE
#endif
#endif /* __ARCH_ARM_SRC_BCM2708_BCM_CONFIG_H */

View File

@ -0,0 +1,168 @@
/****************************************************************************
* arch/arm/src/bcm2708/bcm_lowputc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: 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 <assert.h>
#include "up_arch.h"
#include "chip/bcm2708_uart_spi.h"
#include "bcm_config.h"
#include "bcm_lowputc.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#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
# define BCM_CONSOLE_2STOP CONFIG_BCM2708_PL011_UART_2STOP
# endif
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef BCM_HAVE_UART_CONSOLE
static const struct uart_config_s g_console_config =
{
.baud = BCM_CONSOLE_BAUD, /* Configured baud */
.parity = BCM_CONSOLE_PARITY, /* 0=none, 1=odd, 2=even */
.bits = BCM_CONSOLE_BITS, /* Number of bits (5-9) */
.stopbits2 = BCM_CONSOLE_2STOP, /* true: Configure with 2 stop bits instead of 1 */
};
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: bcm_lowsetup
*
* Description:
* Called at the very beginning of _start. Performs low level
* initialization including setup of the console UART. This UART done
* early so that the serial console is available for debugging very early
* in the boot sequence.
*
****************************************************************************/
void bcm_lowsetup(void)
{
#ifndef CONFIG_SUPPRESS_UART_CONFIG
#ifdef CONFIG_BCM2708_MINI_UART
/* Disable and configure the Mini-UART */
# warning Missing logic
/* Configure Mini-pins: RXD and TXD. Also configure RTS and CTS if flow
* control is enabled.
*/
# warning Missing logic
#endif
#ifdef CONFIG_BCM2708_PL011_UART
/* Disable and configure the PL011 UART */
# warning Missing logic
/* Configure PL001 pins: RXD and TXD. Also configure RTS and CTS if flow
* control is enabled.
*/
# warning Missing logic
#endif
#ifdef BCM_HAVE_UART_CONSOLE
/* Configure the serial console for initial, non-interrupt driver mode */
(void)bcm_uart_configure(BCM_CONSOLE_VBASE, &g_console_config);
#endif
#endif /* CONFIG_SUPPRESS_UART_CONFIG */
}
/************************************************************************************
* Name: bcm_uart_configure
*
* Description:
* Configure a UART for non-interrupt driven operation
*
************************************************************************************/
#ifdef BCM_HAVE_UART
int bcm_uart_configure(uint32_t base, FAR const struct uart_config_s *config)
{
#ifndef CONFIG_SUPPRESS_UART_CONFIG
# warning Missing logic
#endif
return OK;
}
#endif /* BCM_HAVE_UART */
/************************************************************************************
* 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.)
*
************************************************************************************/
#if defined(BCM_HAVE_UART) && defined(CONFIG_DEBUG_FEATURES)
void bcm_lowputc(int ch)
{
#warning Missing logic
}
#endif

View File

@ -54,7 +54,7 @@
* Public Types
****************************************************************************/
#ifdef IMX_HAVE_UART
#ifdef BCM_HAVE_UART
/* This structure describes the configuration of an UART */
struct uart_config_s
@ -91,7 +91,7 @@ void bcm_lowsetup(void);
*
****************************************************************************/
#ifdef IMX_HAVE_UART
#ifdef BCM_HAVE_UART
int bcm_uart_configure(uint32_t base, FAR const struct uart_config_s *config);
#endif
@ -105,7 +105,7 @@ int bcm_uart_configure(uint32_t base, FAR const struct uart_config_s *config);
*
************************************************************************************/
#if defined(IMX_HAVE_UART) && defined(CONFIG_DEBUG_FEATURES)
#if defined(BCM_HAVE_UART) && defined(CONFIG_DEBUG_FEATURES)
void bcm_lowputc(int ch);
#else
# define bcm_lowputc(ch)

View File

@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_BCM2708_IMX_MEMORYMAP_H
#define __ARCH_ARM_SRC_BCM2708_IMX_MEMORYMAP_H
#ifndef __ARCH_ARM_SRC_BCM2708_BCM_MEMORYMAP_H
#define __ARCH_ARM_SRC_BCM2708_BCM_MEMORYMAP_H
/****************************************************************************
* Included Files
@ -73,4 +73,4 @@ struct section_mapping_s
extern const struct section_mapping_s g_section_mapping[];
extern const size_t g_num_mappings;
#endif /* __ARCH_ARM_SRC_BCM2708_IMX_MEMORYMAP_H */
#endif /* __ARCH_ARM_SRC_BCM2708_BCM_MEMORYMAP_H */

View File

@ -100,7 +100,7 @@ void bcm_earlyserialinit(void);
*
****************************************************************************/
#if defined(USE_EARLYSERIALINIT) && defined(IMX6_HAVE_UART)
#if defined(USE_EARLYSERIALINIT) && defined(BCM6_HAVE_UART)
void uart_earlyserialinit(void);
#endif
@ -113,7 +113,7 @@ void uart_earlyserialinit(void);
*
****************************************************************************/
#ifdef IMX6_HAVE_UART
#ifdef BCM6_HAVE_UART
void uart_serialinit(void);
#endif

View File

@ -66,14 +66,14 @@
#define BCM_PCM_CLK_OFFSET 0x00101098 /* PCM Clock */
#define BCM_RNG_OFFSET 0x00104000 /* Hardware RNG */
#define BCM_GPIO_OFFSET 0x00200000 /* GPIO peripheral */
#define BCM_UART0_OFFSET 0x00201000 /* UART0 peripheral */
#define BCM_PL011_OFFSET 0x00201000 /* PL011 UART peripheral */
#define BCM_MMCI0_OFFSET 0x00202000 /* MMC0 peripheral */
#define BCM_I2S_OFFSET 0x00203000 /* PCM/I2S audio interface */
#define BCM_SPI0_OFFSET 0x00204000 /* Serial interface peripheral */
#define BCM_BSC0_OFFSET 0x00205000 /* Broadcom Serial Controller 0 (BSC0) */
#define BCM_PWM_OFFSET 0x0020c000 /* Pulse Width Modulator interface */
#define BCM_BSCSPI_OFFSET 0x00214000 /* BSC/SPI peripheral */
#define BCM_UART1_OFFSET 0x00215000 /* UART1 peripheral */
#define BCM_AUX_OFFSET 0x00215000 /* AUX/Mini-UART/SPI peripherals */
#define BCM_EMMC_OFFSET 0x00300000 /* External Mass Media Controller */
#define BCM_SMI_OFFSET 0x00600000 /* SMI */
#define BCM_BSC1_OFFSET 0x00804000 /* Broadcom Serial Controller 1 (BSC1) */
@ -128,14 +128,14 @@
#define BCM_PCM_CLK_VBASE (BCM_PERIPH_VSECTION + BCM_PCM_CLK_OFFSET)
#define BCM_RNG_VBASE (BCM_PERIPH_VSECTION + BCM_RNG_OFFSET)
#define BCM_GPIO_VBASE (BCM_PERIPH_VSECTION + BCM_GPIO_OFFSET)
#define BCM_UART0_VBASE (BCM_PERIPH_VSECTION + BCM_UART0_OFFSET)
#define BCM_PL011_VBASE (BCM_PERIPH_VSECTION + BCM_PL011_OFFSET)
#define BCM_MMCI0_VBASE (BCM_PERIPH_VSECTION + BCM_MMCI0_OFFSET)
#define BCM_I2S_VBASE (BCM_PERIPH_VSECTION + BCM_I2S_OFFSET)
#define BCM_SPI0_VBASE (BCM_PERIPH_VSECTION + BCM_SPI0_OFFSET)
#define BCM_BSC0_VBASE (BCM_PERIPH_VSECTION + BCM_BSC0_OFFSET)
#define BCM_PWM_VBASE (BCM_PERIPH_VSECTION + BCM_PWM_OFFSET)
#define BCM_BSCSPI_VBASE (BCM_PERIPH_VSECTION + BCM_BSCSPI_OFFSET)
#define BCM_UART1_VBASE (BCM_PERIPH_VSECTION + BCM_UART1_OFFSET)
#define BCM_AUX_VBASE (BCM_PERIPH_VSECTION + BCM_AUX_OFFSET)
#define BCM_EMMC_VBASE (BCM_PERIPH_VSECTION + BCM_EMMC_OFFSET)
#define BCM_SMI_VBASE (BCM_PERIPH_VSECTION + BCM_SMI_OFFSET)
#define BCM_BSC1_VBASE (BCM_PERIPH_VSECTION + BCM_BSC1_OFFSET)

View File

@ -9,6 +9,8 @@ CONFIG_ARCH_CHIP_BCM2835=y
CONFIG_ARCH_LOWVECTORS=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH="arm"
CONFIG_BCM2708_MINI_UART_SERIAL_CONSOLE=y
CONFIG_BCM2708_MINI_UART=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BOOT_RUNFROMSDRAM=y
CONFIG_BUILTIN=y