blob: 327c1d9ba6516ec898ff38d25aa4433627a221e4 [file] [log] [blame]
Soren Brinkmannf9a31192016-03-06 20:14:51 -08001/*
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01002 * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
Soren Brinkmannf9a31192016-03-06 20:14:51 -08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmannf9a31192016-03-06 20:14:51 -08005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef CDNS_UART_H
8#define CDNS_UART_H
Soren Brinkmannf9a31192016-03-06 20:14:51 -08009
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <drivers/console.h>
Julius Werner1343ad52017-09-18 17:01:06 -070011
Soren Brinkmannf9a31192016-03-06 20:14:51 -080012/* 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 Simekbd0992d2017-10-06 10:24:17 +020024#define UART_SR_INTR_TEMPTY_BIT 3
Prasad Kummarie870c862023-08-07 20:41:58 +053025#define UART_SR_INTR_TACTIVE_BIT 11
Soren Brinkmannf9a31192016-03-06 20:14:51 -080026
27#define R_UART_TX 0x30
28#define R_UART_RX 0x30
29
Julius Werner53456fc2019-07-09 13:49:11 -070030#ifndef __ASSEMBLER__
Julius Werner1343ad52017-09-18 17:01:06 -070031
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +010032#include <stdint.h>
Julius Werner1343ad52017-09-18 17:01:06 -070033
Julius Werner1343ad52017-09-18 17:01:06 -070034/*
35 * Initialize a new Cadence console instance and register it with the console
36 * framework. The |console| pointer must point to storage that will be valid
37 * for the lifetime of the console, such as a global or static local variable.
38 * Its contents will be reinitialized from scratch.
39 */
Alexei Colinf04146b2018-11-09 17:36:55 -050040int console_cdns_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud,
Andre Przywara8ccc4a42020-01-25 00:58:35 +000041 console_t *console);
Julius Werner1343ad52017-09-18 17:01:06 -070042
Julius Werner53456fc2019-07-09 13:49:11 -070043#endif /*__ASSEMBLER__*/
Julius Werner1343ad52017-09-18 17:01:06 -070044
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000045#endif /* CDNS_UART_H */