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