Soren Brinkmann | f9a3119 | 2016-03-06 20:14:51 -0800 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 4b32e62 | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Soren Brinkmann | f9a3119 | 2016-03-06 20:14:51 -0800 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soren Brinkmann | f9a3119 | 2016-03-06 20:14:51 -0800 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef CDNS_UART_H |
| 8 | #define CDNS_UART_H |
Soren Brinkmann | f9a3119 | 2016-03-06 20:14:51 -0800 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <drivers/console.h> |
Julius Werner | 1343ad5 | 2017-09-18 17:01:06 -0700 | [diff] [blame] | 11 | |
Soren Brinkmann | f9a3119 | 2016-03-06 20:14:51 -0800 | [diff] [blame] | 12 | /* This is very minimalistic and will only work in QEMU. */ |
| 13 | |
| 14 | /* CADENCE Registers */ |
| 15 | #define R_UART_CR 0 |
| 16 | #define R_UART_CR_RXRST (1 << 0) /* RX logic reset */ |
| 17 | #define R_UART_CR_TXRST (1 << 1) /* TX logic reset */ |
| 18 | #define R_UART_CR_RX_EN (1 << 2) /* RX enabled */ |
| 19 | #define R_UART_CR_TX_EN (1 << 4) /* TX enabled */ |
| 20 | |
| 21 | #define R_UART_SR 0x2C |
| 22 | #define UART_SR_INTR_REMPTY_BIT 1 |
| 23 | #define UART_SR_INTR_TFUL_BIT 4 |
Michal Simek | bd0992d | 2017-10-06 10:24:17 +0200 | [diff] [blame] | 24 | #define UART_SR_INTR_TEMPTY_BIT 3 |
Soren Brinkmann | f9a3119 | 2016-03-06 20:14:51 -0800 | [diff] [blame] | 25 | |
| 26 | #define R_UART_TX 0x30 |
| 27 | #define R_UART_RX 0x30 |
| 28 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 29 | #ifndef __ASSEMBLER__ |
Julius Werner | 1343ad5 | 2017-09-18 17:01:06 -0700 | [diff] [blame] | 30 | |
Antonio Nino Diaz | 4b32e62 | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 31 | #include <stdint.h> |
Julius Werner | 1343ad5 | 2017-09-18 17:01:06 -0700 | [diff] [blame] | 32 | |
Julius Werner | 1343ad5 | 2017-09-18 17:01:06 -0700 | [diff] [blame] | 33 | /* |
| 34 | * Initialize a new Cadence console instance and register it with the console |
| 35 | * framework. The |console| pointer must point to storage that will be valid |
| 36 | * for the lifetime of the console, such as a global or static local variable. |
| 37 | * Its contents will be reinitialized from scratch. |
| 38 | */ |
Alexei Colin | f04146b | 2018-11-09 17:36:55 -0500 | [diff] [blame] | 39 | int console_cdns_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, |
Andre Przywara | 8ccc4a4 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 40 | console_t *console); |
Julius Werner | 1343ad5 | 2017-09-18 17:01:06 -0700 | [diff] [blame] | 41 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 42 | #endif /*__ASSEMBLER__*/ |
Julius Werner | 1343ad5 | 2017-09-18 17:01:06 -0700 | [diff] [blame] | 43 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 44 | #endif /* CDNS_UART_H */ |