1/* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef __SOC_UART_H__ 17#define __SOC_UART_H__ 18 19#include "asm/platform.h" 20#include "los_typedef.h" 21#include "los_base.h" 22#ifdef __cplusplus 23#if __cplusplus 24extern "C" { 25#endif /* __cplusplus */ 26#endif /* __cplusplus */ 27 28#define CONFIG_UART0_BAUDRATE 115200 29#define CONFIG_UART_CLK_INPUT (24000000) // 24M or 6M 30 31#define UART0 0 32#define UART0_ENABLE 1 33#define UART0_DMA_RX_PERI 4 34 35#define TTYS0 "/dev/ttyS0" 36 37#define CONSOLE_UART UART0 38 39#define CONSOLE_UART_BAUDRATE 115200 40#define UART_NUM 1 41#if (CONSOLE_UART == UART0) 42 #define TTY_DEVICE "/dev/uartdev-0" 43 #define UART_REG_BASE UART0_REG_BASE 44 #define NUM_HAL_INTERRUPT_UART NUM_HAL_INTERRUPT_UART0 45#endif 46 47#define uart_clk_cfg(uart_num, flag) ({ \ 48 unsigned int tmp = 0; \ 49 tmp = GET_UINT32(CRG_REG_BASE + 0x01B8); \ 50 if (flag) \ 51 tmp |= (1<<(uart_num)); \ 52 else \ 53 tmp &= ~(1<<(uart_num)); \ 54 WRITE_UINT32(tmp, CRG_REG_BASE + 0x01B8); \ 55 }) 56 57extern VOID UartPuts(const CHAR *s, UINT32 len, BOOL isLock); 58extern UINT32 UartPutsReg(UINTPTR base, const CHAR *s, UINT32 len, BOOL isLock); 59#define UART_WITHOUT_LOCK 0 60#define UART_WITH_LOCK 1 61 62#ifdef __cplusplus 63#if __cplusplus 64} 65#endif /* __cplusplus */ 66#endif /* __cplusplus */ 67 68#endif 69