mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
drivers/serial:support arm cmsdk drivers
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
f3b7329816
commit
0040e9a239
@@ -26,6 +26,10 @@ if(CONFIG_SERIAL_GDBSTUB)
|
||||
list(APPEND SRCS serial_gdbstub.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_CMSDK_UART)
|
||||
list(APPEND SRCS serial_cmsdk.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SERIAL_RXDMA)
|
||||
list(APPEND SRCS serial_dma.c)
|
||||
elseif(CONFIG_SERIAL_TXDMA)
|
||||
|
||||
@@ -61,6 +61,15 @@ if UART_PL011
|
||||
source "drivers/serial/Kconfig-pl011"
|
||||
endif
|
||||
|
||||
menuconfig CMSDK_UART
|
||||
bool "CMSDK UART Chip support"
|
||||
select ARCH_HAVE_SERIAL_TERMIOS
|
||||
default n
|
||||
|
||||
if CMSDK_UART
|
||||
source "drivers/serial/Kconfig-cmsdk"
|
||||
endif # CMSDK_UART
|
||||
|
||||
menuconfig 16550_UART
|
||||
bool "16550 UART Chip support"
|
||||
select ARCH_HAVE_SERIAL_TERMIOS
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if CMSDK_UART
|
||||
|
||||
config CMSDK_UART0
|
||||
bool "CMSDK UART0"
|
||||
default n
|
||||
|
||||
if CMSDK_UART0
|
||||
|
||||
config CMSDK_UART0_BASE
|
||||
hex "CMSDK UART0 base address"
|
||||
|
||||
config CMSDK_UART0_CLOCK
|
||||
int "CMSDK UART0 clock"
|
||||
|
||||
config CMSDK_UART0_TX_IRQ
|
||||
int "CMSDK UART0 TX IRQ number"
|
||||
|
||||
config CMSDK_UART0_RX_IRQ
|
||||
int "CMSDK UART0 RX IRQ number"
|
||||
|
||||
config CMSDK_UART0_OV_IRQ
|
||||
int "CMSDK UART0 OVERRUN IRQ number"
|
||||
|
||||
config CMSDK_UART0_BAUD
|
||||
int "CMSDK UART0 BAUD"
|
||||
default 115200
|
||||
|
||||
config CMSDK_UART0_RXBUFSIZE
|
||||
int "CMSDK UART0 RX buffer size"
|
||||
default 256
|
||||
---help---
|
||||
CMSDK UART0 RX buffer size. Default: 256
|
||||
|
||||
config CMSDK_UART0_TXBUFSIZE
|
||||
int "CMSDK UART0 TX buffer size"
|
||||
default 256
|
||||
---help---
|
||||
CMSDK UART0 TX buffer size. Default: 256
|
||||
|
||||
endif # CMSDK_UART0
|
||||
|
||||
config CMSDK_UART1
|
||||
bool "CMSDK UART1"
|
||||
default n
|
||||
|
||||
if CMSDK_UART1
|
||||
|
||||
config CMSDK_UART1_BASE
|
||||
hex "CMSDK UART1 base address"
|
||||
|
||||
config CMSDK_UART1_CLOCK
|
||||
int "CMSDK UART1 clock"
|
||||
|
||||
config CMSDK_UART1_TX_IRQ
|
||||
int "CMSDK UART1 TX IRQ number"
|
||||
|
||||
config CMSDK_UART1_RX_IRQ
|
||||
int "CMSDK UART1 RX IRQ number"
|
||||
|
||||
config CMSDK_UART1_OV_IRQ
|
||||
int "CMSDK UART1 OVERRUN IRQ number"
|
||||
|
||||
config CMSDK_UART1_BAUD
|
||||
int "CMSDK UART1 BAUD"
|
||||
default 115200
|
||||
|
||||
config CMSDK_UART1_RXBUFSIZE
|
||||
int "CMSDK UART1 RX buffer size"
|
||||
default 256
|
||||
---help---
|
||||
CMSDK UART1 RX buffer size. Default: 256
|
||||
|
||||
config CMSDK_UART1_TXBUFSIZE
|
||||
int "CMSDK UART1 TX buffer size"
|
||||
default 256
|
||||
---help---
|
||||
CMSDK UART1 TX buffer size. Default: 256
|
||||
|
||||
endif # CMSDK_UART1
|
||||
|
||||
config CMSDK_UART2
|
||||
bool "CMSDK UART2"
|
||||
default n
|
||||
|
||||
if CMSDK_UART2
|
||||
|
||||
config CMSDK_UART2_BASE
|
||||
hex "CMSDK UART2 base address"
|
||||
|
||||
config CMSDK_UART2_CLOCK
|
||||
hex "CMSDK UART2 clock"
|
||||
|
||||
config CMSDK_UART2_TX_IRQ
|
||||
int "CMSDK UART2 TX IRQ number"
|
||||
|
||||
config CMSDK_UART2_RX_IRQ
|
||||
int "CMSDK UART2 RX IRQ number"
|
||||
|
||||
config CMSDK_UART2_OV_IRQ
|
||||
int "CMSDK UART2 OVERRUN IRQ number"
|
||||
|
||||
config CMSDK_UART2_BAUD
|
||||
int "CMSDK UART2 BAUD"
|
||||
default 115200
|
||||
|
||||
config CMSDK_UART2_RXBUFSIZE
|
||||
int "CMSDK UART2 RX buffer size"
|
||||
default 256
|
||||
---help---
|
||||
CMSDK UART2 RX buffer size. Default: 256
|
||||
|
||||
config CMSDK_UART2_TXBUFSIZE
|
||||
int "CMSDK UART2 TX buffer size"
|
||||
default 256
|
||||
---help---
|
||||
CMSDK UART2 TX buffer size. Default: 256
|
||||
|
||||
endif # CMSDK_UART2
|
||||
|
||||
choice
|
||||
prompt "CMSDK Serial Console"
|
||||
default CMSDK_NO_SERIAL_CONSOLE
|
||||
depends on DEV_CONSOLE
|
||||
|
||||
config CMSDK_UART0_SERIAL_CONSOLE
|
||||
bool "CMSDK UART0 serial console"
|
||||
depends on CMSDK_UART0
|
||||
select SERIAL_CONSOLE
|
||||
|
||||
config CMSDK_UART1_SERIAL_CONSOLE
|
||||
bool "CMSDK UART1 serial console"
|
||||
depends on CMSDK_UART1
|
||||
select SERIAL_CONSOLE
|
||||
|
||||
config CMSDK_UART2_SERIAL_CONSOLE
|
||||
bool "CMSDK UART2 serial console"
|
||||
depends on CMSDK_UART2
|
||||
select SERIAL_CONSOLE
|
||||
|
||||
config CMSDK_NO_SERIAL_CONSOLE
|
||||
bool "No CMSDK serial console"
|
||||
|
||||
endchoice # CMSDK Serial Console
|
||||
|
||||
endif # CMSDK_UART
|
||||
@@ -26,6 +26,10 @@ ifeq ($(CONFIG_SERIAL_GDBSTUB),y)
|
||||
CSRCS += serial_gdbstub.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CMSDK_UART),y)
|
||||
CSRCS += serial_cmsdk.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SERIAL_RXDMA),y)
|
||||
CSRCS += serial_dma.c
|
||||
else ifeq ($(CONFIG_SERIAL_TXDMA),y)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/serial/uart_cmsdk.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SERIAL_UART_CMSDK_H
|
||||
#define __INCLUDE_NUTTX_SERIAL_UART_CMSDK_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Register offsets */
|
||||
|
||||
#define UART_RBR_OFFSET 0 /* Receiver Buffer Register */
|
||||
#define UART_THR_OFFSET 0 /* Transmit Holding Register */
|
||||
#define UART_STATE_OFFSET 1 /* Interrupt State Register */
|
||||
#define UART_CTRL_OFFSET 2 /* Interrupt Control Register */
|
||||
#define UART_INTSTS_OFFSET 3 /* Interrupt Status Clear Register */
|
||||
#define UART_BAUDDIV_OFFSET 4 /* Baud rate divider Register */
|
||||
|
||||
/* Register bit definitions */
|
||||
|
||||
#define UART_STATE_TX_BUF_FULL (1 << 0)
|
||||
#define UART_STATE_RX_BUF_FULL (1 << 1)
|
||||
#define UART_STATE_TX_BUF_OVERRUN (1 << 2)
|
||||
#define UART_STATE_RX_BUF_OVERRUN (1 << 3)
|
||||
|
||||
#define UART_CTRL_TX_ENABLE (1 << 0)
|
||||
#define UART_CTRL_RX_ENABLE (1 << 1)
|
||||
#define UART_CTRL_TX_INT_ENABLE (1 << 2)
|
||||
#define UART_CTRL_RX_INT_ENABLE (1 << 3)
|
||||
#define UART_CTRL_TX_OVERRUN_INT_ENABLE (1 << 4)
|
||||
#define UART_CTRL_RX_OVERRUN_INT_ENABLE (1 << 5)
|
||||
#define UART_CTRL_TSTMODE_ENABLE (1 << 6)
|
||||
#define UART_CTRL_ALLIE (0x3C)
|
||||
|
||||
#define UART_INTSTATUS_TX (1 << 0)
|
||||
#define UART_INTSTATUS_RX (1 << 1)
|
||||
#define UART_INTSTATUS_TX_OVERRUN (1 << 2)
|
||||
#define UART_INTSTATUS_RX_OVERRUN (1 << 3)
|
||||
|
||||
#define UART_BAUDDIV_MIN (16)
|
||||
#define UART_BAUDDIV_MAX (0xfffff)
|
||||
|
||||
#if defined(CONFIG_CMSDK_UART0_SERIAL_CONSOLE) && defined(CONFIG_CMSDK_UART0)
|
||||
# undef CONFIG_CMSDK_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_CMSDK_UART2_SERIAL_CONSOLE
|
||||
# define HAVE_CMSDK_CONSOLE 1
|
||||
#elif defined(CONFIG_CMSDK_UART1_SERIAL_CONSOLE) && defined(CONFIG_CMSDK_UART1)
|
||||
# undef CONFIG_CMSDK_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_CMSDK_UART2_SERIAL_CONSOLE
|
||||
# define HAVE_CMSDK_CONSOLE 1
|
||||
#elif defined(CONFIG_CMSDK_UART2_SERIAL_CONSOLE) && defined(CONFIG_CMSDK_UART2)
|
||||
# undef CONFIG_CMSDK_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_CMSDK_UART1_SERIAL_CONSOLE
|
||||
# define HAVE_CMSDK_CONSOLE 1
|
||||
#else
|
||||
# undef CONFIG_CMSDK_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_CMSDK_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_CMSDK_UART2_SERIAL_CONSOLE
|
||||
# undef HAVE_CMSDK_CONSOLE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public functions prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmsdk_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 uart_serialinit.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void cmsdk_earlyserialinit(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmsdk_serialinit
|
||||
*
|
||||
* Description:
|
||||
* Register serial console and serial ports. This assumes that
|
||||
* up_earlyserialinit was called previously.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void cmsdk_serialinit(void);
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_SERIAL_UART_CMSDK_H */
|
||||
Reference in New Issue
Block a user